[PATCH 7/9] input: remove "mode" field from ValuatorClassRec.

Peter Hutterer peter.hutterer at who-t.net
Thu Oct 21 23:29:34 PDT 2010


We have per-axis mode now. For those bits that still need it (XI 1.x),
assume that the first axis holds the device's mode.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xi/exevents.c            |    3 +--
 Xi/listdev.c             |    7 ++++---
 Xi/queryst.c             |    1 +
 Xi/setmode.c             |    2 +-
 hw/dmx/input/dmxevents.c |    2 +-
 include/inputstr.h       |    1 -
 test/input.c             |    2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 9bff2b3..d57265e 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -556,7 +556,6 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
 
         v->axisVal = (double*)(v->axes + from->valuator->numAxes);
         v->sourceid = from->id;
-        v->mode = from->valuator->mode;
     } else if (to->valuator && !from->valuator)
     {
         ClassesPtr classes;
@@ -1177,7 +1176,7 @@ FixDeviceStateNotify(DeviceIntPtr dev, deviceStateNotify * ev, KeyClassPtr k,
 	int nval = v->numAxes - first;
 
 	ev->classes_reported |= (1 << ValuatorClass);
-	ev->classes_reported |= (dev->valuator->mode << ModeBitsShift);
+	ev->classes_reported |= valuator_get_mode(dev, 0) << ModeBitsShift;
 	ev->num_valuators = nval < 3 ? nval : 3;
 	switch (ev->num_valuators) {
 	case 3:
diff --git a/Xi/listdev.c b/Xi/listdev.c
index 3e5f3d9..2b2f294 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -230,10 +230,11 @@ CopySwapKeyClass(ClientPtr client, KeyClassPtr k, char **buf)
  */
 
 static int
-CopySwapValuatorClass(ClientPtr client, ValuatorClassPtr v, char **buf)
+CopySwapValuatorClass(ClientPtr client, DeviceIntPtr dev, char **buf)
 {
     int i, j, axes, t_axes;
     char n;
+    ValuatorClassPtr v = dev->valuator;
     xValuatorInfoPtr v2;
     AxisInfo *a;
     xAxisInfoPtr a2;
@@ -247,7 +248,7 @@ CopySwapValuatorClass(ClientPtr client, ValuatorClassPtr v, char **buf)
 	v2->class = ValuatorClass;
 	v2->length = sizeof(xValuatorInfo) + t_axes * sizeof(xAxisInfo);
 	v2->num_axes = t_axes;
-	v2->mode = v->mode & DeviceMode;
+	v2->mode = valuator_get_mode(dev, 0);
 	v2->motion_buffer_size = v->numMotionEvents;
 	if (client && client->swapped) {
 	    swapl(&v2->motion_buffer_size, n);
@@ -286,7 +287,7 @@ CopySwapClasses(ClientPtr client, DeviceIntPtr dev, CARD8 *num_classes,
     }
     if (dev->valuator != NULL) {
 	(*num_classes) +=
-	    CopySwapValuatorClass(client, dev->valuator, classbuf);
+	    CopySwapValuatorClass(client, dev, classbuf);
     }
 }
 
diff --git a/Xi/queryst.c b/Xi/queryst.c
index 9c9e4e0..73af76d 100644
--- a/Xi/queryst.c
+++ b/Xi/queryst.c
@@ -151,6 +151,7 @@ ProcXQueryDeviceState(ClientPtr client)
 	tv->class = ValuatorClass;
 	tv->length = sizeof(xValuatorState) + v->numAxes * 4;
 	tv->num_valuators = v->numAxes;
+	tv->mode = valuator_get_mode(dev, 0);
 	tv->mode |= (dev->proximity && !dev->proximity->in_proximity) ? OutOfProximity : 0;
 	buf += sizeof(xValuatorState);
 	for (i = 0, values = v->axisVal; i < v->numAxes; i++) {
diff --git a/Xi/setmode.c b/Xi/setmode.c
index ce2ad47..42e90f7 100644
--- a/Xi/setmode.c
+++ b/Xi/setmode.c
@@ -110,7 +110,7 @@ ProcXSetDeviceMode(ClientPtr client)
 	rep.status = SetDeviceMode(client, dev, stuff->mode);
 
     if (rep.status == Success)
-	dev->valuator->mode = stuff->mode;
+        valuator_set_mode(dev, VALUATOR_MODE_ALL_AXES, stuff->mode);
     else if (rep.status != AlreadyGrabbed)
     {
 	switch(rep.status) {
diff --git a/hw/dmx/input/dmxevents.c b/hw/dmx/input/dmxevents.c
index 9925e16..0360517 100644
--- a/hw/dmx/input/dmxevents.c
+++ b/hw/dmx/input/dmxevents.c
@@ -301,7 +301,7 @@ static void dmxExtMotion(DMXLocalInputInfoPtr dmxLocal,
 
     if (axesCount > DMX_MAX_AXES) axesCount = DMX_MAX_AXES;
 
-    if ((pDevice->valuator->mode == Relative) && axesCount == 2) {
+    if ((valuator_get_mode(pDevice,0) == Relative) && axesCount == 2) {
                                 /* The dmx console is a relative mode
                                  * device that sometimes reports
                                  * absolute motion.  It only has two
diff --git a/include/inputstr.h b/include/inputstr.h
index cd66876..d4c253e 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -240,7 +240,6 @@ typedef struct _ValuatorClassRec {
     AxisInfoPtr 	  axes;
     unsigned short	  numAxes;
     double		  *axisVal; /* always absolute, but device-coord system */
-    CARD8	 	  mode;
     ValuatorAccelerationRec	accelScheme;
 } ValuatorClassRec, *ValuatorClassPtr;
 
diff --git a/test/input.c b/test/input.c
index f94a4d4..daadbea 100644
--- a/test/input.c
+++ b/test/input.c
@@ -66,7 +66,6 @@ static void dix_init_valuators(void)
     g_assert(val);
     g_assert(val->numAxes == num_axes);
     g_assert(val->numMotionEvents == 0);
-    g_assert(val->mode == Absolute);
     g_assert(val->axisVal);
 
     for (i = 0; i < num_axes; i++)
@@ -74,6 +73,7 @@ static void dix_init_valuators(void)
         g_assert(val->axisVal[i] == 0);
         g_assert(val->axes->min_value == NO_AXIS_LIMITS);
         g_assert(val->axes->max_value == NO_AXIS_LIMITS);
+        g_assert(val->axes->mode == Absolute);
     }
 
     g_assert(dev.last.numValuators == num_axes);
-- 
1.7.2.3



More information about the xorg-devel mailing list