Docs @ Psychtoolbox Wiki : KbTriggerWait

Search PTB Function help:
homepsychtoolbox.orgpage updateslogin

Revision [14474]

Last edited on 2012-03-27 09:42:45 by DocBot
Additions:
""<div class="subfct" id="PsychHID">""===[[KbTriggerWait PsychHID('KbTriggerWait')]]===
==[[Psychtoolbox]] › [[PsychHID]].{mex*,dll} subfunction==
%%(matlab;Usage)secs=PsychHID('KbTriggerWait', KeysUsage, [deviceNumber])%%
Scan a keyboard, keypad, or other HID device with buttons, and wait for a
trigger key press.
By default the first keyboard device (the one with the lowest device number) is
scanned. If no keyboard is found, the first keypad device is scanned, followed
by other devices, e.g., mice. Optionally, the deviceNumber of any keyboard or
HID device may be specified.
The 'KeysUsage' parameter must specify the keycode of a single key to wait for
on OS/X. On Linux and Windows, 'KeysUsage' can be a vector of trigger key codes
and the wait will finish as soon as at least one of the keys in the vector is
pressed.
On MS-Windows XP and later, it is currently not possible to enumerate different
keyboards and mice separately. Therefore the 'deviceNumber' argument is mostly
useless for keyboards and mice, usually you can only check the system keyboard
or mouse.
""</div>""
Deletions:
===[[KbTriggerWait]]===
==[[Psychtoolbox]] › [[PsychBasic]]==
secs = KbTriggerWait(keyCode, [deviceNumber])
Waits until trigger has been pressed and returns the time in seconds.
The keyCode argument should be a single number. For example, to check
for the 't' key as the trigger use KbTriggerWait(KbName('t'))
You cannot use KbTriggerWait while a queue created by KbQueueCreate
exists. To shut down such a queue, use KbQueueRelease.
On platforms other than Mac OS X 10.3 and later, this function simply
serves as a convenient substitute for using KbCheck to detect the
trigger of interest.
=== OSX 10.3 and later ===
This function will allow triggers to be reliably detected from devices
that only briefly report that the key is down. KbCheck is not reliable
with such devices because it may not poll often enough to detect the
key down state. This function will not address this problem on other
platforms or with earlier Macintosh operating system versions.
KbTriggerWait uses the PsychHID function, a general purpose function for
reading from the Human Interface Device (HID) class of USB devices.
Unlike KbCheck, it starts a queue that receives keyboard events
regarding the trigger key (and no other keys) and then polls this queue
(rather than the current key status) periodically. In theory, this
should also provide more accurate reporting of the time of the
triggering keypress. However, if multiple trigger events have occurred
since last polled, it is possible that the timestamp of the earliest
of these will have already rotated out of the limited capacity (eight
events) queue. In this case, the time of the earliest event remaining
in the queue is reported. Since the polling frequency is the same as
KbCheck, it should be more accurate on average with regard to timing,
even when the timestamps of the earliest events have been lost due to
queue overflow.
KbTriggerWait tests the first USB-HID keyboard device by default.
Optionally, you can pass in a 'deviceNumber' to test a different keyboard
if multiple keyboards are connected to your machine. The function also
allows to wait for button presses on keypads, mice or other HID devices
with buttons or keys.
Passing a deviceNumber of -1 will NOT cause all keyboards to be detected
One disadvantage of this function is that it renders Matlab relatively
unresponsive to Ctrl-C interrupts. KbQueueWait is a better option in
this regard, but more complicated to use.
----
See also: KbQueueWait KbCheck, KbWait, GetChar, CharAvail, KbDemo.
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of KbTriggerWait.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychBasic/KbTriggerWait.m">beta</a> | view WebSVN <a href=
"http://svn.berlios.de/wsvn/osxptb/trunk/Psychtoolbox/PsychBasic/KbTriggerWait.m?op=log">changelog</a> of trunk branch</span>
</div>
<div class="code">
<code>Psychtoolbox/PsychBasic/KbTriggerWait.m</code>
</div>
""


Revision [14473]

