Skip to content

Commit

Permalink
Add a new "Classic (Toggle)" turbo mode (#16239)
Browse files Browse the repository at this point in the history
  • Loading branch information
bslenul authored Feb 18, 2024
1 parent 46cc225 commit e1cc4fb
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions input/input_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 26 additions & 2 deletions input/input_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions intl/msg_hash_us.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions intl/msg_hash_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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."
Expand Down
3 changes: 3 additions & 0 deletions menu/menu_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions msg_hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit e1cc4fb

Please sign in to comment.