-- | Create virtual input devices.
module Evdev.Uinput (
    Device,
    newDevice,
    writeEvent,
    writeBatch,
    DeviceOpts (..),
    defaultDeviceOpts,
    deviceOptsFromEvents,
    deviceSyspath,
    deviceDevnode,

    -- * Re-exports from 'Evdev'
    AbsInfo (..),
    Event(..),
    EventData(..),
    KeyEvent(..),
    EventCode(..),
    EventValue(..),
) where

import Control.Monad
import Control.Monad.State
import Data.Foldable
import Data.Tuple.Extra
import Foreign

import Data.ByteString.Char8 (ByteString)

import Evdev hiding (Device, newDevice)
import Evdev.Codes
import qualified Evdev.LowLevel as LL
import Util

-- | A `uinput` device.
newtype Device = Device LL.UDevice

-- | Create a new `uinput` device.
newDevice ::
    -- | Device name
    ByteString ->
    DeviceOpts ->
    IO Device
newDevice :: ByteString -> DeviceOpts -> IO Device
newDevice ByteString
name DeviceOpts{[(RepeatEvent, Int)]
[(AbsoluteAxis, AbsInfo)]
[SoundEvent]
[LEDEvent]
[MiscEvent]
[SwitchEvent]
[RelativeAxis]
[Key]
[EventCode]
Maybe Int
Maybe ByteString
phys :: Maybe ByteString
uniq :: Maybe ByteString
idProduct :: Maybe Int
idVendor :: Maybe Int
idBustype :: Maybe Int
idVersion :: Maybe Int
keys :: [Key]
relAxes :: [RelativeAxis]
absAxes :: [(AbsoluteAxis, AbsInfo)]
miscs :: [MiscEvent]
switchs :: [SwitchEvent]
leds :: [LEDEvent]
sounds :: [SoundEvent]
reps :: [(RepeatEvent, Int)]
ffs :: [EventCode]
powers :: [EventCode]
ffStats :: [EventCode]
phys :: DeviceOpts -> Maybe ByteString
uniq :: DeviceOpts -> Maybe ByteString
idProduct :: DeviceOpts -> Maybe Int
idVendor :: DeviceOpts -> Maybe Int
idBustype :: DeviceOpts -> Maybe Int
idVersion :: DeviceOpts -> Maybe Int
keys :: DeviceOpts -> [Key]
relAxes :: DeviceOpts -> [RelativeAxis]
absAxes :: DeviceOpts -> [(AbsoluteAxis, AbsInfo)]
miscs :: DeviceOpts -> [MiscEvent]
switchs :: DeviceOpts -> [SwitchEvent]
leds :: DeviceOpts -> [LEDEvent]
sounds :: DeviceOpts -> [SoundEvent]
reps :: DeviceOpts -> [(RepeatEvent, Int)]
ffs :: DeviceOpts -> [EventCode]
powers :: DeviceOpts -> [EventCode]
ffStats :: DeviceOpts -> [EventCode]
..} = do
    Device
dev <- IO Device
LL.libevdev_new
    Device -> ByteString -> IO ()
LL.setDeviceName Device
dev ByteString
name

    let maybeSet :: (LL.Device -> a -> IO ()) -> Maybe a -> IO ()
        maybeSet :: forall a. (Device -> a -> IO ()) -> Maybe a -> IO ()
maybeSet = IO () -> (a -> IO ()) -> Maybe a -> IO ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe IO ()
forall a. Monoid a => a
mempty ((a -> IO ()) -> Maybe a -> IO ())
-> ((Device -> a -> IO ()) -> a -> IO ())
-> (Device -> a -> IO ())
-> Maybe a
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Device -> a -> IO ()) -> Device -> a -> IO ()
forall a b. (a -> b) -> a -> b
$ Device
dev)
    (Device -> ByteString -> IO ()) -> Maybe ByteString -> IO ()
forall a. (Device -> a -> IO ()) -> Maybe a -> IO ()
maybeSet Device -> ByteString -> IO ()
LL.setDevicePhys Maybe ByteString
phys
    (Device -> ByteString -> IO ()) -> Maybe ByteString -> IO ()
