1 1.9 dsl /* $NetBSD: adbsys.h,v 1.9 2009/03/14 14:46:02 dsl Exp $ */ 2 1.1 tsubai 3 1.1 tsubai /*- 4 1.1 tsubai * Copyright (C) 1993, 1994 Allen K. Briggs, Chris P. Caputo, 5 1.1 tsubai * Michael L. Finch, Bradley A. Grantham, and 6 1.1 tsubai * Lawrence A. Kesteloot 7 1.1 tsubai * All rights reserved. 8 1.1 tsubai * 9 1.1 tsubai * Redistribution and use in source and binary forms, with or without 10 1.1 tsubai * modification, are permitted provided that the following conditions 11 1.1 tsubai * are met: 12 1.1 tsubai * 1. Redistributions of source code must retain the above copyright 13 1.1 tsubai * notice, this list of conditions and the following disclaimer. 14 1.1 tsubai * 2. Redistributions in binary form must reproduce the above copyright 15 1.1 tsubai * notice, this list of conditions and the following disclaimer in the 16 1.1 tsubai * documentation and/or other materials provided with the distribution. 17 1.1 tsubai * 3. All advertising materials mentioning features or use of this software 18 1.1 tsubai * must display the following acknowledgement: 19 1.1 tsubai * This product includes software developed by the Alice Group. 20 1.1 tsubai * 4. The names of the Alice Group or any of its members may not be used 21 1.1 tsubai * to endorse or promote products derived from this software without 22 1.1 tsubai * specific prior written permission. 23 1.1 tsubai * 24 1.1 tsubai * THIS SOFTWARE IS PROVIDED BY THE ALICE GROUP ``AS IS'' AND ANY EXPRESS OR 25 1.1 tsubai * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 26 1.1 tsubai * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 27 1.1 tsubai * IN NO EVENT SHALL THE ALICE GROUP BE LIABLE FOR ANY DIRECT, INDIRECT, 28 1.1 tsubai * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 29 1.1 tsubai * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 1.1 tsubai * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 1.1 tsubai * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 1.1 tsubai * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 1.1 tsubai * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 1.1 tsubai */ 35 1.1 tsubai 36 1.1 tsubai #ifndef _ADBSYS_MACHINE_ 37 1.1 tsubai #define _ADBSYS_MACHINE_ 38 1.1 tsubai 39 1.1 tsubai #include <sys/time.h> /* timeval stuff */ 40 1.1 tsubai #include <sys/ioctl.h> /* ioctls */ 41 1.1 tsubai 42 1.1 tsubai 43 1.1 tsubai /* Handy visual constants */ 44 1.1 tsubai #define ADB_MAX_HANDLERS 256 45 1.1 tsubai #define ADB_MAX_DEVS 16 46 1.1 tsubai 47 1.1 tsubai 48 1.1 tsubai /* Different ADB system types */ 49 1.1 tsubai enum adb_system_e { 50 1.1 tsubai MacIIADB, 51 1.1 tsubai MacIIsiADB, 52 1.1 tsubai MacPBADB 53 1.1 tsubai }; 54 1.1 tsubai extern enum adb_system_e adb_system_type; 55 1.1 tsubai 56 1.1 tsubai 57 1.1 tsubai /* an ADB event */ 58 1.1 tsubai typedef struct adb_event_s { 59 1.1 tsubai int addr; /* device address */ 60 1.1 tsubai int hand_id; /* handler id */ 61 1.1 tsubai int def_addr; /* default address */ 62 1.1 tsubai int byte_count; /* number of bytes */ 63 1.1 tsubai unsigned char bytes[8]; /* bytes from register 0 */ 64 1.1 tsubai struct timeval timestamp; /* time event was acquired */ 65 1.1 tsubai union { 66 1.1 tsubai struct adb_keydata_s{ 67 1.1 tsubai int key; /* ADB key code */ 68 1.1 tsubai } k; 69 1.1 tsubai struct adb_mousedata_s{ 70 1.1 tsubai int dx; /* mouse delta x */ 71 1.1 tsubai int dy; /* mouse delta y */ 72 1.1 tsubai int buttons; /* buttons (down << (buttonnum)) */ 73 1.1 tsubai } m; 74 1.1 tsubai } u; /* courtesy interpretation */ 75 1.1 tsubai } adb_event_t; 76 1.1 tsubai 77 1.1 tsubai 78 1.1 tsubai /* a device on the ADB */ 79 1.1 tsubai typedef struct adb_dev_s{ 80 1.1 tsubai int addr; /* current address */ 81 1.1 tsubai int default_addr; /* startup address */ 82 1.1 tsubai int handler_id; /* handler ID */ 83 1.1 tsubai } adb_dev_t; 84 1.1 tsubai 85 1.1 tsubai 86 1.1 tsubai /* Interesting default addresses */ 87 1.1 tsubai #define ADBADDR_SECURE 1 /* Security dongles */ 88 1.1 tsubai #define ADBADDR_MAP 2 /* Mapped devices (keyboards/pads) */ 89 1.1 tsubai #define ADBADDR_REL 3 /* Relative positioning devices 90 1.1 tsubai (mice, trackballs/pads) */ 91 1.1 tsubai #define ADBADDR_ABS 4 /* Absolute positioning devices 92 1.1 tsubai (graphics tablets) */ 93 1.1 tsubai #define ADBADDR_DATATX 5 94 1.1 tsubai #define ADBADDR_RSRVD 6 /* Reserved by Apple */ 95 1.1 tsubai #define ADBADDR_MISC 7 /* Miscellaneous appliances */ 96 1.1 tsubai #define ADBADDR_DONGLE ADBADDR_SECURE 97 1.1 tsubai #define ADBADDR_KBD ADBADDR_MAP 98 1.1 tsubai #define ADBADDR_MS ADBADDR_REL 99 1.1 tsubai #define ADBADDR_TABLET ADBADDR_ABS 100 1.1 tsubai #define ADBADDR_MODEM ADBADDR_DATATX 101 1.1 tsubai 102 1.7 itojun #define ADBADDR_APM 0xac0ff /* A faux-addr for the APM driver to 103 1.7 itojun latch onto */ 104 1.1 tsubai 105 1.1 tsubai /* Interesting keyboard handler IDs */ 106 1.1 tsubai #define ADB_STDKBD 1 107 1.1 tsubai #define ADB_EXTKBD 2 108 1.1 tsubai #define ADB_ISOKBD 4 109 1.1 tsubai #define ADB_EXTISOKBD 5 110 1.1 tsubai #define ADB_KBDII 8 111 1.1 tsubai #define ADB_ISOKBDII 9 112 1.1 tsubai #define ADB_PBKBD 12 113 1.1 tsubai #define ADB_PBISOKBD 13 114 1.1 tsubai #define ADB_ADJKPD 14 115 1.1 tsubai #define ADB_ADJKBD 16 116 1.1 tsubai #define ADB_ADJISOKBD 17 117 1.1 tsubai #define ADB_ADJJAPKBD 18 118 1.1 tsubai #define ADB_PBEXTISOKBD 20 119 1.1 tsubai #define ADB_PBEXTJAPKBD 21 120 1.2 tsubai #define ADB_JPKBDII 22 121 1.1 tsubai #define ADB_PBEXTKBD 24 122 1.1 tsubai #define ADB_DESIGNKBD 27 /* XXX Needs to be verified XXX */ 123 1.2 tsubai #define ADB_PBJPKBD 30 124 1.6 tsubai #define ADB_PBG3KBD 195 125 1.8 macallan #define ADB_IBOOKKBD 196 /* iBook, probably others? */ 126 1.3 tsubai #define ADB_PBG3JPKBD 201 127 1.1 tsubai 128 1.1 tsubai /* Interesting mouse handler IDs */ 129 1.1 tsubai #define ADBMS_100DPI 1 130 1.1 tsubai #define ADBMS_200DPI 2 131 1.1 tsubai #define ADBMS_MSA3 3 /* Mouse Systems A3 Mouse */ 132 1.1 tsubai #define ADBMS_EXTENDED 4 /* Extended mouse protocol */ 133 1.2 tsubai #define ADBMS_USPEED 0x2f /* MicroSpeed mouse */ 134 1.3 tsubai #define ADBMS_UCONTOUR 0x66 /* Contour mouse */ 135 1.4 tsubai #define ADBMS_TURBO 50 /* Kensington Turbo Mouse */ 136 1.1 tsubai 137 1.1 tsubai /* Interesting tablet handler ID */ 138 1.1 tsubai #define ADB_ARTPAD 58 /* WACOM ArtPad II tablet */ 139 1.1 tsubai 140 1.1 tsubai /* Interesting miscellaneous handler ID */ 141 1.1 tsubai #define ADB_POWERKEY 34 /* Sophisticated Circuits PowerKey */ 142 1.1 tsubai /* (intelligent power tap) */ 143 1.1 tsubai 144 1.1 tsubai /* Get device info from ADB system */ 145 1.1 tsubai typedef struct adb_devinfo_s{ 146 1.1 tsubai adb_dev_t dev[ADB_MAX_DEVS]; 147 1.3 tsubai /* [addr].addr == -1 if none */ 148 1.1 tsubai } adb_devinfo_t; 149 1.1 tsubai #define ADBIOCDEVSINFO _IOR('A', 128, adb_devinfo_t) 150 1.1 tsubai 151 1.1 tsubai 152 1.1 tsubai /* Event auto-repeat */ 153 1.1 tsubai typedef struct adb_rptinfo_s{ 154 1.1 tsubai int delay_ticks; /* ticks before repeat */ 155 1.1 tsubai int interval_ticks; /* ticks between repeats */ 156 1.1 tsubai } adb_rptinfo_t; 157 1.1 tsubai #define ADBIOCGETREPEAT _IOR('A', 130, adb_rptinfo_t) 158 1.1 tsubai #define ADBIOCSETREPEAT _IOW('A', 131, adb_rptinfo_t) 159 1.1 tsubai 160 1.1 tsubai 161 1.1 tsubai /* Reset and reinitialize */ 162 1.1 tsubai #define ADBIOCRESET _IO('A', 132) 163 1.1 tsubai 164 1.1 tsubai 165 1.1 tsubai typedef struct adb_listencmd_s{ 166 1.1 tsubai int address; /* device address */ 167 1.1 tsubai int reg; /* register to which to send bytes */ 168 1.1 tsubai int bytecnt; /* number of bytes */ 169 1.1 tsubai u_char bytes[8]; /* bytes */ 170 1.1 tsubai } adb_listencmd_t; 171 1.1 tsubai #define ADBIOCLISTENCMD _IOW('A', 133, adb_listencmd_t) 172 1.1 tsubai 173 1.9 dsl void adb_init(void); 174 1.1 tsubai 175 1.1 tsubai #endif /* _ADBSYS_MACHINE_ */ 176