module Graphics.XHB.Gen.Input.Types
       (deserializeError, deserializeEvent, KeyCode, EventClass,
        ValuatorMode(..), PropagateMode(..), GetExtensionVersion(..),
        GetExtensionVersionReply(..), DeviceInfo(..), ListInputDevices(..),
        ListInputDevicesReply(..), DeviceUse(..), InputInfo(..),
        KeyInfo(..), ButtonInfo(..), AxisInfo(..), ValuatorInfo(..),
        InputClassInfo(..), OpenDevice(..), OpenDeviceReply(..),
        InputClass(..), CloseDevice(..), SetDeviceMode(..),
        SetDeviceModeReply(..), SelectExtensionEvent(..),
        GetSelectedExtensionEvents(..),
        GetSelectedExtensionEventsReply(..),
        ChangeDeviceDontPropagateList(..), GetDeviceDontPropagateList(..),
        GetDeviceDontPropagateListReply(..), GetDeviceMotionEvents(..),
        GetDeviceMotionEventsReply(..), DeviceTimeCoord(..),
        ChangeKeyboardDevice(..), ChangeKeyboardDeviceReply(..),
        ChangePointerDevice(..), ChangePointerDeviceReply(..),
        GrabDevice(..), GrabDeviceReply(..), UngrabDevice(..),
        GrabDeviceKey(..), UngrabDeviceKey(..), GrabDeviceButton(..),
        UngrabDeviceButton(..), AllowDeviceEvents(..), GetDeviceFocus(..),
        GetDeviceFocusReply(..), SetDeviceFocus(..),
        GetFeedbackControl(..), GetFeedbackControlReply(..),
        FeedbackState(..), KbdFeedbackState(..), PtrFeedbackState(..),
        IntegerFeedbackState(..), StringFeedbackState(..),
        BellFeedbackState(..), LedFeedbackState(..), FeedbackCtl(..),
        KbdFeedbackCtl(..), PtrFeedbackCtl(..), IntegerFeedbackCtl(..),
        StringFeedbackCtl(..), BellFeedbackCtl(..), LedFeedbackCtl(..),
        GetDeviceKeyMapping(..), GetDeviceKeyMappingReply(..),
        ChangeDeviceKeyMapping(..), GetDeviceModifierMapping(..),
        GetDeviceModifierMappingReply(..), SetDeviceModifierMapping(..),
        SetDeviceModifierMappingReply(..), GetDeviceButtonMapping(..),
        GetDeviceButtonMappingReply(..), SetDeviceButtonMapping(..),
        SetDeviceButtonMappingReply(..), QueryDeviceState(..),
        QueryDeviceStateReply(..), InputState(..), KeyState(..),
        ButtonState(..), ValuatorState(..), SendExtensionEvent(..),
        DeviceBell(..), SetDeviceValuators(..),
        SetDeviceValuatorsReply(..), GetDeviceControl(..),
        GetDeviceControlReply(..), DeviceState(..),
        DeviceResolutionState(..), DeviceAbsCalibState(..),
        DeviceAbsAreaState(..), DeviceCoreState(..), DeviceEnableState(..),
        DeviceCtl(..), DeviceResolutionCtl(..), DeviceAbsCalibCtl(..),
        DeviceAbsAreaCtrl(..), DeviceCoreCtrl(..), DeviceEnableCtrl(..),
        DeviceValuator(..), DeviceKeyPress(..), DeviceKeyRelease(..),
        DeviceButtonPress(..), DeviceButtonRelease(..),
        DeviceMotionNotify(..), ProximityIn(..), ProximityOut(..),
        FocusIn(..), FocusOut(..), DeviceStateNotify(..),
        DeviceMappingNotify(..), ChangeDeviceNotify(..),
        DeviceKeyStateNotify(..), DeviceButtonStateNotify(..),
        DevicePresenceNotify(..))
       where
import Data.Word
import Data.Int
import Foreign.C.Types
import Data.Bits
import Data.Binary.Put
import Data.Binary.Get
import Data.Typeable
import Control.Monad
import Control.Exception
import Data.List
import Graphics.XHB.Shared hiding (Event, Error)
import qualified Graphics.XHB.Shared
import Graphics.XHB.Gen.Xproto.Types
       hiding (FocusIn(..), FocusOut(..), deserializeError,
               deserializeEvent)
import qualified Graphics.XHB.Gen.Xproto.Types
 
deserializeError :: Word8 -> Maybe (Get SomeError)
deserializeError _ = Nothing
 
deserializeEvent :: Word8 -> Maybe (Get SomeEvent)
deserializeEvent 0
  = return (liftM toEvent (deserialize :: Get DeviceValuator))
deserializeEvent 1
  = return (liftM toEvent (deserialize :: Get DeviceKeyPress))
deserializeEvent 2
  = return (liftM toEvent (deserialize :: Get DeviceKeyRelease))
deserializeEvent 3
  = return (liftM toEvent (deserialize :: Get DeviceButtonPress))
deserializeEvent 4
  = return (liftM toEvent (deserialize :: Get DeviceButtonRelease))
deserializeEvent 5
  = return (liftM toEvent (deserialize :: Get DeviceMotionNotify))
deserializeEvent 8
  = return (liftM toEvent (deserialize :: Get ProximityIn))
deserializeEvent 9
  = return (liftM toEvent (deserialize :: Get ProximityOut))
deserializeEvent 6
  = return (liftM toEvent (deserialize :: Get FocusIn))
deserializeEvent 7
  = return (liftM toEvent (deserialize :: Get FocusOut))
deserializeEvent 10
  = return (liftM toEvent (deserialize :: Get DeviceStateNotify))
deserializeEvent 11
  = return (liftM toEvent (deserialize :: Get DeviceMappingNotify))
deserializeEvent 12
  = return (liftM toEvent (deserialize :: Get ChangeDeviceNotify))
deserializeEvent 13
  = return (liftM toEvent (deserialize :: Get DeviceKeyStateNotify))
deserializeEvent 14
  = return
      (liftM toEvent (deserialize :: Get DeviceButtonStateNotify))
deserializeEvent 15
  = return (liftM toEvent (deserialize :: Get DevicePresenceNotify))
deserializeEvent _ = Nothing
 
type KeyCode = Word8
 
type EventClass = Word32
 
data ValuatorMode = ValuatorModeRelative
                  | ValuatorModeAbsolute
 
instance SimpleEnum ValuatorMode where
        toValue ValuatorModeRelative{} = 0
        toValue ValuatorModeAbsolute{} = 1
        fromValue 0 = ValuatorModeRelative
        fromValue 1 = ValuatorModeAbsolute
 
data PropagateMode = PropagateModeAddToList
                   | PropagateModeDeleteFromList
 
instance SimpleEnum PropagateMode where
        toValue PropagateModeAddToList{} = 0
        toValue PropagateModeDeleteFromList{} = 1
        fromValue 0 = PropagateModeAddToList
        fromValue 1 = PropagateModeDeleteFromList
 
data GetExtensionVersion = MkGetExtensionVersion{name_len_GetExtensionVersion
                                                 :: Word16,
                                                 name_GetExtensionVersion :: [CChar]}
                         deriving (Show, Typeable)
 
instance ExtensionRequest GetExtensionVersion where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 1
               let size__
                     = 4 + size (name_len_GetExtensionVersion x) + 2 +
                         sum (map size (name_GetExtensionVersion x))
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (name_len_GetExtensionVersion x)
               putSkip 2
               serializeList (name_GetExtensionVersion x)
               putSkip (requiredPadding size__)
 
data GetExtensionVersionReply = MkGetExtensionVersionReply{server_major_GetExtensionVersionReply
                                                           :: Word16,
                                                           server_minor_GetExtensionVersionReply ::
                                                           Word16,
                                                           present_GetExtensionVersionReply ::
                                                           Word8}
                              deriving (Show, Typeable)
 
instance Deserialize GetExtensionVersionReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               server_major <- deserialize
               server_minor <- deserialize
               present <- deserialize
               skip 19
               let _ = isCard32 length
               return
                 (MkGetExtensionVersionReply server_major server_minor present)
 
data DeviceInfo = MkDeviceInfo{device_type_DeviceInfo :: ATOM,
                               device_id_DeviceInfo :: Word8, num_class_info_DeviceInfo :: Word8,
                               device_use_DeviceInfo :: Word8}
                deriving (Show, Typeable)
 
instance Serialize DeviceInfo where
        serialize x
          = do serialize (device_type_DeviceInfo x)
               serialize (device_id_DeviceInfo x)
               serialize (num_class_info_DeviceInfo x)
               serialize (device_use_DeviceInfo x)
               putSkip 1
        size x
          = size (device_type_DeviceInfo x) + size (device_id_DeviceInfo x) +
              size (num_class_info_DeviceInfo x)
              + size (device_use_DeviceInfo x)
              + 1
 
instance Deserialize DeviceInfo where
        deserialize
          = do device_type <- deserialize
               device_id <- deserialize
               num_class_info <- deserialize
               device_use <- deserialize
               skip 1
               return
                 (MkDeviceInfo device_type device_id num_class_info device_use)
 
data ListInputDevices = MkListInputDevices{}
                      deriving (Show, Typeable)
 
instance ExtensionRequest ListInputDevices where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 2
               let size__ = 4
               serialize (convertBytesToRequestSize size__ :: Int16)
               putSkip (requiredPadding size__)
 
data ListInputDevicesReply = MkListInputDevicesReply{devices_len_ListInputDevicesReply
                                                     :: Word8,
                                                     devices_ListInputDevicesReply :: [DeviceInfo]}
                           deriving (Show, Typeable)
 
instance Deserialize ListInputDevicesReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               devices_len <- deserialize
               skip 23
               devices <- deserializeList (fromIntegral devices_len)
               let _ = isCard32 length
               return (MkListInputDevicesReply devices_len devices)
 
data DeviceUse = DeviceUseIsXPointer
               | DeviceUseIsXKeyboard
               | DeviceUseIsXExtensionDevice
               | DeviceUseIsXExtensionKeyboard
               | DeviceUseIsXExtensionPointer
 
instance SimpleEnum DeviceUse where
        toValue DeviceUseIsXPointer{} = 0
        toValue DeviceUseIsXKeyboard{} = 1
        toValue DeviceUseIsXExtensionDevice{} = 2
        toValue DeviceUseIsXExtensionKeyboard{} = 3
        toValue DeviceUseIsXExtensionPointer{} = 4
        fromValue 0 = DeviceUseIsXPointer
        fromValue 1 = DeviceUseIsXKeyboard
        fromValue 2 = DeviceUseIsXExtensionDevice
        fromValue 3 = DeviceUseIsXExtensionKeyboard
        fromValue 4 = DeviceUseIsXExtensionPointer
 
data InputInfo = MkInputInfo{class_id_InputInfo :: Word8,
                             len_InputInfo :: Word8}
               deriving (Show, Typeable)
 
instance Serialize InputInfo where
        serialize x
          = do serialize (class_id_InputInfo x)
               serialize (len_InputInfo x)
        size x = size (class_id_InputInfo x) + size (len_InputInfo x)
 
instance Deserialize InputInfo where
        deserialize
          = do class_id <- deserialize
               len <- deserialize
               return (MkInputInfo class_id len)
 
data KeyInfo = MkKeyInfo{class_id_KeyInfo :: Word8,
                         len_KeyInfo :: Word8, min_keycode_KeyInfo :: KeyCode,
                         max_keycode_KeyInfo :: KeyCode, num_keys_KeyInfo :: Word16}
             deriving (Show, Typeable)
 
instance Serialize KeyInfo where
        serialize x
          = do serialize (class_id_KeyInfo x)
               serialize (len_KeyInfo x)
               serialize (min_keycode_KeyInfo x)
               serialize (max_keycode_KeyInfo x)
               serialize (num_keys_KeyInfo x)
               putSkip 2
        size x
          = size (class_id_KeyInfo x) + size (len_KeyInfo x) +
              size (min_keycode_KeyInfo x)
              + size (max_keycode_KeyInfo x)
              + size (num_keys_KeyInfo x)
              + 2
 
instance Deserialize KeyInfo where
        deserialize
          = do class_id <- deserialize
               len <- deserialize
               min_keycode <- deserialize
               max_keycode <- deserialize
               num_keys <- deserialize
               skip 2
               return (MkKeyInfo class_id len min_keycode max_keycode num_keys)
 
data ButtonInfo = MkButtonInfo{class_id_ButtonInfo :: Word8,
                               len_ButtonInfo :: Word8, num_buttons_ButtonInfo :: Word16}
                deriving (Show, Typeable)
 
instance Serialize ButtonInfo where
        serialize x
          = do serialize (class_id_ButtonInfo x)
               serialize (len_ButtonInfo x)
               serialize (num_buttons_ButtonInfo x)
        size x
          = size (class_id_ButtonInfo x) + size (len_ButtonInfo x) +
              size (num_buttons_ButtonInfo x)
 
instance Deserialize ButtonInfo where
        deserialize
          = do class_id <- deserialize
               len <- deserialize
               num_buttons <- deserialize
               return (MkButtonInfo class_id len num_buttons)
 
