From 3ec70652382217bfc66d02b333e3a49d18bd6dbd Mon Sep 17 00:00:00 2001 From: Chris Merrett Date: Tue, 22 Oct 2013 22:31:48 +0100 Subject: [PATCH] Added Android support for cheap G910 gamepad. --- android/native/jni/input_android.c | 25 ++++++++++++++++++- android/native/jni/input_autodetect.h | 13 ++++++++++ .../phoenix/res/layout/faq_supported_pads.xml | 2 +- android/phoenix/res/values/array.xml | 2 ++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/android/native/jni/input_android.c b/android/native/jni/input_android.c index d376740612..1adb132f65 100644 --- a/android/native/jni/input_android.c +++ b/android/native/jni/input_android.c @@ -1327,12 +1327,35 @@ static void android_input_set_keybinds(void *data, unsigned device, keycode_lut[AKEYCODE_Q] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift); keycode_lut[AKEYCODE_P] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift); keycode_lut[AKEYCODE_R] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift); - keycode_lut[AKEYCODE_Y] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift); + keycode_lut[AKEYCODE_Y] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift); keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift); keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift); keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift); keycode_lut[AKEYCODE_DPAD_RIGHT]|= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift); break; + case ICADE_PROFILE_G910: + strlcpy(g_settings.input.device_names[port], "G910", + sizeof(g_settings.input.device_names[port])); + /* Face buttons map to SNES layout, not button labels on gamepad -- SNES layout has A to the right of B */ + keycode_lut[AKEYCODE_NUMPAD_LCK_3] |= ((RETRO_DEVICE_ID_JOYPAD_Y+1) << shift); /* Button labeled X on gamepad */ + keycode_lut[AKEYCODE_NUMPAD_LCK_0] |= ((RETRO_DEVICE_ID_JOYPAD_B+1) << shift); /* Button labeled A on gamepad */ + keycode_lut[AKEYCODE_NUMPAD_LCK_1] |= ((RETRO_DEVICE_ID_JOYPAD_A+1) << shift); /* Button labeled B on gamepad */ + keycode_lut[AKEYCODE_NUMPAD_LCK_4] |= ((RETRO_DEVICE_ID_JOYPAD_X+1) << shift); /* Button labeled Y on gamepad */ + keycode_lut[AKEYCODE_NUMPAD_LCK_6] |= ((RETRO_DEVICE_ID_JOYPAD_L+1) << shift); + keycode_lut[AKEYCODE_NUMPAD_LCK_8] |= ((RETRO_DEVICE_ID_JOYPAD_L2+1) << shift); + keycode_lut[AKEYCODE_NUMPAD_LCK_2] |= ((RETRO_DEVICE_ID_JOYPAD_L3+1) << shift); + keycode_lut[AKEYCODE_NUMPAD_LCK_7] |= ((RETRO_DEVICE_ID_JOYPAD_R+1) << shift); + keycode_lut[AKEYCODE_NUMPAD_LCK_9] |= ((RETRO_DEVICE_ID_JOYPAD_R2+1) << shift); + keycode_lut[AKEYCODE_NUMPAD_LCK_5] |= ((RETRO_DEVICE_ID_JOYPAD_R3+1) << shift); + keycode_lut[AKEYCODE_NUMPAD_SUB] |= ((RETRO_DEVICE_ID_JOYPAD_SELECT+1) << shift); + keycode_lut[AKEYCODE_OTHR_108] |= ((RETRO_DEVICE_ID_JOYPAD_START+1) << shift); + /* These don't work, in gamepad mode the dpad sends AXIS_HAT_X and AXIS_HAT_Y motion events + instead of button events, so they get processed by engine_handle_dpad_getaxisvalue() */ + keycode_lut[AKEYCODE_DPAD_UP] |= ((RETRO_DEVICE_ID_JOYPAD_UP+1) << shift); + keycode_lut[AKEYCODE_DPAD_DOWN] |= ((RETRO_DEVICE_ID_JOYPAD_DOWN+1) << shift); + keycode_lut[AKEYCODE_DPAD_LEFT] |= ((RETRO_DEVICE_ID_JOYPAD_LEFT+1) << shift); + keycode_lut[AKEYCODE_DPAD_RIGHT]|= ((RETRO_DEVICE_ID_JOYPAD_RIGHT+1) << shift); + break; case ICADE_PROFILE_GAMESTOP_WIRELESS: strlcpy(g_settings.input.device_names[port], "Gamestop Wireless", sizeof(g_settings.input.device_names[port])); diff --git a/android/native/jni/input_autodetect.h b/android/native/jni/input_autodetect.h index 65e8b5787d..2f9fdc3c85 100644 --- a/android/native/jni/input_autodetect.h +++ b/android/native/jni/input_autodetect.h @@ -26,10 +26,23 @@ enum { ICADE_PROFILE_IPEGA_PG9017, ICADE_PROFILE_IPEGA_PG9017_MODE2, ICADE_PROFILE_GAMESTOP_WIRELESS, + ICADE_PROFILE_G910, } icade_profile_enums; enum { AKEYCODE_META_FUNCTION_ON = 8, + AKEYCODE_NUMPAD_LCK_0 = 96, + AKEYCODE_NUMPAD_LCK_1 = 97, + AKEYCODE_NUMPAD_LCK_2 = 98, + AKEYCODE_NUMPAD_LCK_3 = 99, + AKEYCODE_NUMPAD_LCK_4 = 100, + AKEYCODE_NUMPAD_LCK_5 = 101, + AKEYCODE_NUMPAD_LCK_6 = 102, + AKEYCODE_NUMPAD_LCK_7 = 103, + AKEYCODE_NUMPAD_LCK_8 = 104, + AKEYCODE_NUMPAD_LCK_9 = 105, + AKEYCODE_OTHR_108 = 108, + AKEYCODE_NUMPAD_SUB = 109, AKEYCODE_ESCAPE = 111, AKEYCODE_FORWARD_DEL = 112, AKEYCODE_CTRL_LEFT = 113, diff --git a/android/phoenix/res/layout/faq_supported_pads.xml b/android/phoenix/res/layout/faq_supported_pads.xml index 82f877789f..78e2880609 100644 --- a/android/phoenix/res/layout/faq_supported_pads.xml +++ b/android/phoenix/res/layout/faq_supported_pads.xml @@ -9,5 +9,5 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="40px" - android:text="The following pads have been added to the autodetection list:\n\n* Logitech/Logicool Rumblepad 2\n* Microsoft Sidewinder USB (ISSUE - diagonals not working).\n* Microsoft Xbox 360 Wired/Wireless.\n* PS3 Sixaxis/DualShock 3 (using either USB or Dancingpixelstudios' IME app)\n* MOGA (using either 'root' gamepad mode or official IME app)\n* JXD S5110\n* Snakebyte idroid\n* Logitech Dual Action\n* Mayflash Super Joy Box 3 Pro\n* RetroUSB SNES RetroPort\n* RetroUSB NES RetroPad\n* Buffalo SNES Pad\n* Elecom PS1/PS2 to USB\n* Archos gamepad\n* Xbox 1 (Titanium X-Joy Converter) (ISSUE - diagonals not working).\n* Red Samurai (IME app Bluetooth or gamepad mode)\n* Xperia Play\n* Trust Raptor\n* Logitech F710\n* DragonRise USB\n* Madcatz PS3 fighting stick\n* iControlPad (HID joystick profile or SPP profile in tandem with Bluez IME)\n* iPega (gamepad mode, select it in iCade profile)\n* PC2JAMMA-USB (TODO - TEST)\n* Genius MaxFire G-08XU\n* Zeemote Steelseries\n* Saitek Rumblepad\n* Super Smart Joy\n* Groupwise PS2 to USB converter\n* Toodles 2008 Chimp\n* Sega Saturn USB pad\n* Mayflash Wii Classic\n* Mayflash PS2 to USB\n* Nintendo Wii (using ccpcreations.WiiUse IME app)\n* Nyko Playpad Pro\n*Nvidia Shield" /> + android:text="The following pads have been added to the autodetection list:\n\n* Logitech/Logicool Rumblepad 2\n* Microsoft Sidewinder USB (ISSUE - diagonals not working).\n* Microsoft Xbox 360 Wired/Wireless.\n* PS3 Sixaxis/DualShock 3 (using either USB or Dancingpixelstudios' IME app)\n* MOGA (using either 'root' gamepad mode or official IME app)\n* JXD S5110\n* Snakebyte idroid\n* Logitech Dual Action\n* Mayflash Super Joy Box 3 Pro\n* RetroUSB SNES RetroPort\n* RetroUSB NES RetroPad\n* Buffalo SNES Pad\n* Elecom PS1/PS2 to USB\n* Archos gamepad\n* Xbox 1 (Titanium X-Joy Converter) (ISSUE - diagonals not working).\n* Red Samurai (IME app Bluetooth or gamepad mode)\n* Xperia Play\n* Trust Raptor\n* Logitech F710\n* DragonRise USB\n* Madcatz PS3 fighting stick\n* iControlPad (HID joystick profile or SPP profile in tandem with Bluez IME)\n* iPega (gamepad mode, select it in iCade profile)\n* G910 (gamepad mode, select it in iCade profile)\n* PC2JAMMA-USB (TODO - TEST)\n* Genius MaxFire G-08XU\n* Zeemote Steelseries\n* Saitek Rumblepad\n* Super Smart Joy\n* Groupwise PS2 to USB converter\n* Toodles 2008 Chimp\n* Sega Saturn USB pad\n* Mayflash Wii Classic\n* Mayflash PS2 to USB\n* Nintendo Wii (using ccpcreations.WiiUse IME app)\n* Nyko Playpad Pro\n*Nvidia Shield" /> diff --git a/android/phoenix/res/values/array.xml b/android/phoenix/res/values/array.xml index e0909f36d0..9faa68841b 100644 --- a/android/phoenix/res/values/array.xml +++ b/android/phoenix/res/values/array.xml @@ -49,6 +49,7 @@ iPega PG-9017 iPega PG-9017 (Mode 2) Gamestop Wireless + G910 @@ -56,6 +57,7 @@ 1 2 3 + 4