Skip to content

Commit

Permalink
Store both primary and alt keys in PROGMEM
Browse files Browse the repository at this point in the history
Signed-off-by: Evy Bongers <[email protected]>
  • Loading branch information
EvyBongers committed Mar 27, 2024
1 parent 9fd4711 commit 57a4fd9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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};
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 57a4fd9

Please sign in to comment.