diff options
author | dhewg | 2011-03-18 21:22:48 +0100 |
---|---|---|
committer | dhewg | 2011-03-18 21:53:25 +0100 |
commit | e056bfca9c0ef1a07f4a9703d842ffa669096b0d (patch) | |
tree | f569ab92374d61b4d7f73351e6a6a7ba96a6bac9 /backends/platform/android/events.cpp | |
parent | b7215472136c91841d44decd6955b4eb3e3e2ce1 (diff) | |
download | scummvm-rg350-e056bfca9c0ef1a07f4a9703d842ffa669096b0d.tar.gz scummvm-rg350-e056bfca9c0ef1a07f4a9703d842ffa669096b0d.tar.bz2 scummvm-rg350-e056bfca9c0ef1a07f4a9703d842ffa669096b0d.zip |
ANDROID: Seperate DPAD codes
Diffstat (limited to 'backends/platform/android/events.cpp')
-rw-r--r-- | backends/platform/android/events.cpp | 94 |
1 files changed, 48 insertions, 46 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; |