From 748cb2bb1674849ae060ab9bb2f9fa0ab7bd8656 Mon Sep 17 00:00:00 2001 From: Ron Evans Date: Wed, 30 May 2018 13:58:27 +0200 Subject: [PATCH] joystick: update scanner to match go-sdl 0.3 API changes Signed-off-by: Ron Evans --- platforms/joystick/bin/scanner.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/platforms/joystick/bin/scanner.go b/platforms/joystick/bin/scanner.go index b8ba1df8..049c6747 100644 --- a/platforms/joystick/bin/scanner.go +++ b/platforms/joystick/bin/scanner.go @@ -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") }