I am wondering if someone can help me read characters (or scan codes)
directly from the keyboard, without using standard input. I am still
very new to Linux programming, so please bear with me if these are silly
Here is what I am trying to do:
A Gumstix Overo with a console image will have a USB keyboard connected,
and a simple 4x20 LCD display connected via I2C. I am writing software
that runs on the Gumstix as a daemon process, monitors other devices
connected to the Overo, and displays various bits of information on the
LCD. The user should be able to plug in a USB keyboard at will, change
some settings and make adjustments, and then unplug the keyboard. The
keyboard and I2C LCD will be the only human interface devices.
Keyboard input is usually read from stdin in a console session, if I
understand correctly. In this case, there will be no console session
associated with the daemon, and thus I think no stdin to read from.
Therefore, I am looking for ways on how to accomplish the following:
* How can the daemon process detect when a USB keyboard is connected
and disconnected? Is it possible to detect the presence of a
generic character input device, or... ?
* How can the daemon process monitor the keyboard for key presses,
without reading from stdin? I am looking for something like a
getch() function that can read characters or scan codes directly
from the keyboard without using stdin.
* Alternately, is there some way to redirect stdin to read from the
keyboard, once the keyboard has been detected?
I thought of the possibility of ssh'ing into the Overo, in order to
access the control interface. However, there will be no Wifi on this
device, and while it's possible to leave an Ethernet port accessible,
the user would still need another computer to control the Overo. I would
enjoy the ability to use any old $10 USB keyboard to control the device.
It's cheap and simple, and also lets me disable networking, which may
provide a layer of security (these units will be left unattended in
publicly accessible areas).
Help is much appreciated.
All the best,