{-# LINE 1 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
{-# LANGUAGE CPP #-}
{-# LINE 2 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
{- |
   Module      :  System.Win32.Automation.Input.Key
   Copyright   :  2013 shelarcy
   License     :  BSD-style

   Maintainer  :  shelarcy@gmail.com
   Stability   :  Provisional
   Portability :  Non-portable (Win32 API)

   Keyboard input events
-}
module System.Win32.Automation.Input.Key where
import Foreign.Ptr        ( Ptr )
import Foreign.Storable   ( Storable(..) )
import System.Win32.Types ( ULONG_PTR )
import System.Win32.Word  ( DWORD, WORD )


{-# LINE 20 "System\\Win32\\Automation\\Input\\Key.hsc" #-}

{-# LINE 21 "System\\Win32\\Automation\\Input\\Key.hsc" #-}

{-# LINE 22 "System\\Win32\\Automation\\Input\\Key.hsc" #-}

type PKEYBDINPUT = Ptr KEYBDINPUT

data KEYBDINPUT = KEYBDINPUT
     { wVk         :: WORD
     , wScan       :: WORD
     , dwFlags     :: DWORD
     , time        :: DWORD
     , dwExtraInfo :: ULONG_PTR
     } deriving Show

instance Storable KEYBDINPUT where
    sizeOf = const (24)
{-# LINE 35 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
    alignment _ = (8)
{-# LINE 36 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
    poke buf input = do
        ((\hsc_ptr -> pokeByteOff hsc_ptr 0))     buf (wVk input)
{-# LINE 38 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 2))   buf (wScan input)
{-# LINE 39 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 4)) buf (dwFlags input)
{-# LINE 40 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 8))    buf (time input)
{-# LINE 41 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
        ((\hsc_ptr -> pokeByteOff hsc_ptr 16)) buf (dwExtraInfo input)
{-# LINE 42 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
    peek buf = do
        wVk'         <- ((\hsc_ptr -> peekByteOff hsc_ptr 0)) buf
{-# LINE 44 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
        wScan'       <- ((\hsc_ptr -> peekByteOff hsc_ptr 2)) buf
{-# LINE 45 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
        dwFlags'     <- ((\hsc_ptr -> peekByteOff hsc_ptr 4)) buf
{-# LINE 46 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
        time'        <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) buf
{-# LINE 47 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
        dwExtraInfo' <- ((\hsc_ptr -> peekByteOff hsc_ptr 16)) buf
{-# LINE 48 "System\\Win32\\Automation\\Input\\Key.hsc" #-}
        return $ KEYBDINPUT wVk' wScan' dwFlags' time' dwExtraInfo'

kEYEVENTF_EXTENDEDKEY  :: DWORD
kEYEVENTF_EXTENDEDKEY  =  1
kEYEVENTF_KEYUP        :: DWORD
kEYEVENTF_KEYUP        =  2
kEYEVENTF_SCANCODE     :: DWORD
kEYEVENTF_SCANCODE     =  8
kEYEVENTF_UNICODE      :: DWORD
kEYEVENTF_UNICODE      =  4

{-# LINE 56 "System\\Win32\\Automation\\Input\\Key.hsc" #-}