Psychtoolbox KbQueueXXX functions in Ubuntu
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Dear members
I am having a very difficult time using KbQueueXXX functions (i.e., KbQueueCreate, KbQueueStart, KbQueueCheck, KbQueueRelease) to record key presses, kept bumping into errors while following some pretty old step-by-step instructions (e.g., Source One and Two listed at the very end of this post).
I tried to read through the psychtoolbox documentations but still confused with the information presented.
Some very basic questions such as
e.g., should I call
PsychHID('KbQueueStart', device)
or
KbQueueStart(device)
to look for keypresses?
I was also wondering whether there is any working demo scripts or more recent sources/ tutorials that I can learn from.
Thanks in advance!
My script:
%%create the Queue device and specify the allowed keys
device =7;
keys=[45 46];
keylist=zeros(1,256);
keylist(keys)=1;
KbQueueCreate(device,keylist);
...
KbQueueStart(device); % look for key presses within a specified time limit
while TimeOut == 0
[pressed, firstpress] = KbQueueCheck(device); %check response
if pressed
if firstPress(45)>0
...
TimeOut = 1;
break
elseif firstPress(46)>0
...
TimeOut = 1;
break
end
elseif TimeInLoop > 10
...
TimeOut = 1;
break
end
end
KbQueueRelease(device);
Error msg presented :
Error using PsychHID
Usage:
[keyIsDown, firstKeyPressTimes, firstKeyReleaseTimes, lastKeyPressTimes, lastKeyReleaseTimes]=PsychHID('KbQueueCheck' [, deviceIndex])
Error in KbQueueCheck (line 61)
[pressed, firstPress, firstRelease, lastPress, lastRelease] = PsychHID('KbQueueCheck', deviceIndex);
Error in myscript (line 465)
[pressed, firstpress] = KbQueueCheck(device); %check response
References
Source One
Source Two
ftp://ftp.tuebingen.mpg.de/pub/pub_dahl/stmdev10_D/Matlab6/Toolboxes/Psychtoolbox/PsychDocumentation/KbQueue.html
the principle seemed to be
- KbQueueCreate: create a list of keys
- KbQueueStart: start “waiting” for keypresses
- put KbQueueCheck: put this in a while loop to look for specific key presses
- KbQueueRelease : end the “wait”
Software environment
ubuntu 20.04.1 LTS
matlab 2019b
psychtoolbox 3.0.17
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre Installation and Operational Settings en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!