Don't make secondary role stuck when holding a layer switcher even after releasing the dual role key.

This commit is contained in:
László Monda
2017-11-07 00:00:02 +01:00
parent 3ac94684e2
commit 31fa1a0d5e
+14 -7
View File
@@ -149,24 +149,31 @@ void UpdateActiveUsbReports(void)
key_state_t *keyState = &KeyStates[slotId][keyId]; key_state_t *keyState = &KeyStates[slotId][keyId];
key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId]; key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId];
if (keyState->current) {
if (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) { if (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) {
if (!keyState->previous && keyState->current && secondaryRoleState == SecondaryRoleState_Released) { // Press released secondary role key.
if (!keyState->previous && action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole && secondaryRoleState == SecondaryRoleState_Released) {
secondaryRoleState = SecondaryRoleState_Pressed; secondaryRoleState = SecondaryRoleState_Pressed;
secondaryRoleSlotId = slotId; secondaryRoleSlotId = slotId;
secondaryRoleKeyId = keyId; secondaryRoleKeyId = keyId;
secondaryRole = action->keystroke.secondaryRole; secondaryRole = action->keystroke.secondaryRole;
} else if (keyState->previous && !keyState->current && secondaryRoleSlotId == slotId && secondaryRoleKeyId == keyId) {
if (secondaryRoleState == SecondaryRoleState_Pressed) {
applyKeyAction(keyState, action);
} }
secondaryRoleState = SecondaryRoleState_Released; } else {
} // Trigger secondary role.
} else if (keyState->current) {
if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Pressed) { if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Pressed) {
secondaryRoleState = SecondaryRoleState_Triggered; secondaryRoleState = SecondaryRoleState_Triggered;
} }
applyKeyAction(keyState, action); applyKeyAction(keyState, action);
} }
// Release secondary role key.
} else if (keyState->previous && secondaryRoleSlotId == slotId && secondaryRoleKeyId == keyId) {
// Trigger primary role.
if (secondaryRoleState == SecondaryRoleState_Pressed) {
applyKeyAction(keyState, action);
}
secondaryRoleState = SecondaryRoleState_Released;
}
keyState->previous = keyState->current; keyState->previous = keyState->current;
} }
} }