Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sticky keys: fix multiple sticky keys on the same key position active #508

Open
okke-formsma opened this issue Dec 12, 2020 · 0 comments · May be fixed by #670 or #2758
Open

Sticky keys: fix multiple sticky keys on the same key position active #508

okke-formsma opened this issue Dec 12, 2020 · 0 comments · May be fixed by #670 or #2758
Assignees
Labels
behaviors bug Something isn't working

Comments

@okke-formsma
Copy link
Collaborator

  • press sticky shift key on base layer position 0
  • press sticky control key on upper layer position 0
  • press key A

expected result:

  • shift down
  • control down
  • A down
  • A up
  • control up
  • shift up

actual result:

  • shift down
  • shift up
  • control down
  • A down
  • A up
  • control up

This is caused by the sticky key being indexed by position only. The second sticky key replaces the first one.

Tracking the active layer is not enough, because a hold-tap could contain different sticky keys on both the hold and tap.

A possible solution is to track an "event trace id* or something similar, which is a unique ID tracked through all events starting from the key-position-changed all the way to key-code-changed. This would also simplify this ugly code:

        if (strcmp(sticky_key->config->behavior.behavior_dev, "KEY_PRESS") == 0 &&
            HID_USAGE_ID(sticky_key->param1) == ev->keycode &&
            HID_USAGE_PAGE(sticky_key->param1) == ev->usage_page &&
            SELECT_MODS(sticky_key->param1) == ev->implicit_modifiers) {
            // don't catch key down events generated by the sticky key behavior itself
            continue;
        }

into this:

        if (ev->trace_id == sticky_key->trace_id) {
            // don't catch key down events generated by the sticky key behavior itself
            continue;
        }

@innovaker could you assign this to me, and add the bug label?

@Nicell Nicell added the bug Something isn't working label Dec 12, 2020
okke-formsma added a commit to okke-formsma/zmk that referenced this issue Feb 7, 2021
This fixes a bug with overlapping sticky keys when the same key
positions on multiple layers contain different sticky keys.

This also fixes the case when a MT has a sticky key for hold and a
different sticky key for the tap behavior.

Fixes zmkfirmware#508
okke-formsma added a commit to okke-formsma/zmk that referenced this issue Feb 7, 2021
This fixes a bug with overlapping sticky keys when the same key
positions on multiple layers contain different sticky keys.

This also fixes the case when a MT has a sticky key for hold and a
different sticky key for the tap behavior.

Fixes zmkfirmware#508
okke-formsma added a commit to okke-formsma/zmk that referenced this issue Feb 7, 2021
This fixes a bug with overlapping sticky keys when the same key
positions on multiple layers contain different sticky keys.

This also fixes the case when a MT has a sticky key for hold and a
different sticky key for the tap behavior.

Fixes zmkfirmware#508
okke-formsma added a commit to okke-formsma/zmk that referenced this issue Feb 7, 2021
This fixes a bug with overlapping sticky keys when the same key
positions on multiple layers contain different sticky keys.

This also fixes the case when a MT has a sticky key for hold and a
different sticky key for the tap behavior.

Fixes zmkfirmware#508
okke-formsma added a commit to okke-formsma/zmk that referenced this issue Feb 10, 2021
This fixes a bug with overlapping sticky keys when the same key
positions on multiple layers contain different sticky keys.

This also fixes the case when a MT has a sticky key for hold and a
different sticky key for the tap behavior.

Fixes zmkfirmware#508
okke-formsma added a commit to okke-formsma/zmk that referenced this issue Feb 16, 2021
This fixes a bug with overlapping sticky keys when the same key
positions on multiple layers contain different sticky keys.

This also fixes the case when a MT has a sticky key for hold and a
different sticky key for the tap behavior.

Fixes zmkfirmware#508
okke-formsma added a commit to okke-formsma/zmk that referenced this issue Feb 16, 2021
This fixes a bug with overlapping sticky keys when the same key
positions on multiple layers contain different sticky keys.

This also fixes the case when a MT has a sticky key for hold and a
different sticky key for the tap behavior.

Fixes zmkfirmware#508
okke-formsma added a commit to okke-formsma/zmk that referenced this issue Feb 19, 2021
This fixes a bug with overlapping sticky keys when the same key
positions on multiple layers contain different sticky keys.

This also fixes the case when a MT has a sticky key for hold and a
different sticky key for the tap behavior.

Fixes zmkfirmware#508
@urob urob linked a pull request Jan 10, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
behaviors bug Something isn't working
Projects
None yet
2 participants