diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-03-10 15:42:51 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-03-11 14:49:07 +1000 |
commit | c6985e7651636d75ad7f7ed1b3ef434e123a8492 (patch) | |
tree | da4739482559185793281d30fdd8be48e8cfe80e | |
parent | 2712dbc2609ad75674c77df04d42899844968e10 (diff) |
Add support for Raw events.
-rw-r--r-- | include/X11/extensions/XInput2.h | 16 | ||||
-rw-r--r-- | src/XExtInt.c | 44 | ||||
-rw-r--r-- | src/XIFreeEvent.c | 5 |
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; } } |