summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2007-05-01 22:30:04 +0930
committerPeter Hutterer <peter@cs.unisa.edu.au>2007-05-01 22:30:04 +0930
commit44ccc08bb19d9d55fb9ff6bfb0592d5d79b9b712 (patch)
treeb98c8b4f9016547633250ea468ffb9b978dbfba1 /src
parent656b31865bf44b5e9bb9603bed6115d497d94796 (diff)
Add XGE support. Supporting RawDeviceEvents and PairingChangedNotifies.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/XExtInt.c947
-rw-r--r--src/XExtToWire.c878
3 files changed, 950 insertions, 876 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index d25fb2f..8cff802 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -57,6 +57,7 @@ libXi_la_SOURCES = \
XUnregPair.c \
XWarpDvPtr.c \
XExtInt.c \
+ XiSelEv.c \
XIint.h
libXi_la_LIBADD = $(XI_LIBS)
diff --git a/src/XExtInt.c b/src/XExtInt.c
index 4f1f824..9b90711 100644
--- a/src/XExtInt.c
+++ b/src/XExtInt.c
@@ -61,6 +61,9 @@ SOFTWARE.
#include <X11/Xlibint.h>
#include <X11/extensions/XInput.h>
#include <X11/extensions/extutil.h>
+#include <X11/extensions/geproto.h>
+#include <X11/extensions/ge.h>
+#include <X11/extensions/Xge.h>
#include "XIint.h"
#define ENQUEUE_EVENT True
@@ -74,6 +77,10 @@ static Bool XInputWireToEvent();
Status _XiEventToWire();
static /* const */ XEvent emptyevent;
+/* ge events handling */
+static Bool XInputWireToGEEvent(Display*, XEvent*, xEvent*);
+static Status XIGEEventToWire(Display*, XEvent*, xEvent*);
+
typedef struct _XInputData
{
XEvent data;
@@ -268,14 +275,6 @@ _XiGetDevicePresenceNotifyEvent(Display * dpy)
return info->codes->first_event + XI_DevicePresenceNotify;
}
-int
-_XiGetPointerKeyboardPairingNotifyEvent(Display * dpy)
-{
- XExtDisplayInfo *info = XInput_find_display(dpy);
-
- return info->codes->first_event + XI_PointerKeyboardPairingChangedNotify;
-}
-
/***********************************************************************
*
* Handle Input extension events.
@@ -297,9 +296,10 @@ XInputWireToEvent(dpy, re, event)
type = event->u.u.type & 0x7f;
reltype = (type - info->codes->first_event);
- if (reltype != XI_DeviceValuator &&
+ if (type == GenericEvent ||
+ (reltype != XI_DeviceValuator &&
reltype != XI_DeviceKeystateNotify &&
- reltype != XI_DeviceButtonstateNotify) {
+ reltype != XI_DeviceButtonstateNotify)) {
*save = emptyevent;
save->type = type;
((XAnyEvent *) save)->serial = _XSetLastRequestRead(dpy,
@@ -309,444 +309,505 @@ XInputWireToEvent(dpy, re, event)
((XAnyEvent *) save)->display = dpy;
}
- switch (reltype) {
- case XI_DeviceMotionNotify:
+ /* Process traditional events */
+ if (type != GenericEvent)
{
- register XDeviceMotionEvent *ev = (XDeviceMotionEvent *) save;
- deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
-
- ev->root = ev2->root;
- ev->window = ev2->event;
- ev->subwindow = ev2->child;
- ev->time = ev2->time;
- ev->x_root = ev2->root_x;
- ev->y_root = ev2->root_y;
- ev->x = ev2->event_x;
- ev->y = ev2->event_y;
- ev->state = ev2->state;
- ev->same_screen = ev2->same_screen;
- ev->is_hint = ev2->detail;
- ev->deviceid = ev2->deviceid & DEVICE_BITS;
- return (DONT_ENQUEUE);
- }
- break;
- case XI_DeviceKeyPress:
- case XI_DeviceKeyRelease:
- {
- register XDeviceKeyEvent *ev = (XDeviceKeyEvent *) save;
- deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
-
- ev->root = ev2->root;
- ev->window = ev2->event;
- ev->subwindow = ev2->child;
- ev->time = ev2->time;
- ev->x_root = ev2->root_x;
- ev->y_root = ev2->root_y;
- ev->x = ev2->event_x;
- ev->y = ev2->event_y;
- ev->state = ev2->state;
- ev->same_screen = ev2->same_screen;
- ev->keycode = ev2->detail;
- ev->deviceid = ev2->deviceid & DEVICE_BITS;
- if (ev2->deviceid & MORE_EVENTS)
- return (DONT_ENQUEUE);
- else {
- *re = *save;
- return (ENQUEUE_EVENT);
- }
- }
- break;
- case XI_DeviceButtonPress:
- case XI_DeviceButtonRelease:
- {
- register XDeviceButtonEvent *ev = (XDeviceButtonEvent *) save;
- deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
-
- ev->root = ev2->root;
- ev->window = ev2->event;
- ev->subwindow = ev2->child;
- ev->time = ev2->time;
- ev->x_root = ev2->root_x;
- ev->y_root = ev2->root_y;
- ev->x = ev2->event_x;
- ev->y = ev2->event_y;
- ev->state = ev2->state;
- ev->same_screen = ev2->same_screen;
- ev->button = ev2->detail;
- ev->deviceid = ev2->deviceid & DEVICE_BITS;
- if (ev2->deviceid & MORE_EVENTS)
- return (DONT_ENQUEUE);
- else {
- *re = *save;
- return (ENQUEUE_EVENT);
- }
- }
- break;
- case XI_ProximityIn:
- case XI_ProximityOut:
- {
- register XProximityNotifyEvent *ev = (XProximityNotifyEvent *) save;
- deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
-
- ev->root = ev2->root;
- ev->window = ev2->event;
- ev->subwindow = ev2->child;
- ev->time = ev2->time;
- ev->x_root = ev2->root_x;
- ev->y_root = ev2->root_y;
- ev->x = ev2->event_x;
- ev->y = ev2->event_y;
- ev->state = ev2->state;
- ev->same_screen = ev2->same_screen;
- ev->deviceid = ev2->deviceid & DEVICE_BITS;
- if (ev2->deviceid & MORE_EVENTS)
- return (DONT_ENQUEUE);
- else {
- *re = *save;
- return (ENQUEUE_EVENT);
- }
- }
- break;
- case XI_DeviceValuator:
- {
- deviceValuator *xev = (deviceValuator *) event;
- int save_type = save->type - info->codes->first_event;
-
- if (save_type == XI_DeviceKeyPress || save_type == XI_DeviceKeyRelease) {
- XDeviceKeyEvent *kev = (XDeviceKeyEvent *) save;
-
- kev->device_state = xev->device_state;
- kev->axes_count = xev->num_valuators;
- kev->first_axis = xev->first_valuator;
- i = xev->num_valuators;
- if (i > 6)
- i = 6;
- switch (i) {
- case 6:
- kev->axis_data[5] = xev->valuator5;
- case 5:
- kev->axis_data[4] = xev->valuator4;
- case 4:
- kev->axis_data[3] = xev->valuator3;
- case 3:
- kev->axis_data[2] = xev->valuator2;
- case 2:
- kev->axis_data[1] = xev->valuator1;
- case 1:
- kev->axis_data[0] = xev->valuator0;
- }
- } else if (save_type == XI_DeviceButtonPress ||
- save_type == XI_DeviceButtonRelease) {
- XDeviceButtonEvent *bev = (XDeviceButtonEvent *) save;
-
- bev->device_state = xev->device_state;
- bev->axes_count = xev->num_valuators;
- bev->first_axis = xev->first_valuator;
- i = xev->num_valuators;
- if (i > 6)
- i = 6;
- switch (i) {
- case 6:
- bev->axis_data[5] = xev->valuator5;
- case 5:
- bev->axis_data[4] = xev->valuator4;
- case 4:
- bev->axis_data[3] = xev->valuator3;
- case 3:
- bev->axis_data[2] = xev->valuator2;
- case 2:
- bev->axis_data[1] = xev->valuator1;
- case 1:
- bev->axis_data[0] = xev->valuator0;
- }
- } else if (save_type == XI_DeviceMotionNotify) {
- XDeviceMotionEvent *mev = (XDeviceMotionEvent *) save;
-
- mev->device_state = xev->device_state;
- mev->axes_count = xev->num_valuators;
- mev->first_axis = xev->first_valuator;
- i = xev->num_valuators;
- if (i > 6)
- i = 6;
- switch (i) {
- case 6:
- mev->axis_data[5] = xev->valuator5;
- case 5:
- mev->axis_data[4] = xev->valuator4;
- case 4:
- mev->axis_data[3] = xev->valuator3;
- case 3:
- mev->axis_data[2] = xev->valuator2;
- case 2:
- mev->axis_data[1] = xev->valuator1;
- case 1:
- mev->axis_data[0] = xev->valuator0;
- }
- } else if (save_type == XI_ProximityIn || save_type == XI_ProximityOut) {
- XProximityNotifyEvent *pev = (XProximityNotifyEvent *) save;
-
- pev->device_state = xev->device_state;
- pev->axes_count = xev->num_valuators;
- pev->first_axis = xev->first_valuator;
- i = xev->num_valuators;
- if (i > 6)
- i = 6;
- switch (i) {
- case 6:
- pev->axis_data[5] = xev->valuator5;
- case 5:
- pev->axis_data[4] = xev->valuator4;
- case 4:
- pev->axis_data[3] = xev->valuator3;
- case 3:
- pev->axis_data[2] = xev->valuator2;
- case 2:
- pev->axis_data[1] = xev->valuator1;
- case 1:
- pev->axis_data[0] = xev->valuator0;
- }
- } else if (save_type == XI_DeviceStateNotify) {
- XDeviceStateNotifyEvent *sev = (XDeviceStateNotifyEvent *) save;
- XInputClass *any = (XInputClass *) & sev->data[0];
- XValuatorStatus *v;
-
- for (i = 0; i < sev->num_classes; i++)
- if (any->class != ValuatorClass)
- any = (XInputClass *) ((char *)any + any->length);
- v = (XValuatorStatus *) any;
- i = v->num_valuators;
- j = xev->num_valuators;
- if (j > 3)
- j = 3;
- switch (j) {
- case 3:
- v->valuators[i + 2] = xev->valuator2;
- case 2:
- v->valuators[i + 1] = xev->valuator1;
- case 1:
- v->valuators[i + 0] = xev->valuator0;
- }
- v->num_valuators += j;
-
- }
- *re = *save;
- return (ENQUEUE_EVENT);
- }
- break;
- case XI_DeviceFocusIn:
- case XI_DeviceFocusOut:
- {
- register XDeviceFocusChangeEvent *ev = (XDeviceFocusChangeEvent *) re;
- deviceFocus *fev = (deviceFocus *) event;
-
- *ev = *((XDeviceFocusChangeEvent *) save);
- ev->window = fev->window;
- ev->time = fev->time;
- ev->mode = fev->mode;
- ev->detail = fev->detail;
- ev->deviceid = fev->deviceid & DEVICE_BITS;
- return (ENQUEUE_EVENT);
- }
- break;
- case XI_DeviceStateNotify:
- {
- XDeviceStateNotifyEvent *stev = (XDeviceStateNotifyEvent *) save;
- deviceStateNotify *sev = (deviceStateNotify *) event;
- char *data;
-
- stev->window = None;
- stev->deviceid = sev->deviceid & DEVICE_BITS;
- stev->time = sev->time;
- stev->num_classes = Ones((Mask) sev->classes_reported & InputClassBits);
- data = (char *)&stev->data[0];
- if (sev->classes_reported & (1 << KeyClass)) {
- register XKeyStatus *kstev = (XKeyStatus *) data;
-
- kstev->class = KeyClass;
- kstev->length = sizeof(XKeyStatus);
- kstev->num_keys = sev->num_keys;
- memcpy((char *)&kstev->keys[0], (char *)&sev->keys[0], 4);
- data += sizeof(XKeyStatus);
- }
- if (sev->classes_reported & (1 << ButtonClass)) {
- register XButtonStatus *bev = (XButtonStatus *) data;
-
- bev->class = ButtonClass;
- bev->length = sizeof(XButtonStatus);
- bev->num_buttons = sev->num_buttons;
- memcpy((char *)bev->buttons, (char *)sev->buttons, 4);
- data += sizeof(XButtonStatus);
- }
- if (sev->classes_reported & (1 << ValuatorClass)) {
- register XValuatorStatus *vev = (XValuatorStatus *) data;
-
- vev->class = ValuatorClass;
- vev->length = sizeof(XValuatorStatus);
- vev->num_valuators = sev->num_valuators;
- vev->mode = sev->classes_reported >> ModeBitsShift;
- j = sev->num_valuators;
- if (j > 3)
- j = 3;
- switch (j) {
- case 3:
- vev->valuators[2] = sev->valuator2;
- case 2:
- vev->valuators[1] = sev->valuator1;
- case 1:
- vev->valuators[0] = sev->valuator0;
- }
- data += sizeof(XValuatorStatus);
- }
- if (sev->deviceid & MORE_EVENTS)
- return (DONT_ENQUEUE);
- else {
- *re = *save;
- stev = (XDeviceStateNotifyEvent *) re;
- return (ENQUEUE_EVENT);
- }
- }
- break;
- case XI_DeviceKeystateNotify:
- {
- int i;
- XInputClass *anyclass;
- register XKeyStatus *kv;
- deviceKeyStateNotify *ksev = (deviceKeyStateNotify *) event;
- XDeviceStateNotifyEvent *kstev = (XDeviceStateNotifyEvent *) save;
-
- anyclass = (XInputClass *) & kstev->data[0];
- for (i = 0; i < kstev->num_classes; i++)
- if (anyclass->class == KeyClass)
- break;
- else
- anyclass = (XInputClass *) ((char *)anyclass +
- anyclass->length);
-
- kv = (XKeyStatus *) anyclass;
- kv->num_keys = 256;
- memcpy((char *)&kv->keys[4], (char *)ksev->keys, 28);
- if (ksev->deviceid & MORE_EVENTS)
- return (DONT_ENQUEUE);
- else {
- *re = *save;
- kstev = (XDeviceStateNotifyEvent *) re;
- return (ENQUEUE_EVENT);
- }
- }
- break;
- case XI_DeviceButtonstateNotify:
- {
- int i;
- XInputClass *anyclass;
- register XButtonStatus *bv;
- deviceButtonStateNotify *bsev = (deviceButtonStateNotify *) event;
- XDeviceStateNotifyEvent *bstev = (XDeviceStateNotifyEvent *) save;
-
- anyclass = (XInputClass *) & bstev->data[0];
- for (i = 0; i < bstev->num_classes; i++)
- if (anyclass->class == ButtonClass)
- break;
- else
- anyclass = (XInputClass *) ((char *)anyclass +
- anyclass->length);
-
- bv = (XButtonStatus *) anyclass;
- bv->num_buttons = 256;
- memcpy((char *)&bv->buttons[4], (char *)bsev->buttons, 28);
- if (bsev->deviceid & MORE_EVENTS)
- return (DONT_ENQUEUE);
- else {
- *re = *save;
- bstev = (XDeviceStateNotifyEvent *) re;
- return (ENQUEUE_EVENT);
- }
- }
- break;
- case XI_DeviceMappingNotify:
- {
- register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re;
- deviceMappingNotify *ev2 = (deviceMappingNotify *) event;
-
- *ev = *((XDeviceMappingEvent *) save);
- ev->window = 0;
- ev->first_keycode = ev2->firstKeyCode;
- ev->request = ev2->request;
- ev->count = ev2->count;
- ev->time = ev2->time;
- ev->deviceid = ev2->deviceid & DEVICE_BITS;
- return (ENQUEUE_EVENT);
- }
- break;
- case XI_ChangeDeviceNotify:
- {
- register XChangeDeviceNotifyEvent *ev = (XChangeDeviceNotifyEvent *) re;
- changeDeviceNotify *ev2 = (changeDeviceNotify *) event;
-
- *ev = *((XChangeDeviceNotifyEvent *) save);
- ev->window = 0;
- ev->request = ev2->request;
- ev->time = ev2->time;
- ev->deviceid = ev2->deviceid & DEVICE_BITS;
- return (ENQUEUE_EVENT);
- }
- break;
-
- case XI_DevicePresenceNotify:
+ switch (reltype) {
+ case XI_DeviceMotionNotify:
+ {
+ register XDeviceMotionEvent *ev = (XDeviceMotionEvent *) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->is_hint = ev2->detail;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ return (DONT_ENQUEUE);
+ }
+ break;
+ case XI_DeviceKeyPress:
+ case XI_DeviceKeyRelease:
+ {
+ register XDeviceKeyEvent *ev = (XDeviceKeyEvent *) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->keycode = ev2->detail;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ if (ev2->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else {
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceButtonPress:
+ case XI_DeviceButtonRelease:
+ {
+ register XDeviceButtonEvent *ev = (XDeviceButtonEvent *) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->button = ev2->detail;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ if (ev2->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else {
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_ProximityIn:
+ case XI_ProximityOut:
+ {
+ register XProximityNotifyEvent *ev = (XProximityNotifyEvent *) save;
+ deviceKeyButtonPointer *ev2 = (deviceKeyButtonPointer *) event;
+
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->root_x;
+ ev->y_root = ev2->root_y;
+ ev->x = ev2->event_x;
+ ev->y = ev2->event_y;
+ ev->state = ev2->state;
+ ev->same_screen = ev2->same_screen;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ if (ev2->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else {
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceValuator:
+ {
+ deviceValuator *xev = (deviceValuator *) event;
+ int save_type = save->type - info->codes->first_event;
+
+ if (save_type == XI_DeviceKeyPress || save_type == XI_DeviceKeyRelease) {
+ XDeviceKeyEvent *kev = (XDeviceKeyEvent *) save;
+
+ kev->device_state = xev->device_state;
+ kev->axes_count = xev->num_valuators;
+ kev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6)
+ i = 6;
+ switch (i) {
+ case 6:
+ kev->axis_data[5] = xev->valuator5;
+ case 5:
+ kev->axis_data[4] = xev->valuator4;
+ case 4:
+ kev->axis_data[3] = xev->valuator3;
+ case 3:
+ kev->axis_data[2] = xev->valuator2;
+ case 2:
+ kev->axis_data[1] = xev->valuator1;
+ case 1:
+ kev->axis_data[0] = xev->valuator0;
+ }
+ } else if (save_type == XI_DeviceButtonPress ||
+ save_type == XI_DeviceButtonRelease) {
+ XDeviceButtonEvent *bev = (XDeviceButtonEvent *) save;
+
+ bev->device_state = xev->device_state;
+ bev->axes_count = xev->num_valuators;
+ bev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6)
+ i = 6;
+ switch (i) {
+ case 6:
+ bev->axis_data[5] = xev->valuator5;
+ case 5:
+ bev->axis_data[4] = xev->valuator4;
+ case 4:
+ bev->axis_data[3] = xev->valuator3;
+ case 3:
+ bev->axis_data[2] = xev->valuator2;
+ case 2:
+ bev->axis_data[1] = xev->valuator1;
+ case 1:
+ bev->axis_data[0] = xev->valuator0;
+ }
+ } else if (save_type == XI_DeviceMotionNotify) {
+ XDeviceMotionEvent *mev = (XDeviceMotionEvent *) save;
+
+ mev->device_state = xev->device_state;
+ mev->axes_count = xev->num_valuators;
+ mev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6)
+ i = 6;
+ switch (i) {
+ case 6:
+ mev->axis_data[5] = xev->valuator5;
+ case 5:
+ mev->axis_data[4] = xev->valuator4;
+ case 4:
+ mev->axis_data[3] = xev->valuator3;
+ case 3:
+ mev->axis_data[2] = xev->valuator2;
+ case 2:
+ mev->axis_data[1] = xev->valuator1;
+ case 1:
+ mev->axis_data[0] = xev->valuator0;
+ }
+ } else if (save_type == XI_ProximityIn || save_type == XI_ProximityOut) {
+ XProximityNotifyEvent *pev = (XProximityNotifyEvent *) save;
+
+ pev->device_state = xev->device_state;
+ pev->axes_count = xev->num_valuators;
+ pev->first_axis = xev->first_valuator;
+ i = xev->num_valuators;
+ if (i > 6)
+ i = 6;
+ switch (i) {
+ case 6:
+ pev->axis_data[5] = xev->valuator5;
+ case 5:
+ pev->axis_data[4] = xev->valuator4;
+ case 4:
+ pev->axis_data[3] = xev->valuator3;
+ case 3:
+ pev->axis_data[2] = xev->valuator2;
+ case 2:
+ pev->axis_data[1] = xev->valuator1;
+ case 1:
+ pev->axis_data[0] = xev->valuator0;
+ }
+ } else if (save_type == XI_DeviceStateNotify) {
+ XDeviceStateNotifyEvent *sev = (XDeviceStateNotifyEvent *) save;
+ XInputClass *any = (XInputClass *) & sev->data[0];
+ XValuatorStatus *v;
+
+ for (i = 0; i < sev->num_classes; i++)
+ if (any->class != ValuatorClass)
+ any = (XInputClass *) ((char *)any + any->length);
+ v = (XValuatorStatus *) any;
+ i = v->num_valuators;
+ j = xev->num_valuators;
+ if (j > 3)
+ j = 3;
+ switch (j) {
+ case 3:
+ v->valuators[i + 2] = xev->valuator2;
+ case 2:
+ v->valuators[i + 1] = xev->valuator1;
+ case 1:
+ v->valuators[i + 0] = xev->valuator0;
+ }
+ v->num_valuators += j;
+
+ }
+ *re = *save;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ case XI_DeviceFocusIn:
+ case XI_DeviceFocusOut:
+ {
+ register XDeviceFocusChangeEvent *ev = (XDeviceFocusChangeEvent *) re;
+ deviceFocus *fev = (deviceFocus *) event;
+
+ *ev = *((XDeviceFocusChangeEvent *) save);
+ ev->window = fev->window;
+ ev->time = fev->time;
+ ev->mode = fev->mode;
+ ev->detail = fev->detail;
+ ev->deviceid = fev->deviceid & DEVICE_BITS;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ case XI_DeviceStateNotify:
+ {
+ XDeviceStateNotifyEvent *stev = (XDeviceStateNotifyEvent *) save;
+ deviceStateNotify *sev = (deviceStateNotify *) event;
+ char *data;
+
+ stev->window = None;
+ stev->deviceid = sev->deviceid & DEVICE_BITS;
+ stev->time = sev->time;
+ stev->num_classes = Ones((Mask) sev->classes_reported & InputClassBits);
+ data = (char *)&stev->data[0];
+ if (sev->classes_reported & (1 << KeyClass)) {
+ register XKeyStatus *kstev = (XKeyStatus *) data;
+
+ kstev->class = KeyClass;
+ kstev->length = sizeof(XKeyStatus);
+ kstev->num_keys = sev->num_keys;
+ memcpy((char *)&kstev->keys[0], (char *)&sev->keys[0], 4);
+ data += sizeof(XKeyStatus);
+ }
+ if (sev->classes_reported & (1 << ButtonClass)) {
+ register XButtonStatus *bev = (XButtonStatus *) data;
+
+ bev->class = ButtonClass;
+ bev->length = sizeof(XButtonStatus);
+ bev->num_buttons = sev->num_buttons;
+ memcpy((char *)bev->buttons, (char *)sev->buttons, 4);
+ data += sizeof(XButtonStatus);
+ }
+ if (sev->classes_reported & (1 << ValuatorClass)) {
+ register XValuatorStatus *vev = (XValuatorStatus *) data;
+
+ vev->class = ValuatorClass;
+ vev->length = sizeof(XValuatorStatus);
+ vev->num_valuators = sev->num_valuators;
+ vev->mode = sev->classes_reported >> ModeBitsShift;
+ j = sev->num_valuators;
+ if (j > 3)
+ j = 3;
+ switch (j) {
+ case 3:
+ vev->valuators[2] = sev->valuator2;
+ case 2:
+ vev->valuators[1] = sev->valuator1;
+ case 1:
+ vev->valuators[0] = sev->valuator0;
+ }
+ data += sizeof(XValuatorStatus);
+ }
+ if (sev->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else {
+ *re = *save;
+ stev = (XDeviceStateNotifyEvent *) re;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceKeystateNotify:
+ {
+ int i;
+ XInputClass *anyclass;
+ register XKeyStatus *kv;
+ deviceKeyStateNotify *ksev = (deviceKeyStateNotify *) event;
+ XDeviceStateNotifyEvent *kstev = (XDeviceStateNotifyEvent *) save;
+
+ anyclass = (XInputClass *) & kstev->data[0];
+ for (i = 0; i < kstev->num_classes; i++)
+ if (anyclass->class == KeyClass)
+ break;
+ else
+ anyclass = (XInputClass *) ((char *)anyclass +
+ anyclass->length);
+
+ kv = (XKeyStatus *) anyclass;
+ kv->num_keys = 256;
+ memcpy((char *)&kv->keys[4], (char *)ksev->keys, 28);
+ if (ksev->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else {
+ *re = *save;
+ kstev = (XDeviceStateNotifyEvent *) re;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceButtonstateNotify:
+ {
+ int i;
+ XInputClass *anyclass;
+ register XButtonStatus *bv;
+ deviceButtonStateNotify *bsev = (deviceButtonStateNotify *) event;
+ XDeviceStateNotifyEvent *bstev = (XDeviceStateNotifyEvent *) save;
+
+ anyclass = (XInputClass *) & bstev->data[0];
+ for (i = 0; i < bstev->num_classes; i++)
+ if (anyclass->class == ButtonClass)
+ break;
+ else
+ anyclass = (XInputClass *) ((char *)anyclass +
+ anyclass->length);
+
+ bv = (XButtonStatus *) anyclass;
+ bv->num_buttons = 256;
+ memcpy((char *)&bv->buttons[4], (char *)bsev->buttons, 28);
+ if (bsev->deviceid & MORE_EVENTS)
+ return (DONT_ENQUEUE);
+ else {
+ *re = *save;
+ bstev = (XDeviceStateNotifyEvent *) re;
+ return (ENQUEUE_EVENT);
+ }
+ }
+ break;
+ case XI_DeviceMappingNotify:
+ {
+ register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re;
+ deviceMappingNotify *ev2 = (deviceMappingNotify *) event;
+
+ *ev = *((XDeviceMappingEvent *) save);
+ ev->window = 0;
+ ev->first_keycode = ev2->firstKeyCode;
+ ev->request = ev2->request;
+ ev->count = ev2->count;
+ ev->time = ev2->time;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ case XI_ChangeDeviceNotify:
+ {
+ register XChangeDeviceNotifyEvent *ev = (XChangeDeviceNotifyEvent *) re;
+ changeDeviceNotify *ev2 = (changeDeviceNotify *) event;
+
+ *ev = *((XChangeDeviceNotifyEvent *) save);
+ ev->window = 0;
+ ev->request = ev2->request;
+ ev->time = ev2->time;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+
+ case XI_DevicePresenceNotify:
+ {
+ XDevicePresenceNotifyEvent *ev = (XDevicePresenceNotifyEvent *) re;
+ devicePresenceNotify *ev2 = (devicePresenceNotify *) event;
+
+ *ev = *(XDevicePresenceNotifyEvent *) save;
+ ev->window = 0;
+ ev->time = ev2->time;
+ ev->devchange = ev2->devchange;
+ ev->deviceid = ev2->deviceid;
+ ev->control = ev2->control;
+ return (ENQUEUE_EVENT);
+ }
+ break;
+
+ case XI_DeviceEnterNotify:
+ case XI_DeviceLeaveNotify:
+ {
+ XDeviceCrossingEvent *ev = (XDeviceCrossingEvent*)re;
+ deviceEnterNotify *ev2 = (deviceEnterNotify*) event;
+ *ev = *(XDeviceCrossingEvent*)save;
+ ev->root = ev2->root;
+ ev->window = ev2->event;
+ ev->subwindow = ev2->child;
+ ev->time = ev2->time;
+ ev->x_root = ev2->rootX;
+ ev->y_root = ev2->rootY;
+ ev->x = ev2->eventX;
+ ev->y = ev2->eventY;
+ ev->state = ev2->state;
+ ev->mode = ev2->mode;
+ ev->deviceid = ev2->deviceid & DEVICE_BITS;
+ if (ev2->flags & ELFlagSameScreen) {
+ ev->same_screen = True;
+ }
+ if (ev2->flags & ELFlagFocus) {
+ ev->focus = True;
+ }
+ return (ENQUEUE_EVENT);
+ }
+ break;
+ default:
+ printf("XInputWireToEvent: UNKNOWN WIRE EVENT! type=%d\n", type);
+ break;
+ }
+ } else /* if type == GenericEvent */
{
- XDevicePresenceNotifyEvent *ev = (XDevicePresenceNotifyEvent *) re;
- devicePresenceNotify *ev2 = (devicePresenceNotify *) event;
-
- *ev = *(XDevicePresenceNotifyEvent *) save;
- ev->window = 0;
- ev->time = ev2->time;
- ev->devchange = ev2->devchange;
- ev->deviceid = ev2->deviceid;
- ev->control = ev2->control;
- return (ENQUEUE_EVENT);
- }
- break;
-
- case XI_DeviceEnterNotify:
- case XI_DeviceLeaveNotify:
+ xGenericEvent* ge = (xGenericEvent*)event;
+ if (ge->extension == info->codes->major_opcode)
{
- XDeviceCrossingEvent *ev = (XDeviceCrossingEvent*)re;
- deviceEnterNotify *ev2 = (deviceEnterNotify*) event;
- *ev = *(XDeviceCrossingEvent*)save;
- ev->root = ev2->root;
- ev->window = ev2->event;
- ev->subwindow = ev2->child;
- ev->time = ev2->time;
- ev->x_root = ev2->rootX;
- ev->y_root = ev2->rootY;
- ev->x = ev2->eventX;
- ev->y = ev2->eventY;
- ev->state = ev2->state;
- ev->mode = ev2->mode;
- ev->deviceid = ev2->deviceid & DEVICE_BITS;
- if (ev2->flags & ELFlagSameScreen) {
- ev->same_screen = True;
- }
- if (ev2->flags & ELFlagFocus) {
- ev->focus = True;
+ switch(ge->evtype)
+ {
+ case XI_PointerKeyboardPairingChangedNotify:
+ {
+ XPointerKeyboardPairingChangedNotifyEvent* pkc_event =
+ (XPointerKeyboardPairingChangedNotifyEvent*)save;
+ pairingChangedNotify* pkc_wire =
+ (pairingChangedNotify*)event;
+
+ pkc_event->extension = pkc_wire->extension;
+ pkc_event->evtype = pkc_wire->evtype;
+ pkc_event->pointerid = pkc_wire->pointer;
+ pkc_event->keyboardid = pkc_wire->keyboard;
+ pkc_event->time = pkc_wire->time;
+ *re = *save;
+ return ENQUEUE_EVENT;
+ }
+ case XI_RandomStringEvent:
+ {
+ XRandomStringEvent* xrs_event =
+ (XRandomStringEvent*)save;
+ randomStringEvent* xrs_wire =
+ (randomStringEvent*)event;
+
+ xrs_event->extension = xrs_wire->extension;
+ xrs_event->evtype = xrs_wire->evtype;
+
+ xrs_event->string = (char*)calloc((xrs_wire->slen +
+ 1), sizeof(char));
+ memcpy(xrs_event->string,
+ &xrs_wire[1],
+ xrs_wire->slen);
+ *re = *save;
+ return ENQUEUE_EVENT;
+ }
+ case XI_RawDeviceEvent:
+ {
+ XRawDeviceEvent* raw_event =
+ (XRawDeviceEvent*)save;
+ rawDeviceEvent* raw_wire =
+ (rawDeviceEvent*)event;
+
+ raw_event->extension = raw_wire->extension;
+ raw_event->evtype = raw_wire->evtype;
+ raw_event->num_valuators = raw_wire->num_valuators;
+ raw_event->first_valuator = raw_wire->first_valuator;
+ raw_event->buttons = raw_wire->buttons;
+ if (raw_event->num_valuators)
+ {
+ raw_event->valuators =
+ (char*)calloc((raw_event->num_valuators), sizeof(int));
+ memcpy(raw_event->valuators, &raw_wire->valuator0,
+ raw_event->num_valuators * sizeof(CARD32));
+ } else
+ raw_event->valuators = NULL;
+ *re = *save;
+ return ENQUEUE_EVENT;
+ }
+ default:
+ printf("XInputWireToEvent: Unknown generic event. type %d\n", ge->evtype);
+
}
- return (ENQUEUE_EVENT);
- }
- break;
- case XI_PointerKeyboardPairingChangedNotify:
- {
- XPointerKeyboardPairingChangedNotifyEvent *ev =
- (XPointerKeyboardPairingChangedNotifyEvent*)re;
- pairingChangedNotify *ev2 = (pairingChangedNotify*) event;
- *ev = *(XPointerKeyboardPairingChangedNotifyEvent*)save;
- ev->time = ev2->time;
- ev->pointerid = ev2->pointer;
- ev->keyboardid = ev2->keyboard;
- return (ENQUEUE_EVENT);
}
- default:
- printf("XInputWireToEvent: UNKNOWN WIRE EVENT! type=%d\n", type);
- break;
- }
+ }
return (DONT_ENQUEUE);
}
diff --git a/src/XExtToWire.c b/src/XExtToWire.c
index e0e9565..163dd4a 100644
--- a/src/XExtToWire.c
+++ b/src/XExtToWire.c
@@ -59,6 +59,8 @@ SOFTWARE.
#include <X11/Xlibint.h>
#include <X11/extensions/XInput.h>
#include <X11/extensions/extutil.h>
+#include <X11/extensions/Xge.h>
+#include <X11/extensions/geproto.h>
#include "XIint.h"
Status
@@ -71,441 +73,451 @@ _XiEventToWire(dpy, re, event, count)
XExtDisplayInfo *info = XInput_find_display(dpy);
int i;
- switch ((re->type & 0x7f) - info->codes->first_event) {
- case XI_DeviceKeyPress:
- case XI_DeviceKeyRelease:
+ if ((re->type & 0x7f) != GenericEvent) {
+ switch ((re->type & 0x7f) - info->codes->first_event) {
+ case XI_DeviceKeyPress:
+ case XI_DeviceKeyRelease:
+ {
+ register XDeviceKeyEvent *ev = (XDeviceKeyEvent *) re;
+ register deviceKeyButtonPointer *kev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ kev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent));
+ if (!kev)
+ return (_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) kev;
+
+ kev->type = ev->type;
+ kev->root = ev->root;
+ kev->event = ev->window;
+ kev->child = ev->subwindow;
+ kev->time = ev->time;
+ kev->event_x = ev->x;
+ kev->event_y = ev->y;
+ kev->root_x = ev->x_root;
+ kev->root_y = ev->y_root;
+ kev->state = ev->state;
+ kev->same_screen = ev->same_screen;
+ kev->detail = ev->keycode;
+ kev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *)++ kev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+ i = vev->num_valuators;
+ if (i > 6)
+ i = 6;
+ switch (i) {
+ case 6:
+ vev->valuator5 = ev->axis_data[5];
+ case 5:
+ vev->valuator4 = ev->axis_data[4];
+ case 4:
+ vev->valuator3 = ev->axis_data[3];
+ case 3:
+ vev->valuator2 = ev->axis_data[2];
+ case 2:
+ vev->valuator1 = ev->axis_data[1];
+ case 1:
+ vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_ProximityIn:
+ case XI_ProximityOut:
+ {
+ register XProximityNotifyEvent *ev = (XProximityNotifyEvent *) re;
+ register deviceKeyButtonPointer *pev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ pev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent));
+ if (!pev)
+ return (_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) pev;
+
+ pev->type = ev->type;
+ pev->root = ev->root;
+ pev->event = ev->window;
+ pev->child = ev->subwindow;
+ pev->time = ev->time;
+ pev->event_x = ev->x;
+ pev->event_y = ev->y;
+ pev->root_x = ev->x_root;
+ pev->root_y = ev->y_root;
+ pev->state = ev->state;
+ pev->same_screen = ev->same_screen;
+ pev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *)++ pev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+
+ i = vev->num_valuators;
+ if (i > 6)
+ i = 6;
+ switch (i) {
+ case 6:
+ vev->valuator5 = ev->axis_data[5];
+ case 5:
+ vev->valuator4 = ev->axis_data[4];
+ case 4:
+ vev->valuator3 = ev->axis_data[3];
+ case 3:
+ vev->valuator2 = ev->axis_data[2];
+ case 2:
+ vev->valuator1 = ev->axis_data[1];
+ case 1:
+ vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_DeviceButtonPress:
+ case XI_DeviceButtonRelease:
+ {
+ register XDeviceButtonEvent *ev = (XDeviceButtonEvent *) re;
+ register deviceKeyButtonPointer *bev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ bev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent));
+ if (!bev)
+ return (_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) bev;
+
+ bev->type = ev->type;
+ bev->root = ev->root;
+ bev->event = ev->window;
+ bev->child = ev->subwindow;
+ bev->time = ev->time;
+ bev->event_x = ev->x;
+ bev->event_y = ev->y;
+ bev->root_x = ev->x_root;
+ bev->root_y = ev->y_root;
+ bev->state = ev->state;
+ bev->same_screen = ev->same_screen;
+ bev->detail = ev->button;
+ bev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *)++ bev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+
+ i = vev->num_valuators;
+ if (i > 6)
+ i = 6;
+ switch (i) {
+ case 6:
+ vev->valuator5 = ev->axis_data[5];
+ case 5:
+ vev->valuator4 = ev->axis_data[4];
+ case 4:
+ vev->valuator3 = ev->axis_data[3];
+ case 3:
+ vev->valuator2 = ev->axis_data[2];
+ case 2:
+ vev->valuator1 = ev->axis_data[1];
+ case 1:
+ vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_DeviceMotionNotify:
+ {
+ register XDeviceMotionEvent *ev = (XDeviceMotionEvent *) re;
+ register deviceKeyButtonPointer *mev;
+ register deviceValuator *vev;
+
+ *count = 2;
+ mev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent));
+ if (!mev)
+ return (_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) mev;
+
+ mev->type = ev->type;
+ mev->root = ev->root;
+ mev->event = ev->window;
+ mev->child = ev->subwindow;
+ mev->time = ev->time;
+ mev->event_x = ev->x;
+ mev->event_y = ev->y;
+ mev->root_x = ev->x_root;
+ mev->root_y = ev->y_root;
+ mev->state = ev->state;
+ mev->same_screen = ev->same_screen;
+ mev->detail = ev->is_hint;
+ mev->deviceid = ev->deviceid | MORE_EVENTS;
+
+ vev = (deviceValuator *)++ mev;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->device_state = ev->device_state;
+ vev->first_valuator = ev->first_axis;
+ vev->num_valuators = ev->axes_count;
+
+ i = vev->num_valuators;
+ if (i > 6)
+ i = 6;
+ switch (i) {
+ case 6:
+ vev->valuator5 = ev->axis_data[5];
+ case 5:
+ vev->valuator4 = ev->axis_data[4];
+ case 4:
+ vev->valuator3 = ev->axis_data[3];
+ case 3:
+ vev->valuator2 = ev->axis_data[2];
+ case 2:
+ vev->valuator1 = ev->axis_data[1];
+ case 1:
+ vev->valuator0 = ev->axis_data[0];
+ }
+ break;
+ }
+ case XI_DeviceFocusIn:
+ case XI_DeviceFocusOut:
+ {
+ register XDeviceFocusChangeEvent *ev = (XDeviceFocusChangeEvent *) re;
+ register deviceFocus *fev;
+
+ *count = 1;
+ fev = (deviceFocus *) Xmalloc(*count * sizeof(xEvent));
+ if (!fev)
+ return (_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) fev;
+
+ fev->type = ev->type;
+ fev->window = ev->window;
+ fev->mode = ev->mode;
+ fev->detail = ev->detail;
+ fev->time = ev->time;
+ fev->deviceid = ev->deviceid;
+ break;
+ }
+ case XI_DeviceMappingNotify:
+ {
+ register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re;
+ register deviceMappingNotify *mev;
+
+ *count = 1;
+ mev = (deviceMappingNotify *) Xmalloc(*count * sizeof(xEvent));
+ if (!mev)
+ return (_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) mev;
+
+ mev->type = ev->type;
+ mev->firstKeyCode = ev->first_keycode;
+ mev->request = ev->request;
+ mev->count = ev->count;
+ mev->time = ev->time;
+ mev->deviceid = ev->deviceid;
+ break;
+ }
+ case XI_DeviceStateNotify:
+ {
+ register XDeviceStateNotifyEvent *ev = (XDeviceStateNotifyEvent *) re;
+ register deviceStateNotify *sev;
+ register xEvent *tev;
+ XInputClass *any = (XInputClass *) & ev->data[0];
+ unsigned char *sav_id;
+
+ *count = 1;
+
+ for (i = 0; i < ev->num_classes; i++) {
+ if (any->class == KeyClass) {
+ XKeyStatus *k = (XKeyStatus *) any;
+
+ if (k->num_keys > 32)
+ (*count)++;
+ } else if (any->class == ButtonClass) {
+ XButtonStatus *b = (XButtonStatus *) any;
+
+ if (b->num_buttons > 32)
+ (*count)++;
+ } else if (any->class == ValuatorClass) {
+ XValuatorStatus *v = (XValuatorStatus *) any;
+
+ if (v->num_valuators > 3)
+ (*count)++;
+ }
+ any = (XInputClass *) ((char *)any + any->length);
+ }
+
+ sev = (deviceStateNotify *) Xmalloc(*count * sizeof(xEvent));
+ if (!sev)
+ return (_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) sev;
+ tev = (xEvent *) (sev + 1);
+
+ sev->type = ev->type;
+ sev->deviceid = ev->deviceid;
+ sav_id = &(sev->deviceid);
+ sev->time = ev->time;
+ sev->classes_reported = 0;
+
+ any = (XInputClass *) & ev->data[0];
+ for (i = 0; i < ev->num_classes; i++) {
+ if (any->class == KeyClass) {
+ XKeyStatus *k = (XKeyStatus *) any;
+ register deviceKeyStateNotify *kev;
+
+ sev->classes_reported |= (1 << KeyClass);
+ sev->num_keys = k->num_keys;
+ memcpy((char *)(sev->keys), (char *)(k->keys), 4);
+ if (k->num_keys > 32) {
+ kev = (deviceKeyStateNotify *) tev++;
+ kev->type = info->codes->first_event +
+ XI_DeviceKeystateNotify;
+ kev->deviceid = ev->deviceid;
+ *sav_id |= MORE_EVENTS;
+ sav_id = &(kev->deviceid);
+ memcpy((char *)(kev->keys), (char *)(&k->keys[4]), 28);
+ }
+ } else if (any->class == ButtonClass) {
+ XButtonStatus *b = (XButtonStatus *) any;
+ register deviceButtonStateNotify *bev;
+
+ sev->classes_reported |= (1 << ButtonClass);
+ sev->num_buttons = b->num_buttons;
+ memcpy((char *)(sev->buttons), (char *)(b->buttons), 4);
+ if (b->num_buttons > 32) {
+ bev = (deviceButtonStateNotify *) tev++;
+ bev->type = info->codes->first_event +
+ XI_DeviceButtonstateNotify;
+ bev->deviceid = ev->deviceid;
+ *sav_id |= MORE_EVENTS;
+ sav_id = &(bev->deviceid);
+ memcpy((char *)(bev->buttons), (char *)(&b->buttons[4]),
+ 28);
+ }
+ } else if (any->class == ValuatorClass) {
+ XValuatorStatus *val = (XValuatorStatus *) any;
+ register deviceValuator *vev;
+
+ sev->classes_reported |= (1 << ValuatorClass);
+ sev->num_valuators = val->num_valuators < 3 ?
+ val->num_valuators : 3;
+ switch (sev->num_valuators) {
+ case 3:
+ sev->valuator2 = val->valuators[2];
+ case 2:
+ sev->valuator1 = val->valuators[1];
+ case 1:
+ sev->valuator0 = val->valuators[0];
+ }
+ if (val->num_valuators > 3) {
+ vev = (deviceValuator *) tev++;
+ vev->type = info->codes->first_event + XI_DeviceValuator;
+ vev->deviceid = ev->deviceid;
+ vev->first_valuator = 3;
+ vev->num_valuators = val->num_valuators - 3;
+ *sav_id |= MORE_EVENTS;
+ sav_id = &(vev->deviceid);
+ i = val->num_valuators;
+ if (i > 6)
+ i = 6;
+ switch (i) {
+ case 6:
+ vev->valuator2 = val->valuators[5];
+ case 5:
+ vev->valuator1 = val->valuators[4];
+ case 4:
+ vev->valuator0 = val->valuators[3];
+ }
+ }
+ }
+ any = (XInputClass *) ((char *)any + any->length);
+ }
+ break;
+ }
+ case XI_ChangeDeviceNotify:
+ {
+ register XChangeDeviceNotifyEvent *ev = (XChangeDeviceNotifyEvent *) re;
+ register changeDeviceNotify *cev;
+
+ *count = 1;
+ cev = (changeDeviceNotify *) Xmalloc(*count * sizeof(xEvent));
+ if (!cev)
+ return (_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) cev;
+
+ cev->type = ev->type;
+ cev->request = ev->request;
+ cev->time = ev->time;
+ cev->deviceid = ev->deviceid;
+ break;
+ }
+ case XI_DeviceEnterNotify:
+ case XI_DeviceLeaveNotify:
+ {
+ register XDeviceCrossingEvent *ev = (XDeviceCrossingEvent*)re;
+ register deviceEnterNotify *elev;
+
+ *count =1;
+ elev = (deviceEnterNotify *) Xmalloc(*count * sizeof(xEvent));
+ if (!elev)
+ return (_XUnknownNativeEvent(dpy, re, *event));
+ *event = (xEvent *) elev;
+
+ elev->type = ev->type;
+ elev->deviceid = ev->deviceid;
+ elev->root = ev->root;
+ elev->event = ev->window;
+ elev->child = ev->subwindow;
+ elev->time = ev->time;
+ elev->eventX = ev->x;
+ elev->eventY = ev->y;
+ elev->rootX = ev->x_root;
+ elev->rootY = ev->y_root;
+ elev->state = ev->state;
+ elev->mode = ev->mode;
+ elev->flags = 0;
+ if (ev->same_screen) {
+ elev->flags |= ELFlagSameScreen;
+ }
+ if (ev->focus) {
+ elev->flags |= ELFlagFocus;
+ }
+ break;
+ }
+ default:
+ return (_XUnknownNativeEvent(dpy, re, *event));
+ } /* switch */
+ } else /* if type != GenericEvent */
{
- register XDeviceKeyEvent *ev = (XDeviceKeyEvent *) re;
- register deviceKeyButtonPointer *kev;
- register deviceValuator *vev;
-
- *count = 2;
- kev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent));
- if (!kev)
- return (_XUnknownNativeEvent(dpy, re, *event));
- *event = (xEvent *) kev;
-
- kev->type = ev->type;
- kev->root = ev->root;
- kev->event = ev->window;
- kev->child = ev->subwindow;
- kev->time = ev->time;
- kev->event_x = ev->x;
- kev->event_y = ev->y;
- kev->root_x = ev->x_root;
- kev->root_y = ev->y_root;
- kev->state = ev->state;
- kev->same_screen = ev->same_screen;
- kev->detail = ev->keycode;
- kev->deviceid = ev->deviceid | MORE_EVENTS;
-
- vev = (deviceValuator *)++ kev;
- vev->type = info->codes->first_event + XI_DeviceValuator;
- vev->deviceid = ev->deviceid;
- vev->device_state = ev->device_state;
- vev->first_valuator = ev->first_axis;
- vev->num_valuators = ev->axes_count;
- i = vev->num_valuators;
- if (i > 6)
- i = 6;
- switch (i) {
- case 6:
- vev->valuator5 = ev->axis_data[5];
- case 5:
- vev->valuator4 = ev->axis_data[4];
- case 4:
- vev->valuator3 = ev->axis_data[3];
- case 3:
- vev->valuator2 = ev->axis_data[2];
- case 2:
- vev->valuator1 = ev->axis_data[1];
- case 1:
- vev->valuator0 = ev->axis_data[0];
- }
- break;
- }
- case XI_ProximityIn:
- case XI_ProximityOut:
- {
- register XProximityNotifyEvent *ev = (XProximityNotifyEvent *) re;
- register deviceKeyButtonPointer *pev;
- register deviceValuator *vev;
-
- *count = 2;
- pev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent));
- if (!pev)
- return (_XUnknownNativeEvent(dpy, re, *event));
- *event = (xEvent *) pev;
-
- pev->type = ev->type;
- pev->root = ev->root;
- pev->event = ev->window;
- pev->child = ev->subwindow;
- pev->time = ev->time;
- pev->event_x = ev->x;
- pev->event_y = ev->y;
- pev->root_x = ev->x_root;
- pev->root_y = ev->y_root;
- pev->state = ev->state;
- pev->same_screen = ev->same_screen;
- pev->deviceid = ev->deviceid | MORE_EVENTS;
-
- vev = (deviceValuator *)++ pev;
- vev->type = info->codes->first_event + XI_DeviceValuator;
- vev->deviceid = ev->deviceid;
- vev->device_state = ev->device_state;
- vev->first_valuator = ev->first_axis;
- vev->num_valuators = ev->axes_count;
-
- i = vev->num_valuators;
- if (i > 6)
- i = 6;
- switch (i) {
- case 6:
- vev->valuator5 = ev->axis_data[5];
- case 5:
- vev->valuator4 = ev->axis_data[4];
- case 4:
- vev->valuator3 = ev->axis_data[3];
- case 3:
- vev->valuator2 = ev->axis_data[2];
- case 2:
- vev->valuator1 = ev->axis_data[1];
- case 1:
- vev->valuator0 = ev->axis_data[0];
- }
- break;
- }
- case XI_DeviceButtonPress:
- case XI_DeviceButtonRelease:
- {
- register XDeviceButtonEvent *ev = (XDeviceButtonEvent *) re;
- register deviceKeyButtonPointer *bev;
- register deviceValuator *vev;
-
- *count = 2;
- bev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent));
- if (!bev)
- return (_XUnknownNativeEvent(dpy, re, *event));
- *event = (xEvent *) bev;
-
- bev->type = ev->type;
- bev->root = ev->root;
- bev->event = ev->window;
- bev->child = ev->subwindow;
- bev->time = ev->time;
- bev->event_x = ev->x;
- bev->event_y = ev->y;
- bev->root_x = ev->x_root;
- bev->root_y = ev->y_root;
- bev->state = ev->state;
- bev->same_screen = ev->same_screen;
- bev->detail = ev->button;
- bev->deviceid = ev->deviceid | MORE_EVENTS;
-
- vev = (deviceValuator *)++ bev;
- vev->type = info->codes->first_event + XI_DeviceValuator;
- vev->deviceid = ev->deviceid;
- vev->device_state = ev->device_state;
- vev->first_valuator = ev->first_axis;
- vev->num_valuators = ev->axes_count;
-
- i = vev->num_valuators;
- if (i > 6)
- i = 6;
- switch (i) {
- case 6:
- vev->valuator5 = ev->axis_data[5];
- case 5:
- vev->valuator4 = ev->axis_data[4];
- case 4:
- vev->valuator3 = ev->axis_data[3];
- case 3:
- vev->valuator2 = ev->axis_data[2];
- case 2:
- vev->valuator1 = ev->axis_data[1];
- case 1:
- vev->valuator0 = ev->axis_data[0];
- }
- break;
- }
- case XI_DeviceMotionNotify:
- {
- register XDeviceMotionEvent *ev = (XDeviceMotionEvent *) re;
- register deviceKeyButtonPointer *mev;
- register deviceValuator *vev;
-
- *count = 2;
- mev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent));
- if (!mev)
- return (_XUnknownNativeEvent(dpy, re, *event));
- *event = (xEvent *) mev;
-
- mev->type = ev->type;
- mev->root = ev->root;
- mev->event = ev->window;
- mev->child = ev->subwindow;
- mev->time = ev->time;
- mev->event_x = ev->x;
- mev->event_y = ev->y;
- mev->root_x = ev->x_root;
- mev->root_y = ev->y_root;
- mev->state = ev->state;
- mev->same_screen = ev->same_screen;
- mev->detail = ev->is_hint;
- mev->deviceid = ev->deviceid | MORE_EVENTS;
-
- vev = (deviceValuator *)++ mev;
- vev->type = info->codes->first_event + XI_DeviceValuator;
- vev->deviceid = ev->deviceid;
- vev->device_state = ev->device_state;
- vev->first_valuator = ev->first_axis;
- vev->num_valuators = ev->axes_count;
-
- i = vev->num_valuators;
- if (i > 6)
- i = 6;
- switch (i) {
- case 6:
- vev->valuator5 = ev->axis_data[5];
- case 5:
- vev->valuator4 = ev->axis_data[4];
- case 4:
- vev->valuator3 = ev->axis_data[3];
- case 3:
- vev->valuator2 = ev->axis_data[2];
- case 2:
- vev->valuator1 = ev->axis_data[1];
- case 1:
- vev->valuator0 = ev->axis_data[0];
- }
- break;
- }
- case XI_DeviceFocusIn:
- case XI_DeviceFocusOut:
- {
- register XDeviceFocusChangeEvent *ev = (XDeviceFocusChangeEvent *) re;
- register deviceFocus *fev;
-
- *count = 1;
- fev = (deviceFocus *) Xmalloc(*count * sizeof(xEvent));
- if (!fev)
- return (_XUnknownNativeEvent(dpy, re, *event));
- *event = (xEvent *) fev;
-
- fev->type = ev->type;
- fev->window = ev->window;
- fev->mode = ev->mode;
- fev->detail = ev->detail;
- fev->time = ev->time;
- fev->deviceid = ev->deviceid;
- break;
- }
- case XI_DeviceMappingNotify:
- {
- register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re;
- register deviceMappingNotify *mev;
-
- *count = 1;
- mev = (deviceMappingNotify *) Xmalloc(*count * sizeof(xEvent));
- if (!mev)
- return (_XUnknownNativeEvent(dpy, re, *event));
- *event = (xEvent *) mev;
-
- mev->type = ev->type;
- mev->firstKeyCode = ev->first_keycode;
- mev->request = ev->request;
- mev->count = ev->count;
- mev->time = ev->time;
- mev->deviceid = ev->deviceid;
- break;
- }
- case XI_DeviceStateNotify:
- {
- register XDeviceStateNotifyEvent *ev = (XDeviceStateNotifyEvent *) re;
- register deviceStateNotify *sev;
- register xEvent *tev;
- XInputClass *any = (XInputClass *) & ev->data[0];
- unsigned char *sav_id;
-
- *count = 1;
-
- for (i = 0; i < ev->num_classes; i++) {
- if (any->class == KeyClass) {
- XKeyStatus *k = (XKeyStatus *) any;
-
- if (k->num_keys > 32)
- (*count)++;
- } else if (any->class == ButtonClass) {
- XButtonStatus *b = (XButtonStatus *) any;
-
- if (b->num_buttons > 32)
- (*count)++;
- } else if (any->class == ValuatorClass) {
- XValuatorStatus *v = (XValuatorStatus *) any;
-
- if (v->num_valuators > 3)
- (*count)++;
- }
- any = (XInputClass *) ((char *)any + any->length);
- }
-
- sev = (deviceStateNotify *) Xmalloc(*count * sizeof(xEvent));
- if (!sev)
- return (_XUnknownNativeEvent(dpy, re, *event));
- *event = (xEvent *) sev;
- tev = (xEvent *) (sev + 1);
-
- sev->type = ev->type;
- sev->deviceid = ev->deviceid;
- sav_id = &(sev->deviceid);
- sev->time = ev->time;
- sev->classes_reported = 0;
-
- any = (XInputClass *) & ev->data[0];
- for (i = 0; i < ev->num_classes; i++) {
- if (any->class == KeyClass) {
- XKeyStatus *k = (XKeyStatus *) any;
- register deviceKeyStateNotify *kev;
-
- sev->classes_reported |= (1 << KeyClass);
- sev->num_keys = k->num_keys;
- memcpy((char *)(sev->keys), (char *)(k->keys), 4);
- if (k->num_keys > 32) {
- kev = (deviceKeyStateNotify *) tev++;
- kev->type = info->codes->first_event +
- XI_DeviceKeystateNotify;
- kev->deviceid = ev->deviceid;
- *sav_id |= MORE_EVENTS;
- sav_id = &(kev->deviceid);
- memcpy((char *)(kev->keys), (char *)(&k->keys[4]), 28);
- }
- } else if (any->class == ButtonClass) {
- XButtonStatus *b = (XButtonStatus *) any;
- register deviceButtonStateNotify *bev;
-
- sev->classes_reported |= (1 << ButtonClass);
- sev->num_buttons = b->num_buttons;
- memcpy((char *)(sev->buttons), (char *)(b->buttons), 4);
- if (b->num_buttons > 32) {
- bev = (deviceButtonStateNotify *) tev++;
- bev->type = info->codes->first_event +
- XI_DeviceButtonstateNotify;
- bev->deviceid = ev->deviceid;
- *sav_id |= MORE_EVENTS;
- sav_id = &(bev->deviceid);
- memcpy((char *)(bev->buttons), (char *)(&b->buttons[4]),
- 28);
- }
- } else if (any->class == ValuatorClass) {
- XValuatorStatus *val = (XValuatorStatus *) any;
- register deviceValuator *vev;
-
- sev->classes_reported |= (1 << ValuatorClass);
- sev->num_valuators = val->num_valuators < 3 ?
- val->num_valuators : 3;
- switch (sev->num_valuators) {
- case 3:
- sev->valuator2 = val->valuators[2];
- case 2:
- sev->valuator1 = val->valuators[1];
- case 1:
- sev->valuator0 = val->valuators[0];
- }
- if (val->num_valuators > 3) {
- vev = (deviceValuator *) tev++;
- vev->type = info->codes->first_event + XI_DeviceValuator;
- vev->deviceid = ev->deviceid;
- vev->first_valuator = 3;
- vev->num_valuators = val->num_valuators - 3;
- *sav_id |= MORE_EVENTS;
- sav_id = &(vev->deviceid);
- i = val->num_valuators;
- if (i > 6)
- i = 6;
- switch (i) {
- case 6:
- vev->valuator2 = val->valuators[5];
- case 5:
- vev->valuator1 = val->valuators[4];
- case 4:
- vev->valuator0 = val->valuators[3];
- }
- }
- }
- any = (XInputClass *) ((char *)any + any->length);
- }
- break;
- }
- case XI_ChangeDeviceNotify:
- {
- register XChangeDeviceNotifyEvent *ev = (XChangeDeviceNotifyEvent *) re;
- register changeDeviceNotify *cev;
-
- *count = 1;
- cev = (changeDeviceNotify *) Xmalloc(*count * sizeof(xEvent));
- if (!cev)
- return (_XUnknownNativeEvent(dpy, re, *event));
- *event = (xEvent *) cev;
-
- cev->type = ev->type;
- cev->request = ev->request;
- cev->time = ev->time;
- cev->deviceid = ev->deviceid;
- break;
- }
- case XI_DeviceEnterNotify:
- case XI_DeviceLeaveNotify:
- {
- register XDeviceCrossingEvent *ev = (XDeviceCrossingEvent*)re;
- register deviceEnterNotify *elev;
-
- *count =1;
- elev = (deviceEnterNotify *) Xmalloc(*count * sizeof(xEvent));
- if (!elev)
- return (_XUnknownNativeEvent(dpy, re, *event));
- *event = (xEvent *) elev;
-
- elev->type = ev->type;
- elev->deviceid = ev->deviceid;
- elev->root = ev->root;
- elev->event = ev->window;
- elev->child = ev->subwindow;
- elev->time = ev->time;
- elev->eventX = ev->x;
- elev->eventY = ev->y;
- elev->rootX = ev->x_root;
- elev->rootY = ev->y_root;
- elev->state = ev->state;
- elev->mode = ev->mode;
- elev->flags = 0;
- if (ev->same_screen) {
- elev->flags |= ELFlagSameScreen;
+ switch (((XGenericEvent*)re)->evtype)
+ {
+ case XI_PointerKeyboardPairingChangedNotify:
+ {
+ register XPointerKeyboardPairingChangedNotifyEvent *ev =
+ (XPointerKeyboardPairingChangedNotifyEvent*)re;
+ register pairingChangedNotify *pcev;
+ *count = 1;
+ pcev = (pairingChangedNotify *)Xmalloc(*count * sizeof(xEvent));
+ if (!pcev)
+ return (_XUnknownNativeEvent(dpy, re, *event));
+
+ *event = (xEvent *) pcev;
+ pcev->type = ev->type;
+ pcev->time = ev->time;
+ pcev->pointer = ev->pointerid;
+ pcev->keyboard = ev->keyboardid;
+ break;
+ }
+ default:
+ return (_XUnknownNativeEvent(dpy, re, *event));
}
- if (ev->focus) {
- elev->flags |= ELFlagFocus;
- }
- break;
- }
- case XI_PointerKeyboardPairingChangedNotify:
- {
- register XPointerKeyboardPairingChangedNotifyEvent *ev =
- (XPointerKeyboardPairingChangedNotifyEvent*)re;
- register pairingChangedNotify *pcev;
- *count = 1;
- pcev = (pairingChangedNotify *)Xmalloc(*count * sizeof(xEvent));
- if (!pcev)
- return (_XUnknownNativeEvent(dpy, re, *event));
-
- *event = (xEvent *) pcev;
- pcev->type = ev->type;
- pcev->time = ev->time;
- pcev->pointer = ev->pointerid;
- pcev->keyboard = ev->keyboardid;
- break;
- }
- default:
- return (_XUnknownNativeEvent(dpy, re, *event));
+
}
return (1);
}