data AxisInfo = MkAxisInfo{resolution_AxisInfo :: Word32,
                           minimum_AxisInfo :: Word32, maximum_AxisInfo :: Word32}
              deriving (Show, Typeable)
 
instance Serialize AxisInfo where
        serialize x
          = do serialize (resolution_AxisInfo x)
               serialize (minimum_AxisInfo x)
               serialize (maximum_AxisInfo x)
        size x
          = size (resolution_AxisInfo x) + size (minimum_AxisInfo x) +
              size (maximum_AxisInfo x)
 
instance Deserialize AxisInfo where
        deserialize
          = do resolution <- deserialize
               minimum <- deserialize
               maximum <- deserialize
               return (MkAxisInfo resolution minimum maximum)
 
data ValuatorInfo = MkValuatorInfo{class_id_ValuatorInfo :: Word8,
                                   len_ValuatorInfo :: Word8, axes_len_ValuatorInfo :: Word8,
                                   mode_ValuatorInfo :: Word8, motion_size_ValuatorInfo :: Word32,
                                   axes_ValuatorInfo :: [AxisInfo]}
                  deriving (Show, Typeable)
 
instance Serialize ValuatorInfo where
        serialize x
          = do serialize (class_id_ValuatorInfo x)
               serialize (len_ValuatorInfo x)
               serialize (axes_len_ValuatorInfo x)
               serialize (mode_ValuatorInfo x)
               serialize (motion_size_ValuatorInfo x)
               serializeList (axes_ValuatorInfo x)
        size x
          = size (class_id_ValuatorInfo x) + size (len_ValuatorInfo x) +
              size (axes_len_ValuatorInfo x)
              + size (mode_ValuatorInfo x)
              + size (motion_size_ValuatorInfo x)
              + sum (map size (axes_ValuatorInfo x))
 
instance Deserialize ValuatorInfo where
        deserialize
          = do class_id <- deserialize
               len <- deserialize
               axes_len <- deserialize
               mode <- deserialize
               motion_size <- deserialize
               axes <- deserializeList (fromIntegral axes_len)
               return (MkValuatorInfo class_id len axes_len mode motion_size axes)
 
data InputClassInfo = MkInputClassInfo{class_id_InputClassInfo ::
                                       Word8,
                                       event_type_base_InputClassInfo :: Word8}
                    deriving (Show, Typeable)
 
instance Serialize InputClassInfo where
        serialize x
          = do serialize (class_id_InputClassInfo x)
               serialize (event_type_base_InputClassInfo x)
        size x
          = size (class_id_InputClassInfo x) +
              size (event_type_base_InputClassInfo x)
 
instance Deserialize InputClassInfo where
        deserialize
          = do class_id <- deserialize
               event_type_base <- deserialize
               return (MkInputClassInfo class_id event_type_base)
 
data OpenDevice = MkOpenDevice{device_id_OpenDevice :: Word8}
                deriving (Show, Typeable)
 
instance ExtensionRequest OpenDevice where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 3
               let size__ = 4 + size (device_id_OpenDevice x) + 3
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_OpenDevice x)
               putSkip 3
               putSkip (requiredPadding size__)
 
data OpenDeviceReply = MkOpenDeviceReply{num_classes_OpenDeviceReply
                                         :: Word8,
                                         class_info_OpenDeviceReply :: [InputClassInfo]}
                     deriving (Show, Typeable)
 
instance Deserialize OpenDeviceReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               num_classes <- deserialize
               skip 23
               class_info <- deserializeList (fromIntegral num_classes)
               let _ = isCard32 length
               return (MkOpenDeviceReply num_classes class_info)
 
data InputClass = InputClassKey
                | InputClassButton
                | InputClassValuator
                | InputClassFeedback
                | InputClassProximity
                | InputClassFocus
                | InputClassOther
 
instance SimpleEnum InputClass where
        toValue InputClassKey{} = 0
        toValue InputClassButton{} = 1
        toValue InputClassValuator{} = 2
        toValue InputClassFeedback{} = 3
        toValue InputClassProximity{} = 4
        toValue InputClassFocus{} = 5
        toValue InputClassOther{} = 6
        fromValue 0 = InputClassKey
        fromValue 1 = InputClassButton
        fromValue 2 = InputClassValuator
        fromValue 3 = InputClassFeedback
        fromValue 4 = InputClassProximity
        fromValue 5 = InputClassFocus
        fromValue 6 = InputClassOther
 
data CloseDevice = MkCloseDevice{device_id_CloseDevice :: Word8}
                 deriving (Show, Typeable)
 
instance ExtensionRequest CloseDevice where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 4
               let size__ = 4 + size (device_id_CloseDevice x) + 3
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_CloseDevice x)
               putSkip 3
               putSkip (requiredPadding size__)
 
data SetDeviceMode = MkSetDeviceMode{device_id_SetDeviceMode ::
                                     Word8,
                                     mode_SetDeviceMode :: Word8}
                   deriving (Show, Typeable)
 
instance ExtensionRequest SetDeviceMode where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 5
               let size__
                     = 4 + size (device_id_SetDeviceMode x) +
                         size (mode_SetDeviceMode x)
                         + 2
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_SetDeviceMode x)
               serialize (mode_SetDeviceMode x)
               putSkip 2
               putSkip (requiredPadding size__)
 
data SetDeviceModeReply = MkSetDeviceModeReply{status_SetDeviceModeReply
                                               :: Word8}
                        deriving (Show, Typeable)
 
instance Deserialize SetDeviceModeReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               status <- deserialize
               skip 23
               let _ = isCard32 length
               return (MkSetDeviceModeReply status)
 
data SelectExtensionEvent = MkSelectExtensionEvent{window_SelectExtensionEvent
                                                   :: WINDOW,
                                                   num_classes_SelectExtensionEvent :: Word16,
                                                   classes_SelectExtensionEvent :: [EventClass]}
                          deriving (Show, Typeable)
 
instance ExtensionRequest SelectExtensionEvent where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 6
               let size__
                     = 4 + size (window_SelectExtensionEvent x) +
                         size (num_classes_SelectExtensionEvent x)
                         + 2
                         + sum (map size (classes_SelectExtensionEvent x))
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (window_SelectExtensionEvent x)
               serialize (num_classes_SelectExtensionEvent x)
               putSkip 2
               serializeList (classes_SelectExtensionEvent x)
               putSkip (requiredPadding size__)
 
data GetSelectedExtensionEvents = MkGetSelectedExtensionEvents{window_GetSelectedExtensionEvents
                                                               :: WINDOW}
                                deriving (Show, Typeable)
 
instance ExtensionRequest GetSelectedExtensionEvents where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 7
               let size__ = 4 + size (window_GetSelectedExtensionEvents x)
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (window_GetSelectedExtensionEvents x)
               putSkip (requiredPadding size__)
 
data GetSelectedExtensionEventsReply = MkGetSelectedExtensionEventsReply{num_this_classes_GetSelectedExtensionEventsReply
                                                                         :: Word16,
                                                                         num_all_classes_GetSelectedExtensionEventsReply
                                                                         :: Word16,
                                                                         this_classes_GetSelectedExtensionEventsReply
                                                                         :: [EventClass],
                                                                         all_classes_GetSelectedExtensionEventsReply
                                                                         :: [EventClass]}
                                     deriving (Show, Typeable)
 
instance Deserialize GetSelectedExtensionEventsReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               num_this_classes <- deserialize
               num_all_classes <- deserialize
               skip 20
               this_classes <- deserializeList (fromIntegral num_this_classes)
               all_classes <- deserializeList (fromIntegral num_all_classes)
               let _ = isCard32 length
               return
                 (MkGetSelectedExtensionEventsReply num_this_classes num_all_classes
                    this_classes
                    all_classes)
 
data ChangeDeviceDontPropagateList = MkChangeDeviceDontPropagateList{window_ChangeDeviceDontPropagateList
                                                                     :: WINDOW,
                                                                     num_classes_ChangeDeviceDontPropagateList
                                                                     :: Word16,
                                                                     mode_ChangeDeviceDontPropagateList
                                                                     :: Word8,
                                                                     classes_ChangeDeviceDontPropagateList
                                                                     :: [EventClass]}
                                   deriving (Show, Typeable)
 
instance ExtensionRequest ChangeDeviceDontPropagateList where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 8
               let size__
                     = 4 + size (window_ChangeDeviceDontPropagateList x) +
                         size (num_classes_ChangeDeviceDontPropagateList x)
                         + size (mode_ChangeDeviceDontPropagateList x)
                         + 1
                         + sum (map size (classes_ChangeDeviceDontPropagateList x))
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (window_ChangeDeviceDontPropagateList x)
               serialize (num_classes_ChangeDeviceDontPropagateList x)
               serialize (mode_ChangeDeviceDontPropagateList x)
               putSkip 1
               serializeList (classes_ChangeDeviceDontPropagateList x)
               putSkip (requiredPadding size__)
 
data GetDeviceDontPropagateList = MkGetDeviceDontPropagateList{window_GetDeviceDontPropagateList
                                                               :: WINDOW}
                                deriving (Show, Typeable)
 
instance ExtensionRequest GetDeviceDontPropagateList where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 9
               let size__ = 4 + size (window_GetDeviceDontPropagateList x)
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (window_GetDeviceDontPropagateList x)
               putSkip (requiredPadding size__)
 
data GetDeviceDontPropagateListReply = MkGetDeviceDontPropagateListReply{num_classes_GetDeviceDontPropagateListReply
                                                                         :: Word16,
                                                                         classes_GetDeviceDontPropagateListReply
                                                                         :: [EventClass]}
                                     deriving (Show, Typeable)
 
instance Deserialize GetDeviceDontPropagateListReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               num_classes <- deserialize
               skip 22
               classes <- deserializeList (fromIntegral num_classes)
               let _ = isCard32 length
               return (MkGetDeviceDontPropagateListReply num_classes classes)
 
data GetDeviceMotionEvents = MkGetDeviceMotionEvents{start_GetDeviceMotionEvents
                                                     :: TIMESTAMP,
                                                     stop_GetDeviceMotionEvents :: TIMESTAMP,
                                                     device_id_GetDeviceMotionEvents :: Word8}
                           deriving (Show, Typeable)
 
instance ExtensionRequest GetDeviceMotionEvents where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 10
               let size__
                     = 4 + size (start_GetDeviceMotionEvents x) +
                         size (stop_GetDeviceMotionEvents x)
                         + size (device_id_GetDeviceMotionEvents x)
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (start_GetDeviceMotionEvents x)
               serialize (stop_GetDeviceMotionEvents x)
               serialize (device_id_GetDeviceMotionEvents x)
               putSkip (requiredPadding size__)
 
data GetDeviceMotionEventsReply = MkGetDeviceMotionEventsReply{num_coords_GetDeviceMotionEventsReply
                                                               :: Word32,
                                                               num_axes_GetDeviceMotionEventsReply
                                                               :: Word8,
                                                               device_mode_GetDeviceMotionEventsReply
                                                               :: Word8}
                                deriving (Show, Typeable)
 
instance Deserialize GetDeviceMotionEventsReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               num_coords <- deserialize
               num_axes <- deserialize
               device_mode <- deserialize
               skip 18
               let _ = isCard32 length
               return
                 (MkGetDeviceMotionEventsReply num_coords num_axes device_mode)
 
data DeviceTimeCoord = MkDeviceTimeCoord{time_DeviceTimeCoord ::
                                         TIMESTAMP}
                     deriving (Show, Typeable)
 
instance Serialize DeviceTimeCoord where
        serialize x = do serialize (time_DeviceTimeCoord x)
        size x = size (time_DeviceTimeCoord x)
 
instance Deserialize DeviceTimeCoord where
        deserialize
          = do time <- deserialize
               return (MkDeviceTimeCoord time)
 
data ChangeKeyboardDevice = MkChangeKeyboardDevice{device_id_ChangeKeyboardDevice
                                                   :: Word8}
                          deriving (Show, Typeable)
 
instance ExtensionRequest ChangeKeyboardDevice where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 11
               let size__ = 4 + size (device_id_ChangeKeyboardDevice x) + 3
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_ChangeKeyboardDevice x)
               putSkip 3
               putSkip (requiredPadding size__)
 
data ChangeKeyboardDeviceReply = MkChangeKeyboardDeviceReply{status_ChangeKeyboardDeviceReply
                                                             :: Word8}
                               deriving (Show, Typeable)
 
instance Deserialize ChangeKeyboardDeviceReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               status <- deserialize
               skip 23
               let _ = isCard32 length
               return (MkChangeKeyboardDeviceReply status)
 
data ChangePointerDevice = MkChangePointerDevice{x_axis_ChangePointerDevice
                                                 :: Word8,
                                                 y_axis_ChangePointerDevice :: Word8,
                                                 device_id_ChangePointerDevice :: Word8}
                         deriving (Show, Typeable)
 
instance ExtensionRequest ChangePointerDevice where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 12
               let size__
                     = 4 + size (x_axis_ChangePointerDevice x) +
                         size (y_axis_ChangePointerDevice x)
                         + size (device_id_ChangePointerDevice x)
                         + 1
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (x_axis_ChangePointerDevice x)
               serialize (y_axis_ChangePointerDevice x)
               serialize (device_id_ChangePointerDevice x)
               putSkip 1
               putSkip (requiredPadding size__)
 
