aboutsummaryrefslogtreecommitdiff
path: root/backends/platform
diff options
context:
space:
mode:
authorOystein Eftevaag2007-11-17 21:26:03 +0000
committerOystein Eftevaag2007-11-17 21:26:03 +0000
commitdbbce1985aee049e5bb1690ec9d8368934a4d6a7 (patch)
tree0c02aacfbbc48ad27f72c30edf64ae26765569e3 /backends/platform
parent7bc422a8e94fedbb70470222b155ced1163d0a81 (diff)
downloadscummvm-rg350-dbbce1985aee049e5bb1690ec9d8368934a4d6a7.tar.gz
scummvm-rg350-dbbce1985aee049e5bb1690ec9d8368934a4d6a7.tar.bz2
scummvm-rg350-dbbce1985aee049e5bb1690ec9d8368934a4d6a7.zip
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
svn-id: r29541
Diffstat (limited to 'backends/platform')
-rw-r--r--backends/platform/iphone/iphone_common.h5
-rw-r--r--backends/platform/iphone/iphone_main.m5
-rw-r--r--backends/platform/iphone/iphone_video.h6
-rw-r--r--backends/platform/iphone/iphone_video.m146
-rw-r--r--backends/platform/iphone/osys_iphone.cpp135
-rw-r--r--backends/platform/iphone/osys_iphone.h4
6 files changed, 219 insertions, 82 deletions
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h
index f1731f3dfe..287f797472 100644
--- a/backends/platform/iphone/iphone_common.h
+++ b/backends/platform/iphone/iphone_common.h
@@ -28,7 +28,8 @@ enum InputEvent {
kInputMouseDown,
kInputMouseUp,
kInputMouseDragged,
- kInputMouseSecondToggled
+ kInputMouseSecondToggled,
+ kInputOrientationChanged
};
// We need this to be able to call functions from/in Objective-C.
@@ -44,7 +45,7 @@ void iPhone_updateScreen();
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
diff --git a/backends/platform/iphone/iphone_main.m b/backends/platform/iphone/iphone_main.m
index 5701b361ff..2391e7cbac 100644
--- a/backends/platform/iphone/iphone_main.m
+++ b/backends/platform/iphone/iphone_main.m
@@ -88,6 +88,11 @@ int main(int argc, char** argv) {
[NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil];
}
+- (void)deviceOrientationChanged:(GSEvent *)event {
+ int screenOrientation = GSEventDeviceOrientation(event);
+ [_view deviceOrientationChanged: screenOrientation];
+}
+
- (UIWindow*) getWindow {
return _window;
}
diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h
index dfd45eb89a..167b74705b 100644
--- a/backends/platform/iphone/iphone_video.h
+++ b/backends/platform/iphone/iphone_video.h
@@ -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 */
diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m
index 05f3e9bcaf..d3989e3838 100644
--- a/backends/platform/iphone/iphone_video.m
+++ b/backends/platform/iphone/iphone_video.m
@@ -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 @@ void iPhone_unlockSurface() {
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 @@ bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY)
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 @@ bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY)
_fullWidth = frame.size.width;
_fullHeight = frame.size.height;
-
+ _screenLayer = nil;
+
sharedInstance = self;
+ _keyboard = [UIKeyboardImpl sharedInstance];
+ //[self addSubview:_keyboard];
+
return self;
}
@@ -139,6 +158,10 @@ bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY)
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 @@ bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY)
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 @@ bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY)
return event;
}
-- (void)addEvent:(NSDictionary*)event
-{
+- (void)addEvent:(NSDictionary*)event {
[self lock];
if(_events == nil)
@@ -213,56 +245,67 @@ bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY)
[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 @@ bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY)
// ];
}
-- (void)mouseExited:(GSEvent*)event
-{
+- (void)mouseExited:(GSEvent*)event {
//printf("mouseExited().\n");
// [self addEvent:
// [[NSDictionary alloc] initWithObjectsAndKeys:
@@ -290,11 +332,15 @@ bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY)
{
//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
]
];
diff --git a/backends/platform/iphone/osys_iphone.cpp b/backends/platform/iphone/osys_iphone.cpp
index b67e5b41c5..cc69d85c61 100644
--- a/backends/platform/iphone/osys_iphone.cpp
+++ b/backends/platform/iphone/osys_iphone.cpp
@@ -59,7 +59,7 @@ OSystem_IPHONE::OSystem_IPHONE() :
_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 @@ void OSystem_IPHONE::initSize(uint width, uint height) {
_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 @@ void OSystem_IPHONE::addDirtyRect(int16 x, int16 y, int16 w, int16 h) {
_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 @@ void OSystem_IPHONE::updateScreen() {
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;
-
- if ( my >= 0 && my < _screenHeight)
- _fullscreen[row + my] = _palette[_mouseBuf[y * _mouseWidth + x]];
+ my = _mouseY + y - _mouseHotspotY;
+
+ 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 @@ void OSystem_IPHONE::updateScreen() {
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::setShakePos(int shakeOffset) {
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,20 +441,27 @@ int16 OSystem_IPHONE::getOverlayWidth() {
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);
@@ -445,7 +482,7 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot
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 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) {
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 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) {
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 @@ bool OSystem_IPHONE::setSoundCallback(SoundProc proc, void *param) {
}
void OSystem_IPHONE::clearSoundCallback() {
+ debug("clearSoundCallback()\n");
}
int OSystem_IPHONE::getOutputSampleRate() const {
@@ -731,6 +789,23 @@ OSystem *OSystem_IPHONE_create() {
}
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);
diff --git a/backends/platform/iphone/osys_iphone.h b/backends/platform/iphone/osys_iphone.h
index 4e3e302dc1..3ee38e62fb 100644
--- a/backends/platform/iphone/osys_iphone.h
+++ b/backends/platform/iphone/osys_iphone.h
@@ -84,6 +84,7 @@ protected:
TimerProc _timerCallback;
Common::Array<Common::Rect> _dirtyRects;
+ bool _landscapeMode;
public:
@@ -148,6 +149,9 @@ public:
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);
};