Re: [A89: Re: OSInitBetweenKeyDelay]
[Prev][Next][Index][Thread]
Re: [A89: Re: OSInitBetweenKeyDelay]
Hello again!
Yeah, I have that problem too. I had planned on ignoring the problem in
my program (it's not bad if the delay is small), but maybe I'll give it a
second look.
The problem is, you don't want to repeat fast if the user is holding the
key, but if he/she lets go of the key and presses it again, you want to act
on that. Maybe the delay countdown could continue while _rowread()
continues to indicate that the key is pressed, and if the key is released,
the delay could be set to 0. I'll let you know if that works for me.
James Darpinian
----- Original Message -----
From: Bubba Stinky <BubbaStinky@netscape.net>
To: <assembly-89@lists.ticalc.org>
Sent: Tuesday, August 08, 2000 9:37 PM
Subject: 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:
References: