From 03cf0a7069904c80eb7795fac729723a866f4bf7 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Wed, 7 Jan 2015 04:04:04 +0900 Subject: [PATCH] Bug fix: glfw.MouseButton should be converted to MouseButton --- internal/ui/input_glfw.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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