Skip to content

Commit

Permalink
joystick: update scanner to match go-sdl 0.3 API changes
Browse files Browse the repository at this point in the history
Signed-off-by: Ron Evans <[email protected]>
  • Loading branch information
deadprogram committed May 30, 2018
1 parent 3d4b3b6 commit 748cb2b
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions platforms/joystick/bin/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,16 @@ func run() int {
case *sdl.JoyHatEvent:
fmt.Printf("[%d ms] Hat:%d\tvalue:%d\n",
t.Timestamp, t.Hat, t.Value)
case *sdl.JoyDeviceEvent:
if t.Type == sdl.JOYDEVICEADDED {
joysticks[int(t.Which)] = sdl.JoystickOpen(int(t.Which))
if joysticks[int(t.Which)] != nil {
fmt.Printf("Joystick %d connected\n", t.Which)
}
} else if t.Type == sdl.JOYDEVICEREMOVED {
if joystick := joysticks[int(t.Which)]; joystick != nil {
joystick.Close()
}
fmt.Printf("Joystick %d disconnected\n", t.Which)
case *sdl.JoyDeviceAddedEvent:
joysticks[int(t.Which)] = sdl.JoystickOpen(int(t.Which))
if joysticks[int(t.Which)] != nil {
fmt.Printf("Joystick %d connected\n", t.Which)
}
case *sdl.JoyDeviceRemovedEvent:
if joystick := joysticks[int(t.Which)]; joystick != nil {
joystick.Close()
}
fmt.Printf("Joystick %d disconnected\n", t.Which)
default:
fmt.Printf("Unknown event\n")
}
Expand Down

0 comments on commit 748cb2b

Please sign in to comment.