diff --git a/internal/ui/input_glfw.go b/internal/ui/input_glfw.go index f2f7960d6..a90c9f544 100644 --- a/internal/ui/input_glfw.go +++ b/internal/ui/input_glfw.go @@ -33,12 +33,18 @@ func CursorPosition() (x, y int) { return current.input.cursorPosition() } +var glfwMouseButtonToMouseButton = map[glfw.MouseButton]MouseButton{ + glfw.MouseButtonLeft: MouseButtonLeft, + glfw.MouseButtonRight: MouseButtonRight, + glfw.MouseButtonMiddle: MouseButtonMiddle, +} + func (i *input) update(window *glfw.Window, scale int) { for g, e := range glfwKeyCodeToKey { i.keyPressed[e] = window.GetKey(g) == glfw.Press } - for b := 0; b < len(i.mouseButtonPressed); b++ { - i.mouseButtonPressed[b] = window.GetMouseButton(glfw.MouseButton(b)) == glfw.Press + for g, e := range glfwMouseButtonToMouseButton { + i.mouseButtonPressed[e] = window.GetMouseButton(g) == glfw.Press } x, y := window.GetCursorPosition() i.cursorX = int(math.Floor(x)) / scale