Compare commits
No commits in common. "98f3e740e6aebabafdca704ddbfdad42bc70adaf" and "842ae8d4709e7f1c2b805fc6f0d8e2dce10a735b" have entirely different histories.
98f3e740e6
...
842ae8d470
|
@ -13,14 +13,14 @@ func (w *Window) Pressed(button Button) bool {
|
||||||
return w.currInp.buttons[button]
|
return w.currInp.buttons[button]
|
||||||
}
|
}
|
||||||
|
|
||||||
// JustPressed returns whether the Button has been pressed in the last frame.
|
// JustPressed returns whether the Button has just been pressed down.
|
||||||
func (w *Window) JustPressed(button Button) bool {
|
func (w *Window) JustPressed(button Button) bool {
|
||||||
return w.pressEvents[button]
|
return w.currInp.buttons[button] && !w.prevInp.buttons[button]
|
||||||
}
|
}
|
||||||
|
|
||||||
// JustReleased returns whether the Button has been released in the last frame.
|
// JustReleased returns whether the Button has just been released up.
|
||||||
func (w *Window) JustReleased(button Button) bool {
|
func (w *Window) JustReleased(button Button) bool {
|
||||||
return w.releaseEvents[button]
|
return !w.currInp.buttons[button] && w.prevInp.buttons[button]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Repeated returns whether a repeat event has been triggered on button.
|
// Repeated returns whether a repeat event has been triggered on button.
|
||||||
|
@ -362,10 +362,8 @@ func (w *Window) initInput() {
|
||||||
w.window.SetMouseButtonCallback(func(_ *glfw.Window, button glfw.MouseButton, action glfw.Action, mod glfw.ModifierKey) {
|
w.window.SetMouseButtonCallback(func(_ *glfw.Window, button glfw.MouseButton, action glfw.Action, mod glfw.ModifierKey) {
|
||||||
switch action {
|
switch action {
|
||||||
case glfw.Press:
|
case glfw.Press:
|
||||||
w.tempPressEvents[Button(button)] = true
|
|
||||||
w.tempInp.buttons[Button(button)] = true
|
w.tempInp.buttons[Button(button)] = true
|
||||||
case glfw.Release:
|
case glfw.Release:
|
||||||
w.tempReleaseEvents[Button(button)] = true
|
|
||||||
w.tempInp.buttons[Button(button)] = false
|
w.tempInp.buttons[Button(button)] = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -376,10 +374,8 @@ func (w *Window) initInput() {
|
||||||
}
|
}
|
||||||
switch action {
|
switch action {
|
||||||
case glfw.Press:
|
case glfw.Press:
|
||||||
w.tempPressEvents[Button(key)] = true
|
|
||||||
w.tempInp.buttons[Button(key)] = true
|
w.tempInp.buttons[Button(key)] = true
|
||||||
case glfw.Release:
|
case glfw.Release:
|
||||||
w.tempReleaseEvents[Button(key)] = true
|
|
||||||
w.tempInp.buttons[Button(key)] = false
|
w.tempInp.buttons[Button(key)] = false
|
||||||
case glfw.Repeat:
|
case glfw.Repeat:
|
||||||
w.tempInp.repeat[Button(key)] = true
|
w.tempInp.repeat[Button(key)] = true
|
||||||
|
@ -435,12 +431,6 @@ func (w *Window) doUpdateInput() {
|
||||||
w.prevInp = w.currInp
|
w.prevInp = w.currInp
|
||||||
w.currInp = w.tempInp
|
w.currInp = w.tempInp
|
||||||
|
|
||||||
w.pressEvents = w.tempPressEvents
|
|
||||||
w.releaseEvents = w.tempReleaseEvents
|
|
||||||
|
|
||||||
// Clear last frame's temporary status
|
|
||||||
w.tempPressEvents = [KeyLast + 1]bool{}
|
|
||||||
w.tempReleaseEvents = [KeyLast + 1]bool{}
|
|
||||||
w.tempInp.repeat = [KeyLast + 1]bool{}
|
w.tempInp.repeat = [KeyLast + 1]bool{}
|
||||||
w.tempInp.scroll = pixel.ZV
|
w.tempInp.scroll = pixel.ZV
|
||||||
w.tempInp.typed = ""
|
w.tempInp.typed = ""
|
||||||
|
|
|
@ -100,9 +100,6 @@ type Window struct {
|
||||||
typed string
|
typed string
|
||||||
}
|
}
|
||||||
|
|
||||||
pressEvents, tempPressEvents [KeyLast + 1]bool
|
|
||||||
releaseEvents, tempReleaseEvents [KeyLast + 1]bool
|
|
||||||
|
|
||||||
prevJoy, currJoy, tempJoy joystickState
|
prevJoy, currJoy, tempJoy joystickState
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue