Skip to content

Commit

Permalink
Add option for merging 'Hotkey Enable' device types (#16152)
Browse files Browse the repository at this point in the history
  • Loading branch information
sonninnos authored Jan 22, 2024
1 parent cd9fb0d commit 266d3ed
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 2 deletions.
1 change: 1 addition & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,7 @@
#define DEFAULT_INPUT_BIND_HOLD 0
#define DEFAULT_INPUT_POLL_TYPE_BEHAVIOR 2
#define DEFAULT_INPUT_HOTKEY_BLOCK_DELAY 5
#define DEFAULT_INPUT_HOTKEY_DEVICE_MERGE false

#define DEFAULT_GFX_THUMBNAILS_DEFAULT 3

Expand Down
1 change: 1 addition & 0 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,7 @@ static struct config_bool_setting *populate_settings_bool(
SETTING_BOOL("input_allow_turbo_dpad", &settings->bools.input_allow_turbo_dpad, true, DEFAULT_ALLOW_TURBO_DPAD, false);
SETTING_BOOL("input_auto_mouse_grab", &settings->bools.input_auto_mouse_grab, true, false, false);
SETTING_BOOL("input_remap_binds_enable", &settings->bools.input_remap_binds_enable, true, true, false);
SETTING_BOOL("input_hotkey_device_merge", &settings->bools.input_hotkey_device_merge, true, DEFAULT_INPUT_HOTKEY_DEVICE_MERGE, false);
SETTING_BOOL("all_users_control_menu", &settings->bools.input_all_users_control_menu, true, DEFAULT_ALL_USERS_CONTROL_MENU, false);
#ifdef HAVE_MENU
SETTING_BOOL("menu_swap_ok_cancel_buttons", &settings->bools.input_menu_swap_ok_cancel_buttons, true, DEFAULT_MENU_SWAP_OK_CANCEL_BUTTONS, false);
Expand Down
1 change: 1 addition & 0 deletions configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ typedef struct settings
bool input_keyboard_gamepad_enable;
bool input_auto_mouse_grab;
bool input_allow_turbo_dpad;
bool input_hotkey_device_merge;
#if defined(HAVE_DINPUT) || defined(HAVE_WINRAWINPUT)
bool input_nowinkey_enable;
#endif
Expand Down
10 changes: 8 additions & 2 deletions input/input_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -4738,7 +4738,8 @@ static void input_keys_pressed(
const struct retro_keybind *binds_auto,
const input_device_driver_t *joypad,
const input_device_driver_t *sec_joypad,
rarch_joypad_info_t *joypad_info)
rarch_joypad_info_t *joypad_info,
settings_t *settings)
{
unsigned i;
input_driver_state_t *input_st = &input_driver_st;
Expand All @@ -4754,6 +4755,10 @@ static void input_keys_pressed(
if (!binds)
return;

if ( settings->bools.input_hotkey_device_merge
&& (libretro_hotkey_set || keyboard_hotkey_set))
libretro_hotkey_set = keyboard_hotkey_set = true;

if ( binds[port][RARCH_ENABLE_HOTKEY].valid
&& CHECK_INPUT_DRIVER_BLOCK_HOTKEY(binds_norm, binds_auto))
{
Expand Down Expand Up @@ -6265,7 +6270,8 @@ void input_driver_collect_system_input(input_driver_state_t *input_st,
binds_auto,
joypad,
sec_joypad,
&joypad_info);
&joypad_info,
settings);

#ifdef HAVE_MENU
if (menu_is_alive)
Expand Down
4 changes: 4 additions & 0 deletions intl/msg_hash_lbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,10 @@ MSG_HASH(
MENU_ENUM_LABEL_INPUT_HOTKEY_BLOCK_DELAY,
"input_hotkey_block_delay"
)
MSG_HASH(
MENU_ENUM_LABEL_INPUT_HOTKEY_DEVICE_MERGE,
"input_hotkey_device_merge"
)
MSG_HASH(
MENU_ENUM_LABEL_INPUT_ICADE_ENABLE,
"input_icade_enable"
Expand Down
8 changes: 8 additions & 0 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -3532,6 +3532,14 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_HOTKEY_BLOCK_DELAY,
"Add a delay in frames before normal input is blocked after pressing the assigned 'Hotkey Enable' key. Allows normal input from the 'Hotkey Enable' key to be captured when it is mapped to another action (e.g. RetroPad 'Select')."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_HOTKEY_DEVICE_MERGE,
"Hotkey Device Type Merge"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_INPUT_HOTKEY_DEVICE_MERGE,
"Block all hotkeys from both keyboard and controller device types if either type has 'Hotkey Enable' set."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_INPUT_MENU_ENUM_TOGGLE_GAMEPAD_COMBO,
"Menu Toggle (Controller Combo)"
Expand Down
4 changes: 4 additions & 0 deletions menu/cbs/menu_cbs_sublabel.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_meta_netplay_player_chat, ME
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_meta_netplay_fade_chat_toggle, MENU_ENUM_SUBLABEL_INPUT_META_NETPLAY_FADE_CHAT_TOGGLE)

DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_hotkey_block_delay, MENU_ENUM_SUBLABEL_INPUT_HOTKEY_BLOCK_DELAY)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_hotkey_device_merge, MENU_ENUM_SUBLABEL_INPUT_HOTKEY_DEVICE_MERGE)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_device_type, MENU_ENUM_SUBLABEL_INPUT_DEVICE_TYPE)
DEFAULT_SUBLABEL_MACRO(action_bind_sublabel_input_adc_type, MENU_ENUM_SUBLABEL_INPUT_ADC_TYPE)
#ifdef HAVE_MATERIALUI
Expand Down Expand Up @@ -4777,6 +4778,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_INPUT_HOTKEY_BLOCK_DELAY:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_hotkey_block_delay);
break;
case MENU_ENUM_LABEL_INPUT_HOTKEY_DEVICE_MERGE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_input_hotkey_device_merge);
break;
case MENU_ENUM_LABEL_INPUT_USER_1_BINDS:
case MENU_ENUM_LABEL_INPUT_USER_2_BINDS:
case MENU_ENUM_LABEL_INPUT_USER_3_BINDS:
Expand Down
4 changes: 4 additions & 0 deletions menu/menu_displaylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -6829,6 +6829,10 @@ unsigned menu_displaylist_build_list(
MENU_ENUM_LABEL_INPUT_HOTKEY_BLOCK_DELAY,
PARSE_ONLY_UINT, false) == 0)
count++;
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
MENU_ENUM_LABEL_INPUT_HOTKEY_DEVICE_MERGE,
PARSE_ONLY_BOOL, false) == 0)
count++;

