Re: [A89: Re: OSInitBetweenKeyDelay]


[Prev][Next][Index][Thread]

Re: [A89: Re: OSInitBetweenKeyDelay]




I am using _rowread() to access the keyboard.  I had it set up with a keydelay
almost exactly like you said, with a different delay value for rotate and
left/right, but it would miss buttons.  For example, if I hit the flip key
twice really fast it would miss the second flip because of the delay.

Did you have this problem?  I was thinking maybe I could queue up the keys if
they are hit during a delay... Did  you do that?



"James Darpinian" <J112282@prodigy.net> wrote:

Hello!
    If you're disabling interrupts, you must be using the function
_rowread() to access the keyboard.  _rowread() accesses the keyboard
hardware directly and is not affected by OSInitBetweenKeyDelay().  You'll
have to calculate the delay "manually" within your program.  The way I do it
is:

int keydelay = 0;

// in the main loop, where the keypresses are checked
if (keydelay)
{
    keydelay--;
}
else
{
    // check keys
    if (a_key_is_pressed)
    {
        keydelay = 5000;
        // do whatever else you do when a key is pressed
    };
};

In this loop, after a key is pressed, you have to wait for the main loop to
go around 5000 times before keydelay is 0 and the keys are checked again.
You can expand this example to have two different key delays for different
keys.  For example, you could have one for the arrow keys and one for the
rotating keys (this is highly desireable in a Tetris type program).  There
could also be certain keys that are always checked, such as ESC.
There's probably a better way (I'm no expert), but this works fine for me.
Hope this helps!



____________________________________________________________________
Get your own FREE, personal Netscape WebMail account today at http://webmail.netscape.com.



Follow-Ups: