[Scummvm-cvs-logs] SF.net SVN: scummvm: [29633] scummvm/trunk/backends/platform/iphone
vinterstum at users.sourceforge.net
vinterstum at users.sourceforge.net
Sun Nov 25 10:37:15 CET 2007
Revision: 29633
http://scummvm.svn.sourceforge.net/scummvm/?rev=29633&view=rev
Author: vinterstum
Date: 2007-11-25 01:37:15 -0800 (Sun, 25 Nov 2007)
Log Message:
-----------
Suspend ScummVM when the button is hit (or a call is received), putting it in a sleep loop until it's resumed
Modified Paths:
--------------
scummvm/trunk/backends/platform/iphone/iphone_common.h
scummvm/trunk/backends/platform/iphone/iphone_main.m
scummvm/trunk/backends/platform/iphone/iphone_video.h
scummvm/trunk/backends/platform/iphone/iphone_video.m
scummvm/trunk/backends/platform/iphone/osys_iphone.cpp
scummvm/trunk/backends/platform/iphone/osys_iphone.h
Modified: scummvm/trunk/backends/platform/iphone/iphone_common.h
===================================================================
--- scummvm/trunk/backends/platform/iphone/iphone_common.h 2007-11-25 03:17:48 UTC (rev 29632)
+++ scummvm/trunk/backends/platform/iphone/iphone_common.h 2007-11-25 09:37:15 UTC (rev 29633)
@@ -30,7 +30,9 @@
kInputMouseDragged,
kInputMouseSecondToggled,
kInputOrientationChanged,
- kInputKeyPressed
+ kInputKeyPressed,
+ kInputApplicationSuspended,
+ kInputApplicationResumed
};
// We need this to be able to call functions from/in Objective-C.
Modified: scummvm/trunk/backends/platform/iphone/iphone_main.m
===================================================================
--- scummvm/trunk/backends/platform/iphone/iphone_main.m 2007-11-25 03:17:48 UTC (rev 29632)
+++ scummvm/trunk/backends/platform/iphone/iphone_main.m 2007-11-25 09:37:15 UTC (rev 29633)
@@ -88,6 +88,18 @@
[NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil];
}
+- (void)applicationSuspend:(GSEventRef)event {
+ [self setApplicationBadge:NSLocalizedString(@"ON", nil)];
+ [_view applicationSuspend];
+}
+
+- (void)applicationResume:(GSEventRef)event {
+ [self removeApplicationBadge];
+ [UIHardware _setStatusBarHeight:0.0f];
+ [self setStatusBarMode:2 orientation:0 duration:0.0f fenceID:0];
+ [_view applicationResume];
+}
+
- (void)deviceOrientationChanged:(GSEvent *)event {
int screenOrientation = GSEventDeviceOrientation(event);
[_view deviceOrientationChanged: screenOrientation];
Modified: scummvm/trunk/backends/platform/iphone/iphone_video.h
===================================================================
--- scummvm/trunk/backends/platform/iphone/iphone_video.h 2007-11-25 03:17:48 UTC (rev 29632)
+++ scummvm/trunk/backends/platform/iphone/iphone_video.h 2007-11-25 09:37:15 UTC (rev 29633)
@@ -71,6 +71,10 @@
- (void)deviceOrientationChanged:(int)orientation;
+- (void)applicationSuspend;
+
+- (void)applicationResume;
+
@end
Modified: scummvm/trunk/backends/platform/iphone/iphone_video.m
===================================================================
--- scummvm/trunk/backends/platform/iphone/iphone_video.m 2007-11-25 03:17:48 UTC (rev 29632)
+++ scummvm/trunk/backends/platform/iphone/iphone_video.m 2007-11-25 09:37:15 UTC (rev 29633)
@@ -399,5 +399,27 @@
//printf("handleTapWithCount(%i, %i)\n", count, fingerCount);
}
+- (void)applicationSuspend {
+ [self addEvent:
+ [[NSDictionary alloc] initWithObjectsAndKeys:
+ [NSNumber numberWithInt:kInputApplicationSuspended], @"type",
+ [NSNumber numberWithFloat:0], @"x",
+ [NSNumber numberWithFloat:0], @"y",
+ nil
+ ]
+ ];
+}
+
+- (void)applicationResume {
+ [self addEvent:
+ [[NSDictionary alloc] initWithObjectsAndKeys:
+ [NSNumber numberWithInt:kInputApplicationResumed], @"type",
+ [NSNumber numberWithFloat:0], @"x",
+ [NSNumber numberWithFloat:0], @"y",
+ nil
+ ]
+ ];
+}
+
@end
Modified: scummvm/trunk/backends/platform/iphone/osys_iphone.cpp
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_iphone.cpp 2007-11-25 03:17:48 UTC (rev 29632)
+++ scummvm/trunk/backends/platform/iphone/osys_iphone.cpp 2007-11-25 09:37:15 UTC (rev 29633)
@@ -63,7 +63,7 @@
_secondaryTapped(false), _lastSecondaryTap(0), _landscapeMode(true),
_needEventRestPeriod(false), _mouseClickAndDragEnabled(false),
_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false),
- _mouseDirty(false)
+ _mouseDirty(false), _timeSuspended(0)
{
_queuedInputEvent.type = (Common::EventType)0;
_lastDrawnMouseRect = Common::Rect(0, 0, 0, 0);
@@ -711,6 +711,11 @@
dirtyFullScreen();
}
break;
+
+ case kInputApplicationSuspended:
+ suspendLoop();
+ break;
+
case kInputKeyPressed:
int keyPressed = (int)xUnit;
int ascii = keyPressed;
@@ -782,13 +787,32 @@
return false;
}
+void OSystem_IPHONE::suspendLoop() {
+ bool done = false;
+ int eventType;
+ float xUnit, yUnit;
+ uint32 startTime = getMillis();
+
+ AudioQueueStop(s_AudioQueue.queue, true);
+
+ while (!done) {
+ if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit))
+ if ((InputEvent)eventType == kInputApplicationResumed)
+ done = true;
+ usleep(100000);
+ }
+
+ AudioQueueStart(s_AudioQueue.queue, NULL);
+ _timeSuspended += getMillis() - startTime;
+}
+
uint32 OSystem_IPHONE::getMillis() {
//printf("getMillis()\n");
struct timeval currentTime;
gettimeofday(¤tTime, NULL);
return (uint32)(((currentTime.tv_sec - _startTime.tv_sec) * 1000) +
- ((currentTime.tv_usec - _startTime.tv_usec) / 1000));
+ ((currentTime.tv_usec - _startTime.tv_usec) / 1000)) - _timeSuspended;
}
void OSystem_IPHONE::delayMillis(uint msecs) {
Modified: scummvm/trunk/backends/platform/iphone/osys_iphone.h
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_iphone.h 2007-11-25 03:17:48 UTC (rev 29632)
+++ scummvm/trunk/backends/platform/iphone/osys_iphone.h 2007-11-25 09:37:15 UTC (rev 29633)
@@ -64,7 +64,8 @@
uint16 _screenHeight;
struct timeval _startTime;
-
+ uint32 _timeSuspended;
+
bool _mouseVisible;
byte *_mouseBuf;
byte _mouseKeyColour;
@@ -158,7 +159,7 @@
void dirtyMouseCursor();
void dirtyFullScreen();
void clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h);
-
+ void suspendLoop();
static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);
static int timerHandler(int t);
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list