fixing a bug in sticky key one time state behavior, cleaning up a comment, and making braces style consistent with the rest of the code.
sticky layers in the one time state were being popped anytime kbfun_press_release() was called, which should only happen if the key was defined for the sticky layer, i.e. kbfun_transparent() was not the first function mapped to that key in the topmost layer.f13
parent
2d5c6084c0
commit
15a91f7b05
|
@ -80,8 +80,8 @@ void kbfun_transparent(void) {
|
|||
* ------------------------------------------------------------------------- */
|
||||
|
||||
// While there are only MAX_LAYER_PUSH_POP_FUNCTIONS number of layer functions,
|
||||
// there are 1 + MAX_LAYER_PUSH_POP_FUNCTIONS because we still have layer 0
|
||||
// even if we will never have a push or pop function for it
|
||||
// there are 1 + MAX_LAYER_PUSH_POP_FUNCTIONS layer ids because we still have
|
||||
// layer 0 even if we will never have a push or pop function for it
|
||||
static uint8_t layer_ids[1 + MAX_LAYER_PUSH_POP_FUNCTIONS];
|
||||
|
||||
static void layer_push(uint8_t local_id) {
|
||||
|
@ -90,8 +90,7 @@ static void layer_push(uint8_t local_id) {
|
|||
// Only the topmost layer on the stack should be in sticky once state, pop
|
||||
// the top layer if it is in sticky once state
|
||||
uint8_t topSticky = main_layers_peek_sticky(0);
|
||||
if (topSticky == eStickyOnceDown || topSticky == eStickyOnceUp)
|
||||
{
|
||||
if (topSticky == eStickyOnceDown || topSticky == eStickyOnceUp) {
|
||||
main_layers_pop_id(main_layers_peek(0));
|
||||
}
|
||||
layer_ids[local_id] = main_layers_push(keycode, eStickyNone);
|
||||
|
@ -99,21 +98,18 @@ static void layer_push(uint8_t local_id) {
|
|||
|
||||
static void layer_sticky(uint8_t local_id) {
|
||||
uint8_t keycode = kb_layout_get(LAYER, ROW, COL);
|
||||
if (IS_PRESSED)
|
||||
{
|
||||
if (IS_PRESSED) {
|
||||
uint8_t topLayer = main_layers_peek(0);
|
||||
uint8_t topSticky = main_layers_peek_sticky(0);
|
||||
main_layers_pop_id(layer_ids[local_id]);
|
||||
if (topLayer == local_id)
|
||||
{
|
||||
if (topLayer == local_id) {
|
||||
if (topSticky == eStickyOnceUp)
|
||||
layer_ids[local_id] = main_layers_push(keycode, eStickyLock);
|
||||
}
|
||||
else
|
||||
{
|
||||
// only the topmost layer on the stack should be in sticky once state
|
||||
if (topSticky == eStickyOnceDown || topSticky == eStickyOnceUp)
|
||||
{
|
||||
if (topSticky == eStickyOnceDown || topSticky == eStickyOnceUp) {
|
||||
main_layers_pop_id(layer_ids[topLayer]);
|
||||
}
|
||||
layer_ids[local_id] = main_layers_push(keycode, eStickyOnceDown);
|
||||
|
@ -125,14 +121,11 @@ static void layer_sticky(uint8_t local_id) {
|
|||
{
|
||||
uint8_t topLayer = main_layers_peek(0);
|
||||
uint8_t topSticky = main_layers_peek_sticky(0);
|
||||
if (topLayer == local_id)
|
||||
{
|
||||
if (topSticky == eStickyOnceDown)
|
||||
{
|
||||
if (topLayer == local_id) {
|
||||
if (topSticky == eStickyOnceDown) {
|
||||
// When releasing this sticky key, pop the layer always
|
||||
main_layers_pop_id(layer_ids[local_id]);
|
||||
if (!main_arg_any_non_trans_key_pressed)
|
||||
{
|
||||
if (!main_arg_any_non_trans_key_pressed) {
|
||||
// If no key defined for this layer (a non-transparent key)
|
||||
// was pressed, push the layer again, but in the
|
||||
// StickyOnceUp state
|
||||
|
|
|
@ -100,6 +100,7 @@ int main(void) {
|
|||
main_arg_row = row;
|
||||
main_arg_col = col;
|
||||
main_arg_layer_offset = 0;
|
||||
main_arg_trans_key_pressed = false;
|
||||
main_exec_key();
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +177,6 @@ void main_exec_key(void) {
|
|||
? kb_layout_press_get(layer, row, col)
|
||||
: kb_layout_release_get(layer, row, col) );
|
||||
|
||||
main_arg_trans_key_pressed = false;
|
||||
if (key_function)
|
||||
(*key_function)();
|
||||
|
||||
|
|
Loading…
Reference in New Issue