labott1@... wrote:
>
> I've come to the conclusion that the functions avilable are adequate
> for my experiments,
Recently, Wednesday and Thursday (4/18/01 & 4/19/01), I updated the list at
http://color.psych.ucsb.edu/psychtoolbox/winlist.html. of currently working
functions in Psychtoolbox for Windows. See that page for the latest info.
> assuming that GetChar works. On the usergroup
> website I noticed that 'on earlier versions of MATLAB, GetChar misses
> some key responses'.
I would assume that the problem occurs with all versions of Matlab, however I've
only confirmed it on 5.2 and 6.0.
I think that remark which you quote is out of context and wasn't meant to imply
that GetChar catches all keypresses when used with later versions of Matlab, but
rather that there is an additional problem in using it with a later version,
6.0. That problem is that 6.0 hangs when GetChar is called, but we now have a
work around for that, see:
http://groups.yahoo.com/group/psychtoolbox/message/421
http://groups.yahoo.com/group/psychtoolbox/message/422
> Could someone tell me exactly when it does this,
> to what degree,
When executing a .m file Matlab interleaves keyboard scans between expressions in
the .m file. Matlab therefore only steals characters from the event queue before
or after a call to GetChar, not within the call as GetChar awaits a keypress.
The upshot is:
- If CharAvail reports that a keypress is available, subsequent calls to GetChar
could fail to return the keypress because between your calls to CharAvail and
GetChar Matlab has stolen the keypress event. The idiom:
if CharAvail
myChar = GetChar;
end
is a convenient way of scanning for characters without waiting for them, but it
won't be available in Windows until GetChar is fixed. It's likely that you
could make due with KbCheck until GetChar is fixed.
- In the situation where you prompt the user for an input, and then call GetChar
to wait for a keypress, there probably won't be any trouble. The short interval
during which Matlab steals keypresses is probably well within the reaction time
of the subject. The bug makes
fprintf('Press a key\n');
myChar = GetChar;
intermittently equivalent to:
fprintf('Press a key\n');
FlushEvents('KeyDown');
myChar = GetChar;
Conceptually that's bad; after you ask the subject to press a key, you then erase
all record of any keypress, before looking for keypresses. However, in
practice, there won't be trouble because the subject isn't going to press a key
between when you ask him to do so and when you erase keypresses, unless its an
anticipatory response, and for most purposes those can be reasonably excluded.
> and perhaps some timescale as to when it might be
> fixed please? I'm using MATLAB 5.3.
Because the problem arises from Matlab's behavior, and Matlab is a black box
--closed source and distributed as a binary executable,-- it's difficult to
predict exactly what will work to fix the problem.
I'm trying alternative implementations of GetChar, one using DirectInput and one
using hooks and talking to people at Mathworks.
>
>
> Also, does anyone know of some code to be able to use a button box
> with the toolbox and windows.
What code you would need depends on how your button box interfaces to your
computer, so more detail here would be helpful.
If you would like to use a game pad as a button box then I could look into
providing Windows psychtoolbox functions to read a game pad.
Allen