/usr/share/psychtoolbox-3/PsychHardware/FORP/FORPCheck.m is in psychtoolbox-3-common 3.0.11.20131230.dfsg1-1build1.
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | function [KeyPressed,EventTime] = FORPCheck()
% FORPCheck Checks if a button of a FORP device (HH-5-CYL) is pressed.
%
% Usage:
%
% [KeyPressed,EventTime] = FORPCheck()
%
%
% Return the key name (KeyPressed) of the pressed button and the
% time (EventTime) of the status check.
%
%
% KeyPressed Key name of the Pressed Button, empty string
% if none pressed.
%
%
% EventTime Time of keypress check, as returned by GetSecs.
%
% IMPORTANT NOTE:
%
%
% See FORPWait.
%
% Going through each device can be very time consuming. If would advise
% to unplug each unnecessary device, so less devices has to be checked.
% If you have got any advice for a better way to solve those problems, feel
% free to let me know:
%
% Florian Stendel
% Visual Processing Lab
% Universitaets - Augenklinik Magdeburg
% Leipziger Strasse 44
% 39120 Magdeburg
% Tel: 0049 (0)391 67 21723
% Email: vincentdhs@gmx.de
%
%
% 10/10/06 fs Wrote it.
% 10/16/06 mk Add caching of device index.
% 10/17/06 fs Done some restructuring and testing.
% 02/08/07 mk New vendor id 6171 added to valid device lists.
persistent psychtoolbox_forp_id;
% List of vendor IDs for valid FORP devices:
vendorIDs = [1240 6171];
KeyPressed = '';
keydata = [];
% Try to detect first FORP device at first invocation:
if isempty(psychtoolbox_forp_id)
Devices = PsychHID('Devices');
% Loop through all KEYBOARD devices with the vendorID of FORP's vendor:
for i=1:size(Devices,2)
if strcmp(Devices(i).usageName,'Keyboard') && ismember(Devices(i).vendorID, vendorIDs)
psychtoolbox_forp_id=i;
break;
end
end
end
if isempty(psychtoolbox_forp_id)
error('FORPCheck: No FORP-Device detected on your system');
end
% Needed for getting the very LAST Buttonpress:
FORPQueueClear(psychtoolbox_forp_id);
[keydata,err] = PsychHID('GetReport',psychtoolbox_forp_id,1,0,8); % Get Report from device and save pressed.
EventTime=GetSecs;
PsychHID('ReceiveReportsStop',psychtoolbox_forp_id); % Stop receiving reports from that device
if any(keydata)
index = find(keydata ~=0,1); % get the (1st) index of the not-null element in keydata. Only one index can be processed by KbName
if ~isempty(index) % if there is a index in keydata then
KeyPressed=KbName(double(keydata(index))); % translate element at index into keyname
end
end
return;
end
|