Skip to content

Commit 52a2e28

Browse files
committed
Indicate in AudioDeviceEventData if the device is an addition or not
1 parent 580296b commit 52a2e28

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/SDL/Event.hs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,10 @@ data ControllerDeviceEventData =
410410
deriving (Eq,Ord,Generic,Show,Typeable)
411411

412412
data AudioDeviceEventData =
413-
AudioDeviceEventData {audioDeviceEventWhich :: !Word32
414-
-- ^ The audio device ID that reported the event.
413+
AudioDeviceEventData {audioDeviceEventIsAddition :: !Bool
414+
-- ^ If the audio device is an addition, or a removal.
415+
,audioDeviceEventWhich :: !Word32
416+
-- ^ The audio device ID that reported the event.
415417
,audioDeviceEventIsCapture :: !Bool
416418
-- ^ If the audio device is a capture device.
417419
}
@@ -651,8 +653,12 @@ convertRaw (Raw.ControllerButtonEvent _ ts a b c) =
651653
return (Event ts (ControllerButtonEvent (ControllerButtonEventData a b c)))
652654
convertRaw (Raw.ControllerDeviceEvent _ ts a) =
653655
return (Event ts (ControllerDeviceEvent (ControllerDeviceEventData a)))
654-
convertRaw (Raw.AudioDeviceEvent _ ts a b) =
655-
return (Event ts (AudioDeviceEvent (AudioDeviceEventData a (b /= 0))))
656+
convertRaw (Raw.AudioDeviceEvent Raw.SDL_AUDIODEVICEADDED ts a b) =
657+
return (Event ts (AudioDeviceEvent (AudioDeviceEventData True a (b /= 0))))
658+
convertRaw (Raw.AudioDeviceEvent Raw.SDL_AUDIODEVICEREMOVED ts a b) =
659+
return (Event ts (AudioDeviceEvent (AudioDeviceEventData False a (b /= 0))))
660+
convertRaw (Raw.AudioDeviceEvent _ _ _ _) =
661+
error "convertRaw: Unknown audio device motion"
656662
convertRaw (Raw.QuitEvent _ ts) =
657663
return (Event ts QuitEvent)
658664
convertRaw (Raw.UserEvent _ ts a b c d) =

0 commit comments

Comments
 (0)