[Scummvm-cvs-logs] SF.net SVN: scummvm: [29541] scummvm/trunk/backends/platform/iphone

vinterstum at users.sourceforge.net vinterstum at users.sourceforge.net
Sat Nov 17 22:26:04 CET 2007


Revision: 29541
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29541&view=rev
Author:   vinterstum
Date:     2007-11-17 13:26:03 -0800 (Sat, 17 Nov 2007)

Log Message:
-----------
Implemented portrait mode, fixed a few issues with the dirty rects handling, fixed some cursor positioning issues, and redirecting stdout and stderr to a log file when ScummVM is launched from the Springboard

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-17 13:27:43 UTC (rev 29540)
+++ scummvm/trunk/backends/platform/iphone/iphone_common.h	2007-11-17 21:26:03 UTC (rev 29541)
@@ -28,7 +28,8 @@
 	kInputMouseDown,
 	kInputMouseUp,
 	kInputMouseDragged,
-	kInputMouseSecondToggled
+	kInputMouseSecondToggled,
+	kInputOrientationChanged
 };
 
 // We need this to be able to call functions from/in Objective-C.
@@ -44,7 +45,7 @@
 unsigned short* iPhone_getSurface();
 void iPhone_lockSurface();
 void iPhone_unlockSurface();
-void iPhone_initSurface(int width, int height);
+void iPhone_initSurface(int width, int height, bool landscape);
 bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY);
 
 #ifdef __cplusplus

Modified: scummvm/trunk/backends/platform/iphone/iphone_main.m
===================================================================
--- scummvm/trunk/backends/platform/iphone/iphone_main.m	2007-11-17 13:27:43 UTC (rev 29540)
+++ scummvm/trunk/backends/platform/iphone/iphone_main.m	2007-11-17 21:26:03 UTC (rev 29541)
@@ -88,6 +88,11 @@
 	[NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil];
 }
 
+- (void)deviceOrientationChanged:(GSEvent *)event {
+	int screenOrientation = GSEventDeviceOrientation(event);
+	[_view deviceOrientationChanged: screenOrientation];
+}
+
 - (UIWindow*) getWindow {
 	return _window;
 }

Modified: scummvm/trunk/backends/platform/iphone/iphone_video.h
===================================================================
--- scummvm/trunk/backends/platform/iphone/iphone_video.h	2007-11-17 13:27:43 UTC (rev 29540)
+++ scummvm/trunk/backends/platform/iphone/iphone_video.h	2007-11-17 21:26:03 UTC (rev 29541)
@@ -39,6 +39,9 @@
 	CoreSurfaceBufferRef _screenSurface;
 	NSMutableArray* _events;
 	NSLock* _lock;
+	UIKeyboardImpl* _keyboard;
+	LKLayer* _screenLayer;
+
 	int _fullWidth;
 	int _fullHeight;
 	int _widthOffset;
@@ -56,6 +59,9 @@
 - (void)updateScreen;
 
 - (id)getEvent;
+
+- (void)deviceOrientationChanged:(int)orientation;
+
 @end
 
 #endif /* _IPHONE_VIDEO__H */

Modified: scummvm/trunk/backends/platform/iphone/iphone_video.m
===================================================================
--- scummvm/trunk/backends/platform/iphone/iphone_video.m	2007-11-17 13:27:43 UTC (rev 29540)
+++ scummvm/trunk/backends/platform/iphone/iphone_video.m	2007-11-17 21:26:03 UTC (rev 29541)
@@ -36,6 +36,9 @@
 static iPhoneView *sharedInstance = nil;
 static int _width = 0;
 static int _height = 0;
+static bool _landscape;
+static int _orientation = -1;
+static CGRect _screenRect;
 
 // static long lastTick = 0;
 // static int frames = 0;
@@ -56,15 +59,15 @@
 	CoreSurfaceBufferUnlock([sharedInstance getSurface]);
 }
 
