~ubuntu-branches/debian/lenny/wacom-tools/lenny

« back to all changes in this revision

Viewing changes to linuxwacom/src/wactablet.h

  • Committer: Bazaar Package Importer
  • Author(s): Ron Lee
  • Date: 2004-12-10 16:12:07 UTC
  • Revision ID: james.westby@ubuntu.com-20041210161207-cw8urijtjsqvk2e3
Tags: upstream-0.6.6
ImportĀ upstreamĀ versionĀ 0.6.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
** wactablet.h
 
3
**
 
4
** Copyright (C) 2002 - 2004 - John E. Joganic
 
5
**
 
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.
 
10
**
 
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.
 
15
**
 
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.
 
19
**
 
20
****************************************************************************/
 
21
 
 
22
#ifndef __LINUXWACOM_WACTABLET_H
 
23
#define __LINUXWACOM_WACTABLET_H
 
24
 
 
25
#include <stdarg.h>
 
26
#include <sys/time.h>
 
27
 
 
28
#define WACOMVENDOR_UNKNOWN     0x0000
 
29
#define WACOMVENDOR_WACOM       0x056A
 
30
#define WACOMVENDOR_ACER        0xFFFFFF01
 
31
 
 
32
#define WACOMCLASS_SERIAL       0x0001
 
33
#define WACOMCLASS_USB          0x0002
 
34
 
 
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
 
51
 
 
52
typedef struct _WACOMMODEL WACOMMODEL;
 
53
struct _WACOMMODEL
 
54
{
 
55
        unsigned int uClass;
 
56
        unsigned int uVendor;
 
57
        unsigned int uDevice;
 
58
        unsigned int uSubType;
 
59
};
 
60
 
 
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
 
70
 
 
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
 
80
 
 
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
 
96
 
 
97
typedef struct
 
98
{
 
99
        int nValue;
 
100
        int nMin;
 
101
        int nMax;
 
102
        int nReserved;
 
103
} WACOMVALUE;
 
104
 
 
105
typedef struct
 
106
{
 
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];
 
110
} WACOMSTATE;
 
111
 
 
112
#define WACOMSTATE_INIT { WACOMFIELD_MAX }
 
113
 
 
114
typedef struct
 
115
{
 
116
        const char* pszName;
 
117
        const char* pszDesc;
 
118
        unsigned int uDeviceClass;
 
119
} WACOMCLASSREC;
 
120
 
 
121
typedef struct
 
122
{
 
123
        const char* pszName;
 
124
        const char* pszDesc;
 
125
        const char* pszVendorName;
 
126
        const char* pszVendorDesc;
 
127
        const char* pszClass;
 
128
        WACOMMODEL model;
 
129
} WACOMDEVICEREC;
 
130
 
 
131
typedef enum
 
132
{
 
133
        WACOMLOGLEVEL_NONE,
 
134
        WACOMLOGLEVEL_CRITICAL,
 
135
        WACOMLOGLEVEL_ERROR,
 
136
        WACOMLOGLEVEL_WARN,
 
137
        WACOMLOGLEVEL_INFO,
 
138
        WACOMLOGLEVEL_DEBUG,
 
139
        WACOMLOGLEVEL_TRACE,
 
140
        WACOMLOGLEVEL_MAX
 
141
} WACOMLOGLEVEL;
 
142
 
 
143
typedef void (*WACOMLOGFUNC)(struct timeval tv, WACOMLOGLEVEL level,
 
144
        const char* pszLog);
 
145
 
 
146
/*****************************************************************************
 
147
** Public structures
 
148
*****************************************************************************/
 
149
 
 
150
typedef struct { int __unused; } *WACOMENGINE;
 
151
typedef struct { int __unused; } *WACOMTABLET;
 
152
 
 
153
/*****************************************************************************
 
154
** Public API
 
155
*****************************************************************************/
 
156
 
 
157
        WACOMENGINE WacomInitEngine(void);
 
158
        /* Initialize the tablet engine */
 
159
 
 
160
        void WacomTermEngine(WACOMENGINE hEngine);
 
161
        /* Shutdown the tablet engine */
 
162
 
 
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. */
 
170
 
 
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. */
 
174
 
 
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. */
 
181
 
 
182
        void WacomFreeList(void* pvList);
 
183
        /* Releases list memory. */
 
184
 
 
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. */
 
190
 
 
191
        unsigned int WacomGetClassFromName(const char* pszName);
 
192
        /* Returns the device class for a given name. Returns 0, if unknown. */
 
193
 
 
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. */
 
199
 
 
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. */
 
205
 
 
206
        void WacomCloseTablet(WACOMTABLET hTablet);
 
207
        /* Releases all resource associated with tablet and closes device. */
 
208
 
 
209
        WACOMMODEL WacomGetModel(WACOMTABLET hTablet);
 
210
        /* Returns model (vendor, class, and device) of specified tablet. */
 
211
 
 
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. */
 
215
 
 
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. */
 
219
 
 
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. */
 
223
 
 
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. */
 
228
 
 
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. */
 
233
 
 
234
        int WacomGetROMVersion(WACOMTABLET hTablet, int* pnMajor, int* pnMinor,
 
235
                        int* pnRelease);
 
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. */
 
242
 
 
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. */
 
247
 
 
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
 
254
         * WACOMFIELD_MAX. */
 
255
 
 
256
        int WacomGetFileDescriptor(WACOMTABLET hTablet);
 
257
        /* Returns the file descriptor of the tablet or -1 on error. */
 
258
 
 
259
        int WacomReadRaw(WACOMTABLET hTablet, unsigned char* puchData,
 
260
                        unsigned int uSize);
 
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. */
 
263
 
 
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. */
 
270
 
 
271
/*****************************************************************************
 
272
** Private structures
 
273
*****************************************************************************/
 
274
 
 
275
typedef struct _WACOMTABLET_PRIV WACOMTABLET_PRIV;
 
276
 
 
277
struct _WACOMTABLET_PRIV
 
278
{
 
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,
 
287
                int* pnRelease);
 
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,
 
292
                        unsigned int uSize);
 
293
        int (*ParseData)(WACOMTABLET_PRIV* pTablet, const unsigned char* puchData,
 
294
                        unsigned int uLength, WACOMSTATE* pState);
 
295
};
 
296
 
 
297
#endif /* __LINUXWACOM_WACTABLET_H */