Make it possible to disable the double-tap-sticky feature

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/389/head
Gergely Nagy 7 years ago
parent 810acd9842
commit e64f489845

@ -20,7 +20,8 @@ still act as normal when held, that behaviour is not lost.
Furthermore, if a one-shot key is tapped two times in quick succession, it Furthermore, if a one-shot key is tapped two times in quick succession, it
becomes sticky, and remains active until disabled with a third tap. This can be becomes sticky, and remains active until disabled with a third tap. This can be
useful when one needs to input a number of keys with the modifier or layer useful when one needs to input a number of keys with the modifier or layer
active, and still does not wish to hold the key down. active, and still does not wish to hold the key down. If this feature is
undesirable, unset the `OneShot.double_tap_sticky` property (see later).
To make multi-modifier, or multi-layer shortcuts possible, one-shot keys remain To make multi-modifier, or multi-layer shortcuts possible, one-shot keys remain
active if another one-shot of the same type is tapped, so `Ctrl, Alt, b` becomes active if another one-shot of the same type is tapped, so `Ctrl, Alt, b` becomes
@ -48,7 +49,7 @@ void setup() {
## Keymap markup ## Keymap markup
There are two macros the plugin provides: There are two macros the plugin provides:
### `OSM(mod)` ### `OSM(mod)`
@ -111,6 +112,15 @@ modifiers and one-shot layer keys. It has the following methods and properties:
> >
> Defaults to 200. > Defaults to 200.
### `.double_tap_sticky`
> Set this boolean property to make the plugin treat a double-tap of a one-shot
> key as making it sticky until a third tap. Setting it to `false` disables this
> behaviour, in which case double-tapping a one-shot modifier will just restart
> the timer.
>
> Defaults to `true`.
## Dependencies ## Dependencies
* [Kaleidoscope-Ranges](https://github.com/keyboardio/Kaleidoscope-Ranges) * [Kaleidoscope-Ranges](https://github.com/keyboardio/Kaleidoscope-Ranges)

@ -25,6 +25,7 @@ namespace kaleidoscope {
uint32_t OneShot::start_time_ = 0; uint32_t OneShot::start_time_ = 0;
uint16_t OneShot::time_out = 2500; uint16_t OneShot::time_out = 2500;
uint16_t OneShot::hold_time_out = 250; uint16_t OneShot::hold_time_out = 250;
bool OneShot::double_tap_sticky = true;
OneShot::state_t OneShot::state_; OneShot::state_t OneShot::state_;
OneShot::state_t OneShot::sticky_state_; OneShot::state_t OneShot::sticky_state_;
OneShot::state_t OneShot::pressed_state_; OneShot::state_t OneShot::pressed_state_;
@ -130,7 +131,7 @@ Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_st
if (keyToggledOn(key_state)) { if (keyToggledOn(key_state)) {
setPressed(idx); setPressed(idx);
if (isSameAsPrevious(mapped_key)) { if (isSameAsPrevious(mapped_key) && double_tap_sticky) {
setSticky(idx); setSticky(idx);
saveAsPrevious(mapped_key); saveAsPrevious(mapped_key);

@ -39,6 +39,7 @@ class OneShot : public KaleidoscopePlugin {
} }
static uint16_t time_out; static uint16_t time_out;
static uint16_t hold_time_out; static uint16_t hold_time_out;
static bool double_tap_sticky;
static bool isModifierActive(Key key); static bool isModifierActive(Key key);

Loading…
Cancel
Save