1c43cc173Smrg/************************************************************ 2c43cc173Smrg 3c43cc173SmrgCopyright 1989, 1998 The Open Group 4c43cc173Smrg 5c43cc173SmrgPermission to use, copy, modify, distribute, and sell this software and its 6c43cc173Smrgdocumentation for any purpose is hereby granted without fee, provided that 7c43cc173Smrgthe above copyright notice appear in all copies and that both that 8c43cc173Smrgcopyright notice and this permission notice appear in supporting 9c43cc173Smrgdocumentation. 10c43cc173Smrg 11c43cc173SmrgThe above copyright notice and this permission notice shall be included in 12c43cc173Smrgall copies or substantial portions of the Software. 13c43cc173Smrg 14c43cc173SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15c43cc173SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16c43cc173SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17c43cc173SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18c43cc173SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19c43cc173SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20c43cc173Smrg 21c43cc173SmrgExcept as contained in this notice, the name of The Open Group shall not be 22c43cc173Smrgused in advertising or otherwise to promote the sale, use or other dealings 23c43cc173Smrgin this Software without prior written authorization from The Open Group. 24c43cc173Smrg 25c43cc173SmrgCopyright 1989 by Hewlett-Packard Company, Palo Alto, California. 26c43cc173Smrg 27c43cc173Smrg All Rights Reserved 28c43cc173Smrg 29c43cc173SmrgPermission to use, copy, modify, and distribute this software and its 30c43cc173Smrgdocumentation for any purpose and without fee is hereby granted, 31c43cc173Smrgprovided that the above copyright notice appear in all copies and that 32c43cc173Smrgboth that copyright notice and this permission notice appear in 33c43cc173Smrgsupporting documentation, and that the name of Hewlett-Packard not be 34c43cc173Smrgused in advertising or publicity pertaining to distribution of the 35c43cc173Smrgsoftware without specific, written prior permission. 36c43cc173Smrg 37c43cc173SmrgHEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING 38c43cc173SmrgALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL 39c43cc173SmrgHEWLETT-PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR 40c43cc173SmrgANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 41c43cc173SmrgWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, 42c43cc173SmrgARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 43c43cc173SmrgSOFTWARE. 44c43cc173Smrg 45c43cc173Smrg********************************************************/ 46c43cc173Smrg 47c43cc173Smrg/**************************************************************** 48c43cc173Smrg * 49c43cc173Smrg * XExtToWire.c - reformat an XEvent into a wire event. 50c43cc173Smrg */ 51c43cc173Smrg 52f1ee322dSmrg#ifdef HAVE_CONFIG_H 53f1ee322dSmrg#include <config.h> 54f1ee322dSmrg#endif 55f1ee322dSmrg 56c43cc173Smrg#include <X11/extensions/XIproto.h> 57c43cc173Smrg#include <X11/Xlibint.h> 58c43cc173Smrg#include <X11/extensions/XInput.h> 59c43cc173Smrg#include <X11/extensions/extutil.h> 60c27c18e8Smrg#include <X11/extensions/Xge.h> 61c27c18e8Smrg#include <X11/extensions/geproto.h> 62c43cc173Smrg#include "XIint.h" 63c43cc173Smrg 64c27c18e8Smrg_X_HIDDEN Status 65c27c18e8Smrg_XiEventToWire( 66c27c18e8Smrg register Display *dpy, /* pointer to display structure */ 67c27c18e8Smrg register XEvent *re, /* pointer to client event */ 68c27c18e8Smrg register xEvent **event, /* wire protocol event */ 69c27c18e8Smrg register int *count) 70c43cc173Smrg{ 71c43cc173Smrg XExtDisplayInfo *info = XInput_find_display(dpy); 72c43cc173Smrg int i; 73c43cc173Smrg 74c27c18e8Smrg if ((re->type & 0x7f) != GenericEvent) { 75c27c18e8Smrg switch ((re->type & 0x7f) - info->codes->first_event) { 76c27c18e8Smrg case XI_DeviceKeyPress: 77c27c18e8Smrg case XI_DeviceKeyRelease: 78c27c18e8Smrg { 79c27c18e8Smrg register XDeviceKeyEvent *ev = (XDeviceKeyEvent *) re; 80c27c18e8Smrg register deviceKeyButtonPointer *kev; 81c27c18e8Smrg register deviceValuator *vev; 82c27c18e8Smrg 83c27c18e8Smrg *count = 2; 84c27c18e8Smrg kev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent)); 85c27c18e8Smrg if (!kev) 86c27c18e8Smrg return (_XUnknownNativeEvent(dpy, re, *event)); 87c27c18e8Smrg *event = (xEvent *) kev; 88c27c18e8Smrg 89c27c18e8Smrg kev->type = ev->type; 90c27c18e8Smrg kev->root = ev->root; 91c27c18e8Smrg kev->event = ev->window; 92c27c18e8Smrg kev->child = ev->subwindow; 93c27c18e8Smrg kev->time = ev->time; 94c27c18e8Smrg kev->event_x = ev->x; 95c27c18e8Smrg kev->event_y = ev->y; 96c27c18e8Smrg kev->root_x = ev->x_root; 97c27c18e8Smrg kev->root_y = ev->y_root; 98c27c18e8Smrg kev->state = ev->state; 99c27c18e8Smrg kev->same_screen = ev->same_screen; 100c27c18e8Smrg kev->detail = ev->keycode; 101c27c18e8Smrg kev->deviceid = ev->deviceid | MORE_EVENTS; 102c27c18e8Smrg 103c27c18e8Smrg vev = (deviceValuator *)++ kev; 104c27c18e8Smrg vev->type = info->codes->first_event + XI_DeviceValuator; 105c27c18e8Smrg vev->deviceid = ev->deviceid; 106c27c18e8Smrg vev->device_state = ev->device_state; 107c27c18e8Smrg vev->first_valuator = ev->first_axis; 108c27c18e8Smrg vev->num_valuators = ev->axes_count; 109c27c18e8Smrg i = vev->num_valuators; 110c27c18e8Smrg if (i > 6) 111c27c18e8Smrg i = 6; 112c27c18e8Smrg switch (i) { 113c27c18e8Smrg case 6: 114c27c18e8Smrg vev->valuator5 = ev->axis_data[5]; 115c27c18e8Smrg case 5: 116c27c18e8Smrg vev->valuator4 = ev->axis_data[4]; 117c27c18e8Smrg case 4: 118c27c18e8Smrg vev->valuator3 = ev->axis_data[3]; 119c27c18e8Smrg case 3: 120c27c18e8Smrg vev->valuator2 = ev->axis_data[2]; 121c27c18e8Smrg case 2: 122c27c18e8Smrg vev->valuator1 = ev->axis_data[1]; 123c27c18e8Smrg case 1: 124c27c18e8Smrg vev->valuator0 = ev->axis_data[0]; 125c27c18e8Smrg } 126c27c18e8Smrg break; 127c27c18e8Smrg } 128c27c18e8Smrg case XI_ProximityIn: 129c27c18e8Smrg case XI_ProximityOut: 130c27c18e8Smrg { 131c27c18e8Smrg register XProximityNotifyEvent *ev = (XProximityNotifyEvent *) re; 132c27c18e8Smrg register deviceKeyButtonPointer *pev; 133c27c18e8Smrg register deviceValuator *vev; 134c27c18e8Smrg 135c27c18e8Smrg *count = 2; 136c27c18e8Smrg pev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent)); 137c27c18e8Smrg if (!pev) 138c27c18e8Smrg return (_XUnknownNativeEvent(dpy, re, *event)); 139c27c18e8Smrg *event = (xEvent *) pev; 140c27c18e8Smrg 141c27c18e8Smrg pev->type = ev->type; 142c27c18e8Smrg pev->root = ev->root; 143c27c18e8Smrg pev->event = ev->window; 144c27c18e8Smrg pev->child = ev->subwindow; 145c27c18e8Smrg pev->time = ev->time; 146c27c18e8Smrg pev->event_x = ev->x; 147c27c18e8Smrg pev->event_y = ev->y; 148c27c18e8Smrg pev->root_x = ev->x_root; 149c27c18e8Smrg pev->root_y = ev->y_root; 150c27c18e8Smrg pev->state = ev->state; 151c27c18e8Smrg pev->same_screen = ev->same_screen; 152c27c18e8Smrg pev->deviceid = ev->deviceid | MORE_EVENTS; 153c27c18e8Smrg 154c27c18e8Smrg vev = (deviceValuator *)++ pev; 155c27c18e8Smrg vev->type = info->codes->first_event + XI_DeviceValuator; 156c27c18e8Smrg vev->deviceid = ev->deviceid; 157c27c18e8Smrg vev->device_state = ev->device_state; 158c27c18e8Smrg vev->first_valuator = ev->first_axis; 159c27c18e8Smrg vev->num_valuators = ev->axes_count; 160c27c18e8Smrg 161c27c18e8Smrg i = vev->num_valuators; 162c27c18e8Smrg if (i > 6) 163c27c18e8Smrg i = 6; 164c27c18e8Smrg switch (i) { 165c27c18e8Smrg case 6: 166c27c18e8Smrg vev->valuator5 = ev->axis_data[5]; 167c27c18e8Smrg case 5: 168c27c18e8Smrg vev->valuator4 = ev->axis_data[4]; 169c27c18e8Smrg case 4: 170c27c18e8Smrg vev->valuator3 = ev->axis_data[3]; 171c27c18e8Smrg case 3: 172c27c18e8Smrg vev->valuator2 = ev->axis_data[2]; 173c27c18e8Smrg case 2: 174c27c18e8Smrg vev->valuator1 = ev->axis_data[1]; 175c27c18e8Smrg case 1: 176c27c18e8Smrg vev->valuator0 = ev->axis_data[0]; 177c27c18e8Smrg } 178c27c18e8Smrg break; 179c27c18e8Smrg } 180c27c18e8Smrg case XI_DeviceButtonPress: 181c27c18e8Smrg case XI_DeviceButtonRelease: 182c27c18e8Smrg { 183c27c18e8Smrg register XDeviceButtonEvent *ev = (XDeviceButtonEvent *) re; 184c27c18e8Smrg register deviceKeyButtonPointer *bev; 185c27c18e8Smrg register deviceValuator *vev; 186c27c18e8Smrg 187c27c18e8Smrg *count = 2; 188c27c18e8Smrg bev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent)); 189c27c18e8Smrg if (!bev) 190c27c18e8Smrg return (_XUnknownNativeEvent(dpy, re, *event)); 191c27c18e8Smrg *event = (xEvent *) bev; 192c27c18e8Smrg 193c27c18e8Smrg bev->type = ev->type; 194c27c18e8Smrg bev->root = ev->root; 195c27c18e8Smrg bev->event = ev->window; 196c27c18e8Smrg bev->child = ev->subwindow; 197c27c18e8Smrg bev->time = ev->time; 198c27c18e8Smrg bev->event_x = ev->x; 199c27c18e8Smrg bev->event_y = ev->y; 200c27c18e8Smrg bev->root_x = ev->x_root; 201c27c18e8Smrg bev->root_y = ev->y_root; 202c27c18e8Smrg bev->state = ev->state; 203c27c18e8Smrg bev->same_screen = ev->same_screen; 204c27c18e8Smrg bev->detail = ev->button; 205c27c18e8Smrg bev->deviceid = ev->deviceid | MORE_EVENTS; 206c27c18e8Smrg 207c27c18e8Smrg vev = (deviceValuator *)++ bev; 208c27c18e8Smrg vev->type = info->codes->first_event + XI_DeviceValuator; 209c27c18e8Smrg vev->deviceid = ev->deviceid; 210c27c18e8Smrg vev->device_state = ev->device_state; 211c27c18e8Smrg vev->first_valuator = ev->first_axis; 212c27c18e8Smrg vev->num_valuators = ev->axes_count; 213c27c18e8Smrg 214c27c18e8Smrg i = vev->num_valuators; 215c27c18e8Smrg if (i > 6) 216c27c18e8Smrg i = 6; 217c27c18e8Smrg switch (i) { 218c27c18e8Smrg case 6: 219c27c18e8Smrg vev->valuator5 = ev->axis_data[5]; 220c27c18e8Smrg case 5: 221c27c18e8Smrg vev->valuator4 = ev->axis_data[4]; 222c27c18e8Smrg case 4: 223c27c18e8Smrg vev->valuator3 = ev->axis_data[3]; 224c27c18e8Smrg case 3: 225c27c18e8Smrg vev->valuator2 = ev->axis_data[2]; 226c27c18e8Smrg case 2: 227c27c18e8Smrg vev->valuator1 = ev->axis_data[1]; 228c27c18e8Smrg case 1: 229c27c18e8Smrg vev->valuator0 = ev->axis_data[0]; 230c27c18e8Smrg } 231c27c18e8Smrg break; 232c27c18e8Smrg } 233c27c18e8Smrg case XI_DeviceMotionNotify: 234c27c18e8Smrg { 235c27c18e8Smrg register XDeviceMotionEvent *ev = (XDeviceMotionEvent *) re; 236c27c18e8Smrg register deviceKeyButtonPointer *mev; 237c27c18e8Smrg register deviceValuator *vev; 238c27c18e8Smrg 239c27c18e8Smrg *count = 2; 240c27c18e8Smrg mev = (deviceKeyButtonPointer *) Xmalloc(*count * sizeof(xEvent)); 241c27c18e8Smrg if (!mev) 242c27c18e8Smrg return (_XUnknownNativeEvent(dpy, re, *event)); 243c27c18e8Smrg *event = (xEvent *) mev; 244c27c18e8Smrg 245c27c18e8Smrg mev->type = ev->type; 246c27c18e8Smrg mev->root = ev->root; 247c27c18e8Smrg mev->event = ev->window; 248c27c18e8Smrg mev->child = ev->subwindow; 249c27c18e8Smrg mev->time = ev->time; 250c27c18e8Smrg mev->event_x = ev->x; 251c27c18e8Smrg mev->event_y = ev->y; 252c27c18e8Smrg mev->root_x = ev->x_root; 253c27c18e8Smrg mev->root_y = ev->y_root; 254c27c18e8Smrg mev->state = ev->state; 255c27c18e8Smrg mev->same_screen = ev->same_screen; 256c27c18e8Smrg mev->detail = ev->is_hint; 257c27c18e8Smrg mev->deviceid = ev->deviceid | MORE_EVENTS; 258c27c18e8Smrg 259c27c18e8Smrg vev = (deviceValuator *)++ mev; 260c27c18e8Smrg vev->type = info->codes->first_event + XI_DeviceValuator; 261c27c18e8Smrg vev->deviceid = ev->deviceid; 262c27c18e8Smrg vev->device_state = ev->device_state; 263c27c18e8Smrg vev->first_valuator = ev->first_axis; 264c27c18e8Smrg vev->num_valuators = ev->axes_count; 265c27c18e8Smrg 266c27c18e8Smrg i = vev->num_valuators; 267c27c18e8Smrg if (i > 6) 268c27c18e8Smrg i = 6; 269c27c18e8Smrg switch (i) { 270c27c18e8Smrg case 6: 271c27c18e8Smrg vev->valuator5 = ev->axis_data[5]; 272c27c18e8Smrg case 5: 273c27c18e8Smrg vev->valuator4 = ev->axis_data[4]; 274c27c18e8Smrg case 4: 275c27c18e8Smrg vev->valuator3 = ev->axis_data[3]; 276c27c18e8Smrg case 3: 277c27c18e8Smrg vev->valuator2 = ev->axis_data[2]; 278c27c18e8Smrg case 2: 279c27c18e8Smrg vev->valuator1 = ev->axis_data[1]; 280c27c18e8Smrg case 1: 281c27c18e8Smrg vev->valuator0 = ev->axis_data[0]; 282c27c18e8Smrg } 283c27c18e8Smrg break; 284c27c18e8Smrg } 285c27c18e8Smrg case XI_DeviceFocusIn: 286c27c18e8Smrg case XI_DeviceFocusOut: 287c27c18e8Smrg { 288c27c18e8Smrg register XDeviceFocusChangeEvent *ev = (XDeviceFocusChangeEvent *) re; 289c27c18e8Smrg register deviceFocus *fev; 290c27c18e8Smrg 291c27c18e8Smrg *count = 1; 292c27c18e8Smrg fev = (deviceFocus *) Xmalloc(*count * sizeof(xEvent)); 293c27c18e8Smrg if (!fev) 294c27c18e8Smrg return (_XUnknownNativeEvent(dpy, re, *event)); 295c27c18e8Smrg *event = (xEvent *) fev; 296c27c18e8Smrg 297c27c18e8Smrg fev->type = ev->type; 298c27c18e8Smrg fev->window = ev->window; 299c27c18e8Smrg fev->mode = ev->mode; 300c27c18e8Smrg fev->detail = ev->detail; 301c27c18e8Smrg fev->time = ev->time; 302c27c18e8Smrg fev->deviceid = ev->deviceid; 303c27c18e8Smrg break; 304c27c18e8Smrg } 305c27c18e8Smrg case XI_DeviceMappingNotify: 306c27c18e8Smrg { 307c27c18e8Smrg register XDeviceMappingEvent *ev = (XDeviceMappingEvent *) re; 308c27c18e8Smrg register deviceMappingNotify *mev; 309c27c18e8Smrg 310c27c18e8Smrg *count = 1; 311c27c18e8Smrg mev = (deviceMappingNotify *) Xmalloc(*count * sizeof(xEvent)); 312c27c18e8Smrg if (!mev) 313c27c18e8Smrg return (_XUnknownNativeEvent(dpy, re, *event)); 314c27c18e8Smrg *event = (xEvent *) mev; 315c27c18e8Smrg 316c27c18e8Smrg mev->type = ev->type; 317c27c18e8Smrg mev->firstKeyCode = ev->first_keycode; 318c27c18e8Smrg mev->request = ev->request; 319c27c18e8Smrg mev->count = ev->count; 320c27c18e8Smrg mev->time = ev->time; 321c27c18e8Smrg mev->deviceid = ev->deviceid; 322c27c18e8Smrg break; 323c27c18e8Smrg } 324c27c18e8Smrg case XI_DeviceStateNotify: 325c27c18e8Smrg { 326c27c18e8Smrg register XDeviceStateNotifyEvent *ev = (XDeviceStateNotifyEvent *) re; 327c27c18e8Smrg register deviceStateNotify *sev; 328c27c18e8Smrg register xEvent *tev; 329c27c18e8Smrg XInputClass *any = (XInputClass *) & ev->data[0]; 330c27c18e8Smrg unsigned char *sav_id; 331c27c18e8Smrg 332c27c18e8Smrg *count = 1; 333c27c18e8Smrg 334c27c18e8Smrg for (i = 0; i < ev->num_classes; i++) { 335c27c18e8Smrg if (any->class == KeyClass) { 336c27c18e8Smrg XKeyStatus *k = (XKeyStatus *) any; 337c27c18e8Smrg 338c27c18e8Smrg if (k->num_keys > 32) 339c27c18e8Smrg (*count)++; 340c27c18e8Smrg } else if (any->class == ButtonClass) { 341c27c18e8Smrg XButtonStatus *b = (XButtonStatus *) any; 342c27c18e8Smrg 343c27c18e8Smrg if (b->num_buttons > 32) 344c27c18e8Smrg (*count)++; 345c27c18e8Smrg } else if (any->class == ValuatorClass) { 346c27c18e8Smrg XValuatorStatus *v = (XValuatorStatus *) any; 347c27c18e8Smrg 348c27c18e8Smrg if (v->num_valuators > 3) 349c27c18e8Smrg (*count)++; 350c27c18e8Smrg } 351c27c18e8Smrg any = (XInputClass *) ((char *)any + any->length); 352c27c18e8Smrg } 353c27c18e8Smrg 354c27c18e8Smrg sev = (deviceStateNotify *) Xmalloc(*count * sizeof(xEvent)); 355c27c18e8Smrg if (!sev) 356c27c18e8Smrg return (_XUnknownNativeEvent(dpy, re, *event)); 357c27c18e8Smrg *event = (xEvent *) sev; 358c27c18e8Smrg tev = (xEvent *) (sev + 1); 359c27c18e8Smrg 360c27c18e8Smrg sev->type = ev->type; 361c27c18e8Smrg sev->deviceid = ev->deviceid; 362c27c18e8Smrg sav_id = &(sev->deviceid); 363c27c18e8Smrg sev->time = ev->time; 364c27c18e8Smrg sev->classes_reported = 0; 365c27c18e8Smrg 366c27c18e8Smrg any = (XInputClass *) & ev->data[0]; 367c27c18e8Smrg for (i = 0; i < ev->num_classes; i++) { 368c27c18e8Smrg if (any->class == KeyClass) { 369c27c18e8Smrg XKeyStatus *k = (XKeyStatus *) any; 370c27c18e8Smrg register deviceKeyStateNotify *kev; 371c27c18e8Smrg 372c27c18e8Smrg sev->classes_reported |= (1 << KeyClass); 373c27c18e8Smrg sev->num_keys = k->num_keys; 374c27c18e8Smrg memcpy((char *)(sev->keys), (char *)(k->keys), 4); 375c27c18e8Smrg if (k->num_keys > 32) { 376c27c18e8Smrg kev = (deviceKeyStateNotify *) tev++; 377c27c18e8Smrg kev->type = info->codes->first_event + 378c27c18e8Smrg XI_DeviceKeystateNotify; 379c27c18e8Smrg kev->deviceid = ev->deviceid; 380c27c18e8Smrg *sav_id |= MORE_EVENTS; 381c27c18e8Smrg sav_id = &(kev->deviceid); 382c27c18e8Smrg memcpy((char *)(kev->keys), (char *)(&k->keys[4]), 28); 383c27c18e8Smrg } 384c27c18e8Smrg } else if (any->class == ButtonClass) { 385c27c18e8Smrg XButtonStatus *b = (XButtonStatus *) any; 386c27c18e8Smrg register deviceButtonStateNotify *bev; 387c27c18e8Smrg 388c27c18e8Smrg sev->classes_reported |= (1 << ButtonClass); 389c27c18e8Smrg sev->num_buttons = b->num_buttons; 390c27c18e8Smrg memcpy((char *)(sev->buttons), (char *)(b->buttons), 4); 391c27c18e8Smrg if (b->num_buttons > 32) { 392c27c18e8Smrg bev = (deviceButtonStateNotify *) tev++; 393c27c18e8Smrg bev->type = info->codes->first_event + 394c27c18e8Smrg XI_DeviceButtonstateNotify; 395c27c18e8Smrg bev->deviceid = ev->deviceid; 396c27c18e8Smrg *sav_id |= MORE_EVENTS; 397c27c18e8Smrg sav_id = &(bev->deviceid); 398c27c18e8Smrg memcpy((char *)(bev->buttons), (char *)(&b->buttons[4]), 399c27c18e8Smrg 28); 400c27c18e8Smrg } 401c27c18e8Smrg } else if (any->class == ValuatorClass) { 402c27c18e8Smrg XValuatorStatus *val = (XValuatorStatus *) any; 403c27c18e8Smrg register deviceValuator *vev; 404c27c18e8Smrg 405c27c18e8Smrg sev->classes_reported |= (1 << ValuatorClass); 406c27c18e8Smrg sev->num_valuators = val->num_valuators < 3 ? 407c27c18e8Smrg val->num_valuators : 3; 408c27c18e8Smrg switch (sev->num_valuators) { 409c27c18e8Smrg case 3: 410c27c18e8Smrg sev->valuator2 = val->valuators[2]; 411c27c18e8Smrg case 2: 412c27c18e8Smrg sev->valuator1 = val->valuators[1]; 413c27c18e8Smrg case 1: 414c27c18e8Smrg sev->valuator0 = val->valuators[0]; 415c27c18e8Smrg } 416c27c18e8Smrg if (val->num_valuators > 3) { 417c27c18e8Smrg vev = (deviceValuator *) tev++; 418c27c18e8Smrg vev->type = info->codes->first_event + XI_DeviceValuator; 419c27c18e8Smrg vev->deviceid = ev->deviceid; 420c27c18e8Smrg vev->first_valuator = 3; 421c27c18e8Smrg vev->num_valuators = val->num_valuators - 3; 422c27c18e8Smrg *sav_id |= MORE_EVENTS; 423c27c18e8Smrg sav_id = &(vev->deviceid); 424c27c18e8Smrg i = val->num_valuators; 425c27c18e8Smrg if (i > 6) 426c27c18e8Smrg i = 6; 427c27c18e8Smrg switch (i) { 428c27c18e8Smrg case 6: 429c27c18e8Smrg vev->valuator2 = val->valuators[5]; 430c27c18e8Smrg case 5: 431c27c18e8Smrg vev->valuator1 = val->valuators[4]; 432c27c18e8Smrg case 4: 433c27c18e8Smrg vev->valuator0 = val->valuators[3]; 434c27c18e8Smrg } 435c27c18e8Smrg } 436c27c18e8Smrg } 437c27c18e8Smrg any = (XInputClass *) ((char *)any + any->length); 438c27c18e8Smrg } 439c27c18e8Smrg break; 440c27c18e8Smrg } 441c27c18e8Smrg case XI_ChangeDeviceNotify: 442c27c18e8Smrg { 443c27c18e8Smrg register XChangeDeviceNotifyEvent *ev = (XChangeDeviceNotifyEvent *) re; 444c27c18e8Smrg register changeDeviceNotify *cev; 445c27c18e8Smrg 446c27c18e8Smrg *count = 1; 447c27c18e8Smrg cev = (changeDeviceNotify *) Xmalloc(*count * sizeof(xEvent)); 448c27c18e8Smrg if (!cev) 449c27c18e8Smrg return (_XUnknownNativeEvent(dpy, re, *event)); 450c27c18e8Smrg *event = (xEvent *) cev; 451c27c18e8Smrg 452c27c18e8Smrg cev->type = ev->type; 453c27c18e8Smrg cev->request = ev->request; 454c27c18e8Smrg cev->time = ev->time; 455c27c18e8Smrg cev->deviceid = ev->deviceid; 456c27c18e8Smrg break; 457c27c18e8Smrg } 458c27c18e8Smrg default: 459c27c18e8Smrg return (_XUnknownNativeEvent(dpy, re, *event)); 460c27c18e8Smrg } /* switch */ 461c27c18e8Smrg } else /* if type != GenericEvent */ 462c43cc173Smrg { 463c27c18e8Smrg#if 0 464c27c18e8Smrg switch (((XGenericEvent*)re)->evtype) 465c27c18e8Smrg { 466c27c18e8Smrg case XI_HierarchyChangedNotify: 467c27c18e8Smrg { 468c27c18e8Smrg XDeviceHierarchyChangedEvent *ev = 469c27c18e8Smrg (XDeviceHierarchyChangedEvent*)re; 470c27c18e8Smrg XIDeviceHierarchyEvent *dhcev; 471c27c18e8Smrg *count = 1; 472c27c18e8Smrg dhcev = (XIDeviceHierarchyEvent *)Xmalloc(*count * sizeof(xEvent)); 473c27c18e8Smrg if (!dhcev) 474c27c18e8Smrg return (_XUnknownNativeEvent(dpy, re, *event)); 475c27c18e8Smrg 476c27c18e8Smrg *event = (xEvent *) dhcev; 477c27c18e8Smrg dhcev->type = ev->type; 478c27c18e8Smrg dhcev->time = ev->time; 479c27c18e8Smrg break; 480c27c18e8Smrg } 481c27c18e8Smrg default: 482c27c18e8Smrg return (_XUnknownNativeEvent(dpy, re, *event)); 483c27c18e8Smrg } 484c27c18e8Smrg#endif 485c43cc173Smrg } 486c43cc173Smrg return (1); 487c43cc173Smrg} 488