Bind Mode is no longer needed - will detect if we are pressing

on a gamepad or keyboard
This commit is contained in:
twinaphex 2015-10-22 20:21:27 +02:00
parent 5f67c041b0
commit e6541cb699
3 changed files with 33 additions and 64 deletions

View File

@ -664,14 +664,37 @@ static void menu_input_key_bind_set_timeout(void)
MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000;
}
int menu_input_key_bind_set_keyboard_mode(void *data,
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();
global_t *global = global_get_ptr();
bool joypad_pressed = BIT64_GET(menu_input->devices_mask, settings->menu_ok_btn);
if (!setting || menu_input_key_bind_set_mode_common(setting, type) == -1)
if (!setting)
return -1;
if (menu_input_key_bind_set_mode_common(setting, type) == -1)
return -1;
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();
global->menu.bind_mode_keyboard = false;
return 0;
}
global->menu.bind_mode_keyboard = true;
menu_input_key_bind_set_timeout();
input_keyboard_wait_keys(menu,
@ -679,31 +702,6 @@ int menu_input_key_bind_set_keyboard_mode(void *data,
return 0;
}
int menu_input_key_bind_set_device_mode(void *data,
enum menu_input_bind_mode type)
{
unsigned index_offset;
menu_input_t *menu_input = menu_input_get_ptr();
settings_t *settings = config_get_ptr();
rarch_setting_t *setting = (rarch_setting_t*)data;
if (!setting)
return -1;
index_offset = menu_setting_get_index_offset(setting);
bind_port = settings->input.joypad_map[index_offset];
if (menu_input_key_bind_set_mode_common(setting, type) == -1)
return -1;
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();
return 0;
}
void menu_input_key_bind_set_min_max(unsigned min, unsigned max)
{
menu_input_t *menu_input = menu_input_get_ptr();

View File

@ -107,9 +107,7 @@ void menu_input_key_start_line(const char *label,
int menu_input_key_bind_iterate(char *s, size_t len);
int menu_input_key_bind_set_keyboard_mode(void *data, enum menu_input_bind_mode type);
int menu_input_key_bind_set_device_mode(void *data, enum menu_input_bind_mode type);
int menu_input_key_bind_set_mode(void *data, enum menu_input_bind_mode type);
void menu_input_key_bind_set_min_max(unsigned min, unsigned max);

View File

@ -921,12 +921,8 @@ static int setting_bind_action_start(void *data)
if (!keybind)
return -1;
if (!global->menu.bind_mode_keyboard)
{
keybind->joykey = NO_BTN;
keybind->joyaxis = AXIS_NONE;
return 0;
}
keybind->joykey = NO_BTN;
keybind->joyaxis = AXIS_NONE;
if (setting->index_offset)
def_binds = (struct retro_keybind*)retro_keybinds_rest;
@ -1449,10 +1445,7 @@ static int setting_action_ok_bind_all(void *data, bool wraparound)
if (!global)
return -1;
if (global->menu.bind_mode_keyboard)
menu_input_key_bind_set_keyboard_mode(data, MENU_INPUT_BIND_ALL);
else
menu_input_key_bind_set_device_mode(data, MENU_INPUT_BIND_ALL);
menu_input_key_bind_set_mode(data, MENU_INPUT_BIND_ALL);
return 0;
}
@ -1506,13 +1499,9 @@ static int setting_action_ok_bind_defaults(void *data, bool wraparound)
for (i = MENU_SETTINGS_BIND_BEGIN;
i <= MENU_SETTINGS_BIND_LAST; i++, target++)
{
if (global->menu.bind_mode_keyboard)
target->key = def_binds[i - MENU_SETTINGS_BIND_BEGIN].key;
else
{
target->joykey = NO_BTN;
target->joyaxis = AXIS_NONE;
}
target->key = def_binds[i - MENU_SETTINGS_BIND_BEGIN].key;
target->joykey = NO_BTN;
target->joyaxis = AXIS_NONE;
}
return 0;
@ -1596,10 +1585,7 @@ static int setting_bind_action_ok(void *data, bool wraparound)
global_t *global = global_get_ptr();
(void)wraparound;
if (global->menu.bind_mode_keyboard)
menu_input_key_bind_set_keyboard_mode(data, MENU_INPUT_BIND_SINGLE);
else
menu_input_key_bind_set_device_mode(data, MENU_INPUT_BIND_SINGLE);
menu_input_key_bind_set_mode(data, MENU_INPUT_BIND_SINGLE);
return 0;
}
@ -4778,19 +4764,6 @@ static bool setting_append_list_input_options(
subgroup_info,
parent_group);
CONFIG_BOOL(
global->menu.bind_mode_keyboard,
menu_hash_to_str(MENU_LABEL_INPUT_BIND_MODE),
menu_hash_to_str(MENU_LABEL_VALUE_INPUT_BIND_MODE),
false,
menu_hash_to_str(MENU_VALUE_RETROPAD),
menu_hash_to_str(MENU_VALUE_RETROKEYBOARD),
group_info.name,
subgroup_info.name,
parent_group,
general_write_handler,
general_read_handler);
for (user = 0; user < settings->input.max_users; user ++)
{
/* These constants match the string lengths.