Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Libinput CTM: Matrix Math Help!

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
laserted
Posts: 2
Joined: 2020-05-05 19:52

Libinput CTM: Matrix Math Help!

#1 Post by laserted »

Hi guys- I've been a Debian guy for a lot of years and have bungled my way through many touchscreen interface installs (serial, usb, i2c, etc) mostly with either vendor-specific or the old evdev driver. I have a current Deb9 install on an x64 AMD processor with a USB 5-wire touchscreen, specifically registering with the eGalax Inc USB TouchController chipset (a pretty common aftermarket one), attached to a 1024x768 landscape display.

That said, matrix math sucks, unless you're a matrix math wizard. I did 3x3 and 4x4 transforms in high school, and I understand "some" of the affine rules because of some work I do with OpenCV, but I really don't think anyone should be expected to figure out a matrix transform to install a touchscreen on a Desktop PC.

In an earlier time, I would kill libinput and replace it with the evdev driver - except of recent, the evdev driver is broken in the regular distribution. (There is a "recompile-from-scratch-and-patch-if-you-dare" solution), but the distributed version does not perform the "SwapXY" or "SwapAxes" functions. I have no desire to install a compiler dev-environment on each of these PCs I'm working on just to get a driver patched. Aside from the security risks, it's a waste of valuable time.

This touchscreen kit requires me to rotate the touch 90 degrees clockwise, then flip X values (mirror over the Y axis, if you prefer) - (for the uninitiated, please refer to other posts/blogs about how to get started with xinput and setting the CTM's.)

I have found websites and man pages (yes, I did read the wiki and man pages) to EITHER rotate OR FLIP, but not both at one time.
For example, from one resource, if I set the CTM to 0 1 0 -1 0 1 0 0 1 (which is a rotate left 90 deg), my cursor moves up and down correctly, but when finger moves left, cursor moves right - thus I now need to perform a mirroring of X values (around Y axis).
Alternatively, if I set the CTM to a left-rotate (indicated as 0 -1 1 1 0 0 0 0 1) cursor follows finger left-right but now the cursor moves upwards when the finger moves downwards. For this mirroring is still needed but around the X (inverting the Y values)

This honestly destroyed a day's worth of time and I'm surprised it got out the door with as much as a debacle it is. What I would like is to hope that there are some very kind, wise and math-savvy individuals out there that would simply respond with the transform that has the rotation and the mirroring (either of the above examples) done for me, or if there is a real tool that will work for calibration, please point me to it. Oh yes, xinput-calibrator doesn't work with libinput, so no need to be suggesting that, thanks.

Kindest regards in all things linux!
Ted.

User avatar
pylkko
Posts: 1802
Joined: 2014-11-06 19:02

Re: Libinput CTM: Matrix Math Help!

#2 Post by pylkko »

here is a visualizer for the matrix transforms
https://codepen.io/GottZ/full/pWpNgK/

then enter it into udev with something like

Code: Select all

ENV{ID_VENDOR_ID}=="XXXX",ENV{ID_MODEL_ID}=="XXXX",ENV{WL_OUTPUT}="XXXX",ENV{LIBINPUT_CALIBRATION_MATRIX}="1 0 0 0 1 0"

laserted
Posts: 2
Joined: 2020-05-05 19:52

Re: Libinput CTM: Matrix Math Help!

#3 Post by laserted »

Thank you, though, that site was one of the ones I noted as reference (just not the specific url) - and the button presets only work one at a time, not cascaded, so there isn't an example of how to do two functions simultaneously.

So since there also isn't an author link on that page (next thought was perhaps the person who wrote that page is rather good at matri), I just went back at it brute-force. Note that running in the GottZ simulator is not different that editing the xinput live ($ xinput set-prop 'eGalax Inc. USB TouchController' "Coordintate Transformation Matrix" 1 0 0 0 1 0 0 0 1 (this is a natural 1:1 mapping)

But brute force it was - about an hour or two later - merely moving the 1's, -1's and zeroes around with no understanding of what was really going on, I came up with: 0 -1 1 -1 0 1 1 0 0 1 (the last 3 digits are ALWAYS 0 0 1, that I knew, since that's the Z-vector of the matrix)

And just because I may as well leave it here for posterity, my 1024x768 lcd with a 4:3 landscape mounted 5-wire touch panel, with sensor mounted on the left-hand side, the scaled transformation matrix including offsets looks like this: 0 -1.25 1.119 -1.33 0 1.137 0 0 1

I still think this is a lousy deployment - my best wishes and gratitude to whomever rebuilds xinput_calibrator to work with libinput. Clearly it's something that is going to be needed in the future as evdev becomes depreciated. But past that, since I have a working input I can transpose to the other machines, this doesn't hold my attention anymore, nor my concerns.
Cheers,
Ted.

User avatar
pylkko
Posts: 1802
Joined: 2014-11-06 19:02

Re: Libinput CTM: Matrix Math Help!

#4 Post by pylkko »

Yes, I agree. It is always nice when open source community projects are supported by all of us!

Post Reply