Update input_driver.c to improve the classic toggle turbo function (#17252)

Changed the logic of the classic toggle turbo mode code such that the pressing order of the turbo button and the button to enable/disable does not matter.
This commit is contained in:
redenvelope2000 2024-12-16 01:23:59 +08:00 committed by GitHub
parent 928249b20b
commit 7be52caff8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1563,25 +1563,32 @@ static int16_t input_state_device(
{
/* Works pretty much the same as classic mode above
* but with a toggle mechanic */
/* Check if it's to enable the turbo func, if we're still holding
* the button from previous toggle then ignore */
if ( (res)
&& (input_st->turbo_btns.frame_enable[port]))
{
if (!(input_st->turbo_btns.turbo_pressed[port] & (1 << id)))
{
input_st->turbo_btns.enable[port] ^= (1 << id);
/* Remember for the toggle check */
input_st->turbo_btns.turbo_pressed[port] |= (1 << id);
}
}
else
{
input_st->turbo_btns.turbo_pressed[port] &= ~(1 << id);
}
if (res)
{
/* Check if it's a new press, if we're still holding
* the button from previous toggle then ignore */
if ( input_st->turbo_btns.frame_enable[port]
&& !(input_st->turbo_btns.turbo_pressed[port] & (1 << id)))
input_st->turbo_btns.enable[port] ^= (1 << id);
if (input_st->turbo_btns.enable[port] & (1 << id))
/* If turbo button is enabled for this key ID */
res = (( input_st->turbo_btns.count
% settings->uints.input_turbo_period)
< settings->uints.input_turbo_duty_cycle);
}
/* Remember for the toggle check */
if (input_st->turbo_btns.frame_enable[port])
input_st->turbo_btns.turbo_pressed[port] |= (1 << id);
else
input_st->turbo_btns.turbo_pressed[port] &= ~(1 << id);
}
}
}
}