[comp.sys.sgi] qdevice and stuff.........

kaul@cunixa.cc.columbia.edu (Anil Kaul) (03/29/90)

Hi,                                                                             
   I have been trying to queue certain keys on the keyboard, but have           
come up with a strange error:                                                   
   Whenever I press a key it seems to record two enteries in the event           
queue. It appears that one entry is for key being depressed and the other       
for the key while being released. Is it true or am I messing up somewhere else?
I would actually like to get only one entry everytime the key is depressed.    
Is there something I can do to avoid getting two enteries from each key?        
                                                                                
Thanks,                                                                         
                                                                                
- Anil.         
 
email: kaul@ibm.com
       kaul@yktvmx.bitnet
       kaul@cunixa.cc.columbia.edu
                                                                
                                                                                
                                                                                

merritt@iris613.gsfc.nasa.gov (John H Merritt) (03/29/90)

In article <1990Mar28.192724.26499@cunixf.cc.columbia.edu> kaul@cunixa.cc.columbia.edu (Anil Kaul) writes:


>It appears that one entry is for key being depressed and the other       
>for the key while being released.

Precisely why one codes

		event = qread(&val)
		...
		if (val)   (button went down)
		if (!val)  (button went up)

>I would actually like to get only one entry everytime the key is depressed.

and one entry when it is released.

>Is there something I can do to avoid getting two enteries from each key?
                                              ^^^
0, 1, or more than 2 entries?  :-)

I've seen no routine which only queues the keyboard keys in only direction.
I simply choose to ignore the event.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
John H. Merritt                   #  Yesterday I knew nothing,
Applied Research Corporation      #  Today I know that.
merritt@iris613.gsfc.nasa.gov     #

blbates@AERO4.LARC.NASA.GOV ("Brent L. Bates AAD/TAB MS294 x42854") (03/29/90)

     Nothing strange about that, that is the way it works.  One entry
for the key going down and one when the key is released.  Same for 
mouse clicks.  If you have the b key queued and you press the b key
down then execute the following:

     dev=qread(val)

dev will equal "bkey" and val will be 1 for key down.  When you release
the key dev will equal "bkey" and val will be 0 for key up.
     When I queue keys, I usually ignore the event if val is 0.  At the
moment the only time I check for a key up event is when it is a mouse
button.
--

	Brent L. Bates
	NASA-Langley Research Center
	M.S. 361
	Hampton, Virginia  23665-5225
	(804) 864-2854
	E-mail: blbates@aero4.larc.nasa.gov or blbates@aero2.larc.nasa.gov

thant@horus.esd.sgi.com (Thant Tessman) (03/30/90)

In article <1990Mar28.192724.26499@cunixf.cc.columbia.edu>,
kaul@cunixa.cc.columbia.edu (Anil Kaul) writes:
> Hi,                                                                   
>    I have been trying to queue certain keys on the keyboard, but have 
> come up with a strange error:                                         
>    Whenever I press a key it seems to record two enteries in the event
> queue. It appears that one entry is for key being depressed and the
other       
> for the key while being released. Is it true or am I messing up
somewhere else?
> I would actually like to get only one entry everytime the key is
depressed.    
> Is there something I can do to avoid getting two enteries from each
key?        
>                                                                       

When you queue a button, and do:

	dev = qread(&val);

'dev' is set to the button number (as defined in "device.h"),
and 'val' is set to 1 if the button went down, and 0 if the
button went up.

If you only want ascii information from the keyboard, then
qdevice(KEYBD);  When a keyboard key is pressed, 'qread' will
set 'dev' to KEYBD and 'val' to the ascii value of the key.

Hope this helps,

thant

kj@sgi.com (Kenneth Josiah Harris) (03/30/90)

In article <1990Mar28.192724.26499@cunixf.cc.columbia.edu> kaul@cunixa.cc.columbia.edu (Anil Kaul) writes:
>Hi,                                                                             
>   I have been trying to queue certain keys on the keyboard, but have 
>come up with a strange error: 
>   Whenever I press a key it seems to record two enteries in the event 
>queue. It appears that one entry is for key being depressed and the other 
>for the key while being released. Is it true or am I messing up somewhere else?
>I would actually like to get only one entry everytime the key is depressed.    
>Is there something I can do to avoid getting two enteries from each key? 
>
>Thanks,
>
>- Anil.         
> 
>email: kaul@ibm.com
>       kaul@yktvmx.bitnet
>       kaul@cunixa.cc.columbia.edu
>                                                                
	You could queue the KEYBD device:

		qdevice(KEYBD);

	And then on "dev=qread(&val);",  "dev" will be "KEYBD", and "val" will
be the ASCII value of the character.
--
Ken J. Harris -- kj@sgi.com or {decwrl,pyramid,ucbvax}!sgi!kj