From e056bfca9c0ef1a07f4a9703d842ffa669096b0d Mon Sep 17 00:00:00 2001 From: dhewg Date: Fri, 18 Mar 2011 21:22:48 +0100 Subject: ANDROID: Seperate DPAD codes --- backends/platform/android/events.cpp | 94 +++++++++++----------- .../org/inodes/gus/scummvm/ScummVMEvents.java | 23 ++++-- 2 files changed, 66 insertions(+), 51 deletions(-) diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index da17b8ec32..2f6049224a 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -38,11 +38,12 @@ enum { JE_SYS_KEY = 0, JE_KEY = 1, - JE_DOWN = 2, - JE_SCROLL = 3, - JE_TAP = 4, - JE_DOUBLE_TAP = 5, - JE_BALL = 6, + JE_DPAD = 2, + JE_DOWN = 3, + JE_SCROLL = 4, + JE_TAP = 5, + JE_DOUBLE_TAP = 6, + JE_BALL = 7, JE_QUIT = 0x1000 }; @@ -338,7 +339,43 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, break; case JE_KEY: - // five-way first + switch (arg1) { + case JACTION_DOWN: + e.type = Common::EVENT_KEYDOWN; + break; + case JACTION_UP: + e.type = Common::EVENT_KEYUP; + break; + default: + LOGE("unhandled jaction on key: %d", arg1); + return; + } + + if (arg2 < 1 || arg2 > ARRAYSIZE(jkeymap)) { + LOGE("received invalid keycode: %d (%d)", arg2, arg3); + return; + } + + if (arg5 > 0) + e.synthetic = true; + + e.kbd.keycode = jkeymap[arg2]; + e.kbd.ascii = arg3; + + if (arg4 & JMETA_SHIFT) + e.kbd.flags |= Common::KBD_SHIFT; + if (arg4 & JMETA_ALT) + e.kbd.flags |= Common::KBD_ALT; + if (arg4 & (JMETA_SYM | JMETA_CTRL)) + e.kbd.flags |= Common::KBD_CTRL; + + lockMutex(_event_queue_lock); + _event_queue.push(e); + unlockMutex(_event_queue_lock); + + return; + + case JE_DPAD: switch (arg2) { case JKEYCODE_DPAD_UP: case JKEYCODE_DPAD_DOWN: @@ -349,7 +386,6 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, return; e.type = Common::EVENT_MOUSEMOVE; - e.synthetic = true; e.mouse = getEventManager()->getMousePos(); @@ -366,10 +402,12 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, // the longer the button held, the faster the pointer is // TODO put these values in some option dlg? - int f = CLIP(arg5, 1, 8) * _dpad_scale * 100 / s; + int f = CLIP(arg4, 1, 8) * _dpad_scale * 100 / s; - *c += ((arg2 == JKEYCODE_DPAD_UP || - arg2 == JKEYCODE_DPAD_LEFT) ? -1 : 1) * f; + if (arg2 == JKEYCODE_DPAD_UP || arg2 == JKEYCODE_DPAD_LEFT) + *c -= f; + else + *c += f; clipMouse(e.mouse); @@ -406,42 +444,6 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, return; } - switch (arg1) { - case JACTION_DOWN: - e.type = Common::EVENT_KEYDOWN; - break; - case JACTION_UP: - e.type = Common::EVENT_KEYUP; - break; - default: - LOGE("unhandled jaction on key: %d", arg1); - return; - } - - if (arg2 < 1 || arg2 > ARRAYSIZE(jkeymap)) { - LOGE("received invalid keycode: %d (%d)", arg2, arg3); - return; - } - - if (arg5 > 0) - e.synthetic = true; - - e.kbd.keycode = jkeymap[arg2]; - e.kbd.ascii = arg3; - - if (arg4 & JMETA_SHIFT) - e.kbd.flags |= Common::KBD_SHIFT; - if (arg4 & JMETA_ALT) - e.kbd.flags |= Common::KBD_ALT; - if (arg4 & (JMETA_SYM | JMETA_CTRL)) - e.kbd.flags |= Common::KBD_CTRL; - - lockMutex(_event_queue_lock); - _event_queue.push(e); - unlockMutex(_event_queue_lock); - - return; - case JE_DOWN: _touch_pt_down = getEventManager()->getMousePos(); _touch_pt_scroll.x = -1; diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java index baf128292e..cae88ea111 100644 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java +++ b/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java @@ -20,11 +20,12 @@ public class ScummVMEvents implements public static final int JE_SYS_KEY = 0; public static final int JE_KEY = 1; - public static final int JE_DOWN = 2; - public static final int JE_SCROLL = 3; - public static final int JE_TAP = 4; - public static final int JE_DOUBLE_TAP = 5; - public static final int JE_BALL = 6; + public static final int JE_DPAD = 2; + public static final int JE_DOWN = 3; + public static final int JE_SCROLL = 4; + public static final int JE_TAP = 5; + public static final int JE_DOUBLE_TAP = 6; + public static final int JE_BALL = 7; public static final int JE_QUIT = 0x1000; final protected Context _context; @@ -136,6 +137,18 @@ public class ScummVMEvents implements return true; } + switch (keyCode) { + case KeyEvent.KEYCODE_DPAD_UP: + case KeyEvent.KEYCODE_DPAD_DOWN: + case KeyEvent.KEYCODE_DPAD_LEFT: + case KeyEvent.KEYCODE_DPAD_RIGHT: + case KeyEvent.KEYCODE_DPAD_CENTER: + _scummvm.pushEvent(JE_DPAD, action, keyCode, + (int)(e.getEventTime() - e.getDownTime()), + e.getRepeatCount(), 0); + return true; + } + _scummvm.pushEvent(JE_KEY, action, keyCode, e.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK, e.getMetaState(), e.getRepeatCount()); -- cgit v1.2.3