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 }