forked from jooh/matlab-studytools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonboxCheck.m
More file actions
38 lines (36 loc) · 1.18 KB
/
Copy pathButtonboxCheck.m
File metadata and controls
38 lines (36 loc) · 1.18 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
classdef ButtonboxCheck < ResponseCheck
% ButtonboxCheck < StudyEvent subclass for logging button responses
properties
scanobj = [];
keyboardhand = KeyboardCheck;
end
methods
function s = ButtonboxCheck(varargin)
s = varargs2structfields(varargin,s);
end
function [respkey,resptime] = checkkeys(self);
respk = bitand(30,invoke(self.scanobj,'GetResponse'));
rawtime = GetSecs;
keyisdown = respk ~= 30;
resptime = [];
respkey = [];
if keyisdown
% ignore held keys
if self.keyisdown && respk==self.lastkey
return
end
resptime = rawtime;
respkey = respk;
% update internal state
self.keyisdown = keyisdown;
self.lastkey = respkey;
else
% reset to record repeated distinct presses of the same key
self.keyisdown = 0;
self.lastkey = NaN;
end
% check for escape key on keyboard
self.keyboardhand.call;
end
end
end