diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2007-11-24 18:52:17 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2007-11-24 18:52:17 +0000 |
commit | 7f7539c63f6c1d8cc96a016edff945871c68638d (patch) | |
tree | 95abf1539e6668916141e4242129d9d8732006c6 /driver | |
parent | 794c2985f76d400e307a9ab05ff8d36f53262f78 (diff) |
xf86-input-keyboard 1.2.2
Diffstat (limited to 'driver')
-rw-r--r-- | driver/xf86-input-keyboard/src/at_scancode.c | 131 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/bsd_KbdMap.c | 1087 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/bsd_kbd.c | 527 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/bsd_kbd.h | 5 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/hurd_kbd.c | 176 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/lnx_KbdMap.c | 605 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/lnx_kbd.c | 484 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/lnx_kbd.h | 5 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/sco_KbdMap.c | 308 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/sco_kbd.c | 485 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/sco_kbd.h | 20 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/sun_kbd.c | 448 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/sun_kbd.h | 44 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/sun_kbdMap.c | 671 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/xf86Keymap.h | 308 | ||||
-rw-r--r-- | driver/xf86-input-keyboard/src/xf86OSKbd.h | 132 |
16 files changed, 5436 insertions, 0 deletions
diff --git a/driver/xf86-input-keyboard/src/at_scancode.c b/driver/xf86-input-keyboard/src/at_scancode.c new file mode 100644 index 000000000..b9459146c --- /dev/null +++ b/driver/xf86-input-keyboard/src/at_scancode.c @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2002-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "xf86.h" +#include "xf86Xinput.h" +#include "xf86OSKbd.h" +#include "atKeynames.h" + +Bool +ATScancode(InputInfoPtr pInfo, int *scanCode) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + + switch (pKbd->scanPrefix) { + case 0: + switch (*scanCode) { + case KEY_Prefix0: + case KEY_Prefix1: + pKbd->scanPrefix = *scanCode; /* special prefixes */ + return TRUE; + } + if (!xf86IsPc98()) { + switch (*scanCode) { + case 0x59: *scanCode = KEY_0x59; break; + case 0x5a: *scanCode = KEY_0x5A; break; + case 0x5b: *scanCode = KEY_0x5B; break; + case 0x5c: *scanCode = KEY_KP_Equal; break; /* Keypad Equal */ + case 0x5d: *scanCode = KEY_0x5D; break; + case 0x5e: *scanCode = KEY_0x5E; break; + case 0x5f: *scanCode = KEY_0x5F; break; + case 0x62: *scanCode = KEY_0x62; break; + case 0x63: *scanCode = KEY_0x63; break; + case 0x64: *scanCode = KEY_0x64; break; + case 0x65: *scanCode = KEY_0x65; break; + case 0x66: *scanCode = KEY_0x66; break; + case 0x67: *scanCode = KEY_0x67; break; + case 0x68: *scanCode = KEY_0x68; break; + case 0x69: *scanCode = KEY_0x69; break; + case 0x6a: *scanCode = KEY_0x6A; break; + case 0x6b: *scanCode = KEY_0x6B; break; + case 0x6c: *scanCode = KEY_0x6C; break; + case 0x6d: *scanCode = KEY_0x6D; break; + case 0x6e: *scanCode = KEY_0x6E; break; + case 0x6f: *scanCode = KEY_0x6F; break; + case 0x70: *scanCode = KEY_0x70; break; + case 0x71: *scanCode = KEY_0x71; break; + case 0x72: *scanCode = KEY_0x72; break; + case 0x73: *scanCode = KEY_0x73; break; + case 0x74: *scanCode = KEY_0x74; break; + case 0x75: *scanCode = KEY_0x75; break; + case 0x76: *scanCode = KEY_0x76; break; + } + } + break; + case KEY_Prefix0: + pKbd->scanPrefix = 0; + switch (*scanCode) { + case KEY_KP_7: *scanCode = KEY_Home; break; /* curs home */ + case KEY_KP_8: *scanCode = KEY_Up; break; /* curs up */ + case KEY_KP_9: *scanCode = KEY_PgUp; break; /* curs pgup */ + case KEY_KP_4: *scanCode = KEY_Left; break; /* curs left */ + case KEY_KP_5: *scanCode = KEY_Begin; break; /* curs begin */ + case KEY_KP_6: *scanCode = KEY_Right; break; /* curs right */ + case KEY_KP_1: *scanCode = KEY_End; break; /* curs end */ + case KEY_KP_2: *scanCode = KEY_Down; break; /* curs down */ + case KEY_KP_3: *scanCode = KEY_PgDown; break; /* curs pgdown */ + case KEY_KP_0: *scanCode = KEY_Insert; break; /* curs insert */ + case KEY_KP_Decimal: *scanCode = KEY_Delete; break; /* curs delete */ + case KEY_Enter: *scanCode = KEY_KP_Enter; break; /* keypad enter */ + case KEY_LCtrl: *scanCode = KEY_RCtrl; break; /* right ctrl */ + case KEY_KP_Multiply: *scanCode = KEY_Print; break; /* print */ + case KEY_Slash: *scanCode = KEY_KP_Divide; break; /* keyp divide */ + case KEY_Alt: *scanCode = KEY_AltLang; break; /* right alt */ + case KEY_ScrollLock: *scanCode = KEY_Break; break; /* curs break */ + case 0x5b: *scanCode = KEY_LMeta; break; + case 0x5c: *scanCode = KEY_RMeta; break; + case 0x5d: *scanCode = KEY_Menu; break; + case KEY_F3: *scanCode = KEY_F13; break; + case KEY_F4: *scanCode = KEY_F14; break; + case KEY_F5: *scanCode = KEY_F15; break; + case KEY_F6: *scanCode = KEY_F16; break; + case KEY_F7: *scanCode = KEY_F17; break; + case KEY_KP_Plus: *scanCode = KEY_KP_DEC; break; + case 0x2A: + case 0x36: + return TRUE; + default: + xf86MsgVerb(X_INFO, 4, "Unreported Prefix0 scancode: 0x%02x\n", + *scanCode); + *scanCode += 0x78; + } + break; + case KEY_Prefix1: + pKbd->scanPrefix = (*scanCode == KEY_LCtrl) ? KEY_LCtrl : 0; + return TRUE; + case KEY_LCtrl: + pKbd->scanPrefix = 0; + if (*scanCode != KEY_NumLock) + return TRUE; + *scanCode = KEY_Pause; /* pause */ + } + return FALSE; +} diff --git a/driver/xf86-input-keyboard/src/bsd_KbdMap.c b/driver/xf86-input-keyboard/src/bsd_KbdMap.c new file mode 100644 index 000000000..778b5744b --- /dev/null +++ b/driver/xf86-input-keyboard/src/bsd_KbdMap.c @@ -0,0 +1,1087 @@ +/* $XFree86$ */ + +/* + * Slightly modified xf86KbdBSD.c which is + * + * Derived from xf86Kbd.c by S_ren Schmidt (sos@login.dkuug.dk) + * which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * and from xf86KbdCODrv.c by Holger Veit + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86Xinput.h" +#include "xf86OSKbd.h" +#include "atKeynames.h" +#include "xf86Keymap.h" +#include "bsd_kbd.h" + +#if (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)) && defined(GIO_KEYMAP) +#define KD_GET_ENTRY(i,n) \ + eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]] + +static unsigned char remap[NUM_KEYCODES] = { + 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */ + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */ + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */ + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */ + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */ + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */ + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */ + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */ + 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */ + 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */ + 0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */ +}; + +/* This table assumes the ibm code page 437 coding for characters + * > 0x80. They are returned in this form by PCVT */ +static KeySym eascii_to_x[512] = { + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol, + NoSymbol, XK_Return, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_Escape, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_space, XK_exclam, XK_quotedbl, XK_numbersign, + XK_dollar, XK_percent, XK_ampersand, XK_apostrophe, + XK_parenleft, XK_parenright, XK_asterisk, XK_plus, + XK_comma, XK_minus, XK_period, XK_slash, + XK_0, XK_1, XK_2, XK_3, + XK_4, XK_5, XK_6, XK_7, + XK_8, XK_9, XK_colon, XK_semicolon, + XK_less, XK_equal, XK_greater, XK_question, + XK_at, XK_A, XK_B, XK_C, + XK_D, XK_E, XK_F, XK_G, + XK_H, XK_I, XK_J, XK_K, + XK_L, XK_M, XK_N, XK_O, + XK_P, XK_Q, XK_R, XK_S, + XK_T, XK_U, XK_V, XK_W, + XK_X, XK_Y, XK_Z, XK_bracketleft, + XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore, + XK_grave, XK_a, XK_b, XK_c, + XK_d, XK_e, XK_f, XK_g, + XK_h, XK_i, XK_j, XK_k, + XK_l, XK_m, XK_n, XK_o, + XK_p, XK_q, XK_r, XK_s, + XK_t, XK_u, XK_v, XK_w, + XK_x, XK_y, XK_z, XK_braceleft, + XK_bar, XK_braceright, XK_asciitilde, XK_Delete, + XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex, + XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla, + XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis, + XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring, + XK_Eacute, XK_ae, XK_AE, XK_ocircumflex, + XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave, + XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent, + XK_sterling, XK_yen, XK_paragraph, XK_section, + XK_aacute, XK_iacute, XK_oacute, XK_uacute, + XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine, + XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf, + XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi, + XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau, + XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta, + XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection, + XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal, + XK_topintegral, XK_botintegral, XK_division, XK_similarequal, + XK_degree, NoSymbol, NoSymbol, XK_radical, + XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol, + + /* + * special marked entries (256 + x) + */ + + /* This has been checked against what syscons actually does */ + NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R, + XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L, + XK_ISO_Left_Tab,XK_Control_L, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_F1, + XK_F2, XK_F3, XK_F4, XK_F5, + XK_F6, XK_F7, XK_F8, XK_F9, + XK_F10, XK_F11, XK_F12, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_Control_R, XK_Alt_R, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol +}; + +#ifdef __OpenBSD__ +/* don't mark AltR and CtrlR for remapping, since they + * cannot be remapped by pccons */ +static unsigned char pccons_remap[128] = { + 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */ + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */ + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */ + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */ + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */ + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */ + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */ + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */ + 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */ + 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 - 0x77 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */ +}; + +/* This table assumes an iso8859_1 encoding for the characters + * > 80, as returned by pccons */ +static KeySym latin1_to_x[256] = { + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol, + NoSymbol, XK_Return, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_Escape, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_space, XK_exclam, XK_quotedbl, XK_numbersign, + XK_dollar, XK_percent, XK_ampersand, XK_apostrophe, + XK_parenleft, XK_parenright, XK_asterisk, XK_plus, + XK_comma, XK_minus, XK_period, XK_slash, + XK_0, XK_1, XK_2, XK_3, + XK_4, XK_5, XK_6, XK_7, + XK_8, XK_9, XK_colon, XK_semicolon, + XK_less, XK_equal, XK_greater, XK_question, + XK_at, XK_A, XK_B, XK_C, + XK_D, XK_E, XK_F, XK_G, + XK_H, XK_I, XK_J, XK_K, + XK_L, XK_M, XK_N, XK_O, + XK_P, XK_Q, XK_R, XK_S, + XK_T, XK_U, XK_V, XK_W, + XK_X, XK_Y, XK_Z, XK_bracketleft, + XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore, + XK_grave, XK_a, XK_b, XK_c, + XK_d, XK_e, XK_f, XK_g, + XK_h, XK_i, XK_j, XK_k, + XK_l, XK_m, XK_n, XK_o, + XK_p, XK_q, XK_r, XK_s, + XK_t, XK_u, XK_v, XK_w, + XK_x, XK_y, XK_z, XK_braceleft, + XK_bar, XK_braceright, XK_asciitilde, XK_Delete, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling, + XK_currency, XK_yen, XK_brokenbar, XK_section, + XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft, + XK_notsign, XK_hyphen, XK_registered, XK_macron, + XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior, + XK_acute, XK_mu, XK_paragraph, XK_periodcentered, + XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright, + XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown, + XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde, + XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla, + XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis, + XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis, + XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute, + XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply, + XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex, + XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp, + XK_agrave, XK_aacute, XK_acircumflex, XK_atilde, + XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla, + XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis, + XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis, + XK_eth, XK_ntilde, XK_ograve, XK_oacute, + XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division, + XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex, + XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis + }; +#endif + +#ifdef SYSCONS_SUPPORT +static +unsigned char sysconsCODEMap[] = { + KEY_KP_Enter, KEY_RCtrl, KEY_KP_Divide, KEY_Print, + KEY_AltLang, KEY_KP_7, KEY_KP_8, KEY_KP_9, + KEY_KP_4, KEY_KP_6, KEY_KP_1, KEY_KP_2, + KEY_KP_3, KEY_KP_0, KEY_KP_Decimal, KEY_Pause, + KEY_LMeta, KEY_RMeta, KEY_Menu, KEY_Break +}; +static +TransMapRec sysconsCODE = { + 0x59, + 0x6d, + sysconsCODEMap +}; +#endif +#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */ + +#ifdef WSCONS_SUPPORT + +static CARD8 wsUsbMap[] = { + /* 0 */ KEY_NOTUSED, + /* 1 */ KEY_NOTUSED, + /* 2 */ KEY_NOTUSED, + /* 3 */ KEY_NOTUSED, + /* 4 */ KEY_A, + /* 5 */ KEY_B, + /* 6 */ KEY_C, + /* 7 */ KEY_D, + /* 8 */ KEY_E, + /* 9 */ KEY_F, + /* 10 */ KEY_G, + /* 11 */ KEY_H, + /* 12 */ KEY_I, + /* 13 */ KEY_J, + /* 14 */ KEY_K, + /* 15 */ KEY_L, + /* 16 */ KEY_M, + /* 17 */ KEY_N, + /* 18 */ KEY_O, + /* 19 */ KEY_P, + /* 20 */ KEY_Q, + /* 21 */ KEY_R, + /* 22 */ KEY_S, + /* 23 */ KEY_T, + /* 24 */ KEY_U, + /* 25 */ KEY_V, + /* 26 */ KEY_W, + /* 27 */ KEY_X, + /* 28 */ KEY_Y, + /* 29 */ KEY_Z, + /* 30 */ KEY_1, /* 1 !*/ + /* 31 */ KEY_2, /* 2 @ */ + /* 32 */ KEY_3, /* 3 # */ + /* 33 */ KEY_4, /* 4 $ */ + /* 34 */ KEY_5, /* 5 % */ + /* 35 */ KEY_6, /* 6 ^ */ + /* 36 */ KEY_7, /* 7 & */ + /* 37 */ KEY_8, /* 8 * */ + /* 38 */ KEY_9, /* 9 ( */ + /* 39 */ KEY_0, /* 0 ) */ + /* 40 */ KEY_Enter, /* Return */ + /* 41 */ KEY_Escape, /* Escape */ + /* 42 */ KEY_BackSpace, /* Backspace Delete */ + /* 43 */ KEY_Tab, /* Tab */ + /* 44 */ KEY_Space, /* Space */ + /* 45 */ KEY_Minus, /* - _ */ + /* 46 */ KEY_Equal, /* = + */ + /* 47 */ KEY_LBrace, /* [ { */ + /* 48 */ KEY_RBrace, /* ] } */ + /* 49 */ KEY_BSlash, /* \ | */ + /* 50 */ KEY_BSlash2, /* \ _ # ~ on some keyboards */ + /* 51 */ KEY_SemiColon, /* ; : */ + /* 52 */ KEY_Quote, /* ' " */ + /* 53 */ KEY_Tilde, /* ` ~ */ + /* 54 */ KEY_Comma, /* , < */ + /* 55 */ KEY_Period, /* . > */ + /* 56 */ KEY_Slash, /* / ? */ + /* 57 */ KEY_CapsLock, /* Caps Lock */ + /* 58 */ KEY_F1, /* F1 */ + /* 59 */ KEY_F2, /* F2 */ + /* 60 */ KEY_F3, /* F3 */ + /* 61 */ KEY_F4, /* F4 */ + /* 62 */ KEY_F5, /* F5 */ + /* 63 */ KEY_F6, /* F6 */ + /* 64 */ KEY_F7, /* F7 */ + /* 65 */ KEY_F8, /* F8 */ + /* 66 */ KEY_F9, /* F9 */ + /* 67 */ KEY_F10, /* F10 */ + /* 68 */ KEY_F11, /* F11 */ + /* 69 */ KEY_F12, /* F12 */ + /* 70 */ KEY_Print, /* PrintScrn SysReq */ + /* 71 */ KEY_ScrollLock, /* Scroll Lock */ + /* 72 */ KEY_Pause, /* Pause Break */ + /* 73 */ KEY_Insert, /* Insert XXX Help on some Mac Keyboards */ + /* 74 */ KEY_Home, /* Home */ + /* 75 */ KEY_PgUp, /* Page Up */ + /* 76 */ KEY_Delete, /* Delete */ + /* 77 */ KEY_End, /* End */ + /* 78 */ KEY_PgDown, /* Page Down */ + /* 79 */ KEY_Right, /* Right Arrow */ + /* 80 */ KEY_Left, /* Left Arrow */ + /* 81 */ KEY_Down, /* Down Arrow */ + /* 82 */ KEY_Up, /* Up Arrow */ + /* 83 */ KEY_NumLock, /* Num Lock */ + /* 84 */ KEY_KP_Divide, /* Keypad / */ + /* 85 */ KEY_KP_Multiply, /* Keypad * */ + /* 86 */ KEY_KP_Minus, /* Keypad - */ + /* 87 */ KEY_KP_Plus, /* Keypad + */ + /* 88 */ KEY_KP_Enter, /* Keypad Enter */ + /* 89 */ KEY_KP_1, /* Keypad 1 End */ + /* 90 */ KEY_KP_2, /* Keypad 2 Down */ + /* 91 */ KEY_KP_3, /* Keypad 3 Pg Down */ + /* 92 */ KEY_KP_4, /* Keypad 4 Left */ + /* 93 */ KEY_KP_5, /* Keypad 5 */ + /* 94 */ KEY_KP_6, /* Keypad 6 */ + /* 95 */ KEY_KP_7, /* Keypad 7 Home */ + /* 96 */ KEY_KP_8, /* Keypad 8 Up */ + /* 97 */ KEY_KP_9, /* KEypad 9 Pg Up */ + /* 98 */ KEY_KP_0, /* Keypad 0 Ins */ + /* 99 */ KEY_KP_Decimal, /* Keypad . Del */ + /* 100 */ KEY_Less, /* < > on some keyboards */ + /* 101 */ KEY_Menu, /* Menu */ + /* 102 */ KEY_NOTUSED, + /* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */ + /* 104 */ KEY_NOTUSED, + /* 105 */ KEY_NOTUSED, + /* 106 */ KEY_NOTUSED, + /* 107 */ KEY_NOTUSED, + /* 108 */ KEY_NOTUSED, + /* 109 */ KEY_NOTUSED, + /* 110 */ KEY_NOTUSED, + /* 111 */ KEY_NOTUSED, + /* 112 */ KEY_NOTUSED, + /* 113 */ KEY_NOTUSED, + /* 114 */ KEY_NOTUSED, + /* 115 */ KEY_NOTUSED, + /* 116 */ KEY_NOTUSED, + /* 117 */ KEY_NOTUSED, + /* 118 */ KEY_NOTUSED, + /* 119 */ KEY_NOTUSED, + /* 120 */ KEY_NOTUSED, + /* 121 */ KEY_NOTUSED, + /* 122 */ KEY_NOTUSED, + /* 123 */ KEY_NOTUSED, + /* 124 */ KEY_NOTUSED, + /* 125 */ KEY_NOTUSED, + /* 126 */ KEY_NOTUSED, + /* 127 */ KEY_NOTUSED, + /* 128 */ KEY_NOTUSED, + /* 129 */ KEY_NOTUSED, + /* 130 */ KEY_NOTUSED, + /* 131 */ KEY_NOTUSED, + /* 132 */ KEY_NOTUSED, + /* 133 */ KEY_NOTUSED, + /* 134 */ KEY_NOTUSED, + /* 135 */ KEY_NOTUSED, + /* 136 */ KEY_NOTUSED, + /* 137 */ KEY_NOTUSED, + /* 138 */ KEY_NOTUSED, + /* 139 */ KEY_NOTUSED, + /* 140 */ KEY_NOTUSED, + /* 141 */ KEY_NOTUSED, + /* 142 */ KEY_NOTUSED, + /* 143 */ KEY_NOTUSED, + /* 144 */ KEY_NOTUSED, + /* 145 */ KEY_NOTUSED, + /* 146 */ KEY_NOTUSED, + /* 147 */ KEY_NOTUSED, + /* 148 */ KEY_NOTUSED, + /* 149 */ KEY_NOTUSED, + /* 150 */ KEY_NOTUSED, + /* 151 */ KEY_NOTUSED, + /* 152 */ KEY_NOTUSED, + /* 153 */ KEY_NOTUSED, + /* 154 */ KEY_NOTUSED, + /* 155 */ KEY_NOTUSED, + /* 156 */ KEY_NOTUSED, + /* 157 */ KEY_NOTUSED, + /* 158 */ KEY_NOTUSED, + /* 159 */ KEY_NOTUSED, + /* 160 */ KEY_NOTUSED, + /* 161 */ KEY_NOTUSED, + /* 162 */ KEY_NOTUSED, + /* 163 */ KEY_NOTUSED, + /* 164 */ KEY_NOTUSED, + /* 165 */ KEY_NOTUSED, + /* 166 */ KEY_NOTUSED, + /* 167 */ KEY_NOTUSED, + /* 168 */ KEY_NOTUSED, + /* 169 */ KEY_NOTUSED, + /* 170 */ KEY_NOTUSED, + /* 171 */ KEY_NOTUSED, + /* 172 */ KEY_NOTUSED, + /* 173 */ KEY_NOTUSED, + /* 174 */ KEY_NOTUSED, + /* 175 */ KEY_NOTUSED, + /* 176 */ KEY_NOTUSED, + /* 177 */ KEY_NOTUSED, + /* 178 */ KEY_NOTUSED, + /* 179 */ KEY_NOTUSED, + /* 180 */ KEY_NOTUSED, + /* 181 */ KEY_NOTUSED, + /* 182 */ KEY_NOTUSED, + /* 183 */ KEY_NOTUSED, + /* 184 */ KEY_NOTUSED, + /* 185 */ KEY_NOTUSED, + /* 186 */ KEY_NOTUSED, + /* 187 */ KEY_NOTUSED, + /* 188 */ KEY_NOTUSED, + /* 189 */ KEY_NOTUSED, + /* 190 */ KEY_NOTUSED, + /* 191 */ KEY_NOTUSED, + /* 192 */ KEY_NOTUSED, + /* 193 */ KEY_NOTUSED, + /* 194 */ KEY_NOTUSED, + /* 195 */ KEY_NOTUSED, + /* 196 */ KEY_NOTUSED, + /* 197 */ KEY_NOTUSED, + /* 198 */ KEY_NOTUSED, + /* 199 */ KEY_NOTUSED, + /* 200 */ KEY_NOTUSED, + /* 201 */ KEY_NOTUSED, + /* 202 */ KEY_NOTUSED, + /* 203 */ KEY_NOTUSED, + /* 204 */ KEY_NOTUSED, + /* 205 */ KEY_NOTUSED, + /* 206 */ KEY_NOTUSED, + /* 207 */ KEY_NOTUSED, + /* 208 */ KEY_NOTUSED, + /* 209 */ KEY_NOTUSED, + /* 210 */ KEY_NOTUSED, + /* 211 */ KEY_NOTUSED, + /* 212 */ KEY_NOTUSED, + /* 213 */ KEY_NOTUSED, + /* 214 */ KEY_NOTUSED, + /* 215 */ KEY_NOTUSED, + /* 216 */ KEY_NOTUSED, + /* 217 */ KEY_NOTUSED, + /* 218 */ KEY_NOTUSED, + /* 219 */ KEY_NOTUSED, + /* 220 */ KEY_NOTUSED, + /* 221 */ KEY_NOTUSED, + /* 222 */ KEY_NOTUSED, + /* 223 */ KEY_NOTUSED, + /* 224 */ KEY_LCtrl, /* Left Control */ + /* 225 */ KEY_ShiftL, /* Left Shift */ + /* 226 */ KEY_Alt, /* Left Alt */ + /* 227 */ KEY_LMeta, /* Left Meta */ + /* 228 */ KEY_RCtrl, /* Right Control */ + /* 229 */ KEY_ShiftR, /* Right Shift */ + /* 230 */ KEY_AltLang, /* Right Alt, AKA AltGr */ + /* 231 */ KEY_LMeta, /* Right Meta XXX */ +}; +#define WS_USB_MAP_SIZE (sizeof(wsUsbMap)/sizeof(unsigned char)) + +static +TransMapRec wsUsb = { + 0, + WS_USB_MAP_SIZE, + wsUsbMap +}; + +/* Map for adb keyboards */ +static CARD8 wsAdbMap[] = { + /* 0 */ KEY_A, + /* 1 */ KEY_S, + /* 2 */ KEY_D, + /* 3 */ KEY_F, + /* 4 */ KEY_H, + /* 5 */ KEY_G, + /* 6 */ KEY_Z, + /* 7 */ KEY_X, + /* 8 */ KEY_C, + /* 9 */ KEY_V, + /* 10 */ KEY_UNKNOWN, /* @ # on french keyboards */ + /* 11 */ KEY_B, + /* 12 */ KEY_Q, + /* 13 */ KEY_W, + /* 14 */ KEY_E, + /* 15 */ KEY_R, + /* 16 */ KEY_Y, + /* 17 */ KEY_T, + /* 18 */ KEY_1, + /* 19 */ KEY_2, + /* 20 */ KEY_3, + /* 21 */ KEY_4, + /* 22 */ KEY_6, + /* 23 */ KEY_5, + /* 24 */ KEY_Equal, + /* 25 */ KEY_9, + /* 26 */ KEY_7, + /* 27 */ KEY_Minus, + /* 28 */ KEY_8, + /* 29 */ KEY_0, + /* 30 */ KEY_RBrace, + /* 31 */ KEY_O, + /* 32 */ KEY_U, + /* 33 */ KEY_LBrace, + /* 34 */ KEY_I, + /* 35 */ KEY_P, + /* 36 */ KEY_Enter, + /* 37 */ KEY_L, + /* 38 */ KEY_J, + /* 39 */ KEY_Quote, + /* 40 */ KEY_K, + /* 41 */ KEY_SemiColon, + /* 42 */ KEY_BSlash, + /* 43 */ KEY_Comma, + /* 44 */ KEY_Slash, + /* 45 */ KEY_N, + /* 46 */ KEY_M, + /* 47 */ KEY_Period, + /* 48 */ KEY_Tab, + /* 49 */ KEY_Space, + /* 50 */ KEY_Tilde, + /* 51 */ KEY_Delete, + /* 52 */ KEY_AltLang, + /* 53 */ KEY_Escape, + /* 54 */ KEY_LCtrl, + /* 55 */ KEY_Alt, + /* 56 */ KEY_ShiftL, + /* 57 */ KEY_CapsLock, + /* 58 */ KEY_LMeta, + /* 59 */ KEY_Left, + /* 60 */ KEY_Right, + /* 61 */ KEY_Down, + /* 62 */ KEY_Up, + /* 63 */ KEY_UNKNOWN, /* Fn */ + /* 64 */ KEY_NOTUSED, + /* 65 */ KEY_KP_Decimal, + /* 66 */ KEY_NOTUSED, + /* 67 */ KEY_KP_Multiply, + /* 68 */ KEY_NOTUSED, + /* 69 */ KEY_KP_Plus, + /* 70 */ KEY_NOTUSED, + /* 71 */ KEY_UNKNOWN, /* Clear */ + /* 72 */ KEY_NOTUSED, + /* 73 */ KEY_NOTUSED, + /* 74 */ KEY_NOTUSED, + /* 75 */ KEY_KP_Divide, + /* 76 */ KEY_KP_Enter, + /* 77 */ KEY_NOTUSED, + /* 78 */ KEY_KP_Minus, + /* 79 */ KEY_NOTUSED, + /* 80 */ KEY_NOTUSED, + /* 81 */ KEY_KP_Equal, /* Keypad = */ + /* 82 */ KEY_KP_0, + /* 83 */ KEY_KP_1, + /* 84 */ KEY_KP_2, + /* 85 */ KEY_KP_3, + /* 86 */ KEY_KP_4, + /* 87 */ KEY_KP_5, + /* 88 */ KEY_KP_6, + /* 89 */ KEY_KP_7, + /* 90 */ KEY_NOTUSED, + /* 91 */ KEY_KP_8, + /* 92 */ KEY_KP_9, + /* 93 */ KEY_NOTUSED, + /* 94 */ KEY_NOTUSED, + /* 95 */ KEY_UNKNOWN, /* Keypad , */ + /* 96 */ KEY_F5, + /* 97 */ KEY_F6, + /* 98 */ KEY_F7, + /* 99 */ KEY_F3, + /* 100 */ KEY_F8, + /* 101 */ KEY_F9, + /* 102 */ KEY_NOTUSED, + /* 103 */ KEY_F11, + /* 104 */ KEY_NOTUSED, + /* 105 */ KEY_NOTUSED, + /* 106 */ KEY_KP_Enter, + /* 107 */ KEY_NOTUSED, + /* 108 */ KEY_NOTUSED, + /* 109 */ KEY_F10, + /* 110 */ KEY_NOTUSED, + /* 111 */ KEY_F12, + /* 112 */ KEY_NOTUSED, + /* 113 */ KEY_NOTUSED, + /* 114 */ KEY_NOTUSED, + /* 115 */ KEY_Home, + /* 116 */ KEY_PgUp, + /* 117 */ KEY_NOTUSED, + /* 118 */ KEY_F4, + /* 119 */ KEY_End, + /* 120 */ KEY_F2, + /* 121 */ KEY_PgDown, + /* 122 */ KEY_F1 +}; +#define WS_ADB_MAP_SIZE (sizeof(wsAdbMap)/sizeof(unsigned char)) + +static +TransMapRec wsAdb = { + 0, + WS_ADB_MAP_SIZE, + wsAdbMap +}; + +static CARD8 wsSunMap[] = { + /* 0x00 */ KEY_Help, + /* 0x01 */ KEY_L1, /* stop */ + /* 0x02 */ KEY_AudioLower, /* BrightnessDown / S-VolumeDown */ + /* 0x03 */ KEY_L2, /* again */ + /* 0x04 */ KEY_AudioRaise, /* BridgtnessUp / S-VolumeUp */ + /* 0x05 */ KEY_F1, + /* 0x06 */ KEY_F2, + /* 0x07 */ KEY_F10, + /* 0x08 */ KEY_F3, + /* 0x09 */ KEY_F11, + /* 0x0a */ KEY_F4, + /* 0x0b */ KEY_F12, + /* 0x0c */ KEY_F5, + /* 0x0d */ KEY_AltLang, + /* 0x0e */ KEY_F6, + /* 0x0f */ KEY_NOTUSED, + /* 0x10 */ KEY_F7, + /* 0x11 */ KEY_F8, + /* 0x12 */ KEY_F9, + /* 0x13 */ KEY_Alt, + /* 0x14 */ KEY_Up, + /* 0x15 */ KEY_Pause, + /* 0x16 */ KEY_Print, + /* 0x17 */ KEY_ScrollLock, + /* 0x18 */ KEY_Left, + /* 0x19 */ KEY_L3, /* props */ + /* 0x1a */ KEY_L4, /* undo */ + /* 0x1b */ KEY_Down, + /* 0x1c */ KEY_Right, + /* 0x1d */ KEY_Escape, + /* 0x1e */ KEY_1, + /* 0x1f */ KEY_2, + /* 0x20 */ KEY_3, + /* 0x21 */ KEY_4, + /* 0x22 */ KEY_5, + /* 0x23 */ KEY_6, + /* 0x24 */ KEY_7, + /* 0x25 */ KEY_8, + /* 0x26 */ KEY_9, + /* 0x27 */ KEY_0, + /* 0x28 */ KEY_Minus, + /* 0x29 */ KEY_Equal, + /* 0x2a */ KEY_Tilde, + /* 0x2b */ KEY_BackSpace, + /* 0x2c */ KEY_Insert, + /* 0x2d */ KEY_Mute, /* Audio Mute */ + /* 0x2e */ KEY_KP_Divide, + /* 0x2f */ KEY_KP_Multiply, + /* 0x30 */ KEY_NOTUSED, + /* 0x31 */ KEY_L5, /* front */ + /* 0x32 */ KEY_KP_Decimal, + /* 0x33 */ KEY_L6, /* copy */ + /* 0x34 */ KEY_Home, + /* 0x35 */ KEY_Tab, + /* 0x36 */ KEY_Q, + /* 0x37 */ KEY_W, + /* 0x38 */ KEY_E, + /* 0x39 */ KEY_R, + /* 0x3a */ KEY_T, + /* 0x3b */ KEY_Y, + /* 0x3c */ KEY_U, + /* 0x3d */ KEY_I, + /* 0x3e */ KEY_O, + /* 0x3f */ KEY_P, + /* 0x40 */ KEY_LBrace, + /* 0x41 */ KEY_RBrace, + /* 0x42 */ KEY_Delete, + /* 0x43 */ KEY_Menu, /* compose */ + /* 0x44 */ KEY_KP_7, + /* 0x45 */ KEY_KP_8, + /* 0x46 */ KEY_KP_9, + /* 0x47 */ KEY_KP_Minus, + /* 0x48 */ KEY_L7, /* open */ + /* 0x49 */ KEY_L8, /* paste */ + /* 0x4a */ KEY_End, + /* 0x4b */ KEY_NOTUSED, + /* 0x4c */ KEY_LCtrl, + /* 0x4d */ KEY_A, + /* 0x4e */ KEY_S, + /* 0x4f */ KEY_D, + /* 0x50 */ KEY_F, + /* 0x51 */ KEY_G, + /* 0x52 */ KEY_H, + /* 0x53 */ KEY_J, + /* 0x54 */ KEY_K, + /* 0x55 */ KEY_L, + /* 0x56 */ KEY_SemiColon, + /* 0x57 */ KEY_Quote, + /* 0x58 */ KEY_BSlash, + /* 0x59 */ KEY_Enter, + /* 0x5a */ KEY_KP_Enter, + /* 0x5b */ KEY_KP_4, + /* 0x5c */ KEY_KP_5, + /* 0x5d */ KEY_KP_6, + /* 0x5e */ KEY_KP_0, + /* 0x5f */ KEY_L9, /* find */ + /* 0x60 */ KEY_PgUp, + /* 0x61 */ KEY_L10, /* cut */ + /* 0x62 */ KEY_NumLock, + /* 0x63 */ KEY_ShiftL, + /* 0x64 */ KEY_Z, + /* 0x65 */ KEY_X, + /* 0x66 */ KEY_C, + /* 0x67 */ KEY_V, + /* 0x68 */ KEY_B, + /* 0x69 */ KEY_N, + /* 0x6a */ KEY_M, + /* 0x6b */ KEY_Comma, + /* 0x6c */ KEY_Period, + /* 0x6d */ KEY_Slash, + /* 0x6e */ KEY_ShiftR, + /* 0x6f */ KEY_NOTUSED, /* linefeed */ + /* 0x70 */ KEY_KP_1, + /* 0x71 */ KEY_KP_2, + /* 0x72 */ KEY_KP_3, + /* 0x73 */ KEY_NOTUSED, + /* 0x74 */ KEY_NOTUSED, + /* 0x75 */ KEY_NOTUSED, + /* 0x76 */ KEY_NOTUSED, /* help */ + /* 0x77 */ KEY_CapsLock, + /* 0x78 */ KEY_LMeta, + /* 0x79 */ KEY_Space, + /* 0x7a */ KEY_RMeta, + /* 0x7b */ KEY_PgDown, + /* 0x7c */ KEY_Less, /* < > on some keyboards */ + /* 0x7d */ KEY_KP_Plus, + /* 0x7e */ KEY_NOTUSED, + /* 0x7f */ KEY_NOTUSED +}; +#define WS_SUN_MAP_SIZE (sizeof(wsSunMap)/sizeof(unsigned char)) + +static +TransMapRec wsSun = { + 0, + WS_SUN_MAP_SIZE, + wsSunMap +}; + +#endif /* WSCONS_SUPPORT */ + +/*ARGSUSED*/ + +/* + * KbdGetMapping -- + * Get the national keyboard mapping. The keyboard type is set, a new map + * and the modifiermap is computed. + */ + +void +KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + KeySym *k; + int i; + +#ifndef __bsdi__ + switch (pKbd->consType) { + +#ifdef PCCONS_SUPPORT + case PCCONS: +#if defined(__OpenBSD__) + /* + * on OpenBSD, the pccons keymap is programmable, too + */ + { + pccons_keymap_t keymap[KB_NUM_KEYS]; + if (ioctl(pInfo->fd, CONSOLE_GET_KEYMAP, &keymap) != -1) { + for (i = 0; i < KB_NUM_KEYS; i++) + if (pccons_remap[i]) { + k = map + (pccons_remap[i] << 2); + switch (keymap[i].type) { + case KB_ASCII: + /* For ASCII keys, there is only one char in the keymap */ + k[0] = latin1_to_x[(unsigned char)keymap[i].unshift[0]]; + k[1] = latin1_to_x[(unsigned char)keymap[i].shift[0]]; + k[2] = latin1_to_x[(unsigned char)keymap[i].altgr[0]]; + k[3] = latin1_to_x[(unsigned char)keymap[i].shift_altgr[0]]; + break; + case KB_SCROLL: + k[0] = XK_Scroll_Lock; + goto special; + case KB_NUM: + k[0] = XK_Num_Lock; + goto special; + case KB_CAPS: + k[0] = XK_Caps_Lock; + goto special; + case KB_SHIFT: + switch (keymap[i].unshift[0]) { + case 1: + /* left shift */ + k[0] = XK_Shift_L; + break; + case 2: + /* right shift */ + k[0] = XK_Shift_R; + break; + default: + k[0] = NoSymbol; + } + goto special; + case KB_CTL: + k[0] = XK_Control_L; + goto special; + case KB_ALT: + k[0] = XK_Alt_L; + goto special; + case KB_FUNC: + switch (keymap[i].unshift[2]) { + case 'M': + k[0] = XK_F1; + break; + case 'N': + k[0] = XK_F2; + break; + case 'O': + k[0] = XK_F3; + break; + case 'P': + k[0] = XK_F4; + break; + case 'Q': + k[0] = XK_F5; + break; + case 'R': + k[0] = XK_F6; + break; + case 'S': + k[0] = XK_F7; + break; + case 'T': + k[0] = XK_F8; + break; + case 'U': + k[0] = XK_F9; + break; + case 'V': + k[0] = XK_F10; + break; + case 'W': + k[0] = XK_F11; + break; + case 'X': + k[0] = XK_F12; + break; + default: + k[0] = NoSymbol; + break; + } + goto special; + default: + k[0] = NoSymbol; + special: + k[1] = k[2] = k[3] = NoSymbol; + } + } + } else { + ErrorF("Can't read pccons keymap\n"); + } + } +#endif /* __OpenBSD__ */ + break; +#endif + +/* + * XXX wscons has no GIO_KEYMAP + */ +#if (defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)) && defined(GIO_KEYMAP) + case SYSCONS: + case PCVT: + { + keymap_t keymap; + + if (ioctl(pInfo->fd, GIO_KEYMAP, &keymap) != -1) { + for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++) + if (remap[i]) { + k = map + (remap[i] << 2); + k[0] = KD_GET_ENTRY(i,0); /* non-shifed */ + k[1] = KD_GET_ENTRY(i,1); /* shifted */ + k[2] = KD_GET_ENTRY(i,4); /* alt */ + k[3] = KD_GET_ENTRY(i,5); /* alt - shifted */ + if (k[3] == k[2]) k[3] = NoSymbol; + if (k[2] == k[1]) k[2] = NoSymbol; + if (k[1] == k[0]) k[1] = NoSymbol; + if (k[0] == k[2] && k[1] == k[3]) + k[2] = k[3] = NoSymbol; + } + } + } + break; +#endif /* SYSCONS || PCVT */ + + } +#endif /* !bsdi */ + + /* + * compute the modifier map + */ + for (i = 0; i < MAP_LENGTH; i++) + pModMap[i] = NoSymbol; /* make sure it is restored */ + + for (k = map, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += 4) + + switch(*k) { + + case XK_Shift_L: + case XK_Shift_R: + pModMap[i] = ShiftMask; + break; + + case XK_Control_L: + case XK_Control_R: + pModMap[i] = ControlMask; + break; + + case XK_Caps_Lock: + pModMap[i] = LockMask; + break; + + case XK_Alt_L: + case XK_Alt_R: + pModMap[i] = AltMask; + break; + + case XK_Num_Lock: + pModMap[i] = NumLockMask; + break; + + case XK_Scroll_Lock: + pModMap[i] = ScrollLockMask; + break; + + /* kana support */ + case XK_Kana_Lock: + case XK_Kana_Shift: + pModMap[i] = KanaMask; + break; + + /* alternate toggle for multinational support */ + case XK_Mode_switch: + pModMap[i] = AltLangMask; + break; + + } + + pKbd->kbdType = 0; + + pKeySyms->map = map; + pKeySyms->mapWidth = GLYPHS_PER_KEY; + pKeySyms->minKeyCode = MIN_KEYCODE; + pKeySyms->maxKeyCode = MAX_KEYCODE; + + switch(pKbd->consType) { +#ifdef SYSCONS_SUPPORT + case SYSCONS: + if (pKbd->CustomKeycodes) + pKbd->scancodeMap = &sysconsCODE; + else + pKbd->RemapScanCode = ATScancode; + break; +#endif +#if defined(PCCONS_SUPPORT) || defined (PCVT_SUPPORT) + case PCCONS: + case PCVT: + pKbd->RemapScanCode = ATScancode; + break; +#endif +#ifdef WSCONS_SUPPORT + case WSCONS: + if (!pKbd->isConsole) { + switch (pKbd->wsKbdType) { + case WSKBD_TYPE_PC_XT: + case WSKBD_TYPE_PC_AT: + pKbd->RemapScanCode = ATScancode; + break; + case WSKBD_TYPE_USB: + pKbd->scancodeMap = &wsUsb; + break; +#ifdef WSKBD_TYPE_ADB + case WSKBD_TYPE_ADB: + pKbd->scancodeMap = &wsAdb; + break; +#endif +#ifdef WSKBD_TYPE_SUN +#ifdef WSKBD_TYPE_SUN5 + case WSKBD_TYPE_SUN5: +#endif + case WSKBD_TYPE_SUN: + pKbd->scancodeMap = &wsSun; + break; +#endif + default: + ErrorF("Unknown wskbd type %d\n", pKbd->wsKbdType); + } + } else { + pKbd->RemapScanCode = ATScancode; + } + break; +#endif + } + return; +} diff --git a/driver/xf86-input-keyboard/src/bsd_kbd.c b/driver/xf86-input-keyboard/src/bsd_kbd.c new file mode 100644 index 000000000..912879a2b --- /dev/null +++ b/driver/xf86-input-keyboard/src/bsd_kbd.c @@ -0,0 +1,527 @@ + +/* + * Copyright (c) 2002 by The XFree86 Project, Inc. + * Author: Ivan Pascal. + * + * Based on the code from bsd_io.c which is + * Copyright 1992 by Rich Murphey <Rich@Rice.edu> + * Copyright 1993 by David Dawes <dawes@xfree86.org> + */ + +#define NEED_EVENTS + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <X11/X.h> +#include <termios.h> + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#include "xf86Xinput.h" +#include "xf86OSKbd.h" +#include "atKeynames.h" + +extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms, + CARD8 *pModMap); + +extern Bool VTSwitchEnabled; + +static KbdProtocolRec protocols[] = { + {"standard", PROT_STD }, +#ifdef WSCONS_SUPPORT + {"wskbd", PROT_WSCONS }, +#endif + { NULL, PROT_UNKNOWN_KBD } +}; + +typedef struct { + struct termios kbdtty; +} BsdKbdPrivRec, *BsdKbdPrivPtr; + +static +int KbdInit(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + BsdKbdPrivPtr priv = (BsdKbdPrivPtr) pKbd->private; + + if (pKbd->isConsole) { + switch (pKbd->consType) { +#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) || defined (WSCONS_SUPPORT) + case PCCONS: + case SYSCONS: + case PCVT: +#if defined WSCONS_SUPPORT + case WSCONS: +#endif + tcgetattr(pInfo->fd, &(priv->kbdtty)); +#endif + break; + } + } + + return Success; +} + +static void +SetKbdLeds(InputInfoPtr pInfo, int leds) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + int real_leds = 0; + +#ifdef LED_CAP + if (leds & XLED1) real_leds |= LED_CAP; +#endif +#ifdef LED_NUM + if (leds & XLED2) real_leds |= LED_NUM; +#endif +#ifdef LED_SCR + if (leds & XLED3) real_leds |= LED_SCR; + if (leds & XLED4) real_leds |= LED_SCR; +#endif + + switch (pKbd->consType) { + + case PCCONS: + break; +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(pInfo->fd, KDSETLED, real_leds); + break; +#endif +#if defined(WSCONS_SUPPORT) + case WSCONS: + ioctl(pInfo->fd, WSKBDIO_SETLEDS, &real_leds); + break; +#endif + } +} + +static int +GetKbdLeds(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + int leds = 0, real_leds = 0; + + switch (pKbd->consType) { + case PCCONS: + break; +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(pInfo->fd, KDGETLED, &real_leds); + break; +#endif +#if defined(WSCONS_SUPPORT) + case WSCONS: + ioctl(pInfo->fd, WSKBDIO_GETLEDS, &real_leds); + break; +#endif + } + +#ifdef LED_CAP + if (real_leds & LED_CAP) leds |= XLED1; +#endif +#ifdef LED_NUM + if (real_leds & LED_NUM) leds |= XLED2; +#endif +#ifdef LED_SCR + if (real_leds & LED_SCR) leds |= XLED3; +#endif + + return(leds); +} + +static void +SetKbdRepeat(InputInfoPtr pInfo, char rad) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + switch (pKbd->consType) { + + case PCCONS: + break; +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(pInfo->fd, KDSETRAD, rad); + break; +#endif + } +} + +static int +KbdOn(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; +#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT) + BsdKbdPrivPtr priv = (BsdKbdPrivPtr) pKbd->private; + struct termios nTty; +#endif +#ifdef WSCONS_SUPPORT + int option; +#endif + + if (pKbd->isConsole) { + switch (pKbd->consType) { + +#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT) + case SYSCONS: + case PCCONS: + case PCVT: +#ifdef WSCONS_SUPPORT + case WSCONS: +#endif + nTty = priv->kbdtty; + nTty.c_iflag = IGNPAR | IGNBRK; + nTty.c_oflag = 0; + nTty.c_cflag = CREAD | CS8; + nTty.c_lflag = 0; + nTty.c_cc[VTIME] = 0; + nTty.c_cc[VMIN] = 1; + cfsetispeed(&nTty, 9600); + cfsetospeed(&nTty, 9600); + if (tcsetattr(pInfo->fd, TCSANOW, &nTty) < 0) { + xf86Msg(X_ERROR, "KbdOn: tcsetattr: %s\n", + strerror(errno)); + } + break; +#endif + } +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) || defined (WSCONS_SUPPORT) + switch (pKbd->consType) { + case SYSCONS: + case PCVT: +#ifdef K_CODE + if (pKbd->CustomKeycodes) + ioctl(pInfo->fd, KDSKBMODE, K_CODE); + else + ioctl(pInfo->fd, KDSKBMODE, K_RAW); +#else + ioctl(pInfo->fd, KDSKBMODE, K_RAW); +#endif + break; +#endif +#ifdef WSCONS_SUPPORT + case WSCONS: + option = WSKBD_RAW; + if (ioctl(pInfo->fd, WSKBDIO_SETMODE, &option) == -1) { + FatalError("can't switch keyboard to raw mode. " + "Enable support for it in the kernel\n" + "or use for example:\n\n" + "Option \"Protocol\" \"wskbd\"\n" + "Option \"Device\" \"/dev/wskbd0\"\n" + "\nin your xorg.conf(5) file\n"); + } + break; +#endif + } + } + return Success; +} + +static int +KbdOff(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + BsdKbdPrivPtr priv = (BsdKbdPrivPtr) pKbd->private; +#ifdef WSCONS_SUPPORT + int option; +#endif + + if (pKbd->isConsole) { + switch (pKbd->consType) { +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(pInfo->fd, KDSKBMODE, K_XLATE); + /* FALL THROUGH */ +#endif +#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) + case PCCONS: + tcsetattr(pInfo->fd, TCSANOW, &(priv->kbdtty)); + break; +#endif +#ifdef WSCONS_SUPPORT + case WSCONS: + option = WSKBD_TRANSLATED; + ioctl(xf86Info.consoleFd, WSKBDIO_SETMODE, &option); + tcsetattr(pInfo->fd, TCSANOW, &(priv->kbdtty)); + break; +#endif + } + } + return Success; +} + +static void +SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; +#ifdef WSCONS_SUPPORT + struct wskbd_bell_data wsb; +#endif + + if (loudness && pitch) { + switch (pKbd->consType) { +#ifdef PCCONS_SUPPORT + case PCCONS: + { int data[2]; + data[0] = pitch; + data[1] = (duration * loudness) / 50; + ioctl(pInfo->fd, CONSOLE_X_BELL, data); + break; + } +#endif +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + case SYSCONS: + case PCVT: + ioctl(pInfo->fd, KDMKTONE, + ((1193190 / pitch) & 0xffff) | + (((unsigned long)duration*loudness/50)<<16)); + break; +#endif +#if defined (WSCONS_SUPPORT) + case WSCONS: + wsb.which = WSKBD_BELL_DOALL; + wsb.pitch = pitch; + wsb.period = duration; + wsb.volume = loudness; + ioctl(pInfo->fd, WSKBDIO_COMPLEXBELL, &wsb); + break; +#endif + } + } +} + +#define ModifierSet(k) ((modifiers & (k)) == (k)) + +static +Bool SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + + if(!pKbd->vtSwitchSupported) + return FALSE; + + if ((ModifierSet(ControlMask | AltMask)) || + (ModifierSet(ControlMask | AltLangMask))) { + if (VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch) { + switch (key) { + case KEY_F1: + case KEY_F2: + case KEY_F3: + case KEY_F4: + case KEY_F5: + case KEY_F6: + case KEY_F7: + case KEY_F8: + case KEY_F9: + case KEY_F10: +#ifdef VT_ACTIVATE + if (down) { + ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1); + return TRUE; + } +#endif + case KEY_F11: + case KEY_F12: +#ifdef VT_ACTIVATE + if (down) { + ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11); + return TRUE; + } +#endif + } + } + } + + return FALSE; +} + +static void +stdReadInput(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + unsigned char rBuf[64]; + int nBytes, i; + if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) { + for (i = 0; i < nBytes; i++) + pKbd->PostEvent(pInfo, rBuf[i] & 0x7f, + rBuf[i] & 0x80 ? FALSE : TRUE); + } +} + +#ifdef WSCONS_SUPPORT + +static void +WSReadInput(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + struct wscons_event events[64]; + int type; + int blocked, n, i; + + if ((n = read( pInfo->fd, events, sizeof(events))) > 0) { + n /= sizeof(struct wscons_event); + for (i = 0; i < n; i++) { + type = events[i].type; + if (type == WSCONS_EVENT_KEY_UP || type == WSCONS_EVENT_KEY_DOWN) { + /* It seems better to block SIGIO there */ + blocked = xf86BlockSIGIO(); + pKbd->PostEvent(pInfo, (unsigned int)(events[i].value), + type == WSCONS_EVENT_KEY_DOWN ? TRUE : FALSE); + xf86UnblockSIGIO(blocked); + } + } /* for */ + } +} + +static void +printWsType(char *type, char *devname) +{ + xf86Msg(X_PROBED, "%s: Keyboard type: %s\n", type, devname); +} +#endif + +static Bool +OpenKeyboard(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + int i; + KbdProtocolId prot = PROT_UNKNOWN_KBD; + char *s; + + s = xf86SetStrOption(pInfo->options, "Protocol", NULL); + for (i = 0; protocols[i].name; i++) { + if (xf86NameCmp(s, protocols[i].name) == 0) { + prot = protocols[i].id; + break; + } + } + + switch (prot) { + case PROT_STD: + pInfo->read_input = stdReadInput; + break; +#ifdef WSCONS_SUPPORT + case PROT_WSCONS: + pInfo->read_input = WSReadInput; + break; +#endif + default: + xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s); + xfree(s); + return FALSE; + } + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s); + xfree(s); + + s = xf86SetStrOption(pInfo->options, "Device", NULL); + if (s == NULL) { + if (prot == PROT_WSCONS) { + xf86Msg(X_ERROR,"A \"device\" option is required with" + " the \"wskbd\" keyboard protocol\n"); + return FALSE; + } else { + pInfo->fd = xf86Info.consoleFd; + pKbd->isConsole = TRUE; + pKbd->consType = xf86Info.consType; + } + } else { + pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL); + if (pInfo->fd == -1) { + xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s); + xfree(s); + return FALSE; + } + pKbd->isConsole = FALSE; + pKbd->consType = xf86Info.consType; + xfree(s); + } + +#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) + if (pKbd->isConsole && + ((pKbd->consType == SYSCONS) || (pKbd->consType == PCVT))) + pKbd->vtSwitchSupported = TRUE; +#endif + +#ifdef WSCONS_SUPPORT + if( prot == PROT_WSCONS) { + pKbd->consType = WSCONS; + /* Find out keyboard type */ + if (ioctl(pInfo->fd, WSKBDIO_GTYPE, &(pKbd->wsKbdType)) == -1) { + xf86Msg(X_ERROR, "%s: cannot get keyboard type", pInfo->name); + close(pInfo->fd); + return FALSE; + } + switch (pKbd->wsKbdType) { + case WSKBD_TYPE_PC_XT: + printWsType("XT", pInfo->name); + break; + case WSKBD_TYPE_PC_AT: + printWsType("AT", pInfo->name); + break; + case WSKBD_TYPE_USB: + printWsType("USB", pInfo->name); + break; +#ifdef WSKBD_TYPE_ADB + case WSKBD_TYPE_ADB: + printWsType("ADB", pInfo->name); + break; +#endif +#ifdef WSKBD_TYPE_SUN + case WSKBD_TYPE_SUN: + printWsType("Sun", pInfo->name); + break; +#endif +#ifdef WSKBD_TYPE_SUN5 + case WSKBD_TYPE_SUN5: + xf86Msg(X_PROBED, "Keyboard type: Sun5\n"); + break; +#endif + default: + xf86Msg(X_ERROR, "%s: Unsupported wskbd type \"%d\"", + pInfo->name, pKbd->wsKbdType); + close(pInfo->fd); + return FALSE; + } + } +#endif + return TRUE; +} + +_X_EXPORT Bool +xf86OSKbdPreInit(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = pInfo->private; + + pKbd->KbdInit = KbdInit; + pKbd->KbdOn = KbdOn; + pKbd->KbdOff = KbdOff; + pKbd->Bell = SoundBell; + pKbd->SetLeds = SetKbdLeds; + pKbd->GetLeds = GetKbdLeds; + pKbd->SetKbdRepeat = SetKbdRepeat; + pKbd->KbdGetMapping = KbdGetMapping; + pKbd->SpecialKey = SpecialKey; + + pKbd->RemapScanCode = NULL; + pKbd->GetSpecialKey = NULL; + + pKbd->OpenKeyboard = OpenKeyboard; + pKbd->vtSwitchSupported = FALSE; + pKbd->CustomKeycodes = FALSE; + + pKbd->private = xcalloc(sizeof(BsdKbdPrivRec), 1); + if (pKbd->private == NULL) { + xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n"); + return FALSE; + } + return TRUE; +} diff --git a/driver/xf86-input-keyboard/src/bsd_kbd.h b/driver/xf86-input-keyboard/src/bsd_kbd.h new file mode 100644 index 000000000..c042d88bf --- /dev/null +++ b/driver/xf86-input-keyboard/src/bsd_kbd.h @@ -0,0 +1,5 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kbd.h,v 1.1 2002/10/11 01:40:34 dawes Exp $ */ + +extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms, + CARD8 *pModMap); + diff --git a/driver/xf86-input-keyboard/src/hurd_kbd.c b/driver/xf86-input-keyboard/src/hurd_kbd.c new file mode 100644 index 000000000..77f84cecb --- /dev/null +++ b/driver/xf86-input-keyboard/src/hurd_kbd.c @@ -0,0 +1,176 @@ +/* + * Copyright 1997,1998 by UCHIYAMA Yasushi + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of UCHIYAMA Yasushi not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. UCHIYAMA Yasushi makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * UCHIYAMA YASUSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL UCHIYAMA YASUSHI BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/hurd_io.c,v 1.8 2002/10/11 01:40:35 dawes Exp $ */ + +#define NEED_EVENTS +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <X11/X.h> + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#include "xf86Xinput.h" +#include "xf86OSKbd.h" +#include "atKeynames.h" +#include "xf86Keymap.h" + +#include <stdio.h> +#include <errno.h> +#include <sys/time.h> +#include <sys/file.h> +#include <assert.h> +#include <mach.h> +#include <sys/ioctl.h> + +typedef unsigned short kev_type; /* kd event type */ +typedef unsigned char Scancode; + +struct mouse_motion { + short mm_deltaX; /* units? */ + short mm_deltaY; +}; + +typedef struct { + kev_type type; /* see below */ + struct timeval time; /* timestamp */ + union { /* value associated with event */ + boolean_t up; /* MOUSE_LEFT .. MOUSE_RIGHT */ + Scancode sc; /* KEYBD_EVENT */ + struct mouse_motion mmotion; /* MOUSE_MOTION */ + } value; +} kd_event; + +/* + * kd_event ID's. + */ +#define MOUSE_LEFT 1 /* mouse left button up/down */ +#define MOUSE_MIDDLE 2 +#define MOUSE_RIGHT 3 +#define MOUSE_MOTION 4 /* mouse motion */ +#define KEYBD_EVENT 5 /* key up/down */ + +/*********************************************************************** + * Keyboard + **********************************************************************/ +static void +SoundKbdBell(InputInfoPtr pInfo, int loudness,int pitch,int duration) +{ + return; +} + +static void +SetKbdLeds(InputInfoPtr pInfo, int leds) +{ + return; +} + +static int +GetKbdLeds(InputInfoPtr pInfo) +{ + return 0; +} + +static void +SetKbdRepeat(InputInfoPtr pInfo, char rad) +{ + return; +} + +static void +KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap) +{ + pKeySyms->map = map; + pKeySyms->mapWidth = GLYPHS_PER_KEY; + pKeySyms->minKeyCode = MIN_KEYCODE; + pKeySyms->maxKeyCode = MAX_KEYCODE; + return; +} + +static int +KbdOn(InputInfoPtr pInfo, int what) +{ + int data = 1; + if( ioctl( pInfo->fd, _IOW('k', 1, int),&data) < 0) + FatalError("Cannot set event mode on keyboard (%s)\n",strerror(errno)); + return Success; +} +static int +KbdOff(InputInfoPtr pInfo, int what) +{ + int data = 2; + if( ioctl( pInfo->fd, _IOW('k', 1, int),&data) < 0) + FatalError("can't reset keyboard mode (%s)\n",strerror(errno)); + return Success; +} + +static int +KbdInit(InputInfoPtr pInfo, int what) +{ + return Success; +} + +static void +ReadInput(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + kd_event ke; + while( read(pInfo->fd, &ke, sizeof(ke)) == sizeof(ke) ) + pKbd->PostEvent(pInfo, ke.value.sc & 0x7f, ke.value.sc & 0x80 ? FALSE : TRUE); +} + +static Bool +OpenKeyboard(InputInfoPtr pInfo) +{ + pInfo->fd = xf86Info.consoleFd; + return TRUE; +} + +Bool +xf86OSKbdPreInit(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = pInfo->private; + + pKbd->KbdInit = KbdInit; + pKbd->KbdOn = KbdOn; + pKbd->KbdOff = KbdOff; + pKbd->Bell = SoundKbdBell; + pKbd->SetLeds = SetKbdLeds; + pKbd->GetLeds = GetKbdLeds; + pKbd->SetKbdRepeat = SetKbdRepeat; + pKbd->KbdGetMapping = KbdGetMapping; + pKbd->SpecialKey = NULL; + pKbd->RemapScanCode = ATScancode; + pKbd->GetSpecialKey = NULL; + pKbd->OpenKeyboard = OpenKeyboard; + pKbd->vtSwitchSupported = FALSE; + pKbd->CustomKeycodes = FALSE; + pKbd->private = NULL; + pInfo->read_input = ReadInput; + return TRUE; +} diff --git a/driver/xf86-input-keyboard/src/lnx_KbdMap.c b/driver/xf86-input-keyboard/src/lnx_KbdMap.c new file mode 100644 index 000000000..d5bec1c6f --- /dev/null +++ b/driver/xf86-input-keyboard/src/lnx_KbdMap.c @@ -0,0 +1,605 @@ +/* $XFree86$ */ + +/* + * Slightly modified xf86KbdLnx.c which is + * + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> +#include "input.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86Xinput.h" +#include "xf86OSKbd.h" +#include "atKeynames.h" + +#include "xf86Keymap.h" + +#include "lnx_kbd.h" + +/*ARGSUSED*/ + +/* + * KbdGetMapping -- + * Get the national keyboard mapping. The keyboard type is set, a new map + * and the modifiermap is computed. + */ + +static void readKernelMapping(InputInfoPtr pInfo, + KeySymsPtr pKeySyms, CARD8 *pModMap); +void +KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + KeySym *k; + char type; + int i; + + readKernelMapping(pInfo, pKeySyms, pModMap); + + /* + * compute the modifier map + */ + for (i = 0; i < MAP_LENGTH; i++) + pModMap[i] = NoSymbol; /* make sure it is restored */ + + for (k = map, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += 4) + + switch(*k) { + + case XK_Shift_L: + case XK_Shift_R: + pModMap[i] = ShiftMask; + break; + + case XK_Control_L: + case XK_Control_R: + pModMap[i] = ControlMask; + break; + + case XK_Caps_Lock: + pModMap[i] = LockMask; + break; + + case XK_Alt_L: + case XK_Alt_R: + pModMap[i] = AltMask; + break; + + case XK_Num_Lock: + pModMap[i] = NumLockMask; + break; + + case XK_Scroll_Lock: + pModMap[i] = ScrollLockMask; + break; + + /* kana support */ + case XK_Kana_Lock: + case XK_Kana_Shift: + pModMap[i] = KanaMask; + break; + + /* alternate toggle for multinational support */ + case XK_Mode_switch: + pModMap[i] = AltLangMask; + break; + + } + + pKbd->kbdType = ioctl(pInfo->fd, KDGKBTYPE, &type) != -1 ? type : KB_101; + + pKeySyms->map = map; + pKeySyms->mapWidth = GLYPHS_PER_KEY; + pKeySyms->minKeyCode = MIN_KEYCODE; + pKeySyms->maxKeyCode = MAX_KEYCODE; +} + +#include <linux/keyboard.h> + +static KeySym linux_to_x[256] = { + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_Escape, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_space, XK_exclam, XK_quotedbl, XK_numbersign, + XK_dollar, XK_percent, XK_ampersand, XK_apostrophe, + XK_parenleft, XK_parenright, XK_asterisk, XK_plus, + XK_comma, XK_minus, XK_period, XK_slash, + XK_0, XK_1, XK_2, XK_3, + XK_4, XK_5, XK_6, XK_7, + XK_8, XK_9, XK_colon, XK_semicolon, + XK_less, XK_equal, XK_greater, XK_question, + XK_at, XK_A, XK_B, XK_C, + XK_D, XK_E, XK_F, XK_G, + XK_H, XK_I, XK_J, XK_K, + XK_L, XK_M, XK_N, XK_O, + XK_P, XK_Q, XK_R, XK_S, + XK_T, XK_U, XK_V, XK_W, + XK_X, XK_Y, XK_Z, XK_bracketleft, + XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore, + XK_grave, XK_a, XK_b, XK_c, + XK_d, XK_e, XK_f, XK_g, + XK_h, XK_i, XK_j, XK_k, + XK_l, XK_m, XK_n, XK_o, + XK_p, XK_q, XK_r, XK_s, + XK_t, XK_u, XK_v, XK_w, + XK_x, XK_y, XK_z, XK_braceleft, + XK_bar, XK_braceright, XK_asciitilde, XK_BackSpace, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_nobreakspace,XK_exclamdown, XK_cent, XK_sterling, + XK_currency, XK_yen, XK_brokenbar, XK_section, + XK_diaeresis, XK_copyright, XK_ordfeminine, XK_guillemotleft, + XK_notsign, XK_hyphen, XK_registered, XK_macron, + XK_degree, XK_plusminus, XK_twosuperior, XK_threesuperior, + XK_acute, XK_mu, XK_paragraph, XK_periodcentered, + XK_cedilla, XK_onesuperior, XK_masculine, XK_guillemotright, + XK_onequarter, XK_onehalf, XK_threequarters,XK_questiondown, + XK_Agrave, XK_Aacute, XK_Acircumflex, XK_Atilde, + XK_Adiaeresis, XK_Aring, XK_AE, XK_Ccedilla, + XK_Egrave, XK_Eacute, XK_Ecircumflex, XK_Ediaeresis, + XK_Igrave, XK_Iacute, XK_Icircumflex, XK_Idiaeresis, + XK_ETH, XK_Ntilde, XK_Ograve, XK_Oacute, + XK_Ocircumflex, XK_Otilde, XK_Odiaeresis, XK_multiply, + XK_Ooblique, XK_Ugrave, XK_Uacute, XK_Ucircumflex, + XK_Udiaeresis, XK_Yacute, XK_THORN, XK_ssharp, + XK_agrave, XK_aacute, XK_acircumflex, XK_atilde, + XK_adiaeresis, XK_aring, XK_ae, XK_ccedilla, + XK_egrave, XK_eacute, XK_ecircumflex, XK_ediaeresis, + XK_igrave, XK_iacute, XK_icircumflex, XK_idiaeresis, + XK_eth, XK_ntilde, XK_ograve, XK_oacute, + XK_ocircumflex, XK_otilde, XK_odiaeresis, XK_division, + XK_oslash, XK_ugrave, XK_uacute, XK_ucircumflex, + XK_udiaeresis, XK_yacute, XK_thorn, XK_ydiaeresis +}; + +/* + * Maps the AT keycodes to Linux keycodes + */ +static unsigned char at2lnx[] = +{ + 0x01, /* KEY_Escape */ 0x02, /* KEY_1 */ + 0x03, /* KEY_2 */ 0x04, /* KEY_3 */ + 0x05, /* KEY_4 */ 0x06, /* KEY_5 */ + 0x07, /* KEY_6 */ 0x08, /* KEY_7 */ + 0x09, /* KEY_8 */ 0x0a, /* KEY_9 */ + 0x0b, /* KEY_0 */ 0x0c, /* KEY_Minus */ + 0x0d, /* KEY_Equal */ 0x0e, /* KEY_BackSpace */ + 0x0f, /* KEY_Tab */ 0x10, /* KEY_Q */ + 0x11, /* KEY_W */ 0x12, /* KEY_E */ + 0x13, /* KEY_R */ 0x14, /* KEY_T */ + 0x15, /* KEY_Y */ 0x16, /* KEY_U */ + 0x17, /* KEY_I */ 0x18, /* KEY_O */ + 0x19, /* KEY_P */ 0x1a, /* KEY_LBrace */ + 0x1b, /* KEY_RBrace */ 0x1c, /* KEY_Enter */ + 0x1d, /* KEY_LCtrl */ 0x1e, /* KEY_A */ + 0x1f, /* KEY_S */ 0x20, /* KEY_D */ + 0x21, /* KEY_F */ 0x22, /* KEY_G */ + 0x23, /* KEY_H */ 0x24, /* KEY_J */ + 0x25, /* KEY_K */ 0x26, /* KEY_L */ + 0x27, /* KEY_SemiColon */ 0x28, /* KEY_Quote */ + 0x29, /* KEY_Tilde */ 0x2a, /* KEY_ShiftL */ + 0x2b, /* KEY_BSlash */ 0x2c, /* KEY_Z */ + 0x2d, /* KEY_X */ 0x2e, /* KEY_C */ + 0x2f, /* KEY_V */ 0x30, /* KEY_B */ + 0x31, /* KEY_N */ 0x32, /* KEY_M */ + 0x33, /* KEY_Comma */ 0x34, /* KEY_Period */ + 0x35, /* KEY_Slash */ 0x36, /* KEY_ShiftR */ + 0x37, /* KEY_KP_Multiply */ 0x38, /* KEY_Alt */ + 0x39, /* KEY_Space */ 0x3a, /* KEY_CapsLock */ + 0x3b, /* KEY_F1 */ 0x3c, /* KEY_F2 */ + 0x3d, /* KEY_F3 */ 0x3e, /* KEY_F4 */ + 0x3f, /* KEY_F5 */ 0x40, /* KEY_F6 */ + 0x41, /* KEY_F7 */ 0x42, /* KEY_F8 */ + 0x43, /* KEY_F9 */ 0x44, /* KEY_F10 */ + 0x45, /* KEY_NumLock */ 0x46, /* KEY_ScrollLock */ + 0x47, /* KEY_KP_7 */ 0x48, /* KEY_KP_8 */ + 0x49, /* KEY_KP_9 */ 0x4a, /* KEY_KP_Minus */ + 0x4b, /* KEY_KP_4 */ 0x4c, /* KEY_KP_5 */ + 0x4d, /* KEY_KP_6 */ 0x4e, /* KEY_KP_Plus */ + 0x4f, /* KEY_KP_1 */ 0x50, /* KEY_KP_2 */ + 0x51, /* KEY_KP_3 */ 0x52, /* KEY_KP_0 */ + 0x53, /* KEY_KP_Decimal */ 0x54, /* KEY_SysReqest */ + 0x00, /* 0x55 */ 0x56, /* KEY_Less */ + 0x57, /* KEY_F11 */ 0x58, /* KEY_F12 */ + 0x66, /* KEY_Home */ 0x67, /* KEY_Up */ + 0x68, /* KEY_PgUp */ 0x69, /* KEY_Left */ + 0x5d, /* KEY_Begin */ 0x6a, /* KEY_Right */ + 0x6b, /* KEY_End */ 0x6c, /* KEY_Down */ + 0x6d, /* KEY_PgDown */ 0x6e, /* KEY_Insert */ + 0x6f, /* KEY_Delete */ 0x60, /* KEY_KP_Enter */ + 0x61, /* KEY_RCtrl */ 0x77, /* KEY_Pause */ + 0x63, /* KEY_Print */ 0x62, /* KEY_KP_Divide */ + 0x64, /* KEY_AltLang */ 0x65, /* KEY_Break */ + 0x00, /* KEY_LMeta */ 0x00, /* KEY_RMeta */ + 0x7A, /* KEY_Menu/FOCUS_PF11*/0x00, /* 0x6e */ + 0x7B, /* FOCUS_PF12 */ 0x00, /* 0x70 */ + 0x00, /* 0x71 */ 0x00, /* 0x72 */ + 0x59, /* FOCUS_PF2 */ 0x78, /* FOCUS_PF9 */ + 0x00, /* 0x75 */ 0x00, /* 0x76 */ + 0x5A, /* FOCUS_PF3 */ 0x5B, /* FOCUS_PF4 */ + 0x5C, /* FOCUS_PF5 */ 0x5D, /* FOCUS_PF6 */ + 0x5E, /* FOCUS_PF7 */ 0x5F, /* FOCUS_PF8 */ + 0x7C, /* JAP_86 */ 0x79, /* FOCUS_PF10 */ + 0x00, /* 0x7f */ +}; +#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0])) + +#define NUM_CUSTOMKEYS NR_KEYS + +static void +readKernelMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + KeySym *k; + int i; + int maxkey; + static unsigned char tbl[GLYPHS_PER_KEY] = + { + 0, /* unshifted */ + 1, /* shifted */ + 0, /* modeswitch unshifted */ + 0 /* modeswitch shifted */ + }; + + /* + * Read the mapping from the kernel. + * Since we're still using the XFree86 scancode->AT keycode mapping + * routines, we need to convert the AT keycodes to Linux keycodes, + * then translate the Linux keysyms into X keysyms. + * + * First, figure out which tables to use for the modeswitch columns + * above, from the XF86Config fields. + */ + tbl[2] = 8; /* alt */ + tbl[3] = tbl[2] | 1; + + if (pKbd->CustomKeycodes) { + k = map; + maxkey = NUM_CUSTOMKEYS; + } + else { + k = map+GLYPHS_PER_KEY; + maxkey = NUM_AT2LNX; + } + + for (i = 0; i < maxkey; ++i) + { + struct kbentry kbe; + int j; + + if (pKbd->CustomKeycodes) + kbe.kb_index = i; + else + kbe.kb_index = at2lnx[i]; + + for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k) + { + unsigned short kval; + + *k = NoSymbol; + + kbe.kb_table = tbl[j]; + if ( + (!pKbd->CustomKeycodes && kbe.kb_index == 0) || + ioctl(pInfo->fd, KDGKBENT, &kbe)) + continue; + + kval = KVAL(kbe.kb_value); + switch (KTYP(kbe.kb_value)) + { + case KT_LATIN: + case KT_LETTER: + *k = linux_to_x[kval]; + break; + + case KT_FN: + if (kval <= 19) + *k = XK_F1 + kval; + else switch (kbe.kb_value) + { + case K_FIND: + *k = XK_Home; /* or XK_Find */ + break; + case K_INSERT: + *k = XK_Insert; + break; + case K_REMOVE: + *k = XK_Delete; + break; + case K_SELECT: + *k = XK_End; /* or XK_Select */ + break; + case K_PGUP: + *k = XK_Prior; + break; + case K_PGDN: + *k = XK_Next; + break; + case K_HELP: + *k = XK_Help; + break; + case K_DO: + *k = XK_Execute; + break; + case K_PAUSE: + *k = XK_Pause; + break; + case K_MACRO: + *k = XK_Menu; + break; + default: + break; + } + break; + + case KT_SPEC: + switch (kbe.kb_value) + { + case K_ENTER: + *k = XK_Return; + break; + case K_BREAK: + *k = XK_Break; + break; + case K_CAPS: + *k = XK_Caps_Lock; + break; + case K_NUM: + *k = XK_Num_Lock; + break; + case K_HOLD: + *k = XK_Scroll_Lock; + break; + case K_COMPOSE: + *k = XK_Multi_key; + break; + default: + break; + } + break; + + case KT_PAD: + switch (kbe.kb_value) + { + case K_PPLUS: + *k = XK_KP_Add; + break; + case K_PMINUS: + *k = XK_KP_Subtract; + break; + case K_PSTAR: + *k = XK_KP_Multiply; + break; + case K_PSLASH: + *k = XK_KP_Divide; + break; + case K_PENTER: + *k = XK_KP_Enter; + break; + case K_PCOMMA: + *k = XK_KP_Separator; + break; + case K_PDOT: + *k = XK_KP_Decimal; + break; + case K_PPLUSMINUS: + *k = XK_KP_Subtract; + break; + default: + if (kval <= 9) + *k = XK_KP_0 + kval; + break; + } + break; + + /* + * KT_DEAD keys are for accelerated diacritical creation. + */ + case KT_DEAD: + switch (kbe.kb_value) + { + case K_DGRAVE: + *k = XK_dead_grave; + break; + case K_DACUTE: + *k = XK_dead_acute; + break; + case K_DCIRCM: + *k = XK_dead_circumflex; + break; + case K_DTILDE: + *k = XK_dead_tilde; + break; + case K_DDIERE: + *k = XK_dead_diaeresis; + break; + } + break; + + case KT_CUR: + switch (kbe.kb_value) + { + case K_DOWN: + *k = XK_Down; + break; + case K_LEFT: + *k = XK_Left; + break; + case K_RIGHT: + *k = XK_Right; + break; + case K_UP: + *k = XK_Up; + break; + } + break; + + case KT_SHIFT: + switch (kbe.kb_value) + { + case K_ALTGR: + *k = XK_Alt_R; + break; + case K_ALT: + *k = (kbe.kb_index == 0x64 ? + XK_Alt_R : XK_Alt_L); + break; + case K_CTRL: + *k = (kbe.kb_index == 0x61 ? + XK_Control_R : XK_Control_L); + break; + case K_CTRLL: + *k = XK_Control_L; + break; + case K_CTRLR: + *k = XK_Control_R; + break; + case K_SHIFT: + *k = (kbe.kb_index == 0x36 ? + XK_Shift_R : XK_Shift_L); + break; + case K_SHIFTL: + *k = XK_Shift_L; + break; + case K_SHIFTR: + *k = XK_Shift_R; + break; + default: + break; + } + break; + + /* + * KT_ASCII keys accumulate a 3 digit decimal number that gets + * emitted when the shift state changes. We can't emulate that. + */ + case KT_ASCII: + break; + + case KT_LOCK: + if (kbe.kb_value == K_SHIFTLOCK) + *k = XK_Shift_Lock; + break; + + default: + break; + } + } + + if (k[-1] == k[-2]) k[-1] = NoSymbol; + if (k[-2] == k[-3]) k[-2] = NoSymbol; + if (k[-3] == k[-4]) k[-3] = NoSymbol; + if (k[-4] == k[-2] && k[-3] == k[-1]) k[-2] = k[-1] = NoSymbol; + if (k[-1] == k[-4] && k[-2] == k[-3] && k[-2] == NoSymbol) k[-1] =NoSymbol; + } + + if (!pKbd->CustomKeycodes) + return; + + /* + * Find the Mapping for the special server functions + */ + pKbd->specialMap = (TransMapPtr) xcalloc(NUM_CUSTOMKEYS, 1); + if (pKbd->specialMap != NULL) { + pKbd->specialMap->end = NUM_CUSTOMKEYS; + pKbd->specialMap->map = (unsigned char*) xcalloc(NUM_CUSTOMKEYS, 1); + if (pKbd->specialMap == NULL) { + xfree(pKbd->specialMap); + pKbd->specialMap = NULL; + } + } + if (pKbd->specialMap == NULL) { + xf86Msg(X_ERROR, "%s can't allocate \"special map\"\n", pInfo->name); + return; + } + + for (i = 0; i < NUM_CUSTOMKEYS; ++i) { + struct kbentry kbe; + int special = 0; + + kbe.kb_index = i; + kbe.kb_table = 0; /* Plain map */ + if (!ioctl(pInfo->fd, KDGKBENT, &kbe)) + switch (kbe.kb_value) { + case K(KT_LATIN,0x7f): /* This catches DEL too... But who cares? */ + special = KEY_BackSpace; + break; + case K_PMINUS: + special = KEY_KP_Minus; + break; + case K_PPLUS: + special = KEY_KP_Plus; + break; + case K_F1: + special = KEY_F1; + break; + case K_F2: + special = KEY_F2; + break; + case K_F3: + special = KEY_F3; + break; + case K_F4: + special = KEY_F4; + break; + case K_F5: + special = KEY_F5; + break; + case K_F6: + special = KEY_F6; + break; + case K_F7: + special = KEY_F7; + break; + case K_F8: + special = KEY_F8; + break; + case K_F9: + special = KEY_F9; + break; + case K_F10: + special = KEY_F10; + break; + case K_F11: + special = KEY_F11; + break; + case K_F12: + special = KEY_F12; + break; + case K_ALT: + special = KEY_Alt; + break; + case K_ALTGR: + special = KEY_AltLang; + break; + case K_CONS: + special = KEY_SysReqest; + break; + } + pKbd->specialMap->map[i] = special; + } +} diff --git a/driver/xf86-input-keyboard/src/lnx_kbd.c b/driver/xf86-input-keyboard/src/lnx_kbd.c new file mode 100644 index 000000000..d3f29e55b --- /dev/null +++ b/driver/xf86-input-keyboard/src/lnx_kbd.c @@ -0,0 +1,484 @@ + +/* + * Copyright (c) 2002 by The XFree86 Project, Inc. + * Author: Ivan Pascal. + * + * Based on the code from lnx_io.c which is + * Copyright 1992 by Orest Zborowski <obz@Kodak.com> + * Copyright 1993 by David Dawes <dawes@xfree86.org> + * + * Portions based on kbdrate.c from util-linux 2.9t, which is + * Copyright 1992 Rickard E. Faith. Distributed under the GPL. + * This program comes with ABSOLUTELY NO WARRANTY. + */ + +#define NEED_EVENTS + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <X11/X.h> + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" + +#include "xf86Xinput.h" +#include "xf86OSKbd.h" +#include "atKeynames.h" +#include "lnx_kbd.h" + +#define KBC_TIMEOUT 250 /* Timeout in ms for sending to keyboard controller */ + +static KbdProtocolRec protocols[] = { + {"standard", PROT_STD }, + { NULL, PROT_UNKNOWN_KBD } +}; + +extern Bool VTSwitchEnabled; + +static void +SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration) +{ + if (loudness && pitch) + { + ioctl(pInfo->fd, KDMKTONE, + ((1193190 / pitch) & 0xffff) | + (((unsigned long)duration * + loudness / 50) << 16)); + } +} + +static void +SetKbdLeds(InputInfoPtr pInfo, int leds) +{ + int real_leds = 0; + +#if defined (__sparc__) + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + if (pKbd->sunKbd) { + if (leds & 0x08) real_leds |= XLED1; + if (leds & 0x04) real_leds |= XLED3; + if (leds & 0x02) real_leds |= XLED4; + if (leds & 0x01) real_leds |= XLED2; + leds = real_leds; + real_leds = 0; + } +#endif /* defined (__sparc__) */ +#ifdef LED_CAP + if (leds & XLED1) real_leds |= LED_CAP; + if (leds & XLED2) real_leds |= LED_NUM; + if (leds & XLED3) real_leds |= LED_SCR; +#ifdef LED_COMP + if (leds & XLED4) real_leds |= LED_COMP; +#else + if (leds & XLED4) real_leds |= LED_SCR; +#endif +#endif + ioctl(pInfo->fd, KDSETLED, real_leds); +} + +static int +GetKbdLeds(InputInfoPtr pInfo) +{ + int real_leds, leds = 0; + + ioctl(pInfo->fd, KDGETLED, &real_leds); + + if (real_leds & LED_CAP) leds |= XLED1; + if (real_leds & LED_NUM) leds |= XLED2; + if (real_leds & LED_SCR) leds |= XLED3; + + return(leds); +} + +static int +KDKBDREP_ioctl_ok(int rate, int delay) { +#if defined(KDKBDREP) && !defined(__sparc__) + /* This ioctl is defined in <linux/kd.h> but is not + implemented anywhere - must be in some m68k patches. */ + struct kbd_repeat kbdrep_s; + + /* don't change, just test */ + kbdrep_s.LNX_KBD_PERIOD_NAME = -1; + kbdrep_s.delay = -1; + if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) { + return 0; + } + + /* do the change */ + if (rate == 0) /* switch repeat off */ + kbdrep_s.LNX_KBD_PERIOD_NAME = 0; + else + kbdrep_s.LNX_KBD_PERIOD_NAME = 10000 / rate; /* convert cps to msec */ + if (kbdrep_s.LNX_KBD_PERIOD_NAME < 1) + kbdrep_s.LNX_KBD_PERIOD_NAME = 1; + kbdrep_s.delay = delay; + if (kbdrep_s.delay < 1) + kbdrep_s.delay = 1; + + if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) { + return 0; + } + + return 1; /* success! */ +#else /* no KDKBDREP */ + return 0; +#endif /* KDKBDREP */ +} + +static int +KIOCSRATE_ioctl_ok(int rate, int delay) { +#ifdef KIOCSRATE + struct kbd_rate kbdrate_s; + int fd; + + fd = open("/dev/kbd", O_RDONLY); + if (fd == -1) + return 0; + + kbdrate_s.rate = (rate + 5) / 10; /* must be integer, so round up */ + kbdrate_s.delay = delay * HZ / 1000; /* convert ms to Hz */ + if (kbdrate_s.rate > 50) + kbdrate_s.rate = 50; + + if (ioctl( fd, KIOCSRATE, &kbdrate_s )) { + return 0; + } + + close( fd ); + + return 1; +#else /* no KIOCSRATE */ + return 0; +#endif /* KIOCSRATE */ +} + +#undef rate + +static void +SetKbdRepeat(InputInfoPtr pInfo, char rad) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + int i; + int timeout; + int value = 0x7f; /* Maximum delay with slowest rate */ + +#ifdef __sparc__ + int rate = 500; /* Default rate */ + int delay = 200; /* Default delay */ +#else + int rate = 300; /* Default rate */ + int delay = 250; /* Default delay */ +#endif + + static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150, + 133, 120, 109, 100, 92, 86, 80, 75, 67, + 60, 55, 50, 46, 43, 40, 37, 33, 30, 27, + 25, 23, 21, 20 }; +#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int )) + + static int valid_delays[] = { 250, 500, 750, 1000 }; +#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int )) + + if (pKbd->rate >= 0) + rate = pKbd->rate * 10; + if (pKbd->delay >= 0) + delay = pKbd->delay; + + if(KDKBDREP_ioctl_ok(rate, delay)) /* m68k? */ + return; + + if(KIOCSRATE_ioctl_ok(rate, delay)) /* sparc? */ + return; + + if (xf86IsPc98()) + return; + +#if defined(__alpha__) || defined (__i386__) || defined(__ia64__) + + if (!xorgHWAccess) { + if (xf86EnableIO()) + xorgHWAccess = TRUE; + else + return; + } + + /* The ioport way */ + + for (i = 0; i < RATE_COUNT; i++) + if (rate >= valid_rates[i]) { + value &= 0x60; + value |= i; + break; + } + + for (i = 0; i < DELAY_COUNT; i++) + if (delay <= valid_delays[i]) { + value &= 0x1f; + value |= i << 5; + break; + } + + timeout = KBC_TIMEOUT; + while (((inb(0x64) & 2) == 2) && --timeout) + usleep(1000); /* wait */ + + if (timeout == 0) + return; + + outb(0x60, 0xf3); /* set typematic rate */ + while (((inb(0x64) & 2) == 2) && --timeout) + usleep(1000); /* wait */ + + usleep(10000); + outb(0x60, value); + +#endif /* __alpha__ || __i386__ || __ia64__ */ +} + +typedef struct { + int kbdtrans; + struct termios kbdtty; +} LnxKbdPrivRec, *LnxKbdPrivPtr; + +static int +KbdInit(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private; + + if (pKbd->isConsole) { + ioctl (pInfo->fd, KDGKBMODE, &(priv->kbdtrans)); + tcgetattr (pInfo->fd, &(priv->kbdtty)); + } + if (!pKbd->CustomKeycodes) { + pKbd->RemapScanCode = ATScancode; + } + + return Success; +} + +static int +KbdOn(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private; + struct termios nTty; + + if (pKbd->isConsole) { + if (pKbd->CustomKeycodes) + ioctl(pInfo->fd, KDSKBMODE, K_MEDIUMRAW); + else + ioctl(pInfo->fd, KDSKBMODE, K_RAW); + + nTty = priv->kbdtty; + nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); + nTty.c_oflag = 0; + nTty.c_cflag = CREAD | CS8; + nTty.c_lflag = 0; + nTty.c_cc[VTIME]=0; + nTty.c_cc[VMIN]=1; + cfsetispeed(&nTty, 9600); + cfsetospeed(&nTty, 9600); + tcsetattr(pInfo->fd, TCSANOW, &nTty); + } + return Success; +} + +static int +KbdOff(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private; + + if (pKbd->isConsole) { + ioctl(pInfo->fd, KDSKBMODE, priv->kbdtrans); + tcsetattr(pInfo->fd, TCSANOW, &(priv->kbdtty)); + } + return Success; +} + +static int +GetSpecialKey(InputInfoPtr pInfo, int scanCode) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + int specialkey = scanCode; + +#if defined (__sparc__) + if (pKbd->sunKbd) { + switch (scanCode) { + case 0x2b: specialkey = KEY_BackSpace; break; + case 0x47: specialkey = KEY_KP_Minus; break; + case 0x7d: specialkey = KEY_KP_Plus; break; + /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */ + case 0x05: specialkey = KEY_F1; break; + case 0x06: specialkey = KEY_F2; break; + case 0x08: specialkey = KEY_F3; break; + case 0x0a: specialkey = KEY_F4; break; + case 0x0c: specialkey = KEY_F5; break; + case 0x0e: specialkey = KEY_F6; break; + case 0x10: specialkey = KEY_F7; break; + case 0x11: specialkey = KEY_F8; break; + case 0x12: specialkey = KEY_F9; break; + case 0x07: specialkey = KEY_F10; break; + case 0x09: specialkey = KEY_F11; break; + case 0x0b: specialkey = KEY_F12; break; + default: specialkey = 0; break; + } + return specialkey; + } +#endif + + if (pKbd->CustomKeycodes) { + specialkey = pKbd->specialMap->map[scanCode]; + } + return specialkey; +} + +#define ModifierSet(k) ((modifiers & (k)) == (k)) + +static +Bool SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + + if(!pKbd->vtSwitchSupported) + return FALSE; + + if ((ModifierSet(ControlMask | AltMask)) || + (ModifierSet(ControlMask | AltLangMask))) { + if (VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch) { + switch (key) { + case KEY_F1: + case KEY_F2: + case KEY_F3: + case KEY_F4: + case KEY_F5: + case KEY_F6: + case KEY_F7: + case KEY_F8: + case KEY_F9: + case KEY_F10: + if (down) { + ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1); + return TRUE; + } + case KEY_F11: + case KEY_F12: + if (down) { + ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11); + return TRUE; + } + } + } + } + return FALSE; +} + +static void +stdReadInput(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + unsigned char rBuf[64]; + int nBytes, i; + if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) { + for (i = 0; i < nBytes; i++) + pKbd->PostEvent(pInfo, rBuf[i] & 0x7f, + rBuf[i] & 0x80 ? FALSE : TRUE); + } +} + +static Bool +OpenKeyboard(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + int i; + KbdProtocolId prot = PROT_UNKNOWN_KBD; + char *s; + + s = xf86SetStrOption(pInfo->options, "Protocol", NULL); + for (i = 0; protocols[i].name; i++) { + if (xf86NameCmp(s, protocols[i].name) == 0) { + prot = protocols[i].id; + break; + } + } + + switch (prot) { + case PROT_STD: + pInfo->read_input = stdReadInput; + break; + default: + xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s); + xfree(s); + return FALSE; + } + + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s); + xfree(s); + + s = xf86SetStrOption(pInfo->options, "Device", NULL); + if (s == NULL) { + pInfo->fd = xf86Info.consoleFd; + pKbd->isConsole = TRUE; + } else { + pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL); + if (pInfo->fd == -1) { + xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s); + xfree(s); + return FALSE; + } + pKbd->isConsole = FALSE; + xfree(s); + } + + if (pKbd->isConsole) + pKbd->vtSwitchSupported = TRUE; + + return TRUE; +} + +_X_EXPORT Bool +xf86OSKbdPreInit(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = pInfo->private; + + pKbd->KbdInit = KbdInit; + pKbd->KbdOn = KbdOn; + pKbd->KbdOff = KbdOff; + pKbd->Bell = SoundBell; + pKbd->SetLeds = SetKbdLeds; + pKbd->GetLeds = GetKbdLeds; + pKbd->SetKbdRepeat = SetKbdRepeat; + pKbd->KbdGetMapping = KbdGetMapping; + pKbd->SpecialKey = SpecialKey; + + pKbd->RemapScanCode = NULL; + pKbd->GetSpecialKey = GetSpecialKey; + + pKbd->OpenKeyboard = OpenKeyboard; + pKbd->vtSwitchSupported = FALSE; + + pKbd->private = xcalloc(sizeof(LnxKbdPrivRec), 1); + if (pKbd->private == NULL) { + xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n"); + return FALSE; + } + +#if defined(__powerpc__) + { + FILE *f; + f = fopen("/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes","r"); + if (f) { + if (fgetc(f) == '0') + pKbd->CustomKeycodes = TRUE; + fclose(f); + } + } +#endif + return TRUE; +} diff --git a/driver/xf86-input-keyboard/src/lnx_kbd.h b/driver/xf86-input-keyboard/src/lnx_kbd.h new file mode 100644 index 000000000..ac783bfbc --- /dev/null +++ b/driver/xf86-input-keyboard/src/lnx_kbd.h @@ -0,0 +1,5 @@ +/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kbd.h,v 1.1 2002/10/11 01:40:35 dawes Exp $ */ + +extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms, + CARD8 *pModMap); + diff --git a/driver/xf86-input-keyboard/src/sco_KbdMap.c b/driver/xf86-input-keyboard/src/sco_KbdMap.c new file mode 100644 index 000000000..6efe96be3 --- /dev/null +++ b/driver/xf86-input-keyboard/src/sco_KbdMap.c @@ -0,0 +1,308 @@ +/* $XFree86$ */ +/* + * Copyright 2005 by J. Kean Johnston <jkj@sco.com> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name J. Kean Johnston not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. J. Kean Johnston makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Based on xf86KbdMap.c, which is + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * Copyright (c) 1992-2003 by The XFree86 Project, Inc. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> +#include "input.h" +#include "scrnintstr.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86Xinput.h" +#include "xf86OSKbd.h" +#include "atKeynames.h" +#include "xf86Keymap.h" + +#include "sco_kbd.h" + +#define KD_GET_ENTRY(i,n) \ + eascii_to_x[((priv->keymap.key[i].spcl << (n+1)) & 0x100) + priv->keymap.key[i].map[n]] + +/* + * NOTE: Not all possible remappable symbols are remapped. There are two main + * reasons: + * a) The mapping between scancode and SYSV/386 - symboltable + * is inconsistent between different versions and has some + * BIG mistakes. + * b) In X-Windows there is a difference between numpad-keys + * and normal keys. SYSV/386 uses for both kinds of keys + * the same symbol. + * + * Thus only the alpha keypad and the function keys are translated. + * Also CapsLock, NumLock, ScrollLock, Shift, Control & Alt. + */ + +static unsigned char remap[128] = { + 0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, /* 0x00 - 0x07 */ + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, /* 0x08 - 0x0f */ + 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, /* 0x10 - 0x17 */ + 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, /* 0x18 - 0x1f */ + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, /* 0x20 - 0x27 */ + 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, /* 0x28 - 0x2f */ + 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0, /* 0x30 - 0x37 */ + 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, /* 0x38 - 0x3f */ + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0, /* 0x40 - 0x47 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x48 - 0x4f */ + 0, 0, 0, 0, 0, 0, 0x56, 0x57, /* 0x50 - 0x57 */ + 0x58, 0, 0, 0, 0, 0, 0, 0, /* 0x58 - 0x5f */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 - 0x67 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68 - 0x6f */ + 0, 0, 0x69, 0x65, 0, 0, 0, 0, /* 0x70 - 0x77 */ + 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78 - 0x7f */ +}; + +static KeySym eascii_to_x[512] = { + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_BackSpace, XK_Tab, XK_Linefeed, NoSymbol, + NoSymbol, XK_Return, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_Escape, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_space, XK_exclam, XK_quotedbl, XK_numbersign, + XK_dollar, XK_percent, XK_ampersand, XK_apostrophe, + XK_parenleft, XK_parenright, XK_asterisk, XK_plus, + XK_comma, XK_minus, XK_period, XK_slash, + XK_0, XK_1, XK_2, XK_3, + XK_4, XK_5, XK_6, XK_7, + XK_8, XK_9, XK_colon, XK_semicolon, + XK_less, XK_equal, XK_greater, XK_question, + XK_at, XK_A, XK_B, XK_C, + XK_D, XK_E, XK_F, XK_G, + XK_H, XK_I, XK_J, XK_K, + XK_L, XK_M, XK_N, XK_O, + XK_P, XK_Q, XK_R, XK_S, + XK_T, XK_U, XK_V, XK_W, + XK_X, XK_Y, XK_Z, XK_bracketleft, + XK_backslash, XK_bracketright,XK_asciicircum, XK_underscore, + XK_grave, XK_a, XK_b, XK_c, + XK_d, XK_e, XK_f, XK_g, + XK_h, XK_i, XK_j, XK_k, + XK_l, XK_m, XK_n, XK_o, + XK_p, XK_q, XK_r, XK_s, + XK_t, XK_u, XK_v, XK_w, + XK_x, XK_y, XK_z, XK_braceleft, + XK_bar, XK_braceright, XK_asciitilde, XK_Delete, + XK_Ccedilla, XK_udiaeresis, XK_eacute, XK_acircumflex, + XK_adiaeresis, XK_agrave, XK_aring, XK_ccedilla, + XK_ecircumflex, XK_ediaeresis, XK_egrave, XK_idiaeresis, + XK_icircumflex, XK_igrave, XK_Adiaeresis, XK_Aring, + XK_Eacute, XK_ae, XK_AE, XK_ocircumflex, + XK_odiaeresis, XK_ograve, XK_ucircumflex, XK_ugrave, + XK_ydiaeresis, XK_Odiaeresis, XK_Udiaeresis, XK_cent, + XK_sterling, XK_yen, XK_paragraph, XK_section, + XK_aacute, XK_iacute, XK_oacute, XK_uacute, + XK_ntilde, XK_Ntilde, XK_ordfeminine, XK_masculine, + XK_questiondown,XK_hyphen, XK_notsign, XK_onehalf, + XK_onequarter, XK_exclamdown, XK_guillemotleft,XK_guillemotright, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + XK_Greek_alpha, XK_ssharp, XK_Greek_GAMMA, XK_Greek_pi, + XK_Greek_SIGMA, XK_Greek_sigma, XK_mu, XK_Greek_tau, + XK_Greek_PHI, XK_Greek_THETA, XK_Greek_OMEGA, XK_Greek_delta, + XK_infinity, XK_Ooblique, XK_Greek_epsilon, XK_intersection, + XK_identical, XK_plusminus, XK_greaterthanequal, XK_lessthanequal, + XK_topintegral, XK_botintegral, XK_division, XK_similarequal, + XK_degree, NoSymbol, NoSymbol, XK_radical, + XK_Greek_eta, XK_twosuperior, XK_periodcentered, NoSymbol, + + /* + * special marked entries (256 + x) + */ + + NoSymbol, NoSymbol, XK_Shift_L, XK_Shift_R, + XK_Caps_Lock, XK_Num_Lock, XK_Scroll_Lock, XK_Alt_L, + NoSymbol, XK_Control_L, XK_Alt_L, XK_Alt_R, + XK_Control_L, XK_Control_R, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, XK_F1, + XK_F2, XK_F3, XK_F4, XK_F5, + XK_F6, XK_F7, XK_F8, XK_F9, + XK_F10, XK_F11, XK_F12, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, + }; + +/* + * KbdGetMapping -- + * Get the national keyboard mapping. The keyboard type is set, a new map + * and the modifiermap is computed. + */ + +void +KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private; + KeySym *k; + int i; + KeySym *pMap = map; + + for (i = 0; i < priv->keymap.n_keys && i < NUM_KEYCODES; i++) { + if (remap[i]) { + k = pMap + (remap[i] << 2); + + k[0] = KD_GET_ENTRY(i,0); /* non-shifed */ + k[1] = KD_GET_ENTRY(i,1); /* shifted */ + k[2] = KD_GET_ENTRY(i,4); /* alt */ + k[3] = KD_GET_ENTRY(i,5); /* alt - shifted */ + + if (k[3] == k[2]) k[3] = NoSymbol; + if (k[2] == k[1]) k[2] = NoSymbol; + if (k[1] == k[0]) k[1] = NoSymbol; + if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol; + } + } + + /* + * compute the modifier map + */ + for (i = 0; i < MAP_LENGTH; i++) + pModMap[i] = NoSymbol; /* make sure it is restored */ + + for (k = pMap, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += GLYPHS_PER_KEY) { + + switch(*k) { + case XK_Shift_L: + case XK_Shift_R: + pModMap[i] = ShiftMask; + break; + + case XK_Control_L: + case XK_Control_R: + pModMap[i] = ControlMask; + break; + + case XK_Caps_Lock: + pModMap[i] = LockMask; + break; + + case XK_Alt_L: + case XK_Alt_R: + pModMap[i] = AltMask; + break; + + case XK_Num_Lock: + pModMap[i] = NumLockMask; + break; + + case XK_Scroll_Lock: + pModMap[i] = ScrollLockMask; + break; + + /* kana support */ + case XK_Kana_Lock: + case XK_Kana_Shift: + pModMap[i] = KanaMask; + break; + + /* alternate toggle for multinational support */ + case XK_Mode_switch: + pModMap[i] = AltLangMask; + break; + } + } + + pKeySyms->map = pMap; + pKeySyms->mapWidth = GLYPHS_PER_KEY; + pKeySyms->minKeyCode = MIN_KEYCODE; + pKeySyms->maxKeyCode = MAX_KEYCODE; +} diff --git a/driver/xf86-input-keyboard/src/sco_kbd.c b/driver/xf86-input-keyboard/src/sco_kbd.c new file mode 100644 index 000000000..b6731c703 --- /dev/null +++ b/driver/xf86-input-keyboard/src/sco_kbd.c @@ -0,0 +1,485 @@ +/* $XFree86$ */ +/* + * Copyright 2005 by J. Kean Johnston <jkj@sco.com> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name J. Kean Johnston not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. J. Kean Johnston makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF + * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ +/* $XConsortium$ */ + +/* + * Based on sco_io.c which is + * (C) Copyright 2003 J. Kean Johnston <jkj@sco.com> + * + * Based on lnx_kbd.c which is + * Copyright (c) 2002 by The XFree86 Project, Inc. + * + * Based on the code from lnx_io.c which is + * Copyright 1992 by Orest Zborowski <obz@Kodak.com> + * Copyright 1993 by David Dawes <dawes@xfree86.org> + */ + +#define NEED_EVENTS + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <X11/X.h> + +#include "compiler.h" + +#define _NEED_SYSI86 +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86OSpriv.h" +#include "xf86_OSlib.h" + +#include "xf86Xinput.h" +#include "xf86OSKbd.h" +#include "atKeynames.h" +#include "sco_kbd.h" + +#include <sys/param.h> +#include <sys/emap.h> +#include <sys/nmap.h> + +static KbdProtocolRec protocols[] = { + { "standard", PROT_STD }, + { NULL, PROT_UNKNOWN_KBD } +}; + +extern Bool VTSwitchEnabled; + +static void +SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration) +{ + if (loudness && pitch) { + ioctl(pInfo->fd, KIOCSOUND, 1193180 / pitch); + usleep(duration * loudness * 20); + ioctl(pInfo->fd, KIOCSOUND, 0); + } +} + +static void +SetKbdLeds(InputInfoPtr pInfo, int leds) +{ + int real_leds = 0; + static int once = 1; + + /* + * sleep the first time through under SCO. There appears to be a + * timing problem in the driver which causes the keyboard to be lost. + * This usleep stops it from occurring. NOTE: this was in the old code. + * I am not convinced it is true any longer, but it doesn't hurt to + * leave this in here. + */ + if (once) { + usleep(100); + once = 0; + } + +#ifdef LED_CAP + if (leds & XLED1) + real_leds |= LED_CAP; + if (leds & XLED2) + real_leds |= LED_NUM; + if (leds & XLED3) + real_leds |= LED_SCR; +#ifdef LED_COMP + if (leds & XLED4) + real_leds |= LED_COMP; +#else + if (leds & XLED4) + real_leds |= LED_SCR; +#endif +#endif + ioctl(pInfo->fd, KDSETLED, real_leds); +} + +static int +GetKbdLeds(InputInfoPtr pInfo) +{ + int real_leds, leds = 0; + + ioctl(pInfo->fd, KDGETLED, &real_leds); + + if (real_leds & LED_CAP) leds |= XLED1; + if (real_leds & LED_NUM) leds |= XLED2; + if (real_leds & LED_SCR) leds |= XLED3; + + return(leds); +} + +/* + * NOTE: Only OpenServer Release 5.0.6 with Release Supplement 5.0.6A + * and later have the required ioctl. 5.0.6A or higher is HIGHLY + * recommended. The console driver is quite a different beast on that OS. + */ +#undef rate + +static void +SetKbdRepeat(InputInfoPtr pInfo, char rad) +{ +#if defined(KBIO_SETRATE) + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + int i; + int value = 0x7f; /* Maximum delay with slowest rate */ + int delay = 250; /* Default delay */ + int rate = 300; /* Default repeat rate */ + + static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150, + 133, 120, 109, 100, 92, 86, 80, 75, 67, + 60, 55, 50, 46, 43, 40, 37, 33, 30, 27, + 25, 23, 21, 20 }; +#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int )) + + static int valid_delays[] = { 250, 500, 750, 1000 }; +#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int )) + + if (pKbd->rate >= 0) + rate = pKbd->rate * 10; + if (pKbd->delay >= 0) + delay = pKbd->delay; + + for (i = 0; i < RATE_COUNT; i++) + if (rate >= valid_rates[i]) { + value &= 0x60; + value |= i; + break; + } + + for (i = 0; i < DELAY_COUNT; i++) + if (delay <= valid_delays[i]) { + value &= 0x1f; + value |= i << 5; + break; + } + + ioctl (pInfo->fd, KBIO_SETRATE, value); +#endif /* defined(KBIO_SETRATE) */ +} + +static int +KbdInit(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private; + + if (pKbd->isConsole) { + priv->use_tcs = 1; + priv->use_kd = 1; + priv->no_nmap = 1; + priv->no_emap = 1; + priv->orig_getsc = 0; + + if (ioctl (pInfo->fd, TCGETSC, &priv->orig_getsc) < 0) + priv->use_tcs = 0; + if (ioctl (pInfo->fd, KDGKBMODE, &priv->orig_kbm) < 0) + priv->use_kd = 0; + + if (!priv->use_tcs && !priv->use_kd) { + xf86Msg (X_ERROR, "KbdInit: Could not determine keyboard mode\n"); + return !Success; + } + + /* + * One day this should be fixed to translate normal ASCII characters + * back into scancodes or into events that XFree86 wants, but not + * now. For the time being, we only support scancode mode screens. + */ + if (priv->use_tcs && !(priv->orig_getsc & KB_ISSCANCODE)) { + xf86Msg (X_ERROR, "KbdInit: Keyboard can not send scancodes\n"); + return !Success; + } + + /* + * We need to get the original keyboard map and NUL out the lock + * modifiers. This prevents the scancode API from messing with + * the keyboard LED's. We restore the original map when we exit. + */ + if (ioctl (pInfo->fd, GIO_KEYMAP, &priv->keymap) < 0) { + xf86Msg (X_ERROR, "KbdInit: Failed to get keyboard map (%s)\n", + strerror(errno)); + return !Success; + } + if (ioctl (pInfo->fd, GIO_KEYMAP, &priv->noledmap) < 0) { + xf86Msg (X_ERROR, "KbdInit: Failed to get keyboard map (%s)\n", + strerror(errno)); + return !Success; + } else { + int i, j; + + for (i = 0; i < priv->noledmap.n_keys; i++) { + for (j = 0; j < NUM_STATES; j++) { + if (IS_SPECIAL(priv->noledmap, i, j) && + ((priv->noledmap.key[i].map[j] == K_CLK) || + (priv->noledmap.key[i].map[j] == K_NLK) || + (priv->noledmap.key[i].map[j] == K_SLK))) { + priv->noledmap.key[i].map[j] = K_NOP; + } + } + } + } + + if (ioctl (pInfo->fd, XCGETA, &priv->kbdtty) < 0) { + xf86Msg (X_ERROR, "KbdInit: Failed to get terminal modes (%s)\n", + strerror(errno)); + return !Success; + } + + priv->sc_mapbuf = xalloc (10*BSIZE); + priv->sc_mapbuf2 = xalloc(10*BSIZE); + + /* Get the emap */ + if (ioctl (pInfo->fd, LDGMAP, priv->sc_mapbuf) < 0) { + if (errno != ENAVAIL) { + xf86Msg (X_ERROR, "KbdInit: Failed to retrieve e-map (%s)\n", + strerror (errno)); + return !Success; + } + priv->no_emap = 0; + } + + /* Get the nmap */ + if (ioctl (pInfo->fd, NMGMAP, priv->sc_mapbuf2) < 0) { + if (errno != ENAVAIL) { + xf86Msg (X_ERROR, "KbdInit: Failed to retrieve n-map (%s)\n", + strerror (errno)); + return !Success; + } + priv->no_nmap = 0; + } + } /* End of if we are on a console */ + + return Success; +} + +static int +KbdOn(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private; + struct termios newtio; + + if (pKbd->isConsole) { + ioctl (pInfo->fd, LDNMAP); /* Turn e-mapping off */ + ioctl (pInfo->fd, NMNMAP); /* Turn n-mapping off */ + + newtio = priv->kbdtty; /* structure copy */ + newtio.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP); + newtio.c_oflag = 0; + newtio.c_cflag = CREAD | CS8 | B9600; + newtio.c_lflag = 0; + newtio.c_cc[VTIME]=0; + newtio.c_cc[VMIN]=1; + cfsetispeed(&newtio, 9600); + cfsetospeed(&newtio, 9600); + ioctl(pInfo->fd, XCSETA, &newtio); + + /* Now tell the keyboard driver to send us raw scancodes */ + if (priv->use_tcs) { + int nm = priv->orig_getsc; + nm &= ~KB_XSCANCODE; + ioctl (pInfo->fd, TCSETSC, &nm); + } + + if (priv->use_kd) + ioctl (pInfo->fd, KDSKBMODE, K_RAW); + + ioctl (pInfo->fd, PIO_KEYMAP, &priv->noledmap); + } + + return Success; +} + +static int +KbdOff(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private; + + if (pKbd->isConsole) { + /* Revert back to original translate scancode mode */ + if (priv->use_tcs) + ioctl (pInfo->fd, TCSETSC, &priv->orig_getsc); + if (priv->use_kd) + ioctl (pInfo->fd, KDSKBMODE, priv->orig_kbm); + + ioctl (pInfo->fd, PIO_KEYMAP, &priv->keymap); + + if (priv->no_emap) + ioctl (pInfo->fd, LDSMAP, priv->sc_mapbuf); + if (priv->no_nmap) + ioctl (pInfo->fd, NMSMAP, priv->sc_mapbuf2); + + ioctl(pInfo->fd, XCSETA, &priv->kbdtty); + } + + return Success; +} + +static int +GetSpecialKey(InputInfoPtr pInfo, int scanCode) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + int specialkey = scanCode; + + if (pKbd->CustomKeycodes) { + specialkey = pKbd->specialMap->map[scanCode]; + } + return specialkey; +} + +#define ModifierSet(k) ((modifiers & (k)) == (k)) + +static Bool +SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + + if(!pKbd->vtSwitchSupported) + return FALSE; + + if ((!ModifierSet(ShiftMask)) && ((ModifierSet(ControlMask | AltMask)) || + (ModifierSet(ControlMask | AltLangMask)))) { + if (VTSwitchEnabled && !xf86Info.vtSysreq) { + switch (key) { + case KEY_F1: + case KEY_F2: + case KEY_F3: + case KEY_F4: + case KEY_F5: + case KEY_F6: + case KEY_F7: + case KEY_F8: + case KEY_F9: + case KEY_F10: + if (down) { + int sts = key - KEY_F1; + if (sts != xf86Info.vtno) { + ioctl(pInfo->fd, VT_ACTIVATE, sts); + } + return TRUE; + } + case KEY_F11: + case KEY_F12: + if (down) { + int sts = key - KEY_F11 + 10; + if (sts != xf86Info.vtno) { + ioctl(pInfo->fd, VT_ACTIVATE, sts); + } + return TRUE; + } + } + } + } + return FALSE; +} + +static void +stdReadInput(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + unsigned char rBuf[64]; + int nBytes, i; + + if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) { + for (i = 0; i < nBytes; i++) { + pKbd->PostEvent(pInfo, rBuf[i] & 0x7f, rBuf[i] & 0x80 ? FALSE : TRUE); + } + } +} + +static Bool +OpenKeyboard(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + int i; + KbdProtocolId prot = PROT_UNKNOWN_KBD; + char *s; + + s = xf86SetStrOption(pInfo->options, "Protocol", NULL); + for (i = 0; protocols[i].name; i++) { + if (xf86NameCmp(s, protocols[i].name) == 0) { + prot = protocols[i].id; + break; + } + } + + switch (prot) { + case PROT_STD: + pInfo->read_input = stdReadInput; + break; + default: + xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s); + xfree(s); + return FALSE; + } + + xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s); + xfree(s); + + s = xf86SetStrOption(pInfo->options, "Device", NULL); + if (s == NULL) { + pInfo->fd = xf86Info.consoleFd; + pKbd->isConsole = TRUE; + } else { + pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL); + if (pInfo->fd == -1) { + xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s); + xfree(s); + return FALSE; + } + pKbd->isConsole = FALSE; + xfree(s); + } + + if (pKbd->isConsole) + pKbd->vtSwitchSupported = TRUE; + + return TRUE; +} + +_X_EXPORT Bool +xf86OSKbdPreInit(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = pInfo->private; + + pKbd->KbdInit = KbdInit; + pKbd->KbdOn = KbdOn; + pKbd->KbdOff = KbdOff; + pKbd->Bell = SoundBell; + pKbd->SetLeds = SetKbdLeds; + pKbd->GetLeds = GetKbdLeds; + pKbd->SetKbdRepeat = SetKbdRepeat; + pKbd->KbdGetMapping = KbdGetMapping; + pKbd->SpecialKey = SpecialKey; + pKbd->GetSpecialKey = GetSpecialKey; + pKbd->OpenKeyboard = OpenKeyboard; + pKbd->RemapScanCode = ATScancode; + pKbd->vtSwitchSupported = FALSE; + + pKbd->private = xcalloc(sizeof(ScoKbdPrivRec), 1); + if (pKbd->private == NULL) { + xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n"); + return FALSE; + } + + return TRUE; +} diff --git a/driver/xf86-input-keyboard/src/sco_kbd.h b/driver/xf86-input-keyboard/src/sco_kbd.h new file mode 100644 index 000000000..a79cd7bb9 --- /dev/null +++ b/driver/xf86-input-keyboard/src/sco_kbd.h @@ -0,0 +1,20 @@ +/* $XFree86$ */ +#ifndef SCO_KBD_HDR +#define SCO_KBD_HDR + +typedef struct { + int use_tcs; + int use_kd; + int no_nmap; + int no_emap; + int orig_getsc; + int orig_kbm; + struct termios kbdtty; + keymap_t keymap, noledmap; + uchar_t *sc_mapbuf; + uchar_t *sc_mapbuf2; +} ScoKbdPrivRec, *ScoKbdPrivPtr; + +extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms, + CARD8 *pModMap); +#endif /* SCO_KBD_HDR */ diff --git a/driver/xf86-input-keyboard/src/sun_kbd.c b/driver/xf86-input-keyboard/src/sun_kbd.c new file mode 100644 index 000000000..c9dc2746c --- /dev/null +++ b/driver/xf86-input-keyboard/src/sun_kbd.c @@ -0,0 +1,448 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany + * Copyright 1993 by David Dawes <dawes@XFree86.org> + * Copyright 1999 by David Holland <davidh@iquest.net) + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the names of Thomas Roell, David Dawes, and David Holland not be used + * in advertising or publicity pertaining to distribution of the software + * without specific, written prior permission. Thomas Roell, David Dawes, and + * David Holland make no representations about the suitability of this software + * for any purpose. It is provided "as is" without express or implied + * warranty. + * + * THOMAS ROELL, DAVID DAWES, AND DAVID HOLLAND DISCLAIM ALL WARRANTIES WITH + * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS. IN NO EVENT SHALL THOMAS ROELL, DAVID DAWES, OR DAVID HOLLAND + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +/* Copyright 2004-2007 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSlib.h" +#include "xf86OSKbd.h" +#include "sun_kbd.h" +#include "atKeynames.h" + +#include <sys/stropts.h> +#include <sys/vuid_event.h> +#include <sys/kbd.h> + +static void +sunKbdSetLeds(InputInfoPtr pInfo, int leds) +{ + int i; + + SYSCALL(i = ioctl(pInfo->fd, KIOCSLED, &leds)); + if (i < 0) { + xf86Msg(X_ERROR, "%s: Failed to set keyboard LED's: %s\n", + pInfo->name, strerror(errno)); + } +} + + +static int +sunKbdGetLeds(InputInfoPtr pInfo) +{ + int i, leds = 0; + + SYSCALL(i = ioctl(pInfo->fd, KIOCGLED, &leds)); + if (i < 0) { + xf86Msg(X_ERROR, "%s: Failed to get keyboard LED's: %s\n", + pInfo->name, strerror(errno)); + } + return leds; +} + + +/* + * Save initial keyboard state. This is called at the start of each server + * generation. + */ +static int +KbdInit(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private; + pointer options = pInfo->options; + + int ktype, klayout, i; + const char *ktype_name; + + priv->otranslation = -1; + priv->odirect = -1; + + if (options != NULL) { + priv->strmod = xf86SetStrOption(options, "StreamsModule", NULL); + } else { + priv->strmod = NULL; + } + + if (priv->strmod) { + SYSCALL(i = ioctl(pInfo->fd, I_PUSH, priv->strmod)); + if (i < 0) { + xf86Msg(X_ERROR, + "%s: cannot push module '%s' onto keyboard device: %s\n", + pInfo->name, priv->strmod, strerror(errno)); + } + } + + SYSCALL(i = ioctl(pInfo->fd, KIOCTYPE, &ktype)); + if (i < 0) { + xf86Msg(X_ERROR, "%s: Unable to determine keyboard type: %s\n", + pInfo->name, strerror(errno)); + return BadImplementation; + } + + SYSCALL(i = ioctl(pInfo->fd, KIOCLAYOUT, &klayout)); + if (i < 0) { + xf86Msg(X_ERROR, "%s: Unable to determine keyboard layout: %s\n", + pInfo->name, strerror(errno)); + return BadImplementation; + } + + switch (ktype) { + case KB_SUN3: + ktype_name = "Sun Type 3"; break; + case KB_SUN4: + ktype_name = "Sun Type 4/5/6"; break; + case KB_USB: + ktype_name = "USB"; break; + case KB_PC: + ktype_name = "PC"; break; + default: + ktype_name = "Unknown"; break; + } + + xf86Msg(X_PROBED, "%s: Keyboard type: %s (%d)\n", + pInfo->name, ktype_name, ktype); + xf86Msg(X_PROBED, "%s: Keyboard layout: %d\n", pInfo->name, klayout); + + priv->ktype = ktype; + priv->oleds = sunKbdGetLeds(pInfo); + + return Success; +} + + +static int +KbdOn(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private; + + int ktrans, kdirect, i; + + SYSCALL(i = ioctl(pInfo->fd, KIOCGDIRECT, &kdirect)); + if (i < 0) { + xf86Msg(X_ERROR, + "%s: Unable to determine keyboard direct setting: %s\n", + pInfo->name, strerror(errno)); + return BadImplementation; + } + + priv->odirect = kdirect; + kdirect = 1; + + SYSCALL(i = ioctl(pInfo->fd, KIOCSDIRECT, &kdirect)); + if (i < 0) { + xf86Msg(X_ERROR, "%s: Failed turning keyboard direct mode on: %s\n", + pInfo->name, strerror(errno)); + return BadImplementation; + } + + /* Setup translation */ + + SYSCALL(i = ioctl(pInfo->fd, KIOCGTRANS, &ktrans)); + if (i < 0) { + xf86Msg(X_ERROR, + "%s: Unable to determine keyboard translation mode: %s\n", + pInfo->name, strerror(errno)); + return BadImplementation; + } + + priv->otranslation = ktrans; + ktrans = TR_UNTRANS_EVENT; + + SYSCALL(i = ioctl(pInfo->fd, KIOCTRANS, &ktrans)); + if (i < 0) { + xf86Msg(X_ERROR, "%s: Failed setting keyboard translation mode: %s\n", + pInfo->name, strerror(errno)); + return BadImplementation; + } + + /* If Caps Lock or Num Lock LEDs are on when server starts, + * send a fake key down on those keys to set the server state + * to match the LED's. + */ + if ( priv->oleds & (LED_CAPS_LOCK | LED_NUM_LOCK) ) { + int capslock = -1; + int numlock = -1; + int j; + TransMapPtr kmap = pKbd->scancodeMap; + + for (j = kmap->begin; j < kmap->end ; j++) { + switch (kmap->map[j]) { + case KEY_CapsLock: + capslock = j; + break; + case KEY_NumLock: + numlock = j; + break; + default: + /* nothing to do */ + break; + } + if ((capslock >= 0) && (numlock >= 0)) { + break; + } + } + if ((priv->oleds & LED_CAPS_LOCK) && (capslock > 0)) { + pKbd->PostEvent(pInfo, capslock, TRUE); /* Press */ + pKbd->PostEvent(pInfo, capslock, FALSE); /* Release */ + } + if ((priv->oleds & LED_NUM_LOCK) && (numlock > 0)) { + pKbd->PostEvent(pInfo, numlock, TRUE); /* Press */ + pKbd->PostEvent(pInfo, numlock, FALSE); /* Release */ + } + } + + return Success; +} + +static int +KbdOff(InputInfoPtr pInfo, int what) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private; + + int i; + + /* restore original state */ + + sunKbdSetLeds(pInfo, priv->oleds); + + if (priv->otranslation != -1) { + SYSCALL(i = ioctl(pInfo->fd, KIOCTRANS, &priv->otranslation)); + if (i < 0) { + xf86Msg(X_ERROR, + "%s: Unable to restore keyboard translation mode: %s\n", + pInfo->name, strerror(errno)); + return BadImplementation; + } + priv->otranslation = -1; + } + + if (priv->odirect != -1) { + SYSCALL(i = ioctl(pInfo->fd, KIOCSDIRECT, &priv->odirect)); + if (i < 0) { + xf86Msg(X_ERROR, + "%s: Unable to restore keyboard direct setting: %s\n", + pInfo->name, strerror(errno)); + return BadImplementation; + } + priv->odirect = -1; + } + + if (priv->strmod) { + SYSCALL(i = ioctl(pInfo->fd, I_POP, priv->strmod)); + if (i < 0) { + xf86Msg(X_WARNING, + "%s: cannot pop module '%s' off keyboard device: %s\n", + pInfo->name, priv->strmod, strerror(errno)); + } + } + + return Success; +} + + +static void +SoundKbdBell(InputInfoPtr pInfo, int loudness, int pitch, int duration) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private; + + int kbdCmd, i; + + if (loudness && pitch) + { + kbdCmd = KBD_CMD_BELL; + + SYSCALL(i = ioctl (pInfo->fd, KIOCCMD, &kbdCmd)); + if (i < 0) { + xf86Msg(X_ERROR, "%s: Failed to activate bell: %s\n", + pInfo->name, strerror(errno)); + } + + usleep(duration * loudness * 20); + + kbdCmd = KBD_CMD_NOBELL; + SYSCALL(i = ioctl (pInfo->fd, KIOCCMD, &kbdCmd)); + if (i < 0) { + xf86Msg(X_ERROR, "%s: Failed to deactivate bell: %s\n", + pInfo->name, strerror(errno)); + } + } +} + +static void +SetKbdLeds(InputInfoPtr pInfo, int leds) +{ + int real_leds = sunKbdGetLeds(pInfo); + + real_leds &= ~(LED_CAPS_LOCK | LED_NUM_LOCK | LED_SCROLL_LOCK | LED_COMPOSE); + + if (leds & XLED1) real_leds |= LED_CAPS_LOCK; + if (leds & XLED2) real_leds |= LED_NUM_LOCK; + if (leds & XLED3) real_leds |= LED_SCROLL_LOCK; + if (leds & XLED4) real_leds |= LED_COMPOSE; + + sunKbdSetLeds(pInfo, real_leds); +} + +static int +GetKbdLeds(InputInfoPtr pInfo) +{ + int leds = 0; + int real_leds = sunKbdGetLeds(pInfo); + + if (real_leds & LED_CAPS_LOCK) leds |= XLED1; + if (real_leds & LED_NUM_LOCK) leds |= XLED2; + if (real_leds & LED_SCROLL_LOCK) leds |= XLED3; + if (real_leds & LED_COMPOSE) leds |= XLED4; + + return leds; +} + +/* ARGSUSED0 */ +static void +SetKbdRepeat(InputInfoPtr pInfo, char rad) +{ + /* Nothing to do */ +} + +static void +ReadInput(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + Firm_event event[64]; + int nBytes, i; + + /* I certainly hope its not possible to read partial events */ + + if ((nBytes = read(pInfo->fd, (char *)event, sizeof(event))) > 0) + { + for (i = 0; i < (nBytes / sizeof(Firm_event)); i++) { + pKbd->PostEvent(pInfo, event[i].id & 0xFF, + event[i].value == VKEY_DOWN ? TRUE : FALSE); + } + } +} + +static Bool +OpenKeyboard(InputInfoPtr pInfo) +{ + const char *kbdPath = NULL; + const char *defaultKbd = "/dev/kbd"; + + if (pInfo->options != NULL) { + kbdPath = xf86SetStrOption(pInfo->options, "Device", NULL); + } + if (kbdPath == NULL) { + kbdPath = defaultKbd; + } + + pInfo->fd = open(kbdPath, O_RDONLY | O_NONBLOCK); + + if (pInfo->fd == -1) { + xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, kbdPath); + } else { + xf86MsgVerb(X_INFO, 3, "%s: Opened device \"%s\"\n", pInfo->name, + kbdPath); + } + + if ((kbdPath != NULL) && (kbdPath != defaultKbd)) { + xfree(kbdPath); + } + + if (pInfo->fd == -1) { + return FALSE; + } else { + pInfo->read_input = ReadInput; + return TRUE; + } +} + +_X_EXPORT Bool +xf86OSKbdPreInit(InputInfoPtr pInfo) +{ + KbdDevPtr pKbd = pInfo->private; + + pKbd->KbdInit = KbdInit; + pKbd->KbdOn = KbdOn; + pKbd->KbdOff = KbdOff; + pKbd->Bell = SoundKbdBell; + pKbd->SetLeds = SetKbdLeds; + pKbd->GetLeds = GetKbdLeds; + pKbd->SetKbdRepeat = SetKbdRepeat; + pKbd->KbdGetMapping = KbdGetMapping; + + pKbd->RemapScanCode = NULL; + pKbd->GetSpecialKey = NULL; + pKbd->SpecialKey = NULL; + + pKbd->OpenKeyboard = OpenKeyboard; + + pKbd->vtSwitchSupported = FALSE; + pKbd->CustomKeycodes = FALSE; + + pKbd->private = xcalloc(sizeof(sunKbdPrivRec), 1); + if (pKbd->private == NULL) { + xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n"); + return FALSE; + } else { + sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private; + priv->otranslation = -1; + priv->odirect = -1; + } + + return TRUE; +} diff --git a/driver/xf86-input-keyboard/src/sun_kbd.h b/driver/xf86-input-keyboard/src/sun_kbd.h new file mode 100644 index 000000000..1c50993ff --- /dev/null +++ b/driver/xf86-input-keyboard/src/sun_kbd.h @@ -0,0 +1,44 @@ +/* Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, and/or sell copies of the Software, and to permit persons + * to whom the Software is furnished to do so, provided that the above + * copyright notice(s) and this permission notice appear in all copies of + * the Software and that both the above copyright notice(s) and this + * permission notice appear in supporting documentation. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT + * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL + * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING + * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Except as contained in this notice, the name of a copyright holder + * shall not be used in advertising or otherwise to promote the sale, use + * or other dealings in this Software without prior written authorization + * of the copyright holder. + */ + +#ifndef _XORG_SUN_KBD_H_ +#define _XORG_SUN_KBD_H_ + +typedef struct { + int ktype; /* Keyboard type from KIOCTYPE */ + Bool kbdActive; /* Have we set kbd modes for X? */ + int otranslation; /* Original translation mode */ + int odirect; /* Original "direct" mode setting */ + unsigned char oleds; /* Original LED state */ + const char * strmod; /* Streams module pushed on kbd device */ +} sunKbdPrivRec, *sunKbdPrivPtr; + +/* sun_kbdMap.c */ +extern void KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, + CARD8 *pModMap); +#endif diff --git a/driver/xf86-input-keyboard/src/sun_kbdMap.c b/driver/xf86-input-keyboard/src/sun_kbdMap.c new file mode 100644 index 000000000..7ab3d7d1b --- /dev/null +++ b/driver/xf86-input-keyboard/src/sun_kbdMap.c @@ -0,0 +1,671 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * Copyright 1993 by David Dawes <dawes@xfree86.org> + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the names of Thomas Roell and David Dawes not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Thomas Roell and David Dawes make no + * representations about the suitability of this software for any purpose. It + * is provided "as is" without express or implied warranty. + * + * THOMAS ROELL AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. + * IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR ANY SPECIAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <X11/Xfuncproto.h> +#include <X11/Sunkeysym.h> +#include "atKeynames.h" +#include "xf86OSKbd.h" +#include "xf86Keymap.h" +#include "sun_kbd.h" + +#include <sys/kbd.h> + +/* Map the Solaris keycodes to the "XFree86" keycodes. */ + +/* Additional Sun Japanese Keyboard Keys not defined in common/atKeynames.h */ +#define KEY_Kanji 0x82 +#define KEY_Execute 0x83 + +static unsigned char sunmap[256] = { +#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__x86) + KEY_NOTUSED, /* 0 */ + KEY_Tilde, /* 1 */ + KEY_1, /* 2 */ + KEY_2, /* 3 */ + KEY_3, /* 4 */ + KEY_4, /* 5 */ + KEY_5, /* 6 */ + KEY_6, /* 7 */ + KEY_7, /* 8 */ + KEY_8, /* 9 */ + KEY_9, /* 10 */ + KEY_0, /* 11 */ + KEY_Minus, /* 12 */ + KEY_Equal, /* 13 */ + 0x7D, /*KEY_P_YEN*/ /* 14 */ + KEY_BackSpace, /* 15 */ + KEY_Tab, /* 16 */ + KEY_Q, /* 17 */ + KEY_W, /* 18 */ + KEY_E, /* 19 */ + KEY_R, /* 20 */ + KEY_T, /* 21 */ + KEY_Y, /* 22 */ + KEY_U, /* 23 */ + KEY_I, /* 24 */ + KEY_O, /* 25 */ + KEY_P, /* 26 */ + KEY_LBrace, /* 27 */ + KEY_RBrace, /* 28 */ + KEY_BSlash, /* 29 */ + KEY_CapsLock, /* 30 */ + KEY_A, /* 31 */ + KEY_S, /* 32 */ + KEY_D, /* 33 */ + KEY_F, /* 34 */ + KEY_G, /* 35 */ + KEY_H, /* 36 */ + KEY_J, /* 37 */ + KEY_K, /* 38 */ + KEY_L, /* 39 */ + KEY_SemiColon, /* 40 */ + KEY_Quote, /* 41 */ + KEY_UNKNOWN, /* 42 */ + KEY_Enter, /* 43 */ + KEY_ShiftL, /* 44 */ + KEY_Less, /* 45 */ + KEY_Z, /* 46 */ + KEY_X, /* 47 */ + KEY_C, /* 48 */ + KEY_V, /* 49 */ + KEY_B, /* 50 */ + KEY_N, /* 51 */ + KEY_M, /* 52 */ + KEY_Comma, /* 53 */ + KEY_Period, /* 54 */ + KEY_Slash, /* 55 */ + KEY_BSlash2, /* 56 */ + KEY_ShiftR, /* 57 */ + KEY_LCtrl, /* 58 */ + KEY_LMeta, /* 59 */ + KEY_Alt, /* 60 */ + KEY_Space, /* 61 */ + KEY_AltLang, /* 62 */ + KEY_RMeta, /* 63 */ + KEY_RCtrl, /* 64 */ + KEY_Menu, /* 65 */ + KEY_UNKNOWN, /* 66 */ + KEY_UNKNOWN, /* 67 */ + KEY_UNKNOWN, /* 68 */ + KEY_UNKNOWN, /* 69 */ + KEY_UNKNOWN, /* 70 */ + KEY_UNKNOWN, /* 71 */ + KEY_UNKNOWN, /* 72 */ + KEY_UNKNOWN, /* 73 */ + KEY_UNKNOWN, /* 74 */ + KEY_Insert, /* 75 */ + KEY_Delete, /* 76 */ + KEY_UNKNOWN, /* 77 */ + KEY_UNKNOWN, /* 78 */ + KEY_Left, /* 79 */ + KEY_Home, /* 80 */ + KEY_End, /* 81 */ + KEY_UNKNOWN, /* 82 */ + KEY_Up, /* 83 */ + KEY_Down, /* 84 */ + KEY_PgUp, /* 85 */ + KEY_PgDown, /* 86 */ + KEY_UNKNOWN, /* 87 */ + KEY_UNKNOWN, /* 88 */ + KEY_Right, /* 89 */ + KEY_NumLock, /* 90 */ + KEY_KP_7, /* 91 */ + KEY_KP_4, /* 92 */ + KEY_KP_1, /* 93 */ + KEY_UNKNOWN, /* 94 */ + KEY_KP_Divide, /* 95 */ + KEY_KP_8, /* 96 */ + KEY_KP_5, /* 97 */ + KEY_KP_2, /* 98 */ + KEY_KP_0, /* 99 */ + KEY_KP_Multiply, /* 100 */ + KEY_KP_9, /* 101 */ + KEY_KP_6, /* 102 */ + KEY_KP_3, /* 103 */ + KEY_KP_Decimal, /* 104 */ + KEY_KP_Minus, /* 105 */ + KEY_KP_Plus, /* 106 */ + KEY_UNKNOWN, /* 107 */ + KEY_KP_Enter, /* 108 */ + KEY_UNKNOWN, /* 109 */ + KEY_Escape, /* 110 */ + KEY_UNKNOWN, /* 111 */ + KEY_F1, /* 112 */ + KEY_F2, /* 113 */ + KEY_F3, /* 114 */ + KEY_F4, /* 115 */ + KEY_F5, /* 116 */ + KEY_F6, /* 117 */ + KEY_F7, /* 118 */ + KEY_F8, /* 119 */ + KEY_F9, /* 120 */ + KEY_F10, /* 121 */ + KEY_F11, /* 122 */ + KEY_F12, /* 123 */ + KEY_Print, /* 124 */ + KEY_ScrollLock, /* 125 */ + KEY_Pause, /* 126 */ + KEY_UNKNOWN, /* 127 */ + KEY_UNKNOWN, /* 128 */ + KEY_UNKNOWN, /* 129 */ + KEY_UNKNOWN, /* 130 */ + KEY_NFER, /* 131 */ + KEY_XFER, /* 132 */ + KEY_HKTG, /* 133 */ + KEY_UNKNOWN, /* 134 */ +#elif defined(sparc) || defined(__sparc__) + KEY_UNKNOWN, /* 0x00 */ + KEY_UNKNOWN, /* 0x01 */ + KEY_UNKNOWN, /* 0x02 */ + KEY_UNKNOWN, /* 0x03 */ + KEY_UNKNOWN, /* 0x04 */ + KEY_F1, /* 0x05 */ + KEY_F2, /* 0x06 */ + KEY_F10, /* 0x07 */ + KEY_F3, /* 0x08 */ + KEY_F11, /* 0x09 */ + KEY_F4, /* 0x0A */ + KEY_F12, /* 0x0B */ + KEY_F5, /* 0x0C */ + KEY_UNKNOWN, /* 0x0D */ + KEY_F6, /* 0x0E */ + KEY_UNKNOWN, /* 0x0F */ + KEY_F7, /* 0x10 */ + KEY_F8, /* 0x11 */ + KEY_F9, /* 0x12 */ + KEY_Alt, /* 0x13 */ + KEY_Up, /* 0x14 */ + KEY_Pause, /* 0x15 */ + KEY_SysReqest, /* 0x16 */ + KEY_ScrollLock, /* 0x17 */ + KEY_Left, /* 0x18 */ + KEY_UNKNOWN, /* 0x19 */ + KEY_UNKNOWN, /* 0x1A */ + KEY_Down, /* 0x1B */ + KEY_Right, /* 0x1C */ + KEY_Escape, /* 0x1D */ + KEY_1, /* 0x1E */ + KEY_2, /* 0x1F */ + KEY_3, /* 0x20 */ + KEY_4, /* 0x21 */ + KEY_5, /* 0x22 */ + KEY_6, /* 0x23 */ + KEY_7, /* 0x24 */ + KEY_8, /* 0x25 */ + KEY_9, /* 0x26 */ + KEY_0, /* 0x27 */ + KEY_Minus, /* 0x28 */ + KEY_Equal, /* 0x29 */ + KEY_Tilde, /* 0x2A */ + KEY_BackSpace, /* 0x2B */ + KEY_Insert, /* 0x2C */ + KEY_UNKNOWN, /* 0x2D */ + KEY_KP_Divide, /* 0x2E */ + KEY_KP_Multiply, /* 0x2F */ + KEY_UNKNOWN, /* 0x30 */ + KEY_UNKNOWN, /* 0x31 */ + KEY_KP_Decimal, /* 0x32 */ + KEY_UNKNOWN, /* 0x33 */ + KEY_Home, /* 0x34 */ + KEY_Tab, /* 0x35 */ + KEY_Q, /* 0x36 */ + KEY_W, /* 0x37 */ + KEY_E, /* 0x38 */ + KEY_R, /* 0x39 */ + KEY_T, /* 0x3A */ + KEY_Y, /* 0x3B */ + KEY_U, /* 0x3C */ + KEY_I, /* 0x3D */ + KEY_O, /* 0x3E */ + KEY_P, /* 0x3F */ + KEY_LBrace, /* 0x40 */ + KEY_RBrace, /* 0x41 */ + KEY_Delete, /* 0x42 */ + KEY_UNKNOWN, /* 0x43 */ + KEY_KP_7, /* 0x44 */ + KEY_KP_8, /* 0x45 */ + KEY_KP_9, /* 0x46 */ + KEY_KP_Minus, /* 0x47 */ + KEY_UNKNOWN, /* 0x48 */ + KEY_UNKNOWN, /* 0x49 */ + KEY_End, /* 0x4A */ + KEY_UNKNOWN, /* 0x4B */ + KEY_LCtrl, /* 0x4C */ + KEY_A, /* 0x4D */ + KEY_S, /* 0x4E */ + KEY_D, /* 0x4F */ + KEY_F, /* 0x50 */ + KEY_G, /* 0x51 */ + KEY_H, /* 0x52 */ + KEY_J, /* 0x53 */ + KEY_K, /* 0x54 */ + KEY_L, /* 0x55 */ + KEY_SemiColon, /* 0x56 */ + KEY_Quote, /* 0x57 */ + KEY_BSlash, /* 0x58 */ + KEY_Enter, /* 0x59 */ + KEY_KP_Enter, /* 0x5A */ + KEY_KP_4, /* 0x5B */ + KEY_KP_5, /* 0x5C */ + KEY_KP_6, /* 0x5D */ + KEY_KP_0, /* 0x5E */ + KEY_UNKNOWN, /* 0x5F */ + KEY_PgUp, /* 0x60 */ + KEY_UNKNOWN, /* 0x61 */ + KEY_NumLock, /* 0x62 */ + KEY_ShiftL, /* 0x63 */ + KEY_Z, /* 0x64 */ + KEY_X, /* 0x65 */ + KEY_C, /* 0x66 */ + KEY_V, /* 0x67 */ + KEY_B, /* 0x68 */ + KEY_N, /* 0x69 */ + KEY_M, /* 0x6A */ + KEY_Comma, /* 0x6B */ + KEY_Period, /* 0x6C */ + KEY_Slash, /* 0x6D */ + KEY_ShiftR, /* 0x6E */ + KEY_UNKNOWN, /* 0x6F */ + KEY_KP_1, /* 0x70 */ + KEY_KP_2, /* 0x71 */ + KEY_KP_3, /* 0x72 */ + KEY_UNKNOWN, /* 0x73 */ + KEY_UNKNOWN, /* 0x74 */ + KEY_UNKNOWN, /* 0x75 */ + KEY_UNKNOWN, /* 0x76 */ + KEY_CapsLock, /* 0x77 */ + KEY_LMeta, /* 0x78 */ + KEY_Space, /* 0x79 */ + KEY_RMeta, /* 0x7A */ + KEY_PgDown, /* 0x7B */ + KEY_UNKNOWN, /* 0x7C */ + KEY_KP_Plus, /* 0x7D */ + KEY_UNKNOWN, /* 0x7E */ + KEY_UNKNOWN, /* 0x7F */ +#endif + /* The rest default to KEY_UNKNOWN */ +}; + +static +TransMapRec sunTransMap = { + 0, + (sizeof(sunmap)/sizeof(unsigned char)), + sunmap +}; + +#if defined(KB_USB) +static unsigned char usbmap[256] = { +/* + * partially taken from ../bsd/bsd_KbdMap.c + * + * added keycodes for Sun special keys (left function keys, audio control) + */ + /* 0 */ KEY_NOTUSED, + /* 1 */ KEY_NOTUSED, + /* 2 */ KEY_NOTUSED, + /* 3 */ KEY_NOTUSED, + /* 4 */ KEY_A, + /* 5 */ KEY_B, + /* 6 */ KEY_C, + /* 7 */ KEY_D, + /* 8 */ KEY_E, + /* 9 */ KEY_F, + /* 10 */ KEY_G, + /* 11 */ KEY_H, + /* 12 */ KEY_I, + /* 13 */ KEY_J, + /* 14 */ KEY_K, + /* 15 */ KEY_L, + /* 16 */ KEY_M, + /* 17 */ KEY_N, + /* 18 */ KEY_O, + /* 19 */ KEY_P, + /* 20 */ KEY_Q, + /* 21 */ KEY_R, + /* 22 */ KEY_S, + /* 23 */ KEY_T, + /* 24 */ KEY_U, + /* 25 */ KEY_V, + /* 26 */ KEY_W, + /* 27 */ KEY_X, + /* 28 */ KEY_Y, + /* 29 */ KEY_Z, + /* 30 */ KEY_1, /* 1 !*/ + /* 31 */ KEY_2, /* 2 @ */ + /* 32 */ KEY_3, /* 3 # */ + /* 33 */ KEY_4, /* 4 $ */ + /* 34 */ KEY_5, /* 5 % */ + /* 35 */ KEY_6, /* 6 ^ */ + /* 36 */ KEY_7, /* 7 & */ + /* 37 */ KEY_8, /* 8 * */ + /* 38 */ KEY_9, /* 9 ( */ + /* 39 */ KEY_0, /* 0 ) */ + /* 40 */ KEY_Enter, /* Return */ + /* 41 */ KEY_Escape, /* Escape */ + /* 42 */ KEY_BackSpace, /* Backspace Delete */ + /* 43 */ KEY_Tab, /* Tab */ + /* 44 */ KEY_Space, /* Space */ + /* 45 */ KEY_Minus, /* - _ */ + /* 46 */ KEY_Equal, /* = + */ + /* 47 */ KEY_LBrace, /* [ { */ + /* 48 */ KEY_RBrace, /* ] } */ + /* 49 */ KEY_BSlash, /* \ | */ + /* 50 */ KEY_BSlash, /* \ _ # ~ on some keyboards */ + /* 51 */ KEY_SemiColon, /* ; : */ + /* 52 */ KEY_Quote, /* ' " */ + /* 53 */ KEY_Tilde, /* ` ~ */ + /* 54 */ KEY_Comma, /* , < */ + /* 55 */ KEY_Period, /* . > */ + /* 56 */ KEY_Slash, /* / ? */ + /* 57 */ KEY_CapsLock, /* Caps Lock */ + /* 58 */ KEY_F1, /* F1 */ + /* 59 */ KEY_F2, /* F2 */ + /* 60 */ KEY_F3, /* F3 */ + /* 61 */ KEY_F4, /* F4 */ + /* 62 */ KEY_F5, /* F5 */ + /* 63 */ KEY_F6, /* F6 */ + /* 64 */ KEY_F7, /* F7 */ + /* 65 */ KEY_F8, /* F8 */ + /* 66 */ KEY_F9, /* F9 */ + /* 67 */ KEY_F10, /* F10 */ + /* 68 */ KEY_F11, /* F11 */ + /* 69 */ KEY_F12, /* F12 */ + /* 70 */ KEY_Print, /* PrintScrn SysReq */ + /* 71 */ KEY_ScrollLock, /* Scroll Lock */ + /* 72 */ KEY_Pause, /* Pause Break */ + /* 73 */ KEY_Insert, /* Insert XXX Help on some Mac Keyboards */ + /* 74 */ KEY_Home, /* Home */ + /* 75 */ KEY_PgUp, /* Page Up */ + /* 76 */ KEY_Delete, /* Delete */ + /* 77 */ KEY_End, /* End */ + /* 78 */ KEY_PgDown, /* Page Down */ + /* 79 */ KEY_Right, /* Right Arrow */ + /* 80 */ KEY_Left, /* Left Arrow */ + /* 81 */ KEY_Down, /* Down Arrow */ + /* 82 */ KEY_Up, /* Up Arrow */ + /* 83 */ KEY_NumLock, /* Num Lock */ + /* 84 */ KEY_KP_Divide, /* Keypad / */ + /* 85 */ KEY_KP_Multiply, /* Keypad * */ + /* 86 */ KEY_KP_Minus, /* Keypad - */ + /* 87 */ KEY_KP_Plus, /* Keypad + */ + /* 88 */ KEY_KP_Enter, /* Keypad Enter */ + /* 89 */ KEY_KP_1, /* Keypad 1 End */ + /* 90 */ KEY_KP_2, /* Keypad 2 Down */ + /* 91 */ KEY_KP_3, /* Keypad 3 Pg Down */ + /* 92 */ KEY_KP_4, /* Keypad 4 Left */ + /* 93 */ KEY_KP_5, /* Keypad 5 */ + /* 94 */ KEY_KP_6, /* Keypad 6 */ + /* 95 */ KEY_KP_7, /* Keypad 7 Home */ + /* 96 */ KEY_KP_8, /* Keypad 8 Up */ + /* 97 */ KEY_KP_9, /* KEypad 9 Pg Up */ + /* 98 */ KEY_KP_0, /* Keypad 0 Ins */ + /* 99 */ KEY_KP_Decimal, /* Keypad . Del */ + /* 100 */ KEY_Less, /* < > on some keyboards */ + /* 101 */ KEY_Menu, /* Menu */ + /* 102 */ KEY_Power, /* Sun: Power */ + /* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */ + /* 104 */ KEY_NOTUSED, + /* 105 */ KEY_NOTUSED, + /* 106 */ KEY_NOTUSED, + /* 107 */ KEY_NOTUSED, + /* 108 */ KEY_NOTUSED, + /* 109 */ KEY_NOTUSED, + /* 110 */ KEY_NOTUSED, + /* 111 */ KEY_NOTUSED, + /* 112 */ KEY_NOTUSED, + /* 113 */ KEY_NOTUSED, + /* 114 */ KEY_NOTUSED, + /* 115 */ KEY_NOTUSED, + /* 116 */ KEY_L7, /* Sun: Open */ + /* 117 */ KEY_Help, /* Sun: Help */ + /* 118 */ KEY_L3, /* Sun: Props */ + /* 119 */ KEY_L5, /* Sun: Front */ + /* 120 */ KEY_L1, /* Sun: Stop */ + /* 121 */ KEY_L2, /* Sun: Again */ + /* 122 */ KEY_L4, /* Sun: Undo */ + /* 123 */ KEY_L10, /* Sun: Cut */ + /* 124 */ KEY_L6, /* Sun: Copy */ + /* 125 */ KEY_L8, /* Sun: Paste */ + /* 126 */ KEY_L9, /* Sun: Find */ + /* 127 */ KEY_Mute, /* Sun: AudioMute */ + /* 128 */ KEY_AudioRaise, /* Sun: AudioRaise */ + /* 129 */ KEY_AudioLower, /* Sun: AudioLower */ + /* 130 */ KEY_NOTUSED, + /* 131 */ KEY_NOTUSED, + /* 132 */ KEY_NOTUSED, + /* 133 */ KEY_NOTUSED, + /* 134 */ KEY_NOTUSED, + /* 135 */ KEY_BSlash2, /* Sun Japanese Kbd: Backslash / Underscore */ + /* 136 */ KEY_XFER, /* Sun Japanese Kbd: Henkan Mode */ + /* 137 */ KEY_Yen, /* Sun Japanese Kbd: Yen / Brokenbar */ + /* 138 */ KEY_Kanji, /* Sun Japanese Kbd: Kanji */ + /* 139 */ KEY_Execute, /* Sun Japanese Kbd: Execute */ + /* 140 */ KEY_NOTUSED, + /* 141 */ KEY_NOTUSED, + /* 142 */ KEY_NOTUSED, + /* 143 */ KEY_NOTUSED, + /* 144 */ KEY_NOTUSED, + /* 145 */ KEY_NOTUSED, + /* 146 */ KEY_NOTUSED, + /* 147 */ KEY_NOTUSED, + /* 148 */ KEY_NOTUSED, + /* 149 */ KEY_NOTUSED, + /* 150 */ KEY_NOTUSED, + /* 151 */ KEY_NOTUSED, + /* 152 */ KEY_NOTUSED, + /* 153 */ KEY_NOTUSED, + /* 154 */ KEY_NOTUSED, + /* 155 */ KEY_NOTUSED, + /* 156 */ KEY_NOTUSED, + /* 157 */ KEY_NOTUSED, + /* 158 */ KEY_NOTUSED, + /* 159 */ KEY_NOTUSED, + /* 160 */ KEY_NOTUSED, + /* 161 */ KEY_NOTUSED, + /* 162 */ KEY_NOTUSED, + /* 163 */ KEY_NOTUSED, + /* 164 */ KEY_NOTUSED, + /* 165 */ KEY_NOTUSED, + /* 166 */ KEY_NOTUSED, + /* 167 */ KEY_NOTUSED, + /* 168 */ KEY_NOTUSED, + /* 169 */ KEY_NOTUSED, + /* 170 */ KEY_NOTUSED, + /* 171 */ KEY_NOTUSED, + /* 172 */ KEY_NOTUSED, + /* 173 */ KEY_NOTUSED, + /* 174 */ KEY_NOTUSED, + /* 175 */ KEY_NOTUSED, + /* 176 */ KEY_NOTUSED, + /* 177 */ KEY_NOTUSED, + /* 178 */ KEY_NOTUSED, + /* 179 */ KEY_NOTUSED, + /* 180 */ KEY_NOTUSED, + /* 181 */ KEY_NOTUSED, + /* 182 */ KEY_NOTUSED, + /* 183 */ KEY_NOTUSED, + /* 184 */ KEY_NOTUSED, + /* 185 */ KEY_NOTUSED, + /* 186 */ KEY_NOTUSED, + /* 187 */ KEY_NOTUSED, + /* 188 */ KEY_NOTUSED, + /* 189 */ KEY_NOTUSED, + /* 190 */ KEY_NOTUSED, + /* 191 */ KEY_NOTUSED, + /* 192 */ KEY_NOTUSED, + /* 193 */ KEY_NOTUSED, + /* 194 */ KEY_NOTUSED, + /* 195 */ KEY_NOTUSED, + /* 196 */ KEY_NOTUSED, + /* 197 */ KEY_NOTUSED, + /* 198 */ KEY_NOTUSED, + /* 199 */ KEY_NOTUSED, + /* 200 */ KEY_NOTUSED, + /* 201 */ KEY_NOTUSED, + /* 202 */ KEY_NOTUSED, + /* 203 */ KEY_NOTUSED, + /* 204 */ KEY_NOTUSED, + /* 205 */ KEY_NOTUSED, + /* 206 */ KEY_NOTUSED, + /* 207 */ KEY_NOTUSED, + /* 208 */ KEY_NOTUSED, + /* 209 */ KEY_NOTUSED, + /* 210 */ KEY_NOTUSED, + /* 211 */ KEY_NOTUSED, + /* 212 */ KEY_NOTUSED, + /* 213 */ KEY_NOTUSED, + /* 214 */ KEY_NOTUSED, + /* 215 */ KEY_NOTUSED, + /* 216 */ KEY_NOTUSED, + /* 217 */ KEY_NOTUSED, + /* 218 */ KEY_NOTUSED, + /* 219 */ KEY_NOTUSED, + /* 220 */ KEY_NOTUSED, + /* 221 */ KEY_NOTUSED, + /* 222 */ KEY_NOTUSED, + /* 223 */ KEY_NOTUSED, + /* 224 */ KEY_LCtrl, /* Left Control */ + /* 225 */ KEY_ShiftL, /* Left Shift */ + /* 226 */ KEY_Alt, /* Left Alt */ + /* 227 */ KEY_LMeta, /* Left Meta */ + /* 228 */ KEY_RCtrl, /* Right Control */ + /* 229 */ KEY_ShiftR, /* Right Shift */ + /* 230 */ KEY_AltLang, /* Right Alt, AKA AltGr */ + /* 231 */ KEY_RMeta, /* Right Meta */ +}; + +static +TransMapRec usbTransMap = { + 0, + (sizeof(usbmap)/sizeof(unsigned char)), + usbmap +}; +#endif /* KB_USB */ + +_X_HIDDEN void +KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap) +{ + KbdDevPtr pKbd = (KbdDevPtr) pInfo->private; + sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private; + const unsigned char *keymap; + int i; + KeySym *k; + +#if defined(KB_USB) + if (priv->ktype == KB_USB) + pKbd->scancodeMap = &usbTransMap; + else +#endif + pKbd->scancodeMap = &sunTransMap; + + /* + * Add Sun keyboard keysyms to default map + */ +#define map_for_key(k,c) map[(k * GLYPHS_PER_KEY) + c] + map_for_key(KEY_Kanji, 0) = XK_Kanji; + map_for_key(KEY_Execute, 0) = XK_Execute; + map_for_key(KEY_Power, 0) = SunXK_PowerSwitch; + map_for_key(KEY_Power, 1) = SunXK_PowerSwitchShift; + map_for_key(KEY_Mute, 0) = SunXK_AudioMute; + map_for_key(KEY_Mute, 1) = SunXK_VideoDegauss; + map_for_key(KEY_AudioLower, 0) = SunXK_AudioLowerVolume; + map_for_key(KEY_AudioLower, 1) = SunXK_VideoLowerBrightness; + map_for_key(KEY_AudioRaise, 0) = SunXK_AudioRaiseVolume; + map_for_key(KEY_AudioRaise, 1) = SunXK_VideoRaiseBrightness; + map_for_key(KEY_Help, 0) = XK_Help; + map_for_key(KEY_L1, 0) = XK_L1; + map_for_key(KEY_L2, 0) = XK_L2; + map_for_key(KEY_L3, 0) = XK_L3; + map_for_key(KEY_L4, 0) = XK_L4; + map_for_key(KEY_L5, 0) = XK_L5; + map_for_key(KEY_L6, 0) = XK_L6; + map_for_key(KEY_L7, 0) = XK_L7; + map_for_key(KEY_L8, 0) = XK_L8; + map_for_key(KEY_L9, 0) = XK_L9; + map_for_key(KEY_L10, 0) = XK_L10; + map_for_key(KEY_F11, 0) = SunXK_F36; + map_for_key(KEY_F12, 0) = SunXK_F37; + map_for_key(KEY_Menu, 0) = XK_Multi_key; + + /* + * compute the modifier map + */ + for (i = 0; i < MAP_LENGTH; i++) + pModMap[i] = NoSymbol; /* make sure it is restored */ + + for (k = map, i = MIN_KEYCODE; + i < (NUM_KEYCODES + MIN_KEYCODE); + i++, k += 4) + { + switch(*k) { + + case XK_Shift_L: + case XK_Shift_R: + pModMap[i] = ShiftMask; + break; + + case XK_Control_L: + case XK_Control_R: + pModMap[i] = ControlMask; + break; + + case XK_Caps_Lock: + pModMap[i] = LockMask; + break; + + case XK_Alt_L: + case XK_Alt_R: + pModMap[i] = AltMask; + break; + + case XK_Num_Lock: + pModMap[i] = NumLockMask; + break; + + case XK_Scroll_Lock: + pModMap[i] = ScrollLockMask; + break; + + /* kana support */ + case XK_Kana_Lock: + case XK_Kana_Shift: + pModMap[i] = KanaMask; + break; + + /* alternate toggle for multinational support */ + case XK_Mode_switch: + pModMap[i] = AltLangMask; + break; + + } + } + + pKeySyms->map = map; + pKeySyms->mapWidth = GLYPHS_PER_KEY; + pKeySyms->minKeyCode = MIN_KEYCODE; + pKeySyms->maxKeyCode = MAX_KEYCODE; +} diff --git a/driver/xf86-input-keyboard/src/xf86Keymap.h b/driver/xf86-input-keyboard/src/xf86Keymap.h new file mode 100644 index 000000000..2bd22052b --- /dev/null +++ b/driver/xf86-input-keyboard/src/xf86Keymap.h @@ -0,0 +1,308 @@ + +/* + * Copyright (c) 1994-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * + * For Scancodes see notes in atKeynames.h !!!! + * + */ +/* $XConsortium: xf86Keymap.h /main/14 1996/02/21 17:38:47 kaleb $ */ + +#include "xorg-server.h" + +static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = { + + /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x01 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol, + /* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol, + /* 0x03 */ XK_2, XK_at, NoSymbol, NoSymbol, + /* 0x04 */ XK_3, XK_numbersign, NoSymbol, NoSymbol, + /* 0x05 */ XK_4, XK_dollar, NoSymbol, NoSymbol, + /* 0x06 */ XK_5, XK_percent, NoSymbol, NoSymbol, + /* 0x07 */ XK_6, XK_asciicircum, NoSymbol, NoSymbol, + /* 0x08 */ XK_7, XK_ampersand, NoSymbol, NoSymbol, + /* 0x09 */ XK_8, XK_asterisk, NoSymbol, NoSymbol, + /* 0x0a */ XK_9, XK_parenleft, NoSymbol, NoSymbol, + /* 0x0b */ XK_0, XK_parenright, NoSymbol, NoSymbol, + /* 0x0c */ XK_minus, XK_underscore, NoSymbol, NoSymbol, + /* 0x0d */ XK_equal, XK_plus, NoSymbol, NoSymbol, + /* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, + /* 0x0f */ XK_Tab, XK_ISO_Left_Tab,NoSymbol, NoSymbol, + /* 0x10 */ XK_Q, NoSymbol, NoSymbol, NoSymbol, + /* 0x11 */ XK_W, NoSymbol, NoSymbol, NoSymbol, + /* 0x12 */ XK_E, NoSymbol, NoSymbol, NoSymbol, + /* 0x13 */ XK_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x14 */ XK_T, NoSymbol, NoSymbol, NoSymbol, + /* 0x15 */ XK_Y, NoSymbol, NoSymbol, NoSymbol, + /* 0x16 */ XK_U, NoSymbol, NoSymbol, NoSymbol, + /* 0x17 */ XK_I, NoSymbol, NoSymbol, NoSymbol, + /* 0x18 */ XK_O, NoSymbol, NoSymbol, NoSymbol, + /* 0x19 */ XK_P, NoSymbol, NoSymbol, NoSymbol, + /* 0x1a */ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, + /* 0x1b */ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, + /* 0x1c */ XK_Return, NoSymbol, NoSymbol, NoSymbol, + /* 0x1d */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x1e */ XK_A, NoSymbol, NoSymbol, NoSymbol, + /* 0x1f */ XK_S, NoSymbol, NoSymbol, NoSymbol, + /* 0x20 */ XK_D, NoSymbol, NoSymbol, NoSymbol, + /* 0x21 */ XK_F, NoSymbol, NoSymbol, NoSymbol, + /* 0x22 */ XK_G, NoSymbol, NoSymbol, NoSymbol, + /* 0x23 */ XK_H, NoSymbol, NoSymbol, NoSymbol, + /* 0x24 */ XK_J, NoSymbol, NoSymbol, NoSymbol, + /* 0x25 */ XK_K, NoSymbol, NoSymbol, NoSymbol, + /* 0x26 */ XK_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x27 */ XK_semicolon, XK_colon, NoSymbol, NoSymbol, + /* 0x28 */ XK_quoteright, XK_quotedbl, NoSymbol, NoSymbol, + /* 0x29 */ XK_quoteleft, XK_asciitilde, NoSymbol, NoSymbol, + /* 0x2a */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x2b */ XK_backslash, XK_bar, NoSymbol, NoSymbol, + /* 0x2c */ XK_Z, NoSymbol, NoSymbol, NoSymbol, + /* 0x2d */ XK_X, NoSymbol, NoSymbol, NoSymbol, + /* 0x2e */ XK_C, NoSymbol, NoSymbol, NoSymbol, + /* 0x2f */ XK_V, NoSymbol, NoSymbol, NoSymbol, + /* 0x30 */ XK_B, NoSymbol, NoSymbol, NoSymbol, + /* 0x31 */ XK_N, NoSymbol, NoSymbol, NoSymbol, + /* 0x32 */ XK_M, NoSymbol, NoSymbol, NoSymbol, + /* 0x33 */ XK_comma, XK_less, NoSymbol, NoSymbol, + /* 0x34 */ XK_period, XK_greater, NoSymbol, NoSymbol, + /* 0x35 */ XK_slash, XK_question, NoSymbol, NoSymbol, + /* 0x36 */ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x37 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, + /* 0x38 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol, + /* 0x39 */ XK_space, NoSymbol, NoSymbol, NoSymbol, + /* 0x3a */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x3b */ XK_F1, NoSymbol, NoSymbol, NoSymbol, + /* 0x3c */ XK_F2, NoSymbol, NoSymbol, NoSymbol, + /* 0x3d */ XK_F3, NoSymbol, NoSymbol, NoSymbol, + /* 0x3e */ XK_F4, NoSymbol, NoSymbol, NoSymbol, + /* 0x3f */ XK_F5, NoSymbol, NoSymbol, NoSymbol, + /* 0x40 */ XK_F6, NoSymbol, NoSymbol, NoSymbol, + /* 0x41 */ XK_F7, NoSymbol, NoSymbol, NoSymbol, + /* 0x42 */ XK_F8, NoSymbol, NoSymbol, NoSymbol, + /* 0x43 */ XK_F9, NoSymbol, NoSymbol, NoSymbol, + /* 0x44 */ XK_F10, NoSymbol, NoSymbol, NoSymbol, + /* 0x45 */ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x46 */ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x47 */ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, + /* 0x48 */ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, + /* 0x49 */ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, + /* 0x4a */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, + /* 0x4b */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, + /* 0x4c */ XK_KP_Begin, XK_KP_5, NoSymbol, NoSymbol, + /* 0x4d */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, + /* 0x4e */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, + /* 0x4f */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, + /* 0x50 */ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, + /* 0x51 */ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, + /* 0x52 */ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, + /* 0x53 */ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, + /* 0x54 */ XK_Sys_Req, NoSymbol, NoSymbol, NoSymbol, + /* 0x55 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x56 */ XK_less, XK_greater, NoSymbol, NoSymbol, + /* 0x57 */ XK_F11, NoSymbol, NoSymbol, NoSymbol, + /* 0x58 */ XK_F12, NoSymbol, NoSymbol, NoSymbol, + /* 0x59 */ XK_Home, NoSymbol, NoSymbol, NoSymbol, + /* 0x5a */ XK_Up, NoSymbol, NoSymbol, NoSymbol, + /* 0x5b */ XK_Prior, NoSymbol, NoSymbol, NoSymbol, + /* 0x5c */ XK_Left, NoSymbol, NoSymbol, NoSymbol, + /* 0x5d */ XK_Begin, NoSymbol, NoSymbol, NoSymbol, + /* 0x5e */ XK_Right, NoSymbol, NoSymbol, NoSymbol, + /* 0x5f */ XK_End, NoSymbol, NoSymbol, NoSymbol, + /* 0x60 */ XK_Down, NoSymbol, NoSymbol, NoSymbol, + /* 0x61 */ XK_Next, NoSymbol, NoSymbol, NoSymbol, + /* 0x62 */ XK_Insert, NoSymbol, NoSymbol, NoSymbol, + /* 0x63 */ XK_Delete, NoSymbol, NoSymbol, NoSymbol, + /* 0x64 */ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, + /* 0x65 */ XK_Control_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x66 */ XK_Pause, NoSymbol, NoSymbol, NoSymbol, + /* 0x67 */ XK_Print, NoSymbol, NoSymbol, NoSymbol, + /* 0x68 */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, + /* 0x69 */ XK_Alt_R, XK_Meta_R, NoSymbol, NoSymbol, + /* 0x6a */ XK_Break, NoSymbol, NoSymbol, NoSymbol, + /* 0x6b */ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x6c */ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x6d */ XK_Menu, NoSymbol, NoSymbol, NoSymbol, + /* 0x6e */ XK_F13, NoSymbol, NoSymbol, NoSymbol, + /* 0x6f */ XK_F14, NoSymbol, NoSymbol, NoSymbol, + /* 0x70 */ XK_F15, NoSymbol, NoSymbol, NoSymbol, + /* 0x71 */ XK_F16, NoSymbol, NoSymbol, NoSymbol, + /* 0x72 */ XK_F17, NoSymbol, NoSymbol, NoSymbol, + /* 0x73 */ XK_backslash, XK_underscore, NoSymbol, NoSymbol, + /* 0x74 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x77 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x79 */ XK_Henkan, XK_Mode_switch, NoSymbol, NoSymbol, + /* 0x7a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7b */ XK_Muhenkan, NoSymbol, NoSymbol, NoSymbol, + /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7d */ XK_backslash, XK_bar, NoSymbol, NoSymbol, + /* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, +}; + +#if !defined(Lynx) && \ + !defined(__UNIXOS2__) && \ + !defined(__mips__) && \ + !defined(linux) && \ + !defined(CSRG_BASED) && \ + !defined(__CYGWIN__) && \ + !defined(__SOL8__) && \ + (!defined(sun) || defined(i386)) + +static KeySym map84[NUM_KEYCODES * GLYPHS_PER_KEY] = { + /* 0x00 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x01 */ XK_Escape, NoSymbol, NoSymbol, NoSymbol, + /* 0x02 */ XK_1, XK_exclam, NoSymbol, NoSymbol, + /* 0x03 */ XK_2, XK_at, NoSymbol, NoSymbol, + /* 0x04 */ XK_3, XK_numbersign, NoSymbol, NoSymbol, + /* 0x05 */ XK_4, XK_dollar, NoSymbol, NoSymbol, + /* 0x06 */ XK_5, XK_percent, NoSymbol, NoSymbol, + /* 0x07 */ XK_6, XK_asciicircum, NoSymbol, NoSymbol, + /* 0x08 */ XK_7, XK_ampersand, NoSymbol, NoSymbol, + /* 0x09 */ XK_8, XK_asterisk, NoSymbol, NoSymbol, + /* 0x0a */ XK_9, XK_parenleft, NoSymbol, NoSymbol, + /* 0x0b */ XK_0, XK_parenright, NoSymbol, NoSymbol, + /* 0x0c */ XK_minus, XK_underscore, NoSymbol, NoSymbol, + /* 0x0d */ XK_equal, XK_plus, NoSymbol, NoSymbol, + /* 0x0e */ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, + /* 0x0f */ XK_Tab, NoSymbol, NoSymbol, NoSymbol, + /* 0x10 */ XK_Q, NoSymbol, NoSymbol, NoSymbol, + /* 0x11 */ XK_W, NoSymbol, NoSymbol, NoSymbol, + /* 0x12 */ XK_E, NoSymbol, NoSymbol, NoSymbol, + /* 0x13 */ XK_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x14 */ XK_T, NoSymbol, NoSymbol, NoSymbol, + /* 0x15 */ XK_Y, NoSymbol, NoSymbol, NoSymbol, + /* 0x16 */ XK_U, NoSymbol, NoSymbol, NoSymbol, + /* 0x17 */ XK_I, NoSymbol, NoSymbol, NoSymbol, + /* 0x18 */ XK_O, NoSymbol, NoSymbol, NoSymbol, + /* 0x19 */ XK_P, NoSymbol, NoSymbol, NoSymbol, + /* 0x1a */ XK_bracketleft, XK_braceleft, NoSymbol, NoSymbol, + /* 0x1b */ XK_bracketright,XK_braceright, NoSymbol, NoSymbol, + /* 0x1c */ XK_Return, NoSymbol, NoSymbol, NoSymbol, + /* 0x1d */ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x1e */ XK_A, NoSymbol, NoSymbol, NoSymbol, + /* 0x1f */ XK_S, NoSymbol, NoSymbol, NoSymbol, + /* 0x20 */ XK_D, NoSymbol, NoSymbol, NoSymbol, + /* 0x21 */ XK_F, NoSymbol, NoSymbol, NoSymbol, + /* 0x22 */ XK_G, NoSymbol, NoSymbol, NoSymbol, + /* 0x23 */ XK_H, NoSymbol, NoSymbol, NoSymbol, + /* 0x24 */ XK_J, NoSymbol, NoSymbol, NoSymbol, + /* 0x25 */ XK_K, NoSymbol, NoSymbol, NoSymbol, + /* 0x26 */ XK_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x27 */ XK_semicolon, XK_colon, NoSymbol, NoSymbol, + /* 0x28 */ XK_quoteright, XK_quotedbl, NoSymbol, NoSymbol, + /* 0x29 */ XK_quoteleft, XK_asciitilde, NoSymbol, NoSymbol, + /* 0x2a */ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x2b */ XK_backslash, XK_bar, NoSymbol, NoSymbol, + /* 0x2c */ XK_Z, NoSymbol, NoSymbol, NoSymbol, + /* 0x2d */ XK_X, NoSymbol, NoSymbol, NoSymbol, + /* 0x2e */ XK_C, NoSymbol, NoSymbol, NoSymbol, + /* 0x2f */ XK_V, NoSymbol, NoSymbol, NoSymbol, + /* 0x30 */ XK_B, NoSymbol, NoSymbol, NoSymbol, + /* 0x31 */ XK_N, NoSymbol, NoSymbol, NoSymbol, + /* 0x32 */ XK_M, NoSymbol, NoSymbol, NoSymbol, + /* 0x33 */ XK_comma, XK_less, NoSymbol, NoSymbol, + /* 0x34 */ XK_period, XK_greater, NoSymbol, NoSymbol, + /* 0x35 */ XK_slash, XK_question, NoSymbol, NoSymbol, + /* 0x36 */ XK_Shift_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x37 */ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, + /* 0x38 */ XK_Alt_L, XK_Meta_L, NoSymbol, NoSymbol, + /* 0x39 */ XK_space, NoSymbol, NoSymbol, NoSymbol, + /* 0x3a */ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x3b */ XK_F1, NoSymbol, NoSymbol, NoSymbol, + /* 0x3c */ XK_F2, NoSymbol, NoSymbol, NoSymbol, + /* 0x3d */ XK_F3, NoSymbol, NoSymbol, NoSymbol, + /* 0x3e */ XK_F4, NoSymbol, NoSymbol, NoSymbol, + /* 0x3f */ XK_F5, NoSymbol, NoSymbol, NoSymbol, + /* 0x40 */ XK_F6, NoSymbol, NoSymbol, NoSymbol, + /* 0x41 */ XK_F7, NoSymbol, NoSymbol, NoSymbol, + /* 0x42 */ XK_F8, NoSymbol, NoSymbol, NoSymbol, + /* 0x43 */ XK_F9, NoSymbol, NoSymbol, NoSymbol, + /* 0x44 */ XK_F10, NoSymbol, NoSymbol, NoSymbol, + /* 0x45 */ XK_Num_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x46 */ XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, + /* 0x47 */ XK_KP_Home, XK_KP_7, NoSymbol, NoSymbol, + /* 0x48 */ XK_KP_Up, XK_KP_8, NoSymbol, NoSymbol, + /* 0x49 */ XK_KP_Prior, XK_KP_9, NoSymbol, NoSymbol, + /* 0x4a */ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, + /* 0x4b */ XK_KP_Left, XK_KP_4, NoSymbol, NoSymbol, + /* 0x4c */ NoSymbol, XK_KP_5, NoSymbol, NoSymbol, + /* 0x4d */ XK_KP_Right, XK_KP_6, NoSymbol, NoSymbol, + /* 0x4e */ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, + /* 0x4f */ XK_KP_End, XK_KP_1, NoSymbol, NoSymbol, + /* 0x50 */ XK_KP_Down, XK_KP_2, NoSymbol, NoSymbol, + /* 0x51 */ XK_KP_Next, XK_KP_3, NoSymbol, NoSymbol, + /* 0x52 */ XK_KP_Insert, XK_KP_0, NoSymbol, NoSymbol, + /* 0x53 */ XK_KP_Delete, XK_KP_Decimal, NoSymbol, NoSymbol, + /* 0x54 */ XK_Sys_Req, NoSymbol, NoSymbol, NoSymbol, + /* 0x55 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x56 */ XK_less, XK_greater, NoSymbol, NoSymbol, + /* 0x57 */ XK_F11, NoSymbol, NoSymbol, NoSymbol, + /* 0x58 */ XK_F12, NoSymbol, NoSymbol, NoSymbol, + /* 0x59 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x5f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x60 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x61 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x62 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x63 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x64 */ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, + /* 0x65 */ XK_Control_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x66 */ XK_Pause, NoSymbol, NoSymbol, NoSymbol, + /* 0x67 */ XK_Print, NoSymbol, NoSymbol, NoSymbol, + /* 0x68 */ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, + /* 0x69 */ XK_Alt_R, XK_Meta_R, NoSymbol, NoSymbol, + /* 0x6a */ XK_Break, NoSymbol, NoSymbol, NoSymbol, + /* 0x6b */ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, + /* 0x6c */ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, + /* 0x6d */ XK_Menu, NoSymbol, NoSymbol, NoSymbol, + /* 0x6e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x6f */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x70 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x71 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x72 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x73 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x74 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x75 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x76 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x77 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x78 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x79 */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7a */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7b */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7c */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7d */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, + /* 0x7e */ NoSymbol, NoSymbol, NoSymbol, NoSymbol, +}; +#endif diff --git a/driver/xf86-input-keyboard/src/xf86OSKbd.h b/driver/xf86-input-keyboard/src/xf86OSKbd.h new file mode 100644 index 000000000..4ab722ca3 --- /dev/null +++ b/driver/xf86-input-keyboard/src/xf86OSKbd.h @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2002-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + * + * Author: Ivan Pascal. + */ + +#include "xf86Xinput.h" + +Bool ATScancode(InputInfoPtr pInfo, int *scanCode); + +/* Public interface to OS-specific keyboard support. */ + +typedef int (*KbdInitProc)(InputInfoPtr pInfo, int what); +typedef int (*KbdOnProc)(InputInfoPtr pInfo, int what); +typedef int (*KbdOffProc)(InputInfoPtr pInfo, int what); +typedef void (*BellProc)(InputInfoPtr pInfo, + int loudness, int pitch, int duration); +typedef void (*SetLedsProc)(InputInfoPtr pInfo, int leds); +typedef int (*GetLedsProc)(InputInfoPtr pInfo); +typedef void (*SetKbdRepeatProc)(InputInfoPtr pInfo, char rad); +typedef void (*KbdGetMappingProc)(InputInfoPtr pInfo, + KeySymsPtr pKeySyms, CARD8* pModMap); +typedef int (*GetSpecialKeyProc)(InputInfoPtr pInfo, int scanCode); +typedef Bool (*SpecialKeyProc)(InputInfoPtr pInfo, + int key, Bool down, int modifiers); +typedef int (*RemapScanCodeProc)(InputInfoPtr pInfo, int *scanCode); +typedef Bool (*OpenKeyboardProc)(InputInfoPtr pInfo); +typedef void (*PostEventProc)(InputInfoPtr pInfo, + unsigned int key, Bool down); +typedef struct { + int begin; + int end; + unsigned char *map; +} TransMapRec, *TransMapPtr; + +typedef struct { + KbdInitProc KbdInit; + KbdOnProc KbdOn; + KbdOffProc KbdOff; + BellProc Bell; + SetLedsProc SetLeds; + GetLedsProc GetLeds; + SetKbdRepeatProc SetKbdRepeat; + KbdGetMappingProc KbdGetMapping; + RemapScanCodeProc RemapScanCode; + GetSpecialKeyProc GetSpecialKey; + SpecialKeyProc SpecialKey; + + OpenKeyboardProc OpenKeyboard; + PostEventProc PostEvent; + + int rate; + int delay; + int bell_pitch; + int bell_duration; + Bool autoRepeat; + unsigned long leds; + unsigned long xledsMask; + unsigned long keyLeds; + int scanPrefix; + Bool vtSwitchSupported; + Bool CustomKeycodes; + Bool noXkb; + Bool isConsole; + TransMapPtr scancodeMap; + TransMapPtr specialMap; + + /* os specific */ + pointer private; + int kbdType; + int consType; + int wsKbdType; + Bool sunKbd; + Bool Panix106; + +} KbdDevRec, *KbdDevPtr; + +typedef enum { + PROT_STD, + PROT_XQUEUE, + PROT_WSCONS, + PROT_USB, + PROT_UNKNOWN_KBD +} KbdProtocolId; + +typedef struct { + const char *name; + KbdProtocolId id; +} KbdProtocolRec; + +Bool xf86OSKbdPreInit(InputInfoPtr pInfo); + +/* Adjust this when the kbd interface changes. */ + +/* + * History: + * + * 1.0.0 - Initial version. + */ + +#define OS_KBD_VERSION_MAJOR 1 +#define OS_KBD_VERSION_MINOR 0 +#define OS_KBD_VERSION_PATCH 0 + +#define OS_KBD_VERSION_CURRENT \ + BUILTIN_INTERFACE_VERSION_NUMERIC(OS_KBD_VERSION_MAJOR, \ + OS_KBD_VERSION_MINOR, \ + OS_KBD_VERSION_PATCH) + |