Merge pull request #159 from UltimateHackingKeyboard/suppress-keys
Suppress pressed keys when the layer or keymap changes
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#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] = {
|
||||||
{
|
{
|
||||||
@@ -24,6 +25,7 @@ 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)
|
||||||
|
|||||||
@@ -25,6 +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;
|
||||||
|
|
||||||
volatile uint8_t UsbReportUpdateSemaphore = 0;
|
volatile uint8_t UsbReportUpdateSemaphore = 0;
|
||||||
|
|
||||||
@@ -333,7 +334,6 @@ static void updateActiveUsbReports(void)
|
|||||||
if (layerChanged) {
|
if (layerChanged) {
|
||||||
stickyModifiers = 0;
|
stickyModifiers = 0;
|
||||||
}
|
}
|
||||||
bool layerGotReleased = layerChanged && activeLayer == LayerId_Base;
|
|
||||||
LedDisplay_SetLayer(activeLayer);
|
LedDisplay_SetLayer(activeLayer);
|
||||||
|
|
||||||
if (TestUsbStack) {
|
if (TestUsbStack) {
|
||||||
@@ -376,7 +376,7 @@ static void updateActiveUsbReports(void)
|
|||||||
WakeUpHost();
|
WakeUpHost();
|
||||||
}
|
}
|
||||||
key_action_t *baseAction = &CurrentKeymap[LayerId_Base][slotId][keyId];
|
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;
|
keyState->suppressed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -427,6 +427,7 @@ static void updateActiveUsbReports(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
previousLayer = activeLayer;
|
previousLayer = activeLayer;
|
||||||
|
KeymapChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t UsbReportUpdateCounter;
|
uint32_t UsbReportUpdateCounter;
|
||||||
|
|||||||
@@ -72,6 +72,7 @@
|
|||||||
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:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user