[Scummvm-cvs-logs] SF.net SVN: scummvm:[33372] scummvm/branches/branch-0-12-0/backends/ platform/iphone

vinterstum at users.sourceforge.net vinterstum at users.sourceforge.net
Mon Jul 28 14:30:20 CEST 2008


Revision: 33372
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33372&view=rev
Author:   vinterstum
Date:     2008-07-28 12:30:19 +0000 (Mon, 28 Jul 2008)

Log Message:
-----------
Fixed up audio and removal of the status bar after sleep mode. Added a touchpad mode as an input alternative

Modified Paths:
--------------
    scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_keyboard.m
    scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_main.m
    scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_video.m
    scummvm/branches/branch-0-12-0/backends/platform/iphone/osys_iphone.cpp
    scummvm/branches/branch-0-12-0/backends/platform/iphone/osys_iphone.h

Modified: scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_keyboard.m
===================================================================
--- scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_keyboard.m	2008-07-28 11:50:36 UTC (rev 33371)
+++ scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_keyboard.m	2008-07-28 12:30:19 UTC (rev 33372)
@@ -54,8 +54,7 @@
 @implementation SoftKeyboard
 
 - (id)initWithFrame:(CGRect)frame {
-	//self = [super initWithFrame:frame];
-	self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)];
+	self = [super initWithFrame:frame];
 	inputDelegate = nil;
 	inputView = [[TextInputHandler alloc] initWithKeyboard:self];
 	return self;

Modified: scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_main.m
===================================================================
--- scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_main.m	2008-07-28 11:50:36 UTC (rev 33371)
+++ scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_main.m	2008-07-28 12:30:19 UTC (rev 33372)
@@ -79,11 +79,8 @@
 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
 	// hide the status bar
 	[UIHardware _setStatusBarHeight:0.0f];
-	//[self setStatusBarMode:2 orientation:0 duration:0.0f fenceID:0];
+	[self setStatusBarHidden:YES animated:NO];
 
-	//[self setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO];
-	[self setStatusBarHidden:YES animated:YES];
-
 	_window = [[UIWindow alloc] initWithContentRect:  [UIHardware fullScreenApplicationContentRect]];
 	[_window retain];
 
@@ -103,9 +100,13 @@
 
 - (void)applicationResume:(GSEventRef)event {
 	[self removeApplicationBadge];
+	[_view applicationResume];
+	
+	// Workaround, need to "hide" and unhide the statusbar to properly remove it,
+	// since the Springboard has put it back without apparently flagging our application.
+	[self setStatusBarHidden:NO animated:NO]; // hide status bar
 	[UIHardware _setStatusBarHeight:0.0f];
-	[self setStatusBarHidden:YES animated:YES];
-	[_view applicationResume];
+	[self setStatusBarHidden:YES animated:NO]; // hide status bar
 }
 
 - (void)deviceOrientationChanged:(GSEvent *)event {

Modified: scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_video.m
===================================================================
--- scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_video.m	2008-07-28 11:50:36 UTC (rev 33371)
+++ scummvm/branches/branch-0-12-0/backends/platform/iphone/iphone_video.m	2008-07-28 12:30:19 UTC (rev 33372)
@@ -169,10 +169,6 @@
 		nil
 	];
 
-	if (_screenSurface != nil) {
-		//[[sharedInstance _layer] removeSublayer: screenLayer];
-	}
-
 	//("Allocating surface: %d\n", allocSize);
 	_screenSurface = CoreSurfaceBufferCreate((CFDictionaryRef)dict);
 	//printf("Surface created.\n");

Modified: scummvm/branches/branch-0-12-0/backends/platform/iphone/osys_iphone.cpp
===================================================================
--- scummvm/branches/branch-0-12-0/backends/platform/iphone/osys_iphone.cpp	2008-07-28 11:50:36 UTC (rev 33371)
+++ scummvm/branches/branch-0-12-0/backends/platform/iphone/osys_iphone.cpp	2008-07-28 12:30:19 UTC (rev 33372)
@@ -63,7 +63,7 @@
 	_overlayVisible(false), _overlayBuffer(NULL), _fullscreen(NULL),
 	_mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0),
 	_secondaryTapped(false), _lastSecondaryTap(0), _screenOrientation(kScreenOrientationFlippedLandscape),
