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

Bug: other keys mapped to lsft causes undesired release of lsft key #796

Open
1 task done
Kuba314 opened this issue Mar 2, 2024 · 3 comments
Open
1 task done
Assignees
Labels
blocked Blocked on issues outside of the reasonable control of the kanata project bug Something isn't working llhook Pertains to the standard version of Kanata on Windows windows Issue pertains to Windows only

Comments

@Kuba314
Copy link

Kuba314 commented Mar 2, 2024

Requirements

Describe the bug

I'm trying to have lctl on my physical lsft and have lsft on my physical caps. This works well, but I noticed that virtual lctl is not held after I Press lctl, Press lsft, Release lsft. This stops me from entering for example C-S-a followed by C-d without releasing the lctl key between the two shortcuts.

From the logs it seems like a kanata bug; kanata should know it's holding lctl, but it sends Release lctl before sending the user-entered shortcut letter (see the log).

This behaviour happens on lsft and caps physical keys (not on a and s) and the shortcut key has to be in defsrc otherwise the bug isn't there and everything works fine.

Relevant kanata config

(defsrc        lsft caps d    f)  ;; doesn't work for `C-d` and `C-f` shortcuts
;; (defsrc        a    s    d    f)  ;; seems to work for every `C-` shortcut

(deflayer test lctl lsft d    _)

To Reproduce

  1. Press physical lsft (mapped lctl)
  2. Press physical caps (mapped lsft)
  3. Release physical caps
  4. Press any letter
  5. Observe that the key is sent without the ctrl modifier

Expected behavior

lctl remains pressed.

Kanata version

1.6.0-prerelease-1

Debug logs

Output of physical Press lsft, Press caps, Release caps, Press f with the attached config. Note the key release LCtrl and key press F lines and their timing.

2024-03-02T23:15:52.8290383+01:00 [DEBUG] (1) kanata::kanata::windows::llhook: event loop: KeyEvent { code: KEY_LEFTSHIFT, value: Press }
2024-03-02T23:15:52.8304903+01:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_LEFTSHIFT, value: Press }
2024-03-02T23:15:52.8306918+01:00 [DEBUG] (2) kanata::kanata: key press     LCtrl
2024-03-02T23:15:53.0806922+01:00 [DEBUG] (1) kanata::kanata::windows::llhook: event loop: KeyEvent { code: KEY_LEFTSHIFT, value: Press }
2024-03-02T23:15:53.082114+01:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_LEFTSHIFT, value: Repeat }
2024-03-02T23:15:53.0822186+01:00 [DEBUG] (2) kanata::kanata: key outs for default layer: [KEY_LEFTCTRL];
2024-03-02T23:15:53.08227+01:00 [DEBUG] (2) kanata::kanata: repeat    LCtrl
2024-03-02T23:15:53.1119244+01:00 [DEBUG] (1) kanata::kanata::windows::llhook: event loop: KeyEvent { code: KEY_LEFTSHIFT, value: Press }
2024-03-02T23:15:53.1129266+01:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_LEFTSHIFT, value: Repeat }
2024-03-02T23:15:53.1129892+01:00 [DEBUG] (2) kanata::kanata: key outs for default layer: [KEY_LEFTCTRL];
2024-03-02T23:15:53.1130195+01:00 [DEBUG] (2) kanata::kanata: repeat    LCtrl
2024-03-02T23:15:53.1431321+01:00 [DEBUG] (1) kanata::kanata::windows::llhook: event loop: KeyEvent { code: KEY_LEFTSHIFT, value: Press }
2024-03-02T23:15:53.1443409+01:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_LEFTSHIFT, value: Repeat }
2024-03-02T23:15:53.1445161+01:00 [DEBUG] (2) kanata::kanata: key outs for default layer: [KEY_LEFTCTRL];
2024-03-02T23:15:53.1445405+01:00 [DEBUG] (2) kanata::kanata: repeat    LCtrl
2024-03-02T23:15:53.1472444+01:00 [DEBUG] (1) kanata::kanata::windows::llhook: event loop: KeyEvent { code: KEY_CAPSLOCK, value: Press }
2024-03-02T23:15:53.1477303+01:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Press }
2024-03-02T23:15:53.1477897+01:00 [DEBUG] (2) kanata::kanata: key press     LShift
2024-03-02T23:15:53.4040299+01:00 [DEBUG] (1) kanata::kanata::windows::llhook: event loop: KeyEvent { code: KEY_CAPSLOCK, value: Press }
2024-03-02T23:15:53.4049658+01:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Repeat }
2024-03-02T23:15:53.4050309+01:00 [DEBUG] (2) kanata::kanata: key outs for default layer: [KEY_LEFTSHIFT];
2024-03-02T23:15:53.4050487+01:00 [DEBUG] (2) kanata::kanata: repeat    LShift
2024-03-02T23:15:53.4160716+01:00 [DEBUG] (1) kanata::kanata::windows::llhook: event loop: KeyEvent { code: KEY_CAPSLOCK, value: Release }
2024-03-02T23:15:53.4163862+01:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Release }
2024-03-02T23:15:53.4164939+01:00 [DEBUG] (2) kanata::kanata: key release   LShift
2024-03-02T23:15:53.4169116+01:00 [DEBUG] (2) kanata::kanata::windows: lsft-arrowkey workaround: removing LShift at its typical coordinate
2024-03-02T23:15:53.4170039+01:00 [DEBUG] (2) kanata::kanata::windows: removing LShift from pressed keys
2024-03-02T23:15:53.6819452+01:00 [DEBUG] (1) kanata::kanata::windows::llhook: event loop: KeyEvent { code: KEY_F, value: Press }
2024-03-02T23:15:53.6834409+01:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_F, value: Press }
2024-03-02T23:15:53.6836278+01:00 [DEBUG] (2) kanata::kanata: key release   LCtrl
2024-03-02T23:15:53.6838594+01:00 [DEBUG] (2) kanata::kanata: key press     F
2024-03-02T23:15:53.7526101+01:00 [DEBUG] (1) kanata::kanata::windows::llhook: event loop: KeyEvent { code: KEY_F, value: Release }
2024-03-02T23:15:53.7541464+01:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_F, value: Release }
2024-03-02T23:15:53.7543725+01:00 [DEBUG] (2) kanata::kanata: key release   F
2024-03-02T23:15:54.0524055+01:00 [DEBUG] (1) kanata::kanata::windows::llhook: event loop: KeyEvent { code: KEY_LEFTSHIFT, value: Release }
2024-03-02T23:15:54.0542314+01:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_LEFTSHIFT, value: Release }

