1 /* $NetBSD: kbd_tables.h,v 1.5 2009/10/21 23:12:10 snj 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 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 /* 29 * Keyboard translation tables. These tables contain 30 * "Key symbols" (or "keysyms", to use X terminology). 31 * The key symbol space is divided into "classes" where 32 * the high 8 bits determine the symbol class, and the 33 * low 8 bits are interpreted in a way specific to each 34 * class. The simplest class is ASCII, which is defined 35 * as class zero in order to simplify table definition. 36 * 37 * For convenience in the driver, all keysyms that 38 * deserve autorepeat are below 0x8000. The driver 39 * uses the following macro to determine if a keysym 40 * should NOT get autorepeat. 41 */ 42 #define KEYSYM_NOREPEAT(sym) ((sym) & 0x8000) 43 44 #define KEYSYM_CLASS(sym) ((sym) & 0xFF00) 45 #define KEYSYM_DATA(sym) ((sym) & 0x00FF) 46 47 /* 48 * The ACSII class. Low 8 bits are the character. 49 */ 50 #define KEYSYM_ASCII 0 51 52 /* 53 * The "special" class. 54 * We don't expect to receive any of these often, 55 * except for KEYSYM_NOP. All can be ignored, 56 * because HW_ERR, LAYOUT, RESET, are all handled 57 * at a lower layer, before the translation code. 58 */ 59 #define KEYSYM_SPECIAL 0x8300 60 #define KEYSYM_NOP 0x8300 61 #define KEYSYM_OOPS 0x8301 62 #define KEYSYM_HOLE 0x8302 63 #define KEYSYM_HW_ERR 0x8307 /* kbd sent 0x7e */ 64 #define KEYSYM_LAYOUT 0x830e /* kbd sent 0xfe */ 65 #define KEYSYM_RESET 0x830f /* kbd sent 0xff */ 66 67 68 /* 69 * Floating accents class: (not implemented) 70 * umlaut, circumflex, tilde, cedilla, acute, grave,... 71 */ 72 #define KEYSYM_ACCENT 0x0400 73 74 /* 75 * The string entry class. 76 * The low 4 bits select one of the entries from 77 * the string table. (see kbd_stringtab[]) 78 * By default, the string table has ANSI movement 79 * sequences for the arrow keys. 80 */ 81 #define KEYSYM_STRING 0x0500 82 83 /* 84 * Function keys (compatible with SunOS 4.1) 85 * L:left, R:right, F:func(top), N:numeric 86 */ 87 #define KEYSYM_FUNC 0x0600 88 #define KEYSYM_FUNC_L(x) (KEYSYM_FUNC | ((x) - 1)) 89 #define KEYSYM_FUNC_R(x) (KEYSYM_FUNC | ((x) - 1 + 0x10)) 90 #define KEYSYM_FUNC_F(x) (KEYSYM_FUNC | ((x) - 1 + 0x20)) 91 #define KEYSYM_FUNC_N(x) (KEYSYM_FUNC | ((x) - 1 + 0x30)) 92 93 /* 94 * Modifier symbols, to set/clear/toggle a modifier 95 * The low 5 bits define the position of a modifier 96 * bit to be cleared, set, or inverted. The meanings 97 * of the modifier bit positions are defined below. 98 */ 99 #define KEYSYM_CLRMOD 0x9000 100 #define KEYSYM_SETMOD 0x9100 101 #define KEYSYM_INVMOD 0x9200 102 #define KEYSYM_ALL_UP 0x9300 103 104 /* 105 * Modifier indices. 106 * (logical OR with {CLR,SET,TOG}MOD above) 107 */ 108 #define KBMOD_CTRL_L 0 109 #define KBMOD_CTRL_R 1 110 #define KBMOD_SHIFT_L 2 111 #define KBMOD_SHIFT_R 3 112 #define KBMOD_META_L 4 113 #define KBMOD_META_R 5 114 #define KBMOD_ALT_L 6 115 #define KBMOD_ALT_R 7 116 /* Note 0-15 are cleared by ALL_UP */ 117 #define KBMOD_CAPSLOCK 16 118 #define KBMOD_NUMLOCK 17 119 120 #define KBMOD_ALTGRAPH KBMOD_ALT_R 121 122 123 #ifdef _KERNEL 124 125 #define KEYMAP_SIZE 128 126 127 struct keyboard { 128 u_short *k_release; /* Key released */ 129 u_short *k_control; /* Ctrl is down */ 130 u_short *k_normal; /* No shifts */ 131 u_short *k_shifted; /* Shift is down */ 132 }; 133 134 extern char kbd_stringtab[16][10]; 135 extern unsigned short kbd_numlock_map[64]; 136 137 extern struct keyboard * keyboards[]; 138 extern int kbd_max_type; 139 #define KBD_MIN_TYPE 2 140 141 #endif /* _KERNEL */ 142