-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequestResponse.m
More file actions
36 lines (32 loc) · 1.1 KB
/
requestResponse.m
File metadata and controls
36 lines (32 loc) · 1.1 KB
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
function [r, tStart, tRespo, globals] = requestResponse(arrayPerm, startPos, duration, globals)
allowableKeys = [globals.scrollKey, globals.acceptKey];
cursorPos = startPos;
tStart = drawRespArray(arrayPerm, cursorPos, [0,0,1].*globals.white, globals);
tTimeOut = (tStart + duration);
r = NaN;
tRespo = NaN;
now = GetSecs();
tLastValidScroll = -Inf;
while now < tTimeOut
[keyIds, keyTime] = liKeyWait(allowableKeys, tTimeOut);
globals.t = keyTime;
if ismember(globals.scrollKey,keyIds) && isnan(r)
if keyTime > (tLastValidScroll + 0.25)
liSendTrig(0, globals);
cursorPos = (mod((cursorPos), 6)) + 1;
drawRespArray(arrayPerm, cursorPos, [0,0,1].*globals.white, globals);
tLastValidScroll = keyTime;
end
elseif ismember(globals.acceptKey,keyIds) && isnan(r)
liSendTrig(1, globals);
r = arrayPerm(cursorPos);
drawRespArray(arrayPerm, cursorPos, [0,1,1].*globals.white, globals);
tRespo = keyTime;
end
now = GetSecs();
end
if isnan(r)
r = (arrayPerm(cursorPos)+6).*1i;
end
globals.t = tTimeOut;
return