aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/android/events.cpp
diff options
context:
space:
mode:
authorLauri Härsilä2012-10-07 04:53:52 +0300
committerAlyssa Milburn2012-10-19 22:50:09 +0200
commit21093175646b8d359e8108b93e28898ed9695457 (patch)
treee049dbbc84a1eb9599679dc3a254305ad7c34192 /backends/platform/android/events.cpp
parentca256a23b31ba10294cf1f426ebefbc070389357 (diff)
downloadscummvm-rg350-21093175646b8d359e8108b93e28898ed9695457.tar.gz
scummvm-rg350-21093175646b8d359e8108b93e28898ed9695457.tar.bz2
scummvm-rg350-21093175646b8d359e8108b93e28898ed9695457.zip
ANDROID: Mouse and stylus support
From pull request #285.
Diffstat (limited to 'backends/platform/android/events.cpp')
-rw-r--r--backends/platform/android/events.cpp78
1 files changed, 74 insertions, 4 deletions
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp
index 21d2344fa7..db1261e432 100644
--- a/backends/platform/android/events.cpp
+++ b/backends/platform/android/events.cpp
@@ -59,6 +59,11 @@ enum {
JE_DOUBLE_TAP = 6,
JE_MULTI = 7,
JE_BALL = 8,
+ JE_LMB_DOWN = 9,
+ JE_LMB_UP = 10,
+ JE_RMB_DOWN = 11,
+ JE_RMB_UP = 12,
+ JE_MOUSE_MOVE = 13,
JE_QUIT = 0x1000
};
@@ -272,7 +277,7 @@ void OSystem_Android::clipMouse(Common::Point &p) {
}
void OSystem_Android::scaleMouse(Common::Point &p, int x, int y,
- bool deductDrawRect) {
+ bool deductDrawRect, bool touchpadMode) {
const GLESBaseTexture *tex;
if (_show_overlay)
@@ -282,7 +287,7 @@ void OSystem_Android::scaleMouse(Common::Point &p, int x, int y,
const Common::Rect &r = tex->getDrawRect();
- if (_touchpad_mode) {
+ if (touchpadMode) {
x = x * 100 / _touchpad_scale;
y = y * 100 / _touchpad_scale;
}
@@ -327,11 +332,16 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
}
switch (arg2) {
+
+ // special case. we'll only get it's up event
case JKEYCODE_BACK:
e.kbd.keycode = Common::KEYCODE_ESCAPE;
e.kbd.ascii = Common::ASCII_ESCAPE;
lockMutex(_event_queue_lock);
+ e.type = Common::EVENT_KEYDOWN;
+ _event_queue.push(e);
+ e.type = Common::EVENT_KEYUP;
_event_queue.push(e);
unlockMutex(_event_queue_lock);
@@ -554,7 +564,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
}
scaleMouse(e.mouse, arg3 - _touch_pt_scroll.x,
- arg4 - _touch_pt_scroll.y, false);
+ arg4 - _touch_pt_scroll.y, false, true);
e.mouse += _touch_pt_down;
clipMouse(e.mouse);
} else {
@@ -652,7 +662,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
if (_touchpad_mode) {
scaleMouse(e.mouse, arg1 - _touch_pt_dt.x,
- arg2 - _touch_pt_dt.y, false);
+ arg2 - _touch_pt_dt.y, false, true);
e.mouse += _touch_pt_down;
clipMouse(e.mouse);
@@ -757,6 +767,66 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3,
return;
+ case JE_MOUSE_MOVE:
+ e.type = Common::EVENT_MOUSEMOVE;
+
+ scaleMouse(e.mouse, arg1, arg2);
+ clipMouse(e.mouse);
+
+ lockMutex(_event_queue_lock);
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+
+ return;
+
+ case JE_LMB_DOWN:
+ e.type = Common::EVENT_LBUTTONDOWN;
+
+ scaleMouse(e.mouse, arg1, arg2);
+ clipMouse(e.mouse);
+
+ lockMutex(_event_queue_lock);
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+
+ return;
+
+ case JE_LMB_UP:
+ e.type = Common::EVENT_LBUTTONUP;
+
+ scaleMouse(e.mouse, arg1, arg2);
+ clipMouse(e.mouse);
+
+ lockMutex(_event_queue_lock);
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+
+ return;
+
+ case JE_RMB_DOWN:
+ e.type = Common::EVENT_RBUTTONDOWN;
+
+ scaleMouse(e.mouse, arg1, arg2);
+ clipMouse(e.mouse);
+
+ lockMutex(_event_queue_lock);
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+
+ return;
+
+ case JE_RMB_UP:
+ e.type = Common::EVENT_RBUTTONUP;
+
+ scaleMouse(e.mouse, arg1, arg2);
+ clipMouse(e.mouse);
+
+ lockMutex(_event_queue_lock);
+ _event_queue.push(e);
+ unlockMutex(_event_queue_lock);
+
+ return;
+
case JE_QUIT:
e.type = Common::EVENT_QUIT;