Operating system

Windows 11

Additional context

No response

@Kuba314 Kuba314 added the bug Something isn't working label Mar 2, 2024
@Kuba314
Copy link
Author

Kuba314 commented Mar 2, 2024

Soo.... I don't know how exactly lsft-arrowkey workaround works, but removing LShift at its typical coordinate removes the lctl that I'm holding (probably because it's at lsft's typical coordinate.

Not sure why the lsft-arrowkey workaround has to guess like this and disregard any mapping that there can be to lsft (coord (0, 160)) but it's probably some ancient windows "feature". I do hope there's a fix for this...

@jtroo jtroo added windows Issue pertains to Windows only llhook Pertains to the standard version of Kanata on Windows labels Mar 3, 2024
@jtroo
Copy link
Owner

jtroo commented Mar 3, 2024

Here's the original issue that sparked the creation of the workaround:

#138

In summary, without the workaround, in some cases the lsft button state gets stuck because of Windows weirdness.

Perhaps there needs to be a way to turn the workaround off - I originally decided not to add one because I figured most people would keep their shift keys mapped as shift. When the workaround is off though, you will have the risk that your physical caps key, pressed alongside certain other buttons, will cause the physical lsft key state to be stuck as pressed. There is a tradeoff either way. The other alternative is Interception (which comes with its own issues).

@jtroo jtroo added the blocked Blocked on issues outside of the reasonable control of the kanata project label Mar 3, 2024
@jtroo jtroo changed the title Bug: caps causes release of modifier key Bug: other keys mapped to lsft causes undesired release of lsft key Mar 3, 2024
@jtroo
Copy link
Owner

jtroo commented Apr 19, 2024

I wonder if this problem fixed by using winiov2.. Worth testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Blocked on issues outside of the reasonable control of the kanata project bug Something isn't working llhook Pertains to the standard version of Kanata on Windows windows Issue pertains to Windows only
Projects
None yet
Development

No branches or pull requests

2 participants