From 75104aa4e240d7c89965dcead32f47c9afe55b83 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 25 May 2013 18:20:31 +0200 Subject: [PATCH] (iOS) First stab at being able to set default binds (for Wiimote + Classic) --- driver.h | 4 ++++ ios/RetroArch/input/ios_input.c | 39 ++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/driver.h b/driver.h index 998323bbda..fdd8dfef88 100644 --- a/driver.h +++ b/driver.h @@ -279,6 +279,10 @@ enum input_devices DEVICE_KEYBOARD, DEVICE_KEYPAD, DEVICE_UNKNOWN, +#elif defined(IOS) + DEVICE_NONE, + DEVICE_WIIMOTE, + DEVICE_SIXAXIS, #endif DEVICE_LAST }; diff --git a/ios/RetroArch/input/ios_input.c b/ios/RetroArch/input/ios_input.c index e31f066971..55f065c3ce 100644 --- a/ios/RetroArch/input/ios_input.c +++ b/ios/RetroArch/input/ios_input.c @@ -109,13 +109,50 @@ static void ios_input_free_input(void *data) (void)data; } +static void ios_input_set_keybinds(void *data, unsigned device, unsigned port, + unsigned id, unsigned keybind_action) +{ + (void)device; + + if (keybind_action & (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS)) + { + switch (device) + { + case DEVICE_NONE: + break; + case DEVICE_WIIMOTE: + strlcpy(g_settings.input.device_names[port], "Wiimote + Classic", + sizeof(g_settings.input.device_names[port])); + g_settings.input.device[port] = device; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_B].def_joykey = 22; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_Y].def_joykey = 21; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_SELECT].def_joykey = 28; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_START].def_joykey = 26; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_UP].def_joykey = 16; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_DOWN].def_joykey = 30; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_LEFT].def_joykey = 17; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_RIGHT].def_joykey = 31; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_A].def_joykey = 20; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_X].def_joykey = 19; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L].def_joykey = 29; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R].def_joykey = 25; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_L2].def_joykey = 23; + g_settings.input.binds[port][RETRO_DEVICE_ID_JOYPAD_R2].def_joykey = 18; + g_settings.input.dpad_emulation[port] = ANALOG_DPAD_NONE; + break; + case DEVICE_SIXAXIS: + break; + } + } +} + const input_driver_t input_ios = { ios_input_init, ios_input_poll, ios_input_state, ios_bind_button_pressed, ios_input_free_input, - NULL, + ios_input_set_keybinds, "ios_input", };