I want in a trial, the program to wait for joystick axis response after the presentation of stimuli. But the following code does not wait for the response and the loop ends capturing the axis position at that instance.
from psychopy.visual import Window,Circle, Rect
from psychopy.hardware import joystick
from psychopy.core import wait
win = Window(size=(400,400),units='pix',color=(0,0,0),fullscr=False)
stim={}
stim[0]=Circle(win,radius=100,edges=128,lineColor=(1,-1,-1),lineWidth=8)
stim[1]=Rect(win,width=100,height=100,lineColor=(1,-1,-1),lineWidth=8)
nJoys = joystick.getNumJoysticks() # to check if we have any
id = 0
joy = joystick.Joystick(id) # id must be <= nJoys - 1
nAxes = joy.getNumAxes()
locationX = []
locationY = []
for i in range(5):
if (i%2==0):
stim[0].draw()
win.flip()
wait(1)
locationX.append(joy.getX())
locationY.append(joy.getY())
else:
stim[1].draw()
win.flip()
wait(1)
locationX.append(joy.getX())
locationY.append(joy.getY())
win.close()