kanata icon indicating copy to clipboard operation
kanata copied to clipboard

Bug: overlapping chords do not behave as expected

Open jtroo opened this issue 1 year ago • 2 comments

That works a lot better than before, amazing work! But I found one issue though when you have overlapping combos. Sorry its a bit complex, I tried to make it simple:

In this example when you press space+w you expect it to output b, but if you roll quickly it outputs tab or w

If you remove (layertab q) b it fixes it

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

(defsrc
  q w e
  spc
)

(defalias
  q (chord chords q)
  w (chord chords w)
  e (chord chords e)
  layertab (chord chords layertab)
)

(defchords chords 100
  (q) (tap-hold 0 200 q lsft)
  (w) (tap-hold 0 200 w lctl)
  (e) left
  (layertab) (tap-hold-press 0 200 tab (layer-toggle raise))
  (layertab q) b
)

(deflayer base
  @q @w @e
  @layertab
)


(deflayer raise
  a b c
  -
)
2024-03-11T10:11:51.100123976+11:00 [DEBUG] (3) kanata::kanata: process recv ev KeyEvent { code: KEY_SPACE, value: Press }
2024-03-11T10:11:51.167933601+11:00 [DEBUG] (3) kanata::kanata: process recv ev KeyEvent { code: KEY_W, value: Press }
2024-03-11T10:11:51.201999603+11:00 [DEBUG] (3) kanata::kanata: key press     Tab
2024-03-11T10:11:51.20204492+11:00 [DEBUG] (3) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_TAB), value: 1 }
2024-03-11T10:11:51.310298816+11:00 [DEBUG] (3) kanata::kanata: process recv ev KeyEvent { code: KEY_W, value: Release }
2024-03-11T10:11:51.310356083+11:00 [DEBUG] (3) kanata::kanata: key press     W
2024-03-11T10:11:51.310368364+11:00 [DEBUG] (3) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_W), value: 1 }
2024-03-11T10:11:51.316828459+11:00 [DEBUG] (3) kanata::kanata: key release   W
2024-03-11T10:11:51.316846207+11:00 [DEBUG] (3) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_W), value: 0 }
2024-03-11T10:11:51.719484254+11:00 [DEBUG] (3) kanata::kanata: process recv ev KeyEvent { code: KEY_SPACE, value: Release }
2024-03-11T10:11:51.719550028+11:00 [DEBUG] (3) kanata::kanata: key release   Tab
2024-03-11T10:11:51.719564482+11:00 [DEBUG] (3) kanata::oskbd::linux: send to uinput: InputEvent { time: SystemTime { tv_sec: 0, tv_nsec: 0 }, kind: Key(KEY_TAB), value: 0 }

Originally posted by @dlip in https://github.com/jtroo/kanata/issues/743#issuecomment-1987400189

jtroo avatar Mar 11 '24 01:03 jtroo

Hm seems like this particular problem might be solved by the changes in this branch: https://github.com/jtroo/kanata/tree/chord-experimentation

But then in some manual testing a (new? or maybe it already existed) problem appeared where repeatedly tapping of q can produce 1 whereas it does not with w/2. Haven't dug into it too deeply yet but seems to have something to do with q being an ambiguous chord and with the timeout/delay interaction for waiting actions.

jtroo avatar Mar 11 '24 06:03 jtroo

Still not having dug into it deeply, I suppose it could worked around with something like:

  (switch
    ((and (key-history q 1) (key-timing 1 lt 200))) q break
    () (tap-hold 0 200 q 1) break
  )

Other thoughts I had would be that perhaps it's time for a v2 of input chords / combos that works similarly to how I think ZMK/QMK do it. Which is to have as input pre-processing on coordinates rather than being another type of action.

jtroo avatar Mar 11 '24 07:03 jtroo

Hopefully adjacently fixed by https://github.com/jtroo/kanata/pull/916

jtroo avatar Apr 15 '24 05:04 jtroo