> I am developing a C application that operates a barcode reader. The
> reader hardware uses a PS/2 keyboard interface, with a split cable;
> one for the barcode reader, and one to plug the keyboard into.
> This is being developed under RedHat 6.2, with kernel 2.2.16. The
> problem is how I can open the local physical keyboard directly. I
> can't seem to find any /dev special file that correlates to the
> keyboard, and when I open stdin it seems the kernel always deals with
> the ingress data before handing it to me. For instance, when I hit
> Alt-F2, it changes consoles, instead of letting me read the data
> directly. Is it possible to "cut in front" of the kernel on the stdin
> device, so I can handle the input, and pass it to the kernel for
> normal processing, or drop it, or deal with it myself.
> Thank you,
> Hans Zauner
You have to set the tty and the keyboard into raw
mode. Here are a few lines from a program I wrote
doing something similar.
static struct termios ttysetings;
static void daemon_cleanup()
static inline int daemon_init(int flag)
struct termios modified=ttysetings;
modified.c_cflag &= ~HUPCL;
modified.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
The above example will not work within X, it requires
a textmode VC. Before you start using this, I suggest
you set up this little alias that might help you if
you accidentially leaves the keyboard in an unusable
state. Two presses on some key (which I don't remember)
will reenable translation.
alias `printf "\0203"`='kbd_mode -a'