summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-01-14 14:07:26 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2013-01-14 15:28:34 +1000
commit069c035ab0787e6841159929199ae58502d89c4b (patch)
treef49ebaa40e13f369241ee1718b633fa0fcb4a7bf
parent3b7ba39fcaf261f800205fd6cf45fea9998529e5 (diff)
Move valuator swapping into a helper function
No functional changes. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/evdev.c52
1 files 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;