fix joystick disconnect crash
This commit is contained in:
parent
f822b5cabb
commit
fa2501021c
1 changed files with 12 additions and 7 deletions
|
@ -101,11 +101,16 @@ joystickAutoDisconnect js (MsgJoystickDevice _ which SDL.JoyDeviceRemoved) =
|
||||||
liftIO $ do
|
liftIO $ do
|
||||||
joyIds <- mapM SDL.getJoystickID js
|
joyIds <- mapM SDL.getJoystickID js
|
||||||
logIO Verbose $ "These are the Joysticks connected: " ++ show joyIds
|
logIO Verbose $ "These are the Joysticks connected: " ++ show joyIds
|
||||||
[d] <- filterM (\j -> fmap (== which) (SDL.getJoystickID j)) js
|
d <- filterM (\j -> fmap (== which) (SDL.getJoystickID j)) js
|
||||||
logIO Verbose $ "disconnected joysticks: " ++ show d
|
if not (null d)
|
||||||
logIO Verbose $ "Disconnecting Joystick " ++ show which
|
then do
|
||||||
SDL.closeJoystick d
|
logIO Verbose $ "disconnected joysticks: " ++ show (head d)
|
||||||
njoys <- filterM (\j -> return $ d /= j) js
|
logIO Verbose $ "Disconnecting Joystick " ++ show which
|
||||||
logIO Verbose $ "returning joysticks: " ++ show njoys
|
SDL.closeJoystick (head d)
|
||||||
return njoys
|
njoys <- filterM (\j -> return $ head d /= j) js
|
||||||
|
logIO Verbose $ "returning joysticks: " ++ show njoys
|
||||||
|
return njoys
|
||||||
|
else do
|
||||||
|
logIO Error $ "Error while disconnecting Joystick"
|
||||||
|
return js
|
||||||
joystickAutoDisconnect js _ = return js
|
joystickAutoDisconnect js _ = return js
|
||||||
|
|
Loading…
Reference in a new issue