正規品のコントローラーのみ動作したが、サードパーティ製のものはきちんと動作しなかった。無駄金を使ってしまった。
Codeコンポーネントに以下の記述をRoutineにいれることで左右のトリガーの動作確認したので、備忘録。
2017/2/24修正。
#Begin Experiment
try:
from psychopy import visual, core
from psychopy.iohub import launchHubServer, EventConstants
from psychopy.data import getDateStr
kwargs={'psychopy_monitor_name':'default','xinput.Gamepad':{}}
io=launchHubServer(**kwargs)
gamepad=io.devices.gamepad
except Exception, e:
import sys
print "!! Error starting ioHub: ",e," Exiting..."
sys.exit(1)
#Begin Routine
LT=0
RT=0
trial_start=0
io.clearEvents()
#Every Frame
if frameN == 0:
io.clearEvents('all')
trial_start=core.getTime()
else :
gp_triggers = gamepad.getTriggers()
# psychopy time that the trigger values were actually read (in sec.msec)
trig_time = gp_triggers['time']
# values will be between 0.0 and 1.0. 0.0 = Not pressed at all; 1.0 = fully pressed.
left_val, right_val = gp_triggers['left_trigger'], gp_triggers['right_trigger']
if left_val > 0.5:
LT=1
continueRoutine = False
elif right_val > 0.5:
RT=1
continueRoutine = False
LT=1
continueRoutine = False
elif right_val > 0.5:
RT=1
continueRoutine = False
#End Routine
trials.addData("trial_start_time", trial_start)
trials.addData("LT", left_val)
trials.addData("RT", right_val)
trials.addData("react", trig_time)
ReactionTime=(trig_time) - (trial_start)
trials.addData("ReactionTime", ReactionTime)
#End Experiment
io.quit()
0 件のコメント:
コメントを投稿