Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Joystick-position/Haskell/joystick-position.hs
Normal file
22
Task/Joystick-position/Haskell/joystick-position.hs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import qualified Graphics.UI.GLFW as GLFW -- cabal install GLFW-b
|
||||
import Graphics.Win32.Key
|
||||
import Control.Monad.RWS.Strict (liftIO)
|
||||
|
||||
main = do
|
||||
liftIO $ do
|
||||
_ <- GLFW.init
|
||||
GLFW.pollEvents
|
||||
(jxrot, jyrot) <- liftIO $ getJoystickDirections GLFW.Joystick'1
|
||||
putStrLn $ (show jxrot) ++ " " ++ (show jyrot)
|
||||
w <- getAsyncKeyState 27 -- ESC pressed?
|
||||
if (w<1) then main else do
|
||||
GLFW.terminate
|
||||
return ()
|
||||
|
||||
getJoystickDirections :: GLFW.Joystick -> IO (Double, Double)
|
||||
|
||||
getJoystickDirections js = do
|
||||
maxes <- GLFW.getJoystickAxes js
|
||||
return $ case maxes of
|
||||
(Just (x:y:_)) -> (-y, x)
|
||||
_ -> ( 0, 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue