1 /* $NetBSD: adbsys.h,v 1.6 1997/06/16 06:36:28 scottr Exp $ */ 2 3 /*- 4 * Copyright (C) 1993, 1994 Allen K. Briggs, Chris P. Caputo, 5 * Michael L. Finch, Bradley A. Grantham, and 6 * Lawrence A. Kesteloot 7 * All rights reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 3. All advertising materials mentioning features or use of this software 18 * must display the following acknowledgement: 19 * This product includes software developed by the Alice Group. 20 * 4. The names of the Alice Group or any of its members may not be used 21 * to endorse or promote products derived from this software without 22 * specific prior written permission. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR 25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, 28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 36 #ifndef _ADBSYS_MACHINE_ 37 #define _ADBSYS_MACHINE_ 38 39 #include <sys/time.h> /* timeval stuff */ 40 #include <sys/ioctl.h> /* ioctls */ 41 42 43 /* Handy visual constants */ 44 #define ADB_MAX_HANDLERS 256 45 #define ADB_MAX_DEVS 16 46 47 48 /* Different ADB system types */ 49 enum adb_system_e { 50 MacIIADB, 51 MacIIsiADB, 52 MacPBADB}; 53 extern enum adb_system_e adb_system_type; 54 55 56 /* an ADB event */ 57 typedef struct adb_event_s { 58 int addr; /* device address */ 59 int hand_id; /* handler id */ 60 int def_addr; /* default address */ 61 int byte_count; /* number of bytes */ 62 unsigned char bytes[8]; /* bytes from register 0 */ 63 struct timeval timestamp; /* time event was acquired */ 64 union { 65 struct adb_keydata_s{ 66 int key; /* ADB key code */ 67 } k; 68 struct adb_mousedata_s{ 69 int dx; /* mouse delta x */ 70 int dy; /* mouse delta y */ 71 int buttons; /* buttons (down << (buttonnum)) */ 72 } m; 73 } u; /* courtesy interpretation */ 74 } adb_event_t; 75 76 77 /* a device on the ADB */ 78 typedef struct adb_dev_s{ 79 int addr; /* current address */ 80 int default_addr; /* startup address */ 81 int handler_id; /* handler ID */ 82 } adb_dev_t; 83 84 85 /* Interesting default addresses */ 86 #define ADBADDR_MAP 2 87 #define ADBADDR_REL 3 88 #define ADBADDR_ABS 4 89 #define ADBADDR_KBD ADBADDR_MAP 90 #define ADBADDR_MS ADBADDR_REL 91 #define ADBADDR_TABLET ADBADDR_ABS 92 93 94 /* Interesting handler IDs */ 95 #define ADB_STDKBD 1 96 #define ADB_EXTKBD 2 97 #define ADB_PBKBD 12 98 #define ADBMS_100DPI 1 99 #define ADBMS_200DPI 2 100 #define ADBMS_MSA3 3 /* Mouse Systems A3 Mouse */ 101 #define ADBMS_EXTENDED 4 102 #define ADBMS_USPEED 47 /* MicroSpeed mouse */ 103 104 105 /* Get device info from ADB system */ 106 typedef struct adb_devinfo_s{ 107 adb_dev_t dev[ADB_MAX_DEVS]; 108 /* [addr].addr == -1 if none */ 109 } adb_devinfo_t; 110 #define ADBIOC_DEVSINFO _IOR('A', 128, adb_devinfo_t) 111 112 113 /* Event auto-repeat */ 114 typedef struct adb_rptinfo_s{ 115 int delay_ticks; /* ticks before repeat */ 116 int interval_ticks; /* ticks between repeats */ 117 } adb_rptinfo_t; 118 #define ADBIOC_GETREPEAT _IOR('A', 130, adb_rptinfo_t) 119 #define ADBIOC_SETREPEAT _IOW('A', 131, adb_rptinfo_t) 120 121 122 /* Reset and reinitialize */ 123 #define ADBIOC_RESET _IO('A', 132) 124 125 126 typedef struct adb_listencmd_s{ 127 int address; /* device address */ 128 int reg; /* register to which to send bytes */ 129 int bytecnt; /* number of bytes */ 130 u_char bytes[8]; /* bytes */ 131 } adb_listencmd_t; 132 #define ADBIOC_LISTENCMD _IOW('A', 133, adb_listencmd_t) 133 134 void adb_init __P((void)); 135 136 #endif /* _ADBSYS_MACHINE_ */ 137