Comment `isStickableDefault()` to explain default stickability

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1062/head
Michael Richters 4 years ago
parent 9f65e808c0
commit 55af2fd031
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -121,15 +121,22 @@ bool OneShot::isStickable(Key key) {
bool OneShot::isStickableDefault(Key key) { bool OneShot::isStickableDefault(Key key) {
int8_t n; 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()) { if (key.isKeyboardModifier()) {
n = key.getKeyCode() - Key_LeftControl.getKeyCode(); n = key.getKeyCode() - Key_LeftControl.getKeyCode();
return bitRead(stickable_keys_, n); return bitRead(stickable_keys_, n);
} else if (key.isLayerShift()) { } else if (key.isLayerShift()) {
n = oneshot_mod_count + key.getKeyCode() - LAYER_SHIFT_OFFSET; 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) { if (n < oneshot_key_count) {
return bitRead(stickable_keys_, n); 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; return true;
} }

Loading…
Cancel
Save