1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
|
/*
* Copyright 1995-2002 by Frederic Lepied, France. <Lepied@XFree86.org>
* Copyright 2002-2010 by Ping Cheng, Wacom. <pingc@wacom.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __XF86_XF86WACOMDEFS_H
#define __XF86_XF86WACOMDEFS_H
/*****************************************************************************
* General Defines
****************************************************************************/
#include <wacom-util.h>
#include <asm/types.h>
#include <linux/input.h>
#define MAX_USB_EVENTS 32
/* vendor IDs on the kernel device */
#define WACOM_VENDOR_ID 0x056a
#define WALTOP_VENDOR_ID 0x172F
#define NTRIG_VENDOR_ID 0x1b96
#define HANWANG_VENDOR_ID 0x0b57
#define LENOVO_VENDOR_ID 0x17ef
#define DEFAULT_SUPPRESS 2 /* default suppress */
#define MAX_SUPPRESS 100 /* max value of suppress */
#define BUFFER_SIZE 256 /* size of reception buffer */
#define MAXTRY 3 /* max number of try to receive magic number */
#define MIN_ROTATION -900 /* the minimum value of the marker pen rotation */
#define MAX_ROTATION_RANGE 1800 /* the maximum range of the marker pen rotation */
#define MAX_ABS_WHEEL 1023 /* the maximum value of absolute wheel */
#define TILT_RES (180/M_PI) /* Reported tilt resolution in points/radian
(1/degree) */
#define TILT_MIN -64 /* Minimum reported tilt value */
#define TILT_MAX 63 /* Maximum reported tilt value */
#define MIN_PAD_RING 0 /* I4 absolute scroll ring min value */
#define MAX_PAD_RING 71 /* I4 absolute scroll ring max value */
/* I4 cursor tool has a rotation offset of 175 degrees */
#define INTUOS4_CURSOR_ROTATION_OFFSET 175
/* Default max distance to the tablet at which a proximity-out event is generated for
* cursor device (e.g. mouse).
*/
#define PROXOUT_INTUOS_DISTANCE 10
#define PROXOUT_GRAPHIRE_DISTANCE 42
/* 2.6.28 */
#ifndef BTN_TOOL_DOUBLETAP
#define BTN_TOOL_DOUBLETAP 0x14d
#endif
#ifndef BTN_TOOL_TRIPLETAP
#define BTN_TOOL_TRIPLETAP 0x14e
#endif
/* 2.6.30 */
#ifndef ABS_MT_POSITION_X
#define ABS_MT_POSITION_X 0x35
#endif
#ifndef ABS_MT_POSITION_Y
#define ABS_MT_POSITION_Y 0x36
#endif
#ifndef ABS_MT_TRACKING_ID
#define ABS_MT_TRACKING_ID 0x39
#endif
/* 2.6.33 */
#ifndef ABS_MT_PRESSURE
#define ABS_MT_PRESSURE 0x3a
#endif
/* 2.6.36 */
#ifndef ABS_MT_SLOT
#define ABS_MT_SLOT 0x2f
#endif
/* defines to discriminate second side button and the eraser */
#define ERASER_PROX 4
#define OTHER_PROX 1
/******************************************************************************
* Forward Declarations
*****************************************************************************/
typedef struct _WacomModel WacomModel, *WacomModelPtr;
typedef struct _WacomDeviceRec WacomDeviceRec, *WacomDevicePtr;
typedef struct _WacomDeviceState WacomDeviceState, *WacomDeviceStatePtr;
typedef struct _WacomChannel WacomChannel, *WacomChannelPtr;
typedef struct _WacomCommonRec WacomCommonRec, *WacomCommonPtr;
typedef struct _WacomFilterState WacomFilterState, *WacomFilterStatePtr;
typedef struct _WacomDeviceClass WacomDeviceClass, *WacomDeviceClassPtr;
typedef struct _WacomTool WacomTool, *WacomToolPtr;
typedef struct _WacomToolArea WacomToolArea, *WacomToolAreaPtr;
/******************************************************************************
* WacomModel - model-specific device capabilities
*****************************************************************************/
struct _WacomModel
{
const char* name;
void (*Initialize)(WacomCommonPtr common, const char* id, float version);
void (*GetResolution)(InputInfoPtr pInfo);
int (*GetRanges)(InputInfoPtr pInfo);
int (*Start)(InputInfoPtr pInfo);
int (*Parse)(InputInfoPtr pInfo, const unsigned char* data, int len);
int (*DetectConfig)(InputInfoPtr pInfo);
};
/******************************************************************************
* WacomDeviceRec
*****************************************************************************/
/* these device IDs are reported through ABS_MISC for Protocol 4 devices */
#define DEVICE_ID(flags) ((flags) & 0xff)
#define STYLUS_DEVICE_ID 0x02
#define TOUCH_DEVICE_ID 0x03
#define CURSOR_DEVICE_ID 0x06
#define ERASER_DEVICE_ID 0x0A
#define PAD_DEVICE_ID 0x0F
#define STYLUS_ID 0x00000001
#define TOUCH_ID 0x00000002
#define CURSOR_ID 0x00000004
#define ERASER_ID 0x00000008
#define PAD_ID 0x00000010
/* Each tablet may have one or more of the following
* features */
#define WCM_PEN 0x00000001 /* Tablet supports pens */
#define WCM_PAD 0x00000002 /* Has a pad tool */
#define WCM_1FGT 0x00000004 /* One finger touch */
#define WCM_2FGT 0x00000008 /* Two finger touch */
#define WCM_STRIP 0x00000010 /* Tablet has menu strip (e.g.
Intuos3) */
#define WCM_RING 0x00000020 /* Tablet has touch ring (e.g.
Intuos4) */
#define WCM_DUALINPUT 0x00000040 /* Supports two tools on the
tablet simultaneously (Intuos
1 and 2) */
#define WCM_ROTATION 0x00000080 /* Needs to convert mouse tool
tilt to rotation */
#define WCM_LCD 0x00000100 /* Cintiqs and other display
tablets */
#define WCM_TPC (0x00000200 | WCM_LCD) /* TabletPC (special
button handling,
always an LCD) */
#define WCM_PENTOUCH 0x00000400 /* Tablet supports pen and touch */
#define WCM_DUALRING 0x00000800 /* Tablet has two touch rings */
#define TabletHasFeature(common, feature) MaskIsSet((common)->tablet_type, (feature))
#define TabletSetFeature(common, feature) MaskSet((common)->tablet_type, (feature))
#define ABSOLUTE_FLAG 0x00000100
#define BAUD_19200_FLAG 0x00000400
#define BUTTONS_ONLY_FLAG 0x00000800
#define IsCursor(priv) (DEVICE_ID((priv)->flags) == CURSOR_ID)
#define IsStylus(priv) (DEVICE_ID((priv)->flags) == STYLUS_ID)
#define IsTouch(priv) (DEVICE_ID((priv)->flags) == TOUCH_ID)
#define IsEraser(priv) (DEVICE_ID((priv)->flags) == ERASER_ID)
#define IsPad(priv) (DEVICE_ID((priv)->flags) == PAD_ID)
#define IsPen(priv) (IsStylus(priv) || IsEraser(priv))
#define IsUSBDevice(common) ((common)->wcmDevCls == &gWacomUSBDevice)
#define FILTER_PRESSURE_RES 2048 /* maximum points in pressure curve */
/* Tested result for setting the pressure threshold to a reasonable value */
#define THRESHOLD_TOLERANCE (FILTER_PRESSURE_RES / 125)
#define DEFAULT_THRESHOLD (FILTER_PRESSURE_RES / 75)
#define WCM_MAX_BUTTONS 32 /* maximum number of tablet buttons */
#define AXIS_INVERT 0x01 /* Flag describing an axis which increases "downward" */
#define AXIS_BITWISE 0x02 /* Flag describing an axis which changes bitwise */
/* Indicies into the wheel/strip default/keys/actions arrays */
#define WHEEL_REL_UP 0
#define WHEEL_REL_DN 1
#define WHEEL_ABS_UP 2
#define WHEEL_ABS_DN 3
#define WHEEL2_ABS_UP 4
#define WHEEL2_ABS_DN 5
#define STRIP_LEFT_UP 0
#define STRIP_LEFT_DN 1
#define STRIP_RIGHT_UP 2
#define STRIP_RIGHT_DN 3
/* get/set/property */
typedef struct _PROPINFO PROPINFO;
struct _PROPINFO
{
Atom wcmProp;
char paramName[32];
int nParamID;
int nFormat;
int nSize;
int nDefault;
};
struct _WacomDeviceRec
{
char *name; /* Do not move, same offset as common->device_path. Used by DBG macro */
/* configuration fields */
struct _WacomDeviceRec *next;
InputInfoPtr pInfo;
int debugLevel;
unsigned int flags; /* various flags (type, abs, touch...) */
int topX; /* X top in device coordinates */
int topY; /* Y top in device coordinates */
int bottomX; /* X bottom in device coordinates */
int bottomY; /* Y bottom in device coordinates */
int resolX; /* X resolution */
int resolY; /* Y resolution */
int maxX; /* tool physical maxX in device coordinates*/
int maxY; /* tool physical maxY in device coordinates*/
double factorX; /* X factor */
double factorY; /* Y factor */
unsigned int serial; /* device serial number this device takes (if 0, any serial is ok) */
unsigned int cur_serial; /* current serial in prox */
int cur_device_id; /* current device ID in prox */
int leftPadding; /* left padding for virtual tablet in device coordinates*/
int topPadding; /* top padding for virtual tablet in device coordinates*/
/* button mapping information
*
* 'button' variables are indexed by physical button number (0..nbuttons)
* 'strip' variables are indexed by STRIP_* defines
* 'wheel' variables are indexed by WHEEL_* defines
*/
int button_default[WCM_MAX_BUTTONS]; /* Default mappings set by ourselves (possibly overridden by xorg.conf) */
int strip_default[4];
int wheel_default[6];
unsigned keys[WCM_MAX_BUTTONS][256]; /* Action codes to perform when the associated event occurs */
unsigned strip_keys[4][256];
unsigned wheel_keys[6][256];
Atom btn_actions[WCM_MAX_BUTTONS]; /* Action references so we can update the action codes when a client makes a change */
Atom strip_actions[4];
Atom wheel_actions[6];
int nbuttons; /* number of buttons for this subdevice */
int naxes; /* number of axes */
/* FIXME: always 6, and the code relies on that... */
WacomCommonPtr common; /* common info pointer */
/* state fields in device coordinates */
int currentX; /* current X position */
int currentY; /* current Y position */
int currentSX; /* current screen X position in screen coords */
int currentSY; /* current screen Y position in screen coords */
int oldX; /* previous X position */
int oldY; /* previous Y position */
int oldZ; /* previous pressure */
int oldTiltX; /* previous tilt in x direction */
int oldTiltY; /* previous tilt in y direction */
int oldWheel; /* previous wheel value */
int oldWheel2; /* previous wheel2 value */
int oldRot; /* previous rotation value */
int oldStripX; /* previous left strip value */
int oldStripY; /* previous right strip value */
int oldThrottle; /* previous throttle value */
int oldButtons; /* previous buttons state */
int oldProximity; /* previous proximity */
int oldCursorHwProx; /* previous cursor hardware proximity */
int old_device_id; /* last in prox device id */
unsigned int old_serial;/* last in prox tool serial number */
int devReverseCount; /* Relative ReverseConvert called twice each movement*/
/* JEJ - throttle */
int throttleStart; /* time in ticks for last wheel movement */
int throttleLimit; /* time in ticks for next wheel movement */
int throttleValue; /* current throttle value */
/* JEJ - filters */
int pPressCurve[FILTER_PRESSURE_RES + 1]; /* pressure curve */
int nPressCtrl[4]; /* control points for curve */
int minPressure; /* the minimum pressure a pen may hold */
WacomToolPtr tool; /* The common tool-structure for this device */
int isParent; /* set to 1 if the device is not auto-hotplugged */
OsTimerPtr serial_timer; /* timer used for serial number property update */
OsTimerPtr tap_timer; /* timer used for tap timing */
};
/******************************************************************************
* WacomDeviceState
*****************************************************************************/
#define MAX_SAMPLES 20
#define DEFAULT_SAMPLES 4
struct _WacomDeviceState
{
InputInfoPtr pInfo;
int device_id; /* tool id reported from the physical device */
int device_type;
unsigned int serial_num;
int x;
int y;
int buttons;
int pressure;
int tiltx;
int tilty;
int stripx;
int stripy;
int rotation;
int abswheel;
int abswheel2;
int relwheel;
int distance;
int throttle;
int proximity;
int sample; /* wraps every 24 days */
};
struct _WacomFilterState
{
int npoints;
int x[MAX_SAMPLES];
int y[MAX_SAMPLES];
int tiltx[MAX_SAMPLES];
int tilty[MAX_SAMPLES];
};
struct _WacomChannel
{
/* data stored in this structure is raw data from the tablet, prior
* to transformation and user-defined filtering. Suppressed values
* will not be included here, and hardware filtering may occur between
* the work stage and the valid state. */
WacomDeviceState work; /* next state */
Bool dirty;
/* the following union contains the current known state of the
* device channel, as well as the previous MAX_SAMPLES states
* for use in detecting hardware defects, jitter, trends, etc. */
union
{
WacomDeviceState state; /* current state */
WacomDeviceState states[MAX_SAMPLES]; /* states 0..MAX */
} valid;
int nSamples;
WacomFilterState rawFilter;
};
/******************************************************************************
* WacomDeviceClass
*****************************************************************************/
struct _WacomDeviceClass
{
Bool (*Detect)(InputInfoPtr pInfo); /* detect device */
Bool (*ParseOptions)(InputInfoPtr pInfo); /* parse class-specific options */
Bool (*Init)(InputInfoPtr pInfo, char* id, float *version); /* initialize device */
int (*ProbeKeys)(InputInfoPtr pInfo); /* set the bits for the keys supported */
};
extern WacomDeviceClass gWacomUSBDevice;
extern WacomDeviceClass gWacomISDV4Device;
/******************************************************************************
* WacomCommonRec
*****************************************************************************/
#define TILT_REQUEST_FLAG 1
#define TILT_ENABLED_FLAG 2
#define MAX_CHANNELS 17
#define PAD_CHANNEL (MAX_CHANNELS-1)
#define MAX_FINGERS (MAX_CHANNELS-1)
typedef struct {
int wcmZoomDistance; /* minimum distance for a zoom touch gesture */
int wcmScrollDistance; /* minimum motion before sending a scroll gesture */
int wcmScrollDirection; /* store the vertical or horizontal bit in use */
int wcmMaxScrollFingerSpread; /* maximum distance between fingers for scroll gesture */
int wcmGestureUsed; /* retain used gesture count within one in-prox event */
int wcmTapTime; /* minimum time between taps for a right click */
} WacomGesturesParameters;
enum WacomProtocol {
WCM_PROTOCOL_GENERIC,
WCM_PROTOCOL_4,
WCM_PROTOCOL_5
};
struct _WacomCommonRec
{
/* Do not move device_path, same offset as priv->name. Used by DBG macro */
const char* device_path; /* device file name */
dev_t min_maj; /* minor/major number */
unsigned char wcmFlags; /* various flags (handle tilt) */
int debugLevel;
int vendor_id; /* Vendor ID */
int tablet_id; /* USB tablet ID */
int tablet_type; /* bitmask of tablet features (WCM_LCD, WCM_PEN, etc) */
int fd; /* file descriptor to tablet */
int fd_refs; /* number of references to fd; if =0, fd is invalid */
unsigned long wcmKeys[NBITS(KEY_MAX)]; /* supported tool types for the device */
WacomDevicePtr wcmTouchDevice; /* The pointer for pen to access the
touch tool of the same device id */
Bool wcmPenInProx; /* Keep pen in-prox state for touch tool */
/* These values are in tablet coordinates */
int wcmMaxX; /* tablet max X value */
int wcmMaxY; /* tablet max Y value */
int wcmMaxZ; /* tablet max Z value */
int wcmMaxTouchX; /* touch panel max X value */
int wcmMaxTouchY; /* touch panel max Y value */
int wcmResolX; /* pen tool X resolution in points/m */
int wcmResolY; /* pen tool Y resolution in points/m */
int wcmTouchResolX; /* touch X resolution in points/m */
int wcmTouchResolY; /* touch Y resolution in points/m */
/* tablet Z resolution is equivalent
* to wcmMaxZ which is equal to 100% pressure */
int wcmMaxDist; /* tablet max distance value */
int wcmMaxContacts; /* MT device max number of contacts */
/*
* TODO Remove wcmTiltOff*, once the kernel drivers reporting
* non-zero-centered tilt values are no longer in use.
*/
int wcmTiltOffX; /* styli tilt offset in X direction */
int wcmTiltOffY; /* styli tilt offset in Y direction */
double wcmTiltFactX; /* styli tilt factor in X direction */
double wcmTiltFactY; /* styli tilt factor in Y direction */
int wcmTiltMinX; /* styli min reported tilt in X direction */
int wcmTiltMinY; /* styli min reported tilt in Y direction */
int wcmTiltMaxX; /* styli max reported tilt in X direction */
int wcmTiltMaxY; /* styli max reported tilt in Y direction */
int wcmMaxStripX; /* Maximum fingerstrip X */
int wcmMaxStripY; /* Maximum fingerstrip Y */
WacomDevicePtr wcmDevices; /* list of devices sharing same port */
int wcmPktLength; /* length of a packet */
int wcmProtocolLevel; /* Wacom Protocol used */
float wcmVersion; /* ROM version */
int wcmRotate; /* rotate screen (for TabletPC) */
int wcmThreshold; /* Threshold for button pressure */
WacomChannel wcmChannel[MAX_CHANNELS]; /* channel device state */
WacomDeviceClassPtr wcmDevCls; /* device class functions */
WacomModelPtr wcmModel; /* model-specific functions */
int wcmTPCButton; /* set Tablet PC button on/off */
int wcmTouch; /* disable/enable touch event */
int wcmTouchDefault; /* default to disable when not supported */
int wcmGesture; /* disable/enable touch gesture */
int wcmGestureDefault; /* default touch gesture to disable when not supported */
int wcmGestureMode; /* data is in Gesture Mode? */
WacomDeviceState wcmGestureState[MAX_FINGERS]; /* inital state when in gesture mode */
WacomGesturesParameters wcmGestureParameters;
int wcmMaxCursorDist; /* Max mouse distance reported so far */
int wcmCursorProxoutDist; /* Max mouse distance for proxy-out max/256 units */
int wcmCursorProxoutDistDefault; /* Default max mouse distance for proxy-out */
int wcmSuppress; /* transmit position on delta > supress */
int wcmRawSample; /* Number of raw data used to filter an event */
int bufpos; /* position with buffer */
unsigned char buffer[BUFFER_SIZE]; /* data read from device */
void *private; /* backend-specific information */
WacomToolPtr wcmTool; /* List of unique tools */
WacomToolPtr serials; /* Serial numbers provided at startup*/
/* DO NOT TOUCH THIS. use wcmRefCommon() instead */
int refcnt; /* number of devices sharing this struct */
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 16
ValuatorMask *touch_mask;
#endif
};
#define HANDLE_TILT(comm) ((comm)->wcmFlags & TILT_ENABLED_FLAG)
/******************************************************************************
* WacomTool
*****************************************************************************/
struct _WacomTool
{
WacomToolPtr next; /* Next tool in list */
int typeid; /* Tool type */
unsigned int serial; /* Serial id, 0 == no serial id */
Bool enabled;
char *name;
InputInfoPtr device; /* The InputDevice connected to this tool */
};
#endif /*__XF86_XF86WACOMDEFS_H */
/* vim: set noexpandtab tabstop=8 shiftwidth=8: */
|