mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
Bug fix: glfw.MouseButton should be converted to MouseButton
This commit is contained in:
parent
7677d885a2
commit
03cf0a7069
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user