gg/event.go

57 lines
878 B
Go
Raw Normal View History

2023-11-23 22:05:22 +03:00
package gg
import (
//"github.com/hajimehoshi/ebiten/v2"
2023-11-23 22:05:22 +03:00
)
2023-12-24 15:05:34 +03:00
func diffEm[V comparable](s1, s2 []V) []V {
2023-11-23 22:05:22 +03:00
combinedSlice := append(s1, s2...)
2023-12-24 15:05:34 +03:00
dm := make(map[V]int)
2023-11-23 22:05:22 +03:00
for _, v := range combinedSlice {
if _, ok := dm[v]; ok {
// remove element later as it exist in both slice.
dm[v] += 1
continue
}
// new entry, add in map!
dm[v] = 1
}
2023-12-24 15:05:34 +03:00
var retSlice []V
2023-11-23 22:05:22 +03:00
for k, v := range dm {
if v == 1 {
retSlice = append(retSlice, k)
}
}
return retSlice
}
type KeyDown struct {
Key
}
type KeyUp struct {
Key
}
type MouseButtonDown struct {
MouseButton
P Vector
}
type MouseButtonUp struct {
MouseButton
P Vector
}
type MouseMove struct {
2023-12-24 15:05:34 +03:00
// Real and absolute deltas.
Real, Abs Vector
}
type WheelChange struct {
Offset Vector
2023-11-23 22:05:22 +03:00
}
type EventChan chan any