Volume hotkey logic+response improvement (#13667)

This commit is contained in:
Tony 2022-02-25 00:09:17 +02:00 committed by GitHub
parent b697f556e5
commit 977a7d3eb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 15 deletions

View File

@ -6902,26 +6902,24 @@ static enum runloop_state_enum runloop_check_state(
{ {
static unsigned volume_hotkey_delay = 0; static unsigned volume_hotkey_delay = 0;
static unsigned volume_hotkey_delay_active = 0; static unsigned volume_hotkey_delay_active = 0;
unsigned volume_hotkey_delay_default = 15; unsigned volume_hotkey_delay_default = 6;
if (BIT256_GET(current_bits, RARCH_VOLUME_UP)) bool volume_hotkey_up = BIT256_GET(
current_bits, RARCH_VOLUME_UP);
bool volume_hotkey_down = BIT256_GET(
current_bits, RARCH_VOLUME_DOWN);
if ( (volume_hotkey_up && !volume_hotkey_down) ||
(volume_hotkey_down && !volume_hotkey_up))
{ {
if (volume_hotkey_delay > 0) if (volume_hotkey_delay > 0)
volume_hotkey_delay--; volume_hotkey_delay--;
else else
{ {
command_event(CMD_EVENT_VOLUME_UP, NULL); if (volume_hotkey_up)
if (volume_hotkey_delay_active > 0) command_event(CMD_EVENT_VOLUME_UP, NULL);
volume_hotkey_delay_active--; else if (volume_hotkey_down)
volume_hotkey_delay = volume_hotkey_delay_active; command_event(CMD_EVENT_VOLUME_DOWN, NULL);
}
}
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) if (volume_hotkey_delay_active > 0)
volume_hotkey_delay_active--; volume_hotkey_delay_active--;
volume_hotkey_delay = volume_hotkey_delay_active; volume_hotkey_delay = volume_hotkey_delay_active;