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