diff options
author | Oystein Eftevaag | 2008-01-02 00:07:16 +0000 |
---|---|---|
committer | Oystein Eftevaag | 2008-01-02 00:07:16 +0000 |
commit | fe8faf4f195c0105bc31845f9fcd3017462830cb (patch) | |
tree | d2f55565dd93a2d6ff6104f98ccf17dd80cda4be /backends/platform | |
parent | 46368eac5f1afc6d3fe706a3efffc7ccf336a924 (diff) | |
download | scummvm-rg350-fe8faf4f195c0105bc31845f9fcd3017462830cb.tar.gz scummvm-rg350-fe8faf4f195c0105bc31845f9fcd3017462830cb.tar.bz2 scummvm-rg350-fe8faf4f195c0105bc31845f9fcd3017462830cb.zip |
(forward-port) Quick swipes across the screen now triggers arrow key events. Also, some mouse cursor fixes for landscape mode
svn-id: r30134
Diffstat (limited to 'backends/platform')
-rw-r--r-- | backends/platform/iphone/iphone_common.h | 11 | ||||
-rw-r--r-- | backends/platform/iphone/iphone_video.h | 8 | ||||
-rw-r--r-- | backends/platform/iphone/iphone_video.m | 11 | ||||
-rw-r--r-- | backends/platform/iphone/osys_iphone.cpp | 74 |
4 files changed, 91 insertions, 13 deletions
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index b4723670eb..6a5250a018 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -32,7 +32,8 @@ enum InputEvent { kInputOrientationChanged, kInputKeyPressed, kInputApplicationSuspended, - kInputApplicationResumed + kInputApplicationResumed, + kInputSwipe }; enum ScreenOrientation { @@ -41,6 +42,14 @@ enum ScreenOrientation { kScreenOrientationFlippedLandscape }; +typedef enum +{ + kUIViewSwipeUp = 1, + kUIViewSwipeDown = 2, + kUIViewSwipeLeft = 4, + kUIViewSwipeRight = 8 +} UIViewSwipeDirection; + // We need this to be able to call functions from/in Objective-C. #ifdef __cplusplus extern "C" { diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 837cd83b1a..615b2e5345 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -35,14 +35,6 @@ #import "iphone_keyboard.h" -typedef enum -{ - kUIViewSwipeUp = 1, - kUIViewSwipeDown = 2, - kUIViewSwipeLeft = 4, - kUIViewSwipeRight = 8 -} UIViewSwipeDirection; - @interface iPhoneView : UIView { CoreSurfaceBufferRef _screenSurface; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 1d1f46179d..0bc07c10ac 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -388,11 +388,20 @@ bool getLocalMouseCoords(CGPoint *point) { } - (BOOL)canHandleSwipes { - return FALSE; + return TRUE; } - (int)swipe:(UIViewSwipeDirection)num withEvent:(GSEvent*)event { //printf("swipe: %i\n", num); + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputSwipe], @"type", + [NSNumber numberWithFloat:(float)num], @"x", + [NSNumber numberWithFloat:0], @"y", + nil + ] + ]; } - (void)view:(UIView *)view handleTapWithCount:(int)count event:(GSEvent *)event fingerCount:(int)fingerCount{ diff --git a/backends/platform/iphone/osys_iphone.cpp b/backends/platform/iphone/osys_iphone.cpp index 6120a5fa2a..c957191cdb 100644 --- a/backends/platform/iphone/osys_iphone.cpp +++ b/backends/platform/iphone/osys_iphone.cpp @@ -403,7 +403,7 @@ void OSystem_IPHONE::internUpdateScreen() { break; } case kScreenOrientationLandscape: { - byte *src = &_mouseBuf[_mouseHeight * _mouseWidth - 1]; + byte *src = &_mouseBuf[(_mouseHeight - 1 - srcY) * _mouseWidth + srcX]; uint16 *dst = &_fullscreen[left * _screenHeight + (_screenHeight - bottom + srcY)]; for (int x = displayWidth; x > srcX; x--) { for (int y = displayHeight; y > srcY; y--) { @@ -413,7 +413,7 @@ void OSystem_IPHONE::internUpdateScreen() { src -= _mouseWidth; } dst -= -_screenHeight + displayHeight - srcY; - src -= 1 - (displayHeight - srcY) * _mouseWidth; + src += 1 - (displayHeight - srcY) * -_mouseWidth; } break; } @@ -933,7 +933,75 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { event.kbd.ascii = _queuedInputEvent.kbd.ascii = ascii; _needEventRestPeriod = true; break; - + + case kInputSwipe: { + Common::KeyCode keycode = Common::KEYCODE_INVALID; + switch (_screenOrientation) { + case kScreenOrientationPortrait: + switch ((UIViewSwipeDirection)xUnit) { + case kUIViewSwipeUp: + keycode = Common::KEYCODE_UP; + break; + case kUIViewSwipeDown: + keycode = Common::KEYCODE_DOWN; + break; + case kUIViewSwipeLeft: + keycode = Common::KEYCODE_LEFT; + break; + case kUIViewSwipeRight: + keycode = Common::KEYCODE_RIGHT; + break; + default: + return false; + } + break; + case kScreenOrientationLandscape: + switch ((UIViewSwipeDirection)xUnit) { + case kUIViewSwipeUp: + keycode = Common::KEYCODE_LEFT; + break; + case kUIViewSwipeDown: + keycode = Common::KEYCODE_RIGHT; + break; + case kUIViewSwipeLeft: + keycode = Common::KEYCODE_DOWN; + break; + case kUIViewSwipeRight: + keycode = Common::KEYCODE_UP; + break; + default: + return false; + } + break; + case kScreenOrientationFlippedLandscape: + switch ((UIViewSwipeDirection)xUnit) { + case kUIViewSwipeUp: + keycode = Common::KEYCODE_RIGHT; + break; + case kUIViewSwipeDown: + keycode = Common::KEYCODE_LEFT; + break; + case kUIViewSwipeLeft: + keycode = Common::KEYCODE_UP; + break; + case kUIViewSwipeRight: + keycode = Common::KEYCODE_DOWN; + break; + default: + return false; + } + break; + } + + event.kbd.keycode = _queuedInputEvent.kbd.keycode = keycode; + event.kbd.ascii = _queuedInputEvent.kbd.ascii = 0; + event.type = Common::EVENT_KEYDOWN; + _queuedInputEvent.type = Common::EVENT_KEYUP; + event.kbd.flags = _queuedInputEvent.kbd.flags = 0; + _needEventRestPeriod = true; + break; + } + default: break; } |