summaryrefslogtreecommitdiff
path: root/Xi
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-08-10 14:07:54 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-08-13 11:19:36 +1000
commit3f2e4b9867b6877ee7be32b151fcaf221ef0812f (patch)
treed3dc60fbe50d3e2cd7c03c1dfe96be0fe2ad1ded /Xi
parentf3b2f9fb734ecfff6db9ae85b0d247856ede8112 (diff)
Xi: add event swapping for XIRawEvents.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'Xi')
-rw-r--r--Xi/extinit.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/Xi/extinit.c b/Xi/extinit.c
index 4c8857dc6..2b75b3dab 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -810,6 +810,48 @@ static void SXIPropertyEvent(xXIPropertyEvent *from, xXIPropertyEvent *to)
swapl(&to->property, n);
}
+static void SRawEvent(xXIRawEvent *from, xXIRawEvent *to)
+{
+ char n;
+ int i;
+ FP3232 *values;
+ unsigned char *mask;
+
+ memcpy(to, from, sizeof(xEvent) + from->length * 4);
+
+ swaps(&to->sequenceNumber, n);
+ swapl(&to->length, n);
+ swaps(&to->evtype, n);
+ swaps(&to->deviceid, n);
+ swapl(&to->time, n);
+ swapl(&to->detail, n);
+
+
+ mask = (unsigned char*)&to[1];
+ values = (FP3232*)(mask + from->valuators_len * 4);
+
+ for (i = 0; i < from->valuators_len * 4 * 8; i++)
+ {
+ if (BitIsOn(mask, i))
+ {
+ /* for each bit set there are two FP3232 values on the wire, in
+ * the order abcABC for data and data_raw. Here we swap as if
+ * they were in aAbBcC order because it's easier and really
+ * doesn't matter.
+ */
+ swapl(&values->integral, n);
+ swapl(&values->frac, n);
+ values++;
+ swapl(&values->integral, n);
+ swapl(&values->frac, n);
+ values++;
+ }
+ }
+
+ swaps(&to->valuators_len, n);
+}
+
+
/** Event swapping function for XI2 events. */
void
XI2EventSwap(xGenericEvent *from, xGenericEvent *to)
@@ -838,6 +880,13 @@ XI2EventSwap(xGenericEvent *from, xGenericEvent *to)
case XI_ButtonRelease:
SDeviceEvent((xXIDeviceEvent*)from, (xXIDeviceEvent*)to);
break;
+ case XI_RawMotion:
+ case XI_RawKeyPress:
+ case XI_RawKeyRelease:
+ case XI_RawButtonPress:
+ case XI_RawButtonRelease:
+ SRawEvent((xXIRawEvent*)from, (xXIRawEvent*)to);
+ break;
default:
ErrorF("[Xi] Unknown event type to swap. This is a bug.\n");
break;