Add a new "Classic (Toggle)" turbo mode (#16239)

This commit is contained in:
Bobby Smith 2024-02-18 17:24:05 +01:00 committed by GitHub
parent 46cc2250cf
commit e1cc4fb14d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 42 additions and 2 deletions

View file

@ -224,6 +224,7 @@ enum input_combo_type
enum input_turbo_mode
{
INPUT_TURBO_MODE_CLASSIC = 0,
INPUT_TURBO_MODE_CLASSIC_TOGGLE,
INPUT_TURBO_MODE_SINGLEBUTTON,
INPUT_TURBO_MODE_SINGLEBUTTON_HOLD,
INPUT_TURBO_MODE_LAST

View file

@ -1280,7 +1280,7 @@ static int16_t input_state_device(
*/
unsigned turbo_mode = settings->uints.input_turbo_mode;
if (turbo_mode > INPUT_TURBO_MODE_CLASSIC)
if (turbo_mode > INPUT_TURBO_MODE_CLASSIC_TOGGLE)
{
/* Pressing turbo button toggles turbo mode on or off.
* Holding the button will
@ -1350,7 +1350,7 @@ static int16_t input_state_device(
< settings->uints.input_turbo_duty_cycle);
}
}
else
else if (turbo_mode == INPUT_TURBO_MODE_CLASSIC)
{
/* If turbo button is held, all buttons pressed except
* for D-pad will go into a turbo mode. Until the button is
@ -1371,6 +1371,30 @@ static int16_t input_state_device(
else
input_st->turbo_btns.enable[port] &= ~(1 << id);
}
else /* Classic toggle mode */
{
/* Works pretty much the same as classic mode above
* but with a toggle mechanic */
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);
}
}
}

View file

@ -485,6 +485,8 @@ int msg_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len)
unsigned mode = settings ? settings->uints.input_turbo_mode : INPUT_TURBO_MODE_LAST;
if (mode == INPUT_TURBO_MODE_CLASSIC)
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_HELP_TURBO_MODE_CLASSIC), len);
else if (mode == INPUT_TURBO_MODE_CLASSIC_TOGGLE)
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_HELP_TURBO_MODE_CLASSIC_TOGGLE), len);
else if (mode == INPUT_TURBO_MODE_SINGLEBUTTON)
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_HELP_TURBO_MODE_SINGLEBUTTON), len);
else if (mode == INPUT_TURBO_MODE_SINGLEBUTTON_HOLD)

View file

@ -3415,6 +3415,10 @@ MSG_HASH(
MENU_ENUM_LABEL_VALUE_TURBO_MODE_CLASSIC,
"Classic"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TURBO_MODE_CLASSIC_TOGGLE,
"Classic (Toggle)"
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TURBO_MODE_SINGLEBUTTON,
"Single Button (Toggle)"
@ -3427,6 +3431,10 @@ MSG_HASH(
MENU_ENUM_LABEL_HELP_TURBO_MODE_CLASSIC,
"Classic mode, two-button operation. Hold a button and tap the Turbo button to activate the press-release sequence.\nTurbo button can be assigned in Settings/Input/Port 1 Controls."
)
MSG_HASH(
MENU_ENUM_LABEL_HELP_TURBO_MODE_CLASSIC_TOGGLE,
"Classic toggle mode, two-button operation. Hold a button and tap the Turbo button to enable turbo for that button. To disable turbo: hold the button and press the Turbo button again.\nTurbo button can be assigned in Settings/Input/Port 1 Controls."
)
MSG_HASH(
MENU_ENUM_LABEL_HELP_TURBO_MODE_SINGLEBUTTON,
"Toggle mode. Press the Turbo button once to activate the press-release sequence for the selected default button, press it once again to switch it off.\nTurbo button can be assigned in Settings/Input/Port 1 Controls."

View file

@ -6912,6 +6912,9 @@ static void setting_get_string_representation_turbo_mode(
case INPUT_TURBO_MODE_CLASSIC:
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TURBO_MODE_CLASSIC), len);
break;
case INPUT_TURBO_MODE_CLASSIC_TOGGLE:
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TURBO_MODE_CLASSIC_TOGGLE), len);
break;
case INPUT_TURBO_MODE_SINGLEBUTTON:
strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_TURBO_MODE_SINGLEBUTTON), len);
break;

View file

@ -884,9 +884,11 @@ enum msg_hash_enums
MENU_LABEL(INPUT_TURBO_PERIOD),
MENU_LABEL(INPUT_TURBO_MODE),
MENU_ENUM_LABEL_VALUE_TURBO_MODE_CLASSIC,
MENU_ENUM_LABEL_VALUE_TURBO_MODE_CLASSIC_TOGGLE,
MENU_ENUM_LABEL_VALUE_TURBO_MODE_SINGLEBUTTON,
MENU_ENUM_LABEL_VALUE_TURBO_MODE_SINGLEBUTTON_HOLD,
MENU_ENUM_LABEL_HELP_TURBO_MODE_CLASSIC,
MENU_ENUM_LABEL_HELP_TURBO_MODE_CLASSIC_TOGGLE,
MENU_ENUM_LABEL_HELP_TURBO_MODE_SINGLEBUTTON,
MENU_ENUM_LABEL_HELP_TURBO_MODE_SINGLEBUTTON_HOLD,
MENU_LABEL(INPUT_TURBO_DEFAULT_BUTTON),