|
3 | 3 | function responseEvents = getResponse(action, deviceNumber, cfg, getOnlyPress) |
4 | 4 | % |
5 | 5 | % Wrapper function to use KbQueue. The queue will be listening to key presses on a keyboard device: |
6 | | - % ``cfg.keyboard.responseBox`` or ``cfg.keyboard.keyboard`` are 2 main examples.When no deviceNumber |
| 6 | + % ``cfg.keyboard.responseBox`` or ``cfg.keyboard.keyboard`` are 2 main examples. When no deviceNumber |
7 | 7 | % is set then it will listen to the default device. Check the ``CPP_getResponseDemo`` for a quick |
8 | 8 | % script on how to use it. |
9 | 9 | % |
|
19 | 19 | % return when the keys were released (default=true). See the section on |
20 | 20 | % `Returns` below for more info |
21 | 21 | % |
22 | | - % :returns: - :responseEvents: returns all the keypresses and return them as a structure with |
23 | | - % field names that make it easier to save the output of in a BIDS format |
| 22 | + % :returns: - :responseEvents: returns all the keypresses and return them as a structure with field names that make it easier to save the output of in a BIDS format |
| 23 | + % |
| 24 | + % - ``responseEvents.onset`` this is an absolute value and you should substract the "experiment start time" to get a value relative to when the experiment was started. |
| 25 | + % |
| 26 | + % - ``responseEvents.trial_type = response`` |
| 27 | + % |
| 28 | + % - ``responseEvents.duration = 0`` |
| 29 | + % |
| 30 | + % - ``responseEvents.keyName`` the name of the key pressed |
| 31 | + % |
| 32 | + % - ``responseEvents(iEvent,1).pressed`` if |
24 | 33 | % |
25 | | - % - ``responseEvents.onset``: this is an absolute value and you should substract the |
26 | | - % "experiment start time" to get a value relative to when the |
27 | | - % experiment was started. |
28 | | - % - ``responseEvents.trial_type = response``; |
29 | | - % - ``responseEvents.duration = 0;`` |
30 | | - % - ``responseEvents.keyName``: the name of the key pressed |
31 | | - % - ``responseEvents(iEvent,1).pressed``: if |
32 | 34 | % - pressed == 1 --> the key was pressed |
33 | 35 | % - pressed == 0 --> the key was released |
34 | 36 | % |
| 37 | + % --- |
| 38 | + % |
35 | 39 | % ``action`` options: |
36 | 40 | % |
37 | | - % - ``init``: to initialise the queue |
38 | | - % - ``start``: to start listening to keypresses |
39 | | - % - ``check``: checks all the key presses events since 'start', or since last 'check' or 'flush' |
40 | | - % (whichever was the most recent) |
41 | | - % - can check for demand to abort if the escapeKey is listed in the Keys of interest |
42 | | - % - can only check for demands to abort when ``getResponse('check')`` is called so there will be |
43 | | - % a delay between the key press and the experiment stopping |
44 | | - % - abort errors send specific signals that allow the catch to get |
45 | | - % them and allows us to "close" nicely |
46 | | - % - ``flush``: empties the queue of events in case you want to restart from a clean |
47 | | - % queue |
48 | | - % - ``stop``: stops listening to key presses |
| 41 | + % - ``init`` to initialise the queue |
| 42 | + % |
| 43 | + % - ``start`` to start listening to keypresses |
| 44 | + % |
| 45 | + % - ``check`` checks all the key presses events since 'start', or since last 'check' or 'flush' (whichever was the most recent) |
| 46 | + % |
| 47 | + % - can check for demand to abort if the ``escapeKey`` is listed in the Keys of interest |
| 48 | + % - can only check for demands to abort when ``getResponse('check')`` is called so there will be a delay between the key press and the experiment stopping |
| 49 | + % - abort errors send specific signals that allow the catch to get them and allows us to "close" nicely |
| 50 | + % |
| 51 | + % - ``flush`` empties the queue of events in case you want to restart from a clean queue |
| 52 | + % |
| 53 | + % - ``stop`` stops listening to key presses |
| 54 | + % |
49 | 55 |
|
50 | 56 | if nargin < 2 || isempty(deviceNumber) |
51 | 57 | deviceNumber = -1; |
|
0 commit comments