ws.h revision 3cd2e234
1/*
2 * Copyright © 2009 Matthieu Herrb <matthieu@herrb.eu>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include <dev/wscons/wsconsio.h>
18
19
20/* #undef DEBUG */
21#define DEBUG
22#undef DBG
23extern int ws_debug_level;
24#ifdef DEBUG
25# define DBG(lvl, f) { if ((lvl) <= ws_debug_level) f;}
26#else
27# define DBG(lvl, f)
28#endif
29
30#define NAXES 2			/* X and Y axes only */
31#define NBUTTONS 32		/* max theoretical buttons */
32#define DFLTBUTTONS 3		/* default number of buttons */
33#define NUMEVENTS 16		/* max # of ws events to read at once */
34
35typedef struct WSDevice {
36	const char *devName;	/* device name */
37	int type;		/* ws device type */
38	unsigned int buttons;	/* # of buttons */
39	unsigned int lastButtons; /* last state of buttons */
40	int min_x, max_x, min_y, max_y; /* coord space */
41	int swap_axes;
42	int raw;
43	int inv_x, inv_y;
44	int screen_no;
45	int num, den, threshold; /* relative accel params */
46	pointer buffer;
47	int negativeZ, positiveZ; /* mappings for Z axis */
48	int negativeW, positiveW; /* mappings for W axis */
49	struct wsmouse_calibcoords coords; /* mirror of the kernel values */
50	/* Middle mouse button emulation */
51	struct {
52		BOOL enabled;
53		BOOL pending;     /* timer waiting? */
54		int buttonstate; /* phys. button state */
55		int state;       /* state machine (see emumb.c) */
56		Time expires;     /* time of expiry */
57		Time timeout;
58	} emulateMB;
59} WSDeviceRec, *WSDevicePtr;
60
61extern int wsmbEmuTimer(InputInfoPtr);
62extern BOOL wsmbEmuFilterEvent(InputInfoPtr, int, BOOL);
63extern void wsmbEmuWakeupHandler(pointer, int, pointer);
64extern void wsmbEmuBlockHandler(pointer, struct timeval **, pointer);
65extern void wsmbEmuPreInit(InputInfoPtr);
66extern void wsmbEmuOn(InputInfoPtr);
67extern void wsmbEmuFinalize(InputInfoPtr);
68extern void wsmbEmuEnable(InputInfoPtr, BOOL);
69extern void wsmbEmuInitProperty(DeviceIntPtr);
70