data ChangePointerDeviceReply = MkChangePointerDeviceReply{status_ChangePointerDeviceReply
                                                           :: Word8}
                              deriving (Show, Typeable)
 
instance Deserialize ChangePointerDeviceReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               status <- deserialize
               skip 23
               let _ = isCard32 length
               return (MkChangePointerDeviceReply status)
 
data GrabDevice = MkGrabDevice{grab_window_GrabDevice :: WINDOW,
                               time_GrabDevice :: TIMESTAMP, num_classes_GrabDevice :: Word16,
                               this_device_mode_GrabDevice :: Word8,
                               other_device_mode_GrabDevice :: Word8,
                               owner_events_GrabDevice :: Bool, device_id_GrabDevice :: Word8,
                               classes_GrabDevice :: [EventClass]}
                deriving (Show, Typeable)
 
instance ExtensionRequest GrabDevice where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 13
               let size__
                     = 4 + size (grab_window_GrabDevice x) + size (time_GrabDevice x) +
                         size (num_classes_GrabDevice x)
                         + size (this_device_mode_GrabDevice x)
                         + size (other_device_mode_GrabDevice x)
                         + size (owner_events_GrabDevice x)
                         + size (device_id_GrabDevice x)
                         + 2
                         + sum (map size (classes_GrabDevice x))
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (grab_window_GrabDevice x)
               serialize (time_GrabDevice x)
               serialize (num_classes_GrabDevice x)
               serialize (this_device_mode_GrabDevice x)
               serialize (other_device_mode_GrabDevice x)
               serialize (owner_events_GrabDevice x)
               serialize (device_id_GrabDevice x)
               putSkip 2
               serializeList (classes_GrabDevice x)
               putSkip (requiredPadding size__)
 
data GrabDeviceReply = MkGrabDeviceReply{status_GrabDeviceReply ::
                                         Word8}
                     deriving (Show, Typeable)
 
instance Deserialize GrabDeviceReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               status <- deserialize
               skip 23
               let _ = isCard32 length
               return (MkGrabDeviceReply status)
 
data UngrabDevice = MkUngrabDevice{time_UngrabDevice :: TIMESTAMP,
                                   device_id_UngrabDevice :: Word8}
                  deriving (Show, Typeable)
 
instance ExtensionRequest UngrabDevice where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 14
               let size__
                     = 4 + size (time_UngrabDevice x) + size (device_id_UngrabDevice x)
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (time_UngrabDevice x)
               serialize (device_id_UngrabDevice x)
               putSkip (requiredPadding size__)
 
data GrabDeviceKey = MkGrabDeviceKey{grab_window_GrabDeviceKey ::
                                     WINDOW,
                                     num_classes_GrabDeviceKey :: Word16,
                                     modifiers_GrabDeviceKey :: Word16,
                                     modifier_device_GrabDeviceKey :: Word8,
                                     grabbed_device_GrabDeviceKey :: Word8,
                                     key_GrabDeviceKey :: Word8,
                                     this_device_mode_GrabDeviceKey :: Word8,
                                     other_device_mode_GrabDeviceKey :: Word8,
                                     owner_events_GrabDeviceKey :: Bool,
                                     classes_GrabDeviceKey :: [EventClass]}
                   deriving (Show, Typeable)
 
instance ExtensionRequest GrabDeviceKey where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 15
               let size__
                     = 4 + size (grab_window_GrabDeviceKey x) +
                         size (num_classes_GrabDeviceKey x)
                         + size (modifiers_GrabDeviceKey x)
                         + size (modifier_device_GrabDeviceKey x)
                         + size (grabbed_device_GrabDeviceKey x)
                         + size (key_GrabDeviceKey x)
                         + size (this_device_mode_GrabDeviceKey x)
                         + size (other_device_mode_GrabDeviceKey x)
                         + size (owner_events_GrabDeviceKey x)
                         + 2
                         + sum (map size (classes_GrabDeviceKey x))
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (grab_window_GrabDeviceKey x)
               serialize (num_classes_GrabDeviceKey x)
               serialize (modifiers_GrabDeviceKey x)
               serialize (modifier_device_GrabDeviceKey x)
               serialize (grabbed_device_GrabDeviceKey x)
               serialize (key_GrabDeviceKey x)
               serialize (this_device_mode_GrabDeviceKey x)
               serialize (other_device_mode_GrabDeviceKey x)
               serialize (owner_events_GrabDeviceKey x)
               putSkip 2
               serializeList (classes_GrabDeviceKey x)
               putSkip (requiredPadding size__)
 
data UngrabDeviceKey = MkUngrabDeviceKey{grabWindow_UngrabDeviceKey
                                         :: WINDOW,
                                         modifiers_UngrabDeviceKey :: Word16,
                                         modifier_device_UngrabDeviceKey :: Word8,
                                         key_UngrabDeviceKey :: Word8,
                                         grabbed_device_UngrabDeviceKey :: Word8}
                     deriving (Show, Typeable)
 
instance ExtensionRequest UngrabDeviceKey where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 16
               let size__
                     = 4 + size (grabWindow_UngrabDeviceKey x) +
                         size (modifiers_UngrabDeviceKey x)
                         + size (modifier_device_UngrabDeviceKey x)
                         + size (key_UngrabDeviceKey x)
                         + size (grabbed_device_UngrabDeviceKey x)
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (grabWindow_UngrabDeviceKey x)
               serialize (modifiers_UngrabDeviceKey x)
               serialize (modifier_device_UngrabDeviceKey x)
               serialize (key_UngrabDeviceKey x)
               serialize (grabbed_device_UngrabDeviceKey x)
               putSkip (requiredPadding size__)
 
data GrabDeviceButton = MkGrabDeviceButton{grab_window_GrabDeviceButton
                                           :: WINDOW,
                                           grabbed_device_GrabDeviceButton :: Word8,
                                           modifier_device_GrabDeviceButton :: Word8,
                                           num_classes_GrabDeviceButton :: Word16,
                                           modifiers_GrabDeviceButton :: Word16,
                                           this_device_mode_GrabDeviceButton :: Word8,
                                           other_device_mode_GrabDeviceButton :: Word8,
                                           button_GrabDeviceButton :: Word8,
                                           owner_events_GrabDeviceButton :: Word8,
                                           classes_GrabDeviceButton :: [EventClass]}
                      deriving (Show, Typeable)
 
instance ExtensionRequest GrabDeviceButton where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 17
               let size__
                     = 4 + size (grab_window_GrabDeviceButton x) +
                         size (grabbed_device_GrabDeviceButton x)
                         + size (modifier_device_GrabDeviceButton x)
                         + size (num_classes_GrabDeviceButton x)
                         + size (modifiers_GrabDeviceButton x)
                         + size (this_device_mode_GrabDeviceButton x)
                         + size (other_device_mode_GrabDeviceButton x)
                         + size (button_GrabDeviceButton x)
                         + size (owner_events_GrabDeviceButton x)
                         + 2
                         + sum (map size (classes_GrabDeviceButton x))
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (grab_window_GrabDeviceButton x)
               serialize (grabbed_device_GrabDeviceButton x)
               serialize (modifier_device_GrabDeviceButton x)
               serialize (num_classes_GrabDeviceButton x)
               serialize (modifiers_GrabDeviceButton x)
               serialize (this_device_mode_GrabDeviceButton x)
               serialize (other_device_mode_GrabDeviceButton x)
               serialize (button_GrabDeviceButton x)
               serialize (owner_events_GrabDeviceButton x)
               putSkip 2
               serializeList (classes_GrabDeviceButton x)
               putSkip (requiredPadding size__)
 
data UngrabDeviceButton = MkUngrabDeviceButton{grab_window_UngrabDeviceButton
                                               :: WINDOW,
                                               modifiers_UngrabDeviceButton :: Word16,
                                               modifier_device_UngrabDeviceButton :: Word8,
                                               button_UngrabDeviceButton :: Word8,
                                               grabbed_device_UngrabDeviceButton :: Word8}
                        deriving (Show, Typeable)
 
instance ExtensionRequest UngrabDeviceButton where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 18
               let size__
                     = 4 + size (grab_window_UngrabDeviceButton x) +
                         size (modifiers_UngrabDeviceButton x)
                         + size (modifier_device_UngrabDeviceButton x)
                         + size (button_UngrabDeviceButton x)
                         + size (grabbed_device_UngrabDeviceButton x)
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (grab_window_UngrabDeviceButton x)
               serialize (modifiers_UngrabDeviceButton x)
               serialize (modifier_device_UngrabDeviceButton x)
               serialize (button_UngrabDeviceButton x)
               serialize (grabbed_device_UngrabDeviceButton x)
               putSkip (requiredPadding size__)
 
data AllowDeviceEvents = MkAllowDeviceEvents{time_AllowDeviceEvents
                                             :: TIMESTAMP,
                                             mode_AllowDeviceEvents :: Word8,
                                             device_id_AllowDeviceEvents :: Word8}
                       deriving (Show, Typeable)
 
instance ExtensionRequest AllowDeviceEvents where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 19
               let size__
                     = 4 + size (time_AllowDeviceEvents x) +
                         size (mode_AllowDeviceEvents x)
                         + size (device_id_AllowDeviceEvents x)
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (time_AllowDeviceEvents x)
               serialize (mode_AllowDeviceEvents x)
               serialize (device_id_AllowDeviceEvents x)
               putSkip (requiredPadding size__)
 
data GetDeviceFocus = MkGetDeviceFocus{device_id_GetDeviceFocus ::
                                       Word8}
                    deriving (Show, Typeable)
 
instance ExtensionRequest GetDeviceFocus where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 20
               let size__ = 4 + size (device_id_GetDeviceFocus x) + 3
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_GetDeviceFocus x)
               putSkip 3
               putSkip (requiredPadding size__)
 
data GetDeviceFocusReply = MkGetDeviceFocusReply{focus_GetDeviceFocusReply
                                                 :: WINDOW,
                                                 time_GetDeviceFocusReply :: TIMESTAMP,
                                                 revert_to_GetDeviceFocusReply :: Word8}
                         deriving (Show, Typeable)
 
instance Deserialize GetDeviceFocusReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               focus <- deserialize
               time <- deserialize
               revert_to <- deserialize
               skip 15
               let _ = isCard32 length
               return (MkGetDeviceFocusReply focus time revert_to)
 
data SetDeviceFocus = MkSetDeviceFocus{focus_SetDeviceFocus ::
                                       WINDOW,
                                       time_SetDeviceFocus :: TIMESTAMP,
                                       revert_to_SetDeviceFocus :: Word8,
                                       device_id_SetDeviceFocus :: Word8}
                    deriving (Show, Typeable)
 
instance ExtensionRequest SetDeviceFocus where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 21
               let size__
                     = 4 + size (focus_SetDeviceFocus x) + size (time_SetDeviceFocus x)
                         + size (revert_to_SetDeviceFocus x)
                         + size (device_id_SetDeviceFocus x)
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (focus_SetDeviceFocus x)
               serialize (time_SetDeviceFocus x)
               serialize (revert_to_SetDeviceFocus x)
               serialize (device_id_SetDeviceFocus x)
               putSkip (requiredPadding size__)
 
data GetFeedbackControl = MkGetFeedbackControl{device_id_GetFeedbackControl
                                               :: Word8}
                        deriving (Show, Typeable)
 
instance ExtensionRequest GetFeedbackControl where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 22
               let size__ = 4 + size (device_id_GetFeedbackControl x) + 3
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_GetFeedbackControl x)
               putSkip 3
               putSkip (requiredPadding size__)
 
data GetFeedbackControlReply = MkGetFeedbackControlReply{num_feedback_GetFeedbackControlReply
                                                         :: Word16}
                             deriving (Show, Typeable)
 
instance Deserialize GetFeedbackControlReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               num_feedback <- deserialize
               skip 22
               let _ = isCard32 length
               return (MkGetFeedbackControlReply num_feedback)
 
data FeedbackState = MkFeedbackState{class_id_FeedbackState ::
                                     Word8,
                                     id_FeedbackState :: Word8, len_FeedbackState :: Word16}
                   deriving (Show, Typeable)
 
instance Serialize FeedbackState where
        serialize x
          = do serialize (class_id_FeedbackState x)
               serialize (id_FeedbackState x)
               serialize (len_FeedbackState x)
        size x
          = size (class_id_FeedbackState x) + size (id_FeedbackState x) +
              size (len_FeedbackState x)
 
instance Deserialize FeedbackState where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               return (MkFeedbackState class_id id len)
 
data KbdFeedbackState = MkKbdFeedbackState{class_id_KbdFeedbackState
                                           :: Word8,
                                           id_KbdFeedbackState :: Word8,
                                           len_KbdFeedbackState :: Word16,
                                           pitch_KbdFeedbackState :: Word16,
                                           duration_KbdFeedbackState :: Word16,
                                           led_mask_KbdFeedbackState :: Word32,
                                           led_values_KbdFeedbackState :: Word32,
                                           global_auto_repeat_KbdFeedbackState :: Bool,
                                           click_KbdFeedbackState :: Word8,
                                           percent_KbdFeedbackState :: Word8,
                                           auto_repeats_KbdFeedbackState :: [Word8]}
                      deriving (Show, Typeable)
 
