Don't make secondary role stuck when holding a layer switcher even after releasing the dual role key.
This commit is contained in:
@@ -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 (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) {
|
if (keyState->current) {
|
||||||
if (!keyState->previous && keyState->current && secondaryRoleState == SecondaryRoleState_Released) {
|
if (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) {
|
||||||
secondaryRoleState = SecondaryRoleState_Pressed;
|
// Press released secondary role key.
|
||||||
secondaryRoleSlotId = slotId;
|
if (!keyState->previous && action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole && secondaryRoleState == SecondaryRoleState_Released) {
|
||||||
secondaryRoleKeyId = keyId;
|
secondaryRoleState = SecondaryRoleState_Pressed;
|
||||||
secondaryRole = action->keystroke.secondaryRole;
|
secondaryRoleSlotId = slotId;
|
||||||
} else if (keyState->previous && !keyState->current && secondaryRoleSlotId == slotId && secondaryRoleKeyId == keyId) {
|
secondaryRoleKeyId = keyId;
|
||||||
if (secondaryRoleState == SecondaryRoleState_Pressed) {
|
secondaryRole = action->keystroke.secondaryRole;
|
||||||
applyKeyAction(keyState, action);
|
|
||||||
}
|
}
|
||||||
secondaryRoleState = SecondaryRoleState_Released;
|
} else {
|
||||||
|
// Trigger secondary role.
|
||||||
|
if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Pressed) {
|
||||||
|
secondaryRoleState = SecondaryRoleState_Triggered;
|
||||||
|
}
|
||||||
|
applyKeyAction(keyState, action);
|
||||||
}
|
}
|
||||||
} else if (keyState->current) {
|
// Release secondary role key.
|
||||||
if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Pressed) {
|
} else if (keyState->previous && secondaryRoleSlotId == slotId && secondaryRoleKeyId == keyId) {
|
||||||
secondaryRoleState = SecondaryRoleState_Triggered;
|
// Trigger primary role.
|
||||||
|
if (secondaryRoleState == SecondaryRoleState_Pressed) {
|
||||||
|
applyKeyAction(keyState, action);
|
||||||
}
|
}
|
||||||
applyKeyAction(keyState, action);
|
secondaryRoleState = SecondaryRoleState_Released;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyState->previous = keyState->current;
|
keyState->previous = keyState->current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user