xref: /openbsd/usr.sbin/wsmoused/wsmoused.h (revision 5af055cd)
1 /* $OpenBSD: wsmoused.h,v 1.12 2015/10/26 09:58:18 deraadt Exp $ */
2 
3 /*
4  * Copyright (c) 2001 Jean-Baptiste Marchand, Julien Montagne and Jerome Verdon
5  *
6  * Copyright (c) 1998 by Kazutaka Yokota
7  *
8  * Copyright (c) 1995 Michael Smith
9  *
10  * Copyright (c) 1993 by David Dawes <dawes@xfree86.org>
11  *
12  * Copyright (c) 1990,91 by Thomas Roell, Dinkelscherben, Germany.
13  *
14  * All rights reserved.
15  *
16  * Most of this code was taken from the FreeBSD moused daemon, written by
17  * Michael Smith. The FreeBSD moused daemon already contained code from the
18  * Xfree Project, written by David Dawes and Thomas Roell and Kazutaka Yokota.
19  *
20  * Adaptation to OpenBSD was done by Jean-Baptiste Marchand, Julien Montagne
21  * and Jerome Verdon.
22  *
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
26  * 1. Redistributions of source code must retain the above copyright
27  *    notice, this list of conditions and the following disclaimer.
28  * 2. Redistributions in binary form must reproduce the above copyright
29  *    notice, this list of conditions and the following disclaimer in the
30  *    documentation and/or other materials provided with the distribution.
31  * 3. All advertising materials mentioning features or use of this software
32  *    must display the following acknowledgement:
33  *	This product includes software developed by
34  *      David Dawes, Jean-Baptiste Marchand, Julien Montagne, Thomas Roell,
35  *      Michael Smith, Jerome Verdon and Kazutaka Yokota.
36  * 4. The name authors may not be used to endorse or promote products
37  *    derived from this software without specific prior written permission.
38  *
39  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
40  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
41  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
42  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
45  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
46  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
47  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
48  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49  *
50  *
51  */
52 
53 #define FALSE 0
54 #define TRUE 1
55 
56 /* Logging macros */
57 
58 #define debug(fmt, ...) \
59 	if (debug&&nodaemon) printf(fmt, __VA_ARGS__)
60 
61 #define logerr(e, ...) 				\
62 	do {							\
63 		if (background) {				\
64 			syslog(LOG_ERR, __VA_ARGS__);		\
65 			exit(e);				\
66 		} else						\
67 			errx(e, __VA_ARGS__);			\
68 	} while (0)
69 
70 #define logwarn(...)						\
71 	do {							\
72 		if (background)					\
73 			syslog(LOG_WARNING, __VA_ARGS__);	\
74 		else						\
75 			warnx(__VA_ARGS__);			\
76 	} while (0)
77 
78 /* Daemon flags */
79 
80 #define	ChordMiddle	0x0001 /* avoid bug reporting middle button as down
81 				  when left and right are pressed */
82 #define Emulate3Button	0x0002 /* option to emulate a third button */
83 #define ClearDTR	0x0004 /* for mousesystems protocol (3 button mouse) */
84 #define ClearRTS	0x0008 /* idem as above */
85 #define NoPnP		0x0010 /* disable PnP for PnP mice */
86 
87 /* Devices corresponding to physical interfaces */
88 
89 #define WSMOUSE_DEV "/dev/wsmouse" /* can be /dev/wsmouse, /dev/wsmouse0, ...*/
90 
91 /* mouse structure : main structure */
92 typedef struct mouse_s {
93 	int flags;
94 	char *portname;		/* mouse device */
95 	char *ttyname;		/* wsdisplay control tty device */
96 	int proto;		/* MOUSE_PROTO_XXX */
97 	unsigned char rate;	/* report rate */
98 	unsigned int resolution;	/* MOUSE_RES_XXX or a positive number */
99 	int mfd;		/* mouse file descriptor */
100 	int cfd;		/* console file descriptor */
101 	long clickthreshold;	/* double click speed in msec */
102 } mouse_t;
103 
104 /* Mouse buttons */
105 
106 #define MOUSE_BUTTON1	0	/* left */
107 #define MOUSE_BUTTON2	1	/* middle */
108 #define MOUSE_BUTTON3	2	/* right */
109 #define MOUSE_BUTTON4	3
110 #define MOUSE_BUTTON5	4
111 #define MOUSE_BUTTON6	5
112 #define MOUSE_BUTTON7	6
113 #define MOUSE_BUTTON8	7
114 #define MOUSE_BUTTON9	8
115 #define MOUSE_BUTTON10	9
116 #define MOUSE_BUTTON11	10
117 #define MOUSE_BUTTON12	11
118 #define MOUSE_BUTTON13	12
119 #define MOUSE_BUTTON14	13
120 #define MOUSE_BUTTON15	14
121 #define MOUSE_BUTTON16	15
122 #define MOUSE_MAXBUTTON	16
123