Add delay + acceleration to volume hotkeys (#13434)

This commit is contained in:
Tony 2021-12-31 19:17:32 +02:00 committed by GitHub
parent be05a7e194
commit 940f7553fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6873,10 +6873,41 @@ static enum runloop_state_enum runloop_check_state(
/* Check if we have pressed the AI Service toggle button */
HOTKEY_CHECK(RARCH_AI_SERVICE, CMD_EVENT_AI_SERVICE_TOGGLE, true, NULL);
/* Volume stepping + acceleration */
{
static unsigned volume_hotkey_delay = 0;
static unsigned volume_hotkey_delay_active = 0;
unsigned volume_hotkey_delay_default = 15;
if (BIT256_GET(current_bits, RARCH_VOLUME_UP))
{
if (volume_hotkey_delay > 0)
volume_hotkey_delay--;
else
{
command_event(CMD_EVENT_VOLUME_UP, NULL);
if (volume_hotkey_delay_active > 0)
volume_hotkey_delay_active--;
volume_hotkey_delay = volume_hotkey_delay_active;
}
}
else if (BIT256_GET(current_bits, RARCH_VOLUME_DOWN))
{
if (volume_hotkey_delay > 0)
volume_hotkey_delay--;
else
{
command_event(CMD_EVENT_VOLUME_DOWN, NULL);
if (volume_hotkey_delay_active > 0)
volume_hotkey_delay_active--;
volume_hotkey_delay = volume_hotkey_delay_active;
}
}
else
{
volume_hotkey_delay = 0;
volume_hotkey_delay_active = volume_hotkey_delay_default;
}
}
#ifdef HAVE_NETWORKING
/* Check Netplay */