    {-# LANGUAGE CPP #-}
    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DeriveGeneric #-}
    {-# LANGUAGE MultiParamTypeClasses #-}

    module SDL.Input.Keyboard
      ( -- * Keyboard Modifiers
        getModState
      , KeyModifier(..)

      , getKeyboardState

      -- * Text Input
      , startTextInput
      , stopTextInput

      -- * Screen Keyboard
      , hasScreenKeyboardSupport
      , isScreenKeyboardShown

      -- * Scancodes
      , getScancodeName
      , Scancode(..)

      -- * Keycodes
      , Keycode(..)

      -- * Keysym
      , Keysym(..)

      -- * Keycodes and Scancodes
      , module SDL.Input.Keyboard.Codes
    ) where

    import Control.Monad.IO.Class (MonadIO, liftIO)
    import Data.Bits
    import Data.Data (Data)
    import Data.Typeable
    import Data.Word
    import Foreign.C.String
    import Foreign.Marshal.Alloc
    import Foreign.Marshal.Array
    import Foreign.Storable
    import GHC.Generics (Generic)
    import SDL.Input.Keyboard.Codes
    import SDL.Internal.Numbered
    import SDL.Internal.Types
    import qualified Data.Vector as V
    import qualified SDL.Raw.Enum as Raw
    import qualified SDL.Raw.Event as Raw
    import qualified SDL.Raw.Types as Raw

    #if !MIN_VERSION_base(4,8,0)
    import Control.Applicative
    #endif

    -- | Get the current key modifier state for the keyboard. The key modifier state is a mask special keys that are held down.
    --
    -- See @<https://wiki.libsdl.org/SDL2/SDL_GetModState SDL_GetModState>@ for C documentation.
    getModState :: (Functor m, MonadIO m) => m KeyModifier
    getModState :: forall (m :: Type -> Type). (Functor m, MonadIO m) => m KeyModifier
    getModState = Keymod -> KeyModifier
    forall a b. FromNumber a b => b -> a
    fromNumber (Keymod -> KeyModifier) -> m Keymod -> m KeyModifier
    forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
    <$> m Keymod
    forall (m :: Type -> Type). MonadIO m => m Keymod
    Raw.getModState

    -- | Information about which keys are currently held down. Use 'getModState' to generate this information.
    data KeyModifier = KeyModifier
      { KeyModifier -> Bool
    keyModifierLeftShift  :: Bool
      , KeyModifier -> Bool
    keyModifierRightShift :: Bool
      , KeyModifier -> Bool
    keyModifierLeftCtrl   :: Bool
      , KeyModifier -> Bool
    keyModifierRightCtrl  :: Bool
      , KeyModifier -> Bool
    keyModifierLeftAlt    :: Bool
      , KeyModifier -> Bool
    keyModifierRightAlt   :: Bool
      , KeyModifier -> Bool
    keyModifierLeftGUI    :: Bool
      , KeyModifier -> Bool
    keyModifierRightGUI   :: Bool
      , KeyModifier -> Bool
    keyModifierNumLock    :: Bool
      , KeyModifier -> Bool
    keyModifierCapsLock   :: Bool
      , KeyModifier -> Bool
    keyModifierAltGr      :: Bool
      } deriving (Typeable KeyModifier
    Typeable KeyModifier =>
    (forall (c :: Type -> Type).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> KeyModifier -> c KeyModifier)
    -> (forall (c :: Type -> Type).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c KeyModifier)
    -> (KeyModifier -> Constr)
    -> (KeyModifier -> DataType)
    -> (forall (t :: Type -> Type) (c :: Type -> Type).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c KeyModifier))
    -> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c KeyModifier))
    -> ((forall b. Data b => b -> b) -> KeyModifier -> KeyModifier)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> KeyModifier -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> KeyModifier -> r)
    -> (forall u. (forall d. Data d => d -> u) -> KeyModifier -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> KeyModifier -> u)
    -> (forall (m :: Type -> Type).
        Monad m =>
        (forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier)
    -> (forall (m :: Type -> Type).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier)
    -> (forall (m :: Type -> Type).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier)
    -> Data KeyModifier
    KeyModifier -> Constr
    KeyModifier -> DataType
    (forall b. Data b => b -> b) -> KeyModifier -> KeyModifier
    forall a.
    Typeable a =>
    (forall (c :: Type -> Type).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: Type -> Type).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: Type -> Type) (c :: Type -> Type).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: Type -> Type).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: Type -> Type).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: Type -> Type).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> KeyModifier -> u
    forall u. (forall d. Data d => d -> u) -> KeyModifier -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> KeyModifier -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> KeyModifier -> r
    forall (m :: Type -> Type).
    Monad m =>
    (forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier
    forall (m :: Type -> Type).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier
    forall (c :: Type -> Type).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c KeyModifier
    forall (c :: Type -> Type).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> KeyModifier -> c KeyModifier
    forall (t :: Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c KeyModifier)
    forall (t :: Type -> Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c KeyModifier)
    $cgfoldl :: forall (c :: Type -> Type).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> KeyModifier -> c KeyModifier
    gfoldl :: forall (c :: Type -> Type).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> KeyModifier -> c KeyModifier
    $cgunfold :: forall (c :: Type -> Type).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c KeyModifier
    gunfold :: forall (c :: Type -> Type).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c KeyModifier
    $ctoConstr :: KeyModifier -> Constr
    toConstr :: KeyModifier -> Constr
    $cdataTypeOf :: KeyModifier -> DataType
    dataTypeOf :: KeyModifier -> DataType
    $cdataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c KeyModifier)
    dataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c KeyModifier)
    $cdataCast2 :: forall (t :: Type -> Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c KeyModifier)
    dataCast2 :: forall (t :: Type -> Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c KeyModifier)
    $cgmapT :: (forall b. Data b => b -> b) -> KeyModifier -> KeyModifier
    gmapT :: (forall b. Data b => b -> b) -> KeyModifier -> KeyModifier
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> KeyModifier -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> KeyModifier -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> KeyModifier -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> KeyModifier -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> KeyModifier -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> KeyModifier -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KeyModifier -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KeyModifier -> u
    $cgmapM :: forall (m :: Type -> Type).
    Monad m =>
    (forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier
    gmapM :: forall (m :: Type -> Type).
    Monad m =>
    (forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier
    $cgmapMp :: forall (m :: Type -> Type).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier
    gmapMp :: forall (m :: Type -> Type).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier
    $cgmapMo :: forall (m :: Type -> Type).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier
    gmapMo :: forall (m :: Type -> Type).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier
    Data, KeyModifier -> KeyModifier -> Bool
    (KeyModifier -> KeyModifier -> Bool)
    -> (KeyModifier -> KeyModifier -> Bool) -> Eq KeyModifier
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: KeyModifier -> KeyModifier -> Bool
    == :: KeyModifier -> KeyModifier -> Bool
    $c/= :: KeyModifier -> KeyModifier -> Bool
    /= :: KeyModifier -> KeyModifier -> Bool
    Eq, Eq KeyModifier
    Eq KeyModifier =>
    (KeyModifier -> KeyModifier -> Ordering)
    -> (KeyModifier -> KeyModifier -> Bool)
    -> (KeyModifier -> KeyModifier -> Bool)
    -> (KeyModifier -> KeyModifier -> Bool)
    -> (KeyModifier -> KeyModifier -> Bool)
    -> (KeyModifier -> KeyModifier -> KeyModifier)
    -> (KeyModifier -> KeyModifier -> KeyModifier)
    -> Ord KeyModifier
    KeyModifier -> KeyModifier -> Bool
    KeyModifier -> KeyModifier -> Ordering
    KeyModifier -> KeyModifier -> KeyModifier
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: KeyModifier -> KeyModifier -> Ordering
    compare :: KeyModifier -> KeyModifier -> Ordering
    $c< :: KeyModifier -> KeyModifier -> Bool
    < :: KeyModifier -> KeyModifier -> Bool
    $c<= :: KeyModifier -> KeyModifier -> Bool
    <= :: KeyModifier -> KeyModifier -> Bool
    $c> :: KeyModifier -> KeyModifier -> Bool
    > :: KeyModifier -> KeyModifier -> Bool
    $c>= :: KeyModifier -> KeyModifier -> Bool
    >= :: KeyModifier -> KeyModifier -> Bool
    $cmax :: KeyModifier -> KeyModifier -> KeyModifier
    max :: KeyModifier -> KeyModifier -> KeyModifier
    $cmin :: KeyModifier -> KeyModifier -> KeyModifier
    min :: KeyModifier -> KeyModifier -> KeyModifier
    Ord, ReadPrec [KeyModifier]
    ReadPrec KeyModifier
    Int -> ReadS KeyModifier
    ReadS [KeyModifier]
    (Int -> ReadS KeyModifier)
    -> ReadS [KeyModifier]
    -> ReadPrec KeyModifier
    -> ReadPrec [KeyModifier]
    -> Read KeyModifier
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS KeyModifier
    readsPrec :: Int -> ReadS KeyModifier
    $creadList :: ReadS [KeyModifier]
    readList :: ReadS [KeyModifier]
    $creadPrec :: ReadPrec KeyModifier
    readPrec :: ReadPrec KeyModifier
    $creadListPrec :: ReadPrec [KeyModifier]
    readListPrec :: ReadPrec [KeyModifier]
    Read, (forall x. KeyModifier -> Rep KeyModifier x)
    -> (forall x. Rep KeyModifier x -> KeyModifier)
    -> Generic KeyModifier
    forall x. Rep KeyModifier x -> KeyModifier
    forall x. KeyModifier -> Rep KeyModifier x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. KeyModifier -> Rep KeyModifier x
    from :: forall x. KeyModifier -> Rep KeyModifier x
    $cto :: forall x. Rep KeyModifier x -> KeyModifier
    to :: forall x. Rep KeyModifier x -> KeyModifier
    Generic, Int -> KeyModifier -> ShowS
    [KeyModifier] -> ShowS
    KeyModifier -> String
    (Int -> KeyModifier -> ShowS)
    -> (KeyModifier -> String)
    -> ([KeyModifier] -> ShowS)
    -> Show KeyModifier
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> KeyModifier -> ShowS
    showsPrec :: Int -> KeyModifier -> ShowS
    $cshow :: KeyModifier -> String
    show :: KeyModifier -> String
    $cshowList :: [KeyModifier] -> ShowS
    showList :: [KeyModifier] -> ShowS
    Show, Typeable)

    instance FromNumber KeyModifier Word32 where
      fromNumber :: Keymod -> KeyModifier
    fromNumber Keymod
    m' = let m :: Keymod
    m = Keymod
    m' in KeyModifier
        { keyModifierLeftShift :: Bool
    keyModifierLeftShift  = Keymod
    m Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    .&. Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_LSHIFT Keymod -> Keymod -> Bool
    forall a. Ord a => a -> a -> Bool
    > Keymod
    0
        , keyModifierRightShift :: Bool
    keyModifierRightShift = Keymod
    m Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    .&. Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_RSHIFT Keymod -> Keymod -> Bool
    forall a. Ord a => a -> a -> Bool
    > Keymod
    0
        , keyModifierLeftCtrl :: Bool
    keyModifierLeftCtrl   = Keymod
    m Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    .&. Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_LCTRL  Keymod -> Keymod -> Bool
    forall a. Ord a => a -> a -> Bool
    > Keymod
    0
        , keyModifierRightCtrl :: Bool
    keyModifierRightCtrl  = Keymod
    m Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    .&. Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_RCTRL  Keymod -> Keymod -> Bool
    forall a. Ord a => a -> a -> Bool
    > Keymod
    0
        , keyModifierLeftAlt :: Bool
    keyModifierLeftAlt    = Keymod
    m Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    .&. Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_LALT   Keymod -> Keymod -> Bool
    forall a. Ord a => a -> a -> Bool
    > Keymod
    0
        , keyModifierRightAlt :: Bool
    keyModifierRightAlt   = Keymod
    m Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    .&. Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_RALT   Keymod -> Keymod -> Bool
    forall a. Ord a => a -> a -> Bool
    > Keymod
    0
        , keyModifierLeftGUI :: Bool
    keyModifierLeftGUI    = Keymod
    m Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    .&. Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_LGUI   Keymod -> Keymod -> Bool
    forall a. Ord a => a -> a -> Bool
    > Keymod
    0
        , keyModifierRightGUI :: Bool
    keyModifierRightGUI   = Keymod
    m Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    .&. Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_RGUI   Keymod -> Keymod -> Bool
    forall a. Ord a => a -> a -> Bool
    > Keymod
    0
        , keyModifierNumLock :: Bool
    keyModifierNumLock    = Keymod
    m Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    .&. Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_NUM    Keymod -> Keymod -> Bool
    forall a. Ord a => a -> a -> Bool
    > Keymod
    0
        , keyModifierCapsLock :: Bool
    keyModifierCapsLock   = Keymod
    m Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    .&. Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_CAPS   Keymod -> Keymod -> Bool
    forall a. Ord a => a -> a -> Bool
    > Keymod
    0
        , keyModifierAltGr :: Bool
    keyModifierAltGr      = Keymod
    m Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    .&. Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_MODE   Keymod -> Keymod -> Bool
    forall a. Ord a => a -> a -> Bool
    > Keymod
    0
        }

    instance ToNumber KeyModifier Word32 where
      toNumber :: KeyModifier -> Keymod
    toNumber KeyModifier
    m = (Keymod -> Keymod -> Keymod) -> Keymod -> [Keymod] -> Keymod
    forall a b. (a -> b -> b) -> b -> [a] -> b
    forall (t :: Type -> Type) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr Keymod -> Keymod -> Keymod
    forall a. Bits a => a -> a -> a
    (.|.) Keymod
    0
        [ if KeyModifier -> Bool
    keyModifierLeftShift KeyModifier
    m  then Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_LSHIFT else Keymod
    0
        , if KeyModifier -> Bool
    keyModifierRightShift KeyModifier
    m then Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_RSHIFT else Keymod
    0
        , if KeyModifier -> Bool
    keyModifierLeftCtrl KeyModifier
    m   then Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_LCTRL  else Keymod
    0
        , if KeyModifier -> Bool
    keyModifierRightCtrl KeyModifier
    m  then Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_RCTRL  else Keymod
    0
        , if KeyModifier -> Bool
    keyModifierLeftAlt KeyModifier
    m    then Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_LALT   else Keymod
    0
        , if KeyModifier -> Bool
    keyModifierRightAlt KeyModifier
    m   then Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_RALT   else Keymod
    0
        , if KeyModifier -> Bool
    keyModifierLeftGUI KeyModifier
    m    then Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_LGUI   else Keymod
    0
        , if KeyModifier -> Bool
    keyModifierRightGUI KeyModifier
    m   then Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_RGUI   else Keymod
    0
        , if KeyModifier -> Bool
    keyModifierNumLock KeyModifier
    m    then Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_NUM    else Keymod
    0
        , if KeyModifier -> Bool
    keyModifierCapsLock KeyModifier
    m   then Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_CAPS   else Keymod
    0
        , if KeyModifier -> Bool
    keyModifierAltGr KeyModifier
    m      then Keymod
    forall {a}. (Eq a, Num a) => a
    Raw.KMOD_MODE   else Keymod
    0
        ]

    -- | Set the rectangle used to type text inputs and start accepting text input
    -- events.
    --
    -- See @<https://wiki.libsdl.org/SDL2/SDL_StartTextInput SDL_StartTextInput>@ for C documentation.
    startTextInput :: MonadIO m => Raw.Rect -> m ()
    startTextInput :: forall (m :: Type -> Type). MonadIO m => Rect -> m ()
    startTextInput Rect
    rect = IO () -> m ()
    forall a. IO a -> m a
    forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
    liftIO (IO () -> m ()) -> IO () -> m ()
    forall a b. (a -> b) -> a -> b
    $ do
      (Ptr Rect -> IO ()) -> IO ()
    forall a b. Storable a => (Ptr a -> IO b) -> IO b
    alloca ((Ptr Rect -> IO ()) -> IO ()) -> (Ptr Rect -> IO ()) -> IO ()
    forall a b. (a -> b) -> a -> b
    $ \Ptr Rect
    ptr -> do
        Ptr Rect -> Rect -> IO ()
    forall a. Storable a => Ptr a -> a -> IO ()
    poke Ptr Rect
    ptr Rect
    rect
        Ptr Rect -> IO ()
    forall (m :: Type -> Type). MonadIO m => Ptr Rect -> m ()
    Raw.setTextInputRect Ptr Rect
    ptr
      IO ()
    forall (m :: Type -> Type). MonadIO m => m ()
    Raw.startTextInput

    -- | Stop receiving any text input events.
    --
    -- See @<https://wiki.libsdl.org/SDL2/SDL_StopTextInput SDL_StopTextInput>@ for C documentation.
    stopTextInput :: MonadIO m => m ()
    stopTextInput :: forall (m :: Type -> Type). MonadIO m => m ()
    stopTextInput = m ()
    forall (m :: Type -> Type). MonadIO m => m ()
    Raw.stopTextInput

    -- | Check whether the platform has screen keyboard support.
    --
    -- See @<https://wiki.libsdl.org/SDL2/SDL_HasScreenKeyboardSupport SDL_HasScreenKeyboardSupport>@ for C documentation.
    hasScreenKeyboardSupport :: MonadIO m => m Bool
    hasScreenKeyboardSupport :: forall (m :: Type -> Type). MonadIO m => m Bool
    hasScreenKeyboardSupport = m Bool
    forall (m :: Type -> Type). MonadIO m => m Bool
    Raw.hasScreenKeyboardSupport

    -- | Check whether the screen keyboard is shown for the given window.
    --
    -- See @<https://wiki.libsdl.org/SDL2/SDL_IsScreenKeyboardShown SDL_IsScreenKeyboardShown>@ for C documentation.
    isScreenKeyboardShown :: MonadIO m => Window -> m Bool
    isScreenKeyboardShown :: forall (m :: Type -> Type). MonadIO m => Window -> m Bool
    isScreenKeyboardShown (Window Window
    w) = Window -> m Bool
    forall (m :: Type -> Type). MonadIO m => Window -> m Bool
    Raw.isScreenKeyboardShown Window
    w

    -- | Get a human-readable name for a scancode. If the scancode doesn't have a name this function returns the empty string.
    --
    -- See @<https://wiki.libsdl.org/SDL2/SDL_GetScancodeName SDL_GetScancodeName>@ for C documentation.
    getScancodeName :: MonadIO m => Scancode -> m String
    getScancodeName :: forall (m :: Type -> Type). MonadIO m => Scancode -> m String
    getScancodeName Scancode
    scancode = IO String -> m String
    forall a. IO a -> m a
    forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
    liftIO (IO String -> m String) -> IO String -> m String
    forall a b. (a -> b) -> a -> b
    $ do
      name <- Keymod -> IO CString
    forall (m :: Type -> Type). MonadIO m => Keymod -> m CString
    Raw.getScancodeName (Keymod -> IO CString) -> Keymod -> IO CString
    forall a b. (a -> b) -> a -> b
    $ Scancode -> Keymod
    forall a b. ToNumber a b => a -> b
    toNumber Scancode
    scancode
      peekCString name

    -- | Information about a key press or key release event.
    data Keysym = Keysym
      { Keysym -> Scancode
    keysymScancode :: Scancode
        -- ^ The keyboard 'Scancode'
      , Keysym -> Keycode
    keysymKeycode  :: Keycode
        -- ^ SDL's virtual key representation for this key
      , Keysym -> KeyModifier
    keysymModifier :: KeyModifier
        -- ^ A set of modifiers that were held at the time this data was generated
      } deriving (Typeable Keysym
    Typeable Keysym =>
    (forall (c :: Type -> Type).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> Keysym -> c Keysym)
    -> (forall (c :: Type -> Type).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c Keysym)
    -> (Keysym -> Constr)
    -> (Keysym -> DataType)
    -> (forall (t :: Type -> Type) (c :: Type -> Type).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c Keysym))
    -> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Keysym))
    -> ((forall b. Data b => b -> b) -> Keysym -> Keysym)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> Keysym -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> Keysym -> r)
    -> (forall u. (forall d. Data d => d -> u) -> Keysym -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> Keysym -> u)
    -> (forall (m :: Type -> Type).
        Monad m =>
        (forall d. Data d => d -> m d) -> Keysym -> m Keysym)
    -> (forall (m :: Type -> Type).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Keysym -> m Keysym)
    -> (forall (m :: Type -> Type).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> Keysym -> m Keysym)
    -> Data Keysym
    Keysym -> Constr
    Keysym -> DataType
    (forall b. Data b => b -> b) -> Keysym -> Keysym
    forall a.
    Typeable a =>
    (forall (c :: Type -> Type).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: Type -> Type).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: Type -> Type) (c :: Type -> Type).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: Type -> Type -> Type) (c :: Type -> Type).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: Type -> Type).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: Type -> Type).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: Type -> Type).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> Keysym -> u
    forall u. (forall d. Data d => d -> u) -> Keysym -> [u]
    forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Keysym -> r
    forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Keysym -> r
    forall (m :: Type -> Type).
    Monad m =>
    (forall d. Data d => d -> m d) -> Keysym -> m Keysym
    forall (m :: Type -> Type).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Keysym -> m Keysym
    forall (c :: Type -> Type).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Keysym
    forall (c :: Type -> Type).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Keysym -> c Keysym
    forall (t :: Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Keysym)
    forall (t :: Type -> Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Keysym)
    $cgfoldl :: forall (c :: Type -> Type).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Keysym -> c Keysym
    gfoldl :: forall (c :: Type -> Type).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Keysym -> c Keysym
    $cgunfold :: forall (c :: Type -> Type).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Keysym
    gunfold :: forall (c :: Type -> Type).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Keysym
    $ctoConstr :: Keysym -> Constr
    toConstr :: Keysym -> Constr
    $cdataTypeOf :: Keysym -> DataType
    dataTypeOf :: Keysym -> DataType
    $cdataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Keysym)
    dataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Keysym)
    $cdataCast2 :: forall (t :: Type -> Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Keysym)
    dataCast2 :: forall (t :: Type -> Type -> Type) (c :: Type -> Type).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Keysym)
    $cgmapT :: (forall b. Data b => b -> b) -> Keysym -> Keysym
    gmapT :: (forall b. Data b => b -> b) -> Keysym -> Keysym
    $cgmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Keysym -> r
    gmapQl :: forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Keysym -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Keysym -> r
    gmapQr :: forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Keysym -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> Keysym -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> Keysym -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Keysym -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Keysym -> u
    $cgmapM :: forall (m :: Type -> Type).
    Monad m =>
    (forall d. Data d => d -> m d) -> Keysym -> m Keysym
    gmapM :: forall (m :: Type -> Type).
    Monad m =>
    (forall d. Data d => d -> m d) -> Keysym -> m Keysym
    $cgmapMp :: forall (m :: Type -> Type).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Keysym -> m Keysym
    gmapMp :: forall (m :: Type -> Type).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Keysym -> m Keysym
    $cgmapMo :: forall (m :: Type -> Type).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Keysym -> m Keysym
    gmapMo :: forall (m :: Type -> Type).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Keysym -> m Keysym
    Data, Keysym -> Keysym -> Bool
    (Keysym -> Keysym -> Bool)
    -> (Keysym -> Keysym -> Bool) -> Eq Keysym
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: Keysym -> Keysym -> Bool
    == :: Keysym -> Keysym -> Bool
    $c/= :: Keysym -> Keysym -> Bool
    /= :: Keysym -> Keysym -> Bool
    Eq, (forall x. Keysym -> Rep Keysym x)
    -> (forall x. Rep Keysym x -> Keysym) -> Generic Keysym
    forall x. Rep Keysym x -> Keysym
    forall x. Keysym -> Rep Keysym x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. Keysym -> Rep Keysym x
    from :: forall x. Keysym -> Rep Keysym x
    $cto :: forall x. Rep Keysym x -> Keysym
    to :: forall x. Rep Keysym x -> Keysym
    Generic, Eq Keysym
    Eq Keysym =>
    (Keysym -> Keysym -> Ordering)
    -> (Keysym -> Keysym -> Bool)
    -> (Keysym -> Keysym -> Bool)
    -> (Keysym -> Keysym -> Bool)
    -> (Keysym -> Keysym -> Bool)
    -> (Keysym -> Keysym -> Keysym)
    -> (Keysym -> Keysym -> Keysym)
    -> Ord Keysym
    Keysym -> Keysym -> Bool
    Keysym -> Keysym -> Ordering
    Keysym -> Keysym -> Keysym
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: Keysym -> Keysym -> Ordering
    compare :: Keysym -> Keysym -> Ordering
    $c< :: Keysym -> Keysym -> Bool
    < :: Keysym -> Keysym -> Bool
    $c<= :: Keysym -> Keysym -> Bool
    <= :: Keysym -> Keysym -> Bool
    $c> :: Keysym -> Keysym -> Bool
    > :: Keysym -> Keysym -> Bool
    $c>= :: Keysym -> Keysym -> Bool
    >= :: Keysym -> Keysym -> Bool
    $cmax :: Keysym -> Keysym -> Keysym
    max :: Keysym -> Keysym -> Keysym
    $cmin :: Keysym -> Keysym -> Keysym
    min :: Keysym -> Keysym -> Keysym
    Ord, ReadPrec [Keysym]
    ReadPrec Keysym
    Int -> ReadS Keysym
    ReadS [Keysym]
    (Int -> ReadS Keysym)
    -> ReadS [Keysym]
    -> ReadPrec Keysym
    -> ReadPrec [Keysym]
    -> Read Keysym
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS Keysym
    readsPrec :: Int -> ReadS Keysym
    $creadList :: ReadS [Keysym]
    readList :: ReadS [Keysym]
    $creadPrec :: ReadPrec Keysym
    readPrec :: ReadPrec Keysym
    $creadListPrec :: ReadPrec [Keysym]
    readListPrec :: ReadPrec [Keysym]
    Read, Int -> Keysym -> ShowS
    [Keysym] -> ShowS
    Keysym -> String
    (Int -> Keysym -> ShowS)
    -> (Keysym -> String) -> ([Keysym] -> ShowS) -> Show Keysym
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> Keysym -> ShowS
    showsPrec :: Int -> Keysym -> ShowS
    $cshow :: Keysym -> String
    show :: Keysym -> String
    $cshowList :: [Keysym] -> ShowS
    showList :: [Keysym] -> ShowS
    Show, Typeable)

    -- | Get a snapshot of the current state of the keyboard.
    --
    -- This computation generates a mapping from 'Scancode' to 'Bool' - evaluating the function at specific 'Scancode's will inform you as to whether or not that key was held down when 'getKeyboardState' was called.
    --
    -- See @<https://wiki.libsdl.org/SDL2/SDL_GetKeyboardState SDL_GetKeyboardState>@ for C documentation.
    getKeyboardState :: MonadIO m => m (Scancode -> Bool)
    getKeyboardState :: forall (m :: Type -> Type). MonadIO m => m (Scancode -> Bool)
    getKeyboardState = IO (Scancode -> Bool) -> m (Scancode -> Bool)
    forall a. IO a -> m a
    forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
    liftIO (IO (Scancode -> Bool) -> m (Scancode -> Bool))
    -> IO (Scancode -> Bool) -> m (Scancode -> Bool)
    forall a b. (a -> b) -> a -> b
    $ do
      (Ptr CInt -> IO (Scancode -> Bool)) -> IO (Scancode -> Bool)
    forall a b. Storable a => (Ptr a -> IO b) -> IO b
    alloca ((Ptr CInt -> IO (Scancode -> Bool)) -> IO (Scancode -> Bool))
    -> (Ptr CInt -> IO (Scancode -> Bool)) -> IO (Scancode -> Bool)
    forall a b. (a -> b) -> a -> b
    $ \Ptr CInt
    nkeys -> do
        keyptr <- Ptr CInt -> IO (Ptr Word8)
    forall (m :: Type -> Type). MonadIO m => Ptr CInt -> m (Ptr Word8)
    Raw.getKeyboardState Ptr CInt
    nkeys
        n <- peek nkeys
        keys <- V.fromList <$> peekArray (fromIntegral n) keyptr
        return $ \Scancode
    scancode -> Word8
    1 Word8 -> Word8 -> Bool
    forall a. Eq a => a -> a -> Bool
    == Vector Word8
    keys Vector Word8 -> Int -> Word8
    forall a. Vector a -> Int -> a
    V.! Keymod -> Int
    forall a b. (Integral a, Num b) => a -> b
    fromIntegral (Scancode -> Keymod
    forall a b. ToNumber a b => a -> b
    toNumber Scancode
    scancode)