From 7be52caff8784dbb66e4ff3cf9b0aae04663136b Mon Sep 17 00:00:00 2001 From: redenvelope2000 <114486565+redenvelope2000@users.noreply.github.com> Date: Mon, 16 Dec 2024 01:23:59 +0800 Subject: [PATCH] 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. --- input/input_driver.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index df87ad164e..4e43aaf3af 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -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); + } } } }