/dev/kbd, keystroke access

coolbean nieters at eagle.crd.ge.com
Wed Feb 20 08:33:32 AEST 1991


hi
	i have been RTFM'ing for long enough!  time to post .... :-)

the problem:
	i want to write a program which will tell me if
	a key has been pressed on the keyboard.  i don't want to 
	intercept the key or modify it, i just want to catch the
	"interrupt" and count it.  ideally a blocking ioctl() or
	equivalent would be best but i can sit in a busy loop and
	poll until i see a key stroke, increment a counter, and continue.

the platform:
	running on a Sun 4/490 or Sparcstation equivalent

work so far:
	i've read kb(4M) a number of times and believe that it should
be possible to tell when a keyboard is idle because it speaks of a
	 #define IDLE 0x308  The keyboard is idle (no keys down)
therefore, it should be possible to tell when it is NOT idle, right?

/usr/include/sundev/kbd.h has some header comments that claim

 * When no physical keys are depressed, the keyboard transmits a keycode of
 * "IDLE" (7F hex), to indicate that.  Thus, when the last key is released,
 * a keycode for its release is sent, then an IDLE.

the following #defines are also contained in it
#define	IDLEKEY		0x7F		/* Keyboard is idle; no keys down */
#define	PRESSED		0x00		/* 0x80 bit off: key was pressed */
#define	RELEASED	0x80		/* 0x80 bit on : key was released */

i've played with ioctl()'s to turn on LED's, keyclick, bell, find type
of keyboard, etc. etc. etc. but i'm getting very confused with this
key-press thing!

if anyone has had experience doing this kind of thing, can you post a 
pointer to a solution?!  any help is greatly appreciated.

thanks in advance.

--ed

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Edward Nieters		     INTERnet: nieters at crd.ge.com
GE Corporate R&D	     BELLnet:  (518) 387-5187
Schenectady, NY 12301



More information about the Comp.unix.programmer mailing list