0

在上一个问题中,我询问了如何解释 /dev/input/mice 中的事件字节。现在意识到 /dev/input/mice 没有给我我需要的信息,因为我正在使用使用 stmpe-ts 驱动程序的触摸屏。它设置在 EVDEV 节点 /dev/input/event2 下,使用我构建的个人程序,我可以从该文件中获取必要的字节。我唯一的问题是将其转换为事件代码。使用 evtest,我得到以下输出:

    Input driver version is 1.0.1
    Input device ID: bus 0x18 vendor 0x0 product 0x0 version 0x0
    Input device name: "stmpe-ts"
    Supported events:
Event type 0 (EV_SYN)
Event type 1 (EV_KEY)
   Event code 330 (BTN_TOUCH)
Event type 3 (EV_ABS)
   Event code 0 (ABS_X)
     Value   2486
     Min        0
     Max     4095
   Event code 1 (ABS_Y)
     Value   1299
     Min        0
     Max     4095
   Event code 24 (ABS_PRESSURE)
     Value      0
     Min        0
     Max      255
Properties:
Testing ... (interrupt to exit)

我需要那些事件代码,来自直接从 /dev/input/event2 读取获得的原始数据。如下:

236 21 100 83 63 223 11 0 3 0 0 0 124 8 0 0 236 21 100 83 72 223 11 0 3 0 1 0 237 7 
0 0 236 21 100 83 76 223 11 0 3 0 24 0 60 0 0 0 236 21 100 83 80 223 11 0 1 0 74      
1 1 0 0 0 236 21 100 83 84 223 11 0 0 0 0 0 0 0 0 0 236 21 100 83 251 247 11 0 3 0 0 0 
123 8 0 0 236 21 100 83 6 248 11 0 3 0 1 0 242 7 0 0 236 21 100 83 10 248 11 0 3 0 24 
0 142 0 0 0 236 21 100 83 16 248 11 0 0 0 0 0 0 0 0 0 236 21 100 83 137 16 12 0 3 0 0 
0 121 8 0 0 236 21 100 83 147 16 12 0 3 0 1 0 7 8 0 0 236 21 100 83 150 16 12 0 3 0 24 
0 163 0 0 0 236 21 100 83 156 16 12 0 0 0 0 0 0 0 0 0 

这甚至可能吗?如果是这样,有人可以在这里帮助我吗?(另外,我已经确定每 16 个字节左右出现一个模式,我还确定 236 和 237 是表示事件是触摸事件的字节,236 是没有点击的触摸,237 是有点击的触摸)

4

1 回答 1

1

evdev节点的输出是一系列struct input_event,定义在linux/input.h中。

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

因此,您需要做的就是读入这些结构的数组,然后根据需要访问每个类型/代码。不知道如何在 Java 中做到这一点,但这可能并不难。

evtest 是免费软件顺便说一句,所以你可以看看代码,看看它做了什么。另请查看 libevdev,它是 MIT 许可证,因此您不会因查看它而受到“污染”。 http://www.freedesktop.org/wiki/Software/libevdev/

于 2014-08-21T10:19:16.360 回答