Skip to content
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
5 changes: 3 additions & 2 deletions right/src/secondary_role_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ static secondary_role_state_t resolveCurrentKeyRoleIfDontKnowTimeout()
}

// handle positive safety margin part 1: is action key allowed to trigger secondary yet
const bool safetyWaitForRelease = dualRoleRelease == NULL && actionEvent != NULL
const bool safetyBlockSecondary = actionEvent != NULL
&& (int32_t)(Timer_GetCurrentTime() - actionEvent->time) < Cfg.SecondaryRoles_AdvancedStrategySafetyMargin;
if (safetyWaitForRelease) {
if (safetyBlockSecondary) {
// prevent the action from triggering secondary
actionEvent = NULL;
}
Expand Down Expand Up @@ -180,6 +180,7 @@ static secondary_role_state_t resolveCurrentKeyRoleIfDontKnowTimeout()

// now we want to trigger secondary, but are we allowed?
// handle safety margin part 2: wait for the safety margin?
const bool safetyWaitForRelease = safetyBlockSecondary && dualRoleRelease == NULL;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, the check for no dual role key release should be redundant here. If we had one, we would have reached line 176

Copy link
Collaborator

Choose a reason for hiding this comment

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

Code robustness and readability say that it is fine and probably preferred :-).

uint32_t waitUntil = safetyWaitForRelease ? activeTime + Cfg.SecondaryRoles_AdvancedStrategySafetyMargin : 0;
// wait for being allowed to trigger secondary?
if (heldTooShortForSecondary) {
Expand Down