instance Serialize KbdFeedbackState where
        serialize x
          = do serialize (class_id_KbdFeedbackState x)
               serialize (id_KbdFeedbackState x)
               serialize (len_KbdFeedbackState x)
               serialize (pitch_KbdFeedbackState x)
               serialize (duration_KbdFeedbackState x)
               serialize (led_mask_KbdFeedbackState x)
               serialize (led_values_KbdFeedbackState x)
               serialize (global_auto_repeat_KbdFeedbackState x)
               serialize (click_KbdFeedbackState x)
               serialize (percent_KbdFeedbackState x)
               putSkip 1
               serializeList (auto_repeats_KbdFeedbackState x)
        size x
          = size (class_id_KbdFeedbackState x) + size (id_KbdFeedbackState x)
              + size (len_KbdFeedbackState x)
              + size (pitch_KbdFeedbackState x)
              + size (duration_KbdFeedbackState x)
              + size (led_mask_KbdFeedbackState x)
              + size (led_values_KbdFeedbackState x)
              + size (global_auto_repeat_KbdFeedbackState x)
              + size (click_KbdFeedbackState x)
              + size (percent_KbdFeedbackState x)
              + 1
              + sum (map size (auto_repeats_KbdFeedbackState x))
 
instance Deserialize KbdFeedbackState where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               pitch <- deserialize
               duration <- deserialize
               led_mask <- deserialize
               led_values <- deserialize
               global_auto_repeat <- deserialize
               click <- deserialize
               percent <- deserialize
               skip 1
               auto_repeats <- deserializeList (fromIntegral 32)
               return
                 (MkKbdFeedbackState class_id id len pitch duration led_mask
                    led_values
                    global_auto_repeat
                    click
                    percent
                    auto_repeats)
 
data PtrFeedbackState = MkPtrFeedbackState{class_id_PtrFeedbackState
                                           :: Word8,
                                           id_PtrFeedbackState :: Word8,
                                           len_PtrFeedbackState :: Word16,
                                           accel_num_PtrFeedbackState :: Word16,
                                           accel_denom_PtrFeedbackState :: Word16,
                                           threshold_PtrFeedbackState :: Word16}
                      deriving (Show, Typeable)
 
instance Serialize PtrFeedbackState where
        serialize x
          = do serialize (class_id_PtrFeedbackState x)
               serialize (id_PtrFeedbackState x)
               serialize (len_PtrFeedbackState x)
               putSkip 2
               serialize (accel_num_PtrFeedbackState x)
               serialize (accel_denom_PtrFeedbackState x)
               serialize (threshold_PtrFeedbackState x)
        size x
          = size (class_id_PtrFeedbackState x) + size (id_PtrFeedbackState x)
              + size (len_PtrFeedbackState x)
              + 2
              + size (accel_num_PtrFeedbackState x)
              + size (accel_denom_PtrFeedbackState x)
              + size (threshold_PtrFeedbackState x)
 
instance Deserialize PtrFeedbackState where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               skip 2
               accel_num <- deserialize
               accel_denom <- deserialize
               threshold <- deserialize
               return
                 (MkPtrFeedbackState class_id id len accel_num accel_denom
                    threshold)
 
data IntegerFeedbackState = MkIntegerFeedbackState{class_id_IntegerFeedbackState
                                                   :: Word8,
                                                   id_IntegerFeedbackState :: Word8,
                                                   len_IntegerFeedbackState :: Word16,
                                                   resolution_IntegerFeedbackState :: Word32,
                                                   min_value_IntegerFeedbackState :: Int32,
                                                   max_value_IntegerFeedbackState :: Int32}
                          deriving (Show, Typeable)
 
instance Serialize IntegerFeedbackState where
        serialize x
          = do serialize (class_id_IntegerFeedbackState x)
               serialize (id_IntegerFeedbackState x)
               serialize (len_IntegerFeedbackState x)
               serialize (resolution_IntegerFeedbackState x)
               serialize (min_value_IntegerFeedbackState x)
               serialize (max_value_IntegerFeedbackState x)
        size x
          = size (class_id_IntegerFeedbackState x) +
              size (id_IntegerFeedbackState x)
              + size (len_IntegerFeedbackState x)
              + size (resolution_IntegerFeedbackState x)
              + size (min_value_IntegerFeedbackState x)
              + size (max_value_IntegerFeedbackState x)
 
instance Deserialize IntegerFeedbackState where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               resolution <- deserialize
               min_value <- deserialize
               max_value <- deserialize
               return
                 (MkIntegerFeedbackState class_id id len resolution min_value
                    max_value)
 
data StringFeedbackState = MkStringFeedbackState{class_id_StringFeedbackState
                                                 :: Word8,
                                                 id_StringFeedbackState :: Word8,
                                                 len_StringFeedbackState :: Word16,
                                                 max_symbols_StringFeedbackState :: Word16,
                                                 num_keysyms_StringFeedbackState :: Word16,
                                                 keysyms_StringFeedbackState :: [KEYSYM]}
                         deriving (Show, Typeable)
 
instance Serialize StringFeedbackState where
        serialize x
          = do serialize (class_id_StringFeedbackState x)
               serialize (id_StringFeedbackState x)
               serialize (len_StringFeedbackState x)
               serialize (max_symbols_StringFeedbackState x)
               serialize (num_keysyms_StringFeedbackState x)
               serializeList (keysyms_StringFeedbackState x)
        size x
          = size (class_id_StringFeedbackState x) +
              size (id_StringFeedbackState x)
              + size (len_StringFeedbackState x)
              + size (max_symbols_StringFeedbackState x)
              + size (num_keysyms_StringFeedbackState x)
              + sum (map size (keysyms_StringFeedbackState x))
 
instance Deserialize StringFeedbackState where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               max_symbols <- deserialize
               num_keysyms <- deserialize
               keysyms <- deserializeList (fromIntegral num_keysyms)
               return
                 (MkStringFeedbackState class_id id len max_symbols num_keysyms
                    keysyms)
 
data BellFeedbackState = MkBellFeedbackState{class_id_BellFeedbackState
                                             :: Word8,
                                             id_BellFeedbackState :: Word8,
                                             len_BellFeedbackState :: Word16,
                                             percent_BellFeedbackState :: Word8,
                                             pitch_BellFeedbackState :: Word16,
                                             duration_BellFeedbackState :: Word16}
                       deriving (Show, Typeable)
 
instance Serialize BellFeedbackState where
        serialize x
          = do serialize (class_id_BellFeedbackState x)
               serialize (id_BellFeedbackState x)
               serialize (len_BellFeedbackState x)
               serialize (percent_BellFeedbackState x)
               putSkip 3
               serialize (pitch_BellFeedbackState x)
               serialize (duration_BellFeedbackState x)
        size x
          = size (class_id_BellFeedbackState x) +
              size (id_BellFeedbackState x)
              + size (len_BellFeedbackState x)
              + size (percent_BellFeedbackState x)
              + 3
              + size (pitch_BellFeedbackState x)
              + size (duration_BellFeedbackState x)
 
instance Deserialize BellFeedbackState where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               percent <- deserialize
               skip 3
               pitch <- deserialize
               duration <- deserialize
               return (MkBellFeedbackState class_id id len percent pitch duration)
 
data LedFeedbackState = MkLedFeedbackState{class_id_LedFeedbackState
                                           :: Word8,
                                           id_LedFeedbackState :: Word8,
                                           len_LedFeedbackState :: Word16,
                                           led_mask_LedFeedbackState :: Word32,
                                           led_values_LedFeedbackState :: Word32}
                      deriving (Show, Typeable)
 
instance Serialize LedFeedbackState where
        serialize x
          = do serialize (class_id_LedFeedbackState x)
               serialize (id_LedFeedbackState x)
               serialize (len_LedFeedbackState x)
               serialize (led_mask_LedFeedbackState x)
               serialize (led_values_LedFeedbackState x)
        size x
          = size (class_id_LedFeedbackState x) + size (id_LedFeedbackState x)
              + size (len_LedFeedbackState x)
              + size (led_mask_LedFeedbackState x)
              + size (led_values_LedFeedbackState x)
 
instance Deserialize LedFeedbackState where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               led_mask <- deserialize
               led_values <- deserialize
               return (MkLedFeedbackState class_id id len led_mask led_values)
 
data FeedbackCtl = MkFeedbackCtl{class_id_FeedbackCtl :: Word8,
                                 id_FeedbackCtl :: Word8, len_FeedbackCtl :: Word16}
                 deriving (Show, Typeable)
 
instance Serialize FeedbackCtl where
        serialize x
          = do serialize (class_id_FeedbackCtl x)
               serialize (id_FeedbackCtl x)
               serialize (len_FeedbackCtl x)
        size x
          = size (class_id_FeedbackCtl x) + size (id_FeedbackCtl x) +
              size (len_FeedbackCtl x)
 
instance Deserialize FeedbackCtl where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               return (MkFeedbackCtl class_id id len)
 
data KbdFeedbackCtl = MkKbdFeedbackCtl{class_id_KbdFeedbackCtl ::
                                       Word8,
                                       id_KbdFeedbackCtl :: Word8, len_KbdFeedbackCtl :: Word16,
                                       key_KbdFeedbackCtl :: KeyCode,
                                       auto_repeat_mode_KbdFeedbackCtl :: Word8,
                                       key_click_percent_KbdFeedbackCtl :: Int8,
                                       bell_percent_KbdFeedbackCtl :: Int8,
                                       bell_pitch_KbdFeedbackCtl :: Int16,
                                       bell_duration_KbdFeedbackCtl :: Int16,
                                       led_mask_KbdFeedbackCtl :: Word32,
                                       led_values_KbdFeedbackCtl :: Word32}
                    deriving (Show, Typeable)
 
instance Serialize KbdFeedbackCtl where
        serialize x
          = do serialize (class_id_KbdFeedbackCtl x)
               serialize (id_KbdFeedbackCtl x)
               serialize (len_KbdFeedbackCtl x)
               serialize (key_KbdFeedbackCtl x)
               serialize (auto_repeat_mode_KbdFeedbackCtl x)
               serialize (key_click_percent_KbdFeedbackCtl x)
               serialize (bell_percent_KbdFeedbackCtl x)
               serialize (bell_pitch_KbdFeedbackCtl x)
               serialize (bell_duration_KbdFeedbackCtl x)
               serialize (led_mask_KbdFeedbackCtl x)
               serialize (led_values_KbdFeedbackCtl x)
        size x
          = size (class_id_KbdFeedbackCtl x) + size (id_KbdFeedbackCtl x) +
              size (len_KbdFeedbackCtl x)
              + size (key_KbdFeedbackCtl x)
              + size (auto_repeat_mode_KbdFeedbackCtl x)
              + size (key_click_percent_KbdFeedbackCtl x)
              + size (bell_percent_KbdFeedbackCtl x)
              + size (bell_pitch_KbdFeedbackCtl x)
              + size (bell_duration_KbdFeedbackCtl x)
              + size (led_mask_KbdFeedbackCtl x)
              + size (led_values_KbdFeedbackCtl x)
 
instance Deserialize KbdFeedbackCtl where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               key <- deserialize
               auto_repeat_mode <- deserialize
               key_click_percent <- deserialize
               bell_percent <- deserialize
               bell_pitch <- deserialize
               bell_duration <- deserialize
               led_mask <- deserialize
               led_values <- deserialize
               return
                 (MkKbdFeedbackCtl class_id id len key auto_repeat_mode
                    key_click_percent
                    bell_percent
                    bell_pitch
                    bell_duration
                    led_mask
                    led_values)
 
data PtrFeedbackCtl = MkPtrFeedbackCtl{class_id_PtrFeedbackCtl ::
                                       Word8,
                                       id_PtrFeedbackCtl :: Word8, len_PtrFeedbackCtl :: Word16,
                                       num_PtrFeedbackCtl :: Int16, denom_PtrFeedbackCtl :: Int16,
                                       threshold_PtrFeedbackCtl :: Int16}
                    deriving (Show, Typeable)
 
instance Serialize PtrFeedbackCtl where
        serialize x
          = do serialize (class_id_PtrFeedbackCtl x)
               serialize (id_PtrFeedbackCtl x)
               serialize (len_PtrFeedbackCtl x)
               putSkip 2
               serialize (num_PtrFeedbackCtl x)
               serialize (denom_PtrFeedbackCtl x)
               serialize (threshold_PtrFeedbackCtl x)
        size x
          = size (class_id_PtrFeedbackCtl x) + size (id_PtrFeedbackCtl x) +
              size (len_PtrFeedbackCtl x)
              + 2
              + size (num_PtrFeedbackCtl x)
              + size (denom_PtrFeedbackCtl x)
              + size (threshold_PtrFeedbackCtl x)
 
instance Deserialize PtrFeedbackCtl where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               skip 2
               num <- deserialize
               denom <- deserialize
               threshold <- deserialize
               return (MkPtrFeedbackCtl class_id id len num denom threshold)
 
data IntegerFeedbackCtl = MkIntegerFeedbackCtl{class_id_IntegerFeedbackCtl
                                               :: Word8,
                                               id_IntegerFeedbackCtl :: Word8,
                                               len_IntegerFeedbackCtl :: Word16,
                                               int_to_display_IntegerFeedbackCtl :: Int32}
                        deriving (Show, Typeable)
 
