summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/xorg/wacomcfg.h
blob: 03528df8226370ac011d504f76ed403b2cf50b70 (plain)
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
/*****************************************************************************
** wacomcfg.h
**
** Copyright (C) 2003 - John E. Joganic
** Copyright (C) 2004-2008 - Ping Cheng
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser 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 __LINUXWACOM_WACOMCFG_H
#define __LINUXWACOM_WACOMCFG_H

#include <X11/Xlib.h>
#include <X11/extensions/XInput.h>
#include <X11/extensions/XIproto.h>

/* JEJ - NOTE WE DO NOT INCLUDE Xwacom.h HERE.  THIS ELIMINATES A CONFLICT
 *       WHEN THIS FILE IS INSTALLED SINCE Xwacom.h WILL IN MANY CASES NOT
 *       GO WITH IT.  SOMEDAY IT MAY BE PART OF XFREE86. */

typedef struct _WACOMCONFIG WACOMCONFIG;
typedef struct _WACOMDEVICE WACOMDEVICE;
typedef void (*WACOMERRORFUNC)(int err, const char* pszText);
typedef struct _WACOMDEVICEINFO WACOMDEVICEINFO;

typedef enum
{
	WACOMDEVICETYPE_UNKNOWN,
	WACOMDEVICETYPE_CURSOR,
	WACOMDEVICETYPE_STYLUS,
	WACOMDEVICETYPE_ERASER,
	WACOMDEVICETYPE_PAD,
	WACOMDEVICETYPE_TOUCH,
	WACOMDEVICETYPE_MAX
} WACOMDEVICETYPE;

struct _WACOMDEVICEINFO
{
	const char* pszName;
	WACOMDEVICETYPE type;
};

struct _WACOMCONFIG
{
	Display* pDisp;
	WACOMERRORFUNC pfnError;
	XDeviceInfo * pDevs;
	int nDevCnt;
};

struct _WACOMDEVICE
{
	WACOMCONFIG* pCfg;
	XDevice* pDev;
};


/*****************************************************************************
** Functions
*****************************************************************************/

WACOMCONFIG * WacomConfigInit(Display* pDisplay, WACOMERRORFUNC pfnErrorHandler);
/* Initializes configuration library.
 *   pDisplay        - display to configure
 *   pfnErrorHandler - handler to which errors are reported; may be NULL
 * Returns WACOMCONFIG handle on success, NULL on error.
 *   errno contains error code. */

void WacomConfigTerm(WACOMCONFIG * hConfig);
/* Terminates configuration library, releasing display. */

int WacomConfigListDevices(WACOMCONFIG * hConfig, WACOMDEVICEINFO** ppInfo,
	unsigned int* puCount);
/* Returns a list of wacom devices.
 *   ppInfo         - pointer to WACOMDEVICEINFO* to receive device data
 *   puSize         - pointer to receive device count
 * Returns 0 on success, -1 on failure.  errno contains error code.
 * Comments: You must free this structure using WacomConfigFree. */

WACOMDEVICE * WacomConfigOpenDevice(WACOMCONFIG * hConfig,
	const char* pszDeviceName);
/* Open a device by name.
 *   pszDeviceName  - name of XInput device corresponding to wacom device
 * Returns handle to device on success, NULL on error.
 *   errno contains error code.
 * Comments: Close using WacomConfigCloseDevice */

int WacomConfigCloseDevice(WACOMDEVICE * hDevice);
/* Closes a device.
 * Returns 0 on success, -1 on error.  errno contains error code. */

int WacomConfigSetRawParam(WACOMDEVICE * hDevice, int nParam, int nValue, unsigned * keys);
/* Sets the raw device parameter to specified value.
 *   nParam         - valid paramters can be found Xwacom.h which is not
 *                      automatically included.
 *   nValue         - 32 bit integer value
 *   keys	    - an array of keys and modifiers
 * Returns 0 on success, -1 on error.  errno contains error code.
 *   EINVAL  - invalid parameter or value
 *   EIO     - unknown X failure, use XSetErrorHandler to capture complete
 *             error code and message
 * Comments: Data is sent to wacom_drv module without any error checking.
 *   Generally, you should use the more specific handler functions in this
 *   library, but for some parameters, particularly experimental ones, you
 *   will probably have to set them directly. */

int WacomConfigGetRawParam(WACOMDEVICE *hDevice, int nParam, int *nValue, int valu, unsigned * keys);
/* Gets the raw device parameter.
 *   nParam         - valid paramters can be found Xwacom.h which is not
 *                      automatically included.
 *   nValue         - the device parameter is returned in the integer
 *                    pointed by this parameter.
 *   valu	    - calling valuator value: 1: Get 3: GetDefault
 *   keys	    - an array of keys and modifiers
 * Returns 0 on success, -1 on error.  errno contains error code.
 *   EINVAL  - invalid parameter or value
 *   EIO     - unknown X failure, use XSetErrorHandler to capture complete
 *             error code and message
 */

void WacomConfigFree(void* pvData);
/* Frees memory allocated by library. */

#endif /* __LINUXWACOM_WACOMCFG_H */