-void iPhone_initSurface(int width, int height) {
+void iPhone_initSurface(int width, int height, bool landscape) {
 	_width = width;
 	_height = height;
+	_landscape = landscape;
 	
  	[sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES];
 }
 
-bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY)
-{
+bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY) {
 	id event = [sharedInstance getEvent];
 	if (event == nil) {
 		return false;
@@ -83,6 +86,18 @@
 	return true;
 }
 
+bool getLocalMouseCoords(CGPoint *point) {
+	if (point->x < _screenRect.origin.x || point->x > _screenRect.origin.x + _screenRect.size.width ||
+		point->y < _screenRect.origin.y || point->y > _screenRect.origin.y + _screenRect.size.height) {
+			return false;
+	}
+	
+	point->x = (point->x - _screenRect.origin.x) / _screenRect.size.width;
+	point->y = (point->y - _screenRect.origin.y) / _screenRect.size.height;
+	
+	return true;
+}
+
 @implementation iPhoneView
 
 - (id)initWithFrame:(struct CGRect)frame {
@@ -90,9 +105,13 @@
 
 	_fullWidth = frame.size.width;
 	_fullHeight = frame.size.height;
-	
+	_screenLayer = nil;
+
 	sharedInstance = self;
 
+	_keyboard = [UIKeyboardImpl sharedInstance];
+	//[self addSubview:_keyboard];
+
 	return self;
 }
 
@@ -139,6 +158,10 @@
 		nil
 	];
 
+	if (_screenSurface != nil) {
+		//[[sharedInstance _layer] removeSublayer: screenLayer];
+	}
+
 	//("Allocating surface: %d\n", allocSize);
 	_screenSurface = CoreSurfaceBufferCreate((CFDictionaryRef)dict);
 	//printf("Surface created.\n");
@@ -146,44 +169,54 @@
 
 	LKLayer* screenLayer = [[LKLayer layer] retain];
 	
-	float ratioDifference = ((float)_width / (float)_height) / ((float)_fullWidth / (float)_fullHeight);
-	int rectWidth, rectHeight;
-	if (ratioDifference < 1.0f) {
-		rectWidth = _fullWidth * ratioDifference;
-		rectHeight = _fullHeight;
-		_widthOffset = (_fullWidth - rectWidth)/2;
-		_heightOffset = 0;
+	if (_landscape) {
+		float ratioDifference = ((float)_width / (float)_height) / ((float)_fullWidth / (float)_fullHeight);
+		int rectWidth, rectHeight;
+		if (ratioDifference < 1.0f) {
+			rectWidth = _fullWidth * ratioDifference;
+			rectHeight = _fullHeight;
+			_widthOffset = (_fullWidth - rectWidth)/2;
+			_heightOffset = 0;
+		} else {
+			rectWidth = _fullWidth;
+			rectHeight = _fullHeight / ratioDifference;
+			_heightOffset = (_fullHeight - rectHeight)/2;
+			_widthOffset = 0;
+		}
+
+		//printf("Rect: %i, %i, %i, %i\n", _widthOffset, _heightOffset, rectWidth + _widthOffset, rectHeight + _heightOffset);
+		_screenRect = CGRectMake(_widthOffset, _heightOffset, rectWidth + _widthOffset, rectHeight + _heightOffset);
+		[screenLayer setFrame: _screenRect];		
 	} else {
-		rectWidth = _fullWidth;
-		rectHeight = _fullHeight / ratioDifference;
-		_heightOffset = (_fullHeight - rectHeight)/2;
-		_widthOffset = 0;
+		float ratio = (float)_height / (float)_width;
+		_screenRect = CGRectMake(0, 0, _fullWidth, _fullWidth * ratio);
+		[screenLayer setFrame: _screenRect];				
 	}
 
-	//printf("Rect: %i, %i, %i, %i\n", _widthOffset, _heightOffset, rectWidth + _widthOffset, rectHeight + _heightOffset);
-	[screenLayer setFrame: CGRectMake(_widthOffset, _heightOffset, rectWidth + _widthOffset, rectHeight + _heightOffset)];
-
 	[screenLayer setContents: _screenSurface];
 	[screenLayer setOpaque: YES];
-	[[sharedInstance _layer] addSublayer: screenLayer];
 	
+	if (_screenLayer != nil) {
+		[[sharedInstance _layer] replaceSublayer: _screenLayer with: screenLayer];
+	} else {
+		[[sharedInstance _layer] addSublayer: screenLayer];
+	}
+	_screenLayer = screenLayer;
+	
 	CoreSurfaceBufferUnlock(_screenSurface);
 	[dict release];
 }
 
 