instance Serialize IntegerFeedbackCtl where
        serialize x
          = do serialize (class_id_IntegerFeedbackCtl x)
               serialize (id_IntegerFeedbackCtl x)
               serialize (len_IntegerFeedbackCtl x)
               serialize (int_to_display_IntegerFeedbackCtl x)
        size x
          = size (class_id_IntegerFeedbackCtl x) +
              size (id_IntegerFeedbackCtl x)
              + size (len_IntegerFeedbackCtl x)
              + size (int_to_display_IntegerFeedbackCtl x)
 
instance Deserialize IntegerFeedbackCtl where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               int_to_display <- deserialize
               return (MkIntegerFeedbackCtl class_id id len int_to_display)
 
data StringFeedbackCtl = MkStringFeedbackCtl{class_id_StringFeedbackCtl
                                             :: Word8,
                                             id_StringFeedbackCtl :: Word8,
                                             len_StringFeedbackCtl :: Word16,
                                             num_keysyms_StringFeedbackCtl :: Word16,
                                             keysyms_StringFeedbackCtl :: [KEYSYM]}
                       deriving (Show, Typeable)
 
instance Serialize StringFeedbackCtl where
        serialize x
          = do serialize (class_id_StringFeedbackCtl x)
               serialize (id_StringFeedbackCtl x)
               serialize (len_StringFeedbackCtl x)
               putSkip 2
               serialize (num_keysyms_StringFeedbackCtl x)
               serializeList (keysyms_StringFeedbackCtl x)
        size x
          = size (class_id_StringFeedbackCtl x) +
              size (id_StringFeedbackCtl x)
              + size (len_StringFeedbackCtl x)
              + 2
              + size (num_keysyms_StringFeedbackCtl x)
              + sum (map size (keysyms_StringFeedbackCtl x))
 
instance Deserialize StringFeedbackCtl where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               skip 2
               num_keysyms <- deserialize
               keysyms <- deserializeList (fromIntegral num_keysyms)
               return (MkStringFeedbackCtl class_id id len num_keysyms keysyms)
 
data BellFeedbackCtl = MkBellFeedbackCtl{class_id_BellFeedbackCtl
                                         :: Word8,
                                         id_BellFeedbackCtl :: Word8, len_BellFeedbackCtl :: Word16,
                                         percent_BellFeedbackCtl :: Int8,
                                         pitch_BellFeedbackCtl :: Int16,
                                         duration_BellFeedbackCtl :: Int16}
                     deriving (Show, Typeable)
 
instance Serialize BellFeedbackCtl where
        serialize x
          = do serialize (class_id_BellFeedbackCtl x)
               serialize (id_BellFeedbackCtl x)
               serialize (len_BellFeedbackCtl x)
               serialize (percent_BellFeedbackCtl x)
               putSkip 3
               serialize (pitch_BellFeedbackCtl x)
               serialize (duration_BellFeedbackCtl x)
        size x
          = size (class_id_BellFeedbackCtl x) + size (id_BellFeedbackCtl x) +
              size (len_BellFeedbackCtl x)
              + size (percent_BellFeedbackCtl x)
              + 3
              + size (pitch_BellFeedbackCtl x)
              + size (duration_BellFeedbackCtl x)
 
instance Deserialize BellFeedbackCtl where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               percent <- deserialize
               skip 3
               pitch <- deserialize
               duration <- deserialize
               return (MkBellFeedbackCtl class_id id len percent pitch duration)
 
data LedFeedbackCtl = MkLedFeedbackCtl{class_id_LedFeedbackCtl ::
                                       Word8,
                                       id_LedFeedbackCtl :: Word8, len_LedFeedbackCtl :: Word16,
                                       led_mask_LedFeedbackCtl :: Word32,
                                       led_values_LedFeedbackCtl :: Word32}
                    deriving (Show, Typeable)
 
instance Serialize LedFeedbackCtl where
        serialize x
          = do serialize (class_id_LedFeedbackCtl x)
               serialize (id_LedFeedbackCtl x)
               serialize (len_LedFeedbackCtl x)
               serialize (led_mask_LedFeedbackCtl x)
               serialize (led_values_LedFeedbackCtl x)
        size x
          = size (class_id_LedFeedbackCtl x) + size (id_LedFeedbackCtl x) +
              size (len_LedFeedbackCtl x)
              + size (led_mask_LedFeedbackCtl x)
              + size (led_values_LedFeedbackCtl x)
 
instance Deserialize LedFeedbackCtl where
        deserialize
          = do class_id <- deserialize
               id <- deserialize
               len <- deserialize
               led_mask <- deserialize
               led_values <- deserialize
               return (MkLedFeedbackCtl class_id id len led_mask led_values)
 
data GetDeviceKeyMapping = MkGetDeviceKeyMapping{device_id_GetDeviceKeyMapping
                                                 :: Word8,
                                                 first_keycode_GetDeviceKeyMapping :: KeyCode,
                                                 count_GetDeviceKeyMapping :: Word8}
                         deriving (Show, Typeable)
 
instance ExtensionRequest GetDeviceKeyMapping where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 24
               let size__
                     = 4 + size (device_id_GetDeviceKeyMapping x) +
                         size (first_keycode_GetDeviceKeyMapping x)
                         + size (count_GetDeviceKeyMapping x)
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_GetDeviceKeyMapping x)
               serialize (first_keycode_GetDeviceKeyMapping x)
               serialize (count_GetDeviceKeyMapping x)
               putSkip (requiredPadding size__)
 
data GetDeviceKeyMappingReply = MkGetDeviceKeyMappingReply{keysyms_per_keycode_GetDeviceKeyMappingReply
                                                           :: Word8,
                                                           keysyms_GetDeviceKeyMappingReply ::
                                                           [KEYSYM]}
                              deriving (Show, Typeable)
 
instance Deserialize GetDeviceKeyMappingReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               keysyms_per_keycode <- deserialize
               skip 23
               keysyms <- deserializeList (fromIntegral length)
               let _ = isCard32 length
               return (MkGetDeviceKeyMappingReply keysyms_per_keycode keysyms)
 
data ChangeDeviceKeyMapping = MkChangeDeviceKeyMapping{device_id_ChangeDeviceKeyMapping
                                                       :: Word8,
                                                       first_keycode_ChangeDeviceKeyMapping ::
                                                       KeyCode,
                                                       keysyms_per_keycode_ChangeDeviceKeyMapping ::
                                                       Word8,
                                                       keycode_count_ChangeDeviceKeyMapping ::
                                                       Word8,
                                                       keysyms_ChangeDeviceKeyMapping :: [KEYSYM]}
                            deriving (Show, Typeable)
 
instance ExtensionRequest ChangeDeviceKeyMapping where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 25
               let size__
                     = 4 + size (device_id_ChangeDeviceKeyMapping x) +
                         size (first_keycode_ChangeDeviceKeyMapping x)
                         + size (keysyms_per_keycode_ChangeDeviceKeyMapping x)
                         + size (keycode_count_ChangeDeviceKeyMapping x)
                         + sum (map size (keysyms_ChangeDeviceKeyMapping x))
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_ChangeDeviceKeyMapping x)
               serialize (first_keycode_ChangeDeviceKeyMapping x)
               serialize (keysyms_per_keycode_ChangeDeviceKeyMapping x)
               serialize (keycode_count_ChangeDeviceKeyMapping x)
               serializeList (keysyms_ChangeDeviceKeyMapping x)
               putSkip (requiredPadding size__)
 
data GetDeviceModifierMapping = MkGetDeviceModifierMapping{device_id_GetDeviceModifierMapping
                                                           :: Word8}
                              deriving (Show, Typeable)
 
instance ExtensionRequest GetDeviceModifierMapping where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 26
               let size__ = 4 + size (device_id_GetDeviceModifierMapping x) + 3
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_GetDeviceModifierMapping x)
               putSkip 3
               putSkip (requiredPadding size__)
 
data GetDeviceModifierMappingReply = MkGetDeviceModifierMappingReply{keycodes_per_modifier_GetDeviceModifierMappingReply
                                                                     :: Word8,
                                                                     keymaps_GetDeviceModifierMappingReply
                                                                     :: [Word8]}
                                   deriving (Show, Typeable)
 
instance Deserialize GetDeviceModifierMappingReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               keycodes_per_modifier <- deserialize
               skip 23
               keymaps <- deserializeList
                            (fromIntegral (fromIntegral (keycodes_per_modifier * 8)))
               let _ = isCard32 length
               return
                 (MkGetDeviceModifierMappingReply keycodes_per_modifier keymaps)
 
data SetDeviceModifierMapping = MkSetDeviceModifierMapping{device_id_SetDeviceModifierMapping
                                                           :: Word8,
                                                           keycodes_per_modifier_SetDeviceModifierMapping
                                                           :: Word8,
                                                           keymaps_SetDeviceModifierMapping ::
                                                           [Word8]}
                              deriving (Show, Typeable)
 
instance ExtensionRequest SetDeviceModifierMapping where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 27
               let size__
                     = 4 + size (device_id_SetDeviceModifierMapping x) +
                         size (keycodes_per_modifier_SetDeviceModifierMapping x)
                         + 1
                         + sum (map size (keymaps_SetDeviceModifierMapping x))
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_SetDeviceModifierMapping x)
               serialize (keycodes_per_modifier_SetDeviceModifierMapping x)
               putSkip 1
               serializeList (keymaps_SetDeviceModifierMapping x)
               putSkip (requiredPadding size__)
 
data SetDeviceModifierMappingReply = MkSetDeviceModifierMappingReply{status_SetDeviceModifierMappingReply
                                                                     :: Word8}
                                   deriving (Show, Typeable)
 
instance Deserialize SetDeviceModifierMappingReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               status <- deserialize
               skip 23
               let _ = isCard32 length
               return (MkSetDeviceModifierMappingReply status)
 
data GetDeviceButtonMapping = MkGetDeviceButtonMapping{device_id_GetDeviceButtonMapping
                                                       :: Word8}
                            deriving (Show, Typeable)
 
instance ExtensionRequest GetDeviceButtonMapping where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 28
               let size__ = 4 + size (device_id_GetDeviceButtonMapping x) + 3
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_GetDeviceButtonMapping x)
               putSkip 3
               putSkip (requiredPadding size__)
 
data GetDeviceButtonMappingReply = MkGetDeviceButtonMappingReply{map_size_GetDeviceButtonMappingReply
                                                                 :: Word8,
                                                                 map_GetDeviceButtonMappingReply ::
                                                                 [Word8]}
                                 deriving (Show, Typeable)
 
instance Deserialize GetDeviceButtonMappingReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               map_size <- deserialize
               skip 23
               map <- deserializeList (fromIntegral map_size)
               let _ = isCard32 length
               return (MkGetDeviceButtonMappingReply map_size map)
 
data SetDeviceButtonMapping = MkSetDeviceButtonMapping{device_id_SetDeviceButtonMapping
                                                       :: Word8,
                                                       map_size_SetDeviceButtonMapping :: Word8,
                                                       map_SetDeviceButtonMapping :: [Word8]}
                            deriving (Show, Typeable)
 
instance ExtensionRequest SetDeviceButtonMapping where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 29
               let size__
                     = 4 + size (device_id_SetDeviceButtonMapping x) +
                         size (map_size_SetDeviceButtonMapping x)
                         + 2
                         + sum (map size (map_SetDeviceButtonMapping x))
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_SetDeviceButtonMapping x)
               serialize (map_size_SetDeviceButtonMapping x)
               putSkip 2
               serializeList (map_SetDeviceButtonMapping x)
               putSkip (requiredPadding size__)
 
data SetDeviceButtonMappingReply = MkSetDeviceButtonMappingReply{status_SetDeviceButtonMappingReply
                                                                 :: Word8}
                                 deriving (Show, Typeable)
 
instance Deserialize SetDeviceButtonMappingReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               status <- deserialize
               skip 23
               let _ = isCard32 length
               return (MkSetDeviceButtonMappingReply status)
 
data QueryDeviceState = MkQueryDeviceState{device_id_QueryDeviceState
                                           :: Word8}
                      deriving (Show, Typeable)
 
instance ExtensionRequest QueryDeviceState where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 30
               let size__ = 4 + size (device_id_QueryDeviceState x) + 3
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_QueryDeviceState x)
               putSkip 3
               putSkip (requiredPadding size__)
 
data QueryDeviceStateReply = MkQueryDeviceStateReply{num_classes_QueryDeviceStateReply
                                                     :: Word8}
                           deriving (Show, Typeable)
 
instance Deserialize QueryDeviceStateReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               num_classes <- deserialize
               skip 23
               let _ = isCard32 length
               return (MkQueryDeviceStateReply num_classes)
 
data InputState = MkInputState{class_id_InputState :: Word8,
                               len_InputState :: Word8, num_items_InputState :: Word8}
                deriving (Show, Typeable)
 
instance Serialize InputState where
        serialize x
          = do serialize (class_id_InputState x)
               serialize (len_InputState x)
               serialize (num_items_InputState x)
        size x
          = size (class_id_InputState x) + size (len_InputState x) +
              size (num_items_InputState x)
 
