Fixes for quaternion camera
[lambdamundo.git] / keyboard.lisp
blob7af279fda8e8c255026f9cfe6b3c9037d984e288
2 (in-package :cl-blockworld)
4 ;; keyboard handling --------------------
6 (defparameter *key-fns* (make-hash-table)
7 "Hash table to map keypresses to function calls")
9 (defmacro make-key-function (key &body forms)
10 "Compile a body and place it in the key hashtable, to be called
11 when the given key is pressed."
12 `(setf (gethash ,key *key-fns*)
13 (compile nil '(lambda () ,@forms))))
15 (defun kill-key-function (key)
16 "Remove a key function from the list"
17 (remhash key *key-fns*))
19 ;; default quit the window function
20 (make-key-function
21 glfw:+key-esc+ (glfw:close-window))
23 (cffi:defcallback blockworld-key-callback
24 :void ((key :int) (action :int)) (when-funcall (gethash key *key-fns*)))