func (e *MouseEvents) Poll() (mouse.Event, bool) {
	event, ok := e.buffer.Poll()
	if ok {
		return event, ok
	}
	realX, realY := e.window.CursorPosition()
	if e.lastPosX != realX || e.lastPosY != realY {
		w, h := e.window.Size()
		zoom := float64(e.window.Zoom())
		insideWindow := true
		if int(realX) >= w || int(realY) >= h || realX < 0 || realY < 0 {
			insideWindow = false
		}
		e.lastPosX = realX
		e.lastPosY = realY
		return mouse.NewMovedEvent(int(realX/zoom), int(realY/zoom), realX, realY, insideWindow), true
	}
	return mouse.EmptyEvent, false
}
Poll return next mapped event
package internal
import (
	"github.com/go-gl/glfw/v3.3/glfw"
	"github.com/jacekolszak/pixiq/mouse"
)
type MouseEvents struct {
	buffer             *mouse.EventBuffer
	window             Window
	lastPosX, lastPosY float64
}
func NewMouseEvents(buffer *mouse.EventBuffer, window Window) *MouseEvents {
	if buffer == nil {
		panic("nil buffer")
	}
	if window == nil {
		panic("nil window")
	}
	return &MouseEvents{buffer: buffer, window: window}
}
var mouseButtonMapping = map[glfw.MouseButton]mouse.Button{
	glfw.MouseButtonLeft:   mouse.Left,
	glfw.MouseButtonRight:  mouse.Right,
	glfw.MouseButtonMiddle: mouse.Middle,
	glfw.MouseButton4:      mouse.Button4,
	glfw.MouseButton5:      mouse.Button5,
	glfw.MouseButton6:      mouse.Button6,
	glfw.MouseButton7:      mouse.Button7,
	glfw.MouseButton8:      mouse.Button8,
}
func (e *MouseEvents) OnMouseButtonCallback(_ *glfw.Window, button glfw.MouseButton, action glfw.Action, _ glfw.ModifierKey) {
	btn, ok := mouseButtonMapping[button]
	if !ok {
		return
	}
	switch action {
	case glfw.Press:
		e.buffer.Add(mouse.NewPressedEvent(btn))
	case glfw.Release:
		e.buffer.Add(mouse.NewReleasedEvent(btn))
	}
}
func (e *MouseEvents) OnScrollCallback(_ *glfw.Window, xoff float64, yoff float64) {
	e.buffer.Add(mouse.NewScrolledEvent(-xoff, -yoff))
}
type Window interface {
	CursorPosition() (float64, float64)
	Size() (int, int)
	Zoom() int
}