From 9cbb053d5084504b0b51c2bed3540941b542dfaf Mon Sep 17 00:00:00 2001 From: Nulo Date: Mon, 13 Dec 2021 19:30:56 -0300 Subject: [PATCH] Allow for sticky keys to be used with combo keys --- menelaus.scm | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/menelaus.scm b/menelaus.scm index 255a030..a28c604 100644 --- a/menelaus.scm +++ b/menelaus.scm @@ -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,13 +287,21 @@ (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)) - (if sticky - (begin (press-modifier (+ sticky 1) key) - (press-normal-key keycode key) - (release-sticky-modifier (+ sticky 1))) - (press-normal-key keycode key)))))) + (let ((sticky (find sticky-modifiers 1))) + (if sticky + (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) @@ -321,7 +327,9 @@ (vector-set! keys-for-frame slot #f)) #f) (if modifier-slot - (release-modifier modifier-slot key 0) + (begin + (release-modifier modifier-slot key 0) + (release-key key)) #f))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Send USB