/* All other binds come last */
for (i = 0; i < RARCH_BIND_LIST_END; i++)
Expand Down
16 changes: 16 additions & 0 deletions menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -14936,6 +14936,22 @@ static bool setting_append_list(
menu_settings_list_current_add_range(list, list_info, 0, 600, 1, true, true);
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_ADVANCED);

CONFIG_BOOL(
list, list_info,
&settings->bools.input_hotkey_device_merge,
MENU_ENUM_LABEL_INPUT_HOTKEY_DEVICE_MERGE,
MENU_ENUM_LABEL_VALUE_INPUT_HOTKEY_DEVICE_MERGE,
DEFAULT_INPUT_HOTKEY_DEVICE_MERGE,
MENU_ENUM_LABEL_VALUE_OFF,
MENU_ENUM_LABEL_VALUE_ON,
&group_info,
&subgroup_info,
parent_group,
general_write_handler,
general_read_handler,
SD_FLAG_NONE
);

CONFIG_BOOL(
list, list_info,
&settings->bools.input_menu_swap_ok_cancel_buttons,
Expand Down
1 change: 1 addition & 0 deletions msg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ enum msg_hash_enums
MENU_LABEL(INPUT_RETROPAD_BINDS),
MENU_LABEL(INPUT_HOTKEY_BINDS),
MENU_LABEL(INPUT_HOTKEY_BLOCK_DELAY),
MENU_LABEL(INPUT_HOTKEY_DEVICE_MERGE),
MENU_LABEL(INPUT_SPLIT_JOYCON),

MENU_ENUM_LABEL_INPUT_HOTKEY_BINDS_BEGIN,
Expand Down

0 comments on commit 266d3ed

Please sign in to comment.