Skip to content

Commit

Permalink
Define new API
Browse files Browse the repository at this point in the history
Signed-off-by: Evy Bongers <[email protected]>
  • Loading branch information
EvyBongers committed Mar 20, 2024
1 parent e9bd3da commit 00c7fb2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <Arduino.h> // for F, __FlashStringHelper
#include <Kaleidoscope-FocusSerial.h> // for Focus, FocusSerial
#include <Kaleidoscope-Ranges.h> // for DUL_FIRST, DUM_FIRST, DUL_LAST, DUM_LAST
#include <Kaleidoscope-Ranges.h> // 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
Expand Down Expand Up @@ -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) {
Expand Down
9 changes: 8 additions & 1 deletion plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#pragma once

#include <Arduino.h> // for PROGMEM
#include <Kaleidoscope-Ranges.h> // for DUL_FIRST, DUM_FIRST
#include <Kaleidoscope-Ranges.h> // for DUL_FIRST, DUM_FIRST, QK_FIRST
#include <stdint.h> // for uint8_t, uint16_t, int8_t

#include "kaleidoscope/KeyAddr.h" // for KeyAddr
Expand Down Expand Up @@ -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);
}
2 changes: 2 additions & 0 deletions tests/issues/1010/test/testcase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 00c7fb2

Please sign in to comment.