Edited on 2012-03-27 09:42:17 by DocBot
Additions:
===[[KbTriggerWait]]===
==[[Psychtoolbox]] › [[PsychBasic]]==
secs = KbTriggerWait(keyCode, [deviceNumber])
Waits until trigger has been pressed and returns the time in seconds.
The keyCode argument should be a single number. For example, to check
for the 't' key as the trigger use KbTriggerWait(KbName('t'))
You cannot use KbTriggerWait while a queue created by KbQueueCreate
exists. To shut down such a queue, use KbQueueRelease.
On platforms other than Mac OS X 10.3 and later, this function simply
serves as a convenient substitute for using KbCheck to detect the
trigger of interest.
=== OSX 10.3 and later ===
This function will allow triggers to be reliably detected from devices
that only briefly report that the key is down. KbCheck is not reliable
with such devices because it may not poll often enough to detect the
key down state. This function will not address this problem on other
platforms or with earlier Macintosh operating system versions.
KbTriggerWait uses the PsychHID function, a general purpose function for
reading from the Human Interface Device (HID) class of USB devices.
Unlike KbCheck, it starts a queue that receives keyboard events
regarding the trigger key (and no other keys) and then polls this queue
(rather than the current key status) periodically. In theory, this
should also provide more accurate reporting of the time of the
triggering keypress. However, if multiple trigger events have occurred
since last polled, it is possible that the timestamp of the earliest
of these will have already rotated out of the limited capacity (eight
events) queue. In this case, the time of the earliest event remaining
in the queue is reported. Since the polling frequency is the same as
KbCheck, it should be more accurate on average with regard to timing,
even when the timestamps of the earliest events have been lost due to
queue overflow.
KbTriggerWait tests the first USB-HID keyboard device by default.
Optionally, you can pass in a 'deviceNumber' to test a different keyboard
if multiple keyboards are connected to your machine. The function also
allows to wait for button presses on keypads, mice or other HID devices
with buttons or keys.
Passing a deviceNumber of -1 will NOT cause all keyboards to be detected
One disadvantage of this function is that it renders Matlab relatively
unresponsive to Ctrl-C interrupts. KbQueueWait is a better option in
this regard, but more complicated to use.
----
See also: KbQueueWait KbCheck, KbWait, GetChar, CharAvail, KbDemo.
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of KbTriggerWait.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychBasic/KbTriggerWait.m">beta</a> | view WebSVN <a href=
"http://svn.berlios.de/wsvn/osxptb/trunk/Psychtoolbox/PsychBasic/KbTriggerWait.m?op=log">changelog</a> of trunk branch</span>
</div>
<div class="code">
<code>Psychtoolbox/PsychBasic/KbTriggerWait.m</code>
</div>
""
Deletions:
""<div class="subfct" id="PsychHID">""===[[KbTriggerWait PsychHID('KbTriggerWait')]]===
==[[Psychtoolbox]] › [[PsychHID]].{mex*,dll} subfunction==
%%(matlab;Usage)secs=PsychHID('KbTriggerWait', KeysUsage, [deviceNumber])%%
Scan a keyboard or keypad device and wait for a trigger key press.
By default the first keyboard device (the one with the lowest device number) is
scanned. If no keyboard is found, the first keypad device is scanned.
Optionally, the device number of any keyboard or keypad may be specified.
The 'KeysUsage' parameter must specify the keycode of a single key to wait for
on OS/X. On Linux and Windows, 'KeysUsage' can be a vector of trigger key codes
and the wait will finish as soon as at least one of the keys in the vector is
pressed.
On Linux and OS/X handling of keyboard triggers is efficient. On MS-Windows,
keyboard triggers are implemented by periodic polling of the keyboard state with
a frequency of approximately 500 Hz. This is a brute-force approach which can
lead to unreliable stimulus presentation timing and trigger timestamping unless
you have a fast (multi-core) machine. It will also draw significant amounts of
electrical power. Therefore use this feature sparingly on MS-Windows and
consider a different operating system.
On MS-Windows, the 'deviceNumber' argument is ignored and the default keyboard
is waited for.
""</div>""


Revision [14328]

