Bug fix: glfw.MouseButton should be converted to MouseButton

This commit is contained in:
Hajime Hoshi 2015-01-07 04:04:04 +09:00
parent 7677d885a2
commit 03cf0a7069

View File

@ -33,12 +33,18 @@ func CursorPosition() (x, y int) {
return current.input.cursorPosition() 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) { func (i *input) update(window *glfw.Window, scale int) {
for g, e := range glfwKeyCodeToKey { for g, e := range glfwKeyCodeToKey {
i.keyPressed[e] = window.GetKey(g) == glfw.Press i.keyPressed[e] = window.GetKey(g) == glfw.Press
} }
for b := 0; b < len(i.mouseButtonPressed); b++ { for g, e := range glfwMouseButtonToMouseButton {
i.mouseButtonPressed[b] = window.GetMouseButton(glfw.MouseButton(b)) == glfw.Press i.mouseButtonPressed[e] = window.GetMouseButton(g) == glfw.Press
} }
x, y := window.GetCursorPosition() x, y := window.GetCursorPosition()
i.cursorX = int(math.Floor(x)) / scale i.cursorX = int(math.Floor(x)) / scale