-	_needEventRestPeriod(false), _mouseClickAndDragEnabled(false),
+	_needEventRestPeriod(false), _mouseClickAndDragEnabled(false), _touchpadModeEnabled(false),
 	_gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false),
 	_mouseDirty(false), _timeSuspended(0)
 {
@@ -665,8 +665,8 @@
 	float xUnit, yUnit;
 
 	if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit)) {
-		int x;
-		int y;
+		int x = 0;
+		int y = 0;
 		switch (_screenOrientation) {
 			case kScreenOrientationPortrait:
 				x = (int)(xUnit * _screenWidth);
@@ -690,7 +690,12 @@
 				// secondary finger is lifted. Need to make sure we get out of that mode.
 				_secondaryTapped = false;
 
-				warpMouse(x, y);
+				if (_touchpadModeEnabled) {
+					_lastPadX = x;
+					_lastPadY = y;
+				} else
+					warpMouse(x, y);
+
 				// event.type = Common::EVENT_MOUSEMOVE;
 				// event.mouse.x = _mouseX;
 				// event.mouse.y = _mouseY;
@@ -769,15 +774,19 @@
 							GUI::TimedMessageDialog dialog(dialogMsg, 1500);
 							dialog.runModal();
 							return false;
+
 						} else if (vecXNorm > 0.75 && vecYNorm >  -0.5 && vecYNorm < 0.5) {
 							// Swipe right
-							// _secondaryTapped = !_secondaryTapped;
-							// _gestureStartX = x;
-							// _gestureStartY = y;
-							//
-							// GUI::TimedMessageDialog dialog("Forcing toggle of pressed state.", 1500);
-							// dialog.runModal();
+							_touchpadModeEnabled = !_touchpadModeEnabled;
+							const char *dialogMsg;
+							if (_touchpadModeEnabled)
+								dialogMsg = "Touchpad mode enabled.";
+							else
+								dialogMsg = "Touchpad mode disabled.";
+							GUI::TimedMessageDialog dialog(dialogMsg, 1500);
+							dialog.runModal();
 							return false;
+
 						} else if (vecXNorm < -0.75 && vecYNorm >  -0.5 && vecYNorm < 0.5) {
 							// Swipe left
 							return false;
@@ -786,10 +795,36 @@
 					} else
 						return false;
 				} else {
+					int mouseNewPosX;
+					int mouseNewPosY;
+					if (_touchpadModeEnabled ) {
+						int deltaX = _lastPadX - x;
+						int deltaY = _lastPadY - y;	
+						_lastPadX = x;
+						_lastPadY = y;
+						
+						mouseNewPosX = (int)(_mouseX - deltaX / 0.5f);
+						mouseNewPosY = (int)(_mouseY - deltaY / 0.5f);
+						
+						if (mouseNewPosX < 0)
+							mouseNewPosX = 0;
+						else if (mouseNewPosX > _screenWidth)
+							mouseNewPosX = _screenWidth;
+
+						if (mouseNewPosY < 0)
+							mouseNewPosY = 0;
+						else if (mouseNewPosY > _screenHeight)
+							mouseNewPosY = _screenHeight;
+							
+					} else {
+						mouseNewPosX = x;
+						mouseNewPosY = y;
+					}
+					
 					event.type = Common::EVENT_MOUSEMOVE;
-					event.mouse.x = x;
-					event.mouse.y = y;
-					warpMouse(x, y);
+					event.mouse.x = mouseNewPosX;
+					event.mouse.y = mouseNewPosY;
+					warpMouse(mouseNewPosX, mouseNewPosY);
 				}
 				break;
 			case kInputMouseSecondToggled:
