From 00c7fb249e47bc79133dd511df53679e0a42eda7 Mon Sep 17 00:00:00 2001 From: Evy Bongers Date: Tue, 12 Mar 2024 12:13:13 +0100 Subject: [PATCH] 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));