ws.h revision e0490348
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 4			/* X and Y, horizontal and vertical scrolling */
31#define HSCROLL_AXIS	2
32#define VSCROLL_AXIS	3
33
34#define NBUTTONS 32		/* max theoretical buttons */
35#define DFLTBUTTONS 3		/* default number of buttons */
36#define NUMEVENTS 16		/* max # of ws events to read at once */
37
38typedef struct WSDevice {
39	const char *devName;	/* device name */
40	int type;		/* ws device type */
41	unsigned int buttons;	/* # of buttons */
42	unsigned int lastButtons; /* last state of buttons */
43	int min_x, max_x, min_y, max_y; /* coord space */
44	int swap_axes;
45	int raw;
46	int inv_x, inv_y;
47	int screen_no;
48	int num, den, threshold; /* relative accel params */
49	pointer buffer;
50	int autoCalibrate;
51	int translateAbs;
52	int lastScreenWidth, lastScreenHeight;
53	int negativeZ, positiveZ; /* mappings for Z axis */
54	int negativeW, positiveW; /* mappings for W axis */
55	struct wsmouse_calibcoords coords; /* mirror of the kernel values */
56	/* Middle mouse button emulation */
57	struct {
58		BOOL enabled;
59		BOOL pending;     /* timer waiting? */
60		int buttonstate; /* phys. button state */
61		int state;       /* state machine (see emumb.c) */
62		Time expires;     /* time of expiry */
63		Time timeout;
64	} emulateMB;
65	ValuatorMask *scroll_mask;
66} WSDeviceRec, *WSDevicePtr;
67
68extern int wsmbEmuTimer(InputInfoPtr);
69extern BOOL wsmbEmuFilterEvent(InputInfoPtr, int, BOOL);
70/* XXX compat-api.h */
71#if ABI_VIDEODRV_VERSION < SET_ABI_VERSION(23, 0)
72extern void wsmbEmuWakeupHandler(pointer, int, pointer);
73extern void wsmbEmuBlockHandler(pointer, struct timeval **, pointer);
74#else
75extern void wsmbEmuWakeupHandler(pointer, int);
76extern void wsmbEmuBlockHandler(pointer, pointer);
77#endif
78extern void wsmbEmuPreInit(InputInfoPtr);
79extern void wsmbEmuOn(InputInfoPtr);
80extern void wsmbEmuFinalize(InputInfoPtr);
81extern void wsmbEmuEnable(InputInfoPtr, BOOL);
82extern void wsmbEmuInitProperty(DeviceIntPtr);
83