mirror of
https://github.com/dpiponi/Stellarator.git
synced 2024-06-01 02:37:48 -04:00
Factored out key callback
This commit is contained in:
parent
77df11a71b
commit
44f4c93a6b
|
@ -25,10 +25,8 @@ import Keys
|
|||
import Memory
|
||||
import Metrics
|
||||
import Stella
|
||||
-- import SDL.Event
|
||||
import Step
|
||||
import System.Console.CmdArgs hiding ((+=))
|
||||
-- import qualified SDL
|
||||
import Graphics.UI.GLFW
|
||||
import Data.IORef
|
||||
import Data.Dequeue
|
||||
|
|
|
@ -202,6 +202,11 @@ vertices = V.fromList [ -1.0, -1.0
|
|||
, -1.0, 1.0
|
||||
]
|
||||
|
||||
keyCallback :: IORef (BankersDequeue UIKey) ->
|
||||
Window -> Key -> Int -> KeyState -> ModifierKeys -> IO ()
|
||||
keyCallback queue _window key someInt state mods =
|
||||
modifyIORef queue (flip pushBack (UIKey key someInt state mods))
|
||||
|
||||
makeMainWindow :: (Int, Int) -> IORef (BankersDequeue UIKey) -> IO Window
|
||||
makeMainWindow (screenScaleX', screenScaleY') queue = do
|
||||
|
||||
|
@ -218,10 +223,7 @@ makeMainWindow (screenScaleX', screenScaleY') queue = do
|
|||
case mWindow of
|
||||
Nothing -> die "Couldn't create window"
|
||||
Just window -> do
|
||||
|
||||
let keyCallback _window key someInt state mods =
|
||||
modifyIORef queue (flip pushBack (UIKey key someInt state mods))
|
||||
setKeyCallback window (Just keyCallback)
|
||||
setKeyCallback window (Just $ keyCallback queue)
|
||||
|
||||
makeContextCurrent (Just window)
|
||||
putStrLn "Created window"
|
||||
|
|
Loading…
Reference in a new issue