[PATCH 1/2] Clean up getValuatorEvents with token concatenation
Chase Douglas
chase.douglas at canonical.com
Mon Mar 28 10:53:47 PDT 2011
Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
dix/eventconvert.c | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/dix/eventconvert.c b/dix/eventconvert.c
index 7834d68..9fce447 100644
--- a/dix/eventconvert.c
+++ b/dix/eventconvert.c
@@ -358,6 +358,8 @@ countValuators(DeviceEvent *ev, int *first)
return num_valuators;
}
+#define set_valuator_value(xv, ev, num) \
+ xv->valuator##num = (ev)->valuators.data[(xv)->first_valuator + num];
static int
getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
{
@@ -383,19 +385,20 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
xv->num_valuators = ((num_valuators - i) > 6) ? 6 : (num_valuators - i);
xv->deviceid = ev->deviceid;
xv->device_state = state;
+
switch (xv->num_valuators) {
case 6:
- xv->valuator5 = ev->valuators.data[xv->first_valuator + 5];
+ set_valuator_value(xv, ev, 5);
case 5:
- xv->valuator4 = ev->valuators.data[xv->first_valuator + 4];
+ set_valuator_value(xv, ev, 4);
case 4:
- xv->valuator3 = ev->valuators.data[xv->first_valuator + 3];
+ set_valuator_value(xv, ev, 3);
case 3:
- xv->valuator2 = ev->valuators.data[xv->first_valuator + 2];
+ set_valuator_value(xv, ev, 2);
case 2:
- xv->valuator1 = ev->valuators.data[xv->first_valuator + 1];
+ set_valuator_value(xv, ev, 1);
case 1:
- xv->valuator0 = ev->valuators.data[xv->first_valuator + 0];
+ set_valuator_value(xv, ev, 0);
}
if (i + 6 < num_valuators)
@@ -404,6 +407,7 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv)
return (num_valuators + 5) / 6;
}
+#undef set_valuator_value
static int
--
1.7.4.1
More information about the xorg-devel
mailing list