nanogui: Really raw keyboard?


Previous by date: 20 Feb 2001 15:11:19 -0000 Re: Query: How to create a window with title bar, close button, Jordan Crouse
Next by date: 20 Feb 2001 15:11:19 -0000 Re: Really raw keyboard?, Tomasz Motylewski
Previous in thread: 20 Feb 2001 15:11:19 -0000 Really raw keyboard?, Tomasz Motylewski
Next in thread: 20 Feb 2001 15:11:19 -0000 Re: Really raw keyboard?, Tomasz Motylewski

Subject: Re: Really raw keyboard?
From: Jordan Crouse ####@####.####
Date: 20 Feb 2001 15:11:19 -0000
Message-Id: <3A928A2A.7B3EDF37@censoft.com>

So generally, what you are saying is that you want to detect when
certain buttons are pressed and released, correct?  If you examine it
closely, thats exactly how Microwindows works.  The server can handle
key down and key up events (repetition is handled by multiple events as
read from the keyboard driver).  

So your nano-X application simply needs to look for the
GR_EVENT_TYPE_KEY_DOWN and GR_EVENT_TYPE_KEY_UP events and adjust a
bitmask accordingly.  Here is what I would do:

#define KEY_A  0x01
#define KEY_B  0x02
#define KEY_C  0x04

unsigned char bitmask = 0;

/* SET UP YOUR WINDOW UP HERE */

while(1)
{
	GR_EVENT event;
	GrGetNextEvent(&event);

	switch(event.type)
	{
	 	case GR_EVENT_TYPE_KEY_DOWN:
			if (event.keystroke.ch == 'A') bitmask |= KEY_A;
			/* Other keys handled in the same way */
		break;
	
		case GR_EVENT_TYPE_KEY_UP:
			if (event.keystroke.ch == 'A') bitmask &= ~KEY_A;
			/* Other keys handled in the same way */
		break;
	}	
}	

Then, you would simply need to examine the value of the bitmask to find
out which keys are down. 

Happy hacking! 

Tomasz Motylewski wrote:
> 
> Hello,
> 
> Is there any possibility to switch OFF the autorepetition mode in the
> keyboard driver in nano-X (Linux)?
> 
> In our application we need to detect whether more than one keys are
> pressed at once.
> 
> Best regards,
> --
> Tomasz Motylewski
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####

Previous by date: 20 Feb 2001 15:11:19 -0000 Re: Query: How to create a window with title bar, close button, Jordan Crouse
Next by date: 20 Feb 2001 15:11:19 -0000 Re: Really raw keyboard?, Tomasz Motylewski
Previous in thread: 20 Feb 2001 15:11:19 -0000 Really raw keyboard?, Tomasz Motylewski
Next in thread: 20 Feb 2001 15:11:19 -0000 Re: Really raw keyboard?, Tomasz Motylewski


Powered by ezmlm-browse 0.20.