【问题标题】:input_event structure description (from linux/input.h)input_event 结构描述(来自 linux/input.h)
【发布时间】:2013-05-17 17:18:31
【问题描述】:

谁能告诉我 input_event 结构使用的数据类型的属性是什么?

在input.h文件中定义如下:

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

但没有其他描述!甚至谷歌搜索也没有给我带来任何有趣的东西。

我唯一知道的是time 给出了纪元的秒数​​或毫秒数,value 给出了按下按钮的代码。但即使value 属性的值对我来说也不是很清楚。在我的程序中,每次击键都会产生六个事件。以下事件是按 ENTER 键的响应:

type=4,code=4,value=458792
type=1,code=28,value=1
type=0,code=0,value=0
type=4,code=4,value=458792
type=1,code=28,value=0
type=0,code=0,value=0 

那些是给a的信:

type=4,code=4,value=458756
type=1,code=30,value=1
type=0,code=0,value=0
atype=4,code=4,value=458756
type=1,code=30,value=0
type=0,code=0,value=0

我想将值解码为真正的字母,但我不明白属性的含义。

请帮忙!

【问题讨论】:

    标签: c++ c linux input structure


    【解决方案1】:

    struct input_eventinclude/linux/input.h 中定义。


    来自5。 Linux 内核Documentation/input/input.txt 中的事件接口(已修改以提供正确的头文件名):

    • time是时间戳,它返回事件发生的时间。

    • type 是例如 EV_REL 用于相对时间,EV_KEY 用于按键或 发布。 include/linux/input-event-codes.h 中定义了更多类型。

    • code 是事件代码,例如REL_XKEY_BACKSPACE,又是一个完整的 列表位于include/linux/input-event-codes.h

    • value 是事件携带的值。无论是相对变化 EV_RELEV_ABS(操纵杆 ...)的绝对新值,或 0EV_KEY 为 释放,1 用于按键,2 用于自动重复。

    如需指南和示例代码,请在网络上搜索"linux kernel" "input subsystem"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多