/usr/share/psychtoolbox-3/PsychBasic/KbQueueWait.m is in psychtoolbox-3-common 3.0.12.20160126.dfsg1-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | function secs=KbQueueWait(deviceIndex)
% secs=KbQueueWait([deviceIndex])
%
% Waits for any key to be pressed and returns the time of the press.
%
% KbQueueFlush should be called immediately prior to this function
% (unless the queue has just been created and started) to clear any
% prior events.
%
% Note that this command will not respond to any keys that were
% inactivated by using the keyList argument to KbQueueCreate.
%
% Since KbQueueWait is implemented as a looping call to
% KbQueueCheck, it will not respond to any key codes stored in
% the global variable ptb_kbcheck_disabledKeys
% (see "help DisableKeysForKbCheck")
% _________________________________________________________________________
%
% See also: KbQueueCreate, KbQueueStart, KbQueueStop, KbQueueCheck,
% KbQueueWait, KbQueueFlush, KbQueueRelease
% 8/19/07 rpw Wrote it.
% 8/23/07 rpw Modifications to add KbQueueFlush
% 5/14/12 mk Small fixes: Use 1 msec wait interval.
if nargin < 1
deviceIndex = [];
end
% Try to check if keyboard queue for 'deviceIndex' is reserved for our exclusive use:
if ~KbQueueReserve(3, 2, deviceIndex) && KbQueueReserve(3, 1, deviceIndex)
error('Keyboard queue for device %i already in use by GetChar() et al. Use of GetChar and keyboard queues is mutually exclusive!', deviceIndex);
end
% It is implicit in invoking this function that the queue should be running
% and it is potentially problematic if it is not since the function will
% never return, therefore, go ahead and start the queue if it isn't running
KbQueueStart(deviceIndex);
while(1)
[pressed, firstPress] = KbQueueCheck(deviceIndex);
if pressed
break;
end
% Wait for 1 msec to prevent system overload:
WaitSecs('Yieldsecs', 0.001);
end
presses=find(firstPress);
secs=min(firstPress(presses)); %#ok<FNDSB>
return;
|