summaryrefslogtreecommitdiff
path: root/input/input.go
diff options
context:
space:
mode:
Diffstat (limited to 'input/input.go')
-rw-r--r--input/input.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/input/input.go b/input/input.go
new file mode 100644
index 0000000..94f4e56
--- /dev/null
+++ b/input/input.go
@@ -0,0 +1,30 @@
+package input
+
+import "ponger/ecs"
+
+type DeviceID int
+
+type Event struct {
+ ecs.Event
+ Which DeviceID
+ Dx, Dy float32
+ JustPressed, JustReleased, IsPressed bool
+}
+
+type Handler interface {
+ Process(ev Event)
+}
+
+func ProcessTree(root any, ev Event) {
+ if inp, ok := root.(Handler); ok {
+ inp.Process(ev)
+ }
+ if g, ok := root.(*ecs.GameObject); ok {
+ for _, c := range g.Children {
+ if c == nil {
+ continue
+ }
+ ProcessTree(c, ev)
+ }
+ }
+}