gpt4 book ai didi

c++ - input_event 结构描述(来自 linux/input.h)

转载 作者:IT老高 更新时间:2023-10-28 21:45:27 25 4
gpt4 key购买 nike

谁能告诉我 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

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

请帮忙!

最佳答案

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


来自5。 Linux 内核中的事件接口(interface) 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(操纵杆...)的绝对新值,或 EV_KEY0释放,1 表示按键,2 表示自动重复。

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

关于c++ - input_event 结构描述(来自 linux/input.h),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16695432/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com