1/*	$NetBSD: kbdmap.h,v 1.4.62.3 2004/09/21 13:13:59 skrll Exp $	*/
2
3/*
4 * Copyright (c) 1993 Markus Wild
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 *    must display the following acknowledgement:
17 *      This product includes software developed by Markus Wild.
18 * 4. The name of the author may not be used to endorse or promote products
19 *    derived from this software without specific prior written permission
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef _MACHINE_KBDMAP_H_
34#define _MACHINE_KBDMAP_H_
35
36#define NUL	0
37#define SOH	1
38#define STX	2
39#define ETX	3
40#define EOT	4
41#define ENQ	5
42#define ACK	6
43#define	BEL	7
44#define BS	8
45#define HT	9
46#define LF	10
47#define VT	11
48#define FF	12
49#define CR	13
50#define SO	14
51#define SI	15
52#define DLE	16
53#define DC1	17
54#define DC2	18
55#define DC3	19
56#define DC4	20
57#define NAK	21
58#define SYN	22
59#define ETB	23
60#define CAN	24
61#define EM	25
62#define SUB	26
63#define ESC	27
64#define FS	28
65#define GS	29
66#define RS	30
67#define US	31
68#define	DEL	127
69#define IND	132
70#define NEL	133
71#define SSA	134
72#define ESA	135
73#define HTS	136
74#define HTJ	137
75#define VTS	138
76#define PLD	139
77#define PLU	140
78#define RI	141
79#define SS2	142
80#define SS3	143
81#define DCS	144
82#define PU1	145
83#define PU2	146
84#define STS	147
85#define CCH	148
86#define MW	149
87#define SPA	150
88#define EPA	151
89#define CSI	155
90#define ST	156
91#define OSC	157
92#define PM	158
93#define APC	159
94
95
96/*
97 * A total of 0x80 scancode are defined for the atari keyboard.
98 */
99#define KBD_NUM_KEYS	0x80
100
101/* size of string table */
102#define KBD_STRTAB_SIZE	255
103
104/* for dead keys, index into acctable */
105/* FIXME: What the hell are dead keys?? */
106#define	KBD_ACC_GRAVE	0
107#define KBD_ACC_ACUTE	1
108#define KBD_ACC_CIRC	2
109#define KBD_ACC_TILDE	3
110#define KBD_ACC_DIER	4
111#define KBD_NUM_ACC		5
112
113
114struct key {
115	unsigned char	mode;	/* see possible values below */
116	unsigned char	code;
117};
118
119#define KBD_MODE_STRING	(0x01)	/* code is index into strings[] */
120#define KBD_MODE_DEAD	(0x02)	/* acc-index in upper nibble, code = plain acc */
121#define KBD_MODE_CAPS	(0x04)	/* key is capsable. Only in non-shifted maps  */
122#define KBD_MODE_KPAD	(0x08)	/* key is on keypad */
123#define KBD_MODE_GRAVE	(KBD_ACC_GRAVE << 4)
124#define KBD_MODE_ACUTE	(KBD_ACC_ACUTE << 4)
125#define KBD_MODE_CIRC	(KBD_ACC_CIRC  << 4)
126#define KBD_MODE_TILDE	(KBD_ACC_TILDE << 4)
127#define KBD_MODE_DIER	(KBD_ACC_DIER  << 4)
128#define KBD_MODE_ACCENT(m) ((m) >> 4)	/* get accent from mode */
129#define KBD_MODE_ACCMASK  (0xf0)
130
131#define	KBD_SCANCODE(code)	(code & 0x7f)
132#define	KBD_RELEASED(code)	(code & 0x80 ? 1 : 0)
133#define	KBD_IS_KEY(code)	((u_char)(code) < 0xf6)
134
135struct kbdmap {
136	struct key	keys[KBD_NUM_KEYS],
137			shift_keys[KBD_NUM_KEYS],
138			alt_keys[KBD_NUM_KEYS],
139			alt_shift_keys[KBD_NUM_KEYS];
140	unsigned char	strings[KBD_STRTAB_SIZE];
141};
142
143
144#ifdef _KERNEL
145/* XXX: ITE interface */
146extern struct kbdmap	ascii_kbdmap;
147extern unsigned char	acctable[KBD_NUM_ACC][64];
148#endif
149
150#endif /* _MACHINE_KBDMAP_H_ */
151