Question

In a previous question , I asked how to interpret the event bytes from /dev/input/mice. Realizing now that /dev/input/mice does NOT give me the information I need, as I am using a touchscreen using the stmpe-ts driver. It is setup under EVDEV node /dev/input/event2, and using a personal program I built, I can obtain the neccessary bytes from this file. My only problem is translating that into Event Codes. Using evtest, I get this output:

    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)

I need those event codes, from the raw data obtained by reading directly from /dev/input/event2. This is as follows:

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 

Is this even possible to do? If so, can someone help me out here? (Also, I've determined that a pattern occurs every 16 bytes or so, I've also determined that 236 and 237 are byte stating that the event is a touch event, 236 being touch without click, and 237 being touch with click)

Was it helpful?

Solution

The output of evdev nodes is a series of struct input_event, defined in linux/input.h.

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

So all you need to do is read into an array of those structs and then access each type/code as needed. Don't know how to do that in Java, but it's probably not that hard.

evtest is free software btw, so you can look at the code and see what it does. Also look at libevdev, it's MIT license so you don't get 'tainted' by looking at it. http://www.freedesktop.org/wiki/Software/libevdev/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top