Mail Archives: djgpp/1997/05/10/21:46:49
From: | Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Need Shawn's (or anybody's) advice on making joystick buffer...
|
Date: | Sat, 10 May 1997 19:22:41 +0100
|
Organization: | None
|
Distribution: | world
|
Message-ID: | <vFsYmAAxzLdzEwIa@talula.demon.co.uk>
|
References: | <5kp6mt$44dm AT elmo DOT cadvision DOT com>
|
NNTP-Posting-Host: | talula.demon.co.uk
|
MIME-Version: | 1.0
|
Lines: | 36
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Calvin French writes:
>whenever a key is hit, but for the joy buffer all I can think to do is
>have a little little routine which is polled, say, 5 or 10 times a sec
Sounds very plausible to me. You could even try putting this poll code
inside a timer handler, so the buffer will be filled in the background
without you having to keep manually polling the position.
One thing to be aware of, though, is that on many cheap joysticks the
buttons will 'bounce' a few times when they are pressed or released, so
you need to be careful in determining exactly what constitutes a click.
If you do something obvious like:
for (;;) {
do {
poll_joystick();
} while (!joy_b1);
printf("click!\n");
do {
poll_joystick();
} while (joy_b1);
printf("release!\n");
}
you are liable to get several duplicate events each time the button is
pressed, so you should wait some small amount of time (in fact those
printf() statements are probably plenty long enough) before re-reading
the state...
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.
- Raw text -