diff options
-rw-r--r-- | backends/platform/iphone/iphone_common.h | 10 | ||||
-rw-r--r-- | backends/platform/iphone/iphone_video.h | 10 | ||||
-rw-r--r-- | backends/platform/iphone/iphone_video.mm | 11 | ||||
-rw-r--r-- | backends/platform/iphone/osys_events.cpp | 25 | ||||
-rw-r--r-- | backends/platform/iphone/osys_main.cpp | 7 |
5 files changed, 29 insertions, 34 deletions
diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 19e4f2ce9b..9c45a240cb 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -86,9 +86,17 @@ struct VideoContext { int shakeOffsetY; }; +struct InternalEvent { + InternalEvent() : type(), value1(), value2() {} + InternalEvent(InputEvent t, int v1, int v2) : type(t), value1(v1), value2(v2) {} + + InputEvent type; + int value1, value2; +}; + // On the ObjC side void iPhone_updateScreen(); -bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY); +bool iPhone_fetchEvent(InternalEvent *event); const char *iPhone_getDocumentsDir(); bool iPhone_isHighResDevice(); diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index ed147eed2a..6b8c25ebcf 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -36,14 +36,6 @@ #include "common/list.h" -struct InternalEvent { - InternalEvent() : type(), value1(), value2() {} - InternalEvent(InputEvent t, int v1, int v2) : type(t), value1(v1), value2(v2) {} - - InputEvent type; - int value1, value2; -}; - @interface iPhoneView : UIView { VideoContext _videoContext; @@ -111,7 +103,7 @@ struct InternalEvent { - (void)applicationResume; -- (bool)fetchEvent:(int *)outEvent value1:(int *)v1 value2:(int *)v2; +- (bool)fetchEvent:(InternalEvent *)event; @end diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index da328133c3..7877bc6430 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -65,8 +65,8 @@ void iPhone_updateScreen() { } } -bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { - return [g_iPhoneViewInstance fetchEvent:outEvent value1:outX value2:outY]; +bool iPhone_fetchEvent(InternalEvent *event) { + return [g_iPhoneViewInstance fetchEvent:event]; } uint getSizeNextPOT(uint size) { @@ -569,17 +569,14 @@ const char *iPhone_getDocumentsDir() { [_eventLock unlock]; } -- (bool)fetchEvent:(int *)outEvent value1:(int *)v1 value2:(int *)v2 { +- (bool)fetchEvent:(InternalEvent *)event { [_eventLock lock]; if (_events.empty()) { [_eventLock unlock]; return false; } - const InternalEvent &front = *_events.begin(); - *outEvent = front.type; - *v1 = front.value1; - *v2 = front.value2; + *event = *_events.begin(); _events.pop_front(); [_eventLock unlock]; return true; diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index 85efbda208..9cfca0836e 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -46,41 +46,40 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { return true; } - int eventType; - int x, y; + InternalEvent internalEvent; - if (iPhone_fetchEvent(&eventType, &x, &y)) { - switch ((InputEvent)eventType) { + if (iPhone_fetchEvent(&internalEvent)) { + switch (internalEvent.type) { case kInputMouseDown: - if (!handleEvent_mouseDown(event, x, y)) + if (!handleEvent_mouseDown(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputMouseUp: - if (!handleEvent_mouseUp(event, x, y)) + if (!handleEvent_mouseUp(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputMouseDragged: - if (!handleEvent_mouseDragged(event, x, y)) + if (!handleEvent_mouseDragged(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputMouseSecondDragged: - if (!handleEvent_mouseSecondDragged(event, x, y)) + if (!handleEvent_mouseSecondDragged(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputMouseSecondDown: _secondaryTapped = true; - if (!handleEvent_secondMouseDown(event, x, y)) + if (!handleEvent_secondMouseDown(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputMouseSecondUp: _secondaryTapped = false; - if (!handleEvent_secondMouseUp(event, x, y)) + if (!handleEvent_secondMouseUp(event, internalEvent.value1, internalEvent.value2)) return false; break; case kInputOrientationChanged: - handleEvent_orientationChanged(x); + handleEvent_orientationChanged(internalEvent.value1); return false; break; @@ -90,11 +89,11 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { break; case kInputKeyPressed: - handleEvent_keyPressed(event, x); + handleEvent_keyPressed(event, internalEvent.value1); break; case kInputSwipe: - if (!handleEvent_swipe(event, x)) + if (!handleEvent_swipe(event, internalEvent.value1)) return false; break; diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 9a33cd8968..6935399c95 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -145,15 +145,14 @@ bool OSystem_IPHONE::getFeatureState(Feature f) { void OSystem_IPHONE::suspendLoop() { bool done = false; - int eventType; - int x, y; uint32 startTime = getMillis(); stopSoundsystem(); + InternalEvent event; while (!done) { - if (iPhone_fetchEvent(&eventType, &x, &y)) - if ((InputEvent)eventType == kInputApplicationResumed) + if (iPhone_fetchEvent(&event)) + if (event.type == kInputApplicationResumed) done = true; usleep(100000); } |