Refactor hotkey checks
This commit is contained in:
parent
548e1380d7
commit
5d301f321d
52
command.c
52
command.c
|
@ -1749,6 +1749,45 @@ bool command_event(enum event_command cmd, void *data)
|
|||
|
||||
switch (cmd)
|
||||
{
|
||||
case CMD_EVENT_BSV_RECORDING_TOGGLE:
|
||||
if (!recording_is_enabled())
|
||||
command_event(CMD_EVENT_RECORD_INIT, NULL);
|
||||
else
|
||||
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
|
||||
bsv_movie_check();
|
||||
break;
|
||||
case CMD_EVENT_AI_SERVICE_TOGGLE:
|
||||
/* TODO/FIXME - implement */
|
||||
break;
|
||||
case CMD_EVENT_NETPLAY_GAME_WATCH:
|
||||
#ifdef HAVE_NETWORKING
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_GAME_WATCH, NULL);
|
||||
#endif
|
||||
break;
|
||||
case CMD_EVENT_STREAMING_TOGGLE:
|
||||
if (streaming_is_enabled())
|
||||
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
|
||||
else
|
||||
{
|
||||
streaming_set_state(true);
|
||||
command_event(CMD_EVENT_RECORD_INIT, NULL);
|
||||
}
|
||||
break;
|
||||
case CMD_EVENT_RECORDING_TOGGLE:
|
||||
if (recording_is_enabled())
|
||||
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
|
||||
else
|
||||
command_event(CMD_EVENT_RECORD_INIT, NULL);
|
||||
break;
|
||||
case CMD_EVENT_OSK_TOGGLE:
|
||||
if (input_keyboard_ctl(
|
||||
RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL))
|
||||
input_keyboard_ctl(
|
||||
RARCH_INPUT_KEYBOARD_CTL_UNSET_LINEFEED_ENABLED, NULL);
|
||||
else
|
||||
input_keyboard_ctl(
|
||||
RARCH_INPUT_KEYBOARD_CTL_SET_LINEFEED_ENABLED, NULL);
|
||||
break;
|
||||
case CMD_EVENT_SET_PER_GAME_RESOLUTION:
|
||||
#if defined(GEKKO)
|
||||
{
|
||||
|
@ -2051,7 +2090,7 @@ TODO: Add a setting for these tweaks */
|
|||
{
|
||||
#ifdef HAVE_NETWORKING
|
||||
/* Only enable state manager if netplay is not underway
|
||||
TODO: Add a setting for these tweaks */
|
||||
TODO: Add a setting for these tweaks */
|
||||
settings_t *settings = config_get_ptr();
|
||||
if (settings->uints.autosave_interval != 0
|
||||
&& !netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
|
||||
|
@ -2612,7 +2651,7 @@ TODO: Add a setting for these tweaks */
|
|||
}
|
||||
|
||||
/* Disable rewind & sram autosave if it was enabled
|
||||
TODO: Add a setting for these tweaks */
|
||||
TODO: Add a setting for these tweaks */
|
||||
state_manager_event_deinit();
|
||||
#ifdef HAVE_THREADS
|
||||
autosave_deinit();
|
||||
|
@ -2649,7 +2688,7 @@ TODO: Add a setting for these tweaks */
|
|||
string_list_free(hostname);
|
||||
|
||||
/* Disable rewind if it was enabled
|
||||
TODO: Add a setting for these tweaks */
|
||||
TODO: Add a setting for these tweaks */
|
||||
state_manager_event_deinit();
|
||||
#ifdef HAVE_THREADS
|
||||
autosave_deinit();
|
||||
|
@ -2686,16 +2725,13 @@ TODO: Add a setting for these tweaks */
|
|||
string_list_free(hostname);
|
||||
|
||||
/* Disable rewind if it was enabled
|
||||
TODO: Add a setting for these tweaks */
|
||||
TODO: Add a setting for these tweaks */
|
||||
state_manager_event_deinit();
|
||||
#ifdef HAVE_THREADS
|
||||
autosave_deinit();
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case CMD_EVENT_NETPLAY_GAME_WATCH:
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_GAME_WATCH, NULL);
|
||||
break;
|
||||
case CMD_EVENT_NETPLAY_ENABLE_HOST:
|
||||
{
|
||||
#ifdef HAVE_MENU
|
||||
|
@ -2732,7 +2768,7 @@ TODO: Add a setting for these tweaks */
|
|||
netplay_driver_ctl(RARCH_NETPLAY_CTL_DISABLE, NULL);
|
||||
|
||||
/* Re-enable rewind if it was enabled
|
||||
TODO: Add a setting for these tweaks */
|
||||
TODO: Add a setting for these tweaks */
|
||||
if (settings->bools.rewind_enable)
|
||||
command_event(CMD_EVENT_REWIND_INIT, NULL);
|
||||
if (settings->uints.autosave_interval != 0)
|
||||
|
|
|
@ -245,7 +245,12 @@ enum event_command
|
|||
CMD_EVENT_RESTORE_DEFAULT_SHADER_PRESET,
|
||||
CMD_EVENT_DISCORD_INIT,
|
||||
CMD_EVENT_DISCORD_DEINIT,
|
||||
CMD_EVENT_DISCORD_UPDATE
|
||||
CMD_EVENT_DISCORD_UPDATE,
|
||||
CMD_EVENT_OSK_TOGGLE,
|
||||
CMD_EVENT_RECORDING_TOGGLE,
|
||||
CMD_EVENT_STREAMING_TOGGLE,
|
||||
CMD_EVENT_AI_SERVICE_TOGGLE,
|
||||
CMD_EVENT_BSV_RECORDING_TOGGLE
|
||||
};
|
||||
|
||||
bool command_set_shader(const char *arg);
|
||||
|
|
97
retroarch.c
97
retroarch.c
|
@ -3873,77 +3873,16 @@ static enum runloop_state runloop_check_state(
|
|||
HOTKEY_CHECK(RARCH_MUTE, CMD_EVENT_AUDIO_MUTE_TOGGLE);
|
||||
|
||||
/* Check if we have pressed the OSK toggle button */
|
||||
{
|
||||
static bool old_pressed = false;
|
||||
bool pressed = BIT256_GET(current_input, RARCH_OSK);
|
||||
|
||||
if (pressed && !old_pressed)
|
||||
{
|
||||
if (input_keyboard_ctl(
|
||||
RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL))
|
||||
input_keyboard_ctl(
|
||||
RARCH_INPUT_KEYBOARD_CTL_UNSET_LINEFEED_ENABLED, NULL);
|
||||
else
|
||||
input_keyboard_ctl(
|
||||
RARCH_INPUT_KEYBOARD_CTL_SET_LINEFEED_ENABLED, NULL);
|
||||
}
|
||||
|
||||
old_pressed = pressed;
|
||||
}
|
||||
HOTKEY_CHECK(RARCH_OSK, CMD_EVENT_OSK_TOGGLE);
|
||||
|
||||
/* Check if we have pressed the recording toggle button */
|
||||
{
|
||||
static bool old_pressed = false;
|
||||
bool pressed = BIT256_GET(
|
||||
current_input, RARCH_RECORDING_TOGGLE);
|
||||
|
||||
if (pressed && !old_pressed)
|
||||
{
|
||||
if (recording_is_enabled())
|
||||
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
|
||||
else
|
||||
command_event(CMD_EVENT_RECORD_INIT, NULL);
|
||||
}
|
||||
|
||||
old_pressed = pressed;
|
||||
}
|
||||
HOTKEY_CHECK(RARCH_RECORDING_TOGGLE, CMD_EVENT_RECORDING_TOGGLE);
|
||||
|
||||
/* Check if we have pressed the AI Service toggle button */
|
||||
{
|
||||
static bool old_pressed = false;
|
||||
bool pressed = BIT256_GET(
|
||||
current_input, RARCH_AI_SERVICE);
|
||||
|
||||
if (pressed && !old_pressed)
|
||||
{
|
||||
#if 0
|
||||
/* TODO/FIXME */
|
||||
command_event(CMD_EVENT_RECORD_INIT, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
old_pressed = pressed;
|
||||
}
|
||||
HOTKEY_CHECK(RARCH_AI_SERVICE, CMD_EVENT_AI_SERVICE_TOGGLE);
|
||||
|
||||
/* Check if we have pressed the streaming toggle button */
|
||||
{
|
||||
static bool old_pressed = false;
|
||||
bool pressed = BIT256_GET(
|
||||
current_input, RARCH_STREAMING_TOGGLE);
|
||||
|
||||
if (pressed && !old_pressed)
|
||||
{
|
||||
if (streaming_is_enabled())
|
||||
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
|
||||
else
|
||||
{
|
||||
streaming_set_state(true);
|
||||
command_event(CMD_EVENT_RECORD_INIT, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
old_pressed = pressed;
|
||||
}
|
||||
HOTKEY_CHECK(RARCH_STREAMING_TOGGLE, CMD_EVENT_STREAMING_TOGGLE);
|
||||
|
||||
if (BIT256_GET(current_input, RARCH_VOLUME_UP))
|
||||
command_event(CMD_EVENT_VOLUME_UP, NULL);
|
||||
|
@ -3952,16 +3891,7 @@ static enum runloop_state runloop_check_state(
|
|||
|
||||
#ifdef HAVE_NETWORKING
|
||||
/* Check Netplay */
|
||||
{
|
||||
static bool old_netplay_watch = false;
|
||||
bool netplay_watch = BIT256_GET(
|
||||
current_input, RARCH_NETPLAY_GAME_WATCH);
|
||||
|
||||
if (netplay_watch && !old_netplay_watch)
|
||||
netplay_driver_ctl(RARCH_NETPLAY_CTL_GAME_WATCH, NULL);
|
||||
|
||||
old_netplay_watch = netplay_watch;
|
||||
}
|
||||
HOTKEY_CHECK(RARCH_NETPLAY_GAME_WATCH, CMD_EVENT_NETPLAY_GAME_WATCH);
|
||||
#endif
|
||||
|
||||
/* Check if we have pressed the pause button */
|
||||
|
@ -4209,22 +4139,7 @@ static enum runloop_state runloop_check_state(
|
|||
}
|
||||
|
||||
/* Check movie record toggle */
|
||||
{
|
||||
static bool old_pressed = false;
|
||||
bool pressed = BIT256_GET(
|
||||
current_input, RARCH_BSV_RECORD_TOGGLE);
|
||||
|
||||
if (pressed && !old_pressed)
|
||||
{
|
||||
if (!recording_is_enabled())
|
||||
command_event(CMD_EVENT_RECORD_INIT, NULL);
|
||||
else
|
||||
command_event(CMD_EVENT_RECORD_DEINIT, NULL);
|
||||
bsv_movie_check();
|
||||
}
|
||||
|
||||
old_pressed = pressed;
|
||||
}
|
||||
HOTKEY_CHECK(RARCH_BSV_RECORD_TOGGLE, CMD_EVENT_BSV_RECORDING_TOGGLE);
|
||||
|
||||
/* Check shader prev/next */
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue