diff --git a/backends/opengl/input.go b/backends/opengl/input.go index 9f1d324..fb13acf 100644 --- a/backends/opengl/input.go +++ b/backends/opengl/input.go @@ -219,7 +219,7 @@ func (w *Window) initInput() { w.window.SetMouseButtonCallback(func(_ *glfw.Window, button glfw.MouseButton, action glfw.Action, mod glfw.ModifierKey) { if b, buttonOk := mouseButtonMapping[button]; buttonOk { if a, actionOk := actionMapping[action]; actionOk { - w.input.SetButton(b, a) + w.input.ButtonEvent(b, a) } } }) @@ -230,7 +230,7 @@ func (w *Window) initInput() { } if b, buttonOk := keyButtonMapping[key]; buttonOk { if a, actionOk := actionMapping[action]; actionOk { - w.input.SetButton(b, a) + w.input.ButtonEvent(b, a) } } }) diff --git a/input.go b/input.go index ba4a6f4..e2e4951 100644 --- a/input.go +++ b/input.go @@ -37,20 +37,6 @@ func (ih *InputHandler) Repeated(button Button) bool { return ih.currInp.repeat[button] } -// SetButton sets the action state of a button for the next update -func (ih *InputHandler) SetButton(button Button, action Action) { - switch action { - case Press: - ih.tempPressEvents[button] = true - ih.tempInp.buttons[button] = true - case Release: - ih.tempReleaseEvents[button] = true - ih.tempInp.buttons[button] = false - case Repeat: - ih.tempInp.repeat[button] = true - } -} - // MousePosition returns the current mouse position in the Window's Bounds func (ih *InputHandler) MousePosition() Vec { return ih.currInp.mouse @@ -89,6 +75,20 @@ func (ih *InputHandler) SetMousePosition(pos Vec) { ih.tempInp.mouse = pos } +// ButtonEvent sets the action state of a button for the next update +func (ih *InputHandler) ButtonEvent(button Button, action Action) { + switch action { + case Press: + ih.tempPressEvents[button] = true + ih.tempInp.buttons[button] = true + case Release: + ih.tempReleaseEvents[button] = true + ih.tempInp.buttons[button] = false + case Repeat: + ih.tempInp.repeat[button] = true + } +} + // MouseMoveEvent sets the mouse position for the next update func (ih *InputHandler) MouseMoveEvent(pos Vec) { ih.tempInp.mouse = pos