diff --git a/configuration.c b/configuration.c index 60911d2f30..cec6bfbe60 100644 --- a/configuration.c +++ b/configuration.c @@ -1582,6 +1582,7 @@ static void config_set_defaults(void) settings->uints.input_analog_dpad_mode[i] = ANALOG_DPAD_NONE; if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &i)) input_config_set_device(i, RETRO_DEVICE_JOYPAD); + settings->uints.input_mouse_index[i] = 0; } video_driver_reset_custom_viewport(); @@ -2339,6 +2340,9 @@ static bool config_load_file(const char *path, bool set_defaults, snprintf(buf, sizeof(buf), "input_player%u_analog_dpad_mode", i + 1); CONFIG_GET_INT_BASE(conf, settings, uints.input_analog_dpad_mode[i], buf); + snprintf(buf, sizeof(buf), "input_player%u_mouse_index", i + 1); + CONFIG_GET_INT_BASE(conf, settings, uints.input_mouse_index[i], buf); + if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO_DEVICE, &i)) { snprintf(buf, sizeof(buf), "input_libretro_device_p%u", i + 1); @@ -3492,6 +3496,8 @@ bool config_save_file(const char *path) config_set_int(conf, cfg, input_config_get_device(i)); snprintf(cfg, sizeof(cfg), "input_player%u_analog_dpad_mode", i + 1); config_set_int(conf, cfg, settings->uints.input_analog_dpad_mode[i]); + snprintf(cfg, sizeof(cfg), "input_player%u_mouse_index", i + 1); + config_set_int(conf, cfg, settings->uints.input_mouse_index[i]); } /* Boolean settings */ diff --git a/configuration.h b/configuration.h index 8183212f45..0e99efd17b 100644 --- a/configuration.h +++ b/configuration.h @@ -267,6 +267,7 @@ typedef struct settings unsigned input_joypad_map[MAX_USERS]; unsigned input_device[MAX_USERS]; + unsigned input_mouse_index[MAX_USERS]; unsigned input_turbo_period; unsigned input_turbo_duty_cycle; diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 62567e1355..423038c9e7 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -701,6 +701,8 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DEVICE_INDEX, "Device Index") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DEVICE_TYPE, "Device Type") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_INDEX, + "Mouse Index") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DRIVER, "Input Driver") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_DUTY_CYCLE, diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 844fdc2e69..1d1768fc1e 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1299,7 +1299,36 @@ static int setting_action_right_bind_device(void *data, bool wraparound) return 0; } +static int setting_action_left_mouse_index(void *data, bool wraparound) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + settings_t *settings = config_get_ptr(); + if (!setting) + return -1; + + if (settings->uints.input_mouse_index[setting->index_offset]) + { + --settings->uints.input_mouse_index[setting->index_offset]; + settings->modified = true; + } + + return 0; +} + +static int setting_action_right_mouse_index(void *data, bool wraparound) +{ + rarch_setting_t *setting = (rarch_setting_t*)data; + settings_t *settings = config_get_ptr(); + + if (!setting) + return -1; + + ++settings->uints.input_mouse_index[setting->index_offset]; + settings->modified = true; + + return 0; +} /** ******* ACTION OK CALLBACK FUNCTIONS ******* @@ -1918,6 +1947,7 @@ static bool setting_append_list_input_player_options( static char key_bind_all[MAX_USERS][64]; static char key_bind_all_save_autoconfig[MAX_USERS][64]; static char key_bind_defaults[MAX_USERS][64]; + static char mouse_index[MAX_USERS][64]; static char label[MAX_USERS][64]; static char label_type[MAX_USERS][64]; @@ -1925,6 +1955,7 @@ static bool setting_append_list_input_player_options( static char label_bind_all[MAX_USERS][64]; static char label_bind_all_save_autoconfig[MAX_USERS][64]; static char label_bind_defaults[MAX_USERS][64]; + static char label_mouse_index[MAX_USERS][64]; tmp_string[0] = '\0'; @@ -1946,6 +1977,8 @@ static bool setting_append_list_input_player_options( fill_pathname_join_delim(key_bind_defaults[user], tmp_string, "bind_defaults", '_', sizeof(key_bind_defaults[user])); + fill_pathname_join_delim(mouse_index[user], tmp_string, "mouse_index", '_', + sizeof(mouse_index[user])); snprintf(label[user], sizeof(label[user]), "%s %u %s", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_USER), user + 1, @@ -1965,6 +1998,9 @@ static bool setting_append_list_input_player_options( snprintf(label_bind_all_save_autoconfig[user], sizeof(label_bind_all_save_autoconfig[user]), "%s %u %s", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_USER), user + 1, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_SAVE_AUTOCONFIG)); + snprintf(label_mouse_index[user], sizeof(label_mouse_index[user]), + "%s %u %s", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_USER), user + 1, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_INDEX)); CONFIG_UINT_ALT( list, list_info, @@ -2058,6 +2094,22 @@ static bool setting_append_list_input_player_options( (*list)[list_info->index - 1].index_offset = user; (*list)[list_info->index - 1].action_ok = &setting_action_ok_bind_all_save_autoconfig; (*list)[list_info->index - 1].action_cancel = NULL; + + CONFIG_UINT_ALT( + list, list_info, + &settings->uints.input_mouse_index[user], + mouse_index[user], + label_mouse_index[user], + 0, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + (*list)[list_info->index - 1].index = user + 1; + (*list)[list_info->index - 1].index_offset = user; + (*list)[list_info->index - 1].action_left = &setting_action_left_mouse_index; + (*list)[list_info->index - 1].action_right = &setting_action_right_mouse_index; } for (i = 0; i < RARCH_BIND_LIST_END; i ++) diff --git a/msg_hash.h b/msg_hash.h index 60aa55c89d..6dad693b26 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -574,6 +574,7 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_INPUT_BIND_ALL, MENU_ENUM_LABEL_VALUE_INPUT_BIND_DEFAULT_ALL, MENU_ENUM_LABEL_VALUE_INPUT_SAVE_AUTOCONFIG, + MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_INDEX, MENU_LABEL(INPUT_MAX_USERS), MENU_LABEL(INPUT_USER_BINDS),