instance Deserialize InputState where
        deserialize
          = do class_id <- deserialize
               len <- deserialize
               num_items <- deserialize
               return (MkInputState class_id len num_items)
 
data KeyState = MkKeyState{class_id_KeyState :: Word8,
                           len_KeyState :: Word8, num_keys_KeyState :: Word8,
                           keys_KeyState :: [Word8]}
              deriving (Show, Typeable)
 
instance Serialize KeyState where
        serialize x
          = do serialize (class_id_KeyState x)
               serialize (len_KeyState x)
               serialize (num_keys_KeyState x)
               putSkip 1
               serializeList (keys_KeyState x)
        size x
          = size (class_id_KeyState x) + size (len_KeyState x) +
              size (num_keys_KeyState x)
              + 1
              + sum (map size (keys_KeyState x))
 
instance Deserialize KeyState where
        deserialize
          = do class_id <- deserialize
               len <- deserialize
               num_keys <- deserialize
               skip 1
               keys <- deserializeList (fromIntegral 32)
               return (MkKeyState class_id len num_keys keys)
 
data ButtonState = MkButtonState{class_id_ButtonState :: Word8,
                                 len_ButtonState :: Word8, num_buttons_ButtonState :: Word8,
                                 buttons_ButtonState :: [Word8]}
                 deriving (Show, Typeable)
 
instance Serialize ButtonState where
        serialize x
          = do serialize (class_id_ButtonState x)
               serialize (len_ButtonState x)
               serialize (num_buttons_ButtonState x)
               putSkip 1
               serializeList (buttons_ButtonState x)
        size x
          = size (class_id_ButtonState x) + size (len_ButtonState x) +
              size (num_buttons_ButtonState x)
              + 1
              + sum (map size (buttons_ButtonState x))
 
instance Deserialize ButtonState where
        deserialize
          = do class_id <- deserialize
               len <- deserialize
               num_buttons <- deserialize
               skip 1
               buttons <- deserializeList (fromIntegral 32)
               return (MkButtonState class_id len num_buttons buttons)
 
data ValuatorState = MkValuatorState{class_id_ValuatorState ::
                                     Word8,
                                     len_ValuatorState :: Word8,
                                     num_valuators_ValuatorState :: Word8,
                                     mode_ValuatorState :: Word8,
                                     valuators_ValuatorState :: [Word32]}
                   deriving (Show, Typeable)
 
instance Serialize ValuatorState where
        serialize x
          = do serialize (class_id_ValuatorState x)
               serialize (len_ValuatorState x)
               serialize (num_valuators_ValuatorState x)
               serialize (mode_ValuatorState x)
               serializeList (valuators_ValuatorState x)
        size x
          = size (class_id_ValuatorState x) + size (len_ValuatorState x) +
              size (num_valuators_ValuatorState x)
              + size (mode_ValuatorState x)
              + sum (map size (valuators_ValuatorState x))
 
instance Deserialize ValuatorState where
        deserialize
          = do class_id <- deserialize
               len <- deserialize
               num_valuators <- deserialize
               mode <- deserialize
               valuators <- deserializeList (fromIntegral num_valuators)
               return (MkValuatorState class_id len num_valuators mode valuators)
 
data SendExtensionEvent = MkSendExtensionEvent{destination_SendExtensionEvent
                                               :: WINDOW,
                                               device_id_SendExtensionEvent :: Word8,
                                               propagate_SendExtensionEvent :: Bool,
                                               num_classes_SendExtensionEvent :: Word16,
                                               num_events_SendExtensionEvent :: Word8,
                                               events_SendExtensionEvent :: [CChar],
                                               classes_SendExtensionEvent :: [EventClass]}
                        deriving (Show, Typeable)
 
instance ExtensionRequest SendExtensionEvent where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 31
               let size__
                     = 4 + size (destination_SendExtensionEvent x) +
                         size (device_id_SendExtensionEvent x)
                         + size (propagate_SendExtensionEvent x)
                         + size (num_classes_SendExtensionEvent x)
                         + size (num_events_SendExtensionEvent x)
                         + 3
                         + sum (map size (events_SendExtensionEvent x))
                         + sum (map size (classes_SendExtensionEvent x))
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (destination_SendExtensionEvent x)
               serialize (device_id_SendExtensionEvent x)
               serialize (propagate_SendExtensionEvent x)
               serialize (num_classes_SendExtensionEvent x)
               serialize (num_events_SendExtensionEvent x)
               putSkip 3
               serializeList (events_SendExtensionEvent x)
               serializeList (classes_SendExtensionEvent x)
               putSkip (requiredPadding size__)
 
data DeviceBell = MkDeviceBell{device_id_DeviceBell :: Word8,
                               feedback_id_DeviceBell :: Word8,
                               feedback_class_DeviceBell :: Word8, percent_DeviceBell :: Int8}
                deriving (Show, Typeable)
 
instance ExtensionRequest DeviceBell where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 32
               let size__
                     = 4 + size (device_id_DeviceBell x) +
                         size (feedback_id_DeviceBell x)
                         + size (feedback_class_DeviceBell x)
                         + size (percent_DeviceBell x)
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_DeviceBell x)
               serialize (feedback_id_DeviceBell x)
               serialize (feedback_class_DeviceBell x)
               serialize (percent_DeviceBell x)
               putSkip (requiredPadding size__)
 
data SetDeviceValuators = MkSetDeviceValuators{device_id_SetDeviceValuators
                                               :: Word8,
                                               first_valuator_SetDeviceValuators :: Word8,
                                               num_valuators_SetDeviceValuators :: Word8,
                                               valuators_SetDeviceValuators :: [Int32]}
                        deriving (Show, Typeable)
 
instance ExtensionRequest SetDeviceValuators where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 33
               let size__
                     = 4 + size (device_id_SetDeviceValuators x) +
                         size (first_valuator_SetDeviceValuators x)
                         + size (num_valuators_SetDeviceValuators x)
                         + 1
                         + sum (map size (valuators_SetDeviceValuators x))
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (device_id_SetDeviceValuators x)
               serialize (first_valuator_SetDeviceValuators x)
               serialize (num_valuators_SetDeviceValuators x)
               putSkip 1
               serializeList (valuators_SetDeviceValuators x)
               putSkip (requiredPadding size__)
 
data SetDeviceValuatorsReply = MkSetDeviceValuatorsReply{status_SetDeviceValuatorsReply
                                                         :: Word8}
                             deriving (Show, Typeable)
 
instance Deserialize SetDeviceValuatorsReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               status <- deserialize
               skip 23
               let _ = isCard32 length
               return (MkSetDeviceValuatorsReply status)
 
data GetDeviceControl = MkGetDeviceControl{control_id_GetDeviceControl
                                           :: Word16,
                                           device_id_GetDeviceControl :: Word8}
                      deriving (Show, Typeable)
 
instance ExtensionRequest GetDeviceControl where
        extensionId _ = "XInputExtension"
        serializeRequest x extOpCode
          = do putWord8 extOpCode
               putWord8 34
               let size__
                     = 4 + size (control_id_GetDeviceControl x) +
                         size (device_id_GetDeviceControl x)
                         + 1
               serialize (convertBytesToRequestSize size__ :: Int16)
               serialize (control_id_GetDeviceControl x)
               serialize (device_id_GetDeviceControl x)
               putSkip 1
               putSkip (requiredPadding size__)
 
data GetDeviceControlReply = MkGetDeviceControlReply{status_GetDeviceControlReply
                                                     :: Word8}
                           deriving (Show, Typeable)
 
instance Deserialize GetDeviceControlReply where
        deserialize
          = do skip 1
               skip 1
               skip 2
               length <- deserialize
               status <- deserialize
               skip 23
               let _ = isCard32 length
               return (MkGetDeviceControlReply status)
 
data DeviceState = MkDeviceState{control_id_DeviceState :: Word16,
                                 len_DeviceState :: Word16}
                 deriving (Show, Typeable)
 
instance Serialize DeviceState where
        serialize x
          = do serialize (control_id_DeviceState x)
               serialize (len_DeviceState x)
        size x = size (control_id_DeviceState x) + size (len_DeviceState x)
 
instance Deserialize DeviceState where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               return (MkDeviceState control_id len)
 
data DeviceResolutionState = MkDeviceResolutionState{control_id_DeviceResolutionState
                                                     :: Word16,
                                                     len_DeviceResolutionState :: Word16,
                                                     num_valuators_DeviceResolutionState :: Word32,
                                                     resolution_values_DeviceResolutionState ::
                                                     [Word32],
                                                     resolution_min_DeviceResolutionState ::
                                                     [Word32],
                                                     resolution_max_DeviceResolutionState ::
                                                     [Word32]}
                           deriving (Show, Typeable)
 
instance Serialize DeviceResolutionState where
        serialize x
          = do serialize (control_id_DeviceResolutionState x)
               serialize (len_DeviceResolutionState x)
               serialize (num_valuators_DeviceResolutionState x)
               serializeList (resolution_values_DeviceResolutionState x)
               serializeList (resolution_min_DeviceResolutionState x)
               serializeList (resolution_max_DeviceResolutionState x)
        size x
          = size (control_id_DeviceResolutionState x) +
              size (len_DeviceResolutionState x)
              + size (num_valuators_DeviceResolutionState x)
              + sum (map size (resolution_values_DeviceResolutionState x))
              + sum (map size (resolution_min_DeviceResolutionState x))
              + sum (map size (resolution_max_DeviceResolutionState x))
 
instance Deserialize DeviceResolutionState where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               num_valuators <- deserialize
               resolution_values <- deserializeList (fromIntegral num_valuators)
               resolution_min <- deserializeList (fromIntegral num_valuators)
               resolution_max <- deserializeList (fromIntegral num_valuators)
               return
                 (MkDeviceResolutionState control_id len num_valuators
                    resolution_values
                    resolution_min
                    resolution_max)
 
data DeviceAbsCalibState = MkDeviceAbsCalibState{control_id_DeviceAbsCalibState
                                                 :: Word16,
                                                 len_DeviceAbsCalibState :: Word16,
                                                 min_x_DeviceAbsCalibState :: Int32,
                                                 max_x_DeviceAbsCalibState :: Int32,
                                                 min_y_DeviceAbsCalibState :: Int32,
                                                 max_y_DeviceAbsCalibState :: Int32,
                                                 flip_x_DeviceAbsCalibState :: Word32,
                                                 flip_y_DeviceAbsCalibState :: Word32,
                                                 rotation_DeviceAbsCalibState :: Word32,
                                                 button_threshold_DeviceAbsCalibState :: Word32}
                         deriving (Show, Typeable)
 
instance Serialize DeviceAbsCalibState where
        serialize x
          = do serialize (control_id_DeviceAbsCalibState x)
               serialize (len_DeviceAbsCalibState x)
               serialize (min_x_DeviceAbsCalibState x)
               serialize (max_x_DeviceAbsCalibState x)
               serialize (min_y_DeviceAbsCalibState x)
               serialize (max_y_DeviceAbsCalibState x)
               serialize (flip_x_DeviceAbsCalibState x)
               serialize (flip_y_DeviceAbsCalibState x)
               serialize (rotation_DeviceAbsCalibState x)
               serialize (button_threshold_DeviceAbsCalibState x)
        size x
          = size (control_id_DeviceAbsCalibState x) +
              size (len_DeviceAbsCalibState x)
              + size (min_x_DeviceAbsCalibState x)
              + size (max_x_DeviceAbsCalibState x)
              + size (min_y_DeviceAbsCalibState x)
              + size (max_y_DeviceAbsCalibState x)
              + size (flip_x_DeviceAbsCalibState x)
              + size (flip_y_DeviceAbsCalibState x)
              + size (rotation_DeviceAbsCalibState x)
              + size (button_threshold_DeviceAbsCalibState x)
 
instance Deserialize DeviceAbsCalibState where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               min_x <- deserialize
               max_x <- deserialize
               min_y <- deserialize
               max_y <- deserialize
               flip_x <- deserialize
               flip_y <- deserialize
               rotation <- deserialize
               button_threshold <- deserialize
               return
                 (MkDeviceAbsCalibState control_id len min_x max_x min_y max_y
                    flip_x
                    flip_y
                    rotation
                    button_threshold)
 
data DeviceAbsAreaState = MkDeviceAbsAreaState{control_id_DeviceAbsAreaState
                                               :: Word16,
                                               len_DeviceAbsAreaState :: Word16,
                                               offset_x_DeviceAbsAreaState :: Word32,
                                               offset_y_DeviceAbsAreaState :: Word32,
                                               width_DeviceAbsAreaState :: Word32,
                                               height_DeviceAbsAreaState :: Word32,
                                               screen_DeviceAbsAreaState :: Word32,
                                               following_DeviceAbsAreaState :: Word32}
                        deriving (Show, Typeable)
 
