-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetCountResponse.m
More file actions
78 lines (68 loc) · 2.14 KB
/
getCountResponse.m
File metadata and controls
78 lines (68 loc) · 2.14 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
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
function [r, tR, globals] = getCountResponse(...
scrollStart, durResponse, globals)
% Set the time out
tTimeOut = globals.t + durResponse;
drawScroll(scrollStart, globals);
r = NaN;
tR = NaN;
now = GetSecs();
tLastValidScroll = -Inf;
currentNumber = scrollStart;
while now < tTimeOut
[keyIds, keyTime] = liKeyWait(...
[globals.downKey,globals.upKey], tTimeOut);
if keyTime > (tLastValidScroll + 0.25)
if ismember(globals.downKey,keyIds) && currentNumber > 1
currentNumber = currentNumber - 1;
drawScroll(currentNumber, globals);
tLastValidScroll = keyTime;
elseif ismember(globals.upKey,keyIds) && currentNumber < 98
currentNumber = currentNumber + 1;
drawScroll(currentNumber, globals);
tLastValidScroll = keyTime;
end
end
% Set r and tR
if isfinite(tLastValidScroll)
% Buttons have been pressed
r = currentNumber;
tR = tLastValidScroll;
else
% Buttons have not been pressed
r = currentNumber*1i;
end
% Set now
now = GetSecs();
end
globals.t = tTimeOut;
return
function [tDraw] = drawScroll(number, globals)
% Draw the smaller number
% Add one to the number-1 when indexing (number: 0 -> index: 1).
Screen('DrawTexture',...
globals.window,...
globals.textures.numbers(number),...
[],...
globals.xyEdgesNumLeft);
% Draw the central number & frame
% Add one to the number when indexing (number: 0 -> index: 1).
Screen('DrawTexture',...
globals.window,...
globals.textures.numbers(number+1),...
[],...
globals.xyEdgesNumMid);
Screen('FrameRect',...
globals.window,...
globals.white,...
globals.xyEdgesFrameMid,...
globals.penWidthPixels);
% Draw the larger number
% Add one to the number+1 when indexing (number: 0 -> index: 1).
Screen('DrawTexture',...
globals.window,...
globals.textures.numbers(number+2),...
[],...
globals.xyEdgesNumRight);
% Flip the screen
tDraw = Screen('Flip', globals.window, globals.t);
return