summaryrefslogtreecommitdiffstats
path: root/GLX.hs
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-02-24 03:40:06 +0100
committerMatthias Schiffer <matthias@gamezock.de>2010-02-24 03:40:06 +0100
commit7f12f41e5fce40042f97d167da9a0fb58e5a1651 (patch)
tree7a9ec269c62cc6616850fb2cb522378a3f1155bd /GLX.hs
parent4a6d841bc7e3b17bf399ae2e39d409fe85a6fffb (diff)
downloadhtanks-7f12f41e5fce40042f97d167da9a0fb58e5a1651.tar
htanks-7f12f41e5fce40042f97d167da9a0fb58e5a1651.zip
Added keyboard events
Diffstat (limited to 'GLX.hs')
-rw-r--r--GLX.hs12
1 files changed, 12 insertions, 0 deletions
diff --git a/GLX.hs b/GLX.hs
index f457d78..8a1c52d 100644
--- a/GLX.hs
+++ b/GLX.hs
@@ -118,6 +118,18 @@ handleEvent glx disp xevent = do
keysym <- keycodeToKeysym disp (ev_keycode event) 0
case () of
_ | keysym == xK_Escape -> return $ Just $ SomeEvent QuitEvent
+ | keysym == xK_Up -> return $ Just $ SomeEvent $ KeyPressEvent KeyUp
+ | keysym == xK_Down -> return $ Just $ SomeEvent $ KeyPressEvent KeyDown
+ | keysym == xK_Left -> return $ Just $ SomeEvent $ KeyPressEvent KeyLeft
+ | keysym == xK_Right -> return $ Just $ SomeEvent $ KeyPressEvent KeyRight
+ | otherwise -> return Nothing
+ | evtype == keyRelease -> do
+ keysym <- keycodeToKeysym disp (ev_keycode event) 0
+ case () of
+ _ | keysym == xK_Up -> return $ Just $ SomeEvent $ KeyReleaseEvent KeyUp
+ | keysym == xK_Down -> return $ Just $ SomeEvent $ KeyReleaseEvent KeyDown
+ | keysym == xK_Left -> return $ Just $ SomeEvent $ KeyReleaseEvent KeyLeft
+ | keysym == xK_Right -> return $ Just $ SomeEvent $ KeyReleaseEvent KeyRight
| otherwise -> return Nothing
| evtype == clientMessage -> do
if ((glxDeleteWindow glx) == (fromIntegral . head . ev_data $ event))