Transform touchscreen coordinates according to randr rotation.
authorLars-Peter Clausen <lars@metafoo.de>
Wed, 18 Feb 2009 22:15:20 +0000 (22:15 +0000)
committerLars-Peter Clausen <lars@metafoo.de>
Wed, 18 Feb 2009 22:15:20 +0000 (22:15 +0000)
SVN-Revision: 14559

Xorg/driver/xf86-input-tslib/patches/015-add-randr-support.patch [new file with mode: 0644]

diff --git a/Xorg/driver/xf86-input-tslib/patches/015-add-randr-support.patch b/Xorg/driver/xf86-input-tslib/patches/015-add-randr-support.patch
new file mode 100644 (file)
index 0000000..4ea7c7f
--- /dev/null
@@ -0,0 +1,51 @@
+commit b80f653bf33ed0ec23223a9877068cba97850ed1
+Author: Lars-Peter Clausen <lars@metafoo.de>
+Date:   Wed Feb 18 23:08:14 2009 +0100
+
+    Transform touchscreen coordinates according to randr rotation.
+
+diff --git a/src/tslib.c b/src/tslib.c
+index 3eba078..6091006 100644
+--- a/src/tslib.c
++++ b/src/tslib.c
+@@ -48,6 +48,7 @@
+ #include <exevents.h>         /* Needed for InitValuator/Proximity stuff */
+ #include <X11/keysym.h>
+ #include <mipointer.h>
++#include <randrstr.h>
+ #include <tslib.h>
+@@ -128,6 +129,8 @@ static void ReadInput (LocalDevicePtr local)
+       struct ts_sample samp;
+       int ret;
+       int x,y;
++      ScrnInfoPtr pScrn = xf86Screens[priv->screen_num];
++      Rotation rotation = RRGetRotation(pScrn->pScreen);
+       ret = ts_read(priv->ts, &samp, 1);
+@@ -154,6 +157,23 @@ static void ReadInput (LocalDevicePtr local)
+               default:                break;
+               }
++              tmp_x = samp.x;
++
++              switch(rotation) {
++              case RR_Rotate_90:
++                      samp.x = (priv->height - samp.y - 1) * priv->width / priv->height;
++                      samp.y = tmp_x * priv->height / priv->width;
++                      break;
++               case RR_Rotate_180:
++                      samp.x = priv->width - samp.x - 1;
++                      samp.y = priv->height - samp.y - 1;
++                      break;
++              case RR_Rotate_270:
++                      samp.x = samp.y * priv->width / priv->height;
++                      samp.y = (priv->width - tmp_x - 1) * priv->height / priv->width;
++                      break;
++              }
++
+               priv->lastx = samp.x;
+               priv->lasty = samp.y;
+               x = samp.x;