Skip to content

Commit e6210ab

Browse files
committed
checkAbort called at every getResponse check
1 parent d02e11e commit e6210ab

File tree

2 files changed

+39
-38
lines changed

2 files changed

+39
-38
lines changed

CPP_getResponseDemo.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
cfg.keyboard = [];
3030
cfg.responseBox = [];
3131

32+
cfg.escapeKey = 'Escape';
33+
3234
% We set which keys are "valid", any keys other than those will be ignored
3335
expParameters.responseKey = {};
3436

getResponse.m

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777

7878
responseEvents = getAllKeyEvents(responseEvents, responseBox, getOnlyPress);
7979

80+
checkAbort(cfg)
8081

8182
case 'flush'
8283

@@ -95,42 +96,6 @@
9596

9697
talkToMe(action, expParameters);
9798

98-
99-
end
100-
101-
102-
function talkToMe(action, expParameters)
103-
104-
if ~isfield(expParameters, 'verbose') || isempty(expParameters.verbose)
105-
expParameters.verbose = false;
106-
end
107-
108-
switch action
109-
110-
case 'init'
111-
112-
case 'start'
113-
114-
fprintf('\n starting to listen to keypresses\n')
115-
116-
case 'check'
117-
118-
if expParameters.verbose
119-
fprintf('\n checking recent keypresses\n')
120-
end
121-
122-
case 'flush'
123-
124-
if expParameters.verbose
125-
fprintf('\n reinitialising keyboard queue\n')
126-
end
127-
128-
case 'stop'
129-
130-
fprintf('\n stopping to listen to keypresses\n\n')
131-
132-
end
133-
13499
end
135100

136101

@@ -144,7 +109,7 @@ function talkToMe(action, expParameters)
144109
fprintf('\n Will be listening for key presses on : ')
145110

146111
if isfield(expParameters, 'responseKey') && ~isempty(expParameters.responseKey)
147-
112+
148113
responseTargetKeys = nan(1,numel(expParameters.responseKey));
149114

150115
for iKey = 1:numel(expParameters.responseKey)
@@ -164,7 +129,6 @@ function talkToMe(action, expParameters)
164129
end
165130

166131

167-
168132
function responseEvents = getAllKeyEvents(responseEvents, responseBox, getOnlyPress)
169133

170134
iEvent = 1;
@@ -189,4 +153,39 @@ function talkToMe(action, expParameters)
189153

190154
end
191155

156+
end
157+
158+
159+
function talkToMe(action, expParameters)
160+
161+
if ~isfield(expParameters, 'verbose') || isempty(expParameters.verbose)
162+
expParameters.verbose = false;
163+
end
164+
165+
switch action
166+
167+
case 'init'
168+
169+
case 'start'
170+
171+
fprintf('\n starting to listen to keypresses\n')
172+
173+
case 'check'
174+
175+
if expParameters.verbose
176+
fprintf('\n checking recent keypresses\n')
177+
end
178+
179+
case 'flush'
180+
181+
if expParameters.verbose
182+
fprintf('\n reinitialising keyboard queue\n')
183+
end
184+
185+
case 'stop'
186+
187+
fprintf('\n stopping to listen to keypresses\n\n')
188+
189+
end
190+
192191
end

0 commit comments

Comments
 (0)