summaryrefslogtreecommitdiff
path: root/events/events.go
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 /events/events.go
parentd0fe29558b040a11c5c8a744c37fbd2e3826f6c4 (diff)
switch to single render loop
Diffstat (limited to 'events/events.go')
-rw-r--r--events/events.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/events/events.go b/events/events.go
new file mode 100644
index 0000000..6783703
--- /dev/null
+++ b/events/events.go
@@ -0,0 +1,43 @@
+package events
+
+type DeviceID int
+
+type MouseMotion struct {
+ Which DeviceID
+ Dx, Dy float32
+ Delta uint64
+}
+
+type MousePress struct {
+ Delta uint64
+ Key uint8
+ Which DeviceID
+ JustPressed, JustReleased, IsPressed bool
+}
+
+type WindowChange struct {
+ Height, Width int32
+}
+
+type KeyPress struct {
+ Delta uint64
+ Key string
+ Which DeviceID
+ JustPressed, JustReleased, IsPressed bool
+}
+
+type Event interface {
+ KeyPress | WindowChange | MousePress | MouseMotion
+}
+
+type Events []any
+
+func OfType[T Event](events ...any) []T {
+ var result []T
+ for _, e := range events {
+ if eT, ok := e.(T); ok {
+ result = append(result, eT)
+ }
+ }
+ return result
+}