jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
3.18k stars 130 forks source link

Bug: tap-hold-press and tap-hold-release do not work on Linux #1204

Closed LorenzoIanotto closed 3 months ago

LorenzoIanotto commented 3 months ago

Requirements

Describe the bug

On Linux Kanata will treat both tap-hold variants as a simple tap-hold action, not sending the early hold action. This bug is not present on the Kanata web simulator. I haven't tested it on Windows.

Relevant kanata config

(defsrc
  caps
)

(defalias
  escctrl (tap-hold-press 0 10000 esc lctrl)
)

(deflayer base
  @escctrl
)

To Reproduce

  1. Start Kanata with the relevant config
  2. Hold CapsLock, press and release a letter (for example A), release CapsLock (within the 10s timeout)
  3. Kanata immediately outputs the letter and, when CapsLock is released, the Esc key

Expected behavior

Kanata should send an early lctrl action when the second key is pressed/released

Kanata version

kanata 1.6.1

Debug logs

Here is me pressing CapsLock-A multiple times

2024-08-21T12:32:08.840489372+02:00 [INFO] kanata v1.6.1 starting
2024-08-21T12:32:08.840835401+02:00 [INFO] process unmapped keys: false
2024-08-21T12:32:08.840908966+02:00 [INFO] NOTE: kanata was compiled to never allow cmd
2024-08-21T12:32:08.840920402+02:00 [DEBUG] (1) kanata_parser::cfg::alloc: freeing allocations of length 0
2024-08-21T12:32:08.84102368+02:00 [INFO] config file is valid
2024-08-21T12:32:08.841905213+02:00 [INFO] Created device "/dev/input/event14"
2024-08-21T12:32:08.84209705+02:00 [INFO] Sleeping for 2s. Please release all keys and don't press additional ones. Run kanata with --help to see how understand more and how to disable this sleep.
2024-08-21T12:32:10.842398117+02:00 [INFO] entering the processing loop
2024-08-21T12:32:10.842652025+02:00 [INFO] entering the event loop
2024-08-21T12:32:10.842677848+02:00 [INFO] looking for devices in /dev/input
2024-08-21T12:32:10.842956352+02:00 [INFO] Init: catching only releases and sending immediately
2024-08-21T12:32:10.960909173+02:00 [DEBUG] (1) kanata_state_machine::oskbd::linux: Detected Keyboard: name=AT Translated Set 2 keyboard physical_path=Some("isa0060/serio0/input0")
2024-08-21T12:32:11.067582846+02:00 [DEBUG] (1) kanata_state_machine::oskbd::linux: Detected Mouse: name=FTE1200:00 0B05:0701 Mouse physical_path=Some("i2c-FTE1200:00")
2024-08-21T12:32:11.240819121+02:00 [INFO] registering /dev/input/event5: "AT Translated Set 2 keyboard"
2024-08-21T12:32:11.274153641+02:00 [INFO] registering /dev/input/event9: "FTE1200:00 0B05:0701 Mouse"
2024-08-21T12:32:11.456356393+02:00 [INFO] Starting kanata proper
2024-08-21T12:32:11.456414443+02:00 [INFO] You may forcefully exit kanata by pressing lctl+spc+esc at any time. These keys refer to defsrc input, meaning BEFORE kanata remaps keys.
2024-08-21T12:32:15.008039198+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Press }
2024-08-21T12:32:15.142009105+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Repeat }
2024-08-21T12:32:15.142081507+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: key outs for active layer-while-held: [KEY_ESC, KEY_LEFTCTRL];
2024-08-21T12:32:15.142090442+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: empty layer-while-held outputs, probably transparent
2024-08-21T12:32:15.142095989+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: key outs for default layer: [KEY_ESC, KEY_LEFTCTRL];
2024-08-21T12:32:15.142101479+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: checking defsrc output
2024-08-21T12:32:15.201727395+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Release }
2024-08-21T12:32:15.201794495+02:00 [DEBUG] (3) kanata_state_machine::kanata: key press     Escape
2024-08-21T12:32:15.201803691+02:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ESC), value: 1 }
2024-08-21T12:32:15.207589183+02:00 [DEBUG] (3) kanata_state_machine::kanata: key release   Escape
2024-08-21T12:32:15.207640048+02:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ESC), value: 0 }
2024-08-21T12:32:16.59668608+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Press }
2024-08-21T12:32:16.795272128+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Release }
2024-08-21T12:32:16.795340396+02:00 [DEBUG] (3) kanata_state_machine::kanata: key press     Escape
2024-08-21T12:32:16.795388054+02:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ESC), value: 1 }
2024-08-21T12:32:16.801875424+02:00 [DEBUG] (3) kanata_state_machine::kanata: key release   Escape
2024-08-21T12:32:16.801947953+02:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ESC), value: 0 }
2024-08-21T12:32:18.155115591+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Press }
2024-08-21T12:32:18.288895079+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Repeat }
2024-08-21T12:32:18.288973665+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: key outs for active layer-while-held: [KEY_ESC, KEY_LEFTCTRL];
2024-08-21T12:32:18.288986495+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: empty layer-while-held outputs, probably transparent
2024-08-21T12:32:18.288994907+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: key outs for default layer: [KEY_ESC, KEY_LEFTCTRL];
2024-08-21T12:32:18.289002924+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: checking defsrc output
2024-08-21T12:32:18.305386538+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Repeat }
2024-08-21T12:32:18.305461457+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: key outs for active layer-while-held: [KEY_ESC, KEY_LEFTCTRL];
2024-08-21T12:32:18.305473992+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: empty layer-while-held outputs, probably transparent
2024-08-21T12:32:18.305482334+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: key outs for default layer: [KEY_ESC, KEY_LEFTCTRL];
2024-08-21T12:32:18.305490224+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: checking defsrc output
2024-08-21T12:32:18.32577198+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Repeat }
2024-08-21T12:32:18.325847684+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: key outs for active layer-while-held: [KEY_ESC, KEY_LEFTCTRL];
2024-08-21T12:32:18.325860366+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: empty layer-while-held outputs, probably transparent
2024-08-21T12:32:18.325868686+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: key outs for default layer: [KEY_ESC, KEY_LEFTCTRL];
2024-08-21T12:32:18.325876798+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: checking defsrc output
2024-08-21T12:32:18.62744361+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Release }
2024-08-21T12:32:18.627532804+02:00 [DEBUG] (3) kanata_state_machine::kanata: key press     Escape
2024-08-21T12:32:18.627545888+02:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ESC), value: 1 }
2024-08-21T12:32:18.633287761+02:00 [DEBUG] (3) kanata_state_machine::kanata: key release   Escape
2024-08-21T12:32:18.633350068+02:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ESC), value: 0 }
2024-08-21T12:32:19.737885318+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Press }
2024-08-21T12:32:19.871596761+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Repeat }
2024-08-21T12:32:19.871672975+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: key outs for active layer-while-held: [KEY_ESC, KEY_LEFTCTRL];
2024-08-21T12:32:19.871723911+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: empty layer-while-held outputs, probably transparent
2024-08-21T12:32:19.871734129+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: key outs for default layer: [KEY_ESC, KEY_LEFTCTRL];
2024-08-21T12:32:19.871742774+02:00 [DEBUG] (3) kanata_state_machine::kanata::key_repeat: checking defsrc output
2024-08-21T12:32:20.273065157+02:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_CAPSLOCK, value: Release }
2024-08-21T12:32:20.273134085+02:00 [DEBUG] (3) kanata_state_machine::kanata: key press     Escape
2024-08-21T12:32:20.273139342+02:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ESC), value: 1 }
2024-08-21T12:32:20.279255262+02:00 [DEBUG] (3) kanata_state_machine::kanata: key release   Escape
2024-08-21T12:32:20.279311241+02:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ESC), value: 0 }

Operating system

Arch Linux 6.10.6-arch1-1 x86_64

Additional context

No response

jtroo commented 3 months ago

Please read through this: https://github.com/jtroo/kanata/blob/main/docs/config.adoc#process-unmapped-keys

LorenzoIanotto commented 3 months ago

Adding

(defcfg
  process-unmapped-keys yes
)

Makes it work. Thank you :)