Allow for sticky keys to be used with combo keys

This commit is contained in:
Cat /dev/Nulo 2021-12-13 19:30:56 -03:00
parent 34de0948da
commit 9cbb053d50

View file

@ -275,10 +275,8 @@
(and slot (vector-set! keycodes-down slot keycode))
(and slot (vector-set! keys-for-frame slot key))))
;; Record a key press in the modifiers/keycodes-down vectors for the layout.
(define (press-key key)
(let ((keycode (lookup key))
(sticky (find sticky-modifiers 1)))
(define (press-key-aux keycode key)
(let ((original-keycode (lookup key)))
;; Sometimes "keycodes" are procedures; in that case we call them with
;; true when the key is pressed and false when it's released.
(if (procedure? keycode)
@ -289,14 +287,22 @@
(press-sticky-modifier (unmodify keycode))
(begin
(press-modifier (unmodify keycode) key)
(press-normal-key (uncombo keycode) key)))
(press-key-aux (uncombo keycode) key)))
(press-modifier (unmodify keycode) key))
(let ((sticky (find sticky-modifiers 1)))
(if sticky
(begin (press-modifier (+ sticky 1) key)
(press-normal-key keycode key)
(begin
(press-modifier (+ sticky 1) key)
(release-sticky-modifier (+ sticky 1)))
#f)
(press-normal-key keycode key))))))
;; Record a key press in the modifiers/keycodes-down vectors for the layout.
(define (press-key key)
(let ((keycode (lookup key)))
(press-key-aux keycode key)))
;; Record that a given key being released resulted in a modifier release.
(define (release-modifier keycode key n)
(if (= (or (vector-ref keys-for-modifiers n) (- 0 1)) key)
@ -321,7 +327,9 @@
(vector-set! keys-for-frame slot #f))
#f)
(if modifier-slot
(begin
(release-modifier modifier-slot key 0)
(release-key key))
#f)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Send USB