wintab32: Capture the number of buttons earlier, allowing our button maps to be fille...
[wine/multimedia.git] / dlls / winex11.drv / wintab.c
blobc3ad140ad0bf242e7b74ec6c0f4a0bd3815873f3
1 /*
2 * X11 tablet driver
4 * Copyright 2003 CodeWeavers (Aric Stewart)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
22 #include "wine/port.h"
24 #include <stdlib.h>
25 #include <stdarg.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winnls.h"
30 #include "x11drv.h"
31 #include "wine/library.h"
32 #include "wine/unicode.h"
33 #include "wine/debug.h"
34 #include "wintab.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(wintab32);
38 #define WT_MAX_NAME_LEN 256
40 typedef struct tagWTI_CURSORS_INFO
42 WCHAR NAME[WT_MAX_NAME_LEN];
43 /* a displayable zero-terminated string containing the name of the
44 * cursor.
46 BOOL ACTIVE;
47 /* whether the cursor is currently connected. */
48 WTPKT PKTDATA;
49 /* a bit mask indicating the packet data items supported when this
50 * cursor is connected.
52 BYTE BUTTONS;
53 /* the number of buttons on this cursor. */
54 BYTE BUTTONBITS;
55 /* the number of bits of raw button data returned by the hardware.*/
56 DWORD cchBTNNAMES;
57 WCHAR *BTNNAMES;
58 /* a list of zero-terminated strings containing the names of the
59 * cursor's buttons. The number of names in the list is the same as the
60 * number of buttons on the cursor. The names are separated by a single
61 * zero character; the list is terminated by two zero characters.
63 BYTE BUTTONMAP[32];
64 /* a 32 byte array of logical button numbers, one for each physical
65 * button.
67 BYTE SYSBTNMAP[32];
68 /* a 32 byte array of button action codes, one for each logical
69 * button.
71 BYTE NPBUTTON;
72 /* the physical button number of the button that is controlled by normal
73 * pressure.
75 UINT NPBTNMARKS[2];
76 /* an array of two UINTs, specifying the button marks for the normal
77 * pressure button. The first UINT contains the release mark; the second
78 * contains the press mark.
80 UINT *NPRESPONSE;
81 /* an array of UINTs describing the pressure response curve for normal
82 * pressure.
84 BYTE TPBUTTON;
85 /* the physical button number of the button that is controlled by
86 * tangential pressure.
88 UINT TPBTNMARKS[2];
89 /* an array of two UINTs, specifying the button marks for the tangential
90 * pressure button. The first UINT contains the release mark; the second
91 * contains the press mark.
93 UINT *TPRESPONSE;
94 /* an array of UINTs describing the pressure response curve for
95 * tangential pressure.
97 DWORD PHYSID;
98 /* a manufacturer-specific physical identifier for the cursor. This
99 * value will distinguish the physical cursor from others on the same
100 * device. This physical identifier allows applications to bind
101 * functions to specific physical cursors, even if category numbers
102 * change and multiple, otherwise identical, physical cursors are
103 * present.
105 UINT MODE;
106 /* the cursor mode number of this cursor type, if this cursor type has
107 * the CRC_MULTIMODE capability.
109 UINT MINPKTDATA;
110 /* the minimum set of data available from a physical cursor in this
111 * cursor type, if this cursor type has the CRC_AGGREGATE capability.
113 UINT MINBUTTONS;
114 /* the minimum number of buttons of physical cursors in the cursor type,
115 * if this cursor type has the CRC_AGGREGATE capability.
117 UINT CAPABILITIES;
118 /* flags indicating cursor capabilities, as defined below:
119 CRC_MULTIMODE
120 Indicates this cursor type describes one of several modes of a
121 single physical cursor. Consecutive cursor type categories
122 describe the modes; the CSR_MODE data item gives the mode number
123 of each cursor type.
124 CRC_AGGREGATE
125 Indicates this cursor type describes several physical cursors
126 that cannot be distinguished by software.
127 CRC_INVERT
128 Indicates this cursor type describes the physical cursor in its
129 inverted orientation; the previous consecutive cursor type
130 category describes the normal orientation.
132 UINT TYPE;
133 /* Manufacturer Unique id for the item type */
134 } WTI_CURSORS_INFO, *LPWTI_CURSORS_INFO;
137 typedef struct tagWTI_DEVICES_INFO
139 WCHAR NAME[WT_MAX_NAME_LEN];
140 /* a displayable null- terminated string describing the device,
141 * manufacturer, and revision level.
143 UINT HARDWARE;
144 /* flags indicating hardware and driver capabilities, as defined
145 * below:
146 HWC_INTEGRATED:
147 Indicates that the display and digitizer share the same surface.
148 HWC_TOUCH
149 Indicates that the cursor must be in physical contact with the
150 device to report position.
151 HWC_HARDPROX
152 Indicates that device can generate events when the cursor is
153 entering and leaving the physical detection range.
154 HWC_PHYSID_CURSORS
155 Indicates that device can uniquely identify the active cursor in
156 hardware.
158 UINT NCSRTYPES;
159 /* the number of supported cursor types.*/
160 UINT FIRSTCSR;
161 /* the first cursor type number for the device. */
162 UINT PKTRATE;
163 /* the maximum packet report rate in Hertz. */
164 WTPKT PKTDATA;
165 /* a bit mask indicating which packet data items are always available.*/
166 WTPKT PKTMODE;
167 /* a bit mask indicating which packet data items are physically
168 * relative, i.e., items for which the hardware can only report change,
169 * not absolute measurement.
171 WTPKT CSRDATA;
172 /* a bit mask indicating which packet data items are only available when
173 * certain cursors are connected. The individual cursor descriptions
174 * must be consulted to determine which cursors return which data.
176 INT XMARGIN;
177 INT YMARGIN;
178 INT ZMARGIN;
179 /* the size of tablet context margins in tablet native coordinates, in
180 * the x, y, and z directions, respectively.
182 AXIS X;
183 AXIS Y;
184 AXIS Z;
185 /* the tablet's range and resolution capabilities, in the x, y, and z
186 * axes, respectively.
188 AXIS NPRESSURE;
189 AXIS TPRESSURE;
190 /* the tablet's range and resolution capabilities, for the normal and
191 * tangential pressure inputs, respectively.
193 AXIS ORIENTATION[3];
194 /* a 3-element array describing the tablet's orientation range and
195 * resolution capabilities.
197 AXIS ROTATION[3];
198 /* a 3-element array describing the tablet's rotation range and
199 * resolution capabilities.
201 WCHAR PNPID[WT_MAX_NAME_LEN];
202 /* a null-terminated string containing the devices Plug and Play ID.*/
203 } WTI_DEVICES_INFO, *LPWTI_DEVICES_INFO;
206 /***********************************************************************
207 * WACOM WINTAB EXTENSIONS TO SUPPORT CSR_TYPE
208 * In Wintab 1.2, a CSR_TYPE feature was added. This adds the
209 * ability to return a type of cursor on a tablet.
210 * Unfortunately, we cannot get the cursor type directly from X,
211 * and it is not specified directly anywhere. So we virtualize
212 * the type here. (This is unfortunate, the kernel module has
213 * the exact type, but we have no way of getting that module to
214 * pass us that type).
217 #define CSR_TYPE_PEN 0x822
218 #define CSR_TYPE_ERASER 0x82a
219 #define CSR_TYPE_MOUSE_2D 0x007
220 #define CSR_TYPE_MOUSE_4D 0x094
223 typedef struct tagWTPACKET {
224 HCTX pkContext;
225 UINT pkStatus;
226 LONG pkTime;
227 WTPKT pkChanged;
228 UINT pkSerialNumber;
229 UINT pkCursor;
230 DWORD pkButtons;
231 DWORD pkX;
232 DWORD pkY;
233 DWORD pkZ;
234 UINT pkNormalPressure;
235 UINT pkTangentPressure;
236 ORIENTATION pkOrientation;
237 ROTATION pkRotation; /* 1.1 */
238 } WTPACKET, *LPWTPACKET;
241 #ifdef SONAME_LIBXI
243 #include <X11/Xlib.h>
244 #include <X11/extensions/XInput.h>
246 static int motion_type;
247 static int button_press_type;
248 static int button_release_type;
249 static int key_press_type;
250 static int key_release_type;
251 static int proximity_in_type;
252 static int proximity_out_type;
254 static HWND hwndTabletDefault;
255 static WTPACKET gMsgPacket;
256 static DWORD gSerial;
257 static INT button_state[10];
259 #define CURSORMAX 10
261 static LOGCONTEXTW gSysContext;
262 static WTI_DEVICES_INFO gSysDevice;
263 static WTI_CURSORS_INFO gSysCursor[CURSORMAX];
264 static INT gNumCursors;
267 /* XInput stuff */
268 static void *xinput_handle;
270 #define MAKE_FUNCPTR(f) static typeof(f) * p##f;
271 MAKE_FUNCPTR(XListInputDevices)
272 MAKE_FUNCPTR(XFreeDeviceList)
273 MAKE_FUNCPTR(XOpenDevice)
274 MAKE_FUNCPTR(XQueryDeviceState)
275 MAKE_FUNCPTR(XGetDeviceButtonMapping)
276 MAKE_FUNCPTR(XCloseDevice)
277 MAKE_FUNCPTR(XSelectExtensionEvent)
278 MAKE_FUNCPTR(XFreeDeviceState)
279 #undef MAKE_FUNCPTR
281 static INT X11DRV_XInput_Init(void)
283 xinput_handle = wine_dlopen(SONAME_LIBXI, RTLD_NOW, NULL, 0);
284 if (xinput_handle)
286 #define LOAD_FUNCPTR(f) if((p##f = wine_dlsym(xinput_handle, #f, NULL, 0)) == NULL) goto sym_not_found;
287 LOAD_FUNCPTR(XListInputDevices)
288 LOAD_FUNCPTR(XFreeDeviceList)
289 LOAD_FUNCPTR(XOpenDevice)
290 LOAD_FUNCPTR(XGetDeviceButtonMapping)
291 LOAD_FUNCPTR(XCloseDevice)
292 LOAD_FUNCPTR(XSelectExtensionEvent)
293 LOAD_FUNCPTR(XQueryDeviceState)
294 LOAD_FUNCPTR(XFreeDeviceState)
295 #undef LOAD_FUNCPTR
296 return 1;
298 sym_not_found:
299 return 0;
302 static int Tablet_ErrorHandler(Display *dpy, XErrorEvent *event, void* arg)
304 return 1;
307 static int find_cursor_by_type(int cursor_type, int exclude)
309 int i;
310 for (i = 0; i < gNumCursors; i++)
311 if (i != exclude)
312 if (gSysCursor[i].TYPE == cursor_type)
313 return i;
315 return -1;
318 static void swap_cursors(int a, int b)
320 WTI_CURSORS_INFO temp;
321 temp = gSysCursor[a];
322 gSysCursor[a] = gSysCursor[b];
323 gSysCursor[b] = temp;
326 /* Adobe Photoshop 7.0 relies on the eraser being cursor #2 or #5, and it assumes the stylus is 1.
327 ** If the X configuration is not set up that way, make it
329 static void Tablet_FixupCursors(void)
331 if (gNumCursors >= 1)
332 if (gSysCursor[1].TYPE != CSR_TYPE_PEN)
334 int stylus;
335 stylus = find_cursor_by_type(CSR_TYPE_PEN, 1);
336 if (stylus >= 0)
338 swap_cursors(1, stylus);
339 TRACE("Swapped cursor %d with stylus slot (1) for compatibility with older programs\n", stylus);
343 if (gNumCursors >= 2)
344 if (gSysCursor[2].TYPE != CSR_TYPE_ERASER)
346 int eraser;
347 eraser = find_cursor_by_type(CSR_TYPE_ERASER, 2);
348 if (eraser >= 0)
350 swap_cursors(2, eraser);
351 TRACE("Swapped cursor %d with eraser slot (2) for compatibility with older programs\n", eraser);
356 static void trace_axes(XValuatorInfoPtr val)
358 int i;
359 XAxisInfoPtr axis;
361 for (i = 0, axis = val->axes ; i < val->num_axes; i++, axis++)
362 TRACE(" Axis %d: [resolution %d|min_value %d|max_value %d]\n", i, axis->resolution, axis->min_value, axis->max_value);
365 void X11DRV_LoadTabletInfo(HWND hwnddefault)
367 const WCHAR SZ_CONTEXT_NAME[] = {'W','i','n','e',' ','T','a','b','l','e','t',' ','C','o','n','t','e','x','t',0};
368 const WCHAR SZ_DEVICE_NAME[] = {'W','i','n','e',' ','T','a','b','l','e','t',' ','D','e','v','i','c','e',0};
369 const WCHAR SZ_NON_PLUGINPLAY[] = {'n','o','n','-','p','l','u','g','i','n','p','l','a','y',0};
371 struct x11drv_thread_data *data = x11drv_thread_data();
372 int num_devices;
373 int loop;
374 int cursor_target;
375 XDeviceInfo *devices;
376 XDeviceInfo *target = NULL;
377 BOOL axis_read_complete= FALSE;
379 XAnyClassPtr any;
380 XButtonInfoPtr Button;
381 XValuatorInfoPtr Val;
382 XAxisInfoPtr Axis;
384 XDevice *opendevice;
386 if (!X11DRV_XInput_Init())
388 ERR("Unable to initialized the XInput library.\n");
389 return;
392 hwndTabletDefault = hwnddefault;
394 /* Do base initializaion */
395 strcpyW(gSysContext.lcName, SZ_CONTEXT_NAME);
396 strcpyW(gSysDevice.NAME, SZ_DEVICE_NAME);
398 gSysContext.lcOptions = CXO_SYSTEM;
399 gSysContext.lcLocks = CXL_INSIZE | CXL_INASPECT | CXL_MARGIN |
400 CXL_SENSITIVITY | CXL_SYSOUT;
402 gSysContext.lcMsgBase= WT_DEFBASE;
403 gSysContext.lcDevice = 0;
404 gSysContext.lcPktData =
405 PK_CONTEXT | PK_STATUS | PK_SERIAL_NUMBER| PK_TIME | PK_CURSOR |
406 PK_BUTTONS | PK_X | PK_Y | PK_NORMAL_PRESSURE | PK_ORIENTATION;
407 gSysContext.lcMoveMask=
408 PK_BUTTONS | PK_X | PK_Y | PK_NORMAL_PRESSURE | PK_ORIENTATION;
409 gSysContext.lcStatus = CXS_ONTOP;
410 gSysContext.lcPktRate = 100;
411 gSysContext.lcBtnDnMask = 0xffffffff;
412 gSysContext.lcBtnUpMask = 0xffffffff;
413 gSysContext.lcSensX = 65536;
414 gSysContext.lcSensY = 65536;
415 gSysContext.lcSensX = 65536;
416 gSysContext.lcSensZ = 65536;
417 gSysContext.lcSysSensX= 65536;
418 gSysContext.lcSysSensY= 65536;
420 /* Device Defaults */
421 gSysDevice.HARDWARE = HWC_HARDPROX|HWC_PHYSID_CURSORS;
422 gSysDevice.FIRSTCSR= 0;
423 gSysDevice.PKTRATE = 100;
424 gSysDevice.PKTDATA =
425 PK_CONTEXT | PK_STATUS | PK_SERIAL_NUMBER| PK_TIME | PK_CURSOR |
426 PK_BUTTONS | PK_X | PK_Y | PK_NORMAL_PRESSURE | PK_ORIENTATION;
427 strcpyW(gSysDevice.PNPID, SZ_NON_PLUGINPLAY);
429 wine_tsx11_lock();
431 cursor_target = -1;
432 devices = pXListInputDevices(data->display, &num_devices);
433 if (!devices)
435 WARN("XInput Extenstions reported as not avalable\n");
436 wine_tsx11_unlock();
437 return;
439 for (loop=0; loop < num_devices; loop++)
441 int class_loop;
443 TRACE("Device %i: [id %d|name %s|type %s|num_classes %d|use %s]\n",
444 loop, (int) devices[loop].id, devices[loop].name,
445 XGetAtomName(data->display, devices[loop].type),
446 devices[loop].num_classes,
447 devices[loop].use == IsXKeyboard ? "IsXKeyboard" :
448 devices[loop].use == IsXPointer ? "IsXPointer" :
449 devices[loop].use == IsXExtensionDevice ? "IsXExtensionDevice" :
450 "Unknown"
452 if (devices[loop].use == IsXExtensionDevice)
454 LPWTI_CURSORS_INFO cursor;
456 TRACE("Is Extension Device\n");
457 cursor_target++;
458 target = &devices[loop];
459 cursor = &gSysCursor[cursor_target];
461 if (strlen(target->name) >= WT_MAX_NAME_LEN)
463 ERR("Input device '%s' name too long - skipping\n", wine_dbgstr_a(target->name));
464 cursor_target--;
465 continue;
468 X11DRV_expect_error(data->display, Tablet_ErrorHandler, NULL);
469 opendevice = pXOpenDevice(data->display,target->id);
470 if (!X11DRV_check_error() && opendevice)
472 unsigned char map[32];
473 int i;
474 int shft = 0;
476 X11DRV_expect_error(data->display,Tablet_ErrorHandler,NULL);
477 cursor->BUTTONS = pXGetDeviceButtonMapping(data->display, opendevice, map, 32);
478 if (X11DRV_check_error() || cursor->BUTTONS <= 0)
480 TRACE("No buttons, Non Tablet Device\n");
481 pXCloseDevice(data->display, opendevice);
482 cursor_target --;
483 continue;
486 for (i=0; i< cursor->BUTTONS; i++,shft++)
488 cursor->BUTTONMAP[i] = map[i];
489 cursor->SYSBTNMAP[i] = (1<<shft);
491 pXCloseDevice(data->display, opendevice);
493 else
495 WARN("Unable to open device %s\n",target->name);
496 cursor_target --;
497 continue;
499 MultiByteToWideChar(CP_UNIXCP, 0, target->name, -1, cursor->NAME, WT_MAX_NAME_LEN);
501 cursor->ACTIVE = 1;
502 cursor->PKTDATA = PK_TIME | PK_CURSOR | PK_BUTTONS | PK_X | PK_Y |
503 PK_NORMAL_PRESSURE | PK_TANGENT_PRESSURE |
504 PK_ORIENTATION;
506 cursor->PHYSID = target->id;
507 cursor->NPBUTTON = 1;
508 cursor->NPBTNMARKS[0] = 0 ;
509 cursor->NPBTNMARKS[1] = 1 ;
510 cursor->CAPABILITIES = CRC_MULTIMODE;
511 if (strcasecmp(target->name,"stylus")==0)
512 cursor->TYPE = CSR_TYPE_PEN;
513 if (strcasecmp(target->name,"eraser")==0)
514 cursor->TYPE = CSR_TYPE_ERASER;
517 any = (XAnyClassPtr) (target->inputclassinfo);
519 for (class_loop = 0; class_loop < target->num_classes; class_loop++)
521 switch (any->class)
524 case ValuatorClass:
525 Val = (XValuatorInfoPtr) any;
526 TRACE(" ValidatorInput %d: [class %d|length %d|num_axes %d|mode %d|motion_buffer %ld]\n",
527 class_loop, (int) Val->class, Val->length, Val->num_axes, Val->mode, Val->motion_buffer);
528 if (TRACE_ON(wintab32))
529 trace_axes(Val);
531 /* FIXME: This is imperfect; we compute our devices capabilities based upon the
532 ** first pen type device we find. However, a more correct implementation
533 ** would require acquiring a wide variety of tablets and running through
534 ** the various inputs to see what the values are. Odds are that a
535 ** more 'correct' algorithm would condense to this one anyway.
537 if (!axis_read_complete && Val->num_axes >= 5 && cursor->TYPE == CSR_TYPE_PEN)
539 Axis = (XAxisInfoPtr) ((char *) Val + sizeof
540 (XValuatorInfo));
542 if (Val->num_axes>=1)
544 /* Axis 1 is X */
545 gSysDevice.X.axMin = Axis->min_value;
546 gSysDevice.X.axMax= Axis->max_value;
547 gSysDevice.X.axUnits = TU_INCHES;
548 gSysDevice.X.axResolution = Axis->resolution;
549 gSysContext.lcInOrgX = Axis->min_value;
550 gSysContext.lcSysOrgX = Axis->min_value;
551 gSysContext.lcInExtX = Axis->max_value;
552 gSysContext.lcSysExtX = Axis->max_value;
553 Axis++;
555 if (Val->num_axes>=2)
557 /* Axis 2 is Y */
558 gSysDevice.Y.axMin = Axis->min_value;
559 gSysDevice.Y.axMax= Axis->max_value;
560 gSysDevice.Y.axUnits = TU_INCHES;
561 gSysDevice.Y.axResolution = Axis->resolution;
562 gSysContext.lcInOrgY = Axis->min_value;
563 gSysContext.lcSysOrgY = Axis->min_value;
564 gSysContext.lcInExtY = Axis->max_value;
565 gSysContext.lcSysExtY = Axis->max_value;
566 Axis++;
568 if (Val->num_axes>=3)
570 /* Axis 3 is Normal Pressure */
571 gSysDevice.NPRESSURE.axMin = Axis->min_value;
572 gSysDevice.NPRESSURE.axMax= Axis->max_value;
573 gSysDevice.NPRESSURE.axUnits = TU_INCHES;
574 gSysDevice.NPRESSURE.axResolution =
575 Axis->resolution;
576 Axis++;
578 if (Val->num_axes >= 5)
580 /* Axis 4 and 5 are X and Y tilt */
581 XAxisInfoPtr XAxis = Axis;
582 Axis++;
583 if (max (abs(Axis->max_value),
584 abs(XAxis->max_value)))
586 gSysDevice.ORIENTATION[0].axMin = 0;
587 gSysDevice.ORIENTATION[0].axMax = 3600;
588 gSysDevice.ORIENTATION[0].axUnits = TU_CIRCLE;
589 gSysDevice.ORIENTATION[0].axResolution
590 = CASTFIX32(3600);
591 gSysDevice.ORIENTATION[1].axMin = -1000;
592 gSysDevice.ORIENTATION[1].axMax = 1000;
593 gSysDevice.ORIENTATION[1].axUnits = TU_CIRCLE;
594 gSysDevice.ORIENTATION[1].axResolution
595 = CASTFIX32(3600);
596 Axis++;
599 axis_read_complete = TRUE;
601 break;
602 case ButtonClass:
604 int cchBuf = 512;
605 int cchPos = 0;
606 int i;
608 Button = (XButtonInfoPtr) any;
609 TRACE(" ButtonInput %d: [class %d|length %d|num_buttons %d]\n",
610 class_loop, (int) Button->class, Button->length, Button->num_buttons);
611 cursor->BTNNAMES = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*cchBuf);
612 for (i = 0; i < cursor->BUTTONS; i++)
614 /* FIXME - these names are probably incorrect */
615 int cch = strlenW(cursor->NAME) + 1;
616 while (cch > cchBuf - cchPos - 1) /* we want one extra byte for the last NUL */
618 cchBuf *= 2;
619 cursor->BTNNAMES = HeapReAlloc(GetProcessHeap(), 0, cursor->BTNNAMES, sizeof(WCHAR)*cchBuf);
622 strcpyW(cursor->BTNNAMES + cchPos, cursor->NAME);
623 cchPos += cch;
625 cursor->BTNNAMES[cchPos++] = 0;
626 cursor->BTNNAMES = HeapReAlloc(GetProcessHeap(), 0, cursor->BTNNAMES, sizeof(WCHAR)*cchPos);
627 cursor->cchBTNNAMES = cchPos;
629 break;
631 any = (XAnyClassPtr) ((char*) any + any->length);
635 pXFreeDeviceList(devices);
636 gSysDevice.NCSRTYPES = cursor_target+1;
637 gNumCursors = cursor_target+1;
638 Tablet_FixupCursors();
639 wine_tsx11_unlock();
642 static int figure_deg(int x, int y)
644 int rc;
646 if (y != 0)
648 rc = (int) 10 * (atan( (FLOAT)abs(y) / (FLOAT)abs(x)) / (3.1415 / 180));
649 if (y>0)
651 if (x>0)
652 rc += 900;
653 else
654 rc = 2700 - rc;
656 else
658 if (x>0)
659 rc = 900 - rc;
660 else
661 rc += 2700;
664 else
666 if (x >= 0)
667 rc = 900;
668 else
669 rc = 2700;
672 return rc;
675 static int get_button_state(int curnum)
677 return button_state[curnum];
680 static void set_button_state(int curnum, XID deviceid)
682 struct x11drv_thread_data *data = x11drv_thread_data();
683 XDevice *device;
684 XDeviceState *state;
685 XInputClass *class;
686 int loop;
687 int rc = 0;
689 wine_tsx11_lock();
690 device = pXOpenDevice(data->display,deviceid);
691 state = pXQueryDeviceState(data->display,device);
693 if (state)
695 class = state->data;
696 for (loop = 0; loop < state->num_classes; loop++)
698 if (class->class == ButtonClass)
700 int loop2;
701 XButtonState *button_state = (XButtonState*)class;
702 for (loop2 = 0; loop2 < button_state->num_buttons; loop2++)
704 if (button_state->buttons[loop2 / 8] & (1 << (loop2 % 8)))
706 rc |= (1<<loop2);
710 class = (XInputClass *) ((char *) class + class->length);
713 pXFreeDeviceState(state);
714 wine_tsx11_unlock();
715 button_state[curnum] = rc;
718 static int cursor_from_device(DWORD deviceid, LPWTI_CURSORS_INFO *cursorp)
720 int i;
721 for (i = 0; i < gNumCursors; i++)
722 if (gSysCursor[i].PHYSID == deviceid)
724 *cursorp = &gSysCursor[i];
725 return i;
728 ERR("Could not map device id %d to a cursor\n", (int) deviceid);
729 return -1;
732 static void motion_event( HWND hwnd, XEvent *event )
734 XDeviceMotionEvent *motion = (XDeviceMotionEvent *)event;
735 LPWTI_CURSORS_INFO cursor;
736 int curnum = cursor_from_device(motion->deviceid, &cursor);
737 if (curnum < 0)
738 return;
740 memset(&gMsgPacket,0,sizeof(WTPACKET));
742 TRACE("Received tablet motion event (%p); device id %d, cursor num %d\n",hwnd, (int) motion->deviceid, curnum);
744 /* Set cursor to inverted if cursor is the eraser */
745 gMsgPacket.pkStatus = (cursor->TYPE == CSR_TYPE_ERASER ? TPS_INVERT:0);
746 gMsgPacket.pkTime = EVENT_x11_time_to_win32_time(motion->time);
747 gMsgPacket.pkSerialNumber = gSerial++;
748 gMsgPacket.pkCursor = curnum;
749 gMsgPacket.pkX = motion->axis_data[0];
750 gMsgPacket.pkY = motion->axis_data[1];
751 gMsgPacket.pkOrientation.orAzimuth = figure_deg(motion->axis_data[3],motion->axis_data[4]);
752 gMsgPacket.pkOrientation.orAltitude = ((1000 - 15 * max
753 (abs(motion->axis_data[3]),
754 abs(motion->axis_data[4])))
755 * (gMsgPacket.pkStatus & TPS_INVERT?-1:1));
756 gMsgPacket.pkNormalPressure = motion->axis_data[2];
757 gMsgPacket.pkButtons = get_button_state(curnum);
758 SendMessageW(hwndTabletDefault,WT_PACKET,0,(LPARAM)hwnd);
761 static void button_event( HWND hwnd, XEvent *event )
763 XDeviceButtonEvent *button = (XDeviceButtonEvent *) event;
764 LPWTI_CURSORS_INFO cursor;
765 int curnum = cursor_from_device(button->deviceid, &cursor);
766 if (curnum < 0)
767 return;
769 memset(&gMsgPacket,0,sizeof(WTPACKET));
771 TRACE("Received tablet button %s event\n", (event->type == button_press_type)?"press":"release");
773 /* Set cursor to inverted if cursor is the eraser */
774 gMsgPacket.pkStatus = (cursor->TYPE == CSR_TYPE_ERASER ? TPS_INVERT:0);
775 set_button_state(curnum, button->deviceid);
776 gMsgPacket.pkTime = EVENT_x11_time_to_win32_time(button->time);
777 gMsgPacket.pkSerialNumber = gSerial++;
778 gMsgPacket.pkCursor = curnum;
779 gMsgPacket.pkX = button->axis_data[0];
780 gMsgPacket.pkY = button->axis_data[1];
781 gMsgPacket.pkOrientation.orAzimuth = figure_deg(button->axis_data[3],button->axis_data[4]);
782 gMsgPacket.pkOrientation.orAltitude = ((1000 - 15 * max(abs(button->axis_data[3]),
783 abs(button->axis_data[4])))
784 * (gMsgPacket.pkStatus & TPS_INVERT?-1:1));
785 gMsgPacket.pkNormalPressure = button->axis_data[2];
786 gMsgPacket.pkButtons = get_button_state(curnum);
787 SendMessageW(hwndTabletDefault,WT_PACKET,0,(LPARAM)hwnd);
790 static void key_event( HWND hwnd, XEvent *event )
792 if (event->type == key_press_type)
793 FIXME("Received tablet key press event\n");
794 else
795 FIXME("Received tablet key release event\n");
798 static void proximity_event( HWND hwnd, XEvent *event )
800 XProximityNotifyEvent *proximity = (XProximityNotifyEvent *) event;
801 LPWTI_CURSORS_INFO cursor;
802 int curnum = cursor_from_device(proximity->deviceid, &cursor);
803 if (curnum < 0)
804 return;
806 memset(&gMsgPacket,0,sizeof(WTPACKET));
808 TRACE("Received tablet proximity event\n");
809 /* Set cursor to inverted if cursor is the eraser */
810 gMsgPacket.pkStatus = (cursor->TYPE == CSR_TYPE_ERASER ? TPS_INVERT:0);
811 gMsgPacket.pkStatus |= (event->type==proximity_out_type)?TPS_PROXIMITY:0;
812 gMsgPacket.pkTime = EVENT_x11_time_to_win32_time(proximity->time);
813 gMsgPacket.pkSerialNumber = gSerial++;
814 gMsgPacket.pkCursor = curnum;
815 gMsgPacket.pkX = proximity->axis_data[0];
816 gMsgPacket.pkY = proximity->axis_data[1];
817 gMsgPacket.pkOrientation.orAzimuth = figure_deg(proximity->axis_data[3],proximity->axis_data[4]);
818 gMsgPacket.pkOrientation.orAltitude = ((1000 - 15 * max(abs(proximity->axis_data[3]),
819 abs(proximity->axis_data[4])))
820 * (gMsgPacket.pkStatus & TPS_INVERT?-1:1));
821 gMsgPacket.pkNormalPressure = proximity->axis_data[2];
822 gMsgPacket.pkButtons = get_button_state(curnum);
824 SendMessageW(hwndTabletDefault, WT_PROXIMITY, (event->type == proximity_in_type), (LPARAM)hwnd);
827 int X11DRV_AttachEventQueueToTablet(HWND hOwner)
829 struct x11drv_thread_data *data = x11drv_thread_data();
830 int num_devices;
831 int loop;
832 int cur_loop;
833 XDeviceInfo *devices;
834 XDeviceInfo *target = NULL;
835 XDevice *the_device;
836 XEventClass event_list[7];
837 Window win = X11DRV_get_whole_window( hOwner );
839 if (!win) return 0;
841 TRACE("Creating context for window %p (%lx) %i cursors\n", hOwner, win, gNumCursors);
843 wine_tsx11_lock();
844 devices = pXListInputDevices(data->display, &num_devices);
846 X11DRV_expect_error(data->display,Tablet_ErrorHandler,NULL);
847 for (cur_loop=0; cur_loop < gNumCursors; cur_loop++)
849 char cursorNameA[WT_MAX_NAME_LEN];
850 int event_number=0;
852 /* the cursor name fits in the buffer because too long names are skipped */
853 WideCharToMultiByte(CP_UNIXCP, 0, gSysCursor[cur_loop].NAME, -1, cursorNameA, WT_MAX_NAME_LEN, NULL, NULL);
854 for (loop=0; loop < num_devices; loop ++)
855 if (strcmp(devices[loop].name, cursorNameA) == 0)
856 target = &devices[loop];
858 TRACE("Opening cursor %i id %i\n",cur_loop,(INT)target->id);
860 the_device = pXOpenDevice(data->display, target->id);
862 if (!the_device)
864 WARN("Unable to Open device\n");
865 continue;
868 if (the_device->num_classes > 0)
870 DeviceKeyPress(the_device, key_press_type, event_list[event_number]);
871 if (key_press_type) event_number++;
872 DeviceKeyRelease(the_device, key_release_type, event_list[event_number]);
873 if (key_release_type) event_number++;
874 DeviceButtonPress(the_device, button_press_type, event_list[event_number]);
875 if (button_press_type) event_number++;
876 DeviceButtonRelease(the_device, button_release_type, event_list[event_number]);
877 if (button_release_type) event_number++;
878 DeviceMotionNotify(the_device, motion_type, event_list[event_number]);
879 if (motion_type) event_number++;
880 ProximityIn(the_device, proximity_in_type, event_list[event_number]);
881 if (proximity_in_type) event_number++;
882 ProximityOut(the_device, proximity_out_type, event_list[event_number]);
883 if (proximity_out_type) event_number++;
885 if (key_press_type) X11DRV_register_event_handler( key_press_type, key_event );
886 if (key_release_type) X11DRV_register_event_handler( key_release_type, key_event );
887 if (button_press_type) X11DRV_register_event_handler( button_press_type, button_event );
888 if (button_release_type) X11DRV_register_event_handler( button_release_type, button_event );
889 if (motion_type) X11DRV_register_event_handler( motion_type, motion_event );
890 if (proximity_in_type) X11DRV_register_event_handler( proximity_in_type, proximity_event );
891 if (proximity_out_type) X11DRV_register_event_handler( proximity_out_type, proximity_event );
893 pXSelectExtensionEvent(data->display, win, event_list, event_number);
896 XSync(data->display, False);
897 X11DRV_check_error();
899 if (NULL != devices) pXFreeDeviceList(devices);
900 wine_tsx11_unlock();
901 return 0;
904 int X11DRV_GetCurrentPacket(LPWTPACKET *packet)
906 memcpy(packet,&gMsgPacket,sizeof(WTPACKET));
907 return 1;
911 static inline int CopyTabletData(LPVOID target, LPCVOID src, INT size)
914 * It is valid to call CopyTabletData with NULL.
915 * This handles the WTInfo() case where lpOutput is null.
917 if(target != NULL)
918 memcpy(target,src,size);
919 return(size);
922 /***********************************************************************
923 * X11DRV_WTInfoW (X11DRV.@)
925 UINT X11DRV_WTInfoW(UINT wCategory, UINT nIndex, LPVOID lpOutput)
928 * It is valid to call WTInfoA with lpOutput == NULL, as per standard.
929 * lpOutput == NULL signifies the user only wishes
930 * to find the size of the data.
931 * NOTE:
932 * From now on use CopyTabletData to fill lpOutput. memcpy will break
933 * the code.
935 int rc = 0;
936 LPWTI_CURSORS_INFO tgtcursor;
937 TRACE("(%u, %u, %p)\n", wCategory, nIndex, lpOutput);
939 switch(wCategory)
941 case 0:
942 /* return largest necessary buffer */
943 TRACE("%i cursors\n",gNumCursors);
944 if (gNumCursors>0)
946 FIXME("Return proper size\n");
947 rc = 200;
949 break;
950 case WTI_INTERFACE:
951 switch (nIndex)
953 WORD version;
954 UINT num;
955 case IFC_WINTABID:
957 static const WCHAR driver[] = {'W','i','n','e',' ','W','i','n','t','a','b',' ','1','.','1',0};
958 rc = CopyTabletData(lpOutput, driver, (strlenW(driver) + 1) * sizeof(WCHAR));
959 break;
961 case IFC_SPECVERSION:
962 version = (0x01) | (0x01 << 8);
963 rc = CopyTabletData(lpOutput, &version,sizeof(WORD));
964 break;
965 case IFC_IMPLVERSION:
966 version = (0x00) | (0x01 << 8);
967 rc = CopyTabletData(lpOutput, &version,sizeof(WORD));
968 break;
969 case IFC_NDEVICES:
970 num = 1;
971 rc = CopyTabletData(lpOutput, &num,sizeof(num));
972 break;
973 case IFC_NCURSORS:
974 num = gNumCursors;
975 rc = CopyTabletData(lpOutput, &num,sizeof(num));
976 break;
977 default:
978 FIXME("WTI_INTERFACE unhandled index %i\n",nIndex);
979 rc = 0;
981 break;
982 case WTI_DEFSYSCTX:
983 case WTI_DDCTXS:
984 case WTI_DEFCONTEXT:
985 switch (nIndex)
987 case 0:
988 rc = CopyTabletData(lpOutput, &gSysContext,
989 sizeof(LOGCONTEXTW));
990 break;
991 case CTX_NAME:
992 rc = CopyTabletData(lpOutput, &gSysContext.lcName,
993 (strlenW(gSysContext.lcName)+1) * sizeof(WCHAR));
994 break;
995 case CTX_OPTIONS:
996 rc = CopyTabletData(lpOutput, &gSysContext.lcOptions,
997 sizeof(UINT));
998 break;
999 case CTX_STATUS:
1000 rc = CopyTabletData(lpOutput, &gSysContext.lcStatus,
1001 sizeof(UINT));
1002 break;
1003 case CTX_LOCKS:
1004 rc= CopyTabletData (lpOutput, &gSysContext.lcLocks,
1005 sizeof(UINT));
1006 break;
1007 case CTX_MSGBASE:
1008 rc = CopyTabletData(lpOutput, &gSysContext.lcMsgBase,
1009 sizeof(UINT));
1010 break;
1011 case CTX_DEVICE:
1012 rc = CopyTabletData(lpOutput, &gSysContext.lcDevice,
1013 sizeof(UINT));
1014 break;
1015 case CTX_PKTRATE:
1016 rc = CopyTabletData(lpOutput, &gSysContext.lcPktRate,
1017 sizeof(UINT));
1018 break;
1019 case CTX_PKTDATA:
1020 rc = CopyTabletData(lpOutput, &gSysContext.lcPktData,
1021 sizeof(WTPKT));
1022 break;
1023 case CTX_PKTMODE:
1024 rc = CopyTabletData(lpOutput, &gSysContext.lcPktMode,
1025 sizeof(WTPKT));
1026 break;
1027 case CTX_MOVEMASK:
1028 rc = CopyTabletData(lpOutput, &gSysContext.lcMoveMask,
1029 sizeof(WTPKT));
1030 break;
1031 case CTX_BTNDNMASK:
1032 rc = CopyTabletData(lpOutput, &gSysContext.lcBtnDnMask,
1033 sizeof(DWORD));
1034 break;
1035 case CTX_BTNUPMASK:
1036 rc = CopyTabletData(lpOutput, &gSysContext.lcBtnUpMask,
1037 sizeof(DWORD));
1038 break;
1039 case CTX_INORGX:
1040 rc = CopyTabletData(lpOutput, &gSysContext.lcInOrgX,
1041 sizeof(LONG));
1042 break;
1043 case CTX_INORGY:
1044 rc = CopyTabletData(lpOutput, &gSysContext.lcInOrgY,
1045 sizeof(LONG));
1046 break;
1047 case CTX_INORGZ:
1048 rc = CopyTabletData(lpOutput, &gSysContext.lcInOrgZ,
1049 sizeof(LONG));
1050 break;
1051 case CTX_INEXTX:
1052 rc = CopyTabletData(lpOutput, &gSysContext.lcInExtX,
1053 sizeof(LONG));
1054 break;
1055 case CTX_INEXTY:
1056 rc = CopyTabletData(lpOutput, &gSysContext.lcInExtY,
1057 sizeof(LONG));
1058 break;
1059 case CTX_INEXTZ:
1060 rc = CopyTabletData(lpOutput, &gSysContext.lcInExtZ,
1061 sizeof(LONG));
1062 break;
1063 case CTX_OUTORGX:
1064 rc = CopyTabletData(lpOutput, &gSysContext.lcOutOrgX,
1065 sizeof(LONG));
1066 break;
1067 case CTX_OUTORGY:
1068 rc = CopyTabletData(lpOutput, &gSysContext.lcOutOrgY,
1069 sizeof(LONG));
1070 break;
1071 case CTX_OUTORGZ:
1072 rc = CopyTabletData(lpOutput, &gSysContext.lcOutOrgZ,
1073 sizeof(LONG));
1074 break;
1075 case CTX_OUTEXTX:
1076 rc = CopyTabletData(lpOutput, &gSysContext.lcOutExtX,
1077 sizeof(LONG));
1078 break;
1079 case CTX_OUTEXTY:
1080 rc = CopyTabletData(lpOutput, &gSysContext.lcOutExtY,
1081 sizeof(LONG));
1082 break;
1083 case CTX_OUTEXTZ:
1084 rc = CopyTabletData(lpOutput, &gSysContext.lcOutExtZ,
1085 sizeof(LONG));
1086 break;
1087 case CTX_SENSX:
1088 rc = CopyTabletData(lpOutput, &gSysContext.lcSensX,
1089 sizeof(LONG));
1090 break;
1091 case CTX_SENSY:
1092 rc = CopyTabletData(lpOutput, &gSysContext.lcSensY,
1093 sizeof(LONG));
1094 break;
1095 case CTX_SENSZ:
1096 rc = CopyTabletData(lpOutput, &gSysContext.lcSensZ,
1097 sizeof(LONG));
1098 break;
1099 case CTX_SYSMODE:
1100 rc = CopyTabletData(lpOutput, &gSysContext.lcSysMode,
1101 sizeof(LONG));
1102 break;
1103 case CTX_SYSORGX:
1104 rc = CopyTabletData(lpOutput, &gSysContext.lcSysOrgX,
1105 sizeof(LONG));
1106 break;
1107 case CTX_SYSORGY:
1108 rc = CopyTabletData(lpOutput, &gSysContext.lcSysOrgY,
1109 sizeof(LONG));
1110 break;
1111 case CTX_SYSEXTX:
1112 rc = CopyTabletData(lpOutput, &gSysContext.lcSysExtX,
1113 sizeof(LONG));
1114 break;
1115 case CTX_SYSEXTY:
1116 rc = CopyTabletData(lpOutput, &gSysContext.lcSysExtY,
1117 sizeof(LONG));
1118 break;
1119 case CTX_SYSSENSX:
1120 rc = CopyTabletData(lpOutput, &gSysContext.lcSysSensX,
1121 sizeof(LONG));
1122 break;
1123 case CTX_SYSSENSY:
1124 rc = CopyTabletData(lpOutput, &gSysContext.lcSysSensY,
1125 sizeof(LONG));
1126 break;
1127 default:
1128 FIXME("WTI_DEFSYSCTX unhandled index %i\n",nIndex);
1129 rc = 0;
1131 break;
1132 case WTI_CURSORS:
1133 case WTI_CURSORS+1:
1134 case WTI_CURSORS+2:
1135 case WTI_CURSORS+3:
1136 case WTI_CURSORS+4:
1137 case WTI_CURSORS+5:
1138 case WTI_CURSORS+6:
1139 case WTI_CURSORS+7:
1140 case WTI_CURSORS+8:
1141 case WTI_CURSORS+9:
1142 if (wCategory - WTI_CURSORS >= gNumCursors)
1144 rc = 0;
1145 WARN("Requested cursor information for non existent cursor %d; only %d cursors\n",
1146 wCategory - WTI_CURSORS, gNumCursors);
1148 else
1150 tgtcursor = &gSysCursor[wCategory - WTI_CURSORS];
1151 switch (nIndex)
1153 case CSR_NAME:
1154 rc = CopyTabletData(lpOutput, &tgtcursor->NAME,
1155 (strlenW(tgtcursor->NAME)+1) * sizeof(WCHAR));
1156 break;
1157 case CSR_ACTIVE:
1158 rc = CopyTabletData(lpOutput,&tgtcursor->ACTIVE,
1159 sizeof(BOOL));
1160 break;
1161 case CSR_PKTDATA:
1162 rc = CopyTabletData(lpOutput,&tgtcursor->PKTDATA,
1163 sizeof(WTPKT));
1164 break;
1165 case CSR_BUTTONS:
1166 rc = CopyTabletData(lpOutput,&tgtcursor->BUTTONS,
1167 sizeof(BYTE));
1168 break;
1169 case CSR_BUTTONBITS:
1170 rc = CopyTabletData(lpOutput,&tgtcursor->BUTTONBITS,
1171 sizeof(BYTE));
1172 break;
1173 case CSR_BTNNAMES:
1174 FIXME("Button Names not returned correctly\n");
1175 rc = CopyTabletData(lpOutput,&tgtcursor->BTNNAMES,
1176 tgtcursor->cchBTNNAMES*sizeof(WCHAR));
1177 break;
1178 case CSR_BUTTONMAP:
1179 rc = CopyTabletData(lpOutput,&tgtcursor->BUTTONMAP,
1180 sizeof(BYTE)*32);
1181 break;
1182 case CSR_SYSBTNMAP:
1183 rc = CopyTabletData(lpOutput,&tgtcursor->SYSBTNMAP,
1184 sizeof(BYTE)*32);
1185 break;
1186 case CSR_NPBTNMARKS:
1187 rc = CopyTabletData(lpOutput,&tgtcursor->NPBTNMARKS,
1188 sizeof(UINT)*2);
1189 break;
1190 case CSR_NPBUTTON:
1191 rc = CopyTabletData(lpOutput,&tgtcursor->NPBUTTON,
1192 sizeof(BYTE));
1193 break;
1194 case CSR_NPRESPONSE:
1195 FIXME("Not returning CSR_NPRESPONSE correctly\n");
1196 rc = 0;
1197 break;
1198 case CSR_TPBUTTON:
1199 rc = CopyTabletData(lpOutput,&tgtcursor->TPBUTTON,
1200 sizeof(BYTE));
1201 break;
1202 case CSR_TPBTNMARKS:
1203 rc = CopyTabletData(lpOutput,&tgtcursor->TPBTNMARKS,
1204 sizeof(UINT)*2);
1205 break;
1206 case CSR_TPRESPONSE:
1207 FIXME("Not returning CSR_TPRESPONSE correctly\n");
1208 rc = 0;
1209 break;
1210 case CSR_PHYSID:
1212 DWORD id;
1213 id = tgtcursor->PHYSID;
1214 rc = CopyTabletData(lpOutput,&id,sizeof(DWORD));
1216 break;
1217 case CSR_MODE:
1218 rc = CopyTabletData(lpOutput,&tgtcursor->MODE,sizeof(UINT));
1219 break;
1220 case CSR_MINPKTDATA:
1221 rc = CopyTabletData(lpOutput,&tgtcursor->MINPKTDATA,
1222 sizeof(UINT));
1223 break;
1224 case CSR_MINBUTTONS:
1225 rc = CopyTabletData(lpOutput,&tgtcursor->MINBUTTONS,
1226 sizeof(UINT));
1227 break;
1228 case CSR_CAPABILITIES:
1229 rc = CopyTabletData(lpOutput,&tgtcursor->CAPABILITIES,
1230 sizeof(UINT));
1231 break;
1232 case CSR_TYPE:
1233 rc = CopyTabletData(lpOutput,&tgtcursor->TYPE,
1234 sizeof(UINT));
1235 break;
1236 default:
1237 FIXME("WTI_CURSORS unhandled index %i\n",nIndex);
1238 rc = 0;
1241 break;
1242 case WTI_DEVICES:
1243 switch (nIndex)
1245 case DVC_NAME:
1246 rc = CopyTabletData(lpOutput,gSysDevice.NAME,
1247 (strlenW(gSysDevice.NAME)+1) * sizeof(WCHAR));
1248 break;
1249 case DVC_HARDWARE:
1250 rc = CopyTabletData(lpOutput,&gSysDevice.HARDWARE,
1251 sizeof(UINT));
1252 break;
1253 case DVC_NCSRTYPES:
1254 rc = CopyTabletData(lpOutput,&gSysDevice.NCSRTYPES,
1255 sizeof(UINT));
1256 break;
1257 case DVC_FIRSTCSR:
1258 rc = CopyTabletData(lpOutput,&gSysDevice.FIRSTCSR,
1259 sizeof(UINT));
1260 break;
1261 case DVC_PKTRATE:
1262 rc = CopyTabletData(lpOutput,&gSysDevice.PKTRATE,
1263 sizeof(UINT));
1264 break;
1265 case DVC_PKTDATA:
1266 rc = CopyTabletData(lpOutput,&gSysDevice.PKTDATA,
1267 sizeof(WTPKT));
1268 break;
1269 case DVC_PKTMODE:
1270 rc = CopyTabletData(lpOutput,&gSysDevice.PKTMODE,
1271 sizeof(WTPKT));
1272 break;
1273 case DVC_CSRDATA:
1274 rc = CopyTabletData(lpOutput,&gSysDevice.CSRDATA,
1275 sizeof(WTPKT));
1276 break;
1277 case DVC_XMARGIN:
1278 rc = CopyTabletData(lpOutput,&gSysDevice.XMARGIN,
1279 sizeof(INT));
1280 break;
1281 case DVC_YMARGIN:
1282 rc = CopyTabletData(lpOutput,&gSysDevice.YMARGIN,
1283 sizeof(INT));
1284 break;
1285 case DVC_ZMARGIN:
1286 rc = 0; /* unsupported */
1288 rc = CopyTabletData(lpOutput,&gSysDevice.ZMARGIN,
1289 sizeof(INT));
1291 break;
1292 case DVC_X:
1293 rc = CopyTabletData(lpOutput,&gSysDevice.X,
1294 sizeof(AXIS));
1295 break;
1296 case DVC_Y:
1297 rc = CopyTabletData(lpOutput,&gSysDevice.Y,
1298 sizeof(AXIS));
1299 break;
1300 case DVC_Z:
1301 rc = 0; /* unsupported */
1303 rc = CopyTabletData(lpOutput,&gSysDevice.Z,
1304 sizeof(AXIS));
1306 break;
1307 case DVC_NPRESSURE:
1308 rc = CopyTabletData(lpOutput,&gSysDevice.NPRESSURE,
1309 sizeof(AXIS));
1310 break;
1311 case DVC_TPRESSURE:
1312 rc = 0; /* unsupported */
1314 rc = CopyTabletData(lpOutput,&gSysDevice.TPRESSURE,
1315 sizeof(AXIS));
1317 break;
1318 case DVC_ORIENTATION:
1319 rc = CopyTabletData(lpOutput,&gSysDevice.ORIENTATION,
1320 sizeof(AXIS)*3);
1321 break;
1322 case DVC_ROTATION:
1323 rc = 0; /* unsupported */
1325 rc = CopyTabletData(lpOutput,&gSysDevice.ROTATION,
1326 sizeof(AXIS)*3);
1328 break;
1329 case DVC_PNPID:
1330 rc = CopyTabletData(lpOutput,gSysDevice.PNPID,
1331 (strlenW(gSysDevice.PNPID)+1)*sizeof(WCHAR));
1332 break;
1333 default:
1334 FIXME("WTI_DEVICES unhandled index %i\n",nIndex);
1335 rc = 0;
1337 break;
1338 default:
1339 FIXME("Unhandled Category %i\n",wCategory);
1341 return rc;
1344 #else /* SONAME_LIBXI */
1346 /***********************************************************************
1347 * AttachEventQueueToTablet (X11DRV.@)
1349 int X11DRV_AttachEventQueueToTablet(HWND hOwner)
1351 return 0;
1354 /***********************************************************************
1355 * GetCurrentPacket (X11DRV.@)
1357 int X11DRV_GetCurrentPacket(LPWTPACKET *packet)
1359 return 0;
1362 /***********************************************************************
1363 * LoadTabletInfo (X11DRV.@)
1365 void X11DRV_LoadTabletInfo(HWND hwnddefault)
1369 /***********************************************************************
1370 * WTInfoW (X11DRV.@)
1372 UINT X11DRV_WTInfoW(UINT wCategory, UINT nIndex, LPVOID lpOutput)
1374 return 0;
1377 #endif /* SONAME_LIBXI */