@@ -811,8 +846,8 @@
 					else
 						return false;
 				} else {
-					if (curTime - _lastSecondaryDown < 250 ) {
-						if (curTime - _lastSecondaryTap < 250 && !_overlayVisible) {
+					if (curTime - _lastSecondaryDown < 400 ) {
+						if (curTime - _lastSecondaryTap < 400 && !_overlayVisible) {
 							event.type = Common::EVENT_KEYDOWN;
 							_queuedInputEvent.type = Common::EVENT_KEYUP;
 
@@ -1020,16 +1055,17 @@
 	float xUnit, yUnit;
 	uint32 startTime = getMillis();
 
-	AudioQueueStop(s_AudioQueue.queue, true);
-
+	stopSoundsystem();
+	
 	while (!done) {
 		if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit))
 			if ((InputEvent)eventType == kInputApplicationResumed)
 				done = true;
 		usleep(100000);
 	}
+	
+	startSoundsystem();
 
-	AudioQueueStart(s_AudioQueue.queue, NULL);
 	_timeSuspended += getMillis() - startTime;
 }
 
@@ -1107,7 +1143,10 @@
 	s_soundCallback = mixCallback;
 	s_soundParam = this;
 
+	startSoundsystem();
+}
 
+void OSystem_IPHONE::startSoundsystem() {
 	s_AudioQueue.dataFormat.mSampleRate = AUDIO_SAMPLE_RATE;
 	s_AudioQueue.dataFormat.mFormatID = kAudioFormatLinearPCM;
 	s_AudioQueue.dataFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
@@ -1147,6 +1186,17 @@
 	_mixer->setReady(true);
 }
 
+void OSystem_IPHONE::stopSoundsystem() {
+	AudioQueueStop(s_AudioQueue.queue, true);
+
+	for (int i = 0; i < AUDIO_BUFFERS; i++) {
+		AudioQueueFreeBuffer(s_AudioQueue.queue, s_AudioQueue.buffers[i]);
+	}
+
+	AudioQueueDispose(s_AudioQueue.queue, true);
+	_mixer->setReady(false);
+}
+
 int OSystem_IPHONE::getOutputSampleRate() const {
 	return AUDIO_SAMPLE_RATE;
 }
@@ -1200,29 +1250,6 @@
 	return SCUMMVM_SAVE_PATH;
 }
 
-void OSystem_IPHONE::migrateApp() {
-	// Migrate to the new 1.1.3 directory structure, if needed.
-	
-	FilesystemNode file("/var/mobile");
-	if (file.exists() && file.isDirectory()) {
-		// We have 1.1.3 or above.
-		s_is113OrHigher = true;
-		file = FilesystemNode(SCUMMVM_ROOT_PATH);
-		if (!file.exists()) {
-			system("mkdir " SCUMMVM_ROOT_PATH);
-			system("mkdir " SCUMMVM_SAVE_PATH);
-			
-			// Copy over the prefs file
-			system("cp " SCUMMVM_OLD_PREFS_PATH " " SCUMMVM_PREFS_PATH);
-
-			file = FilesystemNode(SCUMMVM_OLD_SAVE_PATH);
-			// Copy over old savegames to the new directory.
-			if (file.exists() && file.isDirectory())			
-				system("cp " SCUMMVM_OLD_SAVE_PATH "/* " SCUMMVM_SAVE_PATH "/");
-		}
-	}
-}
-
 void iphone_main(int argc, char *argv[]) {
 
 	//OSystem_IPHONE::migrateApp();
@@ -1243,6 +1270,8 @@
 	system("mkdir " SCUMMVM_ROOT_PATH);
 	system("mkdir " SCUMMVM_SAVE_PATH);
 
+	chdir("/var/mobile/");
+
 	g_system = OSystem_IPHONE_create();
 	assert(g_system);
 

Modified: scummvm/branches/branch-0-12-0/backends/platform/iphone/osys_iphone.h
===================================================================
--- scummvm/branches/branch-0-12-0/backends/platform/iphone/osys_iphone.h	2008-07-28 11:50:36 UTC (rev 33371)
+++ scummvm/branches/branch-0-12-0/backends/platform/iphone/osys_iphone.h	2008-07-28 12:30:19 UTC (rev 33372)
@@ -35,7 +35,7 @@
 #include <AudioToolbox/AudioQueue.h>
 
 #define AUDIO_BUFFERS 3
-#define WAVE_BUFFER_SIZE 8192
+#define WAVE_BUFFER_SIZE 2048
 #define AUDIO_SAMPLE_RATE 44100
 
 #define SCUMMVM_ROOT_PATH "/var/mobile/Library/ScummVM"
@@ -97,6 +97,9 @@
 	long _lastSecondaryTap;
 	int _gestureStartX, _gestureStartY;
 	bool _mouseClickAndDragEnabled;
+	bool _touchpadModeEnabled;
+	int _lastPadX;
+	int _lastPadY;
 
 	int _timerCallbackNext;
 	int _timerCallbackTimer;
@@ -170,7 +173,9 @@
 	virtual Audio::Mixer *getMixer();
 	virtual Common::TimerManager *getTimerManager();
 
-	static void migrateApp();
+	void startSoundsystem();
+	void stopSoundsystem();
+
 	static const char* getConfigPath();
 	static const char* getSavePath();	
 


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