instance Serialize DeviceAbsAreaState where
        serialize x
          = do serialize (control_id_DeviceAbsAreaState x)
               serialize (len_DeviceAbsAreaState x)
               serialize (offset_x_DeviceAbsAreaState x)
               serialize (offset_y_DeviceAbsAreaState x)
               serialize (width_DeviceAbsAreaState x)
               serialize (height_DeviceAbsAreaState x)
               serialize (screen_DeviceAbsAreaState x)
               serialize (following_DeviceAbsAreaState x)
        size x
          = size (control_id_DeviceAbsAreaState x) +
              size (len_DeviceAbsAreaState x)
              + size (offset_x_DeviceAbsAreaState x)
              + size (offset_y_DeviceAbsAreaState x)
              + size (width_DeviceAbsAreaState x)
              + size (height_DeviceAbsAreaState x)
              + size (screen_DeviceAbsAreaState x)
              + size (following_DeviceAbsAreaState x)
 
instance Deserialize DeviceAbsAreaState where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               offset_x <- deserialize
               offset_y <- deserialize
               width <- deserialize
               height <- deserialize
               screen <- deserialize
               following <- deserialize
               return
                 (MkDeviceAbsAreaState control_id len offset_x offset_y width height
                    screen
                    following)
 
data DeviceCoreState = MkDeviceCoreState{control_id_DeviceCoreState
                                         :: Word16,
                                         len_DeviceCoreState :: Word16,
                                         status_DeviceCoreState :: Word8,
                                         iscore_DeviceCoreState :: Word8}
                     deriving (Show, Typeable)
 
instance Serialize DeviceCoreState where
        serialize x
          = do serialize (control_id_DeviceCoreState x)
               serialize (len_DeviceCoreState x)
               serialize (status_DeviceCoreState x)
               serialize (iscore_DeviceCoreState x)
               putSkip 2
        size x
          = size (control_id_DeviceCoreState x) +
              size (len_DeviceCoreState x)
              + size (status_DeviceCoreState x)
              + size (iscore_DeviceCoreState x)
              + 2
 
instance Deserialize DeviceCoreState where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               status <- deserialize
               iscore <- deserialize
               skip 2
               return (MkDeviceCoreState control_id len status iscore)
 
data DeviceEnableState = MkDeviceEnableState{control_id_DeviceEnableState
                                             :: Word16,
                                             len_DeviceEnableState :: Word16,
                                             enable_DeviceEnableState :: Word8}
                       deriving (Show, Typeable)
 
instance Serialize DeviceEnableState where
        serialize x
          = do serialize (control_id_DeviceEnableState x)
               serialize (len_DeviceEnableState x)
               serialize (enable_DeviceEnableState x)
               putSkip 3
        size x
          = size (control_id_DeviceEnableState x) +
              size (len_DeviceEnableState x)
              + size (enable_DeviceEnableState x)
              + 3
 
instance Deserialize DeviceEnableState where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               enable <- deserialize
               skip 3
               return (MkDeviceEnableState control_id len enable)
 
data DeviceCtl = MkDeviceCtl{control_id_DeviceCtl :: Word16,
                             len_DeviceCtl :: Word16}
               deriving (Show, Typeable)
 
instance Serialize DeviceCtl where
        serialize x
          = do serialize (control_id_DeviceCtl x)
               serialize (len_DeviceCtl x)
        size x = size (control_id_DeviceCtl x) + size (len_DeviceCtl x)
 
instance Deserialize DeviceCtl where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               return (MkDeviceCtl control_id len)
 
data DeviceResolutionCtl = MkDeviceResolutionCtl{control_id_DeviceResolutionCtl
                                                 :: Word16,
                                                 len_DeviceResolutionCtl :: Word16,
                                                 first_valuator_DeviceResolutionCtl :: Word8,
                                                 num_valuators_DeviceResolutionCtl :: Word8,
                                                 resolution_values_DeviceResolutionCtl :: [Word32]}
                         deriving (Show, Typeable)
 
instance Serialize DeviceResolutionCtl where
        serialize x
          = do serialize (control_id_DeviceResolutionCtl x)
               serialize (len_DeviceResolutionCtl x)
               serialize (first_valuator_DeviceResolutionCtl x)
               serialize (num_valuators_DeviceResolutionCtl x)
               serializeList (resolution_values_DeviceResolutionCtl x)
        size x
          = size (control_id_DeviceResolutionCtl x) +
              size (len_DeviceResolutionCtl x)
              + size (first_valuator_DeviceResolutionCtl x)
              + size (num_valuators_DeviceResolutionCtl x)
              + sum (map size (resolution_values_DeviceResolutionCtl x))
 
instance Deserialize DeviceResolutionCtl where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               first_valuator <- deserialize
               num_valuators <- deserialize
               resolution_values <- deserializeList (fromIntegral num_valuators)
               return
                 (MkDeviceResolutionCtl control_id len first_valuator num_valuators
                    resolution_values)
 
data DeviceAbsCalibCtl = MkDeviceAbsCalibCtl{control_id_DeviceAbsCalibCtl
                                             :: Word16,
                                             len_DeviceAbsCalibCtl :: Word16,
                                             min_x_DeviceAbsCalibCtl :: Int32,
                                             max_x_DeviceAbsCalibCtl :: Int32,
                                             min_y_DeviceAbsCalibCtl :: Int32,
                                             max_y_DeviceAbsCalibCtl :: Int32,
                                             flip_x_DeviceAbsCalibCtl :: Word32,
                                             flip_y_DeviceAbsCalibCtl :: Word32,
                                             rotation_DeviceAbsCalibCtl :: Word32,
                                             button_threshold_DeviceAbsCalibCtl :: Word32}
                       deriving (Show, Typeable)
 
instance Serialize DeviceAbsCalibCtl where
        serialize x
          = do serialize (control_id_DeviceAbsCalibCtl x)
               serialize (len_DeviceAbsCalibCtl x)
               serialize (min_x_DeviceAbsCalibCtl x)
               serialize (max_x_DeviceAbsCalibCtl x)
               serialize (min_y_DeviceAbsCalibCtl x)
               serialize (max_y_DeviceAbsCalibCtl x)
               serialize (flip_x_DeviceAbsCalibCtl x)
               serialize (flip_y_DeviceAbsCalibCtl x)
               serialize (rotation_DeviceAbsCalibCtl x)
               serialize (button_threshold_DeviceAbsCalibCtl x)
        size x
          = size (control_id_DeviceAbsCalibCtl x) +
              size (len_DeviceAbsCalibCtl x)
              + size (min_x_DeviceAbsCalibCtl x)
              + size (max_x_DeviceAbsCalibCtl x)
              + size (min_y_DeviceAbsCalibCtl x)
              + size (max_y_DeviceAbsCalibCtl x)
              + size (flip_x_DeviceAbsCalibCtl x)
              + size (flip_y_DeviceAbsCalibCtl x)
              + size (rotation_DeviceAbsCalibCtl x)
              + size (button_threshold_DeviceAbsCalibCtl x)
 
instance Deserialize DeviceAbsCalibCtl where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               min_x <- deserialize
               max_x <- deserialize
               min_y <- deserialize
               max_y <- deserialize
               flip_x <- deserialize
               flip_y <- deserialize
               rotation <- deserialize
               button_threshold <- deserialize
               return
                 (MkDeviceAbsCalibCtl control_id len min_x max_x min_y max_y flip_x
                    flip_y
                    rotation
                    button_threshold)
 
data DeviceAbsAreaCtrl = MkDeviceAbsAreaCtrl{control_id_DeviceAbsAreaCtrl
                                             :: Word16,
                                             len_DeviceAbsAreaCtrl :: Word16,
                                             offset_x_DeviceAbsAreaCtrl :: Word32,
                                             offset_y_DeviceAbsAreaCtrl :: Word32,
                                             width_DeviceAbsAreaCtrl :: Int32,
                                             height_DeviceAbsAreaCtrl :: Int32,
                                             screen_DeviceAbsAreaCtrl :: Int32,
                                             following_DeviceAbsAreaCtrl :: Word32}
                       deriving (Show, Typeable)
 
instance Serialize DeviceAbsAreaCtrl where
        serialize x
          = do serialize (control_id_DeviceAbsAreaCtrl x)
               serialize (len_DeviceAbsAreaCtrl x)
               serialize (offset_x_DeviceAbsAreaCtrl x)
               serialize (offset_y_DeviceAbsAreaCtrl x)
               serialize (width_DeviceAbsAreaCtrl x)
               serialize (height_DeviceAbsAreaCtrl x)
               serialize (screen_DeviceAbsAreaCtrl x)
               serialize (following_DeviceAbsAreaCtrl x)
        size x
          = size (control_id_DeviceAbsAreaCtrl x) +
              size (len_DeviceAbsAreaCtrl x)
              + size (offset_x_DeviceAbsAreaCtrl x)
              + size (offset_y_DeviceAbsAreaCtrl x)
              + size (width_DeviceAbsAreaCtrl x)
              + size (height_DeviceAbsAreaCtrl x)
              + size (screen_DeviceAbsAreaCtrl x)
              + size (following_DeviceAbsAreaCtrl x)
 
instance Deserialize DeviceAbsAreaCtrl where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               offset_x <- deserialize
               offset_y <- deserialize
               width <- deserialize
               height <- deserialize
               screen <- deserialize
               following <- deserialize
               return
                 (MkDeviceAbsAreaCtrl control_id len offset_x offset_y width height
                    screen
                    following)
 
data DeviceCoreCtrl = MkDeviceCoreCtrl{control_id_DeviceCoreCtrl ::
                                       Word16,
                                       len_DeviceCoreCtrl :: Word16, status_DeviceCoreCtrl :: Word8}
                    deriving (Show, Typeable)
 
instance Serialize DeviceCoreCtrl where
        serialize x
          = do serialize (control_id_DeviceCoreCtrl x)
               serialize (len_DeviceCoreCtrl x)
               serialize (status_DeviceCoreCtrl x)
               putSkip 3
        size x
          = size (control_id_DeviceCoreCtrl x) + size (len_DeviceCoreCtrl x)
              + size (status_DeviceCoreCtrl x)
              + 3
 
instance Deserialize DeviceCoreCtrl where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               status <- deserialize
               skip 3
               return (MkDeviceCoreCtrl control_id len status)
 
data DeviceEnableCtrl = MkDeviceEnableCtrl{control_id_DeviceEnableCtrl
                                           :: Word16,
                                           len_DeviceEnableCtrl :: Word16,
                                           enable_DeviceEnableCtrl :: Word8}
                      deriving (Show, Typeable)
 
instance Serialize DeviceEnableCtrl where
        serialize x
          = do serialize (control_id_DeviceEnableCtrl x)
               serialize (len_DeviceEnableCtrl x)
               serialize (enable_DeviceEnableCtrl x)
               putSkip 3
        size x
          = size (control_id_DeviceEnableCtrl x) +
              size (len_DeviceEnableCtrl x)
              + size (enable_DeviceEnableCtrl x)
              + 3
 
instance Deserialize DeviceEnableCtrl where
        deserialize
          = do control_id <- deserialize
               len <- deserialize
               enable <- deserialize
               skip 3
               return (MkDeviceEnableCtrl control_id len enable)
 
data DeviceValuator = MkDeviceValuator{device_id_DeviceValuator ::
                                       Word8,
                                       device_state_DeviceValuator :: Word16,
                                       num_valuators_DeviceValuator :: Word8,
                                       first_valuator_DeviceValuator :: Word8,
                                       valuators_DeviceValuator :: [Int32]}
                    deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event DeviceValuator
 
instance Deserialize DeviceValuator where
        deserialize
          = do skip 1
               device_id <- deserialize
               skip 2
               device_state <- deserialize
               num_valuators <- deserialize
               first_valuator <- deserialize
               valuators <- deserializeList (fromIntegral 6)
               return
                 (MkDeviceValuator device_id device_state num_valuators
                    first_valuator
                    valuators)
 
data DeviceKeyPress = MkDeviceKeyPress{detail_DeviceKeyPress ::
                                       Word8,
                                       time_DeviceKeyPress :: TIMESTAMP,
                                       root_DeviceKeyPress :: WINDOW,
                                       event_DeviceKeyPress :: WINDOW,
                                       child_DeviceKeyPress :: WINDOW,
                                       root_x_DeviceKeyPress :: Int16,
                                       root_y_DeviceKeyPress :: Int16,
                                       event_x_DeviceKeyPress :: Int16,
                                       event_y_DeviceKeyPress :: Int16,
                                       state_DeviceKeyPress :: Word16,
                                       same_screen_DeviceKeyPress :: Bool,
                                       device_id_DeviceKeyPress :: Word8}
                    deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event DeviceKeyPress
 
instance Deserialize DeviceKeyPress where
        deserialize
          = do skip 1
               detail <- deserialize
               skip 2
               time <- deserialize
               root <- deserialize
               event <- deserialize
               child <- deserialize
               root_x <- deserialize
               root_y <- deserialize
               event_x <- deserialize
               event_y <- deserialize
               state <- deserialize
               same_screen <- deserialize
               device_id <- deserialize
               return
                 (MkDeviceKeyPress detail time root event child root_x root_y
                    event_x
                    event_y
                    state
                    same_screen
                    device_id)
 
