1 /* $OpenBSD: wsmoused.h,v 1.4 2002/02/15 02:18:39 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 extern char *pidfile; 59 60 #define debug(fmt,args...) \ 61 if (debug&&nodaemon) printf(fmt, ##args) 62 63 #define logerr(e, fmt, args...) \ 64 do { \ 65 unlink(pidfile); \ 66 if (background) { \ 67 syslog(LOG_ERR, fmt, ##args); \ 68 exit(e); \ 69 } else \ 70 errx(e, fmt, ##args); \ 71 } while (0) 72 73 #define logwarn(fmt, args...) \ 74 do { \ 75 if (background) \ 76 syslog(LOG_WARNING, fmt, ##args); \ 77 else \ 78 warnx(fmt, ##args); \ 79 } while (0) 80 81 /* Daemon flags */ 82 83 #define ChordMiddle 0x0001 /* avoid bug reporting middle button as down 84 when left and right are pressed */ 85 #define Emulate3Button 0x0002 /* option to emulate a third button */ 86 #define ClearDTR 0x0004 /* for mousesystems protocol (3 button mouse) */ 87 #define ClearRTS 0x0008 /* idem as above */ 88 #define NoPnP 0x0010 /* disable PnP for PnP mice */ 89 90 /* Devices corresponding to physical interfaces */ 91 92 #define WSMOUSE_DEV "/dev/wsmouse" /* can be /dev/wsmouse, /dev/wsmouse0, ...*/ 93 #define SERIAL_DEV "/dev/cua0" /* can be /dev/cua00, /dev/cua01, ... */ 94 95 #define IS_WSMOUSE_DEV(dev) (!(strncmp((dev), WSMOUSE_DEV,12))) 96 #define IS_SERIAL_DEV(dev) (!(strncmp((dev), SERIAL_DEV, 9))) 97 98 /* mouse structure : main structure */ 99 typedef struct mouse_s { 100 int flags; 101 char *portname; /* /dev/XXX */ 102 int proto; /* MOUSE_PROTO_XXX */ 103 int baudrate; 104 int old_baudrate; 105 unsigned char rate; /* report rate */ 106 unsigned char resolution; /* MOUSE_RES_XXX or a positive number */ 107 int zmap; /* MOUSE_{X|Y}AXIS or a button number */ 108 int wmode; /* wheel mode button number */ 109 int mfd; /* mouse file descriptor */ 110 int cfd; /* console file descriptor */ 111 long clickthreshold; /* double click speed in msec */ 112 } mouse_t ; 113 114 /* Mouse buttons */ 115 116 #define MOUSE_BUTTON1 0 /* left */ 117 #define MOUSE_BUTTON2 1 /* middle */ 118 #define MOUSE_BUTTON3 2 /* right */ 119 #define MOUSE_BUTTON4 3 120 #define MOUSE_BUTTON5 4 121 #define MOUSE_BUTTON6 5 122 #define MOUSE_BUTTON7 6 123 #define MOUSE_BUTTON8 7 124 #define MOUSE_MAXBUTTON 8 125 126