From 9a4962ba930abcb33b796eab22d07521a725bb4d Mon Sep 17 00:00:00 2001 From: Daniel Alejandro Tapia Date: Fri, 27 Dec 2024 21:56:57 -0500 Subject: [PATCH] turn right gui mod into the hyper modifier in sdl2 version i have seen people do this from time to time, namely using one of the gui mods as an extra modifier. on my keyboard, i have an extra gui mod for this purpose, two left guis on both sides and two right gui mods on both sides --- frontends/sdl2/keyboard.lisp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/frontends/sdl2/keyboard.lisp b/frontends/sdl2/keyboard.lisp index ab26bd878..90b705133 100644 --- a/frontends/sdl2/keyboard.lisp +++ b/frontends/sdl2/keyboard.lisp @@ -50,12 +50,13 @@ (values (string (code-char code)) t))))) -(defun make-key (&key ctrl meta shift super sym) +(defun make-key (&key ctrl meta shift super hyper sym) (when (equal sym (string #\yen_sign)) (setf sym "\\")) (lem:make-key :ctrl ctrl :meta meta :super super + :hyper hyper :shift shift :sym sym)) @@ -63,7 +64,8 @@ shift ctrl meta - super) + super + hyper) (defstruct (key-event (:constructor %make-key-event)) code @@ -81,7 +83,8 @@ `((:shift ,sdl2-ffi:+kmod-lshift+ ,sdl2-ffi:+kmod-rshift+) (:ctrl ,sdl2-ffi:+kmod-lctrl+ ,sdl2-ffi:+kmod-rctrl+) (:meta ,sdl2-ffi:+kmod-lalt+ ,sdl2-ffi:+kmod-ralt+) - (:super ,sdl2-ffi:+kmod-lgui+ ,sdl2-ffi:+kmod-rgui+))) + (:super ,sdl2-ffi:+kmod-lgui+) + (:hyper ,sdl2-ffi:+kmod-rgui+))) (defun mod-p (mod mod-type) (some (lambda (value) @@ -93,14 +96,16 @@ (shift (mod-p mod :shift)) (ctrl (mod-p mod :ctrl)) (meta (mod-p mod :meta)) - (super (mod-p mod :super))) - (make-modifier :shift shift :ctrl ctrl :meta meta :super super))) + (super (mod-p mod :super)) + (hyper (mod-p mod :hyper))) + (make-modifier :shift shift :ctrl ctrl :meta meta :super super :hyper hyper))) (defun update-modifier (modifier new-modifier) (setf (modifier-shift modifier) (modifier-shift new-modifier)) (setf (modifier-ctrl modifier) (modifier-ctrl new-modifier)) (setf (modifier-meta modifier) (modifier-meta new-modifier)) - (setf (modifier-super modifier) (modifier-super new-modifier))) + (setf (modifier-super modifier) (modifier-super new-modifier)) + (setf (modifier-hyper modifier) (modifier-hyper new-modifier))) (defvar *modifier* (make-modifier)) (defvar *textediting-text* "") @@ -133,6 +138,7 @@ (let ((key (lem:make-key :ctrl (modifier-ctrl *modifier*) :meta (modifier-meta *modifier*) :super (modifier-super *modifier*) + :hyper (modifier-hyper *modifier*) :shift nil :sym sym))) (when text-input-p @@ -151,6 +157,7 @@ :ctrl (modifier-ctrl modifier) :meta (modifier-meta modifier) :super (modifier-super modifier) + :hyper (modifier-hyper modifier) :sym sym))) (send-key-event key)))))) @@ -223,7 +230,7 @@ (values (cdr elt) t) (values char nil))))) -(defun make-key-with-shift-careful (&key shift ctrl meta super sym) +(defun make-key-with-shift-careful (&key shift ctrl meta super hyper sym) (or (and (= 1 (length sym)) shift (multiple-value-bind (char shift-p) @@ -232,22 +239,26 @@ (make-key :ctrl ctrl :meta meta :super super + :hyper hyper :shift nil :sym (string char))))) (make-key :ctrl ctrl :meta meta :super super + :hyper hyper :shift shift :sym sym))) (defun handle-text-input-internal (text) - (unless (or (modifier-super *modifier*) + (unless (or (modifier-hyper *modifier*) + (modifier-super *modifier*) (modifier-meta *modifier*) (modifier-ctrl *modifier*)) (loop :for c :across text :do (let ((key (make-key :ctrl (modifier-ctrl *modifier*) :meta (modifier-meta *modifier*) :super (modifier-super *modifier*) + :hyper (modifier-hyper *modifier*) :shift nil :sym (convert-to-sym (char-code c))))) (send-key-event key))))) @@ -263,11 +274,13 @@ (modifier-ctrl modifier) (modifier-meta modifier) (modifier-super modifier) + (modifier-hyper modifier) (< 256 code))) (let ((key (make-key-with-shift-careful :shift (modifier-shift modifier) :ctrl (modifier-ctrl modifier) :meta (modifier-meta modifier) :super (modifier-super modifier) + :hyper (modifier-hyper modifier) :sym sym))) (send-key-event key)))))))