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

Re: How to handle keyboard inputy



> On Thu, 27 Apr 2000, Keith Lucas wrote:
> 
> > > Suggestions appreciated.
> > > 
> > 
> > 
> > I do it like this:
> > 
> > KeyboardFunc and SpecialFunc and so on read the in they store it in a
> > character buffer if it's a typeable character and it's a "down" event
> > and also in a keymap, so they keymap has the state of all the
> > buttons. I put all the mouse buttons and stuff in there as
> > well. Likewise the state holds the mouse positions and a little state
> > machine that knows what the mouse is doing ( moving, dragging,
> > clicking etc).
> > 
> > During the "idle" event I just read the state out. It means that the
> > idle one is the only one with any real processing happening in it, and
> > when it's called it's got a nice consistent state view of the keyboard
> > and mouse.
> 
> So, you sort of translate the stuff from glut into your own format and
> handle these?
> 
> But, that way you can not handle concurrent key presses, correct?


Oh yes: They're handled in the idle loop... there's a series of things like:

	motion[Z_AXIS]=0.0;
	if (gl().keydown('A'))
		motion[Z_AXIS]+=1.0;
	if (gl().keydown('Z'))
		motion[Z_AXIS]-=1.0;

Kind of thing.

The keymap stores the up and down events and is the queried to find
out what keys are down as we do the idle processing.


---------------------------------------------------------------------
To unsubscribe, e-mail: linuxgames-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: linuxgames-help@sunsite.auc.dk