Format of /dev/input/event*

前端 未结 5 2277
孤街浪徒
孤街浪徒 2020-11-28 04:54

What is the \"format\" of the character devices located in /dev/input/event*?

In other words, how can I decode the character stream? A Python example w

5条回答
  •  天涯浪人
    2020-11-28 05:44

    The format is described in the Documentation/input/input.txt file in the Linux source. Basically, you read structs of the following form from the file:

    struct input_event {
        struct timeval time;
        unsigned short type;
        unsigned short code;
        unsigned int value;
    };
    

    type and code are values defined in linux/input.h. For example, type might be EV_REL for relative moment of a mouse, or EV_KEY for a keypress, and code is the keycode, or REL_X or ABS_X for a mouse.

提交回复
热议问题