Make the double tap to lock feature behave well.
This commit is contained in:
@@ -200,6 +200,7 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
||||
static key_state_t *doubleTapSwitchLayerKey;
|
||||
static uint32_t doubleTapSwitchLayerStartTime;
|
||||
static uint32_t doubleTapSwitchLayerTriggerTime;
|
||||
static bool IsLayerDoubleTapToggled;
|
||||
|
||||
if (keyState->suppressed) {
|
||||
return;
|
||||
@@ -209,6 +210,11 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
||||
doubleTapSwitchLayerKey = NULL;
|
||||
}
|
||||
|
||||
if (!keyState->previous && IsLayerDoubleTapToggled && ToggledLayer == action->switchLayer.layer) {
|
||||
ToggledLayer = LayerId_Base;
|
||||
IsLayerDoubleTapToggled = false;
|
||||
}
|
||||
|
||||
switch (action->type) {
|
||||
case KeyActionType_Keystroke:
|
||||
ActiveUsbBasicKeyboardReport->modifiers |= action->keystroke.modifiers;
|
||||
@@ -247,6 +253,7 @@ static void applyKeyAction(key_state_t *keyState, key_action_t *action)
|
||||
if (!keyState->previous && previousLayer == LayerId_Base && action->switchLayer.mode == SwitchLayerMode_HoldAndDoubleTapToggle) {
|
||||
if (doubleTapSwitchLayerKey && Timer_GetElapsedTimeAndSetCurrent(&doubleTapSwitchLayerStartTime) < DoubleTapSwitchLayerTimeout) {
|
||||
ToggledLayer = action->switchLayer.layer;
|
||||
IsLayerDoubleTapToggled = true;
|
||||
doubleTapSwitchLayerTriggerTime = Timer_GetCurrentTime();
|
||||
} else {
|
||||
doubleTapSwitchLayerKey = keyState;
|
||||
|
||||
Reference in New Issue
Block a user