Index: [thread] [date] [subject] [author]
  From: Tristan Wibberley <bloater@ps.cus.umist.ac.uk>
  To  : ggi-develop@eskimo.com
  Date: Thu, 11 Feb 1999 10:16:55 +0000 (GMT)

Re: Keyboard input

On Wed, 10 Feb 1999, Evan Martin wrote:

> I'm developing a game using ggi. (Let's see if I ever finish!)
> 
> The main loop checks and responds to keyboard events, using
> ggiEventPoll.
> 
> My problem is, I need to determine whether a key is down on each
> iteration of the loop.
> 
> If I use ggiEventPoll followed by ggiEventRead, it is possible for
> multiple key events to become queued up, making control unusable.
> 
> Currently, I do the following:
> 
> if (ggiEventPoll(vis, emKey, &tv)) {
> 	ggi_event ev;
> 	do {
> 		ggiEventRead(vis, &ev, emKey);  //eat multiple events
> 		tv.tv_sec = tv.tv_usec = 0;
> 	} while (ggiEventPoll(vis, emKey, &tv));
> 	
> 	// parse key 
> 
> But even with this, holding down a key causes an inital event (KeyPress)
> followed by a delay, and then a succession of events (KeyRepeat).
> 
> The delay makes the control seem laggy.  
> 
> I'm using the X target.  I fear this problem may be caused by X 
> handling events...
> 
> Is there a better way, or way around this?

Once you get the KeyPress event, you know the key is down, so you just
make your game do whatever as if the key is down. When the key is
released, you'll get a KeyRelease event, which tells you to stop.

--
Tristan

Index: [thread] [date] [subject] [author]