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: Tap dance eager highly consistent when there is unicode(?) inside #1225

Open
1 task done
lunarythia opened this issue Sep 6, 2024 · 11 comments
Open
1 task done
Assignees
Labels
bug Something isn't working

Comments

@lunarythia
Copy link

lunarythia commented Sep 6, 2024

Requirements

Describe the bug

Currently I have the " key set to choose between and depending on what was most recently typed, and I want it to output a normal straight quotation if I type it twice in succession, but for some reason using tap dance eager isn't very consistent.

If I type " twice in succession quickly, it just gives ”“. but every once in awhile, it will output what is expected.

Relevant kanata config

minimal working config (i have the tap dance eager set to 5sec to show that this isn't a timing issue)

(defsrc
  '
  )

(deflayer quot
  @quo
)

(defalias
  quo (tap-dance-eager 5000 (
      (switch
      ((input virtual toggle))
      (multi (unicode ”) (on-press release-vkey toggle)) break
      () (multi (unicode “) (on-press press-vkey toggle)) break)

    (macro bspc t e s t))
  )
)

(defvirtualkeys toggle nop0)

To Reproduce

  1. Hit the " key twice in succession.

Expected behavior

It should output one of the curly quotation marks, then delete it and insert a straight quotation mark.

Kanata version

kanata 1.6.1

Debug logs

This is the output from tapping the " key twice.

2024-09-05T22:32:21.892853268-07:00 [INFO] kanata v1.6.1 starting
2024-09-05T22:32:21.894027098-07:00 [INFO] process unmapped keys: false
2024-09-05T22:32:21.894094982-07:00 [INFO] NOTE: kanata was compiled to never allow cmd
2024-09-05T22:32:21.894136393-07:00 [DEBUG] (1) kanata_parser::cfg::alloc: freeing allocations of length 0
2024-09-05T22:32:21.894637893-07:00 [INFO] config file is valid
2024-09-05T22:32:21.896998766-07:00 [INFO] Created device "/dev/input/event14"
2024-09-05T22:32:21.897265128-07:00 [INFO] entering the processing loop
2024-09-05T22:32:21.897370223-07:00 [INFO] entering the event loop
2024-09-05T22:32:21.897395771-07:00 [INFO] looking for devices in /dev/input
2024-09-05T22:32:21.898226368-07:00 [INFO] Starting kanata proper
2024-09-05T22:32:21.898301812-07: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-09-05T22:32:21.921218937-07:00 [DEBUG] (1) kanata_state_machine::oskbd::linux: Detected Keyboard: name=AT Translated Set 2 keyboard physical_path=Some("isa0060/serio0/input0")
2024-09-05T22:32:21.932589913-07:00 [DEBUG] (1) kanata_state_machine::oskbd::linux: Detected Keyboard: name=Logitech Wireless Keyboard PID:4023 physical_path=Some("usb-0000:00:14.0-1.3/input1:1")
2024-09-05T22:32:21.932922106-07:00 [DEBUG] (1) kanata_state_machine::oskbd::linux: Detected Keyboard/Mouse: name=Logitech Wireless Mouse physical_path=Some("usb-0000:00:14.0-1.3/input1:2")
2024-09-05T22:32:21.986553342-07:00 [INFO] registering /dev/input/event3: "AT Translated Set 2 keyboard"
2024-09-05T22:32:21.994823159-07:00 [INFO] registering /dev/input/event6: "Logitech Wireless Keyboard PID:4023"
2024-09-05T22:32:22.002509348-07:00 [INFO] registering /dev/input/event7: "Logitech Wireless Mouse"
2024-09-05T22:32:25.290490679-07:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_APOSTROPHE, value: Press }
2024-09-05T22:32:25.291978223-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: sending unicode ”
2024-09-05T22:32:25.292093962-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTCTRL), value: 1 }
2024-09-05T22:32:25.292500891-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 1 }
2024-09-05T22:32:25.292598654-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_U), value: 1 }
2024-09-05T22:32:25.29310787-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_U), value: 0 }
2024-09-05T22:32:25.293333576-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 0 }
2024-09-05T22:32:25.293481055-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTCTRL), value: 0 }
2024-09-05T22:32:25.293551782-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_2), value: 1 }
2024-09-05T22:32:25.293605458-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_2), value: 0 }
2024-09-05T22:32:25.293660501-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_0), value: 1 }
2024-09-05T22:32:25.293711057-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_0), value: 0 }
2024-09-05T22:32:25.293764877-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_1), value: 1 }
2024-09-05T22:32:25.293818216-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_1), value: 0 }
2024-09-05T22:32:25.293877496-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_D), value: 1 }
2024-09-05T22:32:25.293928747-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_D), value: 0 }
2024-09-05T22:32:25.293980935-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ENTER), value: 1 }
2024-09-05T22:32:25.294032594-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ENTER), value: 0 }
2024-09-05T22:32:25.294090458-07:00 [DEBUG] (3) kanata_state_machine::kanata: fake key on press   Press 0,1,0 KeyCode(K676)
2024-09-05T22:32:25.29559845-07:00 [DEBUG] (3) kanata_state_machine::kanata: key press     K676
2024-09-05T22:32:25.395872344-07:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_APOSTROPHE, value: Release }
2024-09-05T22:32:25.715404599-07:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_APOSTROPHE, value: Press }
2024-09-05T22:32:25.716304532-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: sending unicode “
2024-09-05T22:32:25.716535014-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTCTRL), value: 1 }
2024-09-05T22:32:25.717710381-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 1 }
2024-09-05T22:32:25.719252033-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_U), value: 1 }
2024-09-05T22:32:25.721493086-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_U), value: 0 }
2024-09-05T22:32:25.721724421-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTSHIFT), value: 0 }
2024-09-05T22:32:25.721815608-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_LEFTCTRL), value: 0 }
2024-09-05T22:32:25.721985851-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_2), value: 1 }
2024-09-05T22:32:25.722235028-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_2), value: 0 }
2024-09-05T22:32:25.72276252-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_0), value: 1 }
2024-09-05T22:32:25.727044626-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_0), value: 0 }
2024-09-05T22:32:25.728012418-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_1), value: 1 }
2024-09-05T22:32:25.729682997-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_1), value: 0 }
2024-09-05T22:32:25.730113685-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_C), value: 1 }
2024-09-05T22:32:25.732666917-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_C), value: 0 }
2024-09-05T22:32:25.73296125-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ENTER), value: 1 }
2024-09-05T22:32:25.734103701-07:00 [DEBUG] (3) kanata_state_machine::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_ENTER), value: 0 }
2024-09-05T22:32:25.73424416-07:00 [DEBUG] (3) kanata_state_machine::kanata: fake key on press   Release 0,1,0 KeyCode(K676)
2024-09-05T22:32:25.734513354-07:00 [DEBUG] (3) kanata_state_machine::kanata: key release   K676
2024-09-05T22:32:25.805741253-07:00 [DEBUG] (3) kanata_state_machine::kanata: process recv ev KeyEvent { code: KEY_APOSTROPHE, value: Release }
^C2024-09-05T22:32:33.231152058-07:00 [ERROR] failed poll: Os { code: 4, kind: Interrupted, message: "Interrupted system call" }

