Jump to content

Joystick position: Difference between revisions

no edit summary
(→‎{{Header|ZX Spectrum Basic}}: i'll get this right in a minute - it'd be so much easier if the spectrum's BIN function was reversible)
No edit summary
Line 318:
<lang guiss>Start,Control Panel, Game Controllers, List:installed controllers,Click:Joystick,
Button:Properties,Button:Test</lang>
 
=={{header|Haskell}}==
Half-solution of the problem, exhibits X and Y coordinates of the joystick; works on Windows (Haskell Platform):
 
<lang Haskell>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)
</lang>
 
=={{header|Liberty BASIC}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.