From 128b61b511774eb8cdc5ccefcbf11d3b9b5ffe7c Mon Sep 17 00:00:00 2001 From: Christian Dirksen Date: Wed, 11 Feb 2026 20:50:26 +0100 Subject: [PATCH] Secondary Role: Fixed a bug where positive safety margin did not work --- right/src/secondary_role_driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/right/src/secondary_role_driver.c b/right/src/secondary_role_driver.c index 6e12c7626..5e5536c31 100644 --- a/right/src/secondary_role_driver.c +++ b/right/src/secondary_role_driver.c @@ -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; } @@ -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; uint32_t waitUntil = safetyWaitForRelease ? activeTime + Cfg.SecondaryRoles_AdvancedStrategySafetyMargin : 0; // wait for being allowed to trigger secondary? if (heldTooShortForSecondary) {