diff options
author | 3gg <3gg@shellblade.net> | 2023-03-10 09:30:47 -0800 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2023-03-10 09:30:47 -0800 |
commit | b2b0e12c212a40ef2469f77043573b5569ff9e6d (patch) | |
tree | 2143488908f04414e74f6c36f0e373982f27d32c | |
parent | 6e26564f4235eeea5dda386282e18081db6f8f07 (diff) |
Minor refactoring and formatting.
-rw-r--r-- | Demos/Pong/Main.hs | 34 | ||||
-rw-r--r-- | Demos/Pong/Pong.hs | 16 | ||||
-rw-r--r-- | Spear/App.hs | 10 | ||||
-rw-r--r-- | Spear/Step.hs | 42 | ||||
-rw-r--r-- | Spear/Window.hs | 246 |
5 files changed, 171 insertions, 177 deletions
diff --git a/Demos/Pong/Main.hs b/Demos/Pong/Main.hs index 4dbe0a3..ee0f8d8 100644 --- a/Demos/Pong/Main.hs +++ b/Demos/Pong/Main.hs | |||
@@ -2,20 +2,20 @@ | |||
2 | 2 | ||
3 | module Main where | 3 | module Main where |
4 | 4 | ||
5 | import Data.Maybe (mapMaybe) | 5 | import Data.Maybe (mapMaybe) |
6 | import Graphics.Rendering.OpenGL.GL (($=)) | 6 | import Graphics.Rendering.OpenGL.GL (($=)) |
7 | import Graphics.Rendering.OpenGL.GL qualified as GL | 7 | import qualified Graphics.Rendering.OpenGL.GL as GL |
8 | import Pong | 8 | import Pong |
9 | import Spear.App | 9 | import Spear.App |
10 | import Spear.Game | 10 | import Spear.Game |
11 | import Spear.Math.AABB | 11 | import Spear.Math.AABB |
12 | import Spear.Math.Spatial2 | 12 | import Spear.Math.Spatial2 |
13 | import Spear.Math.Vector | 13 | import Spear.Math.Vector |
14 | import Spear.Window | 14 | import Spear.Window |
15 | 15 | ||
16 | data GameState = GameState | 16 | data GameState = GameState |
17 | { window :: Window, | 17 | { window :: Window, |
18 | world :: [GameObject] | 18 | world :: [GameObject] |
19 | } | 19 | } |
20 | 20 | ||
21 | main = | 21 | main = |
@@ -53,7 +53,7 @@ renderGO go = do | |||
53 | (xmin, ymin, xmax, ymax) = (f2d xmin', f2d ymin', f2d xmax', f2d ymax') | 53 | (xmin, ymin, xmax, ymax) = (f2d xmin', f2d ymin', f2d xmax', f2d ymax') |
54 | GL.preservingMatrix $ do | 54 | GL.preservingMatrix $ do |
55 | GL.translate (GL.Vector3 (f2d xcenter) (f2d ycenter) 0) | 55 | GL.translate (GL.Vector3 (f2d xcenter) (f2d ycenter) 0) |
56 | GL.renderPrimitive (GL.TriangleStrip) $ do | 56 | GL.renderPrimitive GL.TriangleStrip $ do |
57 | GL.vertex (GL.Vertex2 xmin ymax) | 57 | GL.vertex (GL.Vertex2 xmin ymax) |
58 | GL.vertex (GL.Vertex2 xmin ymin) | 58 | GL.vertex (GL.Vertex2 xmin ymin) |
59 | GL.vertex (GL.Vertex2 xmax ymax) | 59 | GL.vertex (GL.Vertex2 xmax ymax) |
@@ -71,13 +71,13 @@ procEvent _ = return () | |||
71 | 71 | ||
72 | translate = mapMaybe translate' | 72 | translate = mapMaybe translate' |
73 | 73 | ||
74 | translate' (KeyDown KEY_LEFT) = Just MoveLeft | 74 | translate' (KeyDown KEY_LEFT) = Just MoveLeft |
75 | translate' (KeyDown KEY_RIGHT) = Just MoveRight | 75 | translate' (KeyDown KEY_RIGHT) = Just MoveRight |
76 | translate' (KeyUp KEY_LEFT) = Just StopLeft | 76 | translate' (KeyUp KEY_LEFT) = Just StopLeft |
77 | translate' (KeyUp KEY_RIGHT) = Just StopRight | 77 | translate' (KeyUp KEY_RIGHT) = Just StopRight |
78 | translate' _ = Nothing | 78 | translate' _ = Nothing |
79 | 79 | ||
80 | exitRequested = any (== (KeyDown KEY_ESC)) | 80 | exitRequested = elem (KeyDown KEY_ESC) |
81 | 81 | ||
82 | f2d :: Float -> GL.GLdouble | 82 | f2d :: Float -> GL.GLdouble |
83 | f2d = realToFrac | 83 | f2d = realToFrac |
diff --git a/Demos/Pong/Pong.hs b/Demos/Pong/Pong.hs index b048bbc..fd7fbeb 100644 --- a/Demos/Pong/Pong.hs +++ b/Demos/Pong/Pong.hs | |||
@@ -7,12 +7,12 @@ module Pong | |||
7 | ) | 7 | ) |
8 | where | 8 | where |
9 | 9 | ||
10 | import Data.Monoid (mconcat) | 10 | import Data.Monoid (mconcat) |
11 | import GHC.Float (double2Float) | 11 | import GHC.Float (double2Float) |
12 | import Spear.Math.AABB | 12 | import Spear.Math.AABB |
13 | import Spear.Math.Spatial2 | 13 | import Spear.Math.Spatial2 |
14 | import Spear.Math.Vector | 14 | import Spear.Math.Vector |
15 | import Spear.Step | 15 | import Spear.Step |
16 | 16 | ||
17 | -- Configuration | 17 | -- Configuration |
18 | 18 | ||
@@ -42,8 +42,8 @@ data GameEvent | |||
42 | -- Game objects | 42 | -- Game objects |
43 | 43 | ||
44 | data GameObject = GameObject | 44 | data GameObject = GameObject |
45 | { aabb :: AABB2, | 45 | { aabb :: AABB2, |
46 | obj :: Obj2, | 46 | obj :: Obj2, |
47 | gostep :: Step [GameObject] [GameEvent] GameObject GameObject | 47 | gostep :: Step [GameObject] [GameEvent] GameObject GameObject |
48 | } | 48 | } |
49 | 49 | ||
diff --git a/Spear/App.hs b/Spear/App.hs index dc17dec..ca9a355 100644 --- a/Spear/App.hs +++ b/Spear/App.hs | |||
@@ -6,11 +6,11 @@ module Spear.App | |||
6 | ) | 6 | ) |
7 | where | 7 | where |
8 | 8 | ||
9 | import Control.Monad | 9 | import Control.Monad |
10 | import GHC.Float | 10 | import GHC.Float |
11 | import Spear.Game | 11 | import Spear.Game |
12 | import Spear.Sys.Timer as Timer | 12 | import Spear.Sys.Timer as Timer |
13 | import Spear.Window | 13 | import Spear.Window |
14 | 14 | ||
15 | maxFPS = 60 | 15 | maxFPS = 60 |
16 | 16 | ||
diff --git a/Spear/Step.hs b/Spear/Step.hs index 7419d9e..609f387 100644 --- a/Spear/Step.hs +++ b/Spear/Step.hs | |||
@@ -26,10 +26,10 @@ module Spear.Step | |||
26 | ) | 26 | ) |
27 | where | 27 | where |
28 | 28 | ||
29 | import Data.List (foldl') | 29 | import Data.List (foldl') |
30 | import Data.Map (Map) | 30 | import Data.Map (Map) |
31 | import qualified Data.Map as Map | 31 | import qualified Data.Map as Map |
32 | import Data.Monoid | 32 | import Data.Monoid |
33 | 33 | ||
34 | type Elapsed = Double | 34 | type Elapsed = Double |
35 | 35 | ||
@@ -51,11 +51,6 @@ instance Semigroup (Step s e a a) where | |||
51 | instance Monoid (Step s e a a) where | 51 | instance Monoid (Step s e a a) where |
52 | mempty = sid | 52 | mempty = sid |
53 | 53 | ||
54 | mappend (Step s1) (Step s2) = Step $ \elapsed dt g e a -> | ||
55 | let (b, s1') = s1 elapsed dt g e a | ||
56 | (c, s2') = s2 elapsed dt g e b | ||
57 | in (c, mappend s1' s2') | ||
58 | |||
59 | -- | Construct a step from a function. | 54 | -- | Construct a step from a function. |
60 | step :: (Elapsed -> Dt -> s -> e -> a -> (b, Step s e a b)) -> Step s e a b | 55 | step :: (Elapsed -> Dt -> s -> e -> a -> (b, Step s e a b)) -> Step s e a b |
61 | step = Step | 56 | step = Step |
@@ -70,11 +65,11 @@ spure f = Step $ \_ _ _ _ x -> (f x, spure f) | |||
70 | 65 | ||
71 | -- | The step that returns the first component in the tuple. | 66 | -- | The step that returns the first component in the tuple. |
72 | sfst :: Step s e (a, b) a | 67 | sfst :: Step s e (a, b) a |
73 | sfst = spure $ \(a, _) -> a | 68 | sfst = spure fst |
74 | 69 | ||
75 | -- | The step that returns the second component in the tuple. | 70 | -- | The step that returns the second component in the tuple. |
76 | ssnd :: Step s e (a, b) b | 71 | ssnd :: Step s e (a, b) b |
77 | ssnd = spure $ \(_, b) -> b | 72 | ssnd = spure snd |
78 | 73 | ||
79 | -- | Construct a step that folds a given list of inputs. | 74 | -- | Construct a step that folds a given list of inputs. |
80 | -- | 75 | -- |
@@ -97,7 +92,7 @@ sfold' :: | |||
97 | a -> | 92 | a -> |
98 | [e] -> | 93 | [e] -> |
99 | (a, Step s (Maybe e) a a) | 94 | (a, Step s (Maybe e) a a) |
100 | sfold' elapsed dt g s a es = foldl' f (a', s') es | 95 | sfold' elapsed dt g s a = foldl' f (a', s') |
101 | where | 96 | where |
102 | f (a, s) e = runStep s elapsed dt g (Just e) a | 97 | f (a, s) e = runStep s elapsed dt g (Just e) a |
103 | (a', s') = runStep s elapsed dt g Nothing a | 98 | (a', s') = runStep s elapsed dt g Nothing a |
@@ -128,19 +123,19 @@ szip f (Step s1) (Step s2) = Step $ \elapsed dt g e d -> | |||
128 | switch :: | 123 | switch :: |
129 | Eq e => | 124 | Eq e => |
130 | e -> | 125 | e -> |
131 | (Step s (Maybe e) a a) -> | 126 | Step s (Maybe e) a a -> |
132 | e -> | 127 | e -> |
133 | (Step s (Maybe e) a a) -> | 128 | Step s (Maybe e) a a -> |
134 | Step s (Maybe e) a a | 129 | Step s (Maybe e) a a |
135 | switch flag1 s1 flag2 s2 = switch' s1 flag1 s1 flag2 s2 | 130 | switch flag1 s1 flag2 s2 = switch' s1 flag1 s1 flag2 s2 |
136 | 131 | ||
137 | switch' :: | 132 | switch' :: |
138 | Eq e => | 133 | Eq e => |
139 | (Step s (Maybe e) a a) -> | 134 | Step s (Maybe e) a a -> |
140 | e -> | 135 | e -> |
141 | (Step s (Maybe e) a a) -> | 136 | Step s (Maybe e) a a -> |
142 | e -> | 137 | e -> |
143 | (Step s (Maybe e) a a) -> | 138 | Step s (Maybe e) a a -> |
144 | Step s (Maybe e) a a | 139 | Step s (Maybe e) a a |
145 | switch' cur flag1 s1 flag2 s2 = Step $ \elapsed dt g e a -> | 140 | switch' cur flag1 s1 flag2 s2 = Step $ \elapsed dt g e a -> |
146 | case e of | 141 | case e of |
@@ -148,13 +143,10 @@ switch' cur flag1 s1 flag2 s2 = Step $ \elapsed dt g e a -> | |||
148 | let (a', s') = runStep cur elapsed dt g Nothing a | 143 | let (a', s') = runStep cur elapsed dt g Nothing a |
149 | in (a', switch' s' flag1 s1 flag2 s2) | 144 | in (a', switch' s' flag1 s1 flag2 s2) |
150 | Just e' -> | 145 | Just e' -> |
151 | let next = | 146 | let next |
152 | if e' == flag1 | 147 | | e' == flag1 = s1 |
153 | then s1 | 148 | | e' == flag2 = s2 |
154 | else | 149 | | otherwise = cur |
155 | if e' == flag2 | ||
156 | then s2 | ||
157 | else cur | ||
158 | (a', s') = runStep next elapsed dt g e a | 150 | (a', s') = runStep next elapsed dt g e a |
159 | in (a', switch' s' flag1 s1 flag2 s2) | 151 | in (a', switch' s' flag1 s1 flag2 s2) |
160 | 152 | ||
@@ -179,6 +171,6 @@ multiSwitch' curKey cur m = Step $ \elapsed dt g e a -> | |||
179 | Just s -> | 171 | Just s -> |
180 | let (a', s') = runStep s elapsed dt g e a | 172 | let (a', s') = runStep s elapsed dt g e a |
181 | m' = case curKey of | 173 | m' = case curKey of |
182 | Nothing -> m | 174 | Nothing -> m |
183 | Just key -> Map.insert key cur m | 175 | Just key -> Map.insert key cur m |
184 | in (a', multiSwitch' e s' m') | 176 | in (a', multiSwitch' e s' m') |
diff --git a/Spear/Window.hs b/Spear/Window.hs index a6471b0..ec90a2f 100644 --- a/Spear/Window.hs +++ b/Spear/Window.hs | |||
@@ -28,12 +28,12 @@ module Spear.Window | |||
28 | ) | 28 | ) |
29 | where | 29 | where |
30 | 30 | ||
31 | import Control.Concurrent.MVar | 31 | import Control.Concurrent.MVar |
32 | import Control.Exception | 32 | import Control.Exception |
33 | import Control.Monad (foldM, unless, void, when) | 33 | import Control.Monad (foldM, unless, void, when) |
34 | import Data.Maybe (fromJust, fromMaybe, isJust) | 34 | import Data.Maybe (fromJust, fromMaybe, isJust) |
35 | import qualified Graphics.UI.GLFW as GLFW | 35 | import qualified Graphics.UI.GLFW as GLFW |
36 | import Spear.Game | 36 | import Spear.Game |
37 | 37 | ||
38 | type Width = Int | 38 | type Width = Int |
39 | 39 | ||
@@ -59,9 +59,9 @@ instance Exception WindowException | |||
59 | 59 | ||
60 | -- | A window. | 60 | -- | A window. |
61 | data Window = Window | 61 | data Window = Window |
62 | { glfwWindow :: GLFW.Window, | 62 | { glfwWindow :: GLFW.Window, |
63 | closeRequest :: CloseRequest, | 63 | closeRequest :: CloseRequest, |
64 | inputEvents :: MVar [InputEvent] | 64 | inputEvents :: MVar [InputEvent] |
65 | } | 65 | } |
66 | 66 | ||
67 | withWindow :: | 67 | withWindow :: |
@@ -118,7 +118,7 @@ pollEvents window = do | |||
118 | GLFW.pollEvents | 118 | GLFW.pollEvents |
119 | events <- | 119 | events <- |
120 | tryTakeMVar (inputEvents window) >>= \xs -> case xs of | 120 | tryTakeMVar (inputEvents window) >>= \xs -> case xs of |
121 | Nothing -> return [] | 121 | Nothing -> return [] |
122 | Just events -> return events | 122 | Just events -> return events |
123 | putMVar (inputEvents window) [] | 123 | putMVar (inputEvents window) [] |
124 | return events | 124 | return events |
@@ -154,14 +154,14 @@ onMouseButton events window button GLFW.MouseButtonState'Pressed _ = addEvent ev | |||
154 | onMouseButton events window button GLFW.MouseButtonState'Released _ = addEvent events $ MouseUp (fromGLFWbutton button) | 154 | onMouseButton events window button GLFW.MouseButtonState'Released _ = addEvent events $ MouseUp (fromGLFWbutton button) |
155 | 155 | ||
156 | onMouseMove :: MVar [InputEvent] -> IO GLFW.CursorPosCallback | 156 | onMouseMove :: MVar [InputEvent] -> IO GLFW.CursorPosCallback |
157 | onMouseMove events = newEmptyMVar >>= return . flip onMouseMove' events | 157 | onMouseMove events = newEmptyMVar <&> flip onMouseMove' events |
158 | 158 | ||
159 | onMouseMove' :: MVar MousePos -> MVar [InputEvent] -> GLFW.CursorPosCallback | 159 | onMouseMove' :: MVar MousePos -> MVar [InputEvent] -> GLFW.CursorPosCallback |
160 | onMouseMove' oldPos events window x y = do | 160 | onMouseMove' oldPos events window x y = do |
161 | (old_x, old_y) <- | 161 | (old_x, old_y) <- |
162 | tryTakeMVar oldPos >>= \old -> case old of | 162 | tryTakeMVar oldPos >>= \old -> case old of |
163 | Nothing -> return (x, y) | 163 | Nothing -> return (x, y) |
164 | Just p -> return p | 164 | Just p -> return p |
165 | let delta = (x - old_x, y - old_y) | 165 | let delta = (x - old_x, y - old_y) |
166 | putMVar oldPos (x, y) | 166 | putMVar oldPos (x, y) |
167 | addEvent events $ MouseMove (x, y) delta | 167 | addEvent events $ MouseMove (x, y) delta |
@@ -172,7 +172,7 @@ replaceMVar mvar val = tryTakeMVar mvar >> putMVar mvar val | |||
172 | addEvent :: MVar [a] -> a -> IO () | 172 | addEvent :: MVar [a] -> a -> IO () |
173 | addEvent mvar val = | 173 | addEvent mvar val = |
174 | tryTakeMVar mvar >>= \xs -> case xs of | 174 | tryTakeMVar mvar >>= \xs -> case xs of |
175 | Nothing -> putMVar mvar [val] | 175 | Nothing -> putMVar mvar [val] |
176 | Just events -> putMVar mvar (val : events) | 176 | Just events -> putMVar mvar (val : events) |
177 | 177 | ||
178 | -- Input | 178 | -- Input |
@@ -198,7 +198,8 @@ processKeys window = foldM f [] | |||
198 | f acc (key, result) = do | 198 | f acc (key, result) = do |
199 | isDown <- | 199 | isDown <- |
200 | fmap (== GLFW.KeyState'Pressed) $ | 200 | fmap (== GLFW.KeyState'Pressed) $ |
201 | gameIO . GLFW.getKey window . toGLFWkey $ key | 201 | gameIO . GLFW.getKey window . toGLFWkey $ |
202 | key | ||
202 | return $ if isDown then result : acc else acc | 203 | return $ if isDown then result : acc else acc |
203 | 204 | ||
204 | -- | Process the mouse buttons, returning those values for which their | 205 | -- | Process the mouse buttons, returning those values for which their |
@@ -209,7 +210,8 @@ processButtons window = foldM f [] | |||
209 | f acc (button, result) = do | 210 | f acc (button, result) = do |
210 | isDown <- | 211 | isDown <- |
211 | fmap (== GLFW.MouseButtonState'Pressed) $ | 212 | fmap (== GLFW.MouseButtonState'Pressed) $ |
212 | gameIO . GLFW.getMouseButton window . toGLFWbutton $ button | 213 | gameIO . GLFW.getMouseButton window . toGLFWbutton $ |
214 | button | ||
213 | return $ if isDown then result : acc else acc | 215 | return $ if isDown then result : acc else acc |
214 | 216 | ||
215 | data InputEvent | 217 | data InputEvent |
@@ -290,61 +292,61 @@ type MousePos = (Double, Double) | |||
290 | type MouseDelta = (Double, Double) | 292 | type MouseDelta = (Double, Double) |
291 | 293 | ||
292 | fromGLFWkey :: GLFW.Key -> Key | 294 | fromGLFWkey :: GLFW.Key -> Key |
293 | fromGLFWkey GLFW.Key'A = KEY_A | 295 | fromGLFWkey GLFW.Key'A = KEY_A |
294 | fromGLFWkey GLFW.Key'B = KEY_B | 296 | fromGLFWkey GLFW.Key'B = KEY_B |
295 | fromGLFWkey GLFW.Key'C = KEY_C | 297 | fromGLFWkey GLFW.Key'C = KEY_C |
296 | fromGLFWkey GLFW.Key'D = KEY_D | 298 | fromGLFWkey GLFW.Key'D = KEY_D |
297 | fromGLFWkey GLFW.Key'E = KEY_E | 299 | fromGLFWkey GLFW.Key'E = KEY_E |
298 | fromGLFWkey GLFW.Key'F = KEY_F | 300 | fromGLFWkey GLFW.Key'F = KEY_F |
299 | fromGLFWkey GLFW.Key'G = KEY_G | 301 | fromGLFWkey GLFW.Key'G = KEY_G |
300 | fromGLFWkey GLFW.Key'H = KEY_H | 302 | fromGLFWkey GLFW.Key'H = KEY_H |
301 | fromGLFWkey GLFW.Key'I = KEY_I | 303 | fromGLFWkey GLFW.Key'I = KEY_I |
302 | fromGLFWkey GLFW.Key'J = KEY_J | 304 | fromGLFWkey GLFW.Key'J = KEY_J |
303 | fromGLFWkey GLFW.Key'K = KEY_K | 305 | fromGLFWkey GLFW.Key'K = KEY_K |
304 | fromGLFWkey GLFW.Key'L = KEY_L | 306 | fromGLFWkey GLFW.Key'L = KEY_L |
305 | fromGLFWkey GLFW.Key'M = KEY_M | 307 | fromGLFWkey GLFW.Key'M = KEY_M |
306 | fromGLFWkey GLFW.Key'N = KEY_N | 308 | fromGLFWkey GLFW.Key'N = KEY_N |
307 | fromGLFWkey GLFW.Key'O = KEY_O | 309 | fromGLFWkey GLFW.Key'O = KEY_O |
308 | fromGLFWkey GLFW.Key'P = KEY_P | 310 | fromGLFWkey GLFW.Key'P = KEY_P |
309 | fromGLFWkey GLFW.Key'Q = KEY_Q | 311 | fromGLFWkey GLFW.Key'Q = KEY_Q |
310 | fromGLFWkey GLFW.Key'R = KEY_R | 312 | fromGLFWkey GLFW.Key'R = KEY_R |
311 | fromGLFWkey GLFW.Key'S = KEY_S | 313 | fromGLFWkey GLFW.Key'S = KEY_S |
312 | fromGLFWkey GLFW.Key'T = KEY_T | 314 | fromGLFWkey GLFW.Key'T = KEY_T |
313 | fromGLFWkey GLFW.Key'U = KEY_U | 315 | fromGLFWkey GLFW.Key'U = KEY_U |
314 | fromGLFWkey GLFW.Key'V = KEY_V | 316 | fromGLFWkey GLFW.Key'V = KEY_V |
315 | fromGLFWkey GLFW.Key'W = KEY_W | 317 | fromGLFWkey GLFW.Key'W = KEY_W |
316 | fromGLFWkey GLFW.Key'X = KEY_X | 318 | fromGLFWkey GLFW.Key'X = KEY_X |
317 | fromGLFWkey GLFW.Key'Y = KEY_Y | 319 | fromGLFWkey GLFW.Key'Y = KEY_Y |
318 | fromGLFWkey GLFW.Key'Z = KEY_Z | 320 | fromGLFWkey GLFW.Key'Z = KEY_Z |
319 | fromGLFWkey GLFW.Key'0 = KEY_0 | 321 | fromGLFWkey GLFW.Key'0 = KEY_0 |
320 | fromGLFWkey GLFW.Key'1 = KEY_1 | 322 | fromGLFWkey GLFW.Key'1 = KEY_1 |
321 | fromGLFWkey GLFW.Key'2 = KEY_2 | 323 | fromGLFWkey GLFW.Key'2 = KEY_2 |
322 | fromGLFWkey GLFW.Key'3 = KEY_3 | 324 | fromGLFWkey GLFW.Key'3 = KEY_3 |
323 | fromGLFWkey GLFW.Key'4 = KEY_4 | 325 | fromGLFWkey GLFW.Key'4 = KEY_4 |
324 | fromGLFWkey GLFW.Key'5 = KEY_5 | 326 | fromGLFWkey GLFW.Key'5 = KEY_5 |
325 | fromGLFWkey GLFW.Key'6 = KEY_6 | 327 | fromGLFWkey GLFW.Key'6 = KEY_6 |
326 | fromGLFWkey GLFW.Key'7 = KEY_7 | 328 | fromGLFWkey GLFW.Key'7 = KEY_7 |
327 | fromGLFWkey GLFW.Key'8 = KEY_8 | 329 | fromGLFWkey GLFW.Key'8 = KEY_8 |
328 | fromGLFWkey GLFW.Key'9 = KEY_9 | 330 | fromGLFWkey GLFW.Key'9 = KEY_9 |
329 | fromGLFWkey GLFW.Key'Space = KEY_SPACE | 331 | fromGLFWkey GLFW.Key'Space = KEY_SPACE |
330 | fromGLFWkey GLFW.Key'F1 = KEY_F1 | 332 | fromGLFWkey GLFW.Key'F1 = KEY_F1 |
331 | fromGLFWkey GLFW.Key'F2 = KEY_F2 | 333 | fromGLFWkey GLFW.Key'F2 = KEY_F2 |
332 | fromGLFWkey GLFW.Key'F3 = KEY_F3 | 334 | fromGLFWkey GLFW.Key'F3 = KEY_F3 |
333 | fromGLFWkey GLFW.Key'F4 = KEY_F4 | 335 | fromGLFWkey GLFW.Key'F4 = KEY_F4 |
334 | fromGLFWkey GLFW.Key'F5 = KEY_F5 | 336 | fromGLFWkey GLFW.Key'F5 = KEY_F5 |
335 | fromGLFWkey GLFW.Key'F6 = KEY_F6 | 337 | fromGLFWkey GLFW.Key'F6 = KEY_F6 |
336 | fromGLFWkey GLFW.Key'F7 = KEY_F7 | 338 | fromGLFWkey GLFW.Key'F7 = KEY_F7 |
337 | fromGLFWkey GLFW.Key'F8 = KEY_F8 | 339 | fromGLFWkey GLFW.Key'F8 = KEY_F8 |
338 | fromGLFWkey GLFW.Key'F9 = KEY_F9 | 340 | fromGLFWkey GLFW.Key'F9 = KEY_F9 |
339 | fromGLFWkey GLFW.Key'F10 = KEY_F10 | 341 | fromGLFWkey GLFW.Key'F10 = KEY_F10 |
340 | fromGLFWkey GLFW.Key'F11 = KEY_F11 | 342 | fromGLFWkey GLFW.Key'F11 = KEY_F11 |
341 | fromGLFWkey GLFW.Key'F12 = KEY_F12 | 343 | fromGLFWkey GLFW.Key'F12 = KEY_F12 |
342 | fromGLFWkey GLFW.Key'Escape = KEY_ESC | 344 | fromGLFWkey GLFW.Key'Escape = KEY_ESC |
343 | fromGLFWkey GLFW.Key'Up = KEY_UP | 345 | fromGLFWkey GLFW.Key'Up = KEY_UP |
344 | fromGLFWkey GLFW.Key'Down = KEY_DOWN | 346 | fromGLFWkey GLFW.Key'Down = KEY_DOWN |
345 | fromGLFWkey GLFW.Key'Left = KEY_LEFT | 347 | fromGLFWkey GLFW.Key'Left = KEY_LEFT |
346 | fromGLFWkey GLFW.Key'Right = KEY_RIGHT | 348 | fromGLFWkey GLFW.Key'Right = KEY_RIGHT |
347 | fromGLFWkey _ = KEY_UNKNOWN | 349 | fromGLFWkey _ = KEY_UNKNOWN |
348 | 350 | ||
349 | -- https://www.glfw.org/docs/3.3/group__buttons.html | 351 | -- https://www.glfw.org/docs/3.3/group__buttons.html |
350 | fromGLFWbutton :: GLFW.MouseButton -> MouseButton | 352 | fromGLFWbutton :: GLFW.MouseButton -> MouseButton |
@@ -353,60 +355,60 @@ fromGLFWbutton GLFW.MouseButton'2 = RMB | |||
353 | fromGLFWbutton GLFW.MouseButton'3 = MMB | 355 | fromGLFWbutton GLFW.MouseButton'3 = MMB |
354 | 356 | ||
355 | toGLFWkey :: Key -> GLFW.Key | 357 | toGLFWkey :: Key -> GLFW.Key |
356 | toGLFWkey KEY_A = GLFW.Key'A | 358 | toGLFWkey KEY_A = GLFW.Key'A |
357 | toGLFWkey KEY_B = GLFW.Key'B | 359 | toGLFWkey KEY_B = GLFW.Key'B |
358 | toGLFWkey KEY_C = GLFW.Key'C | 360 | toGLFWkey KEY_C = GLFW.Key'C |
359 | toGLFWkey KEY_D = GLFW.Key'D | 361 | toGLFWkey KEY_D = GLFW.Key'D |
360 | toGLFWkey KEY_E = GLFW.Key'E | 362 | toGLFWkey KEY_E = GLFW.Key'E |
361 | toGLFWkey KEY_F = GLFW.Key'F | 363 | toGLFWkey KEY_F = GLFW.Key'F |
362 | toGLFWkey KEY_G = GLFW.Key'G | 364 | toGLFWkey KEY_G = GLFW.Key'G |
363 | toGLFWkey KEY_H = GLFW.Key'H | 365 | toGLFWkey KEY_H = GLFW.Key'H |
364 | toGLFWkey KEY_I = GLFW.Key'I | 366 | toGLFWkey KEY_I = GLFW.Key'I |
365 | toGLFWkey KEY_J = GLFW.Key'J | 367 | toGLFWkey KEY_J = GLFW.Key'J |
366 | toGLFWkey KEY_K = GLFW.Key'K | 368 | toGLFWkey KEY_K = GLFW.Key'K |
367 | toGLFWkey KEY_L = GLFW.Key'L | 369 | toGLFWkey KEY_L = GLFW.Key'L |
368 | toGLFWkey KEY_M = GLFW.Key'M | 370 | toGLFWkey KEY_M = GLFW.Key'M |
369 | toGLFWkey KEY_N = GLFW.Key'N | 371 | toGLFWkey KEY_N = GLFW.Key'N |
370 | toGLFWkey KEY_O = GLFW.Key'O | 372 | toGLFWkey KEY_O = GLFW.Key'O |
371 | toGLFWkey KEY_P = GLFW.Key'P | 373 | toGLFWkey KEY_P = GLFW.Key'P |
372 | toGLFWkey KEY_Q = GLFW.Key'Q | 374 | toGLFWkey KEY_Q = GLFW.Key'Q |
373 | toGLFWkey KEY_R = GLFW.Key'R | 375 | toGLFWkey KEY_R = GLFW.Key'R |
374 | toGLFWkey KEY_S = GLFW.Key'S | 376 | toGLFWkey KEY_S = GLFW.Key'S |
375 | toGLFWkey KEY_T = GLFW.Key'T | 377 | toGLFWkey KEY_T = GLFW.Key'T |
376 | toGLFWkey KEY_U = GLFW.Key'U | 378 | toGLFWkey KEY_U = GLFW.Key'U |
377 | toGLFWkey KEY_V = GLFW.Key'V | 379 | toGLFWkey KEY_V = GLFW.Key'V |
378 | toGLFWkey KEY_W = GLFW.Key'W | 380 | toGLFWkey KEY_W = GLFW.Key'W |
379 | toGLFWkey KEY_X = GLFW.Key'X | 381 | toGLFWkey KEY_X = GLFW.Key'X |
380 | toGLFWkey KEY_Y = GLFW.Key'Y | 382 | toGLFWkey KEY_Y = GLFW.Key'Y |
381 | toGLFWkey KEY_Z = GLFW.Key'Z | 383 | toGLFWkey KEY_Z = GLFW.Key'Z |
382 | toGLFWkey KEY_0 = GLFW.Key'0 | 384 | toGLFWkey KEY_0 = GLFW.Key'0 |
383 | toGLFWkey KEY_1 = GLFW.Key'1 | 385 | toGLFWkey KEY_1 = GLFW.Key'1 |
384 | toGLFWkey KEY_2 = GLFW.Key'2 | 386 | toGLFWkey KEY_2 = GLFW.Key'2 |
385 | toGLFWkey KEY_3 = GLFW.Key'3 | 387 | toGLFWkey KEY_3 = GLFW.Key'3 |
386 | toGLFWkey KEY_4 = GLFW.Key'4 | 388 | toGLFWkey KEY_4 = GLFW.Key'4 |
387 | toGLFWkey KEY_5 = GLFW.Key'5 | 389 | toGLFWkey KEY_5 = GLFW.Key'5 |
388 | toGLFWkey KEY_6 = GLFW.Key'6 | 390 | toGLFWkey KEY_6 = GLFW.Key'6 |
389 | toGLFWkey KEY_7 = GLFW.Key'7 | 391 | toGLFWkey KEY_7 = GLFW.Key'7 |
390 | toGLFWkey KEY_8 = GLFW.Key'8 | 392 | toGLFWkey KEY_8 = GLFW.Key'8 |
391 | toGLFWkey KEY_9 = GLFW.Key'9 | 393 | toGLFWkey KEY_9 = GLFW.Key'9 |
392 | toGLFWkey KEY_SPACE = GLFW.Key'Space | 394 | toGLFWkey KEY_SPACE = GLFW.Key'Space |
393 | toGLFWkey KEY_F1 = GLFW.Key'F1 | 395 | toGLFWkey KEY_F1 = GLFW.Key'F1 |
394 | toGLFWkey KEY_F2 = GLFW.Key'F2 | 396 | toGLFWkey KEY_F2 = GLFW.Key'F2 |
395 | toGLFWkey KEY_F3 = GLFW.Key'F3 | 397 | toGLFWkey KEY_F3 = GLFW.Key'F3 |
396 | toGLFWkey KEY_F4 = GLFW.Key'F4 | 398 | toGLFWkey KEY_F4 = GLFW.Key'F4 |
397 | toGLFWkey KEY_F5 = GLFW.Key'F5 | 399 | toGLFWkey KEY_F5 = GLFW.Key'F5 |
398 | toGLFWkey KEY_F6 = GLFW.Key'F6 | 400 | toGLFWkey KEY_F6 = GLFW.Key'F6 |
399 | toGLFWkey KEY_F7 = GLFW.Key'F7 | 401 | toGLFWkey KEY_F7 = GLFW.Key'F7 |
400 | toGLFWkey KEY_F8 = GLFW.Key'F8 | 402 | toGLFWkey KEY_F8 = GLFW.Key'F8 |
401 | toGLFWkey KEY_F9 = GLFW.Key'F9 | 403 | toGLFWkey KEY_F9 = GLFW.Key'F9 |
402 | toGLFWkey KEY_F10 = GLFW.Key'F10 | 404 | toGLFWkey KEY_F10 = GLFW.Key'F10 |
403 | toGLFWkey KEY_F11 = GLFW.Key'F11 | 405 | toGLFWkey KEY_F11 = GLFW.Key'F11 |
404 | toGLFWkey KEY_F12 = GLFW.Key'F12 | 406 | toGLFWkey KEY_F12 = GLFW.Key'F12 |
405 | toGLFWkey KEY_ESC = GLFW.Key'Escape | 407 | toGLFWkey KEY_ESC = GLFW.Key'Escape |
406 | toGLFWkey KEY_UP = GLFW.Key'Up | 408 | toGLFWkey KEY_UP = GLFW.Key'Up |
407 | toGLFWkey KEY_DOWN = GLFW.Key'Down | 409 | toGLFWkey KEY_DOWN = GLFW.Key'Down |
408 | toGLFWkey KEY_LEFT = GLFW.Key'Left | 410 | toGLFWkey KEY_LEFT = GLFW.Key'Left |
409 | toGLFWkey KEY_RIGHT = GLFW.Key'Right | 411 | toGLFWkey KEY_RIGHT = GLFW.Key'Right |
410 | toGLFWkey KEY_UNKNOWN = GLFW.Key'Unknown | 412 | toGLFWkey KEY_UNKNOWN = GLFW.Key'Unknown |
411 | 413 | ||
412 | -- https://www.glfw.org/docs/3.3/group__buttons.html | 414 | -- https://www.glfw.org/docs/3.3/group__buttons.html |