Permalink
Browse files

Fix key input events

  • Loading branch information...
Shinmera committed Aug 28, 2017
1 parent 3655b7f commit 4abe73f42c77ed9b14714a7cd8b2b68d4d8cbfb1
Showing with 7 additions and 8 deletions.
  1. +1 −5 backends/glfw/context.lisp
  2. +6 −3 input.lisp
@@ -12,7 +12,6 @@
((title :initform "" :accessor title)
(cursor-visible :initform T :accessor cursor-visible)
(mouse-pos :initform (vec 0 0) :accessor mouse-pos)
(key-text :initform "" :accessor key-text)
(initargs :initform NIL :accessor initargs)
(window :initform NIL :accessor window))
(:default-initargs
@@ -222,24 +221,21 @@
(case action
(:press
(v:debug :trial.input "Key pressed: ~a" key)
(setf (key-text context) "")
(handle (make-instance 'key-press
:key (glfw-key->key key)
:text ""
:modifiers modifiers)
(handler context)))
(:release
(v:debug :trial.input "Key released: ~a" key)
(handle (make-instance 'key-release
:key (glfw-key->key key)
:text (key-text context)
:modifiers modifiers)
(handler context))))))
(cl-glfw3:def-char-callback ctx-char (window char)
(%with-context
(handle (make-instance 'text-entered
:text char)
:text (string char))
(handler context))))
(cl-glfw3:def-mouse-button-callback ctx-button (window button action modifiers)
View
@@ -10,20 +10,23 @@
())
(defclass keyboard-event (input-event)
())
(defclass key-event (keyboard-event)
((key :initarg :key :reader key)
(modifiers :initarg :modifiers :reader modifiers))
(:default-initargs
:key (error "KEY required.")
:modifiers ()))
(defmethod print-object ((event keyboard-event) stream)
(defmethod print-object ((event key-event) stream)
(print-unreadable-object (event stream :type T)
(format stream "~a" (key event))))
(defclass key-press (keyboard-event)
(defclass key-press (key-event)
())
(defclass key-release (keyboard-event)
(defclass key-release (key-event)
())
(defclass text-entered (keyboard-event)

0 comments on commit 4abe73f

Please sign in to comment.