IsMouseEvent boolean on all current mouse events

master
Noah 2024-04-19 22:45:13 -07:00
parent 9d436db917
commit c624cc08cd
2 changed files with 7 additions and 2 deletions

View File

@ -27,8 +27,9 @@ type State struct {
keydown map[string]interface{}
// Cursor position
CursorX int
CursorY int
IsMouseEvent bool // A mouse event this tick
CursorX int
CursorY int
// Window resized
WindowResized bool

View File

@ -25,6 +25,7 @@ func (r *Renderer) Poll() (*event.State, error) {
// Reset some events.
s.WindowResized = false
s.Touching = false
s.IsMouseEvent = false
// helper function to push keyboard key names on keyDown events only.
pushKey := func(name string, state uint8) {
@ -56,6 +57,7 @@ func (r *Renderer) Poll() (*event.State, error) {
t.Timestamp, sdl.GetTicks(), t.Type, t.Which, t.X, t.Y, t.XRel, t.YRel,
)
}
s.IsMouseEvent = true
// Push the cursor position.
s.CursorX = int(t.X)
@ -66,6 +68,7 @@ func (r *Renderer) Poll() (*event.State, error) {
t.Timestamp, sdl.GetTicks(), t.Type, t.Which, t.X, t.Y, t.Button, t.State,
)
}
s.IsMouseEvent = true
// Push the cursor position.
s.CursorX = int(t.X)
@ -108,6 +111,7 @@ func (r *Renderer) Poll() (*event.State, error) {
t.Timestamp, sdl.GetTicks(), t.Type, t.Which, t.X, t.Y,
)
}
s.IsMouseEvent = true
case *sdl.TouchFingerEvent:
if DebugTouchEvents {
fmt.Printf("[%d ms] tick:%d TouchFinger type:%d Finger=%d TouchID=%+v Pressure=%f XY=%f,%f\n",