Skip to content

Commit

Permalink
Work out the basic idea
Browse files Browse the repository at this point in the history
Signed-off-by: Evy Bongers <[email protected]>
  • Loading branch information
EvyBongers committed Mar 24, 2024
1 parent 1a3a582 commit 9fd4711
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
22 changes: 17 additions & 5 deletions plugins/Kaleidoscope-Qukeys/src/kaleidoscope/plugin/Qukeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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};
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9fd4711

Please sign in to comment.