Merge pull request #159 from UltimateHackingKeyboard/suppress-keys

Suppress pressed keys when the layer or keymap changes
This commit is contained in:
László Monda
2018-08-19 05:00:10 +02:00
committed by GitHub
3 changed files with 6 additions and 2 deletions

View File

@@ -5,6 +5,7 @@
#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] = {
{
@@ -24,6 +25,7 @@ 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)

View File

@@ -25,6 +25,7 @@ static uint16_t DoubleTapSwitchLayerReleaseTimeout = 200;
static bool activeMouseStates[ACTIVE_MOUSE_STATES_COUNT];
bool TestUsbStack = false;
bool KeymapChanged = false;
volatile uint8_t UsbReportUpdateSemaphore = 0;
@@ -333,7 +334,6 @@ static void updateActiveUsbReports(void)
if (layerChanged) {
stickyModifiers = 0;
}
bool layerGotReleased = layerChanged && activeLayer == LayerId_Base;
LedDisplay_SetLayer(activeLayer);
if (TestUsbStack) {
@@ -376,7 +376,7 @@ static void updateActiveUsbReports(void)
WakeUpHost();
}
key_action_t *baseAction = &CurrentKeymap[LayerId_Base][slotId][keyId];
if (layerGotReleased && !(baseAction->type == KeyActionType_Keystroke && baseAction->keystroke.scancode == 0 && baseAction->keystroke.modifiers)) {
if ((layerChanged || KeymapChanged) && !(baseAction->type == KeyActionType_Keystroke && baseAction->keystroke.scancode == 0 && baseAction->keystroke.modifiers)) {
keyState->suppressed = true;
}
@@ -427,6 +427,7 @@ static void updateActiveUsbReports(void)
}
previousLayer = activeLayer;
KeymapChanged = false;
}
uint32_t UsbReportUpdateCounter;

View File

@@ -72,6 +72,7 @@
extern uint32_t UsbReportUpdateCounter;
extern volatile uint8_t UsbReportUpdateSemaphore;
extern bool TestUsbStack;
extern bool KeymapChanged;
// Functions: