ws.h revision 5eb33880
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 negativeZ, positiveZ; /* mappings for Z axis */ 51 int negativeW, positiveW; /* mappings for W axis */ 52 struct wsmouse_calibcoords coords; /* mirror of the kernel values */ 53 /* Middle mouse button emulation */ 54 struct { 55 BOOL enabled; 56 BOOL pending; /* timer waiting? */ 57 int buttonstate; /* phys. button state */ 58 int state; /* state machine (see emumb.c) */ 59 Time expires; /* time of expiry */ 60 Time timeout; 61 } emulateMB; 62 ValuatorMask *scroll_mask; 63} WSDeviceRec, *WSDevicePtr; 64 65extern int wsmbEmuTimer(InputInfoPtr); 66extern BOOL wsmbEmuFilterEvent(InputInfoPtr, int, BOOL); 67/* XXX compat-api.h */ 68#if ABI_VIDEODRV_VERSION < SET_ABI_VERSION(23, 0) 69extern void wsmbEmuWakeupHandler(pointer, int, pointer); 70extern void wsmbEmuBlockHandler(pointer, struct timeval **, pointer); 71#else 72extern void wsmbEmuWakeupHandler(pointer, int); 73extern void wsmbEmuBlockHandler(pointer, pointer); 74#endif 75extern void wsmbEmuPreInit(InputInfoPtr); 76extern void wsmbEmuOn(InputInfoPtr); 77extern void wsmbEmuFinalize(InputInfoPtr); 78extern void wsmbEmuEnable(InputInfoPtr, BOOL); 79extern void wsmbEmuInitProperty(DeviceIntPtr); 80