From cc6666b96d91994540d275337e1b310505934287 Mon Sep 17 00:00:00 2001 From: Eric Tang Date: Sat, 6 Oct 2018 09:44:52 -0500 Subject: [PATCH 1/2] Don't suppress keys upon keymap changes --- right/src/keymap.c | 2 -- right/src/usb_report_updater.c | 7 +------ right/src/usb_report_updater.h | 1 - 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/right/src/keymap.c b/right/src/keymap.c index 6337101..ef04bd2 100644 --- a/right/src/keymap.c +++ b/right/src/keymap.c @@ -5,7 +5,6 @@ #include "config_parser/parse_keymap.h" #include "config_parser/config_globals.h" #include "macros.h" -#include "usb_report_updater.h" keymap_reference_t AllKeymaps[MAX_KEYMAP_NUM] = { { @@ -25,7 +24,6 @@ void SwitchKeymapById(uint8_t index) ValidatedUserConfigBuffer.offset = AllKeymaps[index].offset; ParseKeymap(&ValidatedUserConfigBuffer, index, AllKeymapsCount, AllMacrosCount); LedDisplay_UpdateText(); - KeymapChanged = true; } bool SwitchKeymapByAbbreviation(uint8_t length, char *abbrev) diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 4452199..3971c35 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -25,7 +25,6 @@ static uint16_t DoubleTapSwitchLayerReleaseTimeout = 200; static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT]; bool TestUsbStack = false; -bool KeymapChanged = false; static uint8_t layerCache[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE]; volatile uint8_t UsbReportUpdateSemaphore = 0; @@ -335,8 +334,6 @@ static void updateActiveUsbReports(void) if (layerChanged) { stickyModifiers = 0; } - bool keymapChangedLastCycle = KeymapChanged; - KeymapChanged = false; LedDisplay_SetLayer(activeLayer); if (TestUsbStack) { @@ -390,9 +387,7 @@ static void updateActiveUsbReports(void) action = &CurrentKeymap[layerCache[slotId][keyId]][slotId][keyId]; if (keyState->current) { - if ((KeymapChanged || keymapChangedLastCycle) && keyState->previous) { - keyState->suppressed = true; - } else if (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) { + if (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) { // Press released secondary role key. if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Released) { secondaryRoleState = SecondaryRoleState_Pressed; diff --git a/right/src/usb_report_updater.h b/right/src/usb_report_updater.h index d3df70b..bbdc507 100644 --- a/right/src/usb_report_updater.h +++ b/right/src/usb_report_updater.h @@ -72,7 +72,6 @@ extern uint32_t UsbReportUpdateCounter; extern volatile uint8_t UsbReportUpdateSemaphore; extern bool TestUsbStack; - extern bool KeymapChanged; // Functions: From 06e34fdcbca32cc827a7a4d2bd5213aa1a52ec40 Mon Sep 17 00:00:00 2001 From: Eric Tang Date: Sat, 6 Oct 2018 09:47:45 -0500 Subject: [PATCH 2/2] Convert the layer cache to an action cache --- right/src/usb_report_updater.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/right/src/usb_report_updater.c b/right/src/usb_report_updater.c index 3971c35..d344ec2 100644 --- a/right/src/usb_report_updater.c +++ b/right/src/usb_report_updater.c @@ -25,7 +25,7 @@ static uint16_t DoubleTapSwitchLayerReleaseTimeout = 200; static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT]; bool TestUsbStack = false; -static uint8_t layerCache[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE]; +static key_action_t actionCache[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE]; volatile uint8_t UsbReportUpdateSemaphore = 0; @@ -380,11 +380,11 @@ static void updateActiveUsbReports(void) secondaryRoleState = SecondaryRoleState_Triggered; keyState->current = false; } else { - layerCache[slotId][keyId] = activeLayer; + actionCache[slotId][keyId] = CurrentKeymap[activeLayer][slotId][keyId]; } } - action = &CurrentKeymap[layerCache[slotId][keyId]][slotId][keyId]; + action = &actionCache[slotId][keyId]; if (keyState->current) { if (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) {