Edited on 2011-10-24 16:22:33 by DocBot
Additions:
""<div class="subfct" id="PsychHID">""===[[KbTriggerWait PsychHID('KbTriggerWait')]]===
==[[Psychtoolbox]] › [[PsychHID]].{mex*,dll} subfunction==
%%(matlab;Usage)secs=PsychHID('KbTriggerWait', KeysUsage, [deviceNumber])%%
Scan a keyboard or keypad device and wait for a trigger key press.
By default the first keyboard device (the one with the lowest device number) is
scanned. If no keyboard is found, the first keypad device is scanned.
Optionally, the device number of any keyboard or keypad may be specified.
The 'KeysUsage' parameter must specify the keycode of a single key to wait for
on OS/X. On Linux and Windows, 'KeysUsage' can be a vector of trigger key codes
and the wait will finish as soon as at least one of the keys in the vector is
pressed.
On Linux and OS/X handling of keyboard triggers is efficient. On MS-Windows,
keyboard triggers are implemented by periodic polling of the keyboard state with
a frequency of approximately 500 Hz. This is a brute-force approach which can
lead to unreliable stimulus presentation timing and trigger timestamping unless
you have a fast (multi-core) machine. It will also draw significant amounts of
electrical power. Therefore use this feature sparingly on MS-Windows and
consider a different operating system.
On MS-Windows, the 'deviceNumber' argument is ignored and the default keyboard
is waited for.
""</div>""
Deletions:
===[[KbTriggerWait]]===
==[[Psychtoolbox]] › [[PsychBasic]]==
secs = KbTriggerWait(keyCode, [deviceNumber])
Waits until trigger has been pressed and returns the time in seconds.
The keyCode argument should be a single number. For example, to check
for the 't' key as the trigger use KbTriggerWait(KbName('t'))
You cannot use KbTriggerWait while a queue created by KbQueueCreate
exists. To shut down such a queue, use KbQueueRelease.
On platforms other than Mac OS X 10.3 and later, this function simply
serves as a convenient substitute for using KbCheck to detect the
trigger of interest.
=== OSX 10.3 and later ===
This function will allow triggers to be reliably detected from devices
that only briefly report that the key is down. KbCheck is not reliable
with such devices because it may not poll often enough to detect the
key down state. This function will not address this problem on other
platforms or with earlier Macintosh operating system versions.
KbTriggerWait uses the PsychHID function, a general purpose function for
reading from the Human Interface Device (HID) class of USB devices.
Unlike KbCheck, it starts a queue that receives keyboard events
regarding the trigger key (and no other keys) and then polls this queue
(rather than the current key status) periodically. In theory, this
should also provide more accurate reporting of the time of the
triggering keypress. However, if multiple trigger events have occurred
since last polled, it is possible that the timestamp of the earliest
of these will have already rotated out of the limited capacity (eight
events) queue. In this case, the time of the earliest event remaining
in the queue is reported. Since the polling frequency is the same as
KbCheck, it should be more accurate on average with regard to timing,
even when the timestamps of the earliest events have been lost due to
queue overflow.
KbTriggerWait tests the first USB-HID keyboard device by default.
Optionally, you can pass in a 'deviceNumber' to test a different keyboard
if multiple keyboards are connected to your machine.
Passing a deviceNumber of -1 will NOT cause all keyboards to be detected
One disadvantage of this function is that it renders Matlab relatively
unresponsive to Ctrl-C interrupts. KbQueueWait is a better option in
this regard, but more complicated to use.
----
See also: KbQueueWait KbCheck, KbWait, GetChar, CharAvail, KbDemo.
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of KbTriggerWait.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychBasic/KbTriggerWait.m">beta</a> | view WebSVN <a href=
"http://svn.berlios.de/wsvn/osxptb/trunk/Psychtoolbox/PsychBasic/KbTriggerWait.m?op=log">changelog</a> of trunk branch</span>
</div>
<div class="code">
<code>Psychtoolbox/PsychBasic/KbTriggerWait.m</code>
</div>
""


Revision [12052]

Edited on 2010-12-06 10:23:19 by DocBot
Additions:
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychBasic/KbTriggerWait.m">beta</a> | view WebSVN <a href=
"http://svn.berlios.de/wsvn/osxptb/trunk/Psychtoolbox/PsychBasic/KbTriggerWait.m?op=log">changelog</a> of trunk branch</span>
Deletions:
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychBasic/KbTriggerWait.m">beta</a> | view in <a href=
"http://svn.berlios.de/wsvn/osxptb/beta/Psychtoolbox/PsychBasic/KbTriggerWait.m?view=markup">WebSVN with changelog</a></span>


Revision [10077]

Edited on 2010-09-09 15:24:48 by DocBot
Additions:
"http://svn.berlios.de/wsvn/osxptb/beta/Psychtoolbox/PsychBasic/KbTriggerWait.m?view=markup">WebSVN with changelog</a></span>
Deletions:
"http://svn.berlios.de/viewcvs/osxptb/beta/Psychtoolbox/PsychBasic/KbTriggerWait.m?view=markup">WebSVN with changelog</a></span>


Revision [7578]

Edited on 2008-09-25 18:08:32 by DocBot
Additions:
""
<div class="code_header" style="text-align:right;">
<span style="float:left;">Path  </span> <span class="counter">Retrieve current version of KbTriggerWait.m from berliOS: <a href=
"http://svn.berlios.de/svnroot/repos/osxptb/beta/Psychtoolbox/PsychBasic/KbTriggerWait.m">beta</a> | view in <a href=
"http://svn.berlios.de/viewcvs/osxptb/beta/Psychtoolbox/PsychBasic/KbTriggerWait.m?view=markup">WebSVN with changelog</a></span>
</div>
<div class="code">
<code>Psychtoolbox/PsychBasic/KbTriggerWait.m</code>
</div>
""
Deletions:
%%(php;Path)Psychtoolbox/PsychBasic/KbTriggerWait.m%%


Revision [5189]

Edited on 2008-06-15 19:56:28 by DocBot
Additions:
==[[Psychtoolbox]] › [[PsychBasic]]==
Deletions:
==[[Psychtoolbox]] › PsychBasic==


Revision [2783]

Edited on 2008-03-21 03:35:02 by DocBot
Additions:
==[[Psychtoolbox]] › PsychBasic==
=== OSX 10.3 and later ===
----
%%(php;Path)Psychtoolbox/PsychBasic/KbTriggerWait.m%%
Deletions:
==PtbReference › PsychBasic==




OSX 10.3 and later: ____________________________________________________





_________________________________________________________________________

PsychBasic


Revision [2375]

Edited on 2008-03-15 12:08:01 by DocBot
Additions:
===[[KbTriggerWait]]===
==PtbReference › PsychBasic==
Deletions:
===PsychBasic===


Revision [256]

The oldest known version of this page was created on 2008-03-15 10:26:05 by DocBot
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki
Page was generated in 0.0215 seconds