Skip to content

Commit

Permalink
Expose modifiers for key, mouse and character input
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Mar 11, 2021
1 parent 5086dec commit bb09727
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion engine/event.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
;;;
;;; Events
;;;

(defun post (event-or-class &rest initargs &key &allow-other-keys)
(let ((event (etypecase event-or-class
((or symbol standard-class) (apply #'make-instance event-or-class initargs))
Expand Down
6 changes: 3 additions & 3 deletions host/events.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@


(defevent keyboard-event (input-event)
(key state))
(key state modifiers))


(defevent character-input-event (input-event)
(character))
(character modifiers))


(defevent mouse-event (input-event)
(button state))
(button state modifiers))


(defevent cursor-event (input-event)
Expand Down
1 change: 1 addition & 0 deletions host/packages.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#:key-from
#:character-from
#:button-from
#:modifiers-from
#:controller-from
#:gamepad-from

Expand Down
12 changes: 9 additions & 3 deletions host/system.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,18 @@
(post 'viewport-hiding-event))


(defun collect-modifiers (app)
(loop for mod in '(:shift :control :alt :super :caps-lock :num-lock)
when (bodge-host:modifiers-engaged-p app mod)
collect mod))


(defmethod bodge-host:on-key-action ((this host-application) key state)
(post 'keyboard-event :key key :state state))
(post 'keyboard-event :key key :state state :modifiers (collect-modifiers this)))


(defmethod bodge-host:on-mouse-action ((this host-application) button state)
(post 'mouse-event :button button :state state))
(post 'mouse-event :button button :state state :modifiers (collect-modifiers this)))


(defmethod bodge-host:on-cursor-movement ((this host-application) x y)
Expand All @@ -135,7 +141,7 @@


(defmethod bodge-host:on-character-input ((this host-application) character)
(post 'character-input-event :character character))
(post 'character-input-event :character character :modifiers (collect-modifiers this)))


(defun make-host-application (cont)
Expand Down

0 comments on commit bb09727

Please sign in to comment.