summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/X11/extensions/XInput2.h16
-rw-r--r--src/XExtInt.c44
-rw-r--r--src/XIFreeEvent.c5
3 files changed, 65 insertions, 0 deletions
diff --git a/include/X11/extensions/XInput2.h b/include/X11/extensions/XInput2.h
index e0ca45a..11f335c 100644
--- a/include/X11/extensions/XInput2.h
+++ b/include/X11/extensions/XInput2.h
@@ -219,6 +219,22 @@ typedef struct {
XIGroupState *group;
} XIDeviceEvent;
+typedef struct {
+ int type; /* GenericEvent */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ int extension; /* XI extension offset */
+ int evtype;
+ Time time;
+ int detail;
+ int deviceid;
+ int sourceid;
+ XIValuatorState *valuators;
+ double *raw_values;
+} XIRawDeviceEvent;
+
+
_XFUNCPROTOBEGIN
extern Bool XIQueryDevicePointer(
diff --git a/src/XExtInt.c b/src/XExtInt.c
index 22c054e..662acbe 100644
--- a/src/XExtInt.c
+++ b/src/XExtInt.c
@@ -130,6 +130,8 @@ static int
wireToDeviceChangedEvent(xXIDeviceChangedEvent *in, XIDeviceChangedEvent* out);
static int
wireToHierarchyChangedEvent(xXIDeviceHierarchyEvent *in, XIDeviceHierarchyEvent* out);
+static int
+wireToRawEvent(xXIRawDeviceEvent *in, XIRawDeviceEvent *out);
static /* const */ XEvent emptyevent;
@@ -818,6 +820,15 @@ XInputWireToEvent(
}
return ENQUEUE_EVENT;
+ case XI_RawEvent:
+ *re = *save;
+ if (!wireToRawEvent(event, re))
+ {
+ printf("XInputWireToEvent: CONVERSION FAILURE! evtype=%d\n",
+ ge->evtype);
+ break;
+ }
+ return ENQUEUE_EVENT;
#if 0
case XI_HierarchyChangedNotify:
{
@@ -1003,3 +1014,36 @@ wireToHierarchyChangedEvent(xXIDeviceHierarchyEvent *in, XIDeviceHierarchyEvent*
return 1;
}
+
+static int
+wireToRawEvent(xXIRawDeviceEvent *in, XIRawDeviceEvent *out)
+{
+ int len, i;
+ FP3232 *values;
+
+ out->type = in->type;
+ out->extension = in->extension;
+ out->evtype = in->evtype;
+ out->time = in->time;
+ out->detail = in->detail;
+ out->deviceid = in->deviceid;
+
+ out->valuators = malloc(sizeof(XIValuatorState) + in->valuators_len * 4);
+ out->valuators->mask_len = in->valuators_len * 4;
+ out->valuators->mask = (unsigned char*)&out->valuators[1];
+ memcpy(out->valuators->mask, &in[1], out->valuators->mask_len);
+
+ len = count_bits(out->valuators->mask, out->valuators->mask_len);
+ out->valuators->values = calloc(len, sizeof(double));
+ out->raw_values = calloc(len, sizeof(double));
+
+ values = (FP3232*)(((char*)&in[1]) + in->valuators_len * 4);
+ for (i = 0; i < len; i++)
+ {
+ out->valuators->values[i] = values->integral;
+ out->raw_values[i] = (values + len)->integral;
+ values++;
+ }
+
+ return 1;
+}
diff --git a/src/XIFreeEvent.c b/src/XIFreeEvent.c
index 004b9e4..0c80602 100644
--- a/src/XIFreeEvent.c
+++ b/src/XIFreeEvent.c
@@ -55,5 +55,10 @@ XIFreeEventData(XIEvent *event)
case XI_HierarchyChanged:
free(((XIDeviceHierarchyEvent*)event)->info);
break;
+ case XI_RawEvent:
+ free(((XIRawDeviceEvent*)event)->valuators->values);
+ free(((XIRawDeviceEvent*)event)->valuators);
+ free(((XIRawDeviceEvent*)event)->raw_values);
+ break;
}
}