xref: /netbsd/sys/dev/sun/kbd_tables.h (revision bf9ec67e)
1 /*	$NetBSD: kbd_tables.h,v 1.4 1996/12/17 20:46:14 gwr Exp $	*/
2 
3 /*
4  * Copyright (c) 1996 Gordon W. Ross
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. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission.
17  * 4. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by Gordon Ross
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 /*
34  * Keyboard translation tables.  These tables contain
35  * "Key symbols" (or "keysyms", to use X terminology).
36  * The key symbol space is divided into "classes" where
37  * the high 8 bits determine the symbol class, and the
38  * low 8 bits are interpreted in a way specific to each
39  * class.  The simplest class is ASCII, which is defined
40  * as class zero in order to simplify table definition.
41  *
42  * For convenience in the driver, all keysyms that
43  * deserve autorepeat are below 0x8000.  The driver
44  * uses the following macro to determine if a keysym
45  * should NOT get autorepeat.
46  */
47 #define KEYSYM_NOREPEAT(sym) ((sym) & 0x8000)
48 
49 #define KEYSYM_CLASS(sym) ((sym) & 0xFF00)
50 #define KEYSYM_DATA(sym)  ((sym) & 0x00FF)
51 
52 /*
53  * The ACSII class.  Low 8 bits are the character.
54  */
55 #define KEYSYM_ASCII 0
56 
57 /*
58  * The "special" class.
59  * We don't expect to receive any of these often,
60  * except for KEYSYM_NOP.  All can be ignored,
61  * because HW_ERR, LAYOUT, RESET, are all handled
62  * at a lower layer, before the translation code.
63  */
64 #define KEYSYM_SPECIAL	0x8300
65 #define KEYSYM_NOP  	0x8300
66 #define KEYSYM_OOPS 	0x8301
67 #define KEYSYM_HOLE 	0x8302
68 #define KEYSYM_HW_ERR	0x8307	/* kbd sent 0x7e */
69 #define KEYSYM_LAYOUT	0x830e	/* kbd sent 0xfe */
70 #define KEYSYM_RESET	0x830f	/* kbd sent 0xff */
71 
72 
73 /*
74  * Floating accents class:  (not implemented)
75  * umlaut, circumflex, tilde, cedilla, acute, grave,...
76  */
77 #define	KEYSYM_ACCENT 0x0400
78 
79 /*
80  * The string entry class.
81  * The low 4 bits select one of the entries from
82  * the string table.  (see kbd_stringtab[])
83  * By default, the string table has ANSI movement
84  * sequences for the arrow keys.
85  */
86 #define	KEYSYM_STRING 0x0500
87 
88 /*
89  * Function keys (compatible with SunOS 4.1)
90  * L:left, R:right, F:func(top), N:numeric
91  */
92 #define	KEYSYM_FUNC   0x0600
93 #define	KEYSYM_FUNC_L(x) (KEYSYM_FUNC | ((x) - 1))
94 #define	KEYSYM_FUNC_R(x) (KEYSYM_FUNC | ((x) - 1 + 0x10))
95 #define	KEYSYM_FUNC_F(x) (KEYSYM_FUNC | ((x) - 1 + 0x20))
96 #define	KEYSYM_FUNC_N(x) (KEYSYM_FUNC | ((x) - 1 + 0x30))
97 
98 /*
99  * Modifier symbols, to set/clear/toggle a modifier
100  * The low 5 bits define the position of a modifier
101  * bit to be cleared, set, or inverted.  The meanings
102  * of the modifier bit positions are defined below.
103  */
104 #define KEYSYM_CLRMOD 0x9000
105 #define KEYSYM_SETMOD 0x9100
106 #define KEYSYM_INVMOD 0x9200
107 #define KEYSYM_ALL_UP 0x9300
108 
109 /*
110  * Modifier indices.
111  * (logical OR with {CLR,SET,TOG}MOD above)
112  */
113 #define	KBMOD_CTRL_L	0
114 #define	KBMOD_CTRL_R	1
115 #define	KBMOD_SHIFT_L	2
116 #define	KBMOD_SHIFT_R	3
117 #define	KBMOD_META_L	4
118 #define	KBMOD_META_R	5
119 #define KBMOD_ALT_L 	6
120 #define KBMOD_ALT_R 	7
121 /* Note 0-15 are cleared by ALL_UP */
122 #define KBMOD_CAPSLOCK  16
123 #define KBMOD_NUMLOCK	17
124 
125 #define	KBMOD_ALTGRAPH	KBMOD_ALT_R
126 
127 
128 #ifdef	_KERNEL
129 
130 #define KEYMAP_SIZE 128
131 
132 struct keyboard {
133 	u_short	*k_release; 	/* Key released */
134 	u_short	*k_control; 	/* Ctrl is down */
135 	u_short	*k_normal;  	/* No shifts */
136 	u_short	*k_shifted; 	/* Shift is down */
137 };
138 
139 extern char kbd_stringtab[16][10];
140 extern unsigned short kbd_numlock_map[64];
141 
142 extern struct keyboard * keyboards[];
143 extern int kbd_max_type;
144 #define	KBD_MIN_TYPE 2
145 
146 #endif	/* _KERNEL */
147