0

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)

Community
  • 1
  • 1
  • pretty good question. Please enhance by editing question to include required output from this sample data. Good luck. – shellter May 05 '14 at 20:40
  • Thanks, Ill do that now... – Einstein12345 May 05 '14 at 20:49
  • ??? I only see <15 numbers in your sample. Why so many in your sample output. I don't see `236` anywhere in the sample input. Sample input-> Sample output, right? :-) Good luck. – shellter May 05 '14 at 21:04
  • The first code block is not sample input. Its the values I need to get from the bytes in my output. The first code block is actually output form evtest, a program that tells what event codes will spawn from a evdev device. For example, I need to turn the bytes above, the sample output, into those event codes. My problem is I don't have the knowledge of how to actually perform that operation. I'd be fine with a Library even, but nothing to do with GUI libs, such as X-related libraries, I'm running headless here. @shellter – Einstein12345 May 05 '14 at 22:08
  • Hm.. you said `Using evtest, I get this output: ` and then a nice eaily parseable block of text. You're saying that non of the values appearing in that output are the values you need? You need to "map" them to something else where some (undefined) text string turns into 100s of integers? If you can tell us `236 21 100 83 63 223 11 0` is derived from 'XYZ' in the sample text, I don't see how we can help you. ------------- You're best off trying to find a specialty support board for your touchscreen.-------- Good luck! – shellter May 05 '14 at 22:18
  • No, no, I am saying that there is a way to obtain the event codes from these bytes, and my problem is not knowing exactly how to do this. Yes, these bytes do represent that "nice easily parseable" output, but that nice output was derived from these. If evtest which is packaged with evdev, a program completely independent of my touchscreen can interpret these bytes, then I don't need a support board, I simply need some help in reading the bytes. As I said previously, I library would be great as well. Even a simple piece of code that acts like evtest would work – Einstein12345 May 05 '14 at 23:36

1 Answers1

1

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/

whot
  • 290
  • 1
  • 3
  • Thanks! This and JNI combined let me get this up and running. I just ended up using a callback style method within Java, and calling the method each time an event was fired. – Einstein12345 Aug 22 '14 at 17:29