diff options
author | Cameron Cawley | 2019-12-14 12:48:47 +0000 |
---|---|---|
committer | Antoniou Athanasios | 2019-12-14 14:48:47 +0200 |
commit | d584df6a0e0b56e5cdd29ad8f3a57f7e7d4d69df (patch) | |
tree | f38468ba7986011183cb3cf0668b762cecf68012 /backends/platform | |
parent | 9a2371ddfbe061cd75fe6a174c52319b7bab362f (diff) | |
download | scummvm-rg350-d584df6a0e0b56e5cdd29ad8f3a57f7e7d4d69df.tar.gz scummvm-rg350-d584df6a0e0b56e5cdd29ad8f3a57f7e7d4d69df.tar.bz2 scummvm-rg350-d584df6a0e0b56e5cdd29ad8f3a57f7e7d4d69df.zip |
ANDROID: Improve keyboard support (#1857)
Diffstat (limited to 'backends/platform')
-rw-r--r-- | backends/platform/android/events.cpp | 8 | ||||
-rw-r--r-- | backends/platform/android/events.h | 208 | ||||
-rw-r--r-- | backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java | 25 |
3 files changed, 216 insertions, 25 deletions
diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index 2765b07045..4503d1ee16 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -239,15 +239,15 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, break; } - if (arg4 & JMETA_SHIFT) + if (arg4 & JMETA_SHIFT_MASK) e.kbd.flags |= Common::KBD_SHIFT; // JMETA_ALT is Fn on physical keyboards! // when mapping this to ALT - as we know it from PC keyboards - all // Fn combos will be broken (like Fn+q, which needs to end as 1 and // not ALT+1). Do not want. - //if (arg4 & JMETA_ALT) + //if (arg4 & JMETA_ALT_MASK) // e.kbd.flags |= Common::KBD_ALT; - if (arg4 & (JMETA_SYM | JMETA_CTRL)) + if (arg4 & (JMETA_SYM_ON | JMETA_CTRL_MASK)) e.kbd.flags |= Common::KBD_CTRL; pushEvent(e); @@ -281,7 +281,7 @@ 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(arg4, 1, 8) * _dpad_scale * 100 / s; + int f = CLIP(arg5, 1, 8) * _dpad_scale * 100 / s; if (arg2 == JKEYCODE_DPAD_UP || arg2 == JKEYCODE_DPAD_LEFT) *c -= f; diff --git a/backends/platform/android/events.h b/backends/platform/android/events.h index 1b0713cab5..4c114cef3d 100644 --- a/backends/platform/android/events.h +++ b/backends/platform/android/events.h @@ -28,6 +28,7 @@ // $ANDROID_NDK/platforms/android-9/arch-arm/usr/include/android/keycodes.h // http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=libs/ui/Input.cpp // http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/view/KeyEvent.java +// https://static.javadoc.io/io.appium/java-client/5.0.4/constant-values.html#io.appium.java_client.android.AndroidKeyCode.FLAG_SOFT_KEYBOARD // event type enum { @@ -117,10 +118,28 @@ enum { // meta modifier enum { - JMETA_SHIFT = 0x01, - JMETA_ALT = 0x02, - JMETA_SYM = 0x04, - JMETA_CTRL = 0x1000 + JMETA_SHIFT_ON = 0x01, + JMETA_ALT_ON = 0x02, + JMETA_SYM_ON = 0x04, + JMETA_FUNCTION_ON = 0x08, + JMETA_ALT_LEFT_ON = 0x10, + JMETA_ALT_RIGHT_ON = 0x20, + JMETA_SHIFT_LEFT_ON = 0x40, + JMETA_SHIFT_RIGHT_ON = 0x80, + JMETA_CTRL_ON = 0x1000, + JMETA_CTRL_LEFT_ON = 0x2000, + JMETA_CTRL_RIGHT_ON = 0x4000, + JMETA_META_ON = 0x10000, + JMETA_META_LEFT_ON = 0x20000, + JMETA_META_RIGHT_ON = 0x40000, + JMETA_CAPS_LOCK_ON = 0x100000, + JMETA_NUM_LOCK_ON = 0x200000, + JMETA_SCROLL_LOCK_ON = 0x400000, + + JMETA_CTRL_MASK = JMETA_CTRL_ON | JMETA_CTRL_LEFT_ON | JMETA_CTRL_RIGHT_ON, + JMETA_META_MASK = JMETA_META_ON | JMETA_META_LEFT_ON | JMETA_META_RIGHT_ON, + JMETA_SHIFT_MASK = JMETA_SHIFT_ON | JMETA_SHIFT_LEFT_ON | JMETA_SHIFT_RIGHT_ON, + JMETA_ALT_MASK = JMETA_ALT_ON | JMETA_ALT_LEFT_ON | JMETA_ALT_RIGHT_ON }; // map android key codes to our kbd codes @@ -144,16 +163,16 @@ static const Common::KeyCode jkeymap[] = { Common::KEYCODE_9, // KEYCODE_9 Common::KEYCODE_ASTERISK, // KEYCODE_STAR Common::KEYCODE_HASH, // KEYCODE_POUND - Common::KEYCODE_INVALID, // KEYCODE_DPAD_UP - Common::KEYCODE_INVALID, // KEYCODE_DPAD_DOWN - Common::KEYCODE_INVALID, // KEYCODE_DPAD_LEFT - Common::KEYCODE_INVALID, // KEYCODE_DPAD_RIGHT + Common::KEYCODE_UP, // KEYCODE_DPAD_UP + Common::KEYCODE_DOWN, // KEYCODE_DPAD_DOWN + Common::KEYCODE_LEFT, // KEYCODE_DPAD_LEFT + Common::KEYCODE_RIGHT, // KEYCODE_DPAD_RIGHT Common::KEYCODE_INVALID, // KEYCODE_DPAD_CENTER Common::KEYCODE_INVALID, // KEYCODE_VOLUME_UP Common::KEYCODE_INVALID, // KEYCODE_VOLUME_DOWN Common::KEYCODE_INVALID, // KEYCODE_POWER Common::KEYCODE_INVALID, // KEYCODE_CAMERA - Common::KEYCODE_INVALID, // KEYCODE_CLEAR + Common::KEYCODE_CLEAR, // KEYCODE_CLEAR Common::KEYCODE_a, // KEYCODE_A Common::KEYCODE_b, // KEYCODE_B Common::KEYCODE_c, // KEYCODE_C @@ -207,7 +226,7 @@ static const Common::KeyCode jkeymap[] = { Common::KEYCODE_INVALID, // KEYCODE_HEADSETHOOK Common::KEYCODE_INVALID, // KEYCODE_FOCUS Common::KEYCODE_PLUS, // KEYCODE_PLUS - Common::KEYCODE_INVALID, // KEYCODE_MENU + Common::KEYCODE_MENU, // KEYCODE_MENU Common::KEYCODE_INVALID, // KEYCODE_NOTIFICATION Common::KEYCODE_INVALID, // KEYCODE_SEARCH Common::KEYCODE_INVALID, // KEYCODE_MEDIA_PLAY_PAUSE @@ -218,7 +237,174 @@ static const Common::KeyCode jkeymap[] = { Common::KEYCODE_INVALID, // KEYCODE_MEDIA_FAST_FORWARD Common::KEYCODE_INVALID, // KEYCODE_MUTE Common::KEYCODE_PAGEUP, // KEYCODE_PAGE_UP - Common::KEYCODE_PAGEDOWN // KEYCODE_PAGE_DOWN + Common::KEYCODE_PAGEDOWN, // KEYCODE_PAGE_DOWN + Common::KEYCODE_INVALID, // KEYCODE_PICTSYMBOLS + Common::KEYCODE_INVALID, // KEYCODE_SWITCH_CHARSET + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_A + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_B + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_C + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_X + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_Y + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_Z + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_L1 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_R1 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_L2 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_R2 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_THUMBL + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_THUMBR + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_START + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_SELECT + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_MODE + Common::KEYCODE_ESCAPE, // KEYCODE_ESCAPE + Common::KEYCODE_DELETE, // KEYCODE_FORWARD_DEL + Common::KEYCODE_LCTRL, // KEYCODE_CTRL_LEFT + Common::KEYCODE_RCTRL, // KEYCODE_CTRL_RIGHT + Common::KEYCODE_CAPSLOCK, // KEYCODE_CAPS_LOCK + Common::KEYCODE_SCROLLOCK, // KEYCODE_SCROLL_LOCK + Common::KEYCODE_LSUPER, // KEYCODE_META_LEFT + Common::KEYCODE_RSUPER, // KEYCODE_META_RIGHT + Common::KEYCODE_INVALID, // KEYCODE_FUNCTION + Common::KEYCODE_SYSREQ, // KEYCODE_SYSRQ + Common::KEYCODE_BREAK, // KEYCODE_BREAK + Common::KEYCODE_HOME, // KEYCODE_MOVE_HOME + Common::KEYCODE_END, // KEYCODE_MOVE_END + Common::KEYCODE_INSERT, // KEYCODE_INSERT + Common::KEYCODE_INVALID, // KEYCODE_FORWARD + Common::KEYCODE_INVALID, // KEYCODE_MEDIA_PLAY + Common::KEYCODE_INVALID, // KEYCODE_MEDIA_PAUSE + Common::KEYCODE_INVALID, // KEYCODE_MEDIA_CLOSE + Common::KEYCODE_INVALID, // KEYCODE_MEDIA_EJECT + Common::KEYCODE_INVALID, // KEYCODE_MEDIA_RECORD + Common::KEYCODE_F1, // KEYCODE_F1 + Common::KEYCODE_F2, // KEYCODE_F2 + Common::KEYCODE_F3, // KEYCODE_F3 + Common::KEYCODE_F4, // KEYCODE_F4 + Common::KEYCODE_F5, // KEYCODE_F5 + Common::KEYCODE_F6, // KEYCODE_F6 + Common::KEYCODE_F7, // KEYCODE_F7 + Common::KEYCODE_F8, // KEYCODE_F8 + Common::KEYCODE_F9, // KEYCODE_F9 + Common::KEYCODE_F10, // KEYCODE_F10 + Common::KEYCODE_F11, // KEYCODE_F11 + Common::KEYCODE_F12, // KEYCODE_F12 + Common::KEYCODE_NUMLOCK, // KEYCODE_NUM_LOCK + Common::KEYCODE_KP0, // KEYCODE_NUMPAD_0 + Common::KEYCODE_KP1, // KEYCODE_NUMPAD_1 + Common::KEYCODE_KP2, // KEYCODE_NUMPAD_2 + Common::KEYCODE_KP3, // KEYCODE_NUMPAD_3 + Common::KEYCODE_KP4, // KEYCODE_NUMPAD_4 + Common::KEYCODE_KP5, // KEYCODE_NUMPAD_5 + Common::KEYCODE_KP6, // KEYCODE_NUMPAD_6 + Common::KEYCODE_KP7, // KEYCODE_NUMPAD_7 + Common::KEYCODE_KP8, // KEYCODE_NUMPAD_8 + Common::KEYCODE_KP9, // KEYCODE_NUMPAD_9 + Common::KEYCODE_KP_DIVIDE, // KEYCODE_NUMPAD_DIVIDE + Common::KEYCODE_KP_MULTIPLY, // KEYCODE_NUMPAD_MULTIPLY + Common::KEYCODE_KP_MINUS, // KEYCODE_NUMPAD_SUBTRACT + Common::KEYCODE_KP_PLUS, // KEYCODE_NUMPAD_ADD + Common::KEYCODE_KP_PERIOD, // KEYCODE_NUMPAD_DOT + Common::KEYCODE_INVALID, // KEYCODE_NUMPAD_COMMA + Common::KEYCODE_KP_ENTER, // KEYCODE_NUMPAD_ENTER + Common::KEYCODE_KP_EQUALS, // KEYCODE_NUMPAD_EQUALS + Common::KEYCODE_INVALID, // KEYCODE_NUMPAD_LEFT_PAREN + Common::KEYCODE_INVALID, // KEYCODE_NUMPAD_RIGHT_PAREN + Common::KEYCODE_INVALID, // KEYCODE_VOLUME_MUTE + Common::KEYCODE_INVALID, // KEYCODE_INFO + Common::KEYCODE_INVALID, // KEYCODE_CHANNEL_UP + Common::KEYCODE_INVALID, // KEYCODE_CHANNEL_DOWN + Common::KEYCODE_INVALID, // KEYCODE_ZOOM_IN + Common::KEYCODE_INVALID, // KEYCODE_ZOOM_OUT + Common::KEYCODE_INVALID, // KEYCODE_TV + Common::KEYCODE_INVALID, // KEYCODE_WINDOW + Common::KEYCODE_INVALID, // KEYCODE_GUIDE + Common::KEYCODE_INVALID, // KEYCODE_DVR + Common::KEYCODE_INVALID, // KEYCODE_BOOKMARK + Common::KEYCODE_INVALID, // KEYCODE_CAPTIONS + Common::KEYCODE_INVALID, // KEYCODE_SETTINGS + Common::KEYCODE_INVALID, // KEYCODE_TV_POWER + Common::KEYCODE_INVALID, // KEYCODE_TV_INPUT + Common::KEYCODE_INVALID, // KEYCODE_STB_POWER + Common::KEYCODE_INVALID, // KEYCODE_STB_INPUT + Common::KEYCODE_INVALID, // KEYCODE_AVR_POWER + Common::KEYCODE_INVALID, // KEYCODE_AVR_INPUT + Common::KEYCODE_INVALID, // KEYCODE_PROG_RED + Common::KEYCODE_INVALID, // KEYCODE_PROG_GREEN + Common::KEYCODE_INVALID, // KEYCODE_PROG_YELLOW + Common::KEYCODE_INVALID, // KEYCODE_PROG_BLUE + Common::KEYCODE_INVALID, // KEYCODE_APP_SWITCH + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_1 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_2 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_3 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_4 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_5 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_6 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_7 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_8 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_9 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_10 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_11 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_12 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_13 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_14 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_15 + Common::KEYCODE_INVALID, // KEYCODE_BUTTON_16 + Common::KEYCODE_INVALID, // KEYCODE_LANGUAGE_SWITCH + Common::KEYCODE_INVALID, // KEYCODE_MANNER_MODE + Common::KEYCODE_INVALID, // KEYCODE_3D_MODE + Common::KEYCODE_INVALID, // KEYCODE_CONTACTS + Common::KEYCODE_INVALID, // KEYCODE_CALENDAR + Common::KEYCODE_INVALID, // KEYCODE_MUSIC + Common::KEYCODE_INVALID, // KEYCODE_CALCULATOR + Common::KEYCODE_INVALID, // KEYCODE_ZENKAKU_HANKAKU + Common::KEYCODE_INVALID, // KEYCODE_EISU + Common::KEYCODE_INVALID, // KEYCODE_MUHENKAN + Common::KEYCODE_INVALID, // KEYCODE_HENKAN + Common::KEYCODE_INVALID, // KEYCODE_KATAKANA_HIRAGANA + Common::KEYCODE_INVALID, // KEYCODE_YEN + Common::KEYCODE_INVALID, // KEYCODE_RO + Common::KEYCODE_INVALID, // KEYCODE_KANA + Common::KEYCODE_INVALID, // KEYCODE_ASSIST + Common::KEYCODE_INVALID, // KEYCODE_BRIGHTNESS_DOWN + Common::KEYCODE_INVALID, // KEYCODE_BRIGHTNESS_UP + Common::KEYCODE_INVALID, // KEYCODE_MEDIA_AUDIO_TRACK + Common::KEYCODE_INVALID, // KEYCODE_SLEEP + Common::KEYCODE_INVALID, // KEYCODE_WAKEUP + Common::KEYCODE_INVALID, // KEYCODE_PAIRING + Common::KEYCODE_INVALID, // KEYCODE_MEDIA_TOP_MENU + Common::KEYCODE_INVALID, // KEYCODE_11 + Common::KEYCODE_INVALID, // KEYCODE_12 + Common::KEYCODE_INVALID, // KEYCODE_LAST_CHANNEL + Common::KEYCODE_INVALID, // KEYCODE_TV_DATA_SERVICE + Common::KEYCODE_INVALID, // KEYCODE_VOICE_ASSIST + Common::KEYCODE_INVALID, // KEYCODE_TV_RADIO_SERVICE + Common::KEYCODE_INVALID, // KEYCODE_TV_TELETEXT + Common::KEYCODE_INVALID, // KEYCODE_TV_NUMBER_ENTRY + Common::KEYCODE_INVALID, // KEYCODE_TV_TERRESTRIAL_ANALOG + Common::KEYCODE_INVALID, // KEYCODE_TV_TERRESTRIAL_DIGITAL + Common::KEYCODE_INVALID, // KEYCODE_TV_SATELLITE + Common::KEYCODE_INVALID, // KEYCODE_TV_SATELLITE_BS + Common::KEYCODE_INVALID, // KEYCODE_TV_SATELLITE_CS + Common::KEYCODE_INVALID, // KEYCODE_TV_SATELLITE_SERVICE + Common::KEYCODE_INVALID, // KEYCODE_TV_NETWORK + Common::KEYCODE_INVALID, // KEYCODE_TV_ANTENNA_CABLE + Common::KEYCODE_INVALID, // KEYCODE_TV_INPUT_HDMI_1 + Common::KEYCODE_INVALID, // KEYCODE_TV_INPUT_HDMI_2 + Common::KEYCODE_INVALID, // KEYCODE_TV_INPUT_HDMI_3 + Common::KEYCODE_INVALID, // KEYCODE_TV_INPUT_HDMI_4 + Common::KEYCODE_INVALID, // KEYCODE_TV_INPUT_COMPOSITE_1 + Common::KEYCODE_INVALID, // KEYCODE_TV_INPUT_COMPOSITE_2 + Common::KEYCODE_INVALID, // KEYCODE_TV_INPUT_COMPONENT_1 + Common::KEYCODE_INVALID, // KEYCODE_TV_INPUT_COMPONENT_2 + Common::KEYCODE_INVALID, // KEYCODE_TV_INPUT_VGA_1 + Common::KEYCODE_INVALID, // KEYCODE_TV_AUDIO_DESCRIPTION + Common::KEYCODE_INVALID, // KEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP + Common::KEYCODE_INVALID, // KEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN + Common::KEYCODE_INVALID, // KEYCODE_TV_ZOOM_MODE + Common::KEYCODE_INVALID, // KEYCODE_TV_CONTENTS_MENU + Common::KEYCODE_INVALID, // KEYCODE_TV_MEDIA_CONTEXT_MENU + Common::KEYCODE_INVALID, // KEYCODE_TV_TIMER_PROGRAMMING + Common::KEYCODE_HELP // KEYCODE_HELP + }; #endif diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java index 67609e0026..4baadba54d 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java @@ -178,16 +178,19 @@ public class ScummVMEvents implements return true; } + int type; 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, 0); - return true; + if (e.getSource() == InputDevice.SOURCE_DPAD) { + type = JE_DPAD; + } else { + type = JE_KEY; + } + break; case KeyEvent.KEYCODE_BUTTON_A: case KeyEvent.KEYCODE_BUTTON_B: case KeyEvent.KEYCODE_BUTTON_C: @@ -203,15 +206,17 @@ public class ScummVMEvents implements case KeyEvent.KEYCODE_BUTTON_START: case KeyEvent.KEYCODE_BUTTON_SELECT: case KeyEvent.KEYCODE_BUTTON_MODE: - _scummvm.pushEvent(JE_GAMEPAD, action, keyCode, - (int)(e.getEventTime() - e.getDownTime()), - e.getRepeatCount(), 0, 0); - return true; + type = JE_GAMEPAD; + break; + default: + type = JE_KEY; + break; } - _scummvm.pushEvent(JE_KEY, action, keyCode, + _scummvm.pushEvent(type, action, keyCode, e.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK, - e.getMetaState(), e.getRepeatCount(), 0); + e.getMetaState(), e.getRepeatCount(), + (int)(e.getEventTime() - e.getDownTime())); return true; } |