diff options
author | Marcus Comstedt | 2013-08-08 14:08:30 +0200 |
---|---|---|
committer | Marcus Comstedt | 2013-08-08 14:08:30 +0200 |
commit | 1b69f8aedee240af79ea871c32a9caadc6a0dd98 (patch) | |
tree | 5eb2f2f79a8bb3bc559730b4d032064ebfa1e8e9 /backends/platform/android/events.cpp | |
parent | 9a888ed1c8b32a33a8dd91f0ff6c81ea7773e6ff (diff) | |
download | scummvm-rg350-1b69f8aedee240af79ea871c32a9caadc6a0dd98.tar.gz scummvm-rg350-1b69f8aedee240af79ea871c32a9caadc6a0dd98.tar.bz2 scummvm-rg350-1b69f8aedee240af79ea871c32a9caadc6a0dd98.zip |
ANDROID: Add gamepad button support
Diffstat (limited to 'backends/platform/android/events.cpp')
-rw-r--r-- | backends/platform/android/events.cpp | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index db1261e432..5ad9ed825c 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -64,6 +64,7 @@ enum { JE_RMB_DOWN = 11, JE_RMB_UP = 12, JE_MOUSE_MOVE = 13, + JE_GAMEPAD = 14, JE_QUIT = 0x1000 }; @@ -109,6 +110,25 @@ enum { JKEYCODE_DPAD_CENTER = 23 }; +// gamepad +enum { + JKEYCODE_BUTTON_A = 96, + JKEYCODE_BUTTON_B = 97, + JKEYCODE_BUTTON_C = 98, + JKEYCODE_BUTTON_X = 99, + JKEYCODE_BUTTON_Y = 100, + JKEYCODE_BUTTON_Z = 101, + JKEYCODE_BUTTON_L1 = 102, + JKEYCODE_BUTTON_R1 = 103, + JKEYCODE_BUTTON_L2 = 104, + JKEYCODE_BUTTON_R2 = 105, + JKEYCODE_BUTTON_THUMBL = 106, + JKEYCODE_BUTTON_THUMBR = 107, + JKEYCODE_BUTTON_START = 108, + JKEYCODE_BUTTON_SELECT = 109, + JKEYCODE_BUTTON_MODE = 110, +}; + // meta modifier enum { JMETA_SHIFT = 0x01, @@ -827,6 +847,55 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, return; + case JE_GAMEPAD: + 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 gamepad key: %d", arg1); + return; + } + + switch (arg2) { + case JKEYCODE_BUTTON_A: + case JKEYCODE_BUTTON_B: + switch (arg1) { + case JACTION_DOWN: + e.type = (arg2 == JKEYCODE_BUTTON_A? + Common::EVENT_LBUTTONDOWN : + Common::EVENT_RBUTTONDOWN); + break; + case JACTION_UP: + e.type = (arg2 == JKEYCODE_BUTTON_A? + Common::EVENT_LBUTTONUP : + Common::EVENT_RBUTTONUP); + break; + } + + e.mouse = getEventManager()->getMousePos(); + + break; + + case JKEYCODE_BUTTON_X: + e.kbd.keycode = Common::KEYCODE_ESCAPE; + e.kbd.ascii = Common::ASCII_ESCAPE; + break; + + default: + LOGW("unmapped gamepad key: %d", arg2); + return; + } + + lockMutex(_event_queue_lock); + _event_queue.push(e); + unlockMutex(_event_queue_lock); + + break; + case JE_QUIT: e.type = Common::EVENT_QUIT; |