Operating system

Linux (Ubuntu 24.04) and Windows 10

Additional context

I understand that this is a niche thing even for the niche world of Kanata, so I completely understand if it ends up that you can't do much about it. If that is the case, I'll just use regular tap dance. (the reason I prefer tap dance eager is because it sends the output immediately)

@lunarythia lunarythia added the bug Something isn't working label Sep 6, 2024
@jtroo
Copy link
Owner

jtroo commented Sep 6, 2024

I suspect some rapid timing related issues are in play. Could you try adding a delay before the backspace+straight-quotes in the second action of the tap-dance?

(macro 50 bspc ...)

@lunarythia
Copy link
Author

lunarythia commented Sep 6, 2024

@jtroo It still does not work. I then also tried changing your 50 to a 5000 to make the difference more obvious, but when I type it twice, it just immediately sends the output, without the delay, so I think that part isn't being parsed at all.

@lunarythia
Copy link
Author

lunarythia commented Sep 7, 2024

I tried it on a Windows laptop and same issue. Every once in awhile, it will output the correct symbol, but it rarely happens.

@jtroo
Copy link
Owner

jtroo commented Sep 14, 2024

Ah right I recall the issue now, I believe it's that the fake-key presses interfere with the tap-dance eager.

Instead of tap-dance eager you might instead want to put the logic in switch, e.g. a case of ((and (input-history real ' 3) (input-history virtual toggle 2))) (multi (on-press release-key toggle) (macro bspc t e s t)) break.

@jtroo
Copy link
Owner

jtroo commented Sep 14, 2024

Interestingly the simulator seems to have the intended behaviour, but it does have some differences so might be due to that. Sim link

@jtroo
Copy link
Owner

jtroo commented Sep 14, 2024

Maybe this might work: Sim link.

@lunarythia
Copy link
Author

@jtroo Sorry for the late reply but this worked! Thank you so much!

@lunarythia
Copy link
Author

@jtroo I do have one problem though, It wont let me enter quotation marks using S-q. It just outputs as '.

@jtroo
Copy link
Owner

jtroo commented Sep 22, 2024

Can you post a simulator link?

@lunarythia
Copy link
Author

lunarythia commented Sep 22, 2024

Note that quote is on the Q key because of dvorak.

link

@jtroo
Copy link
Owner

jtroo commented Oct 5, 2024

I do have one problem though, It wont let me enter quotation marks using S-q. It just outputs as '.

Is this happening on both Windows and Linux? My guess is only Linux, since the simulator sequence looks like it should be OK, but on Linux the unicode output code would do a press+release of lshift and not repress it even though the physical key is still pressed.

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

No branches or pull requests

2 participants