From 26c5bd7162c6c894467ec0ab2bd0adaab4dbde39 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Tue, 20 Mar 2018 10:28:58 -0500 Subject: [PATCH] Ignore keyswitch events with out-of-bounds addresses (#36) Any keyswitch events without real physical addresses were injected by other plugins and should not be processed by Qukeys. There was an interaction with OneShot that prevented the two plugins from working together because OneShot sends events with a (row, col) address of `UNKNOWN_KEYSWITCH_LOCATION` (i.e. 255, 255). This meant that if a OneShot modifier was on when a Qukey was pressed, it would fill up the queue with bogus-address versions of the Qukey, which would then get flushed in the primary state, cancelling the OneShot and producing an un-modified, repeating primary keycode, causing both plugins to fail. --- src/Kaleidoscope/Qukeys.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Kaleidoscope/Qukeys.cpp b/src/Kaleidoscope/Qukeys.cpp index 8f97ee63..b2d04c3b 100644 --- a/src/Kaleidoscope/Qukeys.cpp +++ b/src/Kaleidoscope/Qukeys.cpp @@ -215,6 +215,10 @@ void Qukeys::flushQueue() { Key Qukeys::keyScanHook(Key mapped_key, byte row, byte col, uint8_t key_state) { + // If key_addr is not a physical key, ignore it; some other plugin injected it + if (row >= ROWS || col >= COLS) + return mapped_key; + // If Qukeys is turned off, continue to next plugin if (!active_) return getDualUsePrimaryKey(mapped_key);