fixing bug/adding function for sticky key behavior - kbfun_press_release_preserve_sticky()

kbfun_press_release_preserve_sticky() is meant to replace
kbfun_press_release as the function used for standard modifiers (shift,
control, alt, and gui) so that the sticky state is preserved and it is
possible to key in chorded commands using a key on another layer
pressing the keys in the chord one key at a time simultaneously without
breaking the sticky state. (e.g. ctrl+F2 as lsticky2, ctrl, x [where x
is defined as F2 on layer 2]

TODO: Noticed a bug where the transparent behavior does not work as
expected for modifiers. lsticky2, ctrl, x does not produce ctrl+F2 when
ctrl is defined as transparent on layer 2 and keycode=ctrl,
press=kprrel, release=kprrel on layer 0.
f13
Ryan Prince 2013-04-08 10:54:49 -07:00
parent eb24aef2d5
commit 4e56966795
2 changed files with 22 additions and 2 deletions

View File

@ -17,6 +17,7 @@
// basic
void kbfun_press_release (void);
void kbfun_press_release_preserve_sticky (void);
void kbfun_toggle (void);
void kbfun_transparent (void);
// --- layer push/pop functions

View File

@ -36,12 +36,31 @@
* Generate a normal keypress or keyrelease
*/
void kbfun_press_release(void) {
uint8_t keycode = kb_layout_get(LAYER, ROW, COL);
if (!main_arg_trans_key_pressed)
main_arg_any_non_trans_key_pressed = true;
kbfun_press_release_preserve_sticky();
}
//TODO:
/*
* [name]
* Press|Release and preserve top layer sticky key state
*
* [description]
* Generate a normal keypress or keyrelease
* While basing the sticky key state transition on whether
* kbfun_press_release() was called after kbfun_transparent() generally
* works in practice, it is not always the desired behavior. One of the
* benefits of sticky keys is avoiding key chording, so we want to make sure
* that standard modifiers do not interrupt the sticky key cycle. Use
* kbfun_press_release_preserve_sticky() if you want to define a standard
* modifier key (shift, control, alt, gui) on the sticky layer instead of
* defining the key to be transparent for the layer.
*/
void kbfun_press_release_preserve_sticky(void) {
uint8_t keycode = kb_layout_get(LAYER, ROW, COL);
_kbfun_press_release(IS_PRESSED, keycode);
}
/*
* [name]
* Toggle