MCPcopy Index your code
hub / github.com/fogleman/nes / checkButtons

Method checkButtons

ui/menuview.go:41–60  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39}
40
41func (view *MenuView) checkButtons() {
42 window := view.director.window
43 k1 := readKeys(window, false)
44 j1 := readJoystick(glfw.Joystick1, false)
45 j2 := readJoystick(glfw.Joystick2, false)
46 buttons := combineButtons(combineButtons(j1, j2), k1)
47 now := glfw.GetTime()
48 for i := range buttons {
49 if buttons[i] && !view.buttons[i] {
50 view.times[i] = now + initialDelay
51 view.onPress(i)
52 } else if !buttons[i] && view.buttons[i] {
53 view.onRelease(i)
54 } else if buttons[i] && now >= view.times[i] {
55 view.times[i] = now + repeatDelay
56 view.onPress(i)
57 }
58 }
59 view.buttons = buttons
60}
61
62func (view *MenuView) onPress(index int) {
63 switch index {

Callers 1

UpdateMethod · 0.95

Calls 5

onPressMethod · 0.95
onReleaseMethod · 0.95
readKeysFunction · 0.85
readJoystickFunction · 0.85
combineButtonsFunction · 0.85

Tested by

no test coverage detected