Skip to content

Commit

Permalink
fix get-modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed May 22, 2023
1 parent b969ffb commit 864207b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions frontends/sdl2/keyboard.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,17 @@
(modifier (lem-sdl2/keyboard::get-modifier keysym)))
(make-key-event code modifier)))

(defun mod-p (mod value)
(= value (logand value mod)))

(defun get-modifier (keysym)
(let* ((mod (sdl2:mod-value keysym))
(shift (= 1 (logand 1 mod)))
(ctrl (= 64 (logand 64 mod)))
(meta (= 256 (logand 256 mod))))
(shift (or (mod-p mod sdl2-ffi:+kmod-lshift+)
(mod-p mod sdl2-ffi:+kmod-rshift+)))
(ctrl (or (mod-p mod sdl2-ffi:+kmod-lctrl+)
(mod-p mod sdl2-ffi:+kmod-rctrl+)))
(meta (or (mod-p mod sdl2-ffi:+kmod-lalt+)
(mod-p mod sdl2-ffi:+kmod-ralt+))))
(make-modifier :shift shift :ctrl ctrl :meta meta)))

(defun update-modifier (modifier new-modifier)
Expand Down

0 comments on commit 864207b

Please sign in to comment.