kanata icon indicating copy to clipboard operation
kanata copied to clipboard

Fake key does not triggered inside nested `multi`

Open akhilman opened this issue 3 years ago • 1 comments

Not all fake key release actions are registered if they were put in nested multi blocks.

Here is sample config. Hold the caps and tap the 1 to stuck in the lol layer. Comment out the release_mods and all will work fine.

(defcfg
  linux-dev /dev/input/by-id/usb-MyFourButtonKeypoard-event-kbd
)

(defsrc
	caps	1	2	3
)

(deflayer base
	@fn	1	2	3
)

(deflayer fn
	XX	@tolol	_	_
)

(deflayer lol
	XX	@lol	@lol	@lol
)

(defalias
	release_mods (multi 
			(on-release-fakekey lsftfk release)
			;; More mod keys here.
		)
	release_layers (multi 
			(on-release-fakekey tololfk release) ;; <- this key never gona be released
			;; More layers here.
	)
	fn	(multi
			(layer-while-held fn)
			@release_mods  ;; <- comment this to be able to release fake key below
			@release_layers
		)
	tolol	(on-press-fakekey tololfk press)
	lol	(macro l o l)
)

(deffakekeys
	tololfk	(layer-while-held lol)
	lsftfk	lsft
)

akhilman avatar Oct 16 '22 06:10 akhilman

Likely issue can be fixed by recursing into multi here: https://github.com/jtroo/kanata/blob/f40f4e4711915c6a058d91cbaf088c544f262a32/src/cfg/mod.rs#L788


Edit: rather than recursing (which the code already does), the solution is to flatten multi.

jtroo avatar Oct 17 '22 05:10 jtroo