File: KbQueueFlush.m

package info (click to toggle)
psychtoolbox-3 3.0.19.14.dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 86,796 kB
  • sloc: ansic: 176,245; cpp: 20,103; objc: 5,393; sh: 2,753; python: 1,397; php: 384; makefile: 193; java: 113
file content (51 lines) | stat: -rw-r--r-- 1,805 bytes parent folder | download | duplicates (5)
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
function nflushed = KbQueueFlush(deviceIndex, flushType)
%  nflushed = KbQueueFlush([deviceIndex][flushType=1])
%
%  Flush KbQueue and/or KbQueue event buffer. By default, if flushType is
%  omitted, only the KbQueues events are deleted. Other 'flushTypes' affect
%  the KbQueue event buffer, but rather use the KbEventFlush() function to
%  do this.
%
%  If 'flushType' is 0, only the number of currently queued events will be
%  returned.
%
%  If 'flushType' is 1, only events returned by KbQueueCheck will be flushed. This
%  is the default.
%
%  If 'flushType' is 2, only events returned by KbEventGet will be flushed.
%
%  If 'flushType' is 3, events returned by both KbQueueCheck and KbEventGet
%  will be flushed.
%
%  If 'flushType' is 4, only the number of key-press events with valid, mapped ASCII
%  CookedKey field will be returned.
%
%  Removes all unprocessed events from the queue and zeros out any already
%  scored events.
% _________________________________________________________________________
%
% See also: KbQueueCreate, KbQueueStart, KbQueueStop, KbQueueCheck,
%            KbQueueWait, KbQueueFlush, KbQueueRelease

% 8/23/07    rpw  Wrote it.

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)
    if isempty(deviceIndex)
        deviceIndex = NaN;
    end
    error('Keyboard queue for device %i already in use by GetChar() et al. Use of GetChar and keyboard queues is mutually exclusive!', deviceIndex);
end

if nargin == 0
    nflushed = PsychHID('KbQueueFlush');
elseif nargin > 0
    if nargin < 2 || isempty(flushType)
        flushType = [];
    end
    nflushed = PsychHID('KbQueueFlush', deviceIndex, flushType);
end