Use input package as a module

This commit is contained in:
Renaud Casenave-Péré 2015-08-27 18:39:42 +02:00
parent 03b2fa65fb
commit 994f7c33c4

View file

@ -5,7 +5,9 @@
(uiop:define-package :stoe/engine/input
(:use :cl :alexandria
:stoe/core/utils :stoe/core/containers)
:stoe/core/utils
:stoe/core/containers
:stoe/core/modules)
(:export #:on-key-event #:on-button-event #:on-motion-event
#:make-keymap #:set-global-keymap
#:define-key #:global-set-key
@ -43,17 +45,17 @@
"List containing the currently active (pressed) keys.
Only those will trigger the release event.")
(defun initialize-input (&optional argv)
(defun initialize (&optional argv)
"Initialize the input module."
(declare (ignore argv))
(format t "Initialize Input module~%"))
(defun finalize-input ()
(defun finalize ()
"Finalize the input module."
(format t "Finalize Input module~%")
(set-global-keymap nil))
(defun update-input (delta-time)
(defun update (delta-time)
"Update the input module.
trigger key events that occured this frame."
(loop for event = (dequeue *event-queue*)
@ -61,6 +63,8 @@ trigger key events that occured this frame."
do (process-event event))
(mapc (lambda (key) (process-active-key key delta-time)) *active-keys*))
(defmodule stoe/engine/input :input)
(defun set-global-keymap (keymap)
"Set the current global keymap."
(setf *current-global-keymap* keymap))