-- (void)lock
-{
+- (void)lock {
 	[_lock lock];
 }
 
-- (void)unlock
-{
+- (void)unlock {
 	[_lock unlock];
 }
 
-- (id)getEvent
-{	
+- (id)getEvent {
 	if (_events == nil || [_events count] == 0) {
 		return nil;
 	}
@@ -201,8 +234,7 @@
 	return event;
 }
 
-- (void)addEvent:(NSDictionary*)event
-{
+- (void)addEvent:(NSDictionary*)event {
 	[self lock];
 	
 	if(_events == nil)
@@ -213,56 +245,67 @@
 	[self unlock];
 }
 
-- (void)deviceOrientationChanged:(GSEvent *)event {
-	int screenOrientation = GSEventDeviceOrientation(event);    
-	//[self setUIOrientation: screenOrientation]; // ??? does this do anything?
-	printf("deviceOrientationChanged: %i\n", screenOrientation);
+- (void)deviceOrientationChanged:(int)orientation {
+	[self addEvent:
+		[[NSDictionary alloc] initWithObjectsAndKeys:
+		 [NSNumber numberWithInt:kInputOrientationChanged], @"type",
+		 [NSNumber numberWithFloat:(float)orientation], @"x",
+		 [NSNumber numberWithFloat:0], @"y",
+		 nil
+		]
+	];
 }
 
-
-- (void)mouseDown:(GSEvent*)event
-{
+- (void)mouseDown:(GSEvent*)event {
 	struct CGPoint point = GSEventGetLocationInWindow(event);
 	
+	if (!getLocalMouseCoords(&point))
+		return;
+
 	[self addEvent:
 		[[NSDictionary alloc] initWithObjectsAndKeys:
 		 [NSNumber numberWithInt:kInputMouseDown], @"type",
-		 [NSNumber numberWithFloat:(point.x/_fullWidth)], @"x",
-		 [NSNumber numberWithFloat:(point.y/_fullHeight)], @"y",
+		 [NSNumber numberWithFloat:point.x], @"x",
+		 [NSNumber numberWithFloat:point.y], @"y",
 		 nil
 		]
 	];
 }
 
-- (void)mouseUp:(GSEvent*)event
-{
+- (void)mouseUp:(GSEvent*)event {
 	struct CGPoint point = GSEventGetLocationInWindow(event);
+	
+	if (!getLocalMouseCoords(&point))
+		return;
+	
 	[self addEvent:
 		[[NSDictionary alloc] initWithObjectsAndKeys:
 		 [NSNumber numberWithInt:kInputMouseUp], @"type",
-		 [NSNumber numberWithFloat:(point.x/_fullWidth)], @"x",
-		 [NSNumber numberWithFloat:(point.y/_fullHeight)], @"y",
+		 [NSNumber numberWithFloat:point.x], @"x",
+		 [NSNumber numberWithFloat:point.y], @"y",
 		 nil
 		]
 	];
 }
 
-- (void)mouseDragged:(GSEvent*)event
-{
+- (void)mouseDragged:(GSEvent*)event {
 	//printf("mouseDragged()\n");
 	struct CGPoint point = GSEventGetLocationInWindow(event);
+	
+	if (!getLocalMouseCoords(&point))
+		return;
+	
 	[self addEvent:
 		[[NSDictionary alloc] initWithObjectsAndKeys:
 		 [NSNumber numberWithInt:kInputMouseDragged], @"type",
-		 [NSNumber numberWithFloat:(point.x/_fullWidth)], @"x",
-		 [NSNumber numberWithFloat:(point.y/_fullHeight)], @"y",
+		 [NSNumber numberWithFloat:point.x], @"x",
+		 [NSNumber numberWithFloat:point.y], @"y",
 		 nil
 		]
 	];
 }
 
-- (void)mouseEntered:(GSEvent*)event
-{
+- (void)mouseEntered:(GSEvent*)event {
 	//printf("mouseEntered()\n");
 	// struct CGPoint point = GSEventGetLocationInWindow(event);
 	// [self addEvent:
@@ -275,8 +318,7 @@
 	// ];
 }
 
-- (void)mouseExited:(GSEvent*)event
-{
+- (void)mouseExited:(GSEvent*)event {
 	//printf("mouseExited().\n");
 	// [self addEvent:
 	// 	[[NSDictionary alloc] initWithObjectsAndKeys:
@@ -290,11 +332,15 @@
 {
 	//printf("mouseMoved()\n");
 	struct CGPoint point = GSEventGetLocationInWindow(event);
+	
+	if (!getLocalMouseCoords(&point))
+		return;
+
 	[self addEvent:
 		[[NSDictionary alloc] initWithObjectsAndKeys:
 		 [NSNumber numberWithInt:kInputMouseSecondToggled], @"type",
-		 [NSNumber numberWithFloat:(point.x/_fullWidth)], @"x",
-		 [NSNumber numberWithFloat:(point.y/_fullHeight)], @"y",
+		 [NSNumber numberWithFloat:point.x], @"x",
+		 [NSNumber numberWithFloat:point.y], @"y",
 		 nil
 		]
 	];

Modified: scummvm/trunk/backends/platform/iphone/osys_iphone.cpp
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_iphone.cpp	2007-11-17 13:27:43 UTC (rev 29540)
+++ scummvm/trunk/backends/platform/iphone/osys_iphone.cpp	2007-11-17 21:26:03 UTC (rev 29541)
@@ -59,7 +59,7 @@
 	_savefile(NULL), _mixer(NULL), _timer(NULL), _offscreen(NULL),
 	_overlayVisible(false), _overlayBuffer(NULL), _fullscreen(NULL),
 	_mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0),
-	_secondaryTapped(false), _lastSecondaryTap(0)
+	_secondaryTapped(false), _lastSecondaryTap(0), _landscapeMode(true)
 {	
 	_queuedInputEvent.type = (Common::EventType)0;
 }
@@ -151,7 +151,11 @@
 	_fullscreen = (uint16 *)malloc(fullSize);
 	bzero(_fullscreen, fullSize);
 	
-	iPhone_initSurface(height, width);
+	if (_landscapeMode)
+		iPhone_initSurface(height, width, true);
+	else
+		iPhone_initSurface(width, height, false);
+
 	_dirtyRects.push_back(Common::Rect(0, 0, width, height));
 	_mouseVisible = false;
 }
@@ -242,32 +246,51 @@
 	
 	_dirtyRects.push_back(Common::Rect(x, y, x + w, y + h));
 }
-	
+
 void OSystem_IPHONE::updateScreen() {
-	//printf("updateScreen()\n");
+	//printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size());
 
 	if (_dirtyRects.size() == 0) {
 		return;
 	}
+	
+	if (_landscapeMode) {
+		internUpdateScreen<true>();
+	} else {
+		internUpdateScreen<false>();	
+	}
+	
+	iPhone_updateScreen();
+}
 
-	Common::Rect mouseRect(_mouseX, _mouseY, _mouseX + _mouseWidth, _mouseY + _mouseHeight);
+template <bool landscapeMode>
+void OSystem_IPHONE::internUpdateScreen() {
+	Common::Rect mouseRect(_mouseX - _mouseHotspotX, _mouseY - _mouseHotspotY, _mouseX + _mouseWidth - _mouseHotspotX, _mouseY + _mouseHeight - _mouseHotspotY);
 
 	while (_dirtyRects.size()) {
-		Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size()-1);
+		Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1);
 		//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
 		int row;	
 		if (_overlayVisible) {
 			for (int x = dirtyRect.left; x < dirtyRect.right - 1; x++) {
-				row = (_screenWidth - x - 1) * _screenHeight;
-				for (int y = dirtyRect.top; y < dirtyRect.bottom; y++) {	
-					_fullscreen[row + y] = _overlayBuffer[y * _screenWidth + x];
+				if (landscapeMode) {
+					row = (_screenWidth - x - 1) * _screenHeight;
+					for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
+						_fullscreen[row + y] = _overlayBuffer[y * _screenWidth + x];						
+				} else {
+					for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
+						_fullscreen[y * _screenWidth + x] = _overlayBuffer[y * _screenWidth + x];												
 				}
 			}
 		} else {
 			for (int x = dirtyRect.left; x < dirtyRect.right - 1; x++) {
-				row = (_screenWidth - x - 1) * _screenHeight;
-				for (int y = dirtyRect.top; y < dirtyRect.bottom; y++) {
-					_fullscreen[row + y] = _palette[_offscreen[y * _screenWidth + x]];
+				if (landscapeMode) {
+					row = (_screenWidth - x - 1) * _screenHeight;
+					for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
+						_fullscreen[row + y] = _palette[_offscreen[y * _screenWidth + x]];												
+				} else {
+					for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
+						_fullscreen[y * _screenWidth + x] = _palette[_offscreen[y * _screenWidth + x]];												
 				}
 			}		
 		}
@@ -276,16 +299,20 @@
 		int mx, my;
 		if (_mouseVisible && dirtyRect.intersects(mouseRect)) {
 			for (uint x = 0; x < _mouseWidth - 1; x++) {
-				mx = _mouseX + x; // + _mouseHotspotX;
+				mx = _mouseX + x - _mouseHotspotX;
 				row = (_screenWidth - mx - 1) * _screenHeight;
 				if (mx >= 0 && mx < _screenWidth) {
 
 					for (uint y = 0; y < _mouseHeight; ++y) {
 						if (_mouseBuf[y * _mouseWidth + x] != _mouseKeyColour) {
-							my = _mouseY + y; // + _mouseHotspotY;
+							my = _mouseY + y - _mouseHotspotY;
 
-							if ( my >= 0 && my < _screenHeight)
-								_fullscreen[row + my] = _palette[_mouseBuf[y * _mouseWidth + x]];
+							if (my >= 0 && my < _screenHeight) {
+								if (landscapeMode)
+									_fullscreen[row + my] = _palette[_mouseBuf[y * _mouseWidth + x]];								
+								else
+									_fullscreen[my * _screenWidth + mx] = _palette[_mouseBuf[y * _mouseWidth + x]];								
+							}
 						}
 					}				
 				}
@@ -297,17 +324,17 @@
 			memcpy(surface, _fullscreen, _screenWidth * _screenHeight * 2);
 		} else {
 			for (int x = dirtyRect.left; x < dirtyRect.right - 1; x++) {
-				row = (_screenWidth - x - 1) * _screenHeight;
-				for (int y = dirtyRect.top; y < dirtyRect.bottom; y++) {
-					surface[row + y] = _fullscreen[row + y];
+				if (landscapeMode) {
+					row = (_screenWidth - x - 1) * _screenHeight;
+					for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
+						surface[row + y] = _fullscreen[row + y];
+				} else {
+					for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
+						surface[y * _screenWidth + x] = _fullscreen[y * _screenWidth + x];
 				}
 			}		
 		}
-		
-		//memcpy(iPhone_getSurface(), _fullscreen, (_screenWidth * _screenHeight) * 2);	
 	}
-
-	iPhone_updateScreen();
 }
 
 Graphics::Surface *OSystem_IPHONE::lockScreen() {
@@ -335,16 +362,19 @@
 void OSystem_IPHONE::showOverlay() {
 	//printf("showOverlay()\n");
 	_overlayVisible = true;
+	_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
 }
 
 void OSystem_IPHONE::hideOverlay() {
 	//printf("hideOverlay()\n");
 	_overlayVisible = false;
+	_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
 }
 
 void OSystem_IPHONE::clearOverlay() {
 	//printf("clearOverlay()\n");
 	bzero(_overlayBuffer, _screenWidth * _screenHeight * sizeof(OverlayColor));
+	_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
 }
 
 void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) {
@@ -411,21 +441,28 @@
 bool OSystem_IPHONE::showMouse(bool visible) {
 	bool last = _mouseVisible;
 	_mouseVisible = visible;
+	dirtyMouseCursor();
 	return last;
 }
 
 void OSystem_IPHONE::warpMouse(int x, int y) {
 	//printf("warpMouse()\n");
 	
-	addDirtyRect(_mouseX, _mouseY, _mouseX + _mouseWidth + 1, _mouseY + _mouseHeight + 1);
+	dirtyMouseCursor();
 	_mouseX = x;
 	_mouseY = y;
-	addDirtyRect(_mouseX, _mouseY, _mouseX + _mouseWidth + 1, _mouseY + _mouseHeight + 1);
+	dirtyMouseCursor();
 }
 
+void OSystem_IPHONE::dirtyMouseCursor() {
+	addDirtyRect(_mouseX - _mouseHotspotX, _mouseY - _mouseHotspotY, _mouseX + _mouseWidth - _mouseHotspotX + 1, _mouseY + _mouseHeight - _mouseHotspotY + 1);	
+}
+
 void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) {
-	//printf("setMouseCursor()\n");
+	//printf("setMouseCursor(%i, %i)\n", hotspotX, hotspotY);
 
+	dirtyMouseCursor();
+
 	if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) {
 		free(_mouseBuf);
 		_mouseBuf = NULL;
@@ -445,7 +482,7 @@
 	
 	memcpy(_mouseBuf, buf, w * h);
 	
-	addDirtyRect(_mouseX, _mouseY, _mouseX + _mouseWidth + 1, _mouseY + _mouseHeight + 1);
+	dirtyMouseCursor();
 }
 
 bool OSystem_IPHONE::pollEvent(Common::Event &event) {
@@ -467,8 +504,15 @@
 	float xUnit, yUnit;
 
 	if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit)) {
-		int x = (int)((1.0 - yUnit) * _screenWidth);
-		int y = (int)(xUnit * _screenHeight);
+		int x;
+		int y;
+		if (_landscapeMode) {
+			x = (int)((1.0 - yUnit) * _screenWidth);
+			y = (int)(xUnit * _screenHeight);
+		} else {
+			x = (int)(xUnit * _screenWidth);
+			y = (int)(yUnit * _screenHeight);		
+		}
 
 		switch ((InputEvent)eventType) {
 			case kInputMouseDown:
@@ -591,6 +635,19 @@
 					return false;
 				}
 				break;
+			case kInputOrientationChanged:
+				bool newModeIsLandscape = (int)xUnit != 1;
+				//printf("Orientation: %i", (int)xUnit);
+				if (_landscapeMode != newModeIsLandscape) {
+					_landscapeMode = newModeIsLandscape;
+					if (_landscapeMode) {
+						iPhone_initSurface(_screenHeight, _screenWidth, true);
+					} else {
+						iPhone_initSurface(_screenWidth, _screenHeight, false);
+					}
+					_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
+				}				
+				break;
 			default:
 				break;
 		}
@@ -686,6 +743,7 @@
 }
 
 void OSystem_IPHONE::clearSoundCallback() {
+	debug("clearSoundCallback()\n");
 }
 
 int OSystem_IPHONE::getOutputSampleRate() const {
@@ -731,6 +789,23 @@
 }
 
 void iphone_main(int argc, char *argv[]) {
+	
+	// Redirect stdout and stderr if we're launching from the Springboard.
+	if (argc == 2 && strcmp(argv[1], "--launchedFromSB") == 0) {
+		FILE *newfp = fopen("/tmp/scummvm.log", "a");
+		if (newfp != NULL) {
+			fclose(stdout);
+			fclose(stderr);
+			*stdout = *newfp;
+			*stderr = *newfp;
+			setbuf(stdout, NULL);
+			setbuf(stderr, NULL);	
+
+			//extern int gDebugLevel;
+			//gDebugLevel = 10;
+		}		
+	}
+
 	g_system = OSystem_IPHONE_create();
 	assert(g_system);
 

Modified: scummvm/trunk/backends/platform/iphone/osys_iphone.h
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_iphone.h	2007-11-17 13:27:43 UTC (rev 29540)
+++ scummvm/trunk/backends/platform/iphone/osys_iphone.h	2007-11-17 21:26:03 UTC (rev 29541)
@@ -84,6 +84,7 @@
 	TimerProc _timerCallback;
 
 	Common::Array<Common::Rect> _dirtyRects;
+	bool _landscapeMode;
 
 public:
 
@@ -148,6 +149,9 @@
 	
 protected:
 	inline void addDirtyRect(int16 x1, int16 y1, int16 w, int16 h);
+	template <bool landscapeMode> void internUpdateScreen();
+	void dirtyMouseCursor();
+
 	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