I am trying to use the DirectIN Rotary Controller on Mac OS X (yosemite) with PsychoPy2 (v. 1.82.01). I would like to conduct a two-alternative forced choice experiment and use the buttons on the button box in order to respond; however, I cannot get psychopy to recognize the device.
Somebody with a similar problem was able to make the button box work in coder (see here), and there is a similar question using a different game controller here. So far I have gathered the following information:
- Psychopy will recognize the button box as a joystick.
- I need to use a code component in the trial routine.
The post from the emprisoft forum provides the following code:
import pyglet
joysticks = pyglet.input.get_joysticks()
for joy in joysticks:
if joy.device.name == 'Analog Scale Device':
joy.open()
break
def present_pair_joystick(trial,isi,curdata): #trial is a sound object, isis is the time to wait after response/end of sound, and curdata is a dictionary used to store response data
event.clearEvents()
while joy.buttons[0] or joy.buttons[1]:
continue
curdata['trial_start']=time.time()
trial.play()
dur = trial.getDuration()
while True:
if not (joy.buttons[0] and joy.buttons[1]):
if joy.buttons[0]:
curdata['rt'] = time.time() - curdata['trial_start']
curdata['resp'] = 'Word'
break
elif joy.buttons[1]:
curdata['rt'] = time.time() - curdata['trial_start']
curdata['resp'] = 'Nonword'
break
if 'escape' in event.getKeys():
core.quit()
if time.time() - curdata['trial_start'] > dur:
core.wait(isi)
else:
core.wait((dur - (time.time() - curdata['trial_start'])) + isi)
curdata['dur'] = dur
return
So I believe I can get the button box to work if I incorporate this code into a code component in builder, but I have not had any success with this (I am able to run an experiment without error, but the key responses are not recorded). Any help would be appreciated.