From 7b9a0e754d4650ad976c1457ea6a2bddd335194d Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 14 Dec 2018 18:02:52 -0600 Subject: [PATCH] Fixed JoyDeviceEvent JoyDeviceEvent is now broken up into JoyDeviceAddedEvent and JoyDeviceRemovedEvent, added these two cases to reflect those changes. --- examples/events/events.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/examples/events/events.go b/examples/events/events.go index 76d7202..afc0e85 100644 --- a/examples/events/events.go +++ b/examples/events/events.go @@ -61,18 +61,16 @@ func run() int { case *sdl.JoyHatEvent: fmt.Printf("[%d ms] JoyHat\ttype:%d\twhich:%d\that:%d\tvalue:%d\n", t.Timestamp, t.Type, t.Which, t.Hat, t.Value) - case *sdl.JoyDeviceEvent: - if t.Type == sdl.JOYDEVICEADDED { - joysticks[int(t.Which)] = sdl.JoystickOpen(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(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("Some event\n") }