Add input_hotkey_enable.

Adds a mechanism to toggle when hotkeys are enabled.
This commit is contained in:
Themaister 2012-11-02 23:24:53 +01:00
parent 02f81a38c2
commit 0ac3ee7d31
5 changed files with 32 additions and 2 deletions

View File

@ -390,6 +390,7 @@ static const struct retro_keybind retro_keybinds_1[] = {
{ true, RARCH_MUTE, RETROK_F9, NO_BTN, AXIS_NONE },
{ true, RARCH_NETPLAY_FLIP, RETROK_i, NO_BTN, AXIS_NONE },
{ true, RARCH_SLOWMOTION, RETROK_e, NO_BTN, AXIS_NONE },
{ true, RARCH_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, AXIS_NONE },
};
// Player 2-5

View File

@ -85,6 +85,7 @@ enum // RetroArch specific bind IDs.
RARCH_MUTE,
RARCH_NETPLAY_FLIP,
RARCH_SLOWMOTION,
RARCH_ENABLE_HOTKEY,
#ifdef RARCH_CONSOLE
RARCH_CHEAT_INPUT,
@ -235,6 +236,7 @@ typedef struct driver
rarch_cmd_t *command;
#endif
bool stdin_claimed;
bool block_hotkey;
// Opaque handles to currently running window.
// Used by e.g. input drivers which bind to a window.
@ -337,6 +339,9 @@ extern const input_driver_t input_null;
static inline bool input_key_pressed_func(int key)
{
if (driver.block_hotkey)
return false;
bool ret = driver.input->key_pressed(driver.input_data, key);
#ifdef HAVE_COMMAND
if (!ret && driver.command)

View File

@ -2417,8 +2417,23 @@ static void check_netplay_flip(void)
}
#endif
static void check_block_hotkey(void)
{
driver.block_hotkey = false;
// If we haven't bound anything to this,
// always allow hotkeys.
static const struct retro_keybind *bind = &g_settings.input.binds[0][RARCH_ENABLE_HOTKEY];
if (bind->key == RETROK_UNKNOWN && bind->joykey == NO_BTN && bind->joyaxis == AXIS_NONE)
return;
driver.block_hotkey = !input_key_pressed_func(RARCH_ENABLE_HOTKEY);
}
static void do_state_checks(void)
{
check_block_hotkey();
#if defined(HAVE_SCREENSHOTS) && !defined(_XBOX)
check_screenshot();
#endif

View File

@ -342,6 +342,16 @@
# Hold for slowmotion.
# input_slowmotion = e
# Enable other hotkeys.
# If this hotkey is bound to either keyboard, joybutton or joyaxis,
# all other hotkeys will be disabled unless this hotkey is also held at the same time.
# This is useful for RETRO_KEYBOARD centric implementations
# which query a large area of the keyboard, where it is not desirable
# that hotkeys get in the way.
# Alternatively, all hotkeys for keyboard could be disabled by the user.
# input_enable_hotkey =
#### Misc
# Enable rewinding. This will take a performance hit when playing, so it is disabled by default.

View File

@ -669,6 +669,7 @@ static const struct bind_map bind_maps[MAX_PLAYERS][RARCH_BIND_LIST_END_NULL] =
DECLARE_BIND(audio_mute, RARCH_MUTE),
DECLARE_BIND(netplay_flip_players, RARCH_NETPLAY_FLIP),
DECLARE_BIND(slowmotion, RARCH_SLOWMOTION),
DECLARE_BIND(enable_hotkey, RARCH_ENABLE_HOTKEY),
},
{ DECL_PLAYER(2) },
@ -686,8 +687,6 @@ struct key_map
int key;
};
// Edit: Not portable to different input systems atm. Might move this map into the driver itself or something.
// However, this should map nicely over to other systems aswell since the definition are mostly the same anyways.
static const struct key_map sk_map[] = {
{ "left", RETROK_LEFT },
{ "right", RETROK_RIGHT },