[xorg-x11-drv-evdev] Fix device rotation through SwapAxes/Invert{X|Y} for touch devices
Peter Hutterer
whot at fedoraproject.org
Mon Jan 14 06:13:36 UTC 2013
commit 1ba122ea5d7a00b20fb4154ec1716e0fe550bcbe
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date: Mon Jan 14 16:11:29 2013 +1000
Fix device rotation through SwapAxes/Invert{X|Y} for touch devices
0001-Localise-tmp-variable.patch | 32 ++++++
...-valuator-swapping-into-a-helper-function.patch | 84 ++++++++++++++++
...alibration-adjustments-to-helper-function.patch | 102 ++++++++++++++++++++
...-swap-calibration-and-inversion-for-touch.patch | 30 ++++++
xorg-x11-drv-evdev.spec | 15 +++-
5 files changed, 262 insertions(+), 1 deletions(-)
---
diff --git a/0001-Localise-tmp-variable.patch b/0001-Localise-tmp-variable.patch
new file mode 100644
index 0000000..5068c93
--- /dev/null
+++ b/0001-Localise-tmp-variable.patch
@@ -0,0 +1,32 @@
+From 3b7ba39fcaf261f800205fd6cf45fea9998529e5 Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <peter.hutterer at who-t.net>
+Date: Mon, 14 Jan 2013 14:03:54 +1000
+Subject: [PATCH evdev 1/4] Localise tmp variable
+
+Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
+---
+ src/evdev.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/evdev.c b/src/evdev.c
+index 5667dc1..dfce8c4 100644
+--- a/src/evdev.c
++++ b/src/evdev.c
+@@ -424,7 +424,6 @@ EvdevQueueButtonClicks(InputInfoPtr pInfo, int button, int count)
+ static void
+ EvdevProcessValuators(InputInfoPtr pInfo)
+ {
+- int tmp;
+ EvdevPtr pEvdev = pInfo->private;
+ int *delta = pEvdev->delta;
+
+@@ -456,6 +455,7 @@ EvdevProcessValuators(InputInfoPtr pInfo)
+ }
+
+ if (pEvdev->rel_queued) {
++ int tmp;
+ int i;
+
+ if (pEvdev->swap_axes) {
+--
+1.8.1
diff --git a/0002-Move-valuator-swapping-into-a-helper-function.patch b/0002-Move-valuator-swapping-into-a-helper-function.patch
new file mode 100644
index 0000000..b4b74ed
--- /dev/null
+++ b/0002-Move-valuator-swapping-into-a-helper-function.patch
@@ -0,0 +1,84 @@
+From 069c035ab0787e6841159929199ae58502d89c4b Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <peter.hutterer at who-t.net>
+Date: Mon, 14 Jan 2013 14:07:26 +1000
+Subject: [PATCH evdev 2/4] Move valuator swapping into a helper function
+
+No functional changes.
+
+Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
+---
+ src/evdev.c | 52 +++++++++++++++++++++++++++++++---------------------
+ 1 file changed, 31 insertions(+), 21 deletions(-)
+
+diff --git a/src/evdev.c b/src/evdev.c
+index dfce8c4..f061324 100644
+--- a/src/evdev.c
++++ b/src/evdev.c
+@@ -418,6 +418,36 @@ EvdevQueueButtonClicks(InputInfoPtr pInfo, int button, int count)
+ }
+ }
+
++static void
++EvdevSwapAbsValuators(EvdevPtr pEvdev, ValuatorMask *mask)
++{
++ int i;
++ int swapped_isset[2] = {0, 0};
++ int swapped_values[2];
++
++ if (!pEvdev->swap_axes)
++ return;
++
++ for(i = 0; i <= 1; i++) {
++ if (valuator_mask_isset(mask, i)) {
++ swapped_isset[1 - i] = 1;
++ swapped_values[1 - i] =
++ xf86ScaleAxis(valuator_mask_get(mask, i),
++ pEvdev->absinfo[1 - i].maximum,
++ pEvdev->absinfo[1 - i].minimum,
++ pEvdev->absinfo[i].maximum,
++ pEvdev->absinfo[i].minimum);
++ }
++ }
++
++ for (i = 0; i <= 1; i++) {
++ if (swapped_isset[i])
++ valuator_mask_set(mask, i, swapped_values[i]);
++ else
++ valuator_mask_unset(mask, i);
++ }
++}
++
+ /**
+ * Take the valuators and process them accordingly.
+ */
+@@ -496,27 +526,7 @@ EvdevProcessValuators(InputInfoPtr pInfo)
+ else if (pEvdev->abs_queued && pEvdev->in_proximity) {
+ int i;
+
+- if (pEvdev->swap_axes) {
+- int swapped_isset[2] = {0, 0};
+- int swapped_values[2];
+-
+- for(i = 0; i <= 1; i++)
+- if (valuator_mask_isset(pEvdev->vals, i)) {
+- swapped_isset[1 - i] = 1;
+- swapped_values[1 - i] =
+- xf86ScaleAxis(valuator_mask_get(pEvdev->vals, i),
+- pEvdev->absinfo[1 - i].maximum,
+- pEvdev->absinfo[1 - i].minimum,
+- pEvdev->absinfo[i].maximum,
+- pEvdev->absinfo[i].minimum);
+- }
+-
+- for (i = 0; i <= 1; i++)
+- if (swapped_isset[i])
+- valuator_mask_set(pEvdev->vals, i, swapped_values[i]);
+- else
+- valuator_mask_unset(pEvdev->vals, i);
+- }
++ EvdevSwapAbsValuators(pEvdev, pEvdev->vals);
+
+ for (i = 0; i <= 1; i++) {
+ int val;
+--
+1.8.1
diff --git a/0003-Move-calibration-adjustments-to-helper-function.patch b/0003-Move-calibration-adjustments-to-helper-function.patch
new file mode 100644
index 0000000..1bdc53d
--- /dev/null
+++ b/0003-Move-calibration-adjustments-to-helper-function.patch
@@ -0,0 +1,102 @@
+From 2432626b70b7f55a337bcfdc9ba415811634c062 Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <peter.hutterer at who-t.net>
+Date: Mon, 14 Jan 2013 14:10:14 +1000
+Subject: [PATCH evdev 3/4] Move calibration adjustments to helper function
+
+No functional changes.
+
+Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
+---
+ src/evdev.c | 69 +++++++++++++++++++++++++++++++++----------------------------
+ 1 file changed, 37 insertions(+), 32 deletions(-)
+
+diff --git a/src/evdev.c b/src/evdev.c
+index f061324..1581d47 100644
+--- a/src/evdev.c
++++ b/src/evdev.c
+@@ -448,6 +448,42 @@ EvdevSwapAbsValuators(EvdevPtr pEvdev, ValuatorMask *mask)
+ }
+ }
+
++static void
++EvdevApplyCalibration(EvdevPtr pEvdev, ValuatorMask *mask)
++{
++ int i;
++
++ for (i = 0; i <= 1; i++) {
++ int val;
++ int calib_min;
++ int calib_max;
++
++ if (!valuator_mask_isset(mask, i))
++ continue;
++
++ val = valuator_mask_get(mask, i);
++
++ if (i == 0) {
++ calib_min = pEvdev->calibration.min_x;
++ calib_max = pEvdev->calibration.max_x;
++ } else {
++ calib_min = pEvdev->calibration.min_y;
++ calib_max = pEvdev->calibration.max_y;
++ }
++
++ if (pEvdev->flags & EVDEV_CALIBRATED)
++ val = xf86ScaleAxis(val, pEvdev->absinfo[i].maximum,
++ pEvdev->absinfo[i].minimum, calib_max,
++ calib_min);
++
++ if ((i == 0 && pEvdev->invert_x) || (i == 1 && pEvdev->invert_y))
++ val = (pEvdev->absinfo[i].maximum - val +
++ pEvdev->absinfo[i].minimum);
++
++ valuator_mask_set(mask, i, val);
++ }
++}
++
+ /**
+ * Take the valuators and process them accordingly.
+ */
+@@ -524,39 +560,8 @@ EvdevProcessValuators(InputInfoPtr pInfo)
+ * just works.
+ */
+ else if (pEvdev->abs_queued && pEvdev->in_proximity) {
+- int i;
+-
+ EvdevSwapAbsValuators(pEvdev, pEvdev->vals);
+-
+- for (i = 0; i <= 1; i++) {
+- int val;
+- int calib_min;
+- int calib_max;
+-
+- if (!valuator_mask_isset(pEvdev->vals, i))
+- continue;
+-
+- val = valuator_mask_get(pEvdev->vals, i);
+-
+- if (i == 0) {
+- calib_min = pEvdev->calibration.min_x;
+- calib_max = pEvdev->calibration.max_x;
+- } else {
+- calib_min = pEvdev->calibration.min_y;
+- calib_max = pEvdev->calibration.max_y;
+- }
+-
+- if (pEvdev->flags & EVDEV_CALIBRATED)
+- val = xf86ScaleAxis(val, pEvdev->absinfo[i].maximum,
+- pEvdev->absinfo[i].minimum, calib_max,
+- calib_min);
+-
+- if ((i == 0 && pEvdev->invert_x) || (i == 1 && pEvdev->invert_y))
+- val = (pEvdev->absinfo[i].maximum - val +
+- pEvdev->absinfo[i].minimum);
+-
+- valuator_mask_set(pEvdev->vals, i, val);
+- }
++ EvdevApplyCalibration(pEvdev, pEvdev->vals);
+ Evdev3BEmuProcessAbsMotion(pInfo, pEvdev->vals);
+ }
+ }
+--
+1.8.1
diff --git a/0004-Handle-axis-swap-calibration-and-inversion-for-touch.patch b/0004-Handle-axis-swap-calibration-and-inversion-for-touch.patch
new file mode 100644
index 0000000..bb0e101
--- /dev/null
+++ b/0004-Handle-axis-swap-calibration-and-inversion-for-touch.patch
@@ -0,0 +1,30 @@
+From 67e5376aaa62a1586fee37d610b3ad7e3b8bbcab Mon Sep 17 00:00:00 2001
+From: Peter Hutterer <peter.hutterer at who-t.net>
+Date: Mon, 14 Jan 2013 14:45:58 +1000
+Subject: [PATCH evdev 4/4] Handle axis swap, calibration, and inversion for
+ touch events (#59340)
+
+X.Org Bug 59340 <http://bugs.freedesktop.org/show_bug.cgi?id=59340>
+
+Reported-by: Bastien Nocera <hadess at hadess.net>
+Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
+---
+ src/evdev.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/evdev.c b/src/evdev.c
+index 1581d47..c689257 100644
+--- a/src/evdev.c
++++ b/src/evdev.c
+@@ -744,6 +744,9 @@ EvdevProcessTouch(InputInfoPtr pInfo)
+ type = XI_TouchUpdate;
+
+
++ EvdevSwapAbsValuators(pEvdev, pEvdev->mt_mask);
++ EvdevApplyCalibration(pEvdev, pEvdev->mt_mask);
++
+ EvdevQueueTouchEvent(pInfo, pEvdev->cur_slot, pEvdev->mt_mask, type);
+
+ pEvdev->slot_state = SLOTSTATE_EMPTY;
+--
+1.8.1
diff --git a/xorg-x11-drv-evdev.spec b/xorg-x11-drv-evdev.spec
index 156cdb5..502b622 100644
--- a/xorg-x11-drv-evdev.spec
+++ b/xorg-x11-drv-evdev.spec
@@ -8,7 +8,7 @@
Summary: Xorg X11 evdev input driver
Name: xorg-x11-drv-evdev
Version: 2.7.3
-Release: 4%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist}
+Release: 5%{?gitdate:.%{gitdate}git%{gitversion}}%{?dist}
URL: http://www.x.org
License: MIT
Group: User Interface/X Hardware Support
@@ -25,6 +25,12 @@ Source0: ftp://ftp.x.org/pub/individual/driver/%{tarball}-%{version}.tar.bz2
Patch02: 0001-Allow-relative-scroll-valuators-on-absolute-devices.patch
# fdo 58967 - Device with MT axes but no buttons triggers BUG macro
Patch03: 0001-Force-a-button-if-MT-axes-are-present-and-it-is-not-.patch
+# Fix axis inversion/swapping (i.e. device rotation) for touch devices
+Patch04: 0001-Localise-tmp-variable.patch
+Patch05: 0002-Move-valuator-swapping-into-a-helper-function.patch
+Patch06: 0003-Move-calibration-adjustments-to-helper-function.patch
+Patch07: 0004-Handle-axis-swap-calibration-and-inversion-for-touch.patch
+
ExcludeArch: s390 s390x %{?rhel:ppc ppc64}
@@ -45,6 +51,10 @@ X.Org X11 evdev input driver.
%setup -q -n %{tarball}-%{?gitdate:%{gitdate}}%{!?gitdate:%{version}}
%patch02 -p1 -b .relscroll
%patch03 -p1
+%patch04 -p1
+%patch05 -p1
+%patch06 -p1
+%patch07 -p1
%build
autoreconf --force -v --install || exit 1
@@ -86,6 +96,9 @@ X.Org X11 evdev input driver development files.
%changelog
+* Mon Jan 14 2013 Peter Hutterer <peter.hutterer at redhat.com> 2.7.3-5
+- Fix device rotation through SwapAxes/Invert{X|Y} for touch devices
+
* Thu Jan 10 2013 Adam Jackson <ajax at redhat.com> - 2.7.3-4
- ABI rebuild
More information about the scm-commits
mailing list