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