From 30b820688955f659f82d078f992ab740700fbe91 Mon Sep 17 00:00:00 2001 From: BirDt_ Date: Fri, 17 Apr 2026 21:41:47 +0800 Subject: [PATCH] First pass at a global input action system --- engine/core.scm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/engine/core.scm b/engine/core.scm index 9a432fe..db9d9a4 100644 --- a/engine/core.scm +++ b/engine/core.scm @@ -356,6 +356,44 @@ event) #f))) +;; Input actions alist +(define input-actions '()) + +;; Key-press type action +(define-record-type + (make-key-press key) + key-press? + (key key-press-key)) + +;; Add a new action to the input actions alist +(export register-action) +(define (register-action name type . data) + (assert (symbol? name)) + (assert (member type '(key-press))) + (set! input-actions + (cons (list name + (apply (cond + ((eqv? type 'key-press) make-key-press)) + data)) + input-actions))) + +;; Default global system for simple input management +(add-system + (make-system + 'push-actions + 0 + 'global + '() + (lambda () + (for-each + (lambda (action) + (cond + ((key-press? (cdr action)) + (push-event 'input + (car action) + (cdr action))))) + input-actions)))) + ;; Render queue exports (export register-render-queue push-render-object evaluate-render-queue)