Permalink
Browse files

IPHONE: Use InternalEvent directly.

  • Loading branch information...
1 parent a92c544 commit b886bc0a418462dd2bb5c0f0d1cf21f8f109b34b @lordhoto lordhoto committed Apr 1, 2012
View
10 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();
View
10 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
View
11 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 @@ - (void)addEvent:(InternalEvent)event {
[_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;
View
25 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;
View
7 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);
}

0 comments on commit b886bc0

Please sign in to comment.