[Haskell-beginners] Confused by GLFW and more
Britt Anderson
britt.uwaterloo at gmail.com
Thu Mar 3 16:34:32 CET 2011
To: Beginners List
I am trying to get a simple program working that will display
something on the screen, get user input via joystick until a quit
event, and then start a new trial, and repeat this until all the
trials have been performed.
The problem is that if I try to sequence the trials it hangs on the
last trial (screen freezes and I have to kill it), however, if I just
execute one after the other it exits fine. I don't understand what is
different about doing the commented line versus explicitly invoking
two trials (as demonstrated in the snippet below).
Here is a snippet ( I am happy to provide more, but I don't know what
is needed to diagnose my problem and I don't want to clutter the
question):
tn = 3
main :: IO ()
main = do
let ps = initPlayers
createWindow
putStr "Window Initialized\n"
let joy = GLFW.Joystick 1
putStr "Got Joystick\n"
--sequence_ $ map (trialLoop gain tolerance joy) (trialList ps)
trialLoop gain tolerance joy ((trialList ps)!!0)
trialLoop gain tolerance joy ((trialList ps)!!1)
putStr "Back from Sequence\n"
where trialList oldps =
[[(h' i) , (p' i)] | i <- [1 ..], i < tn]
where
x = 0.2
y = 0.2
h' idx = (oldps!!0)
p' idx = Prey (Circle (((-1)^idx)*0.2,0.2) ((radius .
shape) (oldps!!1))) (clr $ oldps!!1)
As an aside, I was wondering if anyone has experience using joysticks
with any of the Graphics.UI I have both a logitech and a saitek and I
find that although both are found by the Graphics.UI.SDL I cannot get
the buttons for the Saitek, but can for logitech. For neither does
pollEvents seem to work right, although I can use update and getAxis
for both joysticks. It was this unpredictable behaviour that drove me
from SDL to GLFW.
Any general advice on the UIs for joysticks would be appreciated as
well. I am not actually writing a game, but a simple psychophysics
experiment (the use of Haskell is just an exercise - normally I would
do this [and have been done with it long ago] in python. So, my
questions are really focused on trying to use haskell and its
libraries for this purpose). Using Arch Linux if that makes any
difference.
Thanks in advance for any comments.
--Britt
More information about the Beginners
mailing list