int menu_input_key_bind_set_mode(void *data, enum menu_input_bind_mode type) { unsigned index_offset; menu_handle_t *menu = menu_driver_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); rarch_setting_t *setting = (rarch_setting_t*)data; settings_t *settings = config_get_ptr(); if (!setting) return -1; if (menu_input_key_bind_set_mode_common(setting, type) == -1) return -1; index_offset = menu_setting_get_index_offset(setting); bind_port = settings->input.joypad_map[index_offset]; menu_input_key_bind_poll_bind_get_rested_axes(&menu_input->binds, bind_port); menu_input_key_bind_poll_bind_state(&menu_input->binds, bind_port, false); menu_input->binds.timeout_end = retro_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; input_keyboard_wait_keys(menu, menu_input_key_bind_custom_bind_keyboard_cb); return 0; }
static bool menu_input_key_bind_set_mode( enum menu_input_ctl_state state, void *data) { unsigned index_offset; input_keyboard_ctx_wait_t keys; menu_handle_t *menu = NULL; menu_input_t *menu_input = menu_input_get_ptr(); rarch_setting_t *setting = (rarch_setting_t*)data; settings_t *settings = config_get_ptr(); if (!setting) return false; if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return false; if (menu_input_key_bind_set_mode_common(state, setting) == -1) return false; index_offset = menu_setting_get_index_offset(setting); bind_port = settings->input.joypad_map[index_offset]; menu_input_key_bind_poll_bind_get_rested_axes( &menu_input->binds, bind_port); menu_input_key_bind_poll_bind_state( &menu_input->binds, bind_port, false); menu_input->binds.timeout_end = cpu_features_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; keys.userdata = menu; keys.cb = menu_input_key_bind_custom_bind_keyboard_cb; input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_START_WAIT_KEYS, &keys); return true; }
int menu_input_key_bind_set_mode(void *data, enum menu_input_bind_mode type) { menu_handle_t *menu = menu_driver_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); rarch_setting_t *setting = (rarch_setting_t*)data; settings_t *settings = config_get_ptr(); bool joypad_pressed = BIT64_GET(menu_input->devices_mask, settings->menu_ok_btn); if (!setting) return -1; if (menu_input_key_bind_set_mode_common(setting, type) == -1) return -1; switch (settings->input.bind_mode) { case 0: break; case 1: joypad_pressed = false; break; case 2: joypad_pressed = true; break; } if (joypad_pressed) { unsigned index_offset = menu_setting_get_index_offset(setting); bind_port = settings->input.joypad_map[index_offset]; menu_input_key_bind_poll_bind_get_rested_axes(&menu_input->binds, bind_port); menu_input_key_bind_poll_bind_state(&menu_input->binds, bind_port, false); menu_input_key_bind_set_timeout(); menu_input->bind_mode_keyboard = false; return 0; } menu_input->bind_mode_keyboard = true; menu_input_key_bind_set_timeout(); input_keyboard_wait_keys(menu, menu_input_key_bind_custom_bind_keyboard_cb); return 0; }
static int menu_input_key_bind_set_mode_common(rarch_setting_t *setting, enum menu_input_bind_mode type) { size_t selection; unsigned index_offset, bind_type; menu_displaylist_info_t info = {0}; struct retro_keybind *keybind = NULL; file_list_t *menu_stack = NULL; settings_t *settings = config_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); if (!setting) return -1; index_offset = menu_setting_get_index_offset(setting); menu_stack = menu_entries_get_menu_stack_ptr(0); menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); switch (type) { case MENU_INPUT_BIND_NONE: return -1; case MENU_INPUT_BIND_SINGLE: keybind = (struct retro_keybind*)setting_get_ptr(setting); if (!keybind) return -1; bind_type = menu_setting_get_bind_type(setting); menu_input->binds.begin = bind_type; menu_input->binds.last = bind_type; menu_input->binds.target = keybind; menu_input->binds.user = index_offset; info.list = menu_stack; info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; info.directory_ptr = selection; strlcpy(info.label, menu_hash_to_str(MENU_LABEL_CUSTOM_BIND), sizeof(info.label)); if (menu_displaylist_push_list(&info, DISPLAYLIST_INFO) == 0) menu_displaylist_push_list_process(&info); break; case MENU_INPUT_BIND_ALL: menu_input->binds.target = &settings->input.binds [index_offset][0]; menu_input->binds.begin = MENU_SETTINGS_BIND_BEGIN; menu_input->binds.last = MENU_SETTINGS_BIND_LAST; info.list = menu_stack; info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; info.directory_ptr = selection; strlcpy(info.label, menu_hash_to_str(MENU_LABEL_CUSTOM_BIND_ALL), sizeof(info.label)); if (menu_displaylist_push_list(&info, DISPLAYLIST_INFO) == 0) menu_displaylist_push_list_process(&info); break; } return 0; }