summaryrefslogtreecommitdiff
path: root/input
diff options
context:
space:
mode:
authorewy <ewy0@protonmail.com>2026-08-13 15:13:39 +0200
committerewy <ewy0@protonmail.com>2026-08-13 15:13:39 +0200
commit60f58e548ef745ec072482954ac37c35d88280d4 (patch)
treeb1d89c0c1e47a427334e7fe708367b1263aaef40 /input
parentd0fe29558b040a11c5c8a744c37fbd2e3826f6c4 (diff)
switch to single render loop
Diffstat (limited to 'input')
-rw-r--r--input/input.go29
-rw-r--r--input/sdl.go34
2 files changed, 5 insertions, 58 deletions
diff --git a/input/input.go b/input/input.go
index 48eeb02..5a0dea7 100644
--- a/input/input.go
+++ b/input/input.go
@@ -1,30 +1,11 @@
package input
-import "ponger/ecs"
+import "ponger/events"
-type DeviceID int
-
-type Event struct {
- ecs.Event
- Which DeviceID
- Dx, Dy float32
- JustPressed, JustReleased, IsPressed bool
-}
-
-type Handler interface {
- Process(ev Event)
+type MouseMotionHandler interface {
+ ProcessMouseMotion(ev events.MouseMotion)
}
-func ProcessTree(root any, ev Event) {
- if inp, ok := root.(Handler); ok {
- inp.Process(ev)
- }
- if g, ok := root.(ecs.IsGameObject); ok {
- for _, c := range g.GO().Children {
- if c == nil {
- continue
- }
- ProcessTree(c, ev)
- }
- }
+type MousePressHandler interface {
+ ProcessMousePress(ev events.MousePress)
}
diff --git a/input/sdl.go b/input/sdl.go
deleted file mode 100644
index 6b88f35..0000000
--- a/input/sdl.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package input
-
-import (
- "github.com/Zyko0/go-sdl3/sdl"
- "ponger/ecs"
-)
-
-func Poll(root ecs.IsGameObject, delta uint64) error {
- e := Event{
- Event: ecs.Event{
- Delta: delta,
- },
- }
- var event sdl.Event
- for sdl.PollEvent(&event) {
- switch event.Type {
- case sdl.EVENT_QUIT:
- return sdl.EndLoop
- case sdl.EVENT_MOUSE_MOTION:
- ev := event.MouseMotionEvent()
- e.Which = DeviceID(ev.Which)
- e.Dx = ev.Xrel
- e.Dy = ev.Yrel
- case sdl.EVENT_MOUSE_BUTTON_DOWN, sdl.EVENT_MOUSE_BUTTON_UP:
- ev := event.MouseButtonEvent()
- e.Which = DeviceID(ev.Which)
- e.JustPressed = ev.Down
- e.JustReleased = !ev.Down
- e.IsPressed = ev.Down
- }
- }
- ProcessTree(root, e)
- return nil
-}