Home | History | Annotate | Line # | Download | only in include
      1 /*	$NetBSD: adbsys.h,v 1.9 2009/03/14 14:46:02 dsl 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 };
     54 extern enum adb_system_e adb_system_type;
     55 
     56 
     57 /* an ADB event */
     58 typedef struct adb_event_s {
     59 	int addr;			/* device address */
     60 	int hand_id;			/* handler id */
     61 	int def_addr;			/* default address */
     62 	int byte_count;			/* number of bytes */
     63 	unsigned char bytes[8];		/* bytes from register 0 */
     64 	struct timeval timestamp;	/* time event was acquired */
     65 	union {
     66 		struct adb_keydata_s{
     67 			int key;	/* ADB key code */
     68 		} k;
     69 		struct adb_mousedata_s{
     70 			int dx;		/* mouse delta x */
     71 			int dy;		/* mouse delta y */
     72 			int buttons;	/* buttons (down << (buttonnum)) */
     73 		} m;
     74 	} u;				/* courtesy interpretation */
     75 } adb_event_t;
     76 
     77 
     78 /* a device on the ADB */
     79 typedef struct adb_dev_s{
     80 	int		addr;		/* current address */
     81 	int		default_addr;	/* startup address */
     82 	int		handler_id;	/* handler ID */
     83 } adb_dev_t;
     84 
     85 
     86 	/* Interesting default addresses */
     87 #define	ADBADDR_SECURE	1		/* Security dongles */
     88 #define ADBADDR_MAP	2		/* Mapped devices (keyboards/pads) */
     89 #define ADBADDR_REL	3		/* Relative positioning devices
     90 					   (mice, trackballs/pads) */
     91 #define ADBADDR_ABS	4		/* Absolute positioning devices
     92 					   (graphics tablets) */
     93 #define ADBADDR_DATATX	5
     94 #define ADBADDR_RSRVD	6		/* Reserved by Apple */
     95 #define ADBADDR_MISC	7		/* Miscellaneous appliances */
     96 #define ADBADDR_DONGLE	ADBADDR_SECURE
     97 #define ADBADDR_KBD	ADBADDR_MAP
     98 #define ADBADDR_MS	ADBADDR_REL
     99 #define ADBADDR_TABLET	ADBADDR_ABS
    100 #define ADBADDR_MODEM	ADBADDR_DATATX
    101 
    102 #define ADBADDR_APM	0xac0ff		/* A faux-addr for the APM driver to
    103 					   latch onto */
    104 
    105 	/* Interesting keyboard handler IDs */
    106 #define ADB_STDKBD	1
    107 #define ADB_EXTKBD	2
    108 #define ADB_ISOKBD	4
    109 #define ADB_EXTISOKBD	5
    110 #define ADB_KBDII	8
    111 #define ADB_ISOKBDII	9
    112 #define ADB_PBKBD	12
    113 #define ADB_PBISOKBD	13
    114 #define ADB_ADJKPD	14
    115 #define ADB_ADJKBD	16
    116 #define ADB_ADJISOKBD	17
    117 #define ADB_ADJJAPKBD	18
    118 #define ADB_PBEXTISOKBD	20
    119 #define ADB_PBEXTJAPKBD	21
    120 #define ADB_JPKBDII	22
    121 #define ADB_PBEXTKBD	24
    122 #define ADB_DESIGNKBD	27	/* XXX Needs to be verified XXX */
    123 #define ADB_PBJPKBD	30
    124 #define ADB_PBG3KBD	195
    125 #define ADB_IBOOKKBD	196	/* iBook, probably others? */
    126 #define ADB_PBG3JPKBD	201
    127 
    128 	/* Interesting mouse handler IDs */
    129 #define ADBMS_100DPI	1
    130 #define ADBMS_200DPI	2
    131 #define ADBMS_MSA3	3	/* Mouse Systems A3 Mouse */
    132 #define ADBMS_EXTENDED	4	/* Extended mouse protocol */
    133 #define ADBMS_USPEED	0x2f	/* MicroSpeed mouse */
    134 #define ADBMS_UCONTOUR	0x66	/* Contour mouse */
    135 #define ADBMS_TURBO	50	/* Kensington Turbo Mouse */
    136 
    137 	/* Interesting tablet handler ID */
    138 #define ADB_ARTPAD	58	/* WACOM ArtPad II tablet */
    139 
    140 	/* Interesting miscellaneous handler ID */
    141 #define ADB_POWERKEY	34	/* Sophisticated Circuits PowerKey */
    142 				/* (intelligent power tap) */
    143 
    144 	/* Get device info from ADB system */
    145 typedef struct adb_devinfo_s{
    146 	adb_dev_t	dev[ADB_MAX_DEVS];
    147 		/* [addr].addr == -1 if none */
    148 } adb_devinfo_t;
    149 #define ADBIOCDEVSINFO		_IOR('A', 128, adb_devinfo_t)
    150 
    151 
    152 	/* Event auto-repeat */
    153 typedef struct adb_rptinfo_s{
    154 	int delay_ticks;	/* ticks before repeat */
    155 	int interval_ticks;	/* ticks between repeats */
    156 } adb_rptinfo_t;
    157 #define ADBIOCGETREPEAT		_IOR('A', 130, adb_rptinfo_t)
    158 #define ADBIOCSETREPEAT		_IOW('A', 131, adb_rptinfo_t)
    159 
    160 
    161 	/* Reset and reinitialize */
    162 #define ADBIOCRESET		_IO('A', 132)
    163 
    164 
    165 typedef struct adb_listencmd_s{
    166 	int address;		/* device address */
    167 	int reg;		/* register to which to send bytes */
    168 	int bytecnt;		/* number of bytes */
    169 	u_char bytes[8];	/* bytes */
    170 } adb_listencmd_t;
    171 #define ADBIOCLISTENCMD		_IOW('A', 133, adb_listencmd_t)
    172 
    173 void	adb_init(void);
    174 
    175 #endif /* _ADBSYS_MACHINE_ */
    176