Move input to its own module

This commit is contained in:
BirDt_ 2026-04-19 21:25:08 +08:00
parent f54f9c4b40
commit 6ec23c8ff9
3 changed files with 62 additions and 41 deletions

View file

@ -304,8 +304,6 @@
(hash-table-set! event-buses name (make-hash-table))
name)))
(register-event-bus 'input)
;; Remove an event bus
(define (remove-event-bus name)
(assert (symbol? name))
@ -368,45 +366,6 @@
event)
#f)))
;; Input actions alist
(define input-actions '())
;; Key-press type action
(define-record-type <key-press>
(make-key-press key)
key-press?
(key key-press-key))
;; Add a new action to the input actions alist
(export register-action push-actions)
(define (register-action name type . data)
(assert (symbol? name))
(assert (member type '(key-press)))
(set! input-actions
(cons (cons name
(apply (cond
((eqv? type 'key-press) make-key-press))
data))
input-actions)))
;; Default global system for simple input management
(define push-actions
(make-system
'push-actions
0
'global
'()
(lambda ()
(for-each
(lambda (action)
(cond
((key-press? (cdr action))
(when (key-pressed? (key-press-key (cdr action)))
(push-event 'input
(car action)
(cdr action))))))
input-actions))))
;; Render queue exports
(export register-render-queue push-render-object evaluate-render-queue)