Merge pull request #186 from UltimateHackingKeyboard/action-cache

Extend the behavior of keys upon layer changes to keymap changes
This commit is contained in:
László Monda
2018-10-06 20:56:06 +02:00
committed by GitHub
3 changed files with 4 additions and 12 deletions
-2
View File
@@ -5,7 +5,6 @@
#include "config_parser/parse_keymap.h" #include "config_parser/parse_keymap.h"
#include "config_parser/config_globals.h" #include "config_parser/config_globals.h"
#include "macros.h" #include "macros.h"
#include "usb_report_updater.h"
keymap_reference_t AllKeymaps[MAX_KEYMAP_NUM] = { keymap_reference_t AllKeymaps[MAX_KEYMAP_NUM] = {
{ {
@@ -25,7 +24,6 @@ void SwitchKeymapById(uint8_t index)
ValidatedUserConfigBuffer.offset = AllKeymaps[index].offset; ValidatedUserConfigBuffer.offset = AllKeymaps[index].offset;
ParseKeymap(&ValidatedUserConfigBuffer, index, AllKeymapsCount, AllMacrosCount); ParseKeymap(&ValidatedUserConfigBuffer, index, AllKeymapsCount, AllMacrosCount);
LedDisplay_UpdateText(); LedDisplay_UpdateText();
KeymapChanged = true;
} }
bool SwitchKeymapByAbbreviation(uint8_t length, char *abbrev) bool SwitchKeymapByAbbreviation(uint8_t length, char *abbrev)
+4 -9
View File
@@ -25,8 +25,7 @@ static uint16_t DoubleTapSwitchLayerReleaseTimeout = 200;
static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT]; static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT];
bool TestUsbStack = false; bool TestUsbStack = false;
bool KeymapChanged = false; static key_action_t actionCache[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE];
static uint8_t layerCache[SLOT_COUNT][MAX_KEY_COUNT_PER_MODULE];
volatile uint8_t UsbReportUpdateSemaphore = 0; volatile uint8_t UsbReportUpdateSemaphore = 0;
@@ -335,8 +334,6 @@ static void updateActiveUsbReports(void)
if (layerChanged) { if (layerChanged) {
stickyModifiers = 0; stickyModifiers = 0;
} }
bool keymapChangedLastCycle = KeymapChanged;
KeymapChanged = false;
LedDisplay_SetLayer(activeLayer); LedDisplay_SetLayer(activeLayer);
if (TestUsbStack) { if (TestUsbStack) {
@@ -383,16 +380,14 @@ static void updateActiveUsbReports(void)
secondaryRoleState = SecondaryRoleState_Triggered; secondaryRoleState = SecondaryRoleState_Triggered;
keyState->current = false; keyState->current = false;
} else { } 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 (keyState->current) {
if ((KeymapChanged || keymapChangedLastCycle) && keyState->previous) { if (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) {
keyState->suppressed = true;
} else if (action->type == KeyActionType_Keystroke && action->keystroke.secondaryRole) {
// Press released secondary role key. // Press released secondary role key.
if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Released) { if (!keyState->previous && secondaryRoleState == SecondaryRoleState_Released) {
secondaryRoleState = SecondaryRoleState_Pressed; secondaryRoleState = SecondaryRoleState_Pressed;
-1
View File
@@ -74,7 +74,6 @@
extern uint32_t UsbReportUpdateCounter; extern uint32_t UsbReportUpdateCounter;
extern volatile uint8_t UsbReportUpdateSemaphore; extern volatile uint8_t UsbReportUpdateSemaphore;
extern bool TestUsbStack; extern bool TestUsbStack;
extern bool KeymapChanged;
// Functions: // Functions: