diff --git a/console/rarch_console_input.c b/console/rarch_console_input.c index 2de9f9df0b..9b96dd759c 100644 --- a/console/rarch_console_input.c +++ b/console/rarch_console_input.c @@ -20,15 +20,10 @@ #include #include "../boolean.h" +#include "../driver.h" #include "../general.h" #include "rarch_console_input.h" -struct platform_bind -{ - uint64_t joykey; - const char *label; -}; - extern const struct platform_bind platform_keys[]; extern const unsigned int platform_keys_size; @@ -41,66 +36,8 @@ const char *rarch_input_find_platform_key_label(uint64_t joykey) for (size_t i = 0; i < arr_size; i++) { if (platform_keys[i].joykey == joykey) - return platform_keys[i].label; + return platform_keys[i].desc; } return "Unknown"; } - -void rarch_input_set_keybind(unsigned port, unsigned keybind_action, uint64_t id) -{ - uint64_t *key = &g_settings.input.binds[port][id].joykey; - uint64_t joykey = *key; - size_t arr_size; - - switch (keybind_action) - { - case KEYBINDS_ACTION_DECREMENT_BIND: - arr_size = platform_keys_size / sizeof(platform_keys[0]); - - if (joykey == NO_BTN) - *key = platform_keys[arr_size - 1].joykey; - else if (platform_keys[0].joykey == joykey) - *key = NO_BTN; - else - { - *key = NO_BTN; - for (size_t i = 1; i < arr_size; i++) - { - if (platform_keys[i].joykey == joykey) - { - *key = platform_keys[i - 1].joykey; - break; - } - } - } - break; - case KEYBINDS_ACTION_INCREMENT_BIND: - arr_size = platform_keys_size / sizeof(platform_keys[0]); - - if (joykey == NO_BTN) - *key = platform_keys[0].joykey; - else if (platform_keys[arr_size - 1].joykey == joykey) - *key = NO_BTN; - else - { - *key = NO_BTN; - for (size_t i = 0; i < arr_size - 1; i++) - { - if (platform_keys[i].joykey == joykey) - { - *key = platform_keys[i + 1].joykey; - break; - } - } - } - break; - - case KEYBINDS_ACTION_SET_DEFAULT_BIND: - *key = g_settings.input.binds[port][id].def_joykey; - break; - - default: - break; - } -} diff --git a/console/rarch_console_input.h b/console/rarch_console_input.h index d4dd89aad9..dfba3fba92 100644 --- a/console/rarch_console_input.h +++ b/console/rarch_console_input.h @@ -17,9 +17,6 @@ #ifndef CONSOLE_EXT_INPUT_H__ #define CONSOLE_EXT_INPUT_H__ -#include "../driver.h" - const char *rarch_input_find_platform_key_label(uint64_t joykey); -void rarch_input_set_keybind(unsigned player, unsigned keybind_action, uint64_t default_retro_joypad_id); #endif diff --git a/driver.h b/driver.h index ee3109eacc..9de37075d2 100644 --- a/driver.h +++ b/driver.h @@ -132,6 +132,12 @@ struct retro_keybind uint32_t joyaxis; }; +struct platform_bind +{ + uint64_t joykey; + const char *desc; +}; + enum rarch_shader_type { RARCH_SHADER_CG, diff --git a/frontend/frontend_bbqnx.c b/frontend/frontend_bbqnx.c index 47d2200cb9..491c00148e 100644 --- a/frontend/frontend_bbqnx.c +++ b/frontend/frontend_bbqnx.c @@ -67,7 +67,7 @@ int rarch_main(int argc, char *argv[]) args.verbose = g_extern.verbose; args.sram_path = NULL; args.state_path = NULL; - args.rom_path = "/accounts/1000/shared/documents/roms/test.rom"; + args.rom_path = "/accounts/1000/shared/documents/roms/quake/pak0.pak"; args.libretro_path = "/accounts/1000/appdata/com.RetroArch.testDev_m_RetroArch181dafc7/app/native/lib/test.so"; args.config_path = "/accounts/1000/appdata/com.RetroArch.testDev_m_RetroArch181dafc7/app/native/retroarch.cfg"; diff --git a/frontend/menu/menu_settings.c b/frontend/menu/menu_settings.c index c7069a21ab..e74c338d93 100644 --- a/frontend/menu/menu_settings.c +++ b/frontend/menu/menu_settings.c @@ -283,7 +283,9 @@ void menu_settings_create_menu_item_label(char * str, unsigned setting, size_t s snprintf(str, size, "Shader #2: %s", g_settings.video.second_pass_shader); break; case S_LBL_RARCH_VERSION: +#ifndef __BLACKBERRY_QNX__ snprintf(str, size, "RetroArch %s", PACKAGE_VERSION); +#endif break; case S_LBL_SCALE_FACTOR: snprintf(str, size, "Scale Factor: %f (X) / %f (Y)", g_settings.video.fbo.scale_x, g_settings.video.fbo.scale_y); diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index b2c93017f6..8de78bee54 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -974,20 +974,21 @@ static int rgui_settings_toggle_setting(unsigned setting, rgui_action_t action, case RGUI_SETTINGS_BIND_R2: case RGUI_SETTINGS_BIND_L3: case RGUI_SETTINGS_BIND_R3: - { - unsigned keybind_action = KEYBINDS_ACTION_NONE; + if (driver.input->set_keybinds) + { + unsigned keybind_action = KEYBINDS_ACTION_NONE; - if (action == RGUI_ACTION_START) - keybind_action = KEYBINDS_ACTION_SET_DEFAULT_BIND; - else if (action == RGUI_ACTION_LEFT) - keybind_action = KEYBINDS_ACTION_DECREMENT_BIND; - else if (action == RGUI_ACTION_RIGHT) - keybind_action = KEYBINDS_ACTION_INCREMENT_BIND; - else - break; + if (action == RGUI_ACTION_START) + keybind_action = (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BIND); + else if (action == RGUI_ACTION_LEFT) + keybind_action = (1ULL << KEYBINDS_ACTION_DECREMENT_BIND); + else if (action == RGUI_ACTION_RIGHT) + keybind_action = (1ULL << KEYBINDS_ACTION_INCREMENT_BIND); - rarch_input_set_keybind(port, keybind_action, rgui_controller_lut[setting - RGUI_SETTINGS_BIND_UP]); - } + if (keybind_action != KEYBINDS_ACTION_NONE) + driver.input->set_keybinds(driver.input_data, g_settings.input.device[setting - RGUI_SETTINGS_BIND_UP], port, + rgui_controller_lut[setting - RGUI_SETTINGS_BIND_UP], keybind_action); + } #endif default: break; diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 7e35f0468a..ac81aceaa9 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -1103,20 +1103,26 @@ int select_directory(void *data, void *state) return 0; } -static void set_keybind_digital(uint64_t default_retro_joypad_id, uint64_t input) +static void set_keybind_digital(unsigned default_retro_joypad_id, uint64_t input) { + if (!driver.input->set_keybinds) + return; + unsigned keybind_action = KEYBINDS_ACTION_NONE; if(input & (1ULL << RMENU_DEVICE_NAV_LEFT)) - keybind_action = KEYBINDS_ACTION_DECREMENT_BIND; + keybind_action = (1ULL << KEYBINDS_ACTION_DECREMENT_BIND); if((input & (1ULL << RMENU_DEVICE_NAV_RIGHT)) || (input & (1ULL << RMENU_DEVICE_NAV_B))) - keybind_action = KEYBINDS_ACTION_INCREMENT_BIND; + keybind_action = (1ULL << KEYBINDS_ACTION_INCREMENT_BIND); if(input & (1ULL << RMENU_DEVICE_NAV_START)) - keybind_action = KEYBINDS_ACTION_SET_DEFAULT_BIND; + keybind_action = (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BIND); - rarch_input_set_keybind(currently_selected_controller_menu, keybind_action, default_retro_joypad_id); + + if (keybind_action) + driver.input->set_keybinds(driver.input_data, NULL, currently_selected_controller_menu, + default_retro_joypad_id, keybind_action); } #if defined(HAVE_OSKUTIL) diff --git a/frontend/menu/rmenu_xui.cpp b/frontend/menu/rmenu_xui.cpp index 3ec22b765f..c2bc574a86 100644 --- a/frontend/menu/rmenu_xui.cpp +++ b/frontend/menu/rmenu_xui.cpp @@ -475,7 +475,10 @@ HRESULT CRetroArchControls::OnControlNavigate( case SETTING_CONTROLS_DEFAULT_ALL: break; default: - rarch_input_set_keybind(controlno, KEYBINDS_ACTION_DECREMENT_BIND, current_index); + if (driver.input->set_keybinds) + driver.input->set_keybinds(driver.input_data, g_settings.input.device[controlno], + controlno, current_index, (1ULL << KEYBINDS_ACTION_DECREMENT_BIND)); + snprintf(button, sizeof(button), "%s #%d: %s", g_settings.input.binds[controlno][current_index].desc, controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); @@ -512,7 +515,10 @@ HRESULT CRetroArchControls::OnControlNavigate( case SETTING_CONTROLS_DEFAULT_ALL: break; default: - rarch_input_set_keybind(controlno, KEYBINDS_ACTION_INCREMENT_BIND, current_index); + if (driver.input->set_keybinds) + driver.input->set_keybinds(driver.input_data, g_settings.input.device[controlno], + controlno, current_index, (1ULL << KEYBINDS_ACTION_INCREMENT_BIND)); + snprintf(button, sizeof(button), "%s #%d: %s", g_settings.input.binds[controlno][current_index].desc, controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); @@ -567,7 +573,10 @@ HRESULT CRetroArchControls::OnNotifyPress( HXUIOBJ hObjPressed, int & bHandled } break; default: - rarch_input_set_keybind(controlno, KEYBINDS_ACTION_SET_DEFAULT_BIND, current_index); + if (driver.input->set_keybinds) + driver.input->set_keybinds(driver.input_data, g_settings.input.device[controlno], + controlno, current_index, (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BIND)); + snprintf(buttons[current_index], sizeof(buttons[current_index]), "%s #%d: %s", g_settings.input.binds[controlno][current_index].desc, controlno, rarch_input_find_platform_key_label(g_settings.input.binds[controlno][current_index].joykey)); diff --git a/gx/gx_input.c b/gx/gx_input.c index c7c9edcd75..ae9dadb725 100644 --- a/gx/gx_input.c +++ b/gx/gx_input.c @@ -166,7 +166,58 @@ static void power_callback(void) static void gx_input_set_keybinds(void *data, unsigned device, unsigned port, unsigned id, unsigned keybind_action) { - (void)id; + uint64_t *key = &g_settings.input.binds[port][id].joykey; + uint64_t joykey = *key; + size_t arr_size; + + (void)device; + + if (keybind_action & (1ULL << KEYBINDS_ACTION_DECREMENT_BIND)) + { + arr_size = platform_keys_size / sizeof(platform_keys[0]); + + if (joykey == NO_BTN) + *key = platform_keys[arr_size - 1].joykey; + else if (platform_keys[0].joykey == joykey) + *key = NO_BTN; + else + { + *key = NO_BTN; + for (size_t i = 1; i < arr_size; i++) + { + if (platform_keys[i].joykey == joykey) + { + *key = platform_keys[i - 1].joykey; + break; + } + } + } + } + + if (keybind_action & (1ULL << KEYBINDS_ACTION_INCREMENT_BIND)) + { + arr_size = platform_keys_size / sizeof(platform_keys[0]); + + if (joykey == NO_BTN) + *key = platform_keys[0].joykey; + else if (platform_keys[arr_size - 1].joykey == joykey) + *key = NO_BTN; + else + { + *key = NO_BTN; + for (size_t i = 0; i < arr_size - 1; i++) + { + if (platform_keys[i].joykey == joykey) + { + *key = platform_keys[i + 1].joykey; + break; + } + } + } + } + + if (keybind_action & (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BIND)) + *key = g_settings.input.binds[port][id].def_joykey; if (keybind_action & (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS)) { diff --git a/ps3/ps3_input.c b/ps3/ps3_input.c index 029339f4a0..4afaba8d8d 100644 --- a/ps3/ps3_input.c +++ b/ps3/ps3_input.c @@ -400,8 +400,58 @@ static void ps3_input_free_input(void *data) static void ps3_input_set_keybinds(void *data, unsigned device, unsigned port, unsigned id, unsigned keybind_action) { + uint64_t *key = &g_settings.input.binds[port][id].joykey; + uint64_t joykey = *key; + size_t arr_size; + (void)device; - (void)id; + + if (keybind_action & (1ULL << KEYBINDS_ACTION_DECREMENT_BIND)) + { + arr_size = platform_keys_size / sizeof(platform_keys[0]); + + if (joykey == NO_BTN) + *key = platform_keys[arr_size - 1].joykey; + else if (platform_keys[0].joykey == joykey) + *key = NO_BTN; + else + { + *key = NO_BTN; + for (size_t i = 1; i < arr_size; i++) + { + if (platform_keys[i].joykey == joykey) + { + *key = platform_keys[i - 1].joykey; + break; + } + } + } + } + + if (keybind_action & (1ULL << KEYBINDS_ACTION_INCREMENT_BIND)) + { + arr_size = platform_keys_size / sizeof(platform_keys[0]); + + if (joykey == NO_BTN) + *key = platform_keys[0].joykey; + else if (platform_keys[arr_size - 1].joykey == joykey) + *key = NO_BTN; + else + { + *key = NO_BTN; + for (size_t i = 0; i < arr_size - 1; i++) + { + if (platform_keys[i].joykey == joykey) + { + *key = platform_keys[i + 1].joykey; + break; + } + } + } + } + + if (keybind_action & (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BIND)) + *key = g_settings.input.binds[port][id].def_joykey; if (keybind_action & (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS)) { diff --git a/xdk/xdk_xinput_input.c b/xdk/xdk_xinput_input.c index f7085904e0..e8d5d7638f 100644 --- a/xdk/xdk_xinput_input.c +++ b/xdk/xdk_xinput_input.c @@ -272,8 +272,58 @@ static void xdk_input_free_input(void *data) static void xdk_input_set_keybinds(void *data, unsigned device, unsigned port, unsigned id, unsigned keybind_action) { + uint64_t *key = &g_settings.input.binds[port][id].joykey; + uint64_t joykey = *key; + size_t arr_size; + (void)device; - (void)id; + + if (keybind_action & (1ULL << KEYBINDS_ACTION_DECREMENT_BIND)) + { + arr_size = platform_keys_size / sizeof(platform_keys[0]); + + if (joykey == NO_BTN) + *key = platform_keys[arr_size - 1].joykey; + else if (platform_keys[0].joykey == joykey) + *key = NO_BTN; + else + { + *key = NO_BTN; + for (size_t i = 1; i < arr_size; i++) + { + if (platform_keys[i].joykey == joykey) + { + *key = platform_keys[i - 1].joykey; + break; + } + } + } + } + + if (keybind_action & (1ULL << KEYBINDS_ACTION_INCREMENT_BIND)) + { + arr_size = platform_keys_size / sizeof(platform_keys[0]); + + if (joykey == NO_BTN) + *key = platform_keys[0].joykey; + else if (platform_keys[arr_size - 1].joykey == joykey) + *key = NO_BTN; + else + { + *key = NO_BTN; + for (size_t i = 0; i < arr_size - 1; i++) + { + if (platform_keys[i].joykey == joykey) + { + *key = platform_keys[i + 1].joykey; + break; + } + } + } + } + + if (keybind_action & (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BIND)) + *key = g_settings.input.binds[port][id].def_joykey; if (keybind_action & (1ULL << KEYBINDS_ACTION_SET_DEFAULT_BINDS)) {