data DeviceKeyRelease = MkDeviceKeyRelease{detail_DeviceKeyRelease
                                           :: Word8,
                                           time_DeviceKeyRelease :: TIMESTAMP,
                                           root_DeviceKeyRelease :: WINDOW,
                                           event_DeviceKeyRelease :: WINDOW,
                                           child_DeviceKeyRelease :: WINDOW,
                                           root_x_DeviceKeyRelease :: Int16,
                                           root_y_DeviceKeyRelease :: Int16,
                                           event_x_DeviceKeyRelease :: Int16,
                                           event_y_DeviceKeyRelease :: Int16,
                                           state_DeviceKeyRelease :: Word16,
                                           same_screen_DeviceKeyRelease :: Bool,
                                           device_id_DeviceKeyRelease :: Word8}
                      deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event DeviceKeyRelease
 
instance Deserialize DeviceKeyRelease where
        deserialize
          = do skip 1
               detail <- deserialize
               skip 2
               time <- deserialize
               root <- deserialize
               event <- deserialize
               child <- deserialize
               root_x <- deserialize
               root_y <- deserialize
               event_x <- deserialize
               event_y <- deserialize
               state <- deserialize
               same_screen <- deserialize
               device_id <- deserialize
               return
                 (MkDeviceKeyRelease detail time root event child root_x root_y
                    event_x
                    event_y
                    state
                    same_screen
                    device_id)
 
data DeviceButtonPress = MkDeviceButtonPress{detail_DeviceButtonPress
                                             :: Word8,
                                             time_DeviceButtonPress :: TIMESTAMP,
                                             root_DeviceButtonPress :: WINDOW,
                                             event_DeviceButtonPress :: WINDOW,
                                             child_DeviceButtonPress :: WINDOW,
                                             root_x_DeviceButtonPress :: Int16,
                                             root_y_DeviceButtonPress :: Int16,
                                             event_x_DeviceButtonPress :: Int16,
                                             event_y_DeviceButtonPress :: Int16,
                                             state_DeviceButtonPress :: Word16,
                                             same_screen_DeviceButtonPress :: Bool,
                                             device_id_DeviceButtonPress :: Word8}
                       deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event DeviceButtonPress
 
instance Deserialize DeviceButtonPress where
        deserialize
          = do skip 1
               detail <- deserialize
               skip 2
               time <- deserialize
               root <- deserialize
               event <- deserialize
               child <- deserialize
               root_x <- deserialize
               root_y <- deserialize
               event_x <- deserialize
               event_y <- deserialize
               state <- deserialize
               same_screen <- deserialize
               device_id <- deserialize
               return
                 (MkDeviceButtonPress detail time root event child root_x root_y
                    event_x
                    event_y
                    state
                    same_screen
                    device_id)
 
data DeviceButtonRelease = MkDeviceButtonRelease{detail_DeviceButtonRelease
                                                 :: Word8,
                                                 time_DeviceButtonRelease :: TIMESTAMP,
                                                 root_DeviceButtonRelease :: WINDOW,
                                                 event_DeviceButtonRelease :: WINDOW,
                                                 child_DeviceButtonRelease :: WINDOW,
                                                 root_x_DeviceButtonRelease :: Int16,
                                                 root_y_DeviceButtonRelease :: Int16,
                                                 event_x_DeviceButtonRelease :: Int16,
                                                 event_y_DeviceButtonRelease :: Int16,
                                                 state_DeviceButtonRelease :: Word16,
                                                 same_screen_DeviceButtonRelease :: Bool,
                                                 device_id_DeviceButtonRelease :: Word8}
                         deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event DeviceButtonRelease
 
instance Deserialize DeviceButtonRelease where
        deserialize
          = do skip 1
               detail <- deserialize
               skip 2
               time <- deserialize
               root <- deserialize
               event <- deserialize
               child <- deserialize
               root_x <- deserialize
               root_y <- deserialize
               event_x <- deserialize
               event_y <- deserialize
               state <- deserialize
               same_screen <- deserialize
               device_id <- deserialize
               return
                 (MkDeviceButtonRelease detail time root event child root_x root_y
                    event_x
                    event_y
                    state
                    same_screen
                    device_id)
 
data DeviceMotionNotify = MkDeviceMotionNotify{detail_DeviceMotionNotify
                                               :: Word8,
                                               time_DeviceMotionNotify :: TIMESTAMP,
                                               root_DeviceMotionNotify :: WINDOW,
                                               event_DeviceMotionNotify :: WINDOW,
                                               child_DeviceMotionNotify :: WINDOW,
                                               root_x_DeviceMotionNotify :: Int16,
                                               root_y_DeviceMotionNotify :: Int16,
                                               event_x_DeviceMotionNotify :: Int16,
                                               event_y_DeviceMotionNotify :: Int16,
                                               state_DeviceMotionNotify :: Word16,
                                               same_screen_DeviceMotionNotify :: Bool,
                                               device_id_DeviceMotionNotify :: Word8}
                        deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event DeviceMotionNotify
 
instance Deserialize DeviceMotionNotify where
        deserialize
          = do skip 1
               detail <- deserialize
               skip 2
               time <- deserialize
               root <- deserialize
               event <- deserialize
               child <- deserialize
               root_x <- deserialize
               root_y <- deserialize
               event_x <- deserialize
               event_y <- deserialize
               state <- deserialize
               same_screen <- deserialize
               device_id <- deserialize
               return
                 (MkDeviceMotionNotify detail time root event child root_x root_y
                    event_x
                    event_y
                    state
                    same_screen
                    device_id)
 
data ProximityIn = MkProximityIn{detail_ProximityIn :: Word8,
                                 time_ProximityIn :: TIMESTAMP, root_ProximityIn :: WINDOW,
                                 event_ProximityIn :: WINDOW, child_ProximityIn :: WINDOW,
                                 root_x_ProximityIn :: Int16, root_y_ProximityIn :: Int16,
                                 event_x_ProximityIn :: Int16, event_y_ProximityIn :: Int16,
                                 state_ProximityIn :: Word16, same_screen_ProximityIn :: Bool,
                                 device_id_ProximityIn :: Word8}
                 deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event ProximityIn
 
instance Deserialize ProximityIn where
        deserialize
          = do skip 1
               detail <- deserialize
               skip 2
               time <- deserialize
               root <- deserialize
               event <- deserialize
               child <- deserialize
               root_x <- deserialize
               root_y <- deserialize
               event_x <- deserialize
               event_y <- deserialize
               state <- deserialize
               same_screen <- deserialize
               device_id <- deserialize
               return
                 (MkProximityIn detail time root event child root_x root_y event_x
                    event_y
                    state
                    same_screen
                    device_id)
 
data ProximityOut = MkProximityOut{detail_ProximityOut :: Word8,
                                   time_ProximityOut :: TIMESTAMP, root_ProximityOut :: WINDOW,
                                   event_ProximityOut :: WINDOW, child_ProximityOut :: WINDOW,
                                   root_x_ProximityOut :: Int16, root_y_ProximityOut :: Int16,
                                   event_x_ProximityOut :: Int16, event_y_ProximityOut :: Int16,
                                   state_ProximityOut :: Word16, same_screen_ProximityOut :: Bool,
                                   device_id_ProximityOut :: Word8}
                  deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event ProximityOut
 
instance Deserialize ProximityOut where
        deserialize
          = do skip 1
               detail <- deserialize
               skip 2
               time <- deserialize
               root <- deserialize
               event <- deserialize
               child <- deserialize
               root_x <- deserialize
               root_y <- deserialize
               event_x <- deserialize
               event_y <- deserialize
               state <- deserialize
               same_screen <- deserialize
               device_id <- deserialize
               return
                 (MkProximityOut detail time root event child root_x root_y event_x
                    event_y
                    state
                    same_screen
                    device_id)
 
data FocusIn = MkFocusIn{detail_FocusIn :: Word8,
                         time_FocusIn :: TIMESTAMP, window_FocusIn :: WINDOW,
                         mode_FocusIn :: Word8, device_id_FocusIn :: Word8}
             deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event FocusIn
 
instance Deserialize FocusIn where
        deserialize
          = do skip 1
               detail <- deserialize
               skip 2
               time <- deserialize
               window <- deserialize
               mode <- deserialize
               device_id <- deserialize
               skip 18
               return (MkFocusIn detail time window mode device_id)
 
data FocusOut = MkFocusOut{detail_FocusOut :: Word8,
                           time_FocusOut :: TIMESTAMP, root_FocusOut :: WINDOW,
                           event_FocusOut :: WINDOW, child_FocusOut :: WINDOW,
                           root_x_FocusOut :: Int16, root_y_FocusOut :: Int16,
                           event_x_FocusOut :: Int16, event_y_FocusOut :: Int16,
                           state_FocusOut :: Word16, same_screen_FocusOut :: Bool,
                           device_id_FocusOut :: Word8}
              deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event FocusOut
 
instance Deserialize FocusOut where
        deserialize
          = do skip 1
               detail <- deserialize
               skip 2
               time <- deserialize
               root <- deserialize
               event <- deserialize
               child <- deserialize
               root_x <- deserialize
               root_y <- deserialize
               event_x <- deserialize
               event_y <- deserialize
               state <- deserialize
               same_screen <- deserialize
               device_id <- deserialize
               return
                 (MkFocusOut detail time root event child root_x root_y event_x
                    event_y
                    state
                    same_screen
                    device_id)
 
data DeviceStateNotify = MkDeviceStateNotify{device_id_DeviceStateNotify
                                             :: Word8,
                                             time_DeviceStateNotify :: TIMESTAMP,
                                             num_keys_DeviceStateNotify :: Word8,
                                             num_buttons_DeviceStateNotify :: Word8,
                                             num_valuators_DeviceStateNotify :: Word8,
                                             classes_reported_DeviceStateNotify :: Word8,
                                             buttons_DeviceStateNotify :: [Word8],
                                             keys_DeviceStateNotify :: [Word8],
                                             valuators_DeviceStateNotify :: [Word32]}
                       deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event DeviceStateNotify
 
instance Deserialize DeviceStateNotify where
        deserialize
          = do skip 1
               device_id <- deserialize
               skip 2
               time <- deserialize
               num_keys <- deserialize
               num_buttons <- deserialize
               num_valuators <- deserialize
               classes_reported <- deserialize
               buttons <- deserializeList (fromIntegral 4)
               keys <- deserializeList (fromIntegral 4)
               valuators <- deserializeList (fromIntegral 3)
               return
                 (MkDeviceStateNotify device_id time num_keys num_buttons
                    num_valuators
                    classes_reported
                    buttons
                    keys
                    valuators)
 
data DeviceMappingNotify = MkDeviceMappingNotify{device_id_DeviceMappingNotify
                                                 :: Word8,
                                                 request_DeviceMappingNotify :: Word8,
                                                 first_keycode_DeviceMappingNotify :: KeyCode,
                                                 count_DeviceMappingNotify :: Word8,
                                                 time_DeviceMappingNotify :: TIMESTAMP}
                         deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event DeviceMappingNotify
 
instance Deserialize DeviceMappingNotify where
        deserialize
          = do skip 1
               device_id <- deserialize
               skip 2
               request <- deserialize
               first_keycode <- deserialize
               count <- deserialize
               skip 1
               time <- deserialize
               skip 20
               return
                 (MkDeviceMappingNotify device_id request first_keycode count time)
 
data ChangeDeviceNotify = MkChangeDeviceNotify{device_id_ChangeDeviceNotify
                                               :: Word8,
                                               time_ChangeDeviceNotify :: TIMESTAMP,
                                               request_ChangeDeviceNotify :: Word8}
                        deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event ChangeDeviceNotify
 
instance Deserialize ChangeDeviceNotify where
        deserialize
          = do skip 1
               device_id <- deserialize
               skip 2
               time <- deserialize
               request <- deserialize
               skip 23
               return (MkChangeDeviceNotify device_id time request)
 
data DeviceKeyStateNotify = MkDeviceKeyStateNotify{device_id_DeviceKeyStateNotify
                                                   :: Word8,
                                                   keys_DeviceKeyStateNotify :: [Word8]}
                          deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event DeviceKeyStateNotify
 
instance Deserialize DeviceKeyStateNotify where
        deserialize
          = do skip 1
               device_id <- deserialize
               skip 2
               keys <- deserializeList (fromIntegral 28)
               return (MkDeviceKeyStateNotify device_id keys)
 
data DeviceButtonStateNotify = MkDeviceButtonStateNotify{device_id_DeviceButtonStateNotify
                                                         :: Word8,
                                                         buttons_DeviceButtonStateNotify :: [Word8]}
                             deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event DeviceButtonStateNotify
 
instance Deserialize DeviceButtonStateNotify where
        deserialize
          = do skip 1
               device_id <- deserialize
               skip 2
               buttons <- deserializeList (fromIntegral 28)
               return (MkDeviceButtonStateNotify device_id buttons)
 
data DevicePresenceNotify = MkDevicePresenceNotify{time_DevicePresenceNotify
                                                   :: TIMESTAMP,
                                                   devchange_DevicePresenceNotify :: Word8,
                                                   device_id_DevicePresenceNotify :: Word8,
                                                   control_DevicePresenceNotify :: Word16}
                          deriving (Show, Typeable)
 
instance Graphics.XHB.Shared.Event DevicePresenceNotify
 
instance Deserialize DevicePresenceNotify where
        deserialize
          = do skip 1
               skip 1
               skip 2
               time <- deserialize
               devchange <- deserialize
               device_id <- deserialize
               control <- deserialize
               skip 20
               return (MkDevicePresenceNotify time devchange device_id control)