2

I have a specific problem - I would like to recognize source device of input events in my program. Let's assume, that I have two identical touchscreens attached to usb ports. My program is grabbing XButtonPressedEvent, XButtonReleaseEvent etc. but I would like to behave differently between events generated by first device and events generated by second device. I would like to match any of event fields to devices descriptor, devices xinput id, devices system id, or anything else identifying device.

Is it possible to implement?

If so I would appreciate any hints of how to do this.

Best Regards, PG!

  • What is displayed on the screens? If they are not mirrored, wouldn't you be able to tell them apart by the coordinates? Please explain the setup and what you want to achieve in more detail. – danzel Apr 3 '19 at 14:58
  • To be more precisely I would like to modify xinput_calibrator that would give me as an output calibration matrix and identifier of device for many identical touchscreens. The assumptions are, that touchscreens are completely decalibrated, so recognition based on coordinates is not a solution. – Piotrek Apr 4 '19 at 8:14
1

It seems that this is not supported with the old XInput extension. You'll need to use XInput2 which reports the device id for each button press. The original author posted a series on his blog explaining some important aspects (part1,part2,part3) and a few complete code examples are available here. Since the xinput command line utility supports both extensions, you can look at its source code, especially test_xi2.c, to get an idea how to use XInput2.

xinput_calibrator uses the old XInput version (see here). While you could try using XInput2 in parallel, YMMV because there are certain limitations regarding interoperability of the two versions as described here.

However, since xinput_calibrator is known to do poor calculation of the transformation matrix, someone wrote a small python3 script (xcal) to calibrate touch screens. It is a lot simpler than xinput_calibrator and thus may be easier to adapt to your needs. Additonally, the python3-xlib library (available in ubuntu's repositories) does use XInput2 by default (if it is available), and therefore each button press event will contain the source device id.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.