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

Enable Rumble FF Autofire #12

Closed
wants to merge 2 commits into from
Closed
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
33 changes: 22 additions & 11 deletions SamcoEnhanced/OpenFIREFeedback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,21 @@ void FFB::FFBRelease()
}
}
}

if(rumbleHappening) { // Are we currently in a rumble command? (Implicitly needs SamcoPreferences::toggles.rumbleActive)
RumbleActivation(); // Continue processing our rumble command.
// (This is to prevent making the lack of trigger pull actually activate a rumble command instead of skipping it like we should.)
} else if(rumbleHappened) { // If rumble has happened,
rumbleHappened = false; // well we're clear now that we've stopped holding.

// If Rumble FF is enabled and Autofire is enabled, the motor needs to be disabled when the trigger is released. Otherwiseallow RumbleActivation to deal with the activation timer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Otherwiseallow?" I think your typing was on autofire for a bit there.

if(SamcoPreferences::toggles.rumbleFF && SamcoPreferences::toggles.autofireActive) {
if(rumbleHappening || rumbleHappened) {
digitalWrite(SamcoPreferences::pins.oRumble, LOW); // Make sure the rumble is OFF.
rumbleHappening = false; // This rumble command is done now.
rumbleHappened = false; // Make it clear we've stopped holding.
}
} else {
if(rumbleHappening) { // Are we currently in a rumble command? (Implicitly needs SamcoPreferences::toggles.rumbleActive)
RumbleActivation(); // Continue processing our rumble command.
// (This is to prevent making the lack of trigger pull actually activate a rumble command instead of skipping it like we should.)
} else if(rumbleHappened) { // If rumble has happened,
rumbleHappened = false; // well we're clear now that we've stopped holding.
}
}
}

Expand Down Expand Up @@ -212,10 +221,12 @@ void FFB::RumbleActivation()
if(rumbleHappening) { // Are we in a rumble command rn?
currentMillis = millis(); // Calibrate a timer to set how long we've been rumbling.
if(SamcoPreferences::toggles.rumbleFF) {
if(currentMillis - previousMillisRumble >= SamcoPreferences::settings.rumbleInterval / 2) { // If we've been waiting long enough for this whole rumble command,
digitalWrite(SamcoPreferences::pins.oRumble, LOW); // Make sure the rumble is OFF.
rumbleHappening = false; // This rumble command is done now.
rumbleHappened = true; // And just to make sure, to prevent holding == repeat rumble commands.
if(!SamcoPreferences::toggles.autofireActive) { // We only want to use the rumble timer is Autofire is not active. Otherwise, keep it going
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant "We only want to use the rumble timer if Autofire is not active. ..."

if(currentMillis - previousMillisRumble >= SamcoPreferences::settings.rumbleInterval / 2) { // If we've been waiting long enough for this whole rumble command,
digitalWrite(SamcoPreferences::pins.oRumble, LOW); // Make sure the rumble is OFF.
rumbleHappening = false; // This rumble command is done now.
rumbleHappened = true; // And just to make sure, to prevent holding == repeat rumble commands.
}
}
} else {
if(currentMillis - previousMillisRumble >= SamcoPreferences::settings.rumbleInterval) { // If we've been waiting long enough for this whole rumble command,
Expand Down Expand Up @@ -264,4 +275,4 @@ void FFB::FFBShutdown()
triggerHeld = false;
burstFiring = false;
burstFireCount = 0;
}
}
Loading