1
/*****************************************************************************
4
** Copyright (C) 2002 - 2004 - John E. Joganic
6
** This program is free software; you can redistribute it and/or
7
** modify it under the terms of the GNU General Public License
8
** as published by the Free Software Foundation; either version 2
9
** of the License, or (at your option) any later version.
11
** This program 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
14
** GNU Lesser General Public License for more details.
16
** You should have received a copy of the GNU General Public License
17
** along with this program; if not, write to the Free Software
18
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
****************************************************************************/
22
#ifndef __LINUXWACOM_WACTABLET_H
23
#define __LINUXWACOM_WACTABLET_H
28
#define WACOMVENDOR_UNKNOWN 0x0000
29
#define WACOMVENDOR_WACOM 0x056A
30
#define WACOMVENDOR_ACER 0xFFFFFF01
32
#define WACOMCLASS_SERIAL 0x0001
33
#define WACOMCLASS_USB 0x0002
35
#define WACOMDEVICE_UNKNOWN 0x0000
36
#define WACOMDEVICE_ARTPAD 0x0001
37
#define WACOMDEVICE_ARTPADII 0x0002
38
#define WACOMDEVICE_DIGITIZER 0x0003
39
#define WACOMDEVICE_DIGITIZERII 0x0004
40
#define WACOMDEVICE_PENPARTNER 0x0005
41
#define WACOMDEVICE_GRAPHIRE 0x0006
42
#define WACOMDEVICE_GRAPHIRE2 0x0007
43
#define WACOMDEVICE_GRAPHIRE3 0x0008
44
#define WACOMDEVICE_INTUOS 0x0009
45
#define WACOMDEVICE_INTUOS2 0x000A
46
#define WACOMDEVICE_CINTIQ 0x000B
47
#define WACOMDEVICE_PTU 0x000C
48
#define WACOMDEVICE_VOLITO 0x000D
49
#define WACOMDEVICE_ACERC100 0x000E
50
#define WACOMDEVICE_INTUOS3 0x000F
52
typedef struct _WACOMMODEL WACOMMODEL;
58
unsigned int uSubType;
61
#define WACOMTOOLTYPE_NONE 0x00
62
#define WACOMTOOLTYPE_PEN 0x01
63
#define WACOMTOOLTYPE_PENCIL 0x02
64
#define WACOMTOOLTYPE_BRUSH 0x03
65
#define WACOMTOOLTYPE_ERASER 0x04
66
#define WACOMTOOLTYPE_AIRBRUSH 0x05
67
#define WACOMTOOLTYPE_MOUSE 0x06
68
#define WACOMTOOLTYPE_LENS 0x07
69
#define WACOMTOOLTYPE_MAX 0x08
71
#define WACOMBUTTON_LEFT 0
72
#define WACOMBUTTON_MIDDLE 1
73
#define WACOMBUTTON_RIGHT 2
74
#define WACOMBUTTON_EXTRA 3
75
#define WACOMBUTTON_SIDE 4
76
#define WACOMBUTTON_TOUCH 5
77
#define WACOMBUTTON_STYLUS 6
78
#define WACOMBUTTON_STYLUS2 7
79
#define WACOMBUTTON_MAX 8
81
#define WACOMFIELD_TOOLTYPE 0
82
#define WACOMFIELD_SERIAL 1
83
#define WACOMFIELD_PROXIMITY 2
84
#define WACOMFIELD_BUTTONS 3
85
#define WACOMFIELD_POSITION_X 4
86
#define WACOMFIELD_POSITION_Y 5
87
#define WACOMFIELD_ROTATION_Z 6
88
#define WACOMFIELD_DISTANCE 7
89
#define WACOMFIELD_PRESSURE 8
90
#define WACOMFIELD_TILT_X 9
91
#define WACOMFIELD_TILT_Y 10
92
#define WACOMFIELD_ABSWHEEL 11
93
#define WACOMFIELD_RELWHEEL 12
94
#define WACOMFIELD_THROTTLE 13
95
#define WACOMFIELD_MAX 14
107
unsigned int uValueCnt; /* This MUST be set to WACOMFIELD_MAX. */
108
unsigned int uValid; /* Bit mask of WACOMFIELD_xxx bits. */
109
WACOMVALUE values[WACOMFIELD_MAX];
112
#define WACOMSTATE_INIT { WACOMFIELD_MAX }
118
unsigned int uDeviceClass;
125
const char* pszVendorName;
126
const char* pszVendorDesc;
127
const char* pszClass;
134
WACOMLOGLEVEL_CRITICAL,
143
typedef void (*WACOMLOGFUNC)(struct timeval tv, WACOMLOGLEVEL level,
146
/*****************************************************************************
148
*****************************************************************************/
150
typedef struct { int __unused; } *WACOMENGINE;
151
typedef struct { int __unused; } *WACOMTABLET;
153
/*****************************************************************************
155
*****************************************************************************/
157
WACOMENGINE WacomInitEngine(void);
158
/* Initialize the tablet engine */
160
void WacomTermEngine(WACOMENGINE hEngine);
161
/* Shutdown the tablet engine */
163
void WacomSetLogFunc(WACOMENGINE hEngine, WACOMLOGFUNC pfnLog);
164
void WacomSetLogLevel(WACOMENGINE hEngine, WACOMLOGLEVEL level);
165
void WacomLogV(WACOMENGINE hEngine, WACOMLOGLEVEL level,
166
const char* pszFmt, va_list args);
167
void WacomLog(WACOMENGINE hEngine, WACOMLOGLEVEL level,
168
const char* pszFmt, ...);
169
/* Logging functions. Default log function does nothing. */
171
int WacomGetSupportedClassList(WACOMCLASSREC** ppList, int* pnSize);
172
/* Returns 0 on success. Pointer to class record list is returned to
173
* ppList, and size of list to pnSize. Use WacomFreeList to release. */
175
int WacomGetSupportedDeviceList(unsigned int uDeviceClass,
176
WACOMDEVICEREC** ppList, int* pnSize);
177
/* Returns 0 on success. If device class is specified, only devices
178
* of the request type are returned. A value of 0 will return all
179
* devices for all classes. Pointer to device record list is returned to
180
* ppList, and size of list to pnSize. Use WacomFreeList to release. */
182
void WacomFreeList(void* pvList);
183
/* Releases list memory. */
185
int WacomCopyState(WACOMSTATE* pDest, WACOMSTATE* pSrc);
186
/* Returns 0 on success. Copies tablet state structures.
187
* Source and destination structures must be properly initialized,
188
* particularly the uValueCnt field must be set WACOMFIELD_MAX.
189
* Returns 0 on success. */
191
unsigned int WacomGetClassFromName(const char* pszName);
192
/* Returns the device class for a given name. Returns 0, if unknown. */
194
unsigned int WacomGetDeviceFromName(const char* pszName,
195
unsigned int uDeviceClass);
196
/* Returns the device type for a given device name. If the
197
* device class is specified, only that class will be searched.
198
* Returns 0, if unknown. */
200
WACOMTABLET WacomOpenTablet(WACOMENGINE hEngine,
201
const char* pszDevice, WACOMMODEL* pModel);
202
/* Returns tablet handle on success, NULL otherwise.
203
* pszDevice is pathname to device. Model may be NULL; if any model
204
* parameters are 0, detection is automatic. */
206
void WacomCloseTablet(WACOMTABLET hTablet);
207
/* Releases all resource associated with tablet and closes device. */
209
WACOMMODEL WacomGetModel(WACOMTABLET hTablet);
210
/* Returns model (vendor, class, and device) of specified tablet. */
212
const char* WacomGetVendorName(WACOMTABLET hTablet);
213
/* Returns vendor name as human-readable string. String is valid as
214
* long as tablet handle is valid and does not need to be freed. */
216
const char* WacomGetClassName(WACOMTABLET hTablet);
217
/* Returns class name as human-readable string. String is valid as
218
* long as tablet handle is valid and does not need to be freed. */
220
const char* WacomGetDeviceName(WACOMTABLET hTablet);
221
/* Returns device name as human-readable string. String is valid as
222
* long as tablet handle is valid and does not need to be freed. */
224
const char* WacomGetSubTypeName(WACOMTABLET hTablet);
225
/* Returns subtype name as human-readable string. This is typically
226
* the model number (eg. ABC-1234). String is valid as long as tablet
227
* handle is valid and does not need to be freed. */
229
const char* WacomGetModelName(WACOMTABLET hTablet);
230
/* Returns model name as human-readable string. This is typically
231
* the full model name (eg. FooCo FooModel 9x12). String is valid as
232
* long as tablet handle is valid and does not need to be freed. */
234
int WacomGetROMVersion(WACOMTABLET hTablet, int* pnMajor, int* pnMinor,
236
/* Returns 0 on success. ROM version of the tablet firmware is returned
237
* in major, minor, and release values. If the caller needs to
238
* distinguish between ROM versions to work around a bug, please consider
239
* submitting a patch to this library. All tablets should appear
240
* equivalent through this interface. This call is provided for
241
* information purposes. */
243
int WacomGetCapabilities(WACOMTABLET hTablet);
244
/* Returns bitmask of valid fields. Use (1 << WACOMFIELD_xxx) to
245
* translate field identifiers to bit positions. This API will only
246
* support 32 capabilities. */
248
int WacomGetState(WACOMTABLET hTablet, WACOMSTATE* pState);
249
/* Returns 0 on success. Tablet state is copied to specified structure.
250
* Data is only a snapshot of the device and may not accurately reflect
251
* the position of any specific tool. This is particularly true of
252
* multi-tool mode tablets. NOTE: pState must point to an initialized
253
* structure; the uValueCnt field must be correctly set to
256
int WacomGetFileDescriptor(WACOMTABLET hTablet);
257
/* Returns the file descriptor of the tablet or -1 on error. */
259
int WacomReadRaw(WACOMTABLET hTablet, unsigned char* puchData,
261
/* Returns number of bytes read, typically a single packet. Call will
262
* block. uSize should be the maximum size of the given data buffer. */
264
int WacomParseData(WACOMTABLET hTablet, const unsigned char* puchData,
265
unsigned int uLength, WACOMSTATE* pState);
266
/* Updates the tablet state from a given packet. If pState is specified,
267
* the tablet state is copied to the given structure. This structure
268
* must be correctly initialized; the uValueCnt member must be set to
269
* WACOMFIELD_MAX. Returns 0 on success. */
271
/*****************************************************************************
272
** Private structures
273
*****************************************************************************/
275
typedef struct _WACOMTABLET_PRIV WACOMTABLET_PRIV;
277
struct _WACOMTABLET_PRIV
279
void (*Close)(WACOMTABLET_PRIV* pTablet);
280
WACOMMODEL (*GetModel)(WACOMTABLET_PRIV* pTablet);
281
const char* (*GetVendorName)(WACOMTABLET_PRIV* pTablet);
282
const char* (*GetClassName)(WACOMTABLET_PRIV* pTablet);
283
const char* (*GetDeviceName)(WACOMTABLET_PRIV* pTablet);
284
const char* (*GetSubTypeName)(WACOMTABLET_PRIV* pTablet);
285
const char* (*GetModelName)(WACOMTABLET_PRIV* pTablet);
286
int (*GetROMVer)(WACOMTABLET_PRIV* pTablet, int* pnMajor, int* pnMinor,
288
int (*GetCaps)(WACOMTABLET_PRIV* pTablet);
289
int (*GetState)(WACOMTABLET_PRIV* pTablet, WACOMSTATE* pState);
290
int (*GetFD)(WACOMTABLET_PRIV* pTablet);
291
int (*ReadRaw)(WACOMTABLET_PRIV* pTablet, unsigned char* puchData,
293
int (*ParseData)(WACOMTABLET_PRIV* pTablet, const unsigned char* puchData,
294
unsigned int uLength, WACOMSTATE* pState);
297
#endif /* __LINUXWACOM_WACTABLET_H */