* removed files programs/Xserver/hw/xfree86/common/xf86Kbd.c programs/Xserver/hw/xfree86/common/xf86KbdBSD.c programs/Xserver/hw/xfree86/common/xf86KbdLnx.c programs/Xserver/hw/xfree86/common/xf86KbdMach.c * modified files --- orig/programs/Xserver/hw/xfree86/common/Imakefile +++ mod/programs/Xserver/hw/xfree86/common/Imakefile @@ -10,26 +10,6 @@ #include -#ifdef i386MachArchitecture -#ifdef GNUMachArchitecture - KBD = xf86Kbd -#else - KBD = xf86KbdMach -#endif /* GNUMachArchitecture */ -#else -# if defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture) \ - || defined(OpenBSDArchitecture) || defined(NetBSDArchitecture) \ - || defined(FreeBSDArchitecture) - KBD = xf86KbdBSD -# else -# ifdef LinuxArchitecture - KBD = xf86KbdLnx -# else - KBD = xf86Kbd -# endif -# endif -#endif - #if defined(SparcArchitecture) || defined(Sparc64Architecture) SBUSSRC = xf86sbusBus.c SBUSOBJ = xf86sbusBus.o @@ -121,7 +101,6 @@ xf86Versions.c \ xorgHelper.c \ $(DEBUGSRC) \ - $(KBD).c \ $(SBUSSRC) \ $(XF86_XINPUT_SRC) \ $(XINPUT_DEV_SRCS) \ @@ -165,7 +144,6 @@ $(XF86_XINPUT_OBJ) \ $(XKBDDXOBJ) \ $(BETAOBJ) \ - $(KBD).o \ $(RANDROBJ) OFILES = \ --- orig/programs/Xserver/hw/xfree86/common/xf86Config.c +++ mod/programs/Xserver/hw/xfree86/common/xf86Config.c @@ -370,16 +370,6 @@ } -Bool -xf86BuiltinInputDriver(const char *name) -{ - if (xf86NameCmp(name, "keyboard") == 0) - return TRUE; - else - return FALSE; -} - - char ** xf86InputDriverlistFromConfig() { @@ -404,8 +394,7 @@ if (xf86ConfigLayout.inputs) { idp = xf86ConfigLayout.inputs; while (idp->identifier) { - if (!xf86BuiltinInputDriver(idp->driver)) - count++; + count++; idp++; } } @@ -420,10 +409,8 @@ count = 0; idp = xf86ConfigLayout.inputs; while (idp->identifier) { - if (!xf86BuiltinInputDriver(idp->driver)) { - modulearray[count] = idp->driver; - count++; - } + modulearray[count] = idp->driver; + count++; idp++; } modulearray[count] = NULL; @@ -1074,290 +1061,6 @@ } /* - * XXX This function is temporary, and will be removed when the keyboard - * driver is converted into a regular input driver. - */ -static Bool -configInputKbd(IDevPtr inputp) -{ - char *s; - MessageType from = X_DEFAULT; - Bool customKeycodesDefault = FALSE; - int verb = 0; - - /* Initialize defaults */ - xf86Info.xleds = 0L; - xf86Info.kbdDelay = 500; - xf86Info.kbdRate = 30; - - xf86Info.kbdProc = NULL; - xf86Info.vtinit = NULL; - xf86Info.vtSysreq = VT_SYSREQ_DEFAULT; -#if defined(SVR4) && defined(i386) - xf86Info.panix106 = FALSE; -#endif - xf86Info.kbdCustomKeycodes = FALSE; -#ifdef WSCONS_SUPPORT - xf86Info.kbdFd = -1; -#endif -#ifdef XKB - if (!xf86IsPc98()) { - xf86Info.xkbrules = __XKBDEFRULES__; - xf86Info.xkbmodel = "pc105"; - xf86Info.xkblayout = "us"; - xf86Info.xkbvariant = NULL; - xf86Info.xkboptions = NULL; - } else { - xf86Info.xkbrules = "xfree98"; - xf86Info.xkbmodel = "pc98"; - xf86Info.xkblayout = "nec/jp"; - xf86Info.xkbvariant = NULL; - xf86Info.xkboptions = NULL; - } - xf86Info.xkbcomponents_specified = FALSE; - /* Should discourage the use of these. */ - xf86Info.xkbkeymap = NULL; - xf86Info.xkbtypes = NULL; - xf86Info.xkbcompat = NULL; - xf86Info.xkbkeycodes = NULL; - xf86Info.xkbsymbols = NULL; - xf86Info.xkbgeometry = NULL; -#endif - - s = xf86SetStrOption(inputp->commonOptions, "Protocol", "standard"); - if (xf86NameCmp(s, "standard") == 0) { - xf86Info.kbdProc = xf86KbdProc; - xf86Info.kbdEvents = xf86KbdEvents; - xfree(s); - } else if (xf86NameCmp(s, "xqueue") == 0) { -#ifdef XQUEUE - xf86Info.kbdProc = xf86XqueKbdProc; - xf86Info.kbdEvents = xf86XqueEvents; - xf86Msg(X_CONFIG, "Xqueue selected for keyboard input\n"); -#endif - xfree(s); -#ifdef WSCONS_SUPPORT - } else if (xf86NameCmp(s, "wskbd") == 0) { - xf86Info.kbdProc = xf86KbdProc; - xf86Info.kbdEvents = xf86WSKbdEvents; - xfree(s); - s = xf86SetStrOption(inputp->commonOptions, "Device", NULL); - xf86Msg(X_CONFIG, "Keyboard: Protocol: wskbd\n"); - if (s == NULL) { - xf86ConfigError("A \"device\" option is required with" - " the \"wskbd\" keyboard protocol"); - return FALSE; - } - xf86Info.kbdFd = open(s, O_RDWR | O_NONBLOCK | O_EXCL); - if (xf86Info.kbdFd == -1) { - xf86ConfigError("cannot open \"%s\"", s); - xfree(s); - return FALSE; - } - xfree(s); - /* Find out keyboard type */ - if (ioctl(xf86Info.kbdFd, WSKBDIO_GTYPE, &xf86Info.wsKbdType) == -1) { - xf86ConfigError("cannot get keyboard type"); - close(xf86Info.kbdFd); - return FALSE; - } - switch (xf86Info.wsKbdType) { - case WSKBD_TYPE_PC_XT: - xf86Msg(X_PROBED, "Keyboard type: XT\n"); - break; - case WSKBD_TYPE_PC_AT: - xf86Msg(X_PROBED, "Keyboard type: AT\n"); - break; - case WSKBD_TYPE_USB: - xf86Msg(X_PROBED, "Keyboard type: USB\n"); - break; -#ifdef WSKBD_TYPE_ADB - case WSKBD_TYPE_ADB: - xf86Msg(X_PROBED, "Keyboard type: ADB\n"); - break; -#endif -#ifdef WSKBD_TYPE_SUN - case WSKBD_TYPE_SUN: - xf86Msg(X_PROBED, "Keyboard type: Sun\n"); - break; -#endif -#ifdef WSKBD_TYPE_SUN5 - case WSKBD_TYPE_SUN5: - xf86Msg(X_PROBED, "Keyboard type: Sun5\n"); - break; -#endif - default: - xf86ConfigError("Unsupported wskbd type \"%d\"", - xf86Info.wsKbdType); - close(xf86Info.kbdFd); - return FALSE; - } -#endif - } else { - xf86ConfigError("\"%s\" is not a valid keyboard protocol name", s); - xfree(s); - return FALSE; - } - - s = xf86SetStrOption(inputp->commonOptions, "AutoRepeat", NULL); - if (s) { - if (sscanf(s, "%d %d", &xf86Info.kbdDelay, &xf86Info.kbdRate) != 2) { - xf86ConfigError("\"%s\" is not a valid AutoRepeat value", s); - xfree(s); - return FALSE; - } - xfree(s); - } - - s = xf86SetStrOption(inputp->commonOptions, "XLeds", NULL); - if (s) { - char *l, *end; - unsigned int i; - l = strtok(s, " \t\n"); - while (l) { - i = strtoul(l, &end, 0); - if (*end == '\0') - xf86Info.xleds |= 1L << (i - 1); - else { - xf86ConfigError("\"%s\" is not a valid XLeds value", l); - xfree(s); - return FALSE; - } - l = strtok(NULL, " \t\n"); - } - xfree(s); - } - -#ifdef XKB - from = X_DEFAULT; - if (noXkbExtension) - from = X_CMDLINE; - else if (xf86FindOption(inputp->commonOptions, "XkbDisable")) { - xf86Msg(X_WARNING, "KEYBOARD: XKB should be disabled in the " - "ServerFlags section instead\n" - "\tof in the \"keyboard\" InputDevice section.\n"); - noXkbExtension = - xf86SetBoolOption(inputp->commonOptions, "XkbDisable", FALSE); - from = X_CONFIG; - } - if (noXkbExtension) - xf86Msg(from, "XKB: disabled\n"); - -#define NULL_IF_EMPTY(s) (s[0] ? s : (xfree(s), (char *)NULL)) - - if (!noXkbExtension && !XkbInitialMap) { - if ((s = xf86SetStrOption(inputp->commonOptions, "XkbKeymap", NULL))) { - xf86Info.xkbkeymap = NULL_IF_EMPTY(s); - xf86Msg(X_CONFIG, "XKB: keymap: \"%s\" " - "(overrides other XKB settings)\n", xf86Info.xkbkeymap); - } else { - if ((s = xf86SetStrOption(inputp->commonOptions, "XkbCompat", NULL))) { - xf86Info.xkbcompat = NULL_IF_EMPTY(s); - xf86Info.xkbcomponents_specified = TRUE; - xf86Msg(X_CONFIG, "XKB: compat: \"%s\"\n", s); - } - - if ((s = xf86SetStrOption(inputp->commonOptions, "XkbTypes", NULL))) { - xf86Info.xkbtypes = NULL_IF_EMPTY(s); - xf86Info.xkbcomponents_specified = TRUE; - xf86Msg(X_CONFIG, "XKB: types: \"%s\"\n", s); - } - - if ((s = xf86SetStrOption(inputp->commonOptions, "XkbKeycodes", NULL))) { - xf86Info.xkbkeycodes = NULL_IF_EMPTY(s); - xf86Info.xkbcomponents_specified = TRUE; - xf86Msg(X_CONFIG, "XKB: keycodes: \"%s\"\n", s); - } - - if ((s = xf86SetStrOption(inputp->commonOptions, "XkbGeometry", NULL))) { - xf86Info.xkbgeometry = NULL_IF_EMPTY(s); - xf86Info.xkbcomponents_specified = TRUE; - xf86Msg(X_CONFIG, "XKB: geometry: \"%s\"\n", s); - } - - if ((s = xf86SetStrOption(inputp->commonOptions, "XkbSymbols", NULL))) { - xf86Info.xkbsymbols = NULL_IF_EMPTY(s); - xf86Info.xkbcomponents_specified = TRUE; - xf86Msg(X_CONFIG, "XKB: symbols: \"%s\"\n", s); - } - - if ((s = xf86SetStrOption(inputp->commonOptions, "XkbRules", NULL))) { - xf86Info.xkbrules = NULL_IF_EMPTY(s); - xf86Info.xkbcomponents_specified = TRUE; - xf86Msg(X_CONFIG, "XKB: rules: \"%s\"\n", s); - } - - if ((s = xf86SetStrOption(inputp->commonOptions, "XkbModel", NULL))) { - xf86Info.xkbmodel = NULL_IF_EMPTY(s); - xf86Info.xkbcomponents_specified = TRUE; - xf86Msg(X_CONFIG, "XKB: model: \"%s\"\n", s); - } - - if ((s = xf86SetStrOption(inputp->commonOptions, "XkbLayout", NULL))) { - xf86Info.xkblayout = NULL_IF_EMPTY(s); - xf86Info.xkbcomponents_specified = TRUE; - xf86Msg(X_CONFIG, "XKB: layout: \"%s\"\n", s); - } - - if ((s = xf86SetStrOption(inputp->commonOptions, "XkbVariant", NULL))) { - xf86Info.xkbvariant = NULL_IF_EMPTY(s); - xf86Info.xkbcomponents_specified = TRUE; - xf86Msg(X_CONFIG, "XKB: variant: \"%s\"\n", s); - } - - if ((s = xf86SetStrOption(inputp->commonOptions, "XkbOptions", NULL))) { - xf86Info.xkboptions = NULL_IF_EMPTY(s); - xf86Info.xkbcomponents_specified = TRUE; - xf86Msg(X_CONFIG, "XKB: options: \"%s\"\n", s); - } - } - } -#undef NULL_IF_EMPTY -#endif -#if defined(SVR4) && defined(i386) - if ((xf86Info.panix106 = - xf86SetBoolOption(inputp->commonOptions, "Panix106", FALSE))) { - xf86Msg(X_CONFIG, "PANIX106: enabled\n"); - } -#endif - - /* - * This was once a compile time option (ASSUME_CUSTOM_KEYCODES) - * defaulting to 1 on Linux/PPC. It is no longer necessary, but for - * backwards compatibility we provide 'Option "CustomKeycodes"' - * and try to autoprobe on Linux/PPC. - */ - from = X_DEFAULT; - verb = 2; -#if defined(__linux__) && defined(__powerpc__) - { - FILE *f; - - f = fopen("/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes","r"); - if (f) { - if (fgetc(f) == '0') { - customKeycodesDefault = TRUE; - from = X_PROBED; - verb = 1; - } - fclose(f); - } - } -#endif - if (xf86FindOption(inputp->commonOptions, "CustomKeycodes")) { - from = X_CONFIG; - verb = 1; - } - xf86Info.kbdCustomKeycodes = - xf86SetBoolOption(inputp->commonOptions, "CustomKeycodes", - customKeycodesDefault); - xf86MsgVerb(from, verb, "Keyboard: CustomKeycode %s\n", - xf86Info.kbdCustomKeycodes ? "enabled" : "disabled"); - - return TRUE; -} - -/* * Locate the core input devices. These can be specified/located in * the following ways, in order of priority: * @@ -2404,10 +2107,6 @@ inputp->commonOptions = conf_input->inp_option_lst; inputp->extraOptions = NULL; - /* XXX This is required until the keyboard driver is converted */ - if (!xf86NameCmp(inputp->driver, "keyboard")) - return configInputKbd(inputp); - return TRUE; } --- orig/programs/Xserver/hw/xfree86/common/xf86Events.c +++ mod/programs/Xserver/hw/xfree86/common/xf86Events.c @@ -414,681 +414,6 @@ } } -/* - * xf86PostKbdEvent -- - * Translate the raw hardware KbdEvent into an XEvent, and tell DIX - * about it. Scancode preprocessing and so on is done ... - * - * OS/2 specific xf86PostKbdEvent(key) has been moved to os-support/os2/os2_kbd.c - * as some things differ, and I did not want to scatter this routine with - * ifdefs further (hv). - */ - -#ifdef __linux__ -extern u_char SpecialServerMap[]; -#endif - -#if !defined(__UNIXOS2__) && \ - !defined(__SOL8__) && \ - (!defined(sun) || defined(i386)) -void -xf86PostKbdEvent(unsigned key) -{ - int scanCode = (key & 0x7f); - int specialkey = 0; - Bool down = (key & 0x80 ? FALSE : TRUE); - KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key; - Bool updateLeds = FALSE; - Bool UsePrefix = FALSE; - Bool Direction = FALSE; - xEvent kevent; - KeySym *keysym; - int keycode; - static int lockkeys = 0; -#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT) - static Bool first_time = TRUE; -#endif -#if defined(__sparc__) && defined(__linux__) - static int kbdSun = -1; -#endif - /* Disable any keyboard processing while in suspend */ - if (xf86inSuspend) - return; - -#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT) - if (first_time) - { - first_time = FALSE; - VTSwitchEnabled = (xf86Info.consType == SYSCONS) - || (xf86Info.consType == PCVT); - } -#endif - -#if defined (__sparc__) && defined(__linux__) - if (kbdSun == -1) { - if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun")) - || (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun"))) - kbdSun = 1; - else - kbdSun = 0; - } - if (kbdSun) - goto special; -#endif /* __sparc__ && __linux__ */ - -#ifdef __linux__ - if (xf86Info.kbdCustomKeycodes) { - specialkey = SpecialServerMap[scanCode]; - goto customkeycodes; - } -#endif - - /* - * First do some special scancode remapping ... - */ - if (xf86Info.scanPrefix == 0) { - - switch (scanCode) { - case KEY_Prefix0: - case KEY_Prefix1: -#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT) - if (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS - || xf86Info.consType == PCVT -#ifdef WSCONS_SUPPORT - || (xf86Info.consType == WSCONS && xf86Info.kbdEvents != xf86WSKbdEvents) -#endif - ) { -#endif - xf86Info.scanPrefix = scanCode; /* special prefixes */ - return; -#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT) - } - break; -#endif - } -#if defined (i386) && defined (SVR4) - /* - * PANIX returns DICOP standards based keycodes in using 106jp - * keyboard. We need to remap some keys. - */ - if(xf86Info.panix106 == TRUE){ - switch (scanCode) { - case 0x56: scanCode = KEY_BSlash2; break; /* Backslash */ - case 0x5A: scanCode = KEY_NFER; break; /* No Kanji Transfer*/ - case 0x5B: scanCode = KEY_XFER; break; /* Kanji Tranfer */ - case 0x5C: scanCode = KEY_Yen; break; /* Yen curs pgup */ - case 0x6B: scanCode = KEY_Left; break; /* Cur Left */ - case 0x6F: scanCode = KEY_PgUp; break; /* Cur PageUp */ - case 0x72: scanCode = KEY_AltLang; break; /* AltLang(right) */ - case 0x73: scanCode = KEY_RCtrl; break; /* not needed */ - } - } else -#endif /* i386 && SVR4 */ - { - 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; - } - } - } - - else if ( -#ifdef CSRG_BASED - (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS - || xf86Info.consType == PCVT -#ifdef WSCONS_SUPPORT - || (xf86Info.consType == WSCONS && xf86Info.kbdEvents != - xf86WSKbdEvents) -#endif - ) && -#endif - (xf86Info.scanPrefix == KEY_Prefix0)) { - xf86Info.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; - /* - * Ignore virtual shifts (E0 2A, E0 AA, E0 36, E0 B6) - */ - case 0x2A: - case 0x36: - return; - default: - xf86MsgVerb(X_INFO, 4, "Unreported Prefix0 scancode: 0x%02x\n", - scanCode); - /* - * "Internet" keyboards are generating lots of new codes. Let them - * pass. There is little consistency between them, so don't bother - * with symbolic names at this level. - */ - scanCode += 0x78; - } - } - - else if (xf86Info.scanPrefix == KEY_Prefix1) - { - xf86Info.scanPrefix = (scanCode == KEY_LCtrl) ? KEY_LCtrl : 0; - return; - } - - else if (xf86Info.scanPrefix == KEY_LCtrl) - { - xf86Info.scanPrefix = 0; - if (scanCode != KEY_NumLock) return; - scanCode = KEY_Pause; /* pause */ - } - -#ifndef __sparc64__ - /* - * PC keyboards generate separate key codes for - * Alt+Print and Control+Pause but in the X keyboard model - * they need to get the same key code as the base key on the same - * physical keyboard key. - */ - if (scanCode == KEY_SysReqest) - scanCode = KEY_Print; - else if (scanCode == KEY_Break) - scanCode = KEY_Pause; -#endif - - /* - * and now get some special keysequences - */ - - specialkey = scanCode; - -#ifdef __linux__ -customkeycodes: -#endif -#if defined(i386) || defined(__i386__) - if (xf86IsPc98()) { - switch (scanCode) { - case 0x0e: specialkey = 0x0e; break; /* KEY_BackSpace */ - case 0x40: specialkey = 0x4a; break; /* KEY_KP_Minus */ - case 0x49: specialkey = 0x4e; break; /* KEY_KP_Plus */ - - /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */ - - case 0x62: specialkey = 0x3b; break; /* KEY_F1 */ - case 0x63: specialkey = 0x3c; break; /* KEY_F2 */ - case 0x64: specialkey = 0x3d; break; /* KEY_F3 */ - case 0x65: specialkey = 0x3e; break; /* KEY_F4 */ - case 0x66: specialkey = 0x3f; break; /* KEY_F5 */ - case 0x67: specialkey = 0x40; break; /* KEY_F6 */ - case 0x68: specialkey = 0x41; break; /* KEY_F7 */ - case 0x69: specialkey = 0x42; break; /* KEY_F8 */ - case 0x6a: specialkey = 0x43; break; /* KEY_F9 */ - case 0x6b: specialkey = 0x44; break; /* KEY_F10 */ - /* case 0x73: specialkey = 0x38; break; KEY_Alt */ - /* case 0x74: specialkey = 0x1d; break; KEY_LCtrl */ - default: specialkey = 0x00; break; - } - } -#endif -#if defined (__sparc__) && defined(__linux__) -special: - if (kbdSun) { - 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; - } - /* - * XXX XXX XXX: - * - * I really don't know what's wrong here, but passing the real - * scanCode offsets by one from XKB's point of view. - * - * (ecd@skynet.be, 980405) - */ - scanCode--; - } -#endif /* defined (__sparc__) && defined(__linux__) */ - -#ifdef XKB - if ((xf86Info.ddxSpecialKeys == SKWhenNeeded && - !xf86Info.ActionKeyBindingsSet) || - noXkbExtension || xf86Info.ddxSpecialKeys == SKAlways) { -#endif - if (!(ModifierDown(ShiftMask)) && - ((ModifierDown(ControlMask | AltMask)) || - (ModifierDown(ControlMask | AltLangMask)))) - { - switch (specialkey) { - - case KEY_BackSpace: - xf86ProcessActionEvent(ACTION_TERMINATE, NULL); - break; - - /* - * Check grabs - */ - case KEY_KP_Divide: - xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL); - break; - case KEY_KP_Multiply: - xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL); - break; - - /* - * Video mode switches - */ - case KEY_KP_Minus: /* Keypad - */ - if (down) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL); - if (!xf86Info.dontZoom) return; - break; - - case KEY_KP_Plus: /* Keypad + */ - if (down) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL); - if (!xf86Info.dontZoom) return; - break; - - /* Under QNX4, we set the vtPending flag for VT switching and - * let the VT switch function do the rest... - * This is a little different from the other OS'es. - */ -#if defined(QNX4) - case KEY_1: - case KEY_2: - case KEY_3: - case KEY_4: - case KEY_5: - case KEY_6: - case KEY_7: - case KEY_8: - case KEY_9: - if (VTSwitchEnabled && !xf86Info.dontVTSwitch) { - if (down) { - int vtno = specialkey - KEY_1 + 1; - xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno); - } - return; - } - break; -#endif - -#if defined(linux) || (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT))) || defined(SCO) - /* - * Under Linux, the raw keycodes are consumed before the kernel - * does any processing on them, so we must emulate the vt switching - * we want ourselves. - */ - 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: - case KEY_F11: - case KEY_F12: - if ((VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch) -#if (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT))) - && (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT) -#endif - ) { - int vtno = specialkey - KEY_F1 + 1; - if (specialkey == KEY_F11 || specialkey == KEY_F12) - vtno = specialkey - KEY_F11 + 11; - if (down) - xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno); - return; - } - break; -#endif /* linux || BSD with VTs */ - - /* just worth mentioning here: any 386bsd keyboard driver - * (pccons.c or co_kbd.c) catches CTRL-ALT-DEL and CTRL-ALT-ESC - * before any application (e.g. XF86) will see it - * OBS: syscons does not, nor does pcvt ! - */ - } - } - - /* - * Start of actual Solaris VT switching code. - * This should pretty much emulate standard SVR4 switching keys. - * - * DWH 12/2/93 - */ - -#ifdef USE_VT_SYSREQ - if (VTSwitchEnabled && xf86Info.vtSysreq && !xf86Info.dontVTSwitch) - { - switch (specialkey) - { - /* - * syscons on *BSD doesn't have a VT #0 -- don't think Linux does - * either - */ -#if defined (sun) && defined (i386) && defined (SVR4) - case KEY_H: - if (VTSysreqToggle && down) - { - xf86ProcessActionEvent(ACTION_SWITCHSCREEN, NULL); - VTSysreqToggle = 0; - return; - } - break; - - /* - * Yah, I know the N, and P keys seem backwards, however that's - * how they work under Solaris - * XXXX N means go to next active VT not necessarily vtno+1 (or vtno-1) - */ - - case KEY_N: - if (VTSysreqToggle && down) - { - xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL); - VTSysreqToggle = FALSE; - return; - } - break; - - case KEY_P: - if (VTSysreqToggle && down) - { - xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL); - VTSysreqToggle = FALSE; - return; - } - break; -#endif - - 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: - case KEY_F11: - case KEY_F12: - if (VTSysreqToggle && down) - { int vtno = specialkey - KEY_F1 + 1; - if (specialkey == KEY_F11 || specialkey == KEY_F12) - vtno = specialkey - KEY_F11 + 11; - xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno); - VTSysreqToggle = FALSE; - return; - } - break; - - /* Ignore these keys -- ie don't let them cancel an alt-sysreq */ - case KEY_Alt: - case KEY_AltLang: - break; - - case KEY_SysReqest: - if (down && (ModifierDown(AltMask) || ModifierDown(AltLangMask))) - VTSysreqToggle = TRUE; - break; - - default: - if (VTSysreqToggle) - { - /* - * We only land here when Alt-SysReq is followed by a - * non-switching key. - */ - VTSysreqToggle = FALSE; - - } - } - } - -#endif /* USE_VT_SYSREQ */ - -#ifdef SCO - /* - * With the console in raw mode, SCO will not switch consoles, - * you get around this by activating the next console along, if - * this fails then go back to console 0, if there is only one - * then it doesn't matter, switching to yourself is a nop as far - * as the console driver is concerned. - * We could do something similar to linux here but SCO ODT uses - * Ctrl-PrintScrn, so why change? - */ - if (specialkey == KEY_Print && ModifierDown(ControlMask)) { - if (down) - xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL); - return; - } -#endif /* SCO */ -#ifdef XKB - } -#endif - - /* - * Now map the scancodes to real X-keycodes ... - */ - keycode = scanCode + MIN_KEYCODE; - keysym = (keyc->curKeySyms.map + - keyc->curKeySyms.mapWidth * - (keycode - keyc->curKeySyms.minKeyCode)); -#ifdef XKB - if (noXkbExtension) { -#endif - /* - * Filter autorepeated caps/num/scroll lock keycodes. - */ -#define CAPSFLAG 0x01 -#define NUMFLAG 0x02 -#define SCROLLFLAG 0x04 -#define MODEFLAG 0x08 - if( down ) { - switch( keysym[0] ) { - case XK_Caps_Lock : - if (lockkeys & CAPSFLAG) - return; - else - lockkeys |= CAPSFLAG; - break; - - case XK_Num_Lock : - if (lockkeys & NUMFLAG) - return; - else - lockkeys |= NUMFLAG; - break; - - case XK_Scroll_Lock : - if (lockkeys & SCROLLFLAG) - return; - else - lockkeys |= SCROLLFLAG; - break; - } - if (keysym[1] == XF86XK_ModeLock) - { - if (lockkeys & MODEFLAG) - return; - else - lockkeys |= MODEFLAG; - } - - } - else { - switch( keysym[0] ) { - case XK_Caps_Lock : - lockkeys &= ~CAPSFLAG; - break; - - case XK_Num_Lock : - lockkeys &= ~NUMFLAG; - break; - - case XK_Scroll_Lock : - lockkeys &= ~SCROLLFLAG; - break; - } - if (keysym[1] == XF86XK_ModeLock) - lockkeys &= ~MODEFLAG; - } - - /* - * LockKey special handling: - * ignore releases, toggle on & off on presses. - * Don't deal with the Caps_Lock keysym directly, but check the lock modifier - */ - if (keyc->modifierMap[keycode] & LockMask || - keysym[0] == XK_Scroll_Lock || - keysym[1] == XF86XK_ModeLock || - keysym[0] == XK_Num_Lock) - { - Bool flag; - - if (!down) return; - if (KeyPressed(keycode)) { - down = !down; - flag = FALSE; - } - else - flag = TRUE; - - if (keyc->modifierMap[keycode] & LockMask) xf86Info.capsLock = flag; - if (keysym[0] == XK_Num_Lock) xf86Info.numLock = flag; - if (keysym[0] == XK_Scroll_Lock) xf86Info.scrollLock = flag; - if (keysym[1] == XF86XK_ModeLock) xf86Info.modeSwitchLock = flag; - updateLeds = TRUE; - } - - if (!xf86Info.kbdCustomKeycodes) { - /* - * normal, non-keypad keys - */ - if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) { -#if !defined(CSRG_BASED) && \ - !defined(__GNU__) && \ - defined(KB_84) - /* - * magic ALT_L key on AT84 keyboards for multilingual support - */ - if (xf86Info.kbdType == KB_84 && - ModifierDown(AltMask) && - keysym[2] != NoSymbol) - { - UsePrefix = TRUE; - Direction = TRUE; - } -#endif /* !CSRG_BASED && ... */ - } - } - if (updateLeds) xf86UpdateKbdLeds(); -#ifdef XKB - } -#endif - - /* - * check for an autorepeat-event - */ - if (down && KeyPressed(keycode)) { - KbdFeedbackClassRec *kbdfeed = ((DeviceIntPtr)xf86Info.pKeyboard)->kbdfeed; - if ((xf86Info.autoRepeat != AutoRepeatModeOn) || - keyc->modifierMap[keycode] || - (kbdfeed && !(kbdfeed->ctrl.autoRepeats[keycode>>3] & ( 1<<(keycode&7) )))) - return; - } - - - xf86Info.lastEventTime = kevent.u.keyButtonPointer.time = GetTimeInMillis(); - /* - * And now send these prefixes ... - * NOTE: There cannot be multiple Mode_Switch keys !!!! - */ - if (UsePrefix) - { - ENQUEUE(&kevent, - keyc->modifierKeyMap[keyc->maxKeysPerModifier*7], - (Direction ? KeyPress : KeyRelease), - XE_KEYBOARD); - ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD); - ENQUEUE(&kevent, - keyc->modifierKeyMap[keyc->maxKeysPerModifier*7], - (Direction ? KeyRelease : KeyPress), - XE_KEYBOARD); - } - else - { - ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD); - } -} -#endif /* !__UNIXOS2__ */ - #define ModifierIsSet(k) ((modifiers & (k)) == (k)) Bool @@ -1149,8 +474,6 @@ XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices); if (XFD_ANYSET(&devicesWithInput)) { - if (xf86Info.kbdEvents) - (xf86Info.kbdEvents)(); pInfo = xf86InputDevs; while (pInfo) { if (pInfo->read_input && pInfo->fd >= 0 && @@ -1173,8 +496,6 @@ InputInfoPtr pInfo; - (xf86Info.kbdEvents)(); /* Under OS/2 and QNX, always call */ - pInfo = xf86InputDevs; while (pInfo) { if (pInfo->read_input && pInfo->fd >= 0) { @@ -1598,31 +919,3 @@ } #endif /* XTESTEXT1 */ - -#ifdef WSCONS_SUPPORT - -/* XXX Currently XKB is mandatory. */ - -extern int WSKbdToKeycode(int); - -void -xf86PostWSKbdEvent(struct wscons_event *event) -{ - int type = event->type; - int value = event->value; - unsigned int keycode; - int blocked; - - if (type == WSCONS_EVENT_KEY_UP || type == WSCONS_EVENT_KEY_DOWN) { - Bool down = (type == WSCONS_EVENT_KEY_DOWN ? TRUE : FALSE); - - /* map the scancodes to standard XFree86 scancode */ - keycode = WSKbdToKeycode(value); - if (!down) keycode |= 0x80; - /* It seems better to block SIGIO there */ - blocked = xf86BlockSIGIO(); - xf86PostKbdEvent(keycode); - xf86UnblockSIGIO(blocked); - } -} -#endif /* WSCONS_SUPPORT */ --- orig/programs/Xserver/hw/xfree86/common/xf86Globals.c +++ mod/programs/Xserver/hw/xfree86/common/xf86Globals.c @@ -91,35 +91,12 @@ xf86InfoRec xf86Info = { NULL, /* pKeyboard */ - NULL, /* kbdProc */ - NULL, /* kbdEvents */ -1, /* consoleFd */ - -1, /* kbdFd */ -1, /* vtno */ - -1, /* kbdType */ - -1, /* kbdRate */ - -1, /* kbdDelay */ - -1, /* bell_pitch */ - -1, /* bell_duration */ - TRUE, /* autoRepeat */ - 0, /* leds */ - 0, /* xleds */ NULL, /* vtinit */ - 0, /* scanPrefix */ - FALSE, /* capsLock */ - FALSE, /* numLock */ - FALSE, /* scrollLock */ - FALSE, /* modeSwitchLock */ - FALSE, /* composeLock */ - FALSE, /* vtSysreq */ + FALSE, /* vtSysreq */ SKWhenNeeded, /* ddxSpecialKeys */ - FALSE, /* ActionKeyBindingsSet */ -#if defined(SVR4) && defined(i386) - FALSE, /* panix106 */ -#endif -#if defined(__OpenBSD__) || defined(__NetBSD__) - 0, /* wskbdType */ -#endif + NULL, /* pMouse */ #ifdef XINPUT NULL, /* mouseLocal */ --- orig/programs/Xserver/hw/xfree86/common/xf86Init.c +++ mod/programs/Xserver/hw/xfree86/common/xf86Init.c @@ -139,16 +139,6 @@ #endif static Bool formatsDone = FALSE; -InputDriverRec xf86KEYBOARD = { - 1, - "keyboard", - NULL, - NULL, - NULL, - NULL, - 0 -}; - static Bool xf86CreateRootWindow(WindowPtr pWin) { @@ -418,8 +408,6 @@ xfree(modulelist); } - /* Setup the builtin input drivers */ - xf86AddInputDriver(&xf86KEYBOARD, NULL, 0); /* Load all input driver modules specified in the config file. */ if ((modulelist = xf86InputDriverlistFromConfig())) { xf86LoadModules(modulelist, NULL); @@ -1008,12 +996,6 @@ if (serverGeneration == 1) { /* Call the PreInit function for each input device instance. */ for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) { - /* XXX The keyboard driver is a special case for now. */ - if (!xf86NameCmp(pDev->driver, "keyboard")) { - xf86Msg(X_INFO, "Keyboard \"%s\" handled by legacy driver\n", - pDev->identifier); - continue; - } if ((pDrv = MatchInput(pDev)) == NULL) { xf86Msg(X_ERROR, "No Input driver matching `%s'\n", pDev->driver); /* XXX For now, just continue. */ @@ -1088,13 +1070,8 @@ pInfo = pInfo->next; } - if (coreKeyboard) { + if (coreKeyboard) xf86Info.pKeyboard = coreKeyboard->dev; - xf86Info.kbdEvents = NULL; /* to prevent the internal keybord driver usage*/ - } - else { - xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE); - } if (corePointer) xf86Info.pMouse = corePointer->dev; RegisterKeyboardDevice(xf86Info.pKeyboard); @@ -1223,12 +1200,6 @@ int i; /* - * try to deinitialize all input devices - */ - if (xf86Info.pKeyboard) - (xf86Info.kbdProc)(xf86Info.pKeyboard, DEVICE_CLOSE); - - /* * try to restore the original video state */ #ifdef HAS_USL_VTS --- orig/programs/Xserver/hw/xfree86/common/xf86Io.c +++ mod/programs/Xserver/hw/xfree86/common/xf86Io.c @@ -63,6 +63,7 @@ #define XF86_OS_PRIVS #include "xf86_OSlib.h" #include "mipointer.h" +#include "xf86OSKbd.h" #ifdef XINPUT #include "xf86Xinput.h" @@ -70,403 +71,21 @@ #include "exevents.h" #endif -#ifdef XKB -#include -#include -#include -#endif - -unsigned int xf86InitialCaps = 0; -unsigned int xf86InitialNum = 0; -unsigned int xf86InitialScroll = 0; - -#include "atKeynames.h" - /* - * xf86KbdBell -- - * Ring the terminal/keyboard bell for an amount of time proportional to - * "loudness". + * LegalModifier -- + * determine whether a key is a legal modifier key, i.e send a + * press/release sequence. */ -void -xf86KbdBell(percent, pKeyboard, ctrl, unused) - int percent; /* Percentage of full volume */ - DeviceIntPtr pKeyboard; /* Keyboard to ring */ - pointer ctrl; - int unused; -{ - xf86SoundKbdBell(percent, xf86Info.bell_pitch, xf86Info.bell_duration); -} - -void -xf86UpdateKbdLeds() -{ - int leds = 0; - if (xf86Info.capsLock) leds |= XLED1; - if (xf86Info.numLock) leds |= XLED2; - if (xf86Info.scrollLock || xf86Info.modeSwitchLock) leds |= XLED3; - if (xf86Info.composeLock) leds |= XLED4; - xf86Info.leds = (xf86Info.leds & xf86Info.xleds) | (leds & ~xf86Info.xleds); - xf86KbdLeds(); -} - -void -xf86KbdLeds () +/*ARGSUSED*/ +Bool +LegalModifier(key, pDev) + unsigned int key; + DevicePtr pDev; { - int leds, real_leds = 0; - -#if defined (__sparc__) && defined(__linux__) - static int kbdSun = -1; - if (kbdSun == -1) { - if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun")) || - (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun"))) - kbdSun = 1; - else - kbdSun = 0; - } - if (kbdSun) { - if (xf86Info.leds & 0x08) real_leds |= XLED1; - if (xf86Info.leds & 0x04) real_leds |= XLED3; - if (xf86Info.leds & 0x02) real_leds |= XLED4; - if (xf86Info.leds & 0x01) real_leds |= XLED2; - leds = real_leds; - real_leds = 0; - } else { - leds = xf86Info.leds; - } -#else - leds = xf86Info.leds; -#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 - xf86SetKbdLeds(real_leds); - (void)leds; -} - -/* - * xf86KbdCtrl -- - * Alter some of the keyboard control parameters. All special protocol - * values are handled by dix (ProgChangeKeyboardControl) - */ - -void -xf86KbdCtrl (pKeyboard, ctrl) - DevicePtr pKeyboard; /* Keyboard to alter */ - KeybdCtrl *ctrl; -{ - int leds; - xf86Info.bell_pitch = ctrl->bell_pitch; - xf86Info.bell_duration = ctrl->bell_duration; - xf86Info.autoRepeat = ctrl->autoRepeat; - - xf86Info.composeLock = (ctrl->leds & XCOMP) ? TRUE : FALSE; - - leds = (ctrl->leds & ~(XCAPS | XNUM | XSCR)); -#ifdef XKB - if (noXkbExtension) { -#endif - xf86Info.leds = (leds & xf86Info.xleds)|(xf86Info.leds & ~xf86Info.xleds); -#ifdef XKB - } else { - xf86Info.leds = leds; - } -#endif - - xf86KbdLeds(); -} - -/* - * xf86InitKBD -- - * Reinitialize the keyboard. Only set Lockkeys according to ours leds. - * Depress all other keys. - */ - -void -xf86InitKBD(init) -Bool init; -{ - char leds = 0, rad; - unsigned int i; - xEvent kevent; - DeviceIntPtr pKeyboard = xf86Info.pKeyboard; - KeyClassRec *keyc = xf86Info.pKeyboard->key; - KeySym *map = keyc->curKeySyms.map; - - kevent.u.keyButtonPointer.time = GetTimeInMillis(); - kevent.u.keyButtonPointer.rootX = 0; - kevent.u.keyButtonPointer.rootY = 0; - - /* - * Hmm... here is the biggest hack of every time ! - * It may be possible that a switch-vt procedure has finished BEFORE - * you released all keys neccessary to do this. That peculiar behavior - * can fool the X-server pretty much, cause it assumes that some keys - * were not released. TWM may stuck alsmost completly.... - * OK, what we are doing here is after returning from the vt-switch - * exeplicitely unrelease all keyboard keys before the input-devices - * are reenabled. - */ - for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map; - i < keyc->curKeySyms.maxKeyCode; - i++, map += keyc->curKeySyms.mapWidth) - if (KeyPressed(i)) - { - switch (*map) { - /* Don't release the lock keys */ - case XK_Caps_Lock: - case XK_Shift_Lock: - case XK_Num_Lock: - case XK_Scroll_Lock: - case XK_Kana_Lock: - break; - default: - kevent.u.u.detail = i; - kevent.u.u.type = KeyRelease; - (* pKeyboard->public.processInputProc)(&kevent, pKeyboard, 1); - } - } - - xf86Info.scanPrefix = 0; - - if (init) - { - /* - * we must deal here with the fact, that on some cases the numlock or - * capslock key are enabled BEFORE the server is started up. So look - * here at the state on the according LEDS to determine whether a - * lock-key is already set. - */ - - xf86Info.capsLock = FALSE; - xf86Info.numLock = FALSE; - xf86Info.scrollLock = FALSE; - xf86Info.modeSwitchLock = FALSE; - xf86Info.composeLock = FALSE; - -#ifdef LED_CAP -#ifdef INHERIT_LOCK_STATE - leds = xf86Info.leds; - - for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map; - i < keyc->curKeySyms.maxKeyCode; - i++, map += keyc->curKeySyms.mapWidth) - - switch(*map) { - - case XK_Caps_Lock: - case XK_Shift_Lock: - if (leds & LED_CAP) - { - xf86InitialCaps = i; - xf86Info.capsLock = TRUE; - } - break; - - case XK_Num_Lock: - if (leds & LED_NUM) - { - xf86InitialNum = i; - xf86Info.numLock = TRUE; - } - break; - - case XK_Scroll_Lock: - case XK_Kana_Lock: - if (leds & LED_SCR) - { - xf86InitialScroll = i; - xf86Info.scrollLock = TRUE; - } - break; - } -#endif /* INHERIT_LOCK_STATE */ - xf86SetKbdLeds(leds); -#endif /* LED_CAP */ - (void)leds; - - if (xf86Info.kbdDelay <= 375) rad = 0x00; - else if (xf86Info.kbdDelay <= 625) rad = 0x20; - else if (xf86Info.kbdDelay <= 875) rad = 0x40; - else rad = 0x60; - - if (xf86Info.kbdRate <= 2) rad |= 0x1F; - else if (xf86Info.kbdRate >= 30) rad |= 0x00; - else rad |= ((58 / xf86Info.kbdRate) - 2); - - xf86SetKbdRepeat(rad); - } + return (TRUE); } -/* - * xf86KbdProc -- - * Handle the initialization, etc. of a keyboard. - */ - -int -xf86KbdProc (pKeyboard, what) - DeviceIntPtr pKeyboard; /* Keyboard to manipulate */ - int what; /* What to do to it */ -{ - KeySymsRec keySyms; - CARD8 modMap[MAP_LENGTH]; - int kbdFd; - - switch (what) { - - case DEVICE_INIT: - /* - * First open and find the current state of the keyboard. - */ - - xf86KbdInit(); - - xf86KbdGetMapping(&keySyms, modMap); - - -#ifndef XKB - defaultKeyboardControl.leds = xf86GetKbdLeds(); -#else - defaultKeyboardControl.leds = 0; -#endif - - /* - * Perform final initialization of the system private keyboard - * structure and fill in various slots in the device record - * itself which couldn't be filled in before. - */ - - pKeyboard->public.on = FALSE; - -#ifdef XKB - if (noXkbExtension) { -#endif - InitKeyboardDeviceStruct((DevicePtr)xf86Info.pKeyboard, - &keySyms, - modMap, - xf86KbdBell, - (KbdCtrlProcPtr)xf86KbdCtrl); -#ifdef XKB - } else { - XkbComponentNamesRec names; - XkbDescPtr desc; - Bool foundTerminate = FALSE; - int keyc; - if (XkbInitialMap) { - if ((xf86Info.xkbkeymap = strchr(XkbInitialMap, '/')) != NULL) - xf86Info.xkbkeymap++; - else - xf86Info.xkbkeymap = XkbInitialMap; - } - if (xf86Info.xkbkeymap) { - names.keymap = xf86Info.xkbkeymap; - names.keycodes = NULL; - names.types = NULL; - names.compat = NULL; - names.symbols = NULL; - names.geometry = NULL; - } else { - names.keymap = NULL; - names.keycodes = xf86Info.xkbkeycodes; - names.types = xf86Info.xkbtypes; - names.compat = xf86Info.xkbcompat; - names.symbols = xf86Info.xkbsymbols; - names.geometry = xf86Info.xkbgeometry; - } - if ((xf86Info.xkbkeymap || xf86Info.xkbcomponents_specified) - && (xf86Info.xkbmodel == NULL || xf86Info.xkblayout == NULL)) { - xf86Info.xkbrules = NULL; - } - XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel, - xf86Info.xkblayout, xf86Info.xkbvariant, - xf86Info.xkboptions); - - XkbInitKeyboardDeviceStruct(pKeyboard, - &names, - &keySyms, - modMap, - xf86KbdBell, - (KbdCtrlProcPtr)xf86KbdCtrl); - - /* Search keymap for Terminate action */ - desc = pKeyboard->key->xkbInfo->desc; - for (keyc = desc->min_key_code; keyc <= desc->max_key_code; keyc++) { - int i; - for (i = 1; i <= XkbKeyNumActions(desc, keyc); i++) { - if (XkbKeyAction(desc, keyc, i) - && XkbKeyAction(desc, keyc, i)->type == XkbSA_Terminate) { - foundTerminate = TRUE; - goto searchdone; - } - } - } -searchdone: - xf86Info.ActionKeyBindingsSet = foundTerminate; - if (!foundTerminate) - xf86Msg(X_INFO, "Server_Terminate keybinding not found\n"); - } -#endif - - xf86InitKBD(TRUE); - break; - - case DEVICE_ON: - /* - * Set the keyboard into "direct" mode and turn on - * event translation. - */ - - kbdFd = xf86KbdOn(); - /* - * Discard any pending input after a VT switch to prevent the server - * passing on parts of the VT switch sequence. - */ - sleep(1); -#if defined(WSCONS_SUPPORT) - if (xf86Info.consType != WSCONS) { -#endif - if (kbdFd != -1) { - char buf[16]; - read(kbdFd, buf, 16); - } -#if defined(WSCONS_SUPPORT) - } -#endif - -#if !defined(__UNIXOS2__) /* Under EMX, keyboard cannot be select()'ed */ - if (kbdFd != -1) - AddEnabledDevice(kbdFd); -#endif /* __UNIXOS2__ */ - - pKeyboard->public.on = TRUE; - xf86InitKBD(FALSE); - break; - - case DEVICE_CLOSE: - case DEVICE_OFF: - /* - * Restore original keyboard directness and translation. - */ - - kbdFd = xf86KbdOff(); - - if (kbdFd != -1) - RemoveEnabledDevice(kbdFd); - - pKeyboard->public.on = FALSE; - break; - - } - return (Success); -} #if defined(DDXTIME) && !defined(QNX4) /* --- orig/programs/Xserver/hw/xfree86/common/xf86MiscExt.c +++ mod/programs/Xserver/hw/xfree86/common/xf86MiscExt.c @@ -58,6 +58,7 @@ #endif #include "xf86OSmouse.h" +#include "xf86OSKbd.h" #include "../input/mouse/mouse.h" #ifdef DEBUG @@ -87,6 +88,7 @@ int rate; int delay; int serverNumLock; /* obsolete */ + pointer private; } kbdParamsRec, *kbdParamsPtr; /* @@ -254,15 +256,20 @@ MiscExtGetKbdSettings(pointer *kbd) { kbdParamsPtr kbdptr; + InputInfoPtr pInfo; + KbdDevPtr pKbd; DEBUG_P("MiscExtGetKbdSettings"); kbdptr = MiscExtCreateStruct(MISC_KEYBOARD); if (!kbdptr) return FALSE; - kbdptr->type = xf86Info.kbdType; - kbdptr->rate = xf86Info.kbdRate; - kbdptr->delay = xf86Info.kbdDelay; + pInfo = inputInfo.keyboard->public.devicePrivate; + pKbd = (KbdDevPtr) pInfo->private; + + kbdptr->type = pKbd->kbdType; + kbdptr->rate = pKbd->rate; + kbdptr->delay = pKbd->delay; *kbd = kbdptr; return TRUE; } @@ -376,7 +383,7 @@ return mseptr; } case MISC_KEYBOARD: - return xcalloc(sizeof(kbdParamsRec),1); + return xcalloc(sizeof(kbdParamsRec),1); } return 0; } @@ -592,6 +599,11 @@ } if (mse_or_kbd == MISC_KEYBOARD) { kbdParamsPtr kbd = structure; + InputInfoPtr pInfo; + KbdDevPtr pKbd; + + pInfo = inputInfo.keyboard->public.devicePrivate; + pKbd = (KbdDevPtr) pInfo->private; if (kbd->rate < 0) return MISC_RET_BADVAL; @@ -600,24 +612,24 @@ if (kbd->type < KTYPE_UNKNOWN || kbd->type > KTYPE_XQUEUE) return MISC_RET_BADKBDTYPE; - if (xf86Info.kbdRate!=kbd->rate || xf86Info.kbdDelay!=kbd->delay) { + if (pKbd->rate!=kbd->rate || pKbd->delay!=kbd->delay) { char rad; - xf86Info.kbdRate = kbd->rate; - xf86Info.kbdDelay = kbd->delay; - if (xf86Info.kbdDelay <= 375) rad = 0x00; - else if (xf86Info.kbdDelay <= 625) rad = 0x20; - else if (xf86Info.kbdDelay <= 875) rad = 0x40; - else rad = 0x60; - - if (xf86Info.kbdRate <= 2) rad |= 0x1F; - else if (xf86Info.kbdRate >= 30) rad |= 0x00; - else rad |= ((58/xf86Info.kbdRate)-2); + pKbd->rate = kbd->rate; + pKbd->delay = kbd->delay; + if (pKbd->delay <= 375) rad = 0x00; + else if (pKbd->delay <= 625) rad = 0x20; + else if (pKbd->delay <= 875) rad = 0x40; + else rad = 0x60; + + if (pKbd->rate <= 2) rad |= 0x1F; + else if (pKbd->rate >= 30) rad |= 0x00; + else rad |= ((58/pKbd->rate)-2); - xf86SetKbdRepeat(rad); + pKbd->SetKbdRepeat(pInfo, rad); } #if 0 /* Not done yet */ - xf86Info.kbdType = kbd->kbdtype; + pKdb->kbdType = kbd->kbdtype; #endif } return MISC_RET_SUCCESS; --- orig/programs/Xserver/hw/xfree86/common/xf86Priv.h +++ mod/programs/Xserver/hw/xfree86/common/xf86Priv.h @@ -200,17 +200,7 @@ /* xf86Io.c */ -void xf86KbdBell(int percent, DeviceIntPtr pKeyboard, pointer ctrl, - int unused); -void xf86KbdLeds(void); void xf86UpdateKbdLeds(void); -void xf86KbdCtrl(DevicePtr pKeyboard, KeybdCtrl *ctrl); -void xf86InitKBD(Bool init); -int xf86KbdProc(DeviceIntPtr pKeyboard, int what); - -/* xf86Kbd.c */ - -void xf86KbdGetMapping(KeySymsPtr pKeySyms, CARD8 *pModMap); /* xf86Lock.c */ --- orig/programs/Xserver/hw/xfree86/common/xf86Privstr.h +++ mod/programs/Xserver/hw/xfree86/common/xf86Privstr.h @@ -71,35 +71,11 @@ /* keyboard part */ DeviceIntPtr pKeyboard; - DeviceProc kbdProc; /* procedure for initializing */ - void (* kbdEvents)(void); /* proc for processing events */ int consoleFd; - int kbdFd; int vtno; - int kbdType; /* AT84 / AT101 */ - int kbdRate; - int kbdDelay; - int bell_pitch; - int bell_duration; - Bool autoRepeat; - unsigned long leds; - unsigned long xleds; - char * vtinit; - int scanPrefix; /* scancode-state */ - Bool capsLock; - Bool numLock; - Bool scrollLock; - Bool modeSwitchLock; - Bool composeLock; + char * vtinit; Bool vtSysreq; SpecialKeysInDDX ddxSpecialKeys; - Bool ActionKeyBindingsSet; -#if defined(SVR4) && defined(i386) - Bool panix106; -#endif /* SVR4 && i386 */ -#if defined(__OpenBSD__) || defined(__NetBSD__) - int wsKbdType; -#endif /* mouse part */ DeviceIntPtr pMouse; --- orig/programs/Xserver/hw/xfree86/input/keyboard/Imakefile +++ mod/programs/Xserver/hw/xfree86/input/keyboard/Imakefile @@ -6,7 +6,7 @@ SRCS = kbd.c OBJS = kbd.o -DRIVER = kbd +DRIVER = keyboard INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/loader -I$(XF86OSSRC) \ -I$(SERVERSRC)/mi -I$(SERVERSRC)/include -I$(XINCLUDESRC) \ --- orig/programs/Xserver/hw/xfree86/input/keyboard/kbd.c +++ mod/programs/Xserver/hw/xfree86/input/keyboard/kbd.c @@ -62,7 +62,7 @@ #undef KEYBOARD InputDriverRec KEYBOARD = { 1, - "kbd", + "keyboard", NULL, KbdPreInit, NULL, @@ -722,7 +722,7 @@ #ifdef XFree86LOADER ModuleInfoRec KeyboardInfo = { 1, - "KBD", + "KEYBOARD", NULL, 0, KeyboardAvailableOptions, @@ -756,7 +756,7 @@ static XF86ModuleVersionInfo xf86KeyboardVersionRec = { - "kbd", + "keyboard", MODULEVENDORSTRING, MODINFOSTRING1, MODINFOSTRING2, @@ -769,7 +769,7 @@ /* a tool */ }; -XF86ModuleData kbdModuleData = {&xf86KeyboardVersionRec, +XF86ModuleData keyboardModuleData = {&xf86KeyboardVersionRec, xf86KbdPlug, xf86KbdUnplug}; --- orig/programs/Xserver/hw/xfree86/loader/xf86sym.c +++ mod/programs/Xserver/hw/xfree86/loader/xf86sym.c @@ -286,7 +286,6 @@ SYMFUNC(xf86BindGARTMemory) SYMFUNC(xf86UnbindGARTMemory) SYMFUNC(xf86EnableAGP) - SYMFUNC(xf86SoundKbdBell) SYMFUNC(xf86GARTCloseScreen) #ifdef XINPUT /* XISB routines (Merged from Metrolink tree) */ --- orig/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c +++ mod/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c @@ -36,227 +36,9 @@ #define KBC_TIMEOUT 250 /* Timeout in ms for sending to keyboard controller */ -void -xf86SoundKbdBell(int loudness, int pitch, int duration) -{ - if (loudness && pitch) - { - ioctl(xf86Info.consoleFd, KDMKTONE, - ((1193190 / pitch) & 0xffff) | - (((unsigned long)duration * - loudness / 50) << 16)); - } -} - -void -xf86SetKbdLeds(int leds) -{ - ioctl(xf86Info.consoleFd, KDSETLED, leds); -} - -int -xf86GetKbdLeds() -{ - int leds = 0; - - ioctl(xf86Info.consoleFd, KDGETLED, &leds); - return(leds); -} - -/* kbd rate stuff based on kbdrate.c from Rik Faith et.al. - * from util-linux-2.9t package */ - #include #include #ifdef __sparc__ #include #include #endif - -/* Deal with spurious kernel header change */ -#if defined(LINUX_VERSION_CODE) && defined(KERNEL_VERSION) -# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,42) -# define rate period -# endif -#endif - -static int -KDKBDREP_ioctl_ok(int rate, int delay) { -#if defined(KDKBDREP) && !defined(__sparc__) - /* This ioctl is defined in but is not - implemented anywhere - must be in some m68k patches. */ - struct kbd_repeat kbdrep_s; - - /* don't change, just test */ - kbdrep_s.rate = -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.rate = 0; - else - kbdrep_s.rate = 10000 / rate; /* convert cps to msec */ - if (kbdrep_s.rate < 1) - kbdrep_s.rate = 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 - -void xf86SetKbdRepeat(char rad) -{ -#ifdef __sparc__ - int rate = 500; /* Default rate */ - int delay = 200; /* Default delay */ -#else - int rate = 300; /* Default rate */ - int delay = 250; /* Default delay */ -#endif - -#if defined(__alpha__) || defined (__i386__) || defined(__ia64__) - int i; - int timeout; - int value = 0x7f; /* Maximum delay with slowest 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 )) -#endif - - if (xf86Info.kbdRate >= 0) - rate = xf86Info.kbdRate * 10; - if (xf86Info.kbdDelay >= 0) - delay = xf86Info.kbdDelay; - - 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__) - - /* 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__ */ -} - -static int kbdtrans; -static struct termios kbdtty; - -void -xf86KbdInit() -{ - ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans); - tcgetattr (xf86Info.consoleFd, &kbdtty); -} - -int -xf86KbdOn() -{ - struct termios nTty; - -#ifdef __powerpc__ - if (xf86Info.kbdCustomKeycodes) - ioctl(xf86Info.consoleFd, KDSKBMODE, K_MEDIUMRAW); - else -#endif - ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW); - - nTty = 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(xf86Info.consoleFd, TCSANOW, &nTty); - return(xf86Info.consoleFd); -} - -int -xf86KbdOff() -{ - ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans); - tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty); - return(xf86Info.consoleFd); -} -