forall a. (Device -> a -> IO ()) -> Maybe a -> IO ()
maybeSet Device -> ByteString -> IO ()
LL.setDeviceUniq Maybe ByteString
uniq
    (Device -> Int -> IO ()) -> Maybe Int -> IO ()
forall a. (Device -> a -> IO ()) -> Maybe a -> IO ()
maybeSet Device -> Int -> IO ()
LL.libevdev_set_id_product Maybe Int
idProduct
    (Device -> Int -> IO ()) -> Maybe Int -> IO ()
forall a. (Device -> a -> IO ()) -> Maybe a -> IO ()
maybeSet Device -> Int -> IO ()
LL.libevdev_set_id_vendor Maybe Int
idVendor
    (Device -> Int -> IO ()) -> Maybe Int -> IO ()
forall a. (Device -> a -> IO ()) -> Maybe a -> IO ()
maybeSet Device -> Int -> IO ()
LL.libevdev_set_id_bustype Maybe Int
idBustype
    (Device -> Int -> IO ()) -> Maybe Int -> IO ()
forall a. (Device -> a -> IO ()) -> Maybe a -> IO ()
maybeSet Device -> Int -> IO ()
LL.libevdev_set_id_version Maybe Int
idVersion

    let enable :: Ptr () -> EventType -> [Word16] -> IO ()
        enable :: Ptr () -> EventType -> [Word16] -> IO ()
enable Ptr ()
ptr EventType
t [Word16]
cs = do
            Bool -> IO () -> IO ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless ([Word16] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Word16]
cs) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ IO Errno -> IO (CErrCallRes Errno)
forall a. CErrCall a => IO a -> IO (CErrCallRes a)
cec (IO Errno -> IO (CErrCallRes Errno))
-> IO Errno -> IO (CErrCallRes Errno)
forall a b. (a -> b) -> a -> b
$ Device -> Word16 -> IO Errno
LL.enableType Device
dev Word16
t'
            [Word16] -> (Word16 -> IO ()) -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [Word16]
cs ((Word16 -> IO ()) -> IO ()) -> (Word16 -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Word16
c -> IO Errno -> IO (CErrCallRes Errno)
forall a. CErrCall a => IO a -> IO (CErrCallRes a)
cec (IO Errno -> IO (CErrCallRes Errno))
-> IO Errno -> IO (CErrCallRes Errno)
forall a b. (a -> b) -> a -> b
$ Device -> Word16 -> Word16 -> Ptr () -> IO Errno
LL.enableCode Device
dev Word16
t' Word16
c Ptr ()
ptr
          where
            t' :: Word16
t' = EventType -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' EventType
t

    ((EventType, [Word16]) -> IO ())
-> [(EventType, [Word16])] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_
        ((EventType -> [Word16] -> IO ()) -> (EventType, [Word16]) -> IO ()
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ((EventType -> [Word16] -> IO ())
 -> (EventType, [Word16]) -> IO ())
-> (EventType -> [Word16] -> IO ())
-> (EventType, [Word16])
-> IO ()
forall a b. (a -> b) -> a -> b
$ Ptr () -> EventType -> [Word16] -> IO ()
enable Ptr ()
forall a. Ptr a
nullPtr)
        [ (EventType
EvKey, (Key -> Word16) -> [Key] -> [Word16]
forall a b. (a -> b) -> [a] -> [b]
map Key -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' [Key]
keys)
        , (EventType
EvRel, (RelativeAxis -> Word16) -> [RelativeAxis] -> [Word16]
forall a b. (a -> b) -> [a] -> [b]
map RelativeAxis -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' [RelativeAxis]
relAxes)
        , (EventType
EvMsc, (MiscEvent -> Word16) -> [MiscEvent] -> [Word16]
forall a b. (a -> b) -> [a] -> [b]
map MiscEvent -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' [MiscEvent]
miscs)
        , (EventType
EvSw, (SwitchEvent -> Word16) -> [SwitchEvent] -> [Word16]
forall a b. (a -> b) -> [a] -> [b]
map SwitchEvent -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' [SwitchEvent]
switchs)
        , (EventType
EvLed, (LEDEvent -> Word16) -> [LEDEvent] -> [Word16]
forall a b. (a -> b) -> [a] -> [b]
map LEDEvent -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' [LEDEvent]
leds)
        , (EventType
EvSnd, (SoundEvent -> Word16) -> [SoundEvent] -> [Word16]
forall a b. (a -> b) -> [a] -> [b]
map SoundEvent -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' [SoundEvent]
sounds)
        , (EventType
EvFf, (EventCode -> Word16) -> [EventCode] -> [Word16]
forall a b. (a -> b) -> [a] -> [b]
map EventCode -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' [EventCode]
ffs)
        , (EventType
EvPwr, (EventCode -> Word16) -> [EventCode] -> [Word16]
forall a b. (a -> b) -> [a] -> [b]
map EventCode -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' [EventCode]
powers)
        , (EventType
EvFfStatus, (EventCode -> Word16) -> [EventCode] -> [Word16]
forall a b. (a -> b) -> [a] -> [b]
map EventCode -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' [EventCode]
ffStats)
        ]

    [(RepeatEvent, Int)] -> ((RepeatEvent, Int) -> IO ()) -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [(RepeatEvent, Int)]
reps (((RepeatEvent, Int) -> IO ()) -> IO ())
-> ((RepeatEvent, Int) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \(RepeatEvent
rep, Int
n) -> do
        ForeignPtr Int
pf <- IO (ForeignPtr Int)
forall a. Storable a => IO (ForeignPtr a)
mallocForeignPtr
        ForeignPtr Int -> (Ptr Int -> IO ()) -> IO ()
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
withForeignPtr ForeignPtr Int
pf \Ptr Int
p -> do
            Ptr Int -> Int -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Int
p Int
n
            Ptr () -> EventType -> [Word16] -> IO ()
enable (Ptr Int -> Ptr ()
forall a b. Ptr a -> Ptr b
castPtr Ptr Int
p) EventType
EvRep [RepeatEvent -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' RepeatEvent
rep]

    [(AbsoluteAxis, AbsInfo)]
-> ((AbsoluteAxis, AbsInfo) -> IO ()) -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [(AbsoluteAxis, AbsInfo)]
absAxes (((AbsoluteAxis, AbsInfo) -> IO ()) -> IO ())
-> ((AbsoluteAxis, AbsInfo) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \(AbsoluteAxis
axis, AbsInfo
absInfo) ->
        AbsInfo -> (Ptr () -> IO ()) -> IO ()
forall a. AbsInfo -> (Ptr () -> IO a) -> IO a
LL.withAbsInfo AbsInfo
absInfo ((Ptr () -> IO ()) -> IO ()) -> (Ptr () -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr ()
ptr ->
            Ptr () -> EventType -> [Word16] -> IO ()
enable Ptr ()
ptr EventType
EvAbs [AbsoluteAxis -> Word16
forall c a. (Num c, Enum a) => a -> c
fromEnum' AbsoluteAxis
axis]

    (UDevice -> Device) -> IO UDevice -> IO Device
forall a b. (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap UDevice -> Device
Device (IO UDevice -> IO Device) -> IO UDevice -> IO Device
forall a b. (a -> b) -> a -> b
$ IO (Errno, UDevice) -> IO (CErrCallRes (Errno, UDevice))
forall a. CErrCall a => IO a -> IO (CErrCallRes a)
cec (IO (Errno, UDevice) -> IO (CErrCallRes (Errno, UDevice)))
-> IO (Errno, UDevice) -> IO (CErrCallRes (Errno, UDevice))
forall a b. (a -> b) -> a -> b
$ Device -> Fd -> IO (Errno, UDevice)
LL.createFromDevice Device
dev (Fd -> IO (Errno, UDevice)) -> Fd -> IO (Errno, UDevice)
forall a b. (a -> b) -> a -> b
$ UInputOpenMode -> Fd
forall c a. (Num c, Enum a) => a -> c
fromEnum' UInputOpenMode
LL.UOMManaged
  where
    cec :: CErrCall a => IO a -> IO (CErrCallRes a)
    cec :: forall a. CErrCall a => IO a -> IO (CErrCallRes a)
cec = String -> () -> IO a -> IO (CErrCallRes a)
forall a info.
(CErrCall a, CErrInfo info) =>
String -> info -> IO a -> IO (CErrCallRes a)
forall info.
CErrInfo info =>
String -> info -> IO a -> IO (CErrCallRes a)
cErrCall String
"newDevice" ()

data DeviceOpts = DeviceOpts
    { DeviceOpts -> Maybe ByteString
phys :: Maybe ByteString
    , DeviceOpts -> Maybe ByteString
uniq :: Maybe ByteString
    , DeviceOpts -> Maybe Int
idProduct :: Maybe Int
    , DeviceOpts -> Maybe Int
idVendor :: Maybe Int
    , DeviceOpts -> Maybe Int
idBustype :: Maybe Int
    , DeviceOpts -> Maybe Int
idVersion :: Maybe Int
    , DeviceOpts -> [Key]
keys :: [Key]
    , DeviceOpts -> [RelativeAxis]
relAxes :: [RelativeAxis]
    , DeviceOpts -> [(AbsoluteAxis, AbsInfo)]
absAxes :: [(AbsoluteAxis, LL.AbsInfo)]
    , DeviceOpts -> [MiscEvent]
miscs :: [MiscEvent]
    , DeviceOpts -> [SwitchEvent]
switchs :: [SwitchEvent]
    , DeviceOpts -> [LEDEvent]
leds :: [LEDEvent]
    , DeviceOpts -> [SoundEvent]
sounds :: [SoundEvent]
    , DeviceOpts -> [(RepeatEvent, Int)]
reps :: [(RepeatEvent, Int)]
    , DeviceOpts -> [EventCode]
ffs :: [EventCode]
    , DeviceOpts -> [EventCode]
powers :: [EventCode]
    , DeviceOpts -> [EventCode]
ffStats :: [EventCode]
    }
defaultDeviceOpts :: DeviceOpts
defaultDeviceOpts :: DeviceOpts
defaultDeviceOpts =
    DeviceOpts
        { uniq :: Maybe ByteString
uniq = Maybe ByteString
forall a. Maybe a
Nothing
        , phys :: Maybe ByteString
phys = Maybe ByteString
forall a. Maybe a
Nothing
        , idProduct :: Maybe Int
idProduct = Maybe Int
forall a. Maybe a
Nothing
        , idVendor :: Maybe Int
idVendor = Maybe Int
forall a. Maybe a
Nothing
        , idBustype :: Maybe Int
idBustype = Maybe Int
forall a. Maybe a
Nothing
        , idVersion :: Maybe Int
idVersion = Maybe Int
forall a. Maybe a
Nothing
        , keys :: [Key]
keys = []
        , relAxes :: [RelativeAxis]
relAxes = []
        , absAxes :: [(AbsoluteAxis, AbsInfo)]
absAxes = []
        , miscs :: [MiscEvent]
miscs = []
        , switchs :: [SwitchEvent]
switchs = []
        , leds :: [LEDEvent]
leds = []
        , sounds :: [SoundEvent]
sounds = []
        , reps :: [(RepeatEvent, Int)]
reps = []
        , ffs :: [EventCode]
ffs = []
        , powers :: [EventCode]
powers = []
        , ffStats :: [EventCode]
ffStats = []
        }

-- | Write a single event. Doesn't issue a sync event, so: @writeEvent dev e /= writeBatch dev [e]@.
writeEvent :: Device -> EventData -> IO ()
writeEvent :: Device -> EventData -> IO ()
writeEvent (Device UDevice
dev) EventData
e = do
    String -> UDevice -> IO Errno -> IO (CErrCallRes Errno)
forall a info.
(CErrCall a, CErrInfo info) =>
String -> info -> IO a -> IO (CErrCallRes a)
forall info.
CErrInfo info =>
String -> info -> IO Errno -> IO (CErrCallRes Errno)
cErrCall String
"writeEvent" UDevice
dev (IO Errno -> IO (CErrCallRes Errno))
-> IO Errno -> IO (CErrCallRes Errno)
forall a b. (a -> b) -> a -> b
$ (Word16 -> Word16 -> Int32 -> IO Errno)
-> (Word16, Word16, Int32) -> IO Errno
forall a b c d. (a -> b -> c -> d) -> (a, b, c) -> d
uncurry3 (UDevice -> Word16 -> Word16 -> Int32 -> IO Errno
LL.writeEvent UDevice
dev) ((Word16, Word16, Int32) -> IO Errno)
-> (Word16, Word16, Int32) -> IO Errno
forall a b. (a -> b) -> a -> b
$ EventData -> (Word16, Word16, Int32)
toCEventData EventData
e

-- | Write several events followed by a 'SynReport'.
writeBatch :: Foldable t => Device -> t EventData -> IO ()
writeBatch :: forall (t :: * -> *). Foldable t => Device -> t EventData -> IO ()
writeBatch Device
dev t EventData
es = do
    t EventData -> (EventData -> IO ()) -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ t EventData
es ((EventData -> IO ()) -> IO ()) -> (EventData -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ Device -> EventData -> IO ()
writeEvent Device
dev
    Device -> EventData -> IO ()
writeEvent Device
dev (EventData -> IO ()) -> EventData -> IO ()
forall a b. (a -> b) -> a -> b
$ SyncEvent -> EventData
SyncEvent SyncEvent
SynReport

deviceSyspath :: Device -> IO (Maybe ByteString)
deviceSyspath :: Device -> IO (Maybe ByteString)
deviceSyspath = UDevice -> IO (Maybe ByteString)
LL.getSyspath (UDevice -> IO (Maybe ByteString))
-> (Device -> UDevice) -> Device -> IO (Maybe ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \(Device UDevice
d) -> UDevice
d
deviceDevnode :: Device -> IO (Maybe ByteString)
deviceDevnode :: Device -> IO (Maybe ByteString)
deviceDevnode = UDevice -> IO (Maybe ByteString)
LL.getDevnode (UDevice -> IO (Maybe ByteString))
-> (Device -> UDevice) -> Device -> IO (Maybe ByteString)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. \(Device UDevice
d) -> UDevice
d

-- | Make options for a device capable of precisely the events in the list.
deviceOptsFromEvents ::
    Maybe (AbsoluteAxis -> AbsInfo) ->
    Maybe (RepeatEvent -> Int) ->
    [EventData] ->
    DeviceOpts
--TODO use records or lenses to reduce boilerplate
deviceOptsFromEvents :: Maybe (AbsoluteAxis -> AbsInfo)
-> Maybe (RepeatEvent -> Int) -> [EventData] -> DeviceOpts
deviceOptsFromEvents Maybe (AbsoluteAxis -> AbsInfo)
absInfo Maybe (RepeatEvent -> Int)
rep =
    ( \([Key]
keys, [RelativeAxis]
relAxes, [(AbsoluteAxis, AbsInfo)]
absAxes, [MiscEvent]
miscs, [SwitchEvent]
switchs, [LEDEvent]
leds, [SoundEvent]
sounds, [(RepeatEvent, Int)]
reps, [EventCode]
ffs, [EventCode]
powers, [EventCode]
ffStats) ->
        let phys :: Maybe a
phys = Maybe a
forall a. Maybe a
Nothing
            uniq :: Maybe a
uniq = Maybe a
forall a. Maybe a
Nothing
            idProduct :: Maybe a
idProduct = Maybe a
forall a. Maybe a
Nothing
            idVendor :: Maybe a
idVendor = Maybe a
forall a. Maybe a
Nothing
            idBustype :: Maybe a
idBustype = Maybe a
forall a. Maybe a
Nothing
            idVersion :: Maybe a
idVersion = Maybe a
forall a. Maybe a
Nothing
         in DeviceOpts{[(RepeatEvent, Int)]
[(AbsoluteAxis, AbsInfo)]
[SoundEvent]
[LEDEvent]
[MiscEvent]
[SwitchEvent]
[RelativeAxis]
[Key]
[EventCode]
Maybe Int
Maybe ByteString
forall a. Maybe a
phys :: Maybe ByteString
uniq :: Maybe ByteString
idProduct :: Maybe Int
idVendor :: Maybe Int
idBustype :: Maybe Int
idVersion :: Maybe Int
keys :: [Key]
relAxes :: [RelativeAxis]
absAxes :: [(AbsoluteAxis, AbsInfo)]
miscs :: [MiscEvent]
switchs :: [SwitchEvent]
leds :: [LEDEvent]
sounds :: [SoundEvent]
reps :: [(RepeatEvent, Int)]
ffs :: [EventCode]
powers :: [EventCode]
ffStats :: [EventCode]
keys :: [Key]
relAxes :: [RelativeAxis]
absAxes :: [(AbsoluteAxis, AbsInfo)]
miscs :: [MiscEvent]
switchs :: [SwitchEvent]
leds :: [LEDEvent]
sounds :: [SoundEvent]
reps :: [(RepeatEvent, Int)]
ffs :: [EventCode]
powers :: [EventCode]
ffStats :: [EventCode]
phys :: forall a. Maybe a
uniq :: forall a. Maybe a
idProduct :: forall a. Maybe a
idVendor :: forall a. Maybe a
idBustype :: forall a. Maybe a
idVersion :: forall a. Maybe a
..}
    )
        (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> DeviceOpts)
-> ([EventData]
    -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
        [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
        [EventCode], [EventCode], [EventCode]))
-> [EventData]
-> DeviceOpts
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (State
   ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
    [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
    [EventCode], [EventCode], [EventCode])
   ()
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
    [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
    [EventCode], [EventCode], [EventCode])
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
-> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
    [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
    [EventCode], [EventCode], [EventCode])
forall a b c. (a -> b -> c) -> b -> a -> c
flip State
  ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
   [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
   [EventCode], [EventCode], [EventCode])
  ()
-> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
    [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
    [EventCode], [EventCode], [EventCode])
-> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
    [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
    [EventCode], [EventCode], [EventCode])
forall s a. State s a -> s -> s
execState ([Key]
forall a. Monoid a => a
mempty, [RelativeAxis]
forall a. Monoid a => a
mempty, [(AbsoluteAxis, AbsInfo)]
forall a. Monoid a => a
mempty, [MiscEvent]
forall a. Monoid a => a
mempty, [SwitchEvent]
forall a. Monoid a => a
mempty, [LEDEvent]
forall a. Monoid a => a
mempty, [SoundEvent]
forall a. Monoid a => a
mempty, [(RepeatEvent, Int)]
forall a. Monoid a => a
mempty, [EventCode]
forall a. Monoid a => a
mempty, [EventCode]
forall a. Monoid a => a
mempty, [EventCode]
forall a. Monoid a => a
mempty)
        (State
   ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
    [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
    [EventCode], [EventCode], [EventCode])
   ()
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> ([EventData]
    -> State
         ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
          [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
          [EventCode], [EventCode], [EventCode])
         ())
-> [EventData]
-> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
    [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
    [EventCode], [EventCode], [EventCode])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (EventData
 -> State
      ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
       [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
       [EventCode], [EventCode], [EventCode])
      ())
-> [EventData]
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
(a -> f b) -> t a -> f ()
traverse_ \case
            SyncEvent SyncEvent
_ -> ()
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall a.
a
-> StateT
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     Identity
     a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
            KeyEvent Key
e KeyEvent
_ -> (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10) ->
                (Key
e Key -> [Key] -> [Key]
forall a. a -> [a] -> [a]
: [Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10)
            RelativeEvent RelativeAxis
e EventValue
_ -> (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10) ->
                ([Key]
a0, RelativeAxis
e RelativeAxis -> [RelativeAxis] -> [RelativeAxis]
forall a. a -> [a] -> [a]
: [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10)
            AbsoluteEvent AbsoluteAxis
e EventValue
_ -> (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10) ->
                ([Key]
a0, [RelativeAxis]
a1, (AbsoluteAxis
e, AbsInfo
-> ((AbsoluteAxis -> AbsInfo) -> AbsInfo)
-> Maybe (AbsoluteAxis -> AbsInfo)
-> AbsInfo
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> AbsInfo
AbsInfo Int32
0 Int32
0 Int32
0 Int32
0 Int32
0 Int32
0) ((AbsoluteAxis -> AbsInfo) -> AbsoluteAxis -> AbsInfo
forall a b. (a -> b) -> a -> b
$ AbsoluteAxis
e) Maybe (AbsoluteAxis -> AbsInfo)
absInfo) (AbsoluteAxis, AbsInfo)
-> [(AbsoluteAxis, AbsInfo)] -> [(AbsoluteAxis, AbsInfo)]
forall a. a -> [a] -> [a]
: [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10)
            MiscEvent MiscEvent
e EventValue
_ -> (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10) ->
                ([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, MiscEvent
e MiscEvent -> [MiscEvent] -> [MiscEvent]
forall a. a -> [a] -> [a]
: [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10)
            SwitchEvent SwitchEvent
e EventValue
_ -> (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10) ->
                ([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, SwitchEvent
e SwitchEvent -> [SwitchEvent] -> [SwitchEvent]
forall a. a -> [a] -> [a]
: [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10)
            LEDEvent LEDEvent
e EventValue
_ -> (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10) ->
                ([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, LEDEvent
e LEDEvent -> [LEDEvent] -> [LEDEvent]
forall a. a -> [a] -> [a]
: [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10)
            SoundEvent SoundEvent
e EventValue
_ -> (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10) ->
                ([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, SoundEvent
e SoundEvent -> [SoundEvent] -> [SoundEvent]
forall a. a -> [a] -> [a]
: [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10)
            RepeatEvent RepeatEvent
e EventValue
_ -> (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10) ->
                ([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, (RepeatEvent
e, Int
-> ((RepeatEvent -> Int) -> Int)
-> Maybe (RepeatEvent -> Int)
-> Int
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Int
0 ((RepeatEvent -> Int) -> RepeatEvent -> Int
forall a b. (a -> b) -> a -> b
$ RepeatEvent
e) Maybe (RepeatEvent -> Int)
rep) (RepeatEvent, Int) -> [(RepeatEvent, Int)] -> [(RepeatEvent, Int)]
forall a. a -> [a] -> [a]
: [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10)
            ForceFeedbackEvent EventCode
e EventValue
_ -> (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10) ->
                ([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, EventCode
e EventCode -> [EventCode] -> [EventCode]
forall a. a -> [a] -> [a]
: [EventCode]
a8, [EventCode]
a9, [EventCode]
a10)
            PowerEvent EventCode
e EventValue
_ -> (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10) ->
                ([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, EventCode
e EventCode -> [EventCode] -> [EventCode]
forall a. a -> [a] -> [a]
: [EventCode]
a9, [EventCode]
a10)
            ForceFeedbackStatusEvent EventCode
e EventValue
_ -> (([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
  [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
  [EventCode], [EventCode], [EventCode])
 -> ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
     [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
     [EventCode], [EventCode], [EventCode]))
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify \([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, [EventCode]
a10) ->
                ([Key]
a0, [RelativeAxis]
a1, [(AbsoluteAxis, AbsInfo)]
a2, [MiscEvent]
a3, [SwitchEvent]
a4, [LEDEvent]
a5, [SoundEvent]
a6, [(RepeatEvent, Int)]
a7, [EventCode]
a8, [EventCode]
a9, EventCode
e EventCode -> [EventCode] -> [EventCode]
forall a. a -> [a] -> [a]
: [EventCode]
a10)
            UnknownEvent{} -> ()
-> State
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     ()
forall a.
a
-> StateT
     ([Key], [RelativeAxis], [(AbsoluteAxis, AbsInfo)], [MiscEvent],
      [SwitchEvent], [LEDEvent], [SoundEvent], [(RepeatEvent, Int)],
      [EventCode], [EventCode], [EventCode])
     Identity
     a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()