Skip to Content
Linux Device Drivers Development
book

Linux Device Drivers Development

by John Madieu
October 2017
Intermediate to advanced
586 pages
14h 8m
English
Packt Publishing
Content preview from Linux Device Drivers Development

The user space interface

Every registered input device is represented by a /dev/input/event<X> char device, from which we can read the event from the user space. An application reading this file will receive event packets in the struct input_event format:

struct input_event { 
  struct timeval time; 
  __u16 type; 
  __u16 code; 
  __s32 value; 
} 

Let's look at the meaning of each element in the structure:

  • time is the timestamp. It returns the time at which the event happened.
  • type is the event type; for example, EV_KEY for a key press or release, EV_REL for a relative moment, or EV_ABS for an absolute one. More types are defined in include/linux/input-event-codes.h.
  • code is the event code; for example, REL_X or KEY_BACKSPACE. Again, a complete list ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Linux Device Drivers, Second Edition

Linux Device Drivers, Second Edition

Jonathan Corbet, Alessandro Rubini
Linux Device Drivers, 3rd Edition

Linux Device Drivers, 3rd Edition

Jonathan Corbet, Alessandro Rubini, Greg Kroah-Hartman

Publisher Resources

ISBN: 9781785280009Supplemental Content