Skip to content

Commit

Permalink
naming consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
bhperry committed Oct 28, 2023
1 parent 5cbefff commit 2305ab0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions backends/opengl/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
})
Expand All @@ -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)
}
}
})
Expand Down
28 changes: 14 additions & 14 deletions input.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2305ab0

Please sign in to comment.