Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turbo state toggle updates #904

Merged
merged 2 commits into from
Mar 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions src/addons/turbo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,15 @@ void TurboInput::process()
// Check for TURBO pin enabled
if (gamepad->debouncedGpio & turboPinMask) {
if (buttonsPressed && (lastPressed != buttonsPressed)) {
turboButtonsMask ^= buttonsPressed; // Toggle Turbo
// Only toggle state for buttons changed that are pressed
turboButtonsMask ^= (lastPressed ^ buttonsPressed) & ~lastPressed; // Toggle Turbo
gamepad->turboState.buttons = turboButtonsMask; //turboButtonsMask & TURBO_BUTTON_MASK; //&= TURBO_BUTTON_MASK;
if (options.shmupModeEnabled) {
turboButtonsMask |= alwaysEnabled; // SHMUP Always-on Buttons Set
}

// Reset Turbo flicker on a new button press
bTurboFlicker = false;
}

if (dpadPressed & GAMEPAD_MASK_DOWN && (lastDpad != dpadPressed)) {
Expand All @@ -138,10 +142,6 @@ void TurboInput::process()
}
lastPressed = buttonsPressed; // save last pressed
lastDpad = dpadPressed;

// Clear gamepad outputs since we're in turbo adjustment mode
gamepad->clearState();
return; // Holding TURBO cancels turbo functionality
} else {
lastPressed = 0; // disable last pressed
lastDpad = 0; // disable last dpad
Expand Down Expand Up @@ -170,13 +170,8 @@ void TurboInput::process()
nextAdcRead = now + 100000; // Sample every 100ms
}

// Reset Turbo flicker on a new button press
if ((lastButtons & turboButtonsMask) == 0 && (gamepad->state.buttons & turboButtonsMask) != 0) {
bTurboFlicker = false; // reset flicker state to ON
nextTimer = now + uIntervalUS - TURBO_LOOP_OFFSET; // interval to flicker-off button
}
// Check if we've reached the next timer right before applying turbo state
else if (turboButtonsMask && nextTimer < now) {
if (nextTimer < now) {
bTurboFlicker ^= true;
nextTimer = now + uIntervalUS - TURBO_LOOP_OFFSET;
}
Expand Down