{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module SDL.Input.Keyboard
(
getModState
, KeyModifier(..)
, getKeyboardState
, startTextInput
, stopTextInput
, hasScreenKeyboardSupport
, isScreenKeyboardShown
, getScancodeName
, Scancode(..)
, Keycode(..)
, Keysym(..)
, 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
getModState :: (Functor m, MonadIO m) => m KeyModifier
getModState :: forall (m :: Type -> Type). (Functor m, MonadIO m) => m KeyModifier
getModState = forall a b. FromNumber a b => b -> a
fromNumber forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (m :: Type -> Type). MonadIO m => m Keymod
Raw.getModState
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
KeyModifier -> DataType
KeyModifier -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: Type -> Type).
MonadPlus 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
gmapM :: forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier
$cgmapM :: forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> KeyModifier -> m KeyModifier
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KeyModifier -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> KeyModifier -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> KeyModifier -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> KeyModifier -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KeyModifier -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> KeyModifier -> r
gmapT :: (forall b. Data b => b -> b) -> KeyModifier -> KeyModifier
$cgmapT :: (forall b. Data b => b -> b) -> KeyModifier -> 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)
$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)
dataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KeyModifier)
$cdataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c KeyModifier)
dataTypeOf :: KeyModifier -> DataType
$cdataTypeOf :: KeyModifier -> DataType
toConstr :: KeyModifier -> Constr
$ctoConstr :: KeyModifier -> Constr
gunfold :: forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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
gfoldl :: forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> KeyModifier -> 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
Data, KeyModifier -> KeyModifier -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: KeyModifier -> KeyModifier -> Bool
$c/= :: KeyModifier -> KeyModifier -> Bool
== :: KeyModifier -> KeyModifier -> Bool
$c== :: KeyModifier -> KeyModifier -> Bool
Eq, Eq 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
min :: KeyModifier -> KeyModifier -> KeyModifier
$cmin :: KeyModifier -> KeyModifier -> KeyModifier
max :: KeyModifier -> KeyModifier -> KeyModifier
$cmax :: KeyModifier -> KeyModifier -> KeyModifier
>= :: KeyModifier -> KeyModifier -> Bool
$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
compare :: KeyModifier -> KeyModifier -> Ordering
$ccompare :: KeyModifier -> KeyModifier -> Ordering
Ord, ReadPrec [KeyModifier]
ReadPrec KeyModifier
Int -> ReadS KeyModifier
ReadS [KeyModifier]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [KeyModifier]
$creadListPrec :: ReadPrec [KeyModifier]
readPrec :: ReadPrec KeyModifier
$creadPrec :: ReadPrec KeyModifier
readList :: ReadS [KeyModifier]
$creadList :: ReadS [KeyModifier]
readsPrec :: Int -> ReadS KeyModifier
$creadsPrec :: Int -> ReadS KeyModifier
Read, 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
$cto :: forall x. Rep KeyModifier x -> KeyModifier
$cfrom :: forall x. KeyModifier -> Rep KeyModifier x
Generic, Int -> KeyModifier -> ShowS
[KeyModifier] -> ShowS
KeyModifier -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [KeyModifier] -> ShowS
$cshowList :: [KeyModifier] -> ShowS
show :: KeyModifier -> String
$cshow :: KeyModifier -> String
showsPrec :: Int -> KeyModifier -> ShowS
$cshowsPrec :: Int -> 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 forall a. Bits a => a -> a -> a
.&. forall {a}. (Eq a, Num a) => a
Raw.KMOD_LSHIFT forall a. Ord a => a -> a -> Bool
> Keymod
0
, keyModifierRightShift :: Bool
keyModifierRightShift = Keymod
m forall a. Bits a => a -> a -> a
.&. forall {a}. (Eq a, Num a) => a
Raw.KMOD_RSHIFT forall a. Ord a => a -> a -> Bool
> Keymod
0
, keyModifierLeftCtrl :: Bool
keyModifierLeftCtrl = Keymod
m forall a. Bits a => a -> a -> a
.&. forall {a}. (Eq a, Num a) => a
Raw.KMOD_LCTRL forall a. Ord a => a -> a -> Bool
> Keymod
0
, keyModifierRightCtrl :: Bool
keyModifierRightCtrl = Keymod
m forall a. Bits a => a -> a -> a
.&. forall {a}. (Eq a, Num a) => a
Raw.KMOD_RCTRL forall a. Ord a => a -> a -> Bool
> Keymod
0
, keyModifierLeftAlt :: Bool
keyModifierLeftAlt = Keymod
m forall a. Bits a => a -> a -> a
.&. forall {a}. (Eq a, Num a) => a
Raw.KMOD_LALT forall a. Ord a => a -> a -> Bool
> Keymod
0
, keyModifierRightAlt :: Bool
keyModifierRightAlt = Keymod
m forall a. Bits a => a -> a -> a
.&. forall {a}. (Eq a, Num a) => a
Raw.KMOD_RALT forall a. Ord a => a -> a -> Bool
> Keymod
0
, keyModifierLeftGUI :: Bool
keyModifierLeftGUI = Keymod
m forall a. Bits a => a -> a -> a
.&. forall {a}. (Eq a, Num a) => a
Raw.KMOD_LGUI forall a. Ord a => a -> a -> Bool
> Keymod
0
, keyModifierRightGUI :: Bool
keyModifierRightGUI = Keymod
m forall a. Bits a => a -> a -> a
.&. forall {a}. (Eq a, Num a) => a
Raw.KMOD_RGUI forall a. Ord a => a -> a -> Bool
> Keymod
0
, keyModifierNumLock :: Bool
keyModifierNumLock = Keymod
m forall a. Bits a => a -> a -> a
.&. forall {a}. (Eq a, Num a) => a
Raw.KMOD_NUM forall a. Ord a => a -> a -> Bool
> Keymod
0
, keyModifierCapsLock :: Bool
keyModifierCapsLock = Keymod
m forall a. Bits a => a -> a -> a
.&. forall {a}. (Eq a, Num a) => a
Raw.KMOD_CAPS forall a. Ord a => a -> a -> Bool
> Keymod
0
, keyModifierAltGr :: Bool
keyModifierAltGr = Keymod
m forall a. Bits a => a -> a -> a
.&. forall {a}. (Eq a, Num a) => a
Raw.KMOD_MODE forall a. Ord a => a -> a -> Bool
> Keymod
0
}
instance ToNumber KeyModifier Word32 where
toNumber :: KeyModifier -> Keymod
toNumber KeyModifier
m = forall (t :: Type -> Type) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr forall a. Bits a => a -> a -> a
(.|.) Keymod
0
[ if KeyModifier -> Bool
keyModifierLeftShift KeyModifier
m then forall {a}. (Eq a, Num a) => a
Raw.KMOD_LSHIFT else Keymod
0
, if KeyModifier -> Bool
keyModifierRightShift KeyModifier
m then forall {a}. (Eq a, Num a) => a
Raw.KMOD_RSHIFT else Keymod
0
, if KeyModifier -> Bool
keyModifierLeftCtrl KeyModifier
m then forall {a}. (Eq a, Num a) => a
Raw.KMOD_LCTRL else Keymod
0
, if KeyModifier -> Bool
keyModifierRightCtrl KeyModifier
m then forall {a}. (Eq a, Num a) => a
Raw.KMOD_RCTRL else Keymod
0
, if KeyModifier -> Bool
keyModifierLeftAlt KeyModifier
m then forall {a}. (Eq a, Num a) => a
Raw.KMOD_LALT else Keymod
0
, if KeyModifier -> Bool
keyModifierRightAlt KeyModifier
m then forall {a}. (Eq a, Num a) => a
Raw.KMOD_RALT else Keymod
0
, if KeyModifier -> Bool
keyModifierLeftGUI KeyModifier
m then forall {a}. (Eq a, Num a) => a
Raw.KMOD_LGUI else Keymod
0
, if KeyModifier -> Bool
keyModifierRightGUI KeyModifier
m then forall {a}. (Eq a, Num a) => a
Raw.KMOD_RGUI else Keymod
0
, if KeyModifier -> Bool
keyModifierNumLock KeyModifier
m then forall {a}. (Eq a, Num a) => a
Raw.KMOD_NUM else Keymod
0
, if KeyModifier -> Bool
keyModifierCapsLock KeyModifier
m then forall {a}. (Eq a, Num a) => a
Raw.KMOD_CAPS else Keymod
0
, if KeyModifier -> Bool
keyModifierAltGr KeyModifier
m then forall {a}. (Eq a, Num a) => a
Raw.KMOD_MODE else Keymod
0
]
startTextInput :: MonadIO m => Raw.Rect -> m ()
startTextInput :: forall (m :: Type -> Type). MonadIO m => Rect -> m ()
startTextInput Rect
rect = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr Rect
ptr -> do
forall a. Storable a => Ptr a -> a -> IO ()
poke Ptr Rect
ptr Rect
rect
forall (m :: Type -> Type). MonadIO m => Ptr Rect -> m ()
Raw.setTextInputRect Ptr Rect
ptr
forall (m :: Type -> Type). MonadIO m => m ()
Raw.startTextInput
stopTextInput :: MonadIO m => m ()
stopTextInput :: forall (m :: Type -> Type). MonadIO m => m ()
stopTextInput = forall (m :: Type -> Type). MonadIO m => m ()
Raw.stopTextInput
hasScreenKeyboardSupport :: MonadIO m => m Bool
hasScreenKeyboardSupport :: forall (m :: Type -> Type). MonadIO m => m Bool
hasScreenKeyboardSupport = forall (m :: Type -> Type). MonadIO m => m Bool
Raw.hasScreenKeyboardSupport
isScreenKeyboardShown :: MonadIO m => Window -> m Bool
isScreenKeyboardShown :: forall (m :: Type -> Type). MonadIO m => Window -> m Bool
isScreenKeyboardShown (Window Window
w) = forall (m :: Type -> Type). MonadIO m => Window -> m Bool
Raw.isScreenKeyboardShown Window
w
getScancodeName :: MonadIO m => Scancode -> m String
getScancodeName :: forall (m :: Type -> Type). MonadIO m => Scancode -> m String
getScancodeName Scancode
scancode = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
CString
name <- forall (m :: Type -> Type). MonadIO m => Keymod -> m CString
Raw.getScancodeName forall a b. (a -> b) -> a -> b
$ forall a b. ToNumber a b => a -> b
toNumber Scancode
scancode
CString -> IO String
peekCString CString
name
data Keysym = Keysym
{ Keysym -> Scancode
keysymScancode :: Scancode
, Keysym -> Keycode
keysymKeycode :: Keycode
, Keysym -> KeyModifier
keysymModifier :: KeyModifier
} deriving (Typeable Keysym
Keysym -> DataType
Keysym -> Constr
(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)
gmapMo :: 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
gmapMp :: forall (m :: Type -> Type).
MonadPlus 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
gmapM :: forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> Keysym -> m Keysym
$cgmapM :: forall (m :: Type -> Type).
Monad m =>
(forall d. Data d => d -> m d) -> Keysym -> m Keysym
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Keysym -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Keysym -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> Keysym -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Keysym -> [u]
gmapQr :: 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
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Keysym -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Keysym -> r
gmapT :: (forall b. Data b => b -> b) -> Keysym -> Keysym
$cgmapT :: (forall b. Data b => b -> b) -> Keysym -> 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)
$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)
dataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Keysym)
$cdataCast1 :: forall (t :: Type -> Type) (c :: Type -> Type).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Keysym)
dataTypeOf :: Keysym -> DataType
$cdataTypeOf :: Keysym -> DataType
toConstr :: Keysym -> Constr
$ctoConstr :: Keysym -> Constr
gunfold :: forall (c :: Type -> Type).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> 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
gfoldl :: forall (c :: Type -> Type).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Keysym -> 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
Data, Keysym -> Keysym -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Keysym -> Keysym -> Bool
$c/= :: Keysym -> Keysym -> Bool
== :: Keysym -> Keysym -> Bool
$c== :: Keysym -> Keysym -> Bool
Eq, 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
$cto :: forall x. Rep Keysym x -> Keysym
$cfrom :: forall x. Keysym -> Rep Keysym x
Generic, Eq 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
min :: Keysym -> Keysym -> Keysym
$cmin :: Keysym -> Keysym -> Keysym
max :: Keysym -> Keysym -> Keysym
$cmax :: Keysym -> Keysym -> Keysym
>= :: Keysym -> Keysym -> Bool
$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
compare :: Keysym -> Keysym -> Ordering
$ccompare :: Keysym -> Keysym -> Ordering
Ord, ReadPrec [Keysym]
ReadPrec Keysym
Int -> ReadS Keysym
ReadS [Keysym]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Keysym]
$creadListPrec :: ReadPrec [Keysym]
readPrec :: ReadPrec Keysym
$creadPrec :: ReadPrec Keysym
readList :: ReadS [Keysym]
$creadList :: ReadS [Keysym]
readsPrec :: Int -> ReadS Keysym
$creadsPrec :: Int -> ReadS Keysym
Read, Int -> Keysym -> ShowS
[Keysym] -> ShowS
Keysym -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Keysym] -> ShowS
$cshowList :: [Keysym] -> ShowS
show :: Keysym -> String
$cshow :: Keysym -> String
showsPrec :: Int -> Keysym -> ShowS
$cshowsPrec :: Int -> Keysym -> ShowS
Show, Typeable)
getKeyboardState :: MonadIO m => m (Scancode -> Bool)
getKeyboardState :: forall (m :: Type -> Type). MonadIO m => m (Scancode -> Bool)
getKeyboardState = forall (m :: Type -> Type) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ do
forall a b. Storable a => (Ptr a -> IO b) -> IO b
alloca forall a b. (a -> b) -> a -> b
$ \Ptr CInt
nkeys -> do
Ptr Word8
keyptr <- forall (m :: Type -> Type). MonadIO m => Ptr CInt -> m (Ptr Word8)
Raw.getKeyboardState Ptr CInt
nkeys
CInt
n <- forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
nkeys
Vector Word8
keys <- forall a. [a] -> Vector a
V.fromList forall (f :: Type -> Type) a b. Functor f => (a -> b) -> f a -> f b
<$> forall a. Storable a => Int -> Ptr a -> IO [a]
peekArray (forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
n) Ptr Word8
keyptr
forall (m :: Type -> Type) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ \Scancode
scancode -> Word8
1 forall a. Eq a => a -> a -> Bool
== Vector Word8
keys forall a. Vector a -> Int -> a
V.! forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a b. ToNumber a b => a -> b
toNumber Scancode
scancode)