-
Notifications
You must be signed in to change notification settings - Fork 259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend Qukeys to support adding Qukeys in the keymap #1408
Changes from 12 commits
d6eb607
3890a13
e9bd3da
00c7fb2
301d053
3af409a
950b446
7234c72
75e0883
934ee1e
1a3a582
9fd4711
57a4fd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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::Qkey(primary_key, secondary_key) | ||
|
||
namespace kaleidoscope { | ||
namespace plugin { | ||
|
@@ -138,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 | ||
|
@@ -158,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}; | ||
|
@@ -234,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()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My first thought was to use the same approach as with the ModTap and LayerTap keys, but if I grokked the logic of storing key code and flags in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On second thought, simply using the sum of these values seems bound to go wrong. I might have to store both key values in PROGMEM (or EEPROM) and return the sum of |
||
|
||
// 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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this needs to be initialized somehow.