From 55af2fd0319013cc1e1ad5c30fb2a7bd0acc0dc9 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Wed, 16 Jun 2021 15:31:27 -0500 Subject: [PATCH] Comment `isStickableDefault()` to explain default stickability Signed-off-by: Michael Richters --- .../src/kaleidoscope/plugin/OneShot.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp index e0d4fbcb..1ab16ba7 100644 --- a/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp +++ b/plugins/Kaleidoscope-OneShot/src/kaleidoscope/plugin/OneShot.cpp @@ -121,15 +121,22 @@ bool OneShot::isStickable(Key key) { bool OneShot::isStickableDefault(Key key) { int8_t n; + // If the key is either a keyboard modifier or a layer shift, we check to see + // if it has been set to be non-stickable. if (key.isKeyboardModifier()) { n = key.getKeyCode() - Key_LeftControl.getKeyCode(); return bitRead(stickable_keys_, n); } else if (key.isLayerShift()) { n = oneshot_mod_count + key.getKeyCode() - LAYER_SHIFT_OFFSET; + // We only keep track of the stickability of the first 8 layers. if (n < oneshot_key_count) { return bitRead(stickable_keys_, n); } } + // The default is for all keys to be "stickable"; if the default was false, + // any user code or other plugin that uses `setPending()` to turn a key into a + // OneShot would need to override `isStickable()` in order to make that key + // stickable (the default `OSM()` behaviour). return true; }