From d6eb60765d0a1eca65ae6a56ba410548731f0637 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Wed, 20 Mar 2024 21:52:22 +0100 Subject: [PATCH 01/13] Improve consistency when defining ranges Signed-off-by: Evy Bongers --- plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h b/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h index 0deb42b0b8..4e44f25b21 100644 --- a/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h +++ b/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h @@ -62,9 +62,9 @@ enum : uint16_t { OS_LAST = OSL_LAST, DU_FIRST, DUM_FIRST = DU_FIRST, - DUM_LAST = DUM_FIRST + (8 << 8), + DUM_LAST = DUM_FIRST + 2048, DUL_FIRST, - DUL_LAST = DUL_FIRST + (8 << 8), + DUL_LAST = DUL_FIRST + 2048, DU_LAST = DUL_LAST, TD_FIRST, TD_LAST = TD_FIRST + 15, From 3890a13b34cdaf6529647d76c52ad7fe323b9524 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Wed, 20 Mar 2024 22:01:32 +0100 Subject: [PATCH 02/13] Use const expressions for all ranges for clarity Signed-off-by: Evy Bongers --- .../src/Kaleidoscope-Ranges.h | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h b/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h index 4e44f25b21..f3db16973a 100644 --- a/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h +++ b/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h @@ -41,7 +41,17 @@ namespace ranges { // important for compatibility with existing Chrysalis keymaps, despite the fact // that it makes the code more obtuse here. -constexpr uint8_t MAX_CS_KEYS = 64; +constexpr uint8_t MAX_MACROS = 255; +constexpr uint8_t MAX_OSM_KEYS = 7; +constexpr uint8_t MAX_OSL_KEYS = 7; +constexpr uint16_t MAX_DUM_KEYS = 2048; +constexpr uint16_t MAX_DUL_KEYS = 2048; +constexpr uint8_t MAX_TD_KEYS = 15; +constexpr uint8_t MAX_LEAD_KEYS = 7; +constexpr uint8_t MAX_TT_KEYS = 255; +constexpr uint8_t MAX_STENO_KEYS = 42; +constexpr uint8_t MAX_DYNAMIC_MACROS = 31; +constexpr uint8_t MAX_CS_KEYS = 64; enum : uint16_t { // Macro ranges pre-date Kaleidoscope-Ranges, so they're coming before @@ -50,38 +60,38 @@ enum : uint16_t { // between plugin key values and core key values. The magic number // `0b00100000` is the old `IS_MACRO` key flags bit. MACRO_FIRST = (SYNTHETIC | 0b00100000) << 8, - MACRO_LAST = MACRO_FIRST + 255, + MACRO_LAST = MACRO_FIRST + MAX_MACROS, FIRST = 0xc000, KALEIDOSCOPE_FIRST = FIRST, OS_FIRST, OSM_FIRST = OS_FIRST, - OSM_LAST = OSM_FIRST + 7, + OSM_LAST = OSM_FIRST + MAX_OSM_KEYS, OSL_FIRST, - OSL_LAST = OSL_FIRST + 7, + OSL_LAST = OSL_FIRST + MAX_OSL_KEYS, OS_LAST = OSL_LAST, DU_FIRST, DUM_FIRST = DU_FIRST, - DUM_LAST = DUM_FIRST + 2048, + DUM_LAST = DUM_FIRST + MAX_DUM_KEYS, DUL_FIRST, - DUL_LAST = DUL_FIRST + 2048, + DUL_LAST = DUL_FIRST + MAX_DUL_KEYS, DU_LAST = DUL_LAST, TD_FIRST, - TD_LAST = TD_FIRST + 15, + TD_LAST = TD_FIRST + MAX_TD_KEYS, LEAD_FIRST, - LEAD_LAST = LEAD_FIRST + 7, + LEAD_LAST = LEAD_FIRST + MAX_LEAD_KEYS, CYCLE, SYSTER, TT_FIRST, - TT_LAST = TT_FIRST + 255, + TT_LAST = TT_FIRST + MAX_TT_KEYS, STENO_FIRST, - STENO_LAST = STENO_FIRST + 42, + STENO_LAST = STENO_FIRST + MAX_STENO_KEYS, SC_FIRST, SC_LAST, REDIAL, TURBO, DYNAMIC_MACRO_FIRST, - DYNAMIC_MACRO_LAST = DYNAMIC_MACRO_FIRST + 31, + DYNAMIC_MACRO_LAST = DYNAMIC_MACRO_FIRST + MAX_DYNAMIC_MACROS, OS_META_STICKY, OS_ACTIVE_STICKY, OS_CANCEL, From e9bd3da8284fd7242b124f5f9b1187521c5de3ea Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Tue, 12 Mar 2024 12:10:36 +0100 Subject: [PATCH 03/13] Define Qukey range Signed-off-by: Evy Bongers --- plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h b/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h index f3db16973a..3a2a82ea91 100644 --- a/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h +++ b/plugins/Kaleidoscope-Ranges/src/Kaleidoscope-Ranges.h @@ -52,6 +52,7 @@ constexpr uint8_t MAX_TT_KEYS = 255; constexpr uint8_t MAX_STENO_KEYS = 42; constexpr uint8_t MAX_DYNAMIC_MACROS = 31; constexpr uint8_t MAX_CS_KEYS = 64; +constexpr uint8_t MAX_QK_KEYS = 64; enum : uint16_t { // Macro ranges pre-date Kaleidoscope-Ranges, so they're coming before @@ -97,6 +98,8 @@ enum : uint16_t { OS_CANCEL, CS_FIRST, CS_LAST = CS_FIRST + MAX_CS_KEYS, + QK_FIRST, + QK_LAST = QK_FIRST + MAX_QK_KEYS, SAFE_START, KALEIDOSCOPE_SAFE_START = SAFE_START From 00c7fb249e47bc79133dd511df53679e0a42eda7 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Tue, 12 Mar 2024 12:13:13 +0100 Subject: [PATCH 04/13] Define new API Signed-off-by: Evy Bongers --- .../src/kaleidoscope/plugin/Qukeys.cpp | 8 +++++++- .../Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h | 9 ++++++++- tests/issues/1010/test/testcase.cpp | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp index ca0b7e00ed..8c8a61a6cf 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp @@ -20,7 +20,7 @@ #include // for F, __FlashStringHelper #include // for Focus, FocusSerial -#include // for DUL_FIRST, DUM_FIRST, DUL_LAST, DUM_LAST +#include // for DUL_FIRST, DUM_FIRST, DUL_LAST, DUM_LAST, QK_FIRST, QK_LAST #include "kaleidoscope/KeyAddrEventQueue.h" // for KeyAddrEventQueue #include "kaleidoscope/KeyEvent.h" // for KeyEvent @@ -314,6 +314,12 @@ bool Qukeys::isQukey(KeyAddr k) { return true; } + // Then, we check to see if this is a Qukey using the new API (defined in the keymap) + if (key >= ranges::QK_FIRST && key <= ranges::QK_LAST) { + // TODO(EvyBongers) + return false; // for now + } + // Last, we check the qukeys array for a match uint8_t layer_index = Layer.lookupActiveLayer(k); for (uint8_t i{0}; i < qukeys_count_; ++i) { diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h index 6fcf2678f2..8f9ef9ec11 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h @@ -19,7 +19,7 @@ #pragma once #include // for PROGMEM -#include // for DUL_FIRST, DUM_FIRST +#include // for DUL_FIRST, DUM_FIRST, QK_FIRST #include // for uint8_t, uint16_t, int8_t #include "kaleidoscope/KeyAddr.h" // for KeyAddr @@ -244,3 +244,10 @@ extern kaleidoscope::plugin::Qukeys Qukeys; qukey_defs}; \ Qukeys.configureQukeys(qk_table); \ } + +/// This defines a `Key` object that will be handled by the Qukey plugin. +/// The argument `n` is the index number of the `Qukey` in the array (starting +/// at zero). +constexpr kaleidoscope::Key QK(uint8_t n) { + return kaleidoscope::Key(kaleidoscope::ranges::QK_FIRST + n); +} diff --git a/tests/issues/1010/test/testcase.cpp b/tests/issues/1010/test/testcase.cpp index ff2e772857..556ff5416c 100644 --- a/tests/issues/1010/test/testcase.cpp +++ b/tests/issues/1010/test/testcase.cpp @@ -66,6 +66,7 @@ class Issue1010 : public ::testing::Test { OS_CANCEL, CS_FIRST, CS_LAST = CS_FIRST + MAX_CS_KEYS, + // TODO(EvyBongers): add new ranges SAFE_START, KALEIDOSCOPE_SAFE_START = SAFE_START @@ -148,6 +149,7 @@ TEST_F(Issue1010, RangesHaveNotChanged) { uint16_t(kaleidoscope::ranges::CS_FIRST)); ASSERT_EQ(uint16_t(Issue1010::CS_LAST), uint16_t(kaleidoscope::ranges::CS_LAST)); + // TODO(EvyBongers): add tests for new ranges ASSERT_EQ(uint16_t(Issue1010::SAFE_START), uint16_t(kaleidoscope::ranges::SAFE_START)); From 301d0539f80a10858617fc18ce69fc396c56fb86 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Thu, 21 Mar 2024 21:29:28 +0100 Subject: [PATCH 05/13] Add new Qukeys ranges to test for #1010 Signed-off-by: Evy Bongers --- tests/issues/1010/test/testcase.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/issues/1010/test/testcase.cpp b/tests/issues/1010/test/testcase.cpp index 556ff5416c..b9cc6542d2 100644 --- a/tests/issues/1010/test/testcase.cpp +++ b/tests/issues/1010/test/testcase.cpp @@ -26,6 +26,7 @@ namespace testing { class Issue1010 : public ::testing::Test { public: static constexpr uint8_t MAX_CS_KEYS = 64; + static constexpr uint8_t MAX_QK_KEYS = 64; enum : uint16_t { MACRO_FIRST = (SYNTHETIC | 0b00100000) << 8, @@ -66,7 +67,8 @@ class Issue1010 : public ::testing::Test { OS_CANCEL, CS_FIRST, CS_LAST = CS_FIRST + MAX_CS_KEYS, - // TODO(EvyBongers): add new ranges + QK_FIRST, + QK_LAST = QK_FIRST + MAX_QK_KEYS, SAFE_START, KALEIDOSCOPE_SAFE_START = SAFE_START @@ -149,7 +151,10 @@ TEST_F(Issue1010, RangesHaveNotChanged) { uint16_t(kaleidoscope::ranges::CS_FIRST)); ASSERT_EQ(uint16_t(Issue1010::CS_LAST), uint16_t(kaleidoscope::ranges::CS_LAST)); - // TODO(EvyBongers): add tests for new ranges + ASSERT_EQ(uint16_t(Issue1010::QK_FIRST), + uint16_t(kaleidoscope::ranges::QK_FIRST)); + ASSERT_EQ(uint16_t(Issue1010::QK_LAST), + uint16_t(kaleidoscope::ranges::QK_LAST)); ASSERT_EQ(uint16_t(Issue1010::SAFE_START), uint16_t(kaleidoscope::ranges::SAFE_START)); From 3af409a61dcb514b233583ba6ddd7ab1e3b2c8e0 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Thu, 21 Mar 2024 21:38:20 +0100 Subject: [PATCH 06/13] Use const expressions in ranges test as well Signed-off-by: Evy Bongers --- tests/issues/1010/test/testcase.cpp | 34 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/tests/issues/1010/test/testcase.cpp b/tests/issues/1010/test/testcase.cpp index b9cc6542d2..fcf606e8d9 100644 --- a/tests/issues/1010/test/testcase.cpp +++ b/tests/issues/1010/test/testcase.cpp @@ -25,43 +25,53 @@ namespace testing { class Issue1010 : public ::testing::Test { public: - static constexpr uint8_t MAX_CS_KEYS = 64; - static constexpr uint8_t MAX_QK_KEYS = 64; + static constexpr uint8_t MAX_MACROS = 255; + static constexpr uint8_t MAX_OSM_KEYS = 7; + static constexpr uint8_t MAX_OSL_KEYS = 7; + static constexpr uint16_t MAX_DUM_KEYS = 2048; + static constexpr uint16_t MAX_DUL_KEYS = 2048; + static constexpr uint8_t MAX_TD_KEYS = 15; + static constexpr uint8_t MAX_LEAD_KEYS = 7; + static constexpr uint8_t MAX_TT_KEYS = 255; + static constexpr uint8_t MAX_STENO_KEYS = 42; + static constexpr uint8_t MAX_DYNAMIC_MACROS = 31; + static constexpr uint8_t MAX_CS_KEYS = 64; + static constexpr uint8_t MAX_QK_KEYS = 64; enum : uint16_t { MACRO_FIRST = (SYNTHETIC | 0b00100000) << 8, - MACRO_LAST = MACRO_FIRST + 255, + MACRO_LAST = MACRO_FIRST + MAX_MACROS, FIRST = 0xc000, KALEIDOSCOPE_FIRST = FIRST, OS_FIRST, OSM_FIRST = OS_FIRST, - OSM_LAST = OSM_FIRST + 7, + OSM_LAST = OSM_FIRST + MAX_OSM_KEYS, OSL_FIRST, - OSL_LAST = OSL_FIRST + 7, + OSL_LAST = OSL_FIRST + MAX_OSL_KEYS, OS_LAST = OSL_LAST, DU_FIRST, DUM_FIRST = DU_FIRST, - DUM_LAST = DUM_FIRST + (8 << 8), + DUM_LAST = DUM_FIRST + MAX_DUM_KEYS, DUL_FIRST, - DUL_LAST = DUL_FIRST + (8 << 8), + DUL_LAST = DUL_FIRST + MAX_DUL_KEYS, DU_LAST = DUL_LAST, TD_FIRST, - TD_LAST = TD_FIRST + 15, + TD_LAST = TD_FIRST + MAX_TD_KEYS, LEAD_FIRST, - LEAD_LAST = LEAD_FIRST + 7, + LEAD_LAST = LEAD_FIRST + MAX_LEAD_KEYS, CYCLE, SYSTER, TT_FIRST, - TT_LAST = TT_FIRST + 255, + TT_LAST = TT_FIRST + MAX_TT_KEYS, STENO_FIRST, - STENO_LAST = STENO_FIRST + 42, + STENO_LAST = STENO_FIRST + MAX_STENO_KEYS, SC_FIRST, SC_LAST, REDIAL, TURBO, DYNAMIC_MACRO_FIRST, - DYNAMIC_MACRO_LAST = DYNAMIC_MACRO_FIRST + 31, + DYNAMIC_MACRO_LAST = DYNAMIC_MACRO_FIRST + MAX_DYNAMIC_MACROS, OS_META_STICKY, OS_ACTIVE_STICKY, OS_CANCEL, From 950b446edcdc10036f31e4ef6eb579bd2412357a Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Thu, 21 Mar 2024 22:32:13 +0100 Subject: [PATCH 07/13] First attempt at in-keymap qukeys Signed-off-by: Evy Bongers --- .../src/kaleidoscope/plugin/Qukeys.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h index 8f9ef9ec11..229d8ded36 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h @@ -33,14 +33,16 @@ // IWYU pragma: no_include "HIDAliases.h" // DualUse Key definitions for Qukeys in the keymap -#define MT(mod, key) kaleidoscope::plugin::ModTapKey(Key_##mod, Key_##key) +#define MT(mod, key) kaleidoscope::plugin::ModTapKey(Key_##mod, Key_##key) -#define SFT_T(key) MT(LeftShift, key) -#define CTL_T(key) MT(LeftControl, key) -#define ALT_T(key) MT(LeftAlt, key) -#define GUI_T(key) MT(LeftGui, key) +#define SFT_T(key) MT(LeftShift, key) +#define CTL_T(key) MT(LeftControl, key) +#define ALT_T(key) MT(LeftAlt, key) +#define GUI_T(key) MT(LeftGui, key) -#define LT(layer, key) kaleidoscope::plugin::LayerTapKey(layer, Key_##key) +#define LT(layer, key) kaleidoscope::plugin::LayerTapKey(layer, Key_##key) + +#define QK(primary_key, secondary_key) kaleidoscope::plugin::Qukey(primary_key, secondary_key) namespace kaleidoscope { namespace plugin { @@ -55,6 +57,11 @@ constexpr Key LayerTapKey(uint8_t layer, Key tap_key) { (layer << 8) + tap_key.getKeyCode()); } +constexpr Key Qukey(Key primary_key, Key secondary_key) { + return Key(kaleidoscope::ranges::QK_FIRST + + (primary_key.getKeyCode() + secondary_key.getKeyCode()); +} + // Data structure for an individual qukey struct Qukey { // The layer this qukey is mapped on. From 7234c72013a71d9887113cdeb97be2c0e33cc75b Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Sat, 23 Mar 2024 22:02:26 +0100 Subject: [PATCH 08/13] Remove duplicate definition of QK Signed-off-by: Evy Bongers --- .../Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h index 229d8ded36..e1ce68f689 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h @@ -251,10 +251,3 @@ extern kaleidoscope::plugin::Qukeys Qukeys; qukey_defs}; \ Qukeys.configureQukeys(qk_table); \ } - -/// This defines a `Key` object that will be handled by the Qukey plugin. -/// The argument `n` is the index number of the `Qukey` in the array (starting -/// at zero). -constexpr kaleidoscope::Key QK(uint8_t n) { - return kaleidoscope::Key(kaleidoscope::ranges::QK_FIRST + n); -} From 75e08839e9e628a3bb2551b1ff870ebbd73993ad Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Sat, 23 Mar 2024 22:09:49 +0100 Subject: [PATCH 09/13] Temporary fix for duplicate Qukey definition Signed-off-by: Evy Bongers --- plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h index e1ce68f689..ffbea30e03 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h @@ -42,7 +42,7 @@ #define LT(layer, key) kaleidoscope::plugin::LayerTapKey(layer, Key_##key) -#define QK(primary_key, secondary_key) kaleidoscope::plugin::Qukey(primary_key, secondary_key) +#define QK(primary_key, secondary_key) kaleidoscope::plugin::Qkey(primary_key, secondary_key) namespace kaleidoscope { namespace plugin { @@ -57,7 +57,7 @@ constexpr Key LayerTapKey(uint8_t layer, Key tap_key) { (layer << 8) + tap_key.getKeyCode()); } -constexpr Key Qukey(Key primary_key, Key secondary_key) { +constexpr Key Qkey(Key primary_key, Key secondary_key) { return Key(kaleidoscope::ranges::QK_FIRST + (primary_key.getKeyCode() + secondary_key.getKeyCode()); } From 934ee1e828382360ef2037289dce5b699e5208e6 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Sat, 23 Mar 2024 22:12:41 +0100 Subject: [PATCH 10/13] Don't leave open brackets Signed-off-by: Evy Bongers --- plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h index ffbea30e03..083ebd3108 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h @@ -59,7 +59,8 @@ constexpr Key LayerTapKey(uint8_t layer, Key tap_key) { constexpr Key Qkey(Key primary_key, Key secondary_key) { return Key(kaleidoscope::ranges::QK_FIRST + - (primary_key.getKeyCode() + secondary_key.getKeyCode()); + // TODO(EvyBongers): this is going to need review + primary_key.getKeyCode() + secondary_key.getKeyCode()); } // Data structure for an individual qukey From 1a3a5821029f7e3eee8e2a3d02faf67686e00ce7 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Sun, 24 Mar 2024 17:34:51 +0100 Subject: [PATCH 11/13] Little progress Signed-off-by: Evy Bongers --- .../src/kaleidoscope/plugin/Qukeys.cpp | 8 ++++++-- .../Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h | 7 +++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp index 8c8a61a6cf..3fd6705488 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp @@ -316,8 +316,12 @@ bool Qukeys::isQukey(KeyAddr k) { // Then, we check to see if this is a Qukey using the new API (defined in the keymap) if (key >= ranges::QK_FIRST && key <= ranges::QK_LAST) { - // TODO(EvyBongers) - return false; // for now + key.setRaw(key.getRaw() - ranges::QK_FIRST); + + queue_head_.primary_key = key; + // TODO(EvyBongers): retrieve the stored qkey value + //queue_head_.alternate_key = qukey.alternate_key; + return true; } // Last, we check the qukeys array for a match diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h index 083ebd3108..f14067787b 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h @@ -57,10 +57,9 @@ constexpr Key LayerTapKey(uint8_t layer, Key tap_key) { (layer << 8) + tap_key.getKeyCode()); } -constexpr Key Qkey(Key primary_key, Key secondary_key) { - return Key(kaleidoscope::ranges::QK_FIRST + - // TODO(EvyBongers): this is going to need review - primary_key.getKeyCode() + secondary_key.getKeyCode()); +constexpr Key Qkey(Key tap_key, Key qkey) { + // TODO(EvyBongers): store the qkey value somewhere, somehow + return Key(kaleidoscope::ranges::QK_FIRST + tap_key.getRaw()); } // Data structure for an individual qukey From 9fd471145bb7adc2dc27dcf80fbc95e3a36b0fe3 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Sun, 24 Mar 2024 18:10:39 +0100 Subject: [PATCH 12/13] Work out the basic idea Signed-off-by: Evy Bongers --- .../src/kaleidoscope/plugin/Qukeys.cpp | 8 ++++--- .../src/kaleidoscope/plugin/Qukeys.h | 22 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp index 3fd6705488..f53286ae9c 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp @@ -318,9 +318,11 @@ bool Qukeys::isQukey(KeyAddr k) { if (key >= ranges::QK_FIRST && key <= ranges::QK_LAST) { key.setRaw(key.getRaw() - ranges::QK_FIRST); - queue_head_.primary_key = key; - // TODO(EvyBongers): retrieve the stored qkey value - //queue_head_.alternate_key = qukey.alternate_key; + // TODO(EvyBongers): retrieve the stored qkey index + Key qkey = cloneFromProgmem(qkeys_[i]); + + queue_head_.primary_key = key; + queue_head_.alternate_key = qkey; return true; } diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h index f14067787b..e030fd8e9b 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h @@ -57,11 +57,6 @@ constexpr Key LayerTapKey(uint8_t layer, Key tap_key) { (layer << 8) + tap_key.getKeyCode()); } -constexpr Key Qkey(Key tap_key, Key qkey) { - // TODO(EvyBongers): store the qkey value somewhere, somehow - return Key(kaleidoscope::ranges::QK_FIRST + tap_key.getRaw()); -} - // Data structure for an individual qukey struct Qukey { // The layer this qukey is mapped on. @@ -145,6 +140,13 @@ class Qukeys : public kaleidoscope::Plugin { minimum_prior_interval_ = min_interval; } + // Function to store a Qkey + uint8_t storeQkey(Key alt_key) { + qkeys_[qkeys_count_] = alt_key; + ++qkeys_count_; + return (qkeys_count_ - 1); + } + // Function for defining the array of qukeys data (in PROGMEM). It's a // template function that takes as its sole argument an array reference of // size `_qukeys_count`, so there's no need to use `sizeof` to calculate the @@ -165,6 +167,10 @@ class Qukeys : public kaleidoscope::Plugin { EventHandlerResult afterEachCycle(); private: + // An array of Qkeys in PROGMEM. + Key const *qkeys_ PROGMEM; + uint8_t qkeys_count_{0}; + // An array of Qukey objects in PROGMEM. Qukey const *qukeys_{nullptr}; uint8_t qukeys_count_{0}; @@ -241,6 +247,12 @@ bool isModifierKey(Key key); extern kaleidoscope::plugin::Qukeys Qukeys; +constexpr Key Qkey(Key tap_key, Key qkey) { + uint8_t qkey_index = Qukeys.storeQkey(qkey); + // TODO(EvyBongers): store the qkey index somewhere, somehow + return Key(kaleidoscope::ranges::QK_FIRST + tap_key.getRaw()); +} + // Macro for use in sketch file to simplify definition of the qukeys array and // guarantee that the count is set correctly. This is considerably less // important than it used to be, with the `configureQukeys()` function taking From 57a4fd916112d30607dc334d8a22cb21772d1044 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Wed, 27 Mar 2024 20:48:15 +0100 Subject: [PATCH 13/13] Store both primary and alt keys in PROGMEM Signed-off-by: Evy Bongers --- .../src/kaleidoscope/plugin/Qukeys.cpp | 6 +++--- .../src/kaleidoscope/plugin/Qukeys.h | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp index f53286ae9c..02455897cc 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.cpp @@ -316,10 +316,10 @@ bool Qukeys::isQukey(KeyAddr k) { // Then, we check to see if this is a Qukey using the new API (defined in the keymap) if (key >= ranges::QK_FIRST && key <= ranges::QK_LAST) { - key.setRaw(key.getRaw() - ranges::QK_FIRST); + uint8_t qkey_index = key.getRaw() - ranges::QK_FIRST; - // TODO(EvyBongers): retrieve the stored qkey index - Key qkey = cloneFromProgmem(qkeys_[i]); + key.setRaw(cloneFromProgmem(qkeys_[i])[0].getRaw()); + Key qkey = cloneFromProgmem(qkeys_[i])[1]; queue_head_.primary_key = key; queue_head_.alternate_key = qkey; diff --git a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h index e030fd8e9b..a13a1de441 100644 --- a/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h +++ b/plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h @@ -141,8 +141,9 @@ class Qukeys : public kaleidoscope::Plugin { } // Function to store a Qkey - uint8_t storeQkey(Key alt_key) { - qkeys_[qkeys_count_] = alt_key; + uint8_t storeQkey(Key primary_key, Key alt_key) { + qkeys_[qkeys_count_][0] = primary_key; + qkeys_[qkeys_count_][1] = alt_key; ++qkeys_count_; return (qkeys_count_ - 1); } @@ -167,10 +168,6 @@ class Qukeys : public kaleidoscope::Plugin { EventHandlerResult afterEachCycle(); private: - // An array of Qkeys in PROGMEM. - Key const *qkeys_ PROGMEM; - uint8_t qkeys_count_{0}; - // An array of Qukey objects in PROGMEM. Qukey const *qukeys_{nullptr}; uint8_t qukeys_count_{0}; @@ -235,6 +232,10 @@ class Qukeys : public kaleidoscope::Plugin { uint8_t timeout{200}; } tap_repeat_; bool shouldWaitForTapRepeat(); + + // An array of Qkeys in PROGMEM. + uint8_t qkeys_count_{0}; + Key const qkeys_[][2] PROGMEM; }; // This function returns true for any key that we expect to be used chorded with @@ -248,9 +249,8 @@ bool isModifierKey(Key key); extern kaleidoscope::plugin::Qukeys Qukeys; constexpr Key Qkey(Key tap_key, Key qkey) { - uint8_t qkey_index = Qukeys.storeQkey(qkey); - // TODO(EvyBongers): store the qkey index somewhere, somehow - return Key(kaleidoscope::ranges::QK_FIRST + tap_key.getRaw()); + uint8_t qkey_index = Qukeys.storeQkey(tap_key, qkey); + return Key(kaleidoscope::ranges::QK_FIRST + qkey_index); } // Macro for use in sketch file to simplify definition of the qukeys array and