Format of /dev/input/event*
Right here in the Input.py module. You'll also need the event.py module.
/dev/input keyboard format
/dev/input/by-path/platform-i8042-serio-0-event-kbd
is just a symlink to /dev/input/eventX
event device file. Data can be read from event device files as
struct input_event {
struct timeval time;
__u16 type;
__u16 code;
__s32 value;
};
defined in /usr/include/linux/input.h
.
Possible values of type
are prefixed with EV_
.
Possible values of code
depend on type
. They are prefixed with KEY_
or BTN_
or REL_
or so on.
Possible values of value
depend on both type
and code
. For example for key-press events value
equals 1
and for key-release events 0
.
You can examine event data with:
evtest /dev/input/eventX
where X
is the event device number of your keyboard (or any other event device). One key press or release normally emits three events (EV_MSC
, EV_KEY
and EV_SYN
).
What is the format of /dev/input/by-path/pci-xxx-kbd output?
I would guess that they are scan codes. This page lists the make and break codes of keys used by modern keyboards. For more information on PS/2 keyboard programming, see Adam Chapweske's resources.
Getting live info from /dev/input
This page: http://scaryreasoner.wordpress.com/2008/02/22/programming-joysticks-with-linux/ has a nice writeup on how to read the info from /dev/input/js0
The format of the events you read from the file are documented here: https://www.kernel.org/doc/Documentation/input/input.txt . It's a simple struct containing a timestamp, the event type and identifier and the value:
struct input_event {
struct timeval time;
unsigned short type;
unsigned short code;
unsigned int value;
};
Related Topics
Why Is Reading Lines from Stdin Much Slower in C++ Than Python
Is There Go Up Line Character? (Opposite of \N)
Sending Data from HTML Form to a Python Script in Flask
Decode HTML Entities in Python String
Strip HTML from Strings in Python
Post Values from an HTML Form and Access Them in a Flask View
How to Retrieve the Values of Dynamic HTML Content Using Python
How to Unescape HTML Entities in a String in Python 3.1
How to Convert Webpage into Pdf by Using Python
Convert Rgb Color to English Color Name, Like 'Green' With Python
How to Terminate a Python Subprocess Launched With Shell=True
How to Control the Source Ip Address of a Zeromq Packet on a Machine With Multiple Ips
How to Use 'Subprocess' Command With Pipes
Imagemagick Not Authorized to Convert Pdf to an Image
MySQL_Config Not Found When Installing MySQLdb Python Interface