Event Filter Config To Rotate Touchscreen Input

I have tried a few times to set up “event_filter” to rotate the touch input to match the framebuffer rotation, using the “rotate” or “reorient” tags, as described in the README, but without success.

Could someone provide a snippet of a working example of this, which I could use as a starting point.

Thanks!

Good point. I would also like to know how to rotate the touchscreen input. Then we could think about how to combine the two, but first one step at a time.

Sorry for the late reply. The transformations described in the README are, indeed, very basic. What worked for me with a display resolution of 2160x1440:

  • rotate the by screen 90 degree
  • add <reorient angle=”270” width=”1440” height=”2160”/> to the /config/event_filter

I had to find this by try-and-error using a surrounding <log motion=”yes”> around the <transform> node.

2 Likes

Oh, great. I will try it today.

That’s a quite valid remark. We should improve the README with the given example.

Ok, now it works. I had to rotate the display (using the intel_fb component in Leitzentrale) to 90° and the touchdisplay (using the reorient angle in event_filter) to 270 (or vice versa). I assigned to width and height the values of the rotated display.

Here the modified snippet from my /config/event-filter:

         <transform>
            <input name="usb"/>
            <scale x="0.164" y="0.164"/>
            <reorient angle="270" width="1080" height="1920" />
          </transform>
2 Likes

Looking at the implementation and refreshing my knowledge about rotation matrices from Wikipedia, I suspect that the rotation/reorientation is rather implemented as a counter-clockwise rotation. @chelmuth Can you confirm/refute that?

IIRC it’s implemented in the mathematical positive sense, i.e., counter-clockwise.

EDIT: The README states the opposite: Rotates clockwise (around origin (0,0) by 90, 180, or 270 degrees in attribute ‘angle’. So, maybe I’m mistaken.

I checked the implementation with a small Linux test. My memory is not deceiving me: rotate and reorient operate counter-clockwise.

(  5,  0)  rotate(90)  (  0,  5) ... (  5,  0)  reorient(90, 200, 100)  (199,  5)
(  0,  5)  rotate(90)  ( -5,  0) ... (  0,  5)  reorient(90, 200, 100)  (194,  0)
( 20, 10)  rotate(90)  (-10, 20) ... ( 20, 10)  reorient(90, 200, 100)  (189, 20)

I’ll improve the documentation accordingly.

EDIT: This commit on staging adapts the doc.

2 Likes

I’ve been on the road for the past week, so I’m just testing this now, and it worked! Woo Hoo! :tada:

Thanks for the tip! Things are getting interesting in touchscreen world…

Let me add a brief explanation for the rotation angle: When the framebuffer has been rotated by 90 degrees clockwise, e.g. using the intel_fb UI in the Leitzentrale, you need to rotate the device counter clockwise in order to compensate the framebuffer rotation. The configuration of the event filter must be seen in relation to the rotation of the device, not the framebuffer. This explains why the reorientation angle must be set to 270 in this example.

3 Likes