[maemo-developers] How to capture ALL key events, no focus/No-GUI

From: Rémi Denis-Courmont remi.denis-courmont at nokia.com
Date: Thu Jan 28 12:23:41 EET 2010
On Thursday 28 January 2010 11:53:13 ext Stefan Iwanowitsch, you wrote:
> > If you just want to see keyboard input, then you'd open the corresponding
> > file(s) in /dev/input/.
> Can I read from /dev/input without interfering with other consumers?

It should work yes.

> And do you happen to know, where I can find specs
> on the input device files?

/sys/class/input provides informations on each entries.

The protocol is documented in Documentation/input/ in the kernel sources:

|  You can use blocking and nonblocking reads, also select() on the
| /dev/input/eventX devices, and you'll always get a whole number of input
| events on a read. Their layout is:
| struct input_event {
|         struct timeval time;
|         unsigned short type;
|         unsigned short code;
|         unsigned int value;
| };
|   'time' is the timestamp, it returns the time at which the event happened.
| Type is for example EV_REL for relative moment, EV_KEY for a keypress or
| release. More types are defined in include/linux/input.h.
|   'code' is event code, for example REL_X or KEY_BACKSPACE, again a complete
| list is in include/linux/input.h.
|   'value' is the value the event carries. Either a relative change for
| EV_REL, absolute new value for EV_ABS (joysticks ...), or 0 for EV_KEY for
| release, 1 for keypress and 2 for autorepeat.

Rémi Denis-Courmont
Nokia Devices R&D, Maemo Software, Helsinki
More information about the maemo-developers mailing list