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

one-shot-press shift does not work correctly in some cases, likely due to the rapidity of its release #740

Closed
1 task done
dlip opened this issue Feb 14, 2024 · 6 comments · Fixed by #748
Closed
1 task done
Assignees
Labels
bug Something isn't working linux Issue pertains to Linux only

Comments

@dlip
Copy link

dlip commented Feb 14, 2024

Requirements

Describe the bug

I'm not able to get one-shot shift working, even using the artsey example it doesn't work.

Relevant kanata config

https://github.com/jtroo/kanata/blob/main/cfg_samples/artsey.kbd

To Reproduce

  1. press and release one shot shift
  2. press a key

Expected behavior

key should be uppercase but is lowercase

Kanata version

1.5

Debug logs

2024-02-14T17:09:25.903976709+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_E, value: Press }
2024-02-14T17:09:25.904029335+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_W, value: Press }
2024-02-14T17:09:25.904036379+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_Q, value: Press }
2024-02-14T17:09:26.045432742+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_E, value: Release }
2024-02-14T17:09:26.045525377+11:00 [DEBUG] (2) kanata::kanata: key press     LShift
2024-02-14T17:09:26.045537416+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 1 }
2024-02-14T17:09:26.04563351+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_W, value: Release }
2024-02-14T17:09:26.04564733+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_Q, value: Release }
2024-02-14T17:09:26.23911815+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_D, value: Press }
2024-02-14T17:09:26.349926169+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_D, value: Release }
2024-02-14T17:09:26.350001014+11:00 [DEBUG] (2) kanata::kanata: key press     Y
2024-02-14T17:09:26.350013097+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_Y), value: 1 }
2024-02-14T17:09:26.351282642+11:00 [DEBUG] (2) kanata::kanata: key release   LShift
2024-02-14T17:09:26.351328897+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 0 }
2024-02-14T17:09:26.351417786+11:00 [DEBUG] (2) kanata::kanata: key release   LShift
2024-02-14T17:09:26.351427981+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 0 }
2024-02-14T17:09:26.351467984+11:00 [DEBUG] (2) kanata::kanata: key release   LShift
2024-02-14T17:09:26.351489106+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 0 }
2024-02-14T17:09:26.35150489+11:00 [DEBUG] (2) kanata::kanata: key release   Y
2024-02-14T17:09:26.351519561+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_Y), value: 0 }

Operating system

linux

Additional context

No response

@dlip dlip added the bug Something isn't working label Feb 14, 2024
@jtroo
Copy link
Owner

jtroo commented Feb 14, 2024

Interesting, going by the logs the event sequence looks correct. Isolating to the relevant events:

2024-02-14T17:09:26.045537416+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 1 }
2024-02-14T17:09:26.350013097+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_Y), value: 1 }
2024-02-14T17:09:26.351328897+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 0 }

This reminds me a little of #733, where the order of events from kanata is correct but the DE is not processing it correctly due to the rapidity of events.

What happens if you use one-shot-release?

@jtroo
Copy link
Owner

jtroo commented Feb 14, 2024

As an aside, it's a little unusual that there are three release events for LShift, which I would guess is caused by something in the chording code. However, I don't think it is causing any problems with respect to the bug at this time.

@dlip
Copy link
Author

dlip commented Feb 14, 2024

@jtroo one-shot-release works as expected! Here is a more minimal config to test with the output incase you notice something strange

config:

(defcfg
  linux-dev /dev/input/by-path/platform-i8042-serio-0-event-kbd
)

(defsrc
  q w
)

(deflayer base
  (one-shot 1000 lsft) w
)

output:

2024-02-14T17:59:48.909223874+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_Q, value: Press }
2024-02-14T17:59:48.909272012+11:00 [DEBUG] (2) kanata::kanata: key press     LShift
2024-02-14T17:59:48.909280132+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 1 }
2024-02-14T17:59:49.019930971+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_Q, value: Release }
2024-02-14T17:59:49.224916595+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_W, value: Press }
2024-02-14T17:59:49.224988621+11:00 [DEBUG] (2) kanata::kanata: key press     W
2024-02-14T17:59:49.225000342+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_W), value: 1 }
2024-02-14T17:59:49.226166567+11:00 [DEBUG] (2) kanata::kanata: key release   LShift
2024-02-14T17:59:49.226182307+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 0 }
w2024-02-14T17:59:49.319140459+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_W, value: Release }
2024-02-14T17:59:49.319161481+11:00 [DEBUG] (2) kanata::kanata: key release   W
2024-02-14T17:59:49.319166195+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_W), value: 0 }

config:

(defcfg
  linux-dev /dev/input/by-path/platform-i8042-serio-0-event-kbd
)

(defsrc
  q w
)

(deflayer base
  (one-shot-release 1000 lsft) w
)

output:

2024-02-14T18:01:17.522080971+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_Q, value: Press }
2024-02-14T18:01:17.522179407+11:00 [DEBUG] (2) kanata::kanata: key press     LShift
2024-02-14T18:01:17.522192918+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 1 }
2024-02-14T18:01:17.577123056+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_Q, value: Release }
2024-02-14T18:01:17.845876499+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_W, value: Press }
2024-02-14T18:01:17.845957481+11:00 [DEBUG] (2) kanata::kanata: key press     W
2024-02-14T18:01:17.845976501+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_W), value: 1 }
W2024-02-14T18:01:17.9166045+11:00 [DEBUG] (2) kanata::kanata: process recv ev KeyEvent { code: KEY_W, value: Release }
2024-02-14T18:01:17.916674843+11:00 [DEBUG] (2) kanata::kanata: key release   W
2024-02-14T18:01:17.916689912+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_W), value: 0 }
2024-02-14T18:01:17.917941175+11:00 [DEBUG] (2) kanata::kanata: key release   LShift
2024-02-14T18:01:17.917997043+11:00 [DEBUG] (2) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 0 }

@jtroo jtroo added blocked Blocked on issues outside of the reasonable control of the kanata project bug Something isn't working and removed bug Something isn't working labels Feb 14, 2024
@jtroo jtroo changed the title Bug: one-shot shift not working one-shot-press shift does not work correctly in some cases, likely due to the rapidity of its release Feb 16, 2024
@jtroo jtroo added the linux Issue pertains to Linux only label Feb 16, 2024
@dlip
Copy link
Author

dlip commented Feb 17, 2024

After playing with one-shot-release i realised its not an ideal replacement since if you roll 2 keys in succession they are both capitalised as probably intended

@jtroo jtroo removed the blocked Blocked on issues outside of the reasonable control of the kanata project label Feb 17, 2024
@jtroo
Copy link
Owner

jtroo commented Feb 17, 2024

@dlip I had an idea for how this might be fixed. Could you test out #748, which delays the one-shot-press release by 10 ticks instead of releasing on the next tick?

Can also play around with different values for the delay if it didn't help, or also to see what the minimum value that works for you is.

@dlip
Copy link
Author

dlip commented Feb 17, 2024

@jtroo that branch is working great for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linux Issue pertains to Linux only
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants