xserver: Branch 'master' - 2 commits

Adam Jackson ajax at kemper.freedesktop.org
Fri Jan 20 15:40:44 UTC 2017


 configure.ac                |   26 
 hw/dmx/input/Makefile.am    |    9 
 hw/dmx/input/dmxinputinit.c |   28 -
 hw/dmx/input/lnx-keyboard.c | 1193 --------------------------------------------
 hw/dmx/input/lnx-keyboard.h |   63 --
 hw/dmx/input/lnx-ms.c       |  349 ------------
 hw/dmx/input/lnx-ms.h       |   55 --
 hw/dmx/input/lnx-ps2.c      |  316 -----------
 hw/dmx/input/lnx-ps2.h      |   55 --
 hw/dmx/man/Xdmx.man         |    9 
 hw/kdrive/linux/Makefile.am |    8 
 hw/kdrive/linux/keyboard.c  |  341 ------------
 hw/kdrive/linux/linux.c     |   16 
 hw/kdrive/linux/mouse.c     |  982 ------------------------------------
 hw/kdrive/linux/ms.c        |  175 ------
 hw/kdrive/linux/ps2.c       |  177 ------
 include/kdrive-config.h.in  |    6 
 17 files changed, 3 insertions(+), 3805 deletions(-)

New commits:
commit e7b8b7b131d8283c96ed0aff4593ab41441b5d3b
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Jan 19 17:30:40 2017 -0500

    kdrive: Remove non-evdev input drivers
    
    Use evdev.
    
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/configure.ac b/configure.ac
index e23c934..cc6f352 100644
--- a/configure.ac
+++ b/configure.ac
@@ -658,8 +658,6 @@ AC_ARG_ENABLE(xephyr,         AS_HELP_STRING([--enable-xephyr], [Build the kdriv
 AC_ARG_ENABLE(xfake,          AS_HELP_STRING([--enable-xfake], [Build the kdrive 'fake' server (default: auto)]), [XFAKE=$enableval], [XFAKE=auto])
 AC_ARG_ENABLE(xfbdev,         AS_HELP_STRING([--enable-xfbdev], [Build the kdrive framebuffer device server (default: auto)]), [XFBDEV=$enableval], [XFBDEV=auto])
 dnl kdrive options
-AC_ARG_ENABLE(kdrive-kbd,     AS_HELP_STRING([--enable-kdrive-kbd], [Build kbd driver for kdrive (default: auto)]), [KDRIVE_KBD=$enableval], [KDRIVE_KBD=auto])
-AC_ARG_ENABLE(kdrive-mouse,   AS_HELP_STRING([--enable-kdrive-mouse], [Build mouse driver for kdrive (default: auto)]), [KDRIVE_MOUSE=$enableval], [KDRIVE_MOUSE=auto])
 AC_ARG_ENABLE(kdrive-evdev,   AS_HELP_STRING([--enable-kdrive-evdev], [Build evdev driver for kdrive (default: auto)]), [KDRIVE_EVDEV=$enableval], [KDRIVE_EVDEV=auto])
 AC_ARG_ENABLE(libunwind,      AS_HELP_STRING([--enable-libunwind], [Use libunwind for backtracing (default: auto)]), [LIBUNWIND="$enableval"], [LIBUNWIND="auto"])
 AC_ARG_ENABLE(xshmfence,      AS_HELP_STRING([--disable-xshmfence], [Disable xshmfence (default: auto)]), [XSHMFENCE="$enableval"], [XSHMFENCE="auto"])
@@ -2403,35 +2401,17 @@ if test "$KDRIVE" = yes; then
 	    if test "x$KDRIVE_EVDEV" = xauto; then
 		KDRIVE_EVDEV=yes
 	    fi
-	    if test "x$KDRIVE_KBD" = xauto; then
-		KDRIVE_KBD=yes
-	    fi
-	    if test "x$KDRIVE_MOUSE" = xauto; then
-		KDRIVE_MOUSE=yes
-	    fi
 	    ;;
 	*)
 	    if test "x$KDRIVE_EVDEV" = xauto; then
 		KDRIVE_EVDEV=no
 	    fi
-	    if test "x$KDRIVE_KBD" = xauto; then
-		KDRIVE_KBD=no
-	    fi
-	    if test "x$KDRIVE_MOUSE" = xauto; then
-		KDRIVE_MOUSE=no
-	    fi
 	    ;;
     esac
 
-    if test "x$KDRIVE_KBD" = xyes; then
-       AC_DEFINE(KDRIVE_KBD, 1, [Enable KDrive kbd driver])
-    fi
     if test "x$KDRIVE_EVDEV" = xyes; then
        AC_DEFINE(KDRIVE_EVDEV, 1, [Enable KDrive evdev driver])
     fi
-    if test "x$KDRIVE_MOUSE" = xyes; then
-       AC_DEFINE(KDRIVE_MOUSE, 1, [Enable KDrive mouse driver])
-    fi
 
     XEPHYR_REQUIRED_LIBS="xau xdmcp xcb xcb-shape xcb-render xcb-renderutil xcb-aux xcb-image xcb-icccm xcb-shm xcb-keysyms xcb-randr xcb-xkb"
     if test "x$XV" = xyes; then
@@ -2482,8 +2462,6 @@ AC_SUBST([KDRIVE_LOCAL_LIBS])
 AC_SUBST([KDRIVE_LIBS])
 AM_CONDITIONAL(KDRIVELINUX, [test "x$KDRIVELINUX" = xyes])
 AM_CONDITIONAL(KDRIVE_EVDEV, [test "x$KDRIVE_EVDEV" = xyes])
-AM_CONDITIONAL(KDRIVE_KBD,   [test "x$KDRIVE_KBD" = xyes])
-AM_CONDITIONAL(KDRIVE_MOUSE, [test "x$KDRIVE_MOUSE" = xyes])
 AM_CONDITIONAL(TSLIB, [test "x$HAVE_TSLIB" = xyes])
 AM_CONDITIONAL(KDRIVEFBDEV, [test "x$XFBDEV" = xyes])
 AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes])
diff --git a/hw/kdrive/linux/Makefile.am b/hw/kdrive/linux/Makefile.am
index 1362cd9..97c600c 100644
--- a/hw/kdrive/linux/Makefile.am
+++ b/hw/kdrive/linux/Makefile.am
@@ -10,18 +10,10 @@ liblinux_la_SOURCES =
 
 liblinux_la_SOURCES += linux.c
 
-if KDRIVE_KBD
-liblinux_la_SOURCES += keyboard.c
-endif
-
 if KDRIVE_EVDEV
 liblinux_la_SOURCES += evdev.c
 endif
 
-if KDRIVE_MOUSE
-liblinux_la_SOURCES += mouse.c ms.c ps2.c
-endif
-
 if TSLIB
 liblinux_la_SOURCES += tslib.c
 endif
diff --git a/hw/kdrive/linux/keyboard.c b/hw/kdrive/linux/keyboard.c
deleted file mode 100644
index 5d31b7d..0000000
--- a/hw/kdrive/linux/keyboard.c
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- * XKB integration © 2006 Nokia Corporation, author: Tomas Frydrych <tf at o-hand.com>
- *
- * LinuxKeyboardRead() XKB code based on xf86KbdLnx.c:
- * Copyright © 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- * Copyright © 1994-2001 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 <kdrive-config.h>
-#endif
-#include "kdrive.h"
-#include <linux/keyboard.h>
-#include <linux/kd.h>
-#define XK_PUBLISHING
-#include <X11/keysym.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-
-extern int LinuxConsoleFd;
-
-/*
- * We need these to handle extended scancodes correctly (I could just use the
- * numbers below, but this makes the code more readable
- */
-
-/* The prefix codes */
-#define KEY_Prefix0      /* special               0x60  */   96
-#define KEY_Prefix1      /* special               0x61  */   97
-
-/* The raw scancodes */
-#define KEY_Enter        /* Enter                 0x1c  */   28
-#define KEY_LCtrl        /* Ctrl(left)            0x1d  */   29
-#define KEY_Slash        /* / (Slash)   ?         0x35  */   53
-#define KEY_KP_Multiply  /* *                     0x37  */   55
-#define KEY_Alt          /* Alt(left)             0x38  */   56
-#define KEY_F3           /* F3                    0x3d  */   61
-#define KEY_F4           /* F4                    0x3e  */   62
-#define KEY_F5           /* F5                    0x3f  */   63
-#define KEY_F6           /* F6                    0x40  */   64
-#define KEY_F7           /* F7                    0x41  */   65
-#define KEY_ScrollLock   /* ScrollLock            0x46  */   70
-#define KEY_KP_7         /* 7           Home      0x47  */   71
-#define KEY_KP_8         /* 8           Up        0x48  */   72
-#define KEY_KP_9         /* 9           PgUp      0x49  */   73
-#define KEY_KP_Minus     /* - (Minus)             0x4a  */   74
-#define KEY_KP_4         /* 4           Left      0x4b  */   75
-#define KEY_KP_5         /* 5                     0x4c  */   76
-#define KEY_KP_6         /* 6           Right     0x4d  */   77
-#define KEY_KP_Plus      /* + (Plus)              0x4e  */   78
-#define KEY_KP_1         /* 1           End       0x4f  */   79
-#define KEY_KP_2         /* 2           Down      0x50  */   80
-#define KEY_KP_3         /* 3           PgDown    0x51  */   81
-#define KEY_KP_0         /* 0           Insert    0x52  */   82
-#define KEY_KP_Decimal   /* . (Decimal) Delete    0x53  */   83
-#define KEY_Home         /* Home                  0x59  */   89
-#define KEY_Up           /* Up                    0x5a  */   90
-#define KEY_PgUp         /* PgUp                  0x5b  */   91
-#define KEY_Left         /* Left                  0x5c  */   92
-#define KEY_Begin        /* Begin                 0x5d  */   93
-#define KEY_Right        /* Right                 0x5e  */   94
-#define KEY_End          /* End                   0x5f  */   95
-#define KEY_Down         /* Down                  0x60  */   96
-#define KEY_PgDown       /* PgDown                0x61  */   97
-#define KEY_Insert       /* Insert                0x62  */   98
-#define KEY_Delete       /* Delete                0x63  */   99
-#define KEY_KP_Enter     /* Enter                 0x64  */  100
-#define KEY_RCtrl        /* Ctrl(right)           0x65  */  101
-#define KEY_Pause        /* Pause                 0x66  */  102
-#define KEY_Print        /* Print                 0x67  */  103
-#define KEY_KP_Divide    /* Divide                0x68  */  104
-#define KEY_AltLang      /* AtlLang(right)        0x69  */  105
-#define KEY_Break        /* Break                 0x6a  */  106
-#define KEY_LMeta        /* Left Meta             0x6b  */  107
-#define KEY_RMeta        /* Right Meta            0x6c  */  108
-#define KEY_Menu         /* Menu                  0x6d  */  109
-#define KEY_F13          /* F13                   0x6e  */  110
-#define KEY_F14          /* F14                   0x6f  */  111
-#define KEY_F15          /* F15                   0x70  */  112
-#define KEY_F16          /* F16                   0x71  */  113
-#define KEY_F17          /* F17                   0x72  */  114
-#define KEY_KP_DEC       /* KP_DEC                0x73  */  115
-
-static void
-LinuxKeyboardRead(int fd, void *closure)
-{
-    unsigned char buf[256], *b;
-    int n;
-    unsigned char prefix = 0, scancode = 0;
-
-    while ((n = read(fd, buf, sizeof(buf))) > 0) {
-        b = buf;
-        while (n--) {
-            /*
-             * With xkb we use RAW mode for reading the console, which allows us
-             * process extended scancodes.
-             *
-             * See if this is a prefix extending the following keycode
-             */
-            if (!prefix && ((b[0] & 0x7f) == KEY_Prefix0)) {
-                prefix = KEY_Prefix0;
-                /* swallow this up */
-                b++;
-                continue;
-            }
-            else if (!prefix && ((b[0] & 0x7f) == KEY_Prefix1)) {
-                prefix = KEY_Prefix1;
-                /* swallow this up */
-                b++;
-                continue;
-            }
-            scancode = b[0] & 0x7f;
-
-            switch (prefix) {
-                /* from xf86Events.c */
-            case KEY_Prefix0:
-            {
-                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:
-                    b++;
-                    prefix = 0;
-                    continue;
-                default:
-                    /*
-                     * "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;
-                }
-                break;
-            }
-
-            case KEY_Prefix1:
-            {
-                /* we do no handle these */
-                b++;
-                prefix = 0;
-                continue;
-            }
-
-            default:           /* should not happen */
-            case 0:            /* do nothing */
-                ;
-            }
-
-            prefix = 0;
-            KdEnqueueKeyboardEvent(closure, scancode, b[0] & 0x80);
-            b++;
-        }
-    }
-}
-
-static int LinuxKbdTrans;
-static struct termios LinuxTermios;
-
-static Status
-LinuxKeyboardEnable(KdKeyboardInfo * ki)
-{
-    struct termios nTty;
-    unsigned char buf[256];
-    int n;
-    int fd;
-
-    if (!ki)
-        return !Success;
-
-    fd = LinuxConsoleFd;
-    ki->driverPrivate = (void *) (intptr_t) fd;
-
-    ioctl(fd, KDGKBMODE, &LinuxKbdTrans);
-    tcgetattr(fd, &LinuxTermios);
-    ioctl(fd, KDSKBMODE, K_RAW);
-    nTty = LinuxTermios;
-    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(fd, TCSANOW, &nTty);
-    /*
-     * Flush any pending keystrokes
-     */
-    while ((n = read(fd, buf, sizeof(buf))) > 0);
-    KdRegisterFd(fd, LinuxKeyboardRead, ki);
-    return Success;
-}
-
-static void
-LinuxKeyboardDisable(KdKeyboardInfo * ki)
-{
-    int fd;
-
-    if (!ki)
-        return;
-
-    fd = (int) (intptr_t) ki->driverPrivate;
-
-    KdUnregisterFd(ki, fd, FALSE);
-    ioctl(fd, KDSKBMODE, LinuxKbdTrans);
-    tcsetattr(fd, TCSANOW, &LinuxTermios);
-}
-
-static Status
-LinuxKeyboardInit(KdKeyboardInfo * ki)
-{
-    if (!ki)
-        return !Success;
-
-    free(ki->path);
-    ki->path = strdup("console");
-    free(ki->name);
-    ki->name = strdup("Linux console keyboard");
-
-    return Success;
-}
-
-static void
-LinuxKeyboardLeds(KdKeyboardInfo * ki, int leds)
-{
-    if (!ki)
-        return;
-
-    ioctl((int) (intptr_t) ki->driverPrivate, KDSETLED, leds & 7);
-}
-
-KdKeyboardDriver LinuxKeyboardDriver = {
-    "keyboard",
-    .Init = LinuxKeyboardInit,
-    .Enable = LinuxKeyboardEnable,
-    .Leds = LinuxKeyboardLeds,
-    .Disable = LinuxKeyboardDisable,
-};
diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c
index 56c2cb7..20f1fce 100644
--- a/hw/kdrive/linux/linux.c
+++ b/hw/kdrive/linux/linux.c
@@ -32,11 +32,6 @@
 #include <X11/keysym.h>
 #include <linux/apm_bios.h>
 
-#ifdef KDRIVE_MOUSE
-extern KdPointerDriver LinuxMouseDriver;
-extern KdPointerDriver Ps2MouseDriver;
-extern KdPointerDriver MsMouseDriver;
-#endif
 #ifdef TSLIB
 extern KdPointerDriver TsDriver;
 #endif
@@ -44,9 +39,6 @@ extern KdPointerDriver TsDriver;
 extern KdPointerDriver LinuxEvdevMouseDriver;
 extern KdKeyboardDriver LinuxEvdevKeyboardDriver;
 #endif
-#ifdef KDRIVE_KBD
-extern KdKeyboardDriver LinuxKeyboardDriver;
-#endif
 
 static int vtno;
 int LinuxConsoleFd;
@@ -323,11 +315,6 @@ LinuxFini(void)
 void
 KdOsAddInputDrivers(void)
 {
-#ifdef KDRIVE_MOUSE
-    KdAddPointerDriver(&LinuxMouseDriver);
-    KdAddPointerDriver(&MsMouseDriver);
-    KdAddPointerDriver(&Ps2MouseDriver);
-#endif
 #ifdef TSLIB
     KdAddPointerDriver(&TsDriver);
 #endif
@@ -335,9 +322,6 @@ KdOsAddInputDrivers(void)
     KdAddPointerDriver(&LinuxEvdevMouseDriver);
     KdAddKeyboardDriver(&LinuxEvdevKeyboardDriver);
 #endif
-#ifdef KDRIVE_KBD
-    KdAddKeyboardDriver(&LinuxKeyboardDriver);
-#endif
 }
 
 static void
diff --git a/hw/kdrive/linux/mouse.c b/hw/kdrive/linux/mouse.c
deleted file mode 100644
index 6bdd286..0000000
--- a/hw/kdrive/linux/mouse.c
+++ /dev/null
@@ -1,982 +0,0 @@
-/*
- * Copyright © 2001 Keith Packard
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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 <kdrive-config.h>
-#endif
-#include <errno.h>
-#include <termios.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <xserver_poll.h>
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include "kdrive.h"
-
-#undef DEBUG
-#undef DEBUG_BYTES
-#define KBUFIO_SIZE 256
-#define MOUSE_TIMEOUT	100
-
-typedef struct _kbufio {
-    int fd;
-    unsigned char buf[KBUFIO_SIZE];
-    int avail;
-    int used;
-} Kbufio;
-
-static Bool
-MouseWaitForReadable(int fd, int timeout)
-{
-    struct pollfd poll_fd;
-    int n;
-    CARD32 done;
-
-    done = GetTimeInMillis() + timeout;
-    poll_fd.fd = fd;
-    poll_fd.events = POLLIN;
-    for (;;) {
-        n = xserver_poll(&poll_fd, 1, timeout);
-        if (n > 0)
-            return TRUE;
-        if (n < 0 && (errno == EAGAIN || errno == EINTR)) {
-            timeout = (int) (done - GetTimeInMillis());
-            if (timeout > 0)
-                continue;
-        }
-        break;
-    }
-    return FALSE;
-}
-
-static int
-MouseReadByte(Kbufio * b, int timeout)
-{
-    int n;
-
-    if (b->avail <= b->used) {
-        if (timeout && !MouseWaitForReadable(b->fd, timeout)) {
-#ifdef DEBUG_BYTES
-            ErrorF("\tTimeout %d\n", timeout);
-#endif
-            return -1;
-        }
-        n = read(b->fd, b->buf, KBUFIO_SIZE);
-        if (n <= 0)
-            return -1;
-        b->avail = n;
-        b->used = 0;
-    }
-#ifdef DEBUG_BYTES
-    ErrorF("\tget %02x\n", b->buf[b->used]);
-#endif
-    return b->buf[b->used++];
-}
-
-#if NOTUSED
-static int
-MouseFlush(Kbufio * b, char *buf, int size)
-{
-    CARD32 now = GetTimeInMillis();
-    CARD32 done = now + 100;
-    int c;
-    int n = 0;
-
-    while ((c = MouseReadByte(b, done - now)) != -1) {
-        if (buf) {
-            if (n == size) {
-                memmove(buf, buf + 1, size - 1);
-                n--;
-            }
-            buf[n++] = c;
-        }
-        now = GetTimeInMillis();
-        if ((INT32) (now - done) >= 0)
-            break;
-    }
-    return n;
-}
-
-static int
-MousePeekByte(Kbufio * b, int timeout)
-{
-    int c;
-
-    c = MouseReadByte(b, timeout);
-    if (c != -1)
-        --b->used;
-    return c;
-}
-#endif                          /* NOTUSED */
-
-static Bool
-MouseWaitForWritable(int fd, int timeout)
-{
-    struct pollfd poll_fd;
-    int n;
-
-    poll_fd.fd = fd;
-    poll_fd.events = POLLOUT;
-    n = xserver_poll(&poll_fd, 1, timeout);
-    if (n > 0)
-        return TRUE;
-    return FALSE;
-}
-
-static Bool
-MouseWriteByte(int fd, unsigned char c, int timeout)
-{
-    int ret;
-
-#ifdef DEBUG_BYTES
-    ErrorF("\tput %02x\n", c);
-#endif
-    for (;;) {
-        ret = write(fd, &c, 1);
-        if (ret == 1)
-            return TRUE;
-        if (ret == 0)
-            return FALSE;
-        if (errno != EWOULDBLOCK)
-            return FALSE;
-        if (!MouseWaitForWritable(fd, timeout))
-            return FALSE;
-    }
-}
-
-static Bool
-MouseWriteBytes(int fd, unsigned char *c, int n, int timeout)
-{
-    while (n--)
-        if (!MouseWriteByte(fd, *c++, timeout))
-            return FALSE;
-    return TRUE;
-}
-
-#define MAX_MOUSE   10          /* maximum length of mouse protocol */
-#define MAX_SKIP    16          /* number of error bytes before switching */
-#define MAX_VALID   4           /* number of valid packets before accepting */
-
-typedef struct _kmouseProt {
-    const char *name;
-    Bool (*Complete) (KdPointerInfo * pi, unsigned char *ev, int ne);
-    int (*Valid) (KdPointerInfo * pi, unsigned char *ev, int ne);
-    Bool (*Parse) (KdPointerInfo * pi, unsigned char *ev, int ne);
-    Bool (*Init) (KdPointerInfo * pi);
-    unsigned char headerMask, headerValid;
-    unsigned char dataMask, dataValid;
-    Bool tty;
-    unsigned int c_iflag;
-    unsigned int c_oflag;
-    unsigned int c_lflag;
-    unsigned int c_cflag;
-    unsigned int speed;
-    unsigned char *init;
-    unsigned long state;
-} KmouseProt;
-
-typedef enum _kmouseStage {
-    MouseBroken, MouseTesting, MouseWorking
-} KmouseStage;
-
-typedef struct _kmouse {
-    Kbufio iob;
-    const KmouseProt *prot;
-    int i_prot;
-    KmouseStage stage;          /* protocol verification stage */
-    Bool tty;                   /* mouse device is a tty */
-    int valid;                  /* sequential valid events */
-    int tested;                 /* bytes scanned during Testing phase */
-    int invalid;                /* total invalid bytes for this protocol */
-    unsigned long state;        /* private per protocol, init to prot->state */
-} Kmouse;
-
-static int
-mouseValid(KdPointerInfo * pi, unsigned char *ev, int ne)
-{
-    Kmouse *km = pi->driverPrivate;
-    const KmouseProt *prot = km->prot;
-    int i;
-
-    for (i = 0; i < ne; i++)
-        if ((ev[i] & prot->headerMask) == prot->headerValid)
-            break;
-    if (i != 0)
-        return i;
-    for (i = 1; i < ne; i++)
-        if ((ev[i] & prot->dataMask) != prot->dataValid)
-            return -1;
-    return 0;
-}
-
-static Bool
-threeComplete(KdPointerInfo * pi, unsigned char *ev, int ne)
-{
-    return ne == 3;
-}
-
-static Bool
-fourComplete(KdPointerInfo * pi, unsigned char *ev, int ne)
-{
-    return ne == 4;
-}
-
-static Bool
-fiveComplete(KdPointerInfo * pi, unsigned char *ev, int ne)
-{
-    return ne == 5;
-}
-
-static Bool
-MouseReasonable(KdPointerInfo * pi, unsigned long flags, int dx, int dy)
-{
-    Kmouse *km = pi->driverPrivate;
-
-    if (km->stage == MouseWorking)
-        return TRUE;
-    if (dx < -50 || dx > 50) {
-#ifdef DEBUG
-        ErrorF("Large X %d\n", dx);
-#endif
-        return FALSE;
-    }
-    if (dy < -50 || dy > 50) {
-#ifdef DEBUG
-        ErrorF("Large Y %d\n", dy);
-#endif
-        return FALSE;
-    }
-    return TRUE;
-}
-
-/*
- * Standard PS/2 mouse protocol
- */
-static Bool
-ps2Parse(KdPointerInfo * pi, unsigned char *ev, int ne)
-{
-    Kmouse *km = pi->driverPrivate;
-    int dx, dy, dz;
-    unsigned long flags;
-    unsigned long flagsrelease = 0;
-
-    flags = KD_MOUSE_DELTA;
-    if (ev[0] & 4)
-        flags |= KD_BUTTON_2;
-    if (ev[0] & 2)
-        flags |= KD_BUTTON_3;
-    if (ev[0] & 1)
-        flags |= KD_BUTTON_1;
-
-    if (ne > 3) {
-        dz = (int) (signed char) ev[3];
-        if (dz < 0) {
-            flags |= KD_BUTTON_4;
-            flagsrelease = KD_BUTTON_4;
-        }
-        else if (dz > 0) {
-            flags |= KD_BUTTON_5;
-            flagsrelease = KD_BUTTON_5;
-        }
-    }
-
-    dx = ev[1];
-    if (ev[0] & 0x10)
-        dx -= 256;
-    dy = ev[2];
-    if (ev[0] & 0x20)
-        dy -= 256;
-    dy = -dy;
-    if (!MouseReasonable(pi, flags, dx, dy))
-        return FALSE;
-    if (km->stage == MouseWorking) {
-        KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
-        if (flagsrelease) {
-            flags &= ~flagsrelease;
-            KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
-        }
-    }
-    return TRUE;
-}
-
-static Bool ps2Init(KdPointerInfo * pi);
-
-static const KmouseProt ps2Prot = {
-    "ps/2",
-    threeComplete, mouseValid, ps2Parse, ps2Init,
-    0x08, 0x08, 0x00, 0x00,
-    FALSE
-};
-
-static const KmouseProt imps2Prot = {
-    "imps/2",
-    fourComplete, mouseValid, ps2Parse, ps2Init,
-    0x08, 0x08, 0x00, 0x00,
-    FALSE
-};
-
-static const KmouseProt exps2Prot = {
-    "exps/2",
-    fourComplete, mouseValid, ps2Parse, ps2Init,
-    0x08, 0x08, 0x00, 0x00,
-    FALSE
-};
-
-/*
- * Once the mouse is known to speak ps/2 protocol, go and find out
- * what advanced capabilities it has and turn them on
- */
-
-/* these extracted from FreeBSD 4.3 sys/dev/kbd/atkbdcreg.h */
-
-/* aux device commands (sent to KBD_DATA_PORT) */
-#define PSMC_SET_SCALING11      0x00e6
-#define PSMC_SET_SCALING21      0x00e7
-#define PSMC_SET_RESOLUTION     0x00e8
-#define PSMC_SEND_DEV_STATUS    0x00e9
-#define PSMC_SET_STREAM_MODE    0x00ea
-#define PSMC_SEND_DEV_DATA      0x00eb
-#define PSMC_SET_REMOTE_MODE    0x00f0
-#define PSMC_SEND_DEV_ID        0x00f2
-#define PSMC_SET_SAMPLING_RATE  0x00f3
-#define PSMC_ENABLE_DEV         0x00f4
-#define PSMC_DISABLE_DEV        0x00f5
-#define PSMC_SET_DEFAULTS       0x00f6
-#define PSMC_RESET_DEV          0x00ff
-
-/* PSMC_SET_RESOLUTION argument */
-#define PSMD_RES_LOW            0       /* typically 25ppi */
-#define PSMD_RES_MEDIUM_LOW     1       /* typically 50ppi */
-#define PSMD_RES_MEDIUM_HIGH    2       /* typically 100ppi (default) */
-#define PSMD_RES_HIGH           3       /* typically 200ppi */
-#define PSMD_MAX_RESOLUTION     PSMD_RES_HIGH
-
-/* PSMC_SET_SAMPLING_RATE */
-#define PSMD_MAX_RATE           255     /* FIXME: not sure if it's possible */
-
-/* aux device ID */
-#define PSM_MOUSE_ID            0
-#define PSM_BALLPOINT_ID        2
-#define PSM_INTELLI_ID          3
-#define PSM_EXPLORER_ID         4
-#define PSM_4DMOUSE_ID          6
-#define PSM_4DPLUS_ID           8
-
-static unsigned char ps2_init[] = {
-    PSMC_ENABLE_DEV,
-    0,
-};
-
-#define NINIT_PS2   1
-
-static unsigned char wheel_3button_init[] = {
-    PSMC_SET_SAMPLING_RATE, 200,
-    PSMC_SET_SAMPLING_RATE, 100,
-    PSMC_SET_SAMPLING_RATE, 80,
-    PSMC_SEND_DEV_ID,
-    0,
-};
-
-#define NINIT_IMPS2 4
-
-static unsigned char wheel_5button_init[] = {
-    PSMC_SET_SAMPLING_RATE, 200,
-    PSMC_SET_SAMPLING_RATE, 100,
-    PSMC_SET_SAMPLING_RATE, 80,
-    PSMC_SET_SAMPLING_RATE, 200,
-    PSMC_SET_SAMPLING_RATE, 200,
-    PSMC_SET_SAMPLING_RATE, 80,
-    PSMC_SEND_DEV_ID,
-    0
-};
-
-#define NINIT_EXPS2 7
-
-static unsigned char intelli_init[] = {
-    PSMC_SET_SAMPLING_RATE, 200,
-    PSMC_SET_SAMPLING_RATE, 100,
-    PSMC_SET_SAMPLING_RATE, 80,
-    0
-};
-
-#define NINIT_INTELLI	3
-
-static int
-ps2SkipInit(KdPointerInfo * pi, int ninit, Bool ret_next)
-{
-    Kmouse *km = pi->driverPrivate;
-    int c = -1;
-    Bool waiting;
-
-    waiting = FALSE;
-    while (ninit || ret_next) {
-        c = MouseReadByte(&km->iob, MOUSE_TIMEOUT);
-        if (c == -1)
-            break;
-        /* look for ACK */
-        if (c == 0xfa) {
-            ninit--;
-            if (ret_next)
-                waiting = TRUE;
-        }
-        /* look for packet start -- not the response */
-        else if ((c & 0x08) == 0x08)
-            waiting = FALSE;
-        else if (waiting)
-            break;
-    }
-    return c;
-}
-
-static Bool
-ps2Init(KdPointerInfo * pi)
-{
-    Kmouse *km = pi->driverPrivate;
-    int id;
-    unsigned char *init;
-    int ninit;
-
-    /* Send Intellimouse initialization sequence */
-    MouseWriteBytes(km->iob.fd, intelli_init, strlen((char *) intelli_init),
-                    100);
-    /*
-     * Send ID command
-     */
-    if (!MouseWriteByte(km->iob.fd, PSMC_SEND_DEV_ID, 100))
-        return FALSE;
-    id = ps2SkipInit(pi, 0, TRUE);
-    switch (id) {
-    case 3:
-        init = wheel_3button_init;
-        ninit = NINIT_IMPS2;
-        km->prot = &imps2Prot;
-        break;
-    case 4:
-        init = wheel_5button_init;
-        ninit = NINIT_EXPS2;
-        km->prot = &exps2Prot;
-        break;
-    default:
-        init = ps2_init;
-        ninit = NINIT_PS2;
-        km->prot = &ps2Prot;
-        break;
-    }
-    if (init)
-        MouseWriteBytes(km->iob.fd, init, strlen((char *) init), 100);
-    /*
-     * Flush out the available data to eliminate responses to the
-     * initialization string.  Make sure any partial event is
-     * skipped
-     */
-    (void) ps2SkipInit(pi, ninit, FALSE);
-    return TRUE;
-}
-
-static Bool
-busParse(KdPointerInfo * pi, unsigned char *ev, int ne)
-{
-    Kmouse *km = pi->driverPrivate;
-    int dx, dy;
-    unsigned long flags;
-
-    flags = KD_MOUSE_DELTA;
-    dx = (signed char) ev[1];
-    dy = -(signed char) ev[2];
-    if ((ev[0] & 4) == 0)
-        flags |= KD_BUTTON_1;
-    if ((ev[0] & 2) == 0)
-        flags |= KD_BUTTON_2;
-    if ((ev[0] & 1) == 0)
-        flags |= KD_BUTTON_3;
-    if (!MouseReasonable(pi, flags, dx, dy))
-        return FALSE;
-    if (km->stage == MouseWorking)
-        KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
-    return TRUE;
-}
-
-static const KmouseProt busProt = {
-    "bus",
-    threeComplete, mouseValid, busParse, 0,
-    0xf8, 0x00, 0x00, 0x00,
-    FALSE
-};
-
-/*
- * Standard MS serial protocol, three bytes
- */
-
-static Bool
-msParse(KdPointerInfo * pi, unsigned char *ev, int ne)
-{
-    Kmouse *km = pi->driverPrivate;
-    int dx, dy;
-    unsigned long flags;
-
-    flags = KD_MOUSE_DELTA;
-
-    if (ev[0] & 0x20)
-        flags |= KD_BUTTON_1;
-    if (ev[0] & 0x10)
-        flags |= KD_BUTTON_3;
-
-    dx = (signed char) (((ev[0] & 0x03) << 6) | (ev[1] & 0x3F));
-    dy = (signed char) (((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F));
-    if (!MouseReasonable(pi, flags, dx, dy))
-        return FALSE;
-    if (km->stage == MouseWorking)
-        KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
-    return TRUE;
-}
-
-static const KmouseProt msProt = {
-    "ms",
-    threeComplete, mouseValid, msParse, 0,
-    0xc0, 0x40, 0xc0, 0x00,
-    TRUE,
-    IGNPAR,
-    0,
-    0,
-    CS7 | CSTOPB | CREAD | CLOCAL,
-    B1200,
-};
-
-/*
- * Logitech mice send 3 or 4 bytes, the only way to tell is to look at the
- * first byte of a synchronized protocol stream and see if it's got
- * any bits turned on that can't occur in that fourth byte
- */
-static Bool
-logiComplete(KdPointerInfo * pi, unsigned char *ev, int ne)
-{
-    Kmouse *km = pi->driverPrivate;
-
-    if ((ev[0] & 0x40) == 0x40)
-        return ne == 3;
-    if (km->stage != MouseBroken && (ev[0] & ~0x23) == 0)
-        return ne == 1;
-    return FALSE;
-}
-
-static int
-logiValid(KdPointerInfo * pi, unsigned char *ev, int ne)
-{
-    Kmouse *km = pi->driverPrivate;
-    const KmouseProt *prot = km->prot;
-    int i;
-
-    for (i = 0; i < ne; i++) {
-        if ((ev[i] & 0x40) == 0x40)
-            break;
-        if (km->stage != MouseBroken && (ev[i] & ~0x23) == 0)
-            break;
-    }
-    if (i != 0)
-        return i;
-    for (i = 1; i < ne; i++)
-        if ((ev[i] & prot->dataMask) != prot->dataValid)
-            return -1;
-    return 0;
-}
-
-static Bool
-logiParse(KdPointerInfo * pi, unsigned char *ev, int ne)
-{
-    Kmouse *km = pi->driverPrivate;
-    int dx, dy;
-    unsigned long flags;
-
-    flags = KD_MOUSE_DELTA;
-
-    if (ne == 3) {
-        if (ev[0] & 0x20)
-            flags |= KD_BUTTON_1;
-        if (ev[0] & 0x10)
-            flags |= KD_BUTTON_3;
-
-        dx = (signed char) (((ev[0] & 0x03) << 6) | (ev[1] & 0x3F));
-        dy = (signed char) (((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F));
-        flags |= km->state & KD_BUTTON_2;
-    }
-    else {
-        if (ev[0] & 0x20)
-            flags |= KD_BUTTON_2;
-        dx = 0;
-        dy = 0;
-        flags |= km->state & (KD_BUTTON_1 | KD_BUTTON_3);
-    }
-
-    if (!MouseReasonable(pi, flags, dx, dy))
-        return FALSE;
-    if (km->stage == MouseWorking)
-        KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
-    return TRUE;
-}
-
-static const KmouseProt logiProt = {
-    "logitech",
-    logiComplete, logiValid, logiParse, 0,
-    0xc0, 0x40, 0xc0, 0x00,
-    TRUE,
-    IGNPAR,
-    0,
-    0,
-    CS7 | CSTOPB | CREAD | CLOCAL,
-    B1200,
-};
-
-/*
- * Mouse systems protocol, 5 bytes
- */
-static Bool
-mscParse(KdPointerInfo * pi, unsigned char *ev, int ne)
-{
-    Kmouse *km = pi->driverPrivate;
-    int dx, dy;
-    unsigned long flags;
-
-    flags = KD_MOUSE_DELTA;
-
-    if (!(ev[0] & 0x4))
-        flags |= KD_BUTTON_1;
-    if (!(ev[0] & 0x2))
-        flags |= KD_BUTTON_2;
-    if (!(ev[0] & 0x1))
-        flags |= KD_BUTTON_3;
-    dx = (signed char) (ev[1]) + (signed char) (ev[3]);
-    dy = -((signed char) (ev[2]) + (signed char) (ev[4]));
-
-    if (!MouseReasonable(pi, flags, dx, dy))
-        return FALSE;
-    if (km->stage == MouseWorking)
-        KdEnqueuePointerEvent(pi, flags, dx, dy, 0);
-    return TRUE;
-}
-
-static const KmouseProt mscProt = {
-    "msc",
-    fiveComplete, mouseValid, mscParse, 0,
-    0xf8, 0x80, 0x00, 0x00,
-    TRUE,
-    IGNPAR,
-    0,
-    0,
-    CS8 | CSTOPB | CREAD | CLOCAL,
-    B1200,
-};
-
-/*
- * Use logitech before ms -- they're the same except that
- * logitech sometimes has a fourth byte
- */
-static const KmouseProt *kmouseProts[] = {
-    &ps2Prot, &imps2Prot, &exps2Prot, &busProt, &logiProt, &msProt, &mscProt,
-};
-
-#define NUM_PROT    (sizeof (kmouseProts) / sizeof (kmouseProts[0]))
-
-static void
-MouseInitProtocol(Kmouse * km)
-{
-    int ret;
-    struct termios t;
-
-    if (km->prot->tty) {
-        ret = tcgetattr(km->iob.fd, &t);
-
-        if (ret >= 0) {
-            t.c_iflag = km->prot->c_iflag;
-            t.c_oflag = km->prot->c_oflag;
-            t.c_lflag = km->prot->c_lflag;
-            t.c_cflag = km->prot->c_cflag;
-            cfsetispeed(&t, km->prot->speed);
-            cfsetospeed(&t, km->prot->speed);
-            ret = tcsetattr(km->iob.fd, TCSANOW, &t);
-        }
-    }
-    km->stage = MouseBroken;
-    km->valid = 0;
-    km->tested = 0;
-    km->invalid = 0;
-    km->state = km->prot->state;
-}
-
-static void
-MouseFirstProtocol(Kmouse * km, const char *prot)
-{
-    if (prot) {
-        for (km->i_prot = 0; km->i_prot < NUM_PROT; km->i_prot++)
-            if (!strcmp(prot, kmouseProts[km->i_prot]->name))
-                break;
-        if (km->i_prot == NUM_PROT) {
-            int i;
-
-            ErrorF("Unknown mouse protocol \"%s\". Pick one of:", prot);
-            for (i = 0; i < NUM_PROT; i++)
-                ErrorF(" %s", kmouseProts[i]->name);
-            ErrorF("\n");
-        }
-        else {
-            km->prot = kmouseProts[km->i_prot];
-            if (km->tty && !km->prot->tty)
-                ErrorF
-                    ("Mouse device is serial port, protocol %s is not serial protocol\n",
-                     prot);
-            else if (!km->tty && km->prot->tty)
-                ErrorF
-                    ("Mouse device is not serial port, protocol %s is serial protocol\n",
-                     prot);
-        }
-    }
-    if (!km->prot) {
-        for (km->i_prot = 0; kmouseProts[km->i_prot]->tty != km->tty;
-             km->i_prot++);
-        km->prot = kmouseProts[km->i_prot];
-    }
-    MouseInitProtocol(km);
-}
-
-static void
-MouseNextProtocol(Kmouse * km)
-{
-    do {
-        if (!km->prot)
-            km->i_prot = 0;
-        else if (++km->i_prot == NUM_PROT)
-            km->i_prot = 0;
-        km->prot = kmouseProts[km->i_prot];
-    } while (km->prot->tty != km->tty);
-    MouseInitProtocol(km);
-    ErrorF("Switching to mouse protocol \"%s\"\n", km->prot->name);
-}
-
-static void
-MouseRead(int mousePort, void *closure)
-{
-    KdPointerInfo *pi = closure;
-    Kmouse *km = pi->driverPrivate;
-    unsigned char event[MAX_MOUSE];
-    int ne;
-    int c;
-    int i;
-    int timeout;
-
-    timeout = 0;
-    ne = 0;
-    for (;;) {
-        c = MouseReadByte(&km->iob, timeout);
-        if (c == -1) {
-            if (ne) {
-                km->invalid += ne + km->tested;
-                km->valid = 0;
-                km->tested = 0;
-                km->stage = MouseBroken;
-            }
-            break;
-        }
-        event[ne++] = c;
-        i = (*km->prot->Valid) (pi, event, ne);
-        if (i != 0) {
-#ifdef DEBUG
-            ErrorF("Mouse protocol %s broken %d of %d bytes bad\n",
-                   km->prot->name, i > 0 ? i : ne, ne);
-#endif
-            if (i > 0 && i < ne) {
-                ne -= i;
-                memmove(event, event + i, ne);
-            }
-            else {
-                i = ne;
-                ne = 0;
-            }
-            km->invalid += i + km->tested;
-            km->valid = 0;
-            km->tested = 0;
-            if (km->stage == MouseWorking)
-                km->i_prot--;
-            km->stage = MouseBroken;
-            if (km->invalid > MAX_SKIP) {
-                MouseNextProtocol(km);
-                ne = 0;
-            }
-            timeout = 0;
-        }
-        else {
-            if ((*km->prot->Complete) (pi, event, ne)) {
-                if ((*km->prot->Parse) (pi, event, ne)) {
-                    switch (km->stage) {
-                    case MouseBroken:
-#ifdef DEBUG
-                        ErrorF("Mouse protocol %s seems OK\n", km->prot->name);
-#endif
-                        /* do not zero invalid to accumulate invalid bytes */
-                        km->valid = 0;
-                        km->tested = 0;
-                        km->stage = MouseTesting;
-                        /* fall through ... */
-                    case MouseTesting:
-                        km->valid++;
-                        km->tested += ne;
-                        if (km->valid > MAX_VALID) {
-#ifdef DEBUG
-                            ErrorF("Mouse protocol %s working\n",
-                                   km->prot->name);
-#endif
-                            km->stage = MouseWorking;
-                            km->invalid = 0;
-                            km->tested = 0;
-                            km->valid = 0;
-                            if (km->prot->Init && !(*km->prot->Init) (pi))
-                                km->stage = MouseBroken;
-                        }
-                        break;
-                    case MouseWorking:
-                        break;
-                    }
-                }
-                else {
-                    km->invalid += ne + km->tested;
-                    km->valid = 0;
-                    km->tested = 0;
-                    km->stage = MouseBroken;
-                }
-                ne = 0;
-                timeout = 0;
-            }
-            else
-                timeout = MOUSE_TIMEOUT;
-        }
-    }
-}
-
-int MouseInputType;
-
-const char *kdefaultMouse[] = {
-    "/dev/input/mice",
-    "/dev/mouse",
-    "/dev/psaux",
-    "/dev/adbmouse",
-    "/dev/ttyS0",
-    "/dev/ttyS1",
-};
-
-#define NUM_DEFAULT_MOUSE    (sizeof (kdefaultMouse) / sizeof (kdefaultMouse[0]))
-
-static Status
-MouseInit(KdPointerInfo * pi)
-{
-    int i;
-    int fd;
-    Kmouse *km;
-
-    if (!pi)
-        return BadImplementation;
-
-    if (!pi->path || strcmp(pi->path, "auto") == 0) {
-        for (i = 0; i < NUM_DEFAULT_MOUSE; i++) {
-            fd = open(kdefaultMouse[i], 2);
-            if (fd >= 0) {
-                pi->path = strdup(kdefaultMouse[i]);
-                break;
-            }
-        }
-    }
-    else {
-        fd = open(pi->path, 2);
-    }
-
-    if (fd < 0)
-        return BadMatch;
-
-    close(fd);
-
-    km = (Kmouse *) malloc(sizeof(Kmouse));
-    if (km) {
-        km->iob.avail = km->iob.used = 0;
-        MouseFirstProtocol(km, pi->protocol ? pi->protocol : "exps/2");
-        /* MouseFirstProtocol sets state to MouseBroken for later protocol
-         * checks. Skip these checks if a protocol was supplied */
-        if (pi->protocol)
-            km->state = MouseWorking;
-        km->i_prot = 0;
-        km->tty = isatty(fd);
-        km->iob.fd = -1;
-        pi->driverPrivate = km;
-    }
-    else {
-        close(fd);
-        return BadAlloc;
-    }
-
-    return Success;
-}
-
-static Status
-MouseEnable(KdPointerInfo * pi)
-{
-    Kmouse *km;
-
-    if (!pi || !pi->driverPrivate || !pi->path)
-        return BadImplementation;
-
-    km = pi->driverPrivate;
-
-    km->iob.fd = open(pi->path, 2);
-    if (km->iob.fd < 0)
-        return BadMatch;
-
-    if (!KdRegisterFd(km->iob.fd, MouseRead, pi)) {
-        close(km->iob.fd);
-        return BadAlloc;
-    }
-
-    return Success;
-}
-
-static void
-MouseDisable(KdPointerInfo * pi)
-{
-    Kmouse *km;
-
-    if (!pi || !pi->driverPrivate)
-        return;
-
-    km = pi->driverPrivate;
-    KdUnregisterFd(pi, km->iob.fd, TRUE);
-}
-
-static void
-MouseFini(KdPointerInfo * pi)
-{
-    free(pi->driverPrivate);
-    pi->driverPrivate = NULL;
-}
-
-KdPointerDriver LinuxMouseDriver = {
-    "mouse",
-    MouseInit,
-    MouseEnable,
-    MouseDisable,
-    MouseFini,
-    NULL,
-};
diff --git a/hw/kdrive/linux/ms.c b/hw/kdrive/linux/ms.c
deleted file mode 100644
index 3934682..0000000
--- a/hw/kdrive/linux/ms.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
-Copyright (c) 2001 by Juliusz Chroboczek
-Copyright (c) 1999 by Keith Packard
-
-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
-AUTHORS OR COPYRIGHT HOLDERS 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.
-*/
-
-#ifdef HAVE_CONFIG_H
-#include <kdrive-config.h>
-#endif
-#include <errno.h>
-#include <termios.h>
-#include <xserver_poll.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include "kdrive.h"
-
-static int
-MsReadBytes(int fd, char *buf, int len, int min)
-{
-    int n, tot;
-    struct pollfd poll_fd;
-
-    poll_fd.fd = fd;
-    poll_fd.events = POLLIN;
-    tot = 0;
-    while (len) {
-        n = read(fd, buf, len);
-        if (n > 0) {
-            tot += n;
-            buf += n;
-            len -= n;
-        }
-        if (tot % min == 0)
-            break;
-        n = xserver_poll(&poll_fd, 1, 100);
-        if (n <= 0)
-            break;
-    }
-    return tot;
-}
-
-static void
-MsRead(int port, void *closure)
-{
-    unsigned char buf[3 * 200];
-    unsigned char *b;
-    int n;
-    int dx, dy;
-    unsigned long flags;
-
-    while ((n = MsReadBytes(port, (char *) buf, sizeof(buf), 3)) > 0) {
-        b = buf;
-        while (n >= 3) {
-            flags = KD_MOUSE_DELTA;
-
-            if (b[0] & 0x20)
-                flags |= KD_BUTTON_1;
-            if (b[0] & 0x10)
-                flags |= KD_BUTTON_3;
-
-            dx = (char) (((b[0] & 0x03) << 6) | (b[1] & 0x3F));
-            dy = (char) (((b[0] & 0x0C) << 4) | (b[2] & 0x3F));
-            n -= 3;
-            b += 3;
-            KdEnqueuePointerEvent(closure, flags, dx, dy, 0);
-        }
-    }
-}
-
-static Status
-MsInit(KdPointerInfo * pi)
-{
-    if (!pi)
-        return BadImplementation;
-
-    if (!pi->path || strcmp(pi->path, "auto"))
-        pi->path = strdup("/dev/mouse");
-    if (!pi->name)
-        pi->name = strdup("Microsoft protocol mouse");
-
-    return Success;
-}
-
-static Status
-MsEnable(KdPointerInfo * pi)
-{
-    int port;
-    struct termios t;
-    int ret;
-
-    port = open(pi->path, O_RDWR | O_NONBLOCK);
-    if (port < 0) {
-        ErrorF("Couldn't open %s (%d)\n", pi->path, (int) errno);
-        return 0;
-    }
-    else if (port == 0) {
-        ErrorF("Opening %s returned 0!  Please complain to Keith.\n", pi->path);
-        goto bail;
-    }
-
-    if (!isatty(port)) {
-        ErrorF("%s is not a tty\n", pi->path);
-        goto bail;
-    }
-
-    ret = tcgetattr(port, &t);
-    if (ret < 0) {
-        ErrorF("Couldn't tcgetattr(%s): %d\n", pi->path, errno);
-        goto bail;
-    }
-    t.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR |
-                   IGNCR | ICRNL | IXON | IXOFF);
-    t.c_oflag &= ~OPOST;
-    t.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
-    t.c_cflag &= ~(CSIZE | PARENB);
-    t.c_cflag |= CS8 | CLOCAL | CSTOPB;
-
-    cfsetispeed(&t, B1200);
-    cfsetospeed(&t, B1200);
-    t.c_cc[VMIN] = 1;
-    t.c_cc[VTIME] = 0;
-    ret = tcsetattr(port, TCSANOW, &t);
-    if (ret < 0) {
-        ErrorF("Couldn't tcsetattr(%s): %d\n", pi->path, errno);
-        goto bail;
-    }
-    if (KdRegisterFd(port, MsRead, pi))
-        return TRUE;
-    pi->driverPrivate = (void *) (intptr_t) port;
-
-    return Success;
-
- bail:
-    close(port);
-    return BadMatch;
-}
-
-static void
-MsDisable(KdPointerInfo * pi)
-{
-    KdUnregisterFd(pi, (int) (intptr_t) pi->driverPrivate, TRUE);
-}
-
-static void
-MsFini(KdPointerInfo * pi)
-{
-}
-
-KdPointerDriver MsMouseDriver = {
-    "ms",
-    MsInit,
-    MsEnable,
-    MsDisable,
-    MsFini,
-    NULL,
-};
diff --git a/hw/kdrive/linux/ps2.c b/hw/kdrive/linux/ps2.c
deleted file mode 100644
index 4fec024..0000000
--- a/hw/kdrive/linux/ps2.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright © 1999 Keith Packard
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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 <kdrive-config.h>
-#endif
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <xserver_poll.h>
-#include "inputstr.h"
-#include "scrnintstr.h"
-#include "kdrive.h"
-
-static int
-Ps2ReadBytes(int fd, char *buf, int len, int min)
-{
-    int n, tot;
-    struct pollfd poll_fd;
-
-    tot = 0;
-    poll_fd.fd = fd;
-    poll_fd.events = POLLIN;
-    while (len) {
-        n = read(fd, buf, len);
-        if (n > 0) {
-            tot += n;
-            buf += n;
-            len -= n;
-        }
-        if (tot % min == 0)
-            break;
-        n = xserver_poll(&poll_fd, 1, 100);
-        if (n <= 0)
-            break;
-    }
-    return tot;
-}
-
-const char *Ps2Names[] = {
-    "/dev/psaux",
-/*    "/dev/mouse", */
-    "/dev/input/mice",
-};
-
-#define NUM_PS2_NAMES	(sizeof (Ps2Names) / sizeof (Ps2Names[0]))
-
-static void
-Ps2Read(int ps2Port, void *closure)
-{
-    unsigned char buf[3 * 200];
-    unsigned char *b;
-    int n;
-    int dx, dy;
-    unsigned long flags;
-    unsigned long left_button = KD_BUTTON_1;
-    unsigned long right_button = KD_BUTTON_3;
-
-#undef SWAP_USB
-#ifdef SWAP_USB
-    if (id == 2) {
-        left_button = KD_BUTTON_3;
-        right_button = KD_BUTTON_1;
-    }
-#endif
-    while ((n = Ps2ReadBytes(ps2Port, (char *) buf, sizeof(buf), 3)) > 0) {
-        b = buf;
-        while (n >= 3) {
-            flags = KD_MOUSE_DELTA;
-            if (b[0] & 4)
-                flags |= KD_BUTTON_2;
-            if (b[0] & 2)
-                flags |= right_button;
-            if (b[0] & 1)
-                flags |= left_button;
-
-            dx = b[1];
-            if (b[0] & 0x10)
-                dx -= 256;
-            dy = b[2];
-            if (b[0] & 0x20)
-                dy -= 256;
-            dy = -dy;
-            n -= 3;
-            b += 3;
-            KdEnqueuePointerEvent(closure, flags, dx, dy, 0);
-        }
-    }
-}
-
-static Status
-Ps2Init(KdPointerInfo * pi)
-{
-    int ps2Port, i;
-
-    if (!pi->path) {
-        for (i = 0; i < NUM_PS2_NAMES; i++) {
-            ps2Port = open(Ps2Names[i], 0);
-            if (ps2Port >= 0) {
-                pi->path = strdup(Ps2Names[i]);
-                break;
-            }
-        }
-    }
-    else {
-        ps2Port = open(pi->path, 0);
-    }
-
-    if (ps2Port < 0)
-        return BadMatch;
-
-    close(ps2Port);
-    if (!pi->name)
-        pi->name = strdup("PS/2 Mouse");
-
-    return Success;
-}
-
-static Status
-Ps2Enable(KdPointerInfo * pi)
-{
-    int fd;
-
-    if (!pi)
-        return BadImplementation;
-
-    fd = open(pi->path, 0);
-    if (fd < 0)
-        return BadMatch;
-
-    if (!KdRegisterFd(fd, Ps2Read, pi)) {
-        close(fd);
-        return BadAlloc;
-    }
-
-    pi->driverPrivate = (void *) (intptr_t) fd;
-
-    return Success;
-}
-
-static void
-Ps2Disable(KdPointerInfo * pi)
-{
-    KdUnregisterFd(pi, (int) (intptr_t) pi->driverPrivate, TRUE);
-}
-
-static void
-Ps2Fini(KdPointerInfo * pi)
-{
-}
-
-KdPointerDriver Ps2MouseDriver = {
-    "ps2",
-    Ps2Init,
-    Ps2Enable,
-    Ps2Disable,
-    Ps2Fini,
-    NULL,
-};
diff --git a/include/kdrive-config.h.in b/include/kdrive-config.h.in
index 3d7e9a4..f59262c 100644
--- a/include/kdrive-config.h.in
+++ b/include/kdrive-config.h.in
@@ -16,12 +16,6 @@
 /* Support tslib touchscreen abstraction library */
 #undef TSLIB
 
-/* Support KDrive kbd driver */
-#undef KDRIVE_KBD
-
-/* Support KDrive mouse driver */
-#undef KDRIVE_MOUSE
-
 /* Support KDrive evdev driver */
 #undef KDRIVE_EVDEV
 
commit d740e1830a7ef32433fdf338c1e04dc6c9a927cb
Author: Adam Jackson <ajax at redhat.com>
Date:   Thu Jan 19 17:30:39 2017 -0500

    dmx: Remove non-evdev hardware input drivers
    
    Use evdev.
    
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Adam Jackson <ajax at redhat.com>

diff --git a/configure.ac b/configure.ac
index d265528..e23c934 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2336,9 +2336,6 @@ if test "x$DMX" = xyes; then
 dnl USB sources in DMX require <linux/input.h>
 	AC_CHECK_HEADER([linux/input.h], DMX_BUILD_USB="yes",
 			DMX_BUILD_USB="no")
-dnl Linux sources in DMX require <linux/keyboard.h>
-	AC_CHECK_HEADER([linux/keyboard.h], DMX_BUILD_LNX="yes",
-			DMX_BUILD_LNX="no")
 	AC_SUBST(XDMXCONFIG_DEP_CFLAGS)
 	AC_SUBST(XDMXCONFIG_DEP_LIBS)
 	PKG_CHECK_MODULES([DMXEXAMPLES_DEP], [$LIBDMX $LIBXEXT x11])
@@ -2355,7 +2352,6 @@ dnl Linux sources in DMX require <linux/keyboard.h>
 	AC_SUBST(X11EXAMPLES_DEP_LIBS)
 
 fi
-AM_CONDITIONAL([DMX_BUILD_LNX], [test "x$DMX_BUILD_LNX" = xyes])
 AM_CONDITIONAL([DMX_BUILD_USB], [test "x$DMX_BUILD_USB" = xyes])
 
 dnl kdrive DDX
diff --git a/hw/dmx/input/Makefile.am b/hw/dmx/input/Makefile.am
index b56ee8e..27f49d3 100644
--- a/hw/dmx/input/Makefile.am
+++ b/hw/dmx/input/Makefile.am
@@ -1,14 +1,5 @@
 noinst_LIBRARIES = libdmxinput.a
 
-if DMX_BUILD_LNX
-RAWSRCS = lnx-keyboard.c \
-          lnx-keyboard.h \
-          lnx-ms.c \
-          lnx-ms.h \
-          lnx-ps2.c \
-          lnx-ps2.h
-endif
-
 if DMX_BUILD_USB
 USBSRCS = usb-keyboard.c \
           usb-keyboard.h \
diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index 554d234..6698181 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -55,9 +55,6 @@
 #include "config/dmxconfig.h"
 #include "dmxcursor.h"
 
-#include "lnx-keyboard.h"
-#include "lnx-ms.h"
-#include "lnx-ps2.h"
 #include "usb-keyboard.h"
 #include "usb-mouse.h"
 #include "usb-other.h"
@@ -134,31 +131,6 @@ static DMXLocalInputInfoRec DMXConsoleKbd = {
 static DMXLocalInputInfoRec DMXLocalDevices[] = {
     /* Dummy drivers that can compile on any OS */
 #ifdef __linux__
-    /* Linux-specific drivers */
-    {
-     "kbd", DMX_LOCAL_KEYBOARD, DMX_LOCAL_TYPE_LOCAL, 1,
-     kbdLinuxCreatePrivate, kbdLinuxDestroyPrivate,
-     kbdLinuxInit, NULL, NULL, kbdLinuxGetInfo,
-     kbdLinuxOn, kbdLinuxOff, NULL,
-     kbdLinuxVTPreSwitch, kbdLinuxVTPostSwitch, kbdLinuxVTSwitch,
-     kbdLinuxRead, NULL, NULL, NULL,
-     NULL, kbdLinuxCtrl, kbdLinuxBell},
-    {
-     "ms", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1,
-     msLinuxCreatePrivate, msLinuxDestroyPrivate,
-     msLinuxInit, NULL, NULL, msLinuxGetInfo,
-     msLinuxOn, msLinuxOff, NULL,
-     msLinuxVTPreSwitch, msLinuxVTPostSwitch, NULL,
-     msLinuxRead},
-    {
-     "ps2", DMX_LOCAL_MOUSE, DMX_LOCAL_TYPE_LOCAL, 1,
-     ps2LinuxCreatePrivate, ps2LinuxDestroyPrivate,
-     ps2LinuxInit, NULL, NULL, ps2LinuxGetInfo,
-     ps2LinuxOn, ps2LinuxOff, NULL,
-     ps2LinuxVTPreSwitch, ps2LinuxVTPostSwitch, NULL,
-     ps2LinuxRead},
-#endif
-#ifdef __linux__
     /* USB drivers, currently only for
        Linux, but relatively easy to port to
        other OSs */
diff --git a/hw/dmx/input/lnx-keyboard.c b/hw/dmx/input/lnx-keyboard.c
deleted file mode 100644
index a273f6b..0000000
--- a/hw/dmx/input/lnx-keyboard.c
+++ /dev/null
@@ -1,1193 +0,0 @@
-/* Portions of this file were derived from the following files:
- *
- **********************************************************************
- *
- * xfree86/common/{xf86Io.c,xf86Kbd.c,xf86Events.c}
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * 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 Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Thomas Roell makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL 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/common/xf86KbdLnx.c
- *
- * Linux version of keymapping setup. The kernel (since 0.99.14) has support
- * for fully remapping the keyboard, but there are some differences between
- * the Linux map and the SVR4 map (esp. in the extended keycodes). We also
- * remove the restriction on what keycodes can be remapped.
- * Orest Zborowski.
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * 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 Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Thomas Roell makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL 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/os-support/linux/lnx_io.c
- *
- * Copyright 1992 by Orest Zborowski <obz at Kodak.com>
- * Copyright 1993 by David Dawes <dawes at 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 Orest Zborowski and David Dawes
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission.  Orest Zborowski
- * 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.
- *
- * OREST ZBOROWSKI AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD
- * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI 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.
- *
- */
-
-/*
- * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
- *
- * 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 on 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 (including the
- * next paragraph) 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
- * NON-INFRINGEMENT.  IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
- * 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.
- */
-
-/*
- * Authors:
- *   Rickard E. (Rik) Faith <faith at redhat.com>
- *
- */
-
-/** \file
- *
- * This code implements a low-level device driver for the Linux
- * keyboard.  The code is derived from code by Thomas Roell, Orest
- * Zborowski, and David Dawes (see the source code for complete
- * references). */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-/*****************************************************************************/
-/* Define some macros to make it easier to move this file to another
- * part of the Xserver tree.  All calls to the dmx* layer are #defined
- * here for the .c file.  The .h file will also have to be edited. */
-#include "dmxinputinit.h"
-#include "lnx-keyboard.h"
-
-#define GETPRIV       myPrivate *priv                            \
-                      = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
-
-#define LOG0(f)       dmxLog(dmxDebug,f)
-#define LOG1(f,a)     dmxLog(dmxDebug,f,a)
-#define LOG2(f,a,b)   dmxLog(dmxDebug,f,a,b)
-#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
-#define FATAL0(f)     dmxLog(dmxFatal,f)
-#define FATAL1(f,a)   dmxLog(dmxFatal,f,a)
-#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
-#define MOTIONPROC    dmxMotionProcPtr
-#define ENQUEUEPROC   dmxEnqueueProcPtr
-#define CHECKPROC     dmxCheckSpecialProcPtr
-#define SWITCHRETPROC dmxVTSwitchReturnProcPtr
-#define BLOCK         DMXBlockType
-#define MESSAGE       "\033c\n\n\nDMX taking input from this console..."
-#define FINALMESSAGE  "\033cDMX terminated."
-
-/* End of interface definitions. */
-/*****************************************************************************/
-
-#include "inputstr.h"
-#include <X11/Xos.h>
-#include <sys/ioctl.h>
-#include <errno.h>
-#include <sys/vt.h>
-#include <sys/kd.h>
-#include <termios.h>
-#include "atKeynames.h"
-#if 00
-#include "xf86Keymap.h"
-#endif
-#include <linux/keyboard.h>
-#include <xkbsrv.h>
-
-#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
-#define NUM_STATE_ENTRIES (256/32)
-
-/* Private area for Linux-style keyboards. */
-typedef struct _myPrivate {
-    int fd;
-    int vtno;
-    int vtcurrent;
-    int kbdtrans;
-    struct termios kbdtty;
-    int kbdType;
-    CARD32 kbdState[NUM_STATE_ENTRIES];
-    DeviceIntPtr pKeyboard;
-    unsigned char prefix;
-
-    int switched;
-    SWITCHRETPROC switch_return;
-    void *switch_return_data;
-
-    /* For bell */
-    int pitch;
-    unsigned long duration;
-} myPrivate;
-
-static myPrivate *PRIV = NULL;
-
-#undef SYSCALL
-#define SYSCALL(call) while(((call) == -1) && (errno == EINTR))
-
-static int
-kbdLinuxKeyDown(myPrivate * priv, int keyCode)
-{
-    CARD8 byte = keyCode >> 5;
-    CARD32 bit = 1 << (keyCode & 0x1f);
-
-    if (byte > NUM_STATE_ENTRIES)
-        return 0;
-    return priv->kbdState[byte] & bit;
-}
-
-static void
-kbdLinuxKeyState(myPrivate * priv, int type, int keyCode)
-{
-    CARD8 byte = keyCode >> 5;
-    CARD32 bit = 1 << (keyCode & 0x1f);
-
-    if (byte > NUM_STATE_ENTRIES)
-        return;
-    if (type == KeyPress)
-        priv->kbdState[byte] |= bit;
-    else
-        priv->kbdState[byte] &= ~bit;
-}
-
-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[NUM_KEYCODES] = {
-    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 */
-};
-
-/** Create a private structure for use within this file. */
-void *
-kbdLinuxCreatePrivate(DeviceIntPtr pKeyboard)
-{
-    myPrivate *priv = calloc(1, sizeof(*priv));
-
-    priv->fd = -1;
-    priv->pKeyboard = pKeyboard;
-    return priv;
-}
-
-/** Destroy a private structure. */
-void
-kbdLinuxDestroyPrivate(void *priv)
-{
-    free(priv);
-}
-
-/** Ring the bell.
- *
- * Note: we completely ignore the \a volume, since Linux's ioctl()
- * interface does not provide a way to control it.  If it did, the XBell
- * manpage tells how the actual volume is a function of the percent and
- * the (base) volume.
- *
- * Note that most of the other PC-based bell drivers compute the
- * duration for KDMKTONE as a function of the volume and the duration.
- * For some drivers, the duration is only measured in mS if the volume
- * is 50, and is scaled by the volume for other values.  This seems
- * confusing and possibly incorrect (the xset man page says that the
- * bell will be "as closely as it can to the user's specifications" --
- * if we ignore the volume and set the duration correctly, then we'll
- * get one parameter "wrong" -- but if we use the volume to scale the
- * duration, then we'll get both parameters "wrong"). */
-void
-kbdLinuxBell(DevicePtr pDev, int percent, int volume, int pitch, int duration)
-{
-    GETPRIV;
-
-    if (duration && pitch) {
-        ioctl(priv->fd, KDMKTONE, ((1193190 / pitch) & 0xffff)  /* Low bits specify cycle time */
-              |(duration << 16));       /* High bits are duration in msec */
-    }
-}
-
-/** Set the LEDs. */
-void
-kbdLinuxCtrl(DevicePtr pDev, KeybdCtrl * ctrl)
-{
-    GETPRIV;
-
-    ioctl(priv->fd, KDSETLED, ctrl->leds & 0x07);
-}
-
-static int
-kbdLinuxGetFreeVTNumber(void)
-{
-    int fd = -1;
-    int vtno;
-    int i;
-    const char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
-
-    for (i = 0; tty0[i]; i++)
-        if ((fd = open(tty0[i], O_WRONLY, 0)) >= 0)
-            break;
-    if (fd < 0)
-        FATAL1("kbdLinuxGetFreeVTNumber: Cannot open tty0 (%s)\n",
-               strerror(errno));
-    if (ioctl(fd, VT_OPENQRY, &vtno) < 0 || vtno < 0)
-        FATAL0("kbdLinuxGetFreeVTNumber: Cannot find a free VT\n");
-    return vtno;
-}
-
-static int
-kbdLinuxOpenVT(int vtno)
-{
-    int fd = -1;
-    int i;
-    const char *vcs[] = { "/dev/vc/", "/dev/tty", NULL };
-    char name[64];              /* RATS: Only used in snprintf */
-
-    for (i = 0; vcs[i]; i++) {
-        snprintf(name, sizeof(name), "%s%d", vcs[i], vtno);
-        if ((fd = open(name, O_RDWR | O_NONBLOCK, 0)) >= 0)
-            break;
-    }
-    if (fd < 0)
-        FATAL2("kbdLinuxOpenVT: Cannot open VT %d (%s)\n",
-               vtno, strerror(errno));
-    return fd;
-}
-
-static int
-kbdLinuxGetCurrentVTNumber(int fd)
-{
-    struct vt_stat vts;
-
-    if (!ioctl(fd, VT_GETSTATE, &vts))
-        return vts.v_active;
-    return -1;
-}
-
-static int kbdLinuxActivate(int fd, int vtno, int setSig);
-
-/** Currently unused hook called prior to an VT switch. */
-void
-kbdLinuxVTPreSwitch(void *p)
-{
-}
-
-/** Currently unused hook called after returning from a VT switch. */
-void
-kbdLinuxVTPostSwitch(void *p)
-{
-}
-
-/** Tell the operating system to switch to \a vt.  The \a switch_return
- * function is called with the \a switch_return_data when the VT is
- * switched back to the pre-switch VT (i.e., the user returns to the DMX
- * session). */
-int
-kbdLinuxVTSwitch(void *p, int vt,
-                 void (*switch_return) (void *), void *switch_return_data)
-{
-    myPrivate *priv = p;
-
-    if (priv->switched)
-        FATAL0("kbdLinuxVTSwitch: already switched...\n");
-    if (priv->vtno == vt)
-        return 0;
-
-    PRIV = priv;
-    priv->switched = 0;         /* Will switch to 1 in handler */
-    priv->switch_return = switch_return;
-    priv->switch_return_data = switch_return_data;
-    kbdLinuxActivate(priv->fd, vt, 0);
-    return 1;
-}
-
-/* RATS: This function is only ever used to handle SIGUSR1. */
-static void
-kbdLinuxVTSignalHandler(int sig)
-{
-    myPrivate *priv = PRIV;
-
-    OsSignal(sig, kbdLinuxVTSignalHandler);
-    if (priv) {
-        ioctl(priv->fd, VT_RELDISP, VT_ACKACQ);
-        priv->switched = !priv->switched;
-        LOG2("kbdLinuxVTSignalHandler: got signal %d, switched = %d\n",
-             sig, priv->switched);
-        if (!priv->switched && priv->switch_return)
-            priv->switch_return(priv->switch_return_data);
-    }
-}
-
-static int
-kbdLinuxActivate(int fd, int vtno, int setSig)
-{
-    int result;
-    struct vt_mode VT;
-
-    SYSCALL(result = ioctl(fd, VT_ACTIVATE, vtno));
-    if (result)
-        FATAL0("kbdLinuxActivate: VT_ACTIVATE failed\n");
-    SYSCALL(result = ioctl(fd, VT_WAITACTIVE, vtno));
-    if (result)
-        FATAL0("kbdLinuxActivate: VT_WAITACTIVE failed\n");
-    if (setSig) {
-        SYSCALL(result = ioctl(fd, VT_GETMODE, &VT));
-        if (result < 0)
-            FATAL0("kbdLinuxActivate: VT_GETMODE failed\n");
-        VT.mode = VT_PROCESS;
-        VT.relsig = SIGUSR1;
-        VT.acqsig = SIGUSR1;
-        if (ioctl(fd, VT_SETMODE, &VT))
-            FATAL0("kbdLinuxActivate: VT_SETMODE VT_PROCESS failed\n");
-        OsSignal(SIGUSR1, kbdLinuxVTSignalHandler);
-    }
-    return Success;
-}
-
-static void
-kbdLinuxOpenConsole(DevicePtr pDev)
-{
-    GETPRIV;
-    const char *msg = MESSAGE;
-
-    if (priv->fd >= 0)
-        return;
-    priv->vtno = kbdLinuxGetFreeVTNumber();
-    priv->fd = kbdLinuxOpenVT(priv->vtno);
-    priv->vtcurrent = kbdLinuxGetCurrentVTNumber(priv->fd);
-    LOG2("kbdLinuxOpenConsole: current VT %d; using free VT %d\n",
-         priv->vtcurrent, priv->vtno);
-    kbdLinuxActivate(priv->fd, priv->vtno, 1);
-    ioctl(priv->fd, KDSETMODE, KD_GRAPHICS);    /* To turn off gpm */
-    if (msg)
-        write(priv->fd, msg, strlen(msg));
-}
-
-static void
-kbdLinuxCloseConsole(DevicePtr pDev)
-{
-    GETPRIV;
-    struct vt_mode VT;
-    const char *msg = FINALMESSAGE;
-
-    if (priv->fd < 0)
-        return;
-
-    ioctl(priv->fd, KDSETMODE, KD_TEXT);
-    if (msg)
-        write(priv->fd, msg, strlen(msg));
-    if (ioctl(priv->fd, VT_GETMODE, &VT) != -1) {
-        VT.mode = VT_AUTO;
-        ioctl(priv->fd, VT_SETMODE, &VT);
-    }
-
-    LOG1("kbdLinuxCloseConsole: switching to VT %d\n", priv->vtcurrent);
-    if (priv->vtcurrent >= 0)
-        kbdLinuxActivate(priv->fd, priv->vtcurrent, 0);
-
-    close(priv->fd);
-    priv->fd = -1;
-}
-
-/** Initialize the \a pDev as a Linux keyboard. */
-void
-kbdLinuxInit(DevicePtr pDev)
-{
-    GETPRIV;
-
-    if (priv->fd <= 0)
-        kbdLinuxOpenConsole(pDev);
-
-    ioctl(priv->fd, KDGKBMODE, &priv->kbdtrans);
-    if (tcgetattr(priv->fd, &priv->kbdtty) < 0)
-        FATAL1("kbdLinuxInit: tcgetattr failed (%s)\n", strerror(errno));
-}
-
-static int
-kbdLinuxPrefix0Mapping(unsigned char *scanCode)
-{
-    /* Table from xfree86/common/xf86Events.c */
-    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 1;
-    default:
-        /*
-         * "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;
-    }
-    return 0;
-}
-
-static int
-kbdLinuxPrefixMapping(myPrivate * priv, unsigned char *scanCode)
-{
-    int pressed = *scanCode & 0x80;
-    unsigned char code = *scanCode & 0x7f;
-
-    /* If we don't have a prefix, check for one */
-    if (!priv->prefix) {
-        switch (code) {
-        case KEY_Prefix0:
-        case KEY_Prefix1:
-            priv->prefix = code;
-            return 1;
-        }
-        return 0;               /* No change */
-    }
-
-    /* We have a prefix from the last scanCode */
-    switch (priv->prefix) {
-    case KEY_Prefix0:
-        priv->prefix = 0;
-        if (kbdLinuxPrefix0Mapping(&code))
-            return 1;           /* Skip sequence */
-        break;
-    case KEY_Prefix1:
-        priv->prefix = (code = KEY_LCtrl) ? KEY_LCtrl : 0;
-        return 1;               /* Use new prefix */
-    case KEY_LCtrl:
-        priv->prefix = 0;
-        if (code != KEY_NumLock)
-            return 1;           /* Skip sequence */
-        code = KEY_Pause;
-        break;
-    }
-
-    *scanCode = code | (pressed ? 0x80 : 0x00);
-    return 0;                   /* Use old scanCode */
-}
-
-static void
-kbdLinuxConvert(DevicePtr pDev,
-                unsigned char scanCode,
-                ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)
-{
-    GETPRIV;
-    XkbSrvInfoPtr xkbi = priv->pKeyboard->key->xkbInfo;
-    int type;
-    KeySym keySym = NoSymbol;
-    int keyCode;
-    int switching;
-
-    /* Do special PC/AT prefix mapping -- may change scanCode! */
-    if (kbdLinuxPrefixMapping(priv, &scanCode))
-        return;
-
-    type = (scanCode & 0x80) ? KeyRelease : KeyPress;
-    keyCode = (scanCode & 0x7f) + MIN_KEYCODE;
-
-    /* Handle repeats */
-
-    if (keyCode >= xkbi->desc->min_key_code &&
-        keyCode <= xkbi->desc->max_key_code) {
-
-        int effectiveGroup = XkbGetEffectiveGroup(xkbi,
-                                                  &xkbi->state,
-                                                  scanCode);
-
-        keySym = XkbKeySym(xkbi->desc, scanCode, effectiveGroup);
-#if 0
-        switch (keySym) {
-        case XK_Num_Lock:
-        case XK_Scroll_Lock:
-        case XK_Shift_Lock:
-        case XK_Caps_Lock:
-            /* Ignore releases and all but first press */
-            if (kbdLinuxModIgnore(priv, &xE, keySym))
-                return;
-            if (kbdLinuxKeyDown(priv, &xE))
-                xE.u.u.type = KeyRelease;
-            else
-                xE.u.u.type = KeyPress;
-            break;
-        }
-#endif
-
-        /* If key is already down, ignore or autorepeat */
-        if (type == KeyPress && kbdLinuxKeyDown(priv, keyCode)) {
-            KbdFeedbackClassRec *feed = priv->pKeyboard->kbdfeed;
-
-            /* No auto-repeat? */
-            if ((feed && !feed->ctrl.autoRepeat)
-                || priv->pKeyboard->key->xkbInfo->desc->map->modmap[keyCode]
-                || (feed && !(feed->ctrl.autoRepeats[keyCode >> 3]
-                              & (1 << (keyCode & 7)))))
-                return;         /* Ignore */
-
-            /* Do auto-repeat */
-            enqueue(pDev, KeyRelease, keyCode, keySym, NULL, block);
-            type = KeyPress;
-        }
-
-        /* If key is already up, ignore */
-        if (type == KeyRelease && !kbdLinuxKeyDown(priv, keyCode))
-            return;
-    }
-
-    switching = 0;
-    if (checkspecial && type == KeyPress)
-        switching = checkspecial(pDev, keySym);
-    if (!switching) {
-        if (enqueue)
-            enqueue(pDev, type, keyCode, keySym, NULL, block);
-        kbdLinuxKeyState(priv, type, keyCode);  /* Update our state bitmap */
-    }
-}
-
-/** Read an event from the \a pDev device.  If the event is a motion
- * event, enqueue it with the \a motion function.  Otherwise, check for
- * special keys with the \a checkspecial function and enqueue the event
- * with the \a enqueue function.  The \a block type is passed to the
- * functions so that they may block the input thread as appropriate to the
- * caller of this function. */
-void
-kbdLinuxRead(DevicePtr pDev,
-             MOTIONPROC motion,
-             ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)
-{
-    GETPRIV;
-    unsigned char buf[256];     /* RATS: Only used in length-limited call */
-    unsigned char *pt;
-    int n;
-
-    while ((n = read(priv->fd, buf, sizeof(buf))) > 0)
-        for (pt = buf; n; --n, ++pt)
-            kbdLinuxConvert(pDev, *pt, enqueue, checkspecial, block);
-}
-
-/** Turn \a pDev on (i.e., take input from \a pDev). */
-int
-kbdLinuxOn(DevicePtr pDev)
-{
-    GETPRIV;
-    struct termios nTty;
-
-    ioctl(priv->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, B9600);
-    cfsetospeed(&nTty, B9600);
-    if (tcsetattr(priv->fd, TCSANOW, &nTty) < 0)
-        FATAL1("kbdLinuxOn: tcsetattr failed (%s)\n", strerror(errno));
-    return priv->fd;
-}
-
-/** Turn \a pDev off (i.e., stop taking input from \a pDev). */
-void
-kbdLinuxOff(DevicePtr pDev)
-{
-    GETPRIV;
-
-    ioctl(priv->fd, KDSKBMODE, priv->kbdtrans);
-    tcsetattr(priv->fd, TCSANOW, &priv->kbdtty);
-    kbdLinuxCloseConsole(pDev);
-}
-
-static void
-kbdLinuxReadKernelMapping(int fd, KeySymsPtr pKeySyms)
-{
-    KeySym *k;
-    int i;
-    int maxkey;
-
-    static unsigned char tbl[GLYPHS_PER_KEY] = {        /* RATS: Use ok */
-        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 00 /*BP*/
-        k = map + GLYPHS_PER_KEY;
-#else
-    ErrorF("kbdLinuxReadKernelMapping() is broken/no-op'd\n");
-    return;
-#endif
-    maxkey = NUM_AT2LNX;
-
-    for (i = 0; i < maxkey; ++i) {
-        struct kbentry kbe;
-        int j;
-
-        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 (kbe.kb_index == 0 || ioctl(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;
-            case KT_DEAD:
-                /* KT_DEAD keys are for accelerated diacritical creation. */
-                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;
-            case KT_ASCII:
-                /* KT_ASCII keys accumulate a 3 digit decimal number that
-                 * gets emitted when the shift state changes. We can't
-                 * emulate that.
-                 */
-                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;
-    }
-}
-
-static void
-kbdLinuxGetMap(DevicePtr pDev, KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
-    GETPRIV;
-    KeySym *k, *mapCopy;
-    char type;
-    int i;
-
-#if 00 /*BP*/
-        mapCopy = malloc(sizeof(map));
-    memcpy(mapCopy, map, sizeof(map));
-#else
-    ErrorF("kbdLinuxGetMap() is broken/no-op'd\n");
-    return;
-#endif
-
-    kbdLinuxReadKernelMapping(priv->fd, pKeySyms);
-
-    /* compute the modifier map */
-    for (i = 0; i < MAP_LENGTH; i++)
-        pModMap[i] = NoSymbol;  /* make sure it is restored */
-
-    for (k = mapCopy, 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;
-        case XK_Kana_Lock:
-        case XK_Kana_Shift:
-            pModMap[i] = KanaMask;
-            break;
-        case XK_Mode_switch:
-            pModMap[i] = AltLangMask;
-            break;
-        }
-    }
-
-    priv->kbdType = (ioctl(priv->fd, KDGKBTYPE, &type) < 0) ? KB_101 : type;
-
-    pKeySyms->map = mapCopy;    /* Must be XFree'able */
-    pKeySyms->mapWidth = GLYPHS_PER_KEY;
-    pKeySyms->minKeyCode = MIN_KEYCODE;
-    pKeySyms->maxKeyCode = MAX_KEYCODE;
-}
-
-/** Fill the \a info structure with information needed to initialize \a
- * pDev. */
-void
-kbdLinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
-{
-    info->keyboard = 1;
-    info->keyClass = 1;
-    kbdLinuxGetMap(pDev, &info->keySyms, info->modMap);
-    info->focusClass = 1;
-    info->kbdFeedbackClass = 1;
-}
diff --git a/hw/dmx/input/lnx-keyboard.h b/hw/dmx/input/lnx-keyboard.h
deleted file mode 100644
index 857ea11..0000000
--- a/hw/dmx/input/lnx-keyboard.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2001 Red Hat Inc., Durham, North Carolina.
- *
- * 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 on 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 (including the
- * next paragraph) 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
- * NON-INFRINGEMENT.  IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
- * 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.
- */
-
-/*
- * Authors:
- *   Rickard E. (Rik) Faith <faith at redhat.com>
- *
- */
-
-/** \file
- * Interface to Linux keyboard driver.  \see lnx-keyboard.c */
-
-#ifndef _LNX_KEYBOARD_H_
-#define _LNX_KEYBOARD_H_
-
-extern void *kbdLinuxCreatePrivate(DeviceIntPtr pKeyboard);
-extern void kbdLinuxDestroyPrivate(void *private);
-
-extern void kbdLinuxInit(DevicePtr pDev);
-extern void kbdLinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
-extern int kbdLinuxOn(DevicePtr pDev);
-extern void kbdLinuxOff(DevicePtr pDev);
-
-extern void kbdLinuxVTPreSwitch(void *p);
-extern void kbdLinuxVTPostSwitch(void *p);
-extern int kbdLinuxVTSwitch(void *p, int vt,
-                            dmxVTSwitchReturnProcPtr switch_return,
-                            void *switch_return_data);
-
-extern void kbdLinuxRead(DevicePtr pDev,
-                         dmxMotionProcPtr motion,
-                         dmxEnqueueProcPtr enqueue,
-                         dmxCheckSpecialProcPtr checkspecial,
-                         DMXBlockType block);
-
-extern void kbdLinuxCtrl(DevicePtr pDev, KeybdCtrl * ctrl);
-extern void kbdLinuxBell(DevicePtr pDev, int percent,
-                         int volume, int pitch, int duration);
-#endif
diff --git a/hw/dmx/input/lnx-ms.c b/hw/dmx/input/lnx-ms.c
deleted file mode 100644
index 1a5786c..0000000
--- a/hw/dmx/input/lnx-ms.c
+++ /dev/null
@@ -1,349 +0,0 @@
-/* Portions of this file were derived from the following files:
- *
- **********************************************************************
- *
- * Xserver/hw/kdrive/linux/ms.c
- *
- * Copyright (c) 2001 by Juliusz Chroboczek
- * Copyright (c) 1999 by Keith Packard
- *
- * 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 AUTHORS OR COPYRIGHT HOLDERS
- * 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.
- *
- */
-
-/*
- * Copyright 2001-2003 Red Hat Inc., Durham, North Carolina.
- *
- * 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 on 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 (including the
- * next paragraph) 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
- * NON-INFRINGEMENT.  IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
- * 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.
- */
-
-/*
- * Authors:
- *   Rickard E. (Rik) Faith <faith at redhat.com>
- *
- */
-
-/** \file
- *
- * This code implements a low-level device driver for a serial MS mouse.
- * The code is derived from code by Juliusz Chroboczek and Keith Packard
- * (see the source code for complete references). */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#include "inputstr.h"
-#include <X11/Xos.h>
-#include <errno.h>
-#include <termios.h>
-#include <xserver_poll.h>
-
-/*****************************************************************************/
-/* Define some macros to make it easier to move this file to another
- * part of the Xserver tree.  All calls to the dmx* layer are #defined
- * here for the .c file.  The .h file will also have to be edited. */
-#include "dmxinputinit.h"
-#include "lnx-ms.h"
-
-#define GETPRIV       myPrivate *priv                            \
-                      = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
-
-#define LOG0(f)       dmxLog(dmxDebug,f)
-#define LOG1(f,a)     dmxLog(dmxDebug,f,a)
-#define LOG2(f,a,b)   dmxLog(dmxDebug,f,a,b)
-#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
-#define FATAL0(f)     dmxLog(dmxFatal,f)
-#define FATAL1(f,a)   dmxLog(dmxFatal,f,a)
-#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
-#define MOTIONPROC    dmxMotionProcPtr
-#define ENQUEUEPROC   dmxEnqueueProcPtr
-#define CHECKPROC     dmxCheckSpecialProcPtr
-#define BLOCK         DMXBlockType
-
-/* End of interface definitions. */
-/*****************************************************************************/
-
-/* Private area for MS mouse devices. */
-typedef struct _myPrivate {
-    DeviceIntPtr pMouse;
-    int fd;
-    struct termios tty;
-    enum {
-        button1 = 0x0001,
-        button2 = 0x0002,
-        button3 = 0x0004,
-        button4 = 0x0008,
-        button5 = 0x0010
-    } buttons;
-} myPrivate;
-
-static int
-msLinuxReadBytes(int fd, unsigned char *buf, int len, int min)
-{
-    int n, tot;
-    struct pollfd poll_fd;
-
-    tot = 0;
-    poll_fd.fd = fd;
-    poll_fd.events = POLLIN;
-    while (len) {
-        n = read(fd, buf, len);
-        if (n > 0) {
-            tot += n;
-            buf += n;
-            len -= n;
-        }
-        if (tot % min == 0)
-            break;
-        n = xserver_poll(&poll_fd, 1, 100);
-        if (n <= 0)
-            break;
-    }
-    return tot;
-}
-
-static void
-msLinuxButton(DevicePtr pDev, ENQUEUEPROC enqueue, int buttons, BLOCK block)
-{
-    GETPRIV;
-
-#define PRESS(b)                                         \
-    do {                                                 \
-        enqueue(pDev, ButtonPress, 0, 0, NULL, block);   \
-    } while (0)
-
-#define RELEASE(b)                                       \
-    do {                                                 \
-        enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \
-    } while (0)
-
-    if ((buttons & button1) && !(priv->buttons & button1))
-        PRESS(1);
-    if (!(buttons & button1) && (priv->buttons & button1))
-        RELEASE(1);
-
-    if ((buttons & button2) && !(priv->buttons & button2))
-        PRESS(2);
-    if (!(buttons & button2) && (priv->buttons & button2))
-        RELEASE(2);
-
-    if ((buttons & button3) && !(priv->buttons & button3))
-        PRESS(3);
-    if (!(buttons & button3) && (priv->buttons & button3))
-        RELEASE(3);
-
-    if ((buttons & button4) && !(priv->buttons & button4))
-        PRESS(4);
-    if (!(buttons & button4) && (priv->buttons & button4))
-        RELEASE(4);
-
-    if ((buttons & button5) && !(priv->buttons & button5))
-        PRESS(5);
-    if (!(buttons & button5) && (priv->buttons & button5))
-        RELEASE(5);
-
-    priv->buttons = buttons;
-}
-
-/** Read an event from the \a pDev device.  If the event is a motion
- * event, enqueue it with the \a motion function.  Otherwise, check for
- * special keys with the \a checkspecial function and enqueue the event
- * with the \a enqueue function.  The \a block type is passed to the
- * functions so that they may block the input thread as appropriate to the
- * caller of this function. */
-void
-msLinuxRead(DevicePtr pDev,
-            MOTIONPROC motion,
-            ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)
-{
-    GETPRIV;
-    unsigned char buf[3 * 200]; /* RATS: Use ok */
-    unsigned char *b;
-    int n;
-    int dx, dy, v[2];
-
-    while ((n = msLinuxReadBytes(priv->fd, buf, sizeof(buf), 3)) > 0) {
-        b = buf;
-        while (n >= 3) {
-            dx = (char) (((b[0] & 0x03) << 6) | (b[1] & 0x3f));
-            dy = (char) (((b[0] & 0x0c) << 4) | (b[2] & 0x3f));
-            v[0] = -dx;
-            v[1] = -dy;
-
-            motion(pDev, v, 0, 2, 1, block);
-            msLinuxButton(pDev, enqueue, (((b[0] & 0x10) ? button3 : 0)
-                                          | ((b[0] & 0x20) ? button1 : 0)),
-                          block);
-            n -= 3;
-            b += 3;
-        }
-    }
-}
-
-/** Initialize \a pDev. */
-void
-msLinuxInit(DevicePtr pDev)
-{
-    GETPRIV;
-    const char *names[] = { "/dev/serialmouse", "/dev/mouse", NULL };
-    int i;
-
-    if (priv->fd >= 0)
-        return;
-
-    for (i = 0; names[i]; i++) {
-        if ((priv->fd = open(names[i], O_RDWR | O_NONBLOCK, 0)) >= 0)
-            break;
-    }
-    if (priv->fd < 0)
-        FATAL1("msLinuxInit: Cannot open mouse port (%s)\n", strerror(errno));
-
-    if (!isatty(priv->fd))
-        FATAL1("msLinuxInit: Mouse port %s is not a tty\n", names[i]);
-
-    if (tcgetattr(priv->fd, &priv->tty) < 0)
-        FATAL1("msLinuxInit: tcgetattr failed (%s)\n", strerror(errno));
-
-    i = write(priv->fd, "*n", 2);   /* 1200 baud */
-    (void) i;
-    usleep(100000);
-}
-
-/** Turn \a pDev on (i.e., take input from \a pDev). */
-int
-msLinuxOn(DevicePtr pDev)
-{
-    GETPRIV;
-    struct termios nTty;
-    int i;
-
-    if (priv->fd < 0)
-        msLinuxInit(pDev);
-
-    nTty = priv->tty;
-    nTty.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR
-                      | IGNCR | ICRNL | IXON | IXOFF);
-    nTty.c_oflag &= ~OPOST;
-    nTty.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
-    nTty.c_cflag &= ~(CSIZE | PARENB);
-    nTty.c_cflag |= CS8 | CLOCAL | CSTOPB;
-    nTty.c_cc[VTIME] = 0;
-    nTty.c_cc[VMIN] = 1;
-    cfsetispeed(&nTty, B1200);
-    cfsetospeed(&nTty, B1200);
-    if (tcsetattr(priv->fd, TCSANOW, &nTty) < 0)
-        FATAL1("msLinuxInit: tcsetattr failed (%s)\n", strerror(errno));
-    i = write(priv->fd, "*V", 2);   /* 2 button 3 byte protocol */
-    (void) i;
-    return priv->fd;
-}
-
-/** Turn \a pDev off (i.e., stop taking input from \a pDev). */
-void
-msLinuxOff(DevicePtr pDev)
-{
-    GETPRIV;
-
-    tcsetattr(priv->fd, TCSANOW, &priv->tty);
-    close(priv->fd);
-    priv->fd = -1;
-}
-
-static void
-msLinuxGetMap(DevicePtr pDev, unsigned char *map, int *nButtons)
-{
-    int i;
-
-    if (nButtons)
-        *nButtons = 3;
-    if (map)
-        for (i = 0; i <= *nButtons; i++)
-            map[i] = i;
-}
-
-/** Currently unused hook called prior to an VT switch. */
-void
-msLinuxVTPreSwitch(void *p)
-{
-}
-
-/** Currently unused hook called after returning from a VT switch. */
-void
-msLinuxVTPostSwitch(void *p)
-{
-}
-
-/** Create a private structure for use within this file. */
-void *
-msLinuxCreatePrivate(DeviceIntPtr pMouse)
-{
-    myPrivate *priv = calloc(1, sizeof(*priv));
-
-    priv->fd = -1;
-    priv->pMouse = pMouse;
-    return priv;
-}
-
-/** Destroy a private structure. */
-void
-msLinuxDestroyPrivate(void *priv)
-{
-    free(priv);
-}
-
-/** Fill the \a info structure with information needed to initialize \a
- * pDev. */
-void
-msLinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
-{
-    info->buttonClass = 1;
-    msLinuxGetMap(pDev, info->map, &info->numButtons);
-    info->valuatorClass = 1;
-    info->numRelAxes = 2;
-    info->minval[0] = 0;
-    info->maxval[0] = 0;
-    info->res[0] = 1;
-    info->minres[0] = 0;
-    info->maxres[0] = 1;
-    info->ptrFeedbackClass = 1;
-}
diff --git a/hw/dmx/input/lnx-ms.h b/hw/dmx/input/lnx-ms.h
deleted file mode 100644
index 7f3ba4e..0000000
--- a/hw/dmx/input/lnx-ms.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2001 Red Hat Inc., Durham, North Carolina.
- *
- * 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 on 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 (including the
- * next paragraph) 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
- * NON-INFRINGEMENT.  IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
- * 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.
- */
-
-/*
- * Authors:
- *   Rickard E. (Rik) Faith <faith at redhat.com>
- *
- */
-
-/** \file
- * Interface to Linux MS mouse driver.  \see lnx-ms.c */
-
-#ifndef _LNX_MS_H_
-#define _LNX_MS_H_
-
-extern void *msLinuxCreatePrivate(DeviceIntPtr pMouse);
-extern void msLinuxDestroyPrivate(void *priv);
-extern void msLinuxRead(DevicePtr pDev,
-                        dmxMotionProcPtr motion,
-                        dmxEnqueueProcPtr enqueue,
-                        dmxCheckSpecialProcPtr checkspecial,
-                        DMXBlockType block);
-extern void msLinuxInit(DevicePtr pDev);
-extern void msLinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
-extern int msLinuxOn(DevicePtr pDev);
-extern void msLinuxOff(DevicePtr pDev);
-extern void msLinuxCtrl(DevicePtr pDev, PtrCtrl * ctrl);
-extern void msLinuxVTPreSwitch(void *p);
-extern void msLinuxVTPostSwitch(void *p);
-
-#endif
diff --git a/hw/dmx/input/lnx-ps2.c b/hw/dmx/input/lnx-ps2.c
deleted file mode 100644
index 2b6e8d6..0000000
--- a/hw/dmx/input/lnx-ps2.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/* Portions of this file were derived from the following files:
- *
- **********************************************************************
- *
- * Xserver/hw/kdrive/linux/ps2.c
- *
- * Copyright (c) 1999 by Keith Packard
- *
- * 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 Keith Packard not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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 2001,2003 Red Hat Inc., Durham, North Carolina.
- *
- * 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 on 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 (including the
- * next paragraph) 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
- * NON-INFRINGEMENT.  IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
- * 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.
- */
-
-/*
- * Authors:
- *   Rickard E. (Rik) Faith <faith at redhat.com>
- *
- */
-
-/** \file
- *
- * This code implements a low-level device driver for a serial MS mouse.
- * The code is derived from code by Keith Packard (see the source code
- * for complete references). */
-
-#ifdef HAVE_DMX_CONFIG_H
-#include <dmx-config.h>
-#endif
-
-#include "inputstr.h"
-#include <X11/Xos.h>
-#include <errno.h>
-#include <termios.h>
-#include <xserver_poll.h>
-
-/*****************************************************************************/
-/* Define some macros to make it easier to move this file to another
- * part of the Xserver tree.  All calls to the dmx* layer are #defined
- * here for the .c file.  The .h file will also have to be edited. */
-#include "dmxinputinit.h"
-#include "lnx-ps2.h"
-
-#define GETPRIV       myPrivate *priv                            \
-                      = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
-
-#define LOG0(f)       dmxLog(dmxDebug,f)
-#define LOG1(f,a)     dmxLog(dmxDebug,f,a)
-#define LOG2(f,a,b)   dmxLog(dmxDebug,f,a,b)
-#define LOG3(f,a,b,c) dmxLog(dmxDebug,f,a,b,c)
-#define FATAL0(f)     dmxLog(dmxFatal,f)
-#define FATAL1(f,a)   dmxLog(dmxFatal,f,a)
-#define FATAL2(f,a,b) dmxLog(dmxFatal,f,a,b)
-#define MOTIONPROC    dmxMotionProcPtr
-#define ENQUEUEPROC   dmxEnqueueProcPtr
-#define CHECKPROC     dmxCheckSpecialProcPtr
-#define BLOCK         DMXBlockType
-
-/* End of interface definitions. */
-/*****************************************************************************/
-
-/* Private area for PS/2 devices. */
-typedef struct _myPrivate {
-    DeviceIntPtr pMouse;
-    int fd;
-    enum {
-        button1 = 0x0001,
-        button2 = 0x0002,
-        button3 = 0x0004,
-        button4 = 0x0008,
-        button5 = 0x0010
-    } buttons;
-} myPrivate;
-
-static int
-ps2LinuxReadBytes(int fd, unsigned char *buf, int len, int min)
-{
-    int n, tot;
-    struct pollfd poll_fd;
-
-    poll_fd.fd = fd;
-    poll_fd.events = POLLIN;
-    tot = 0;
-    while (len) {
-        n = read(fd, buf, len);
-        if (n > 0) {
-            tot += n;
-            buf += n;
-            len -= n;
-        }
-        if (tot % min == 0)
-            break;
-        n = xserver_poll(&poll_fd, 1, 100);
-        if (n <= 0)
-            break;
-    }
-    return tot;
-}
-
-static void
-ps2LinuxButton(DevicePtr pDev, ENQUEUEPROC enqueue, int buttons, BLOCK block)
-{
-    GETPRIV;
-
-#define PRESS(b)                                         \
-    do {                                                 \
-        enqueue(pDev, ButtonPress, 0, 0, NULL, block);   \
-    } while (0)
-
-#define RELEASE(b)                                       \
-    do {                                                 \
-        enqueue(pDev, ButtonRelease, 0, 0, NULL, block); \
-    } while (0)
-
-    if ((buttons & button1) && !(priv->buttons & button1))
-        PRESS(1);
-    if (!(buttons & button1) && (priv->buttons & button1))
-        RELEASE(1);
-
-    if ((buttons & button2) && !(priv->buttons & button2))
-        PRESS(2);
-    if (!(buttons & button2) && (priv->buttons & button2))
-        RELEASE(2);
-
-    if ((buttons & button3) && !(priv->buttons & button3))
-        PRESS(3);
-    if (!(buttons & button3) && (priv->buttons & button3))
-        RELEASE(3);
-
-    if ((buttons & button4) && !(priv->buttons & button4))
-        PRESS(4);
-    if (!(buttons & button4) && (priv->buttons & button4))
-        RELEASE(4);
-
-    if ((buttons & button5) && !(priv->buttons & button5))
-        PRESS(5);
-    if (!(buttons & button5) && (priv->buttons & button5))
-        RELEASE(5);
-
-    priv->buttons = buttons;
-}
-
-/** Read an event from the \a pDev device.  If the event is a motion
- * event, enqueue it with the \a motion function.  Otherwise, check for
- * special keys with the \a checkspecial function and enqueue the event
- * with the \a enqueue function.  The \a block type is passed to the
- * functions so that they may block the input thread as appropriate to the
- * caller of this function. */
-void
-ps2LinuxRead(DevicePtr pDev, MOTIONPROC motion,
-             ENQUEUEPROC enqueue, CHECKPROC checkspecial, BLOCK block)
-{
-    GETPRIV;
-    unsigned char buf[3 * 200]; /* RATS: Use ok */
-    unsigned char *b;
-    int n;
-    int dx, dy, v[2];
-
-    while ((n = ps2LinuxReadBytes(priv->fd, buf, sizeof(buf), 3)) > 0) {
-        b = buf;
-        while (n >= 3) {
-            dx = b[1] - ((b[0] & 0x10) ? 256 : 0);
-            dy = -b[2] + ((b[0] & 0x20) ? 256 : 0);
-            v[0] = -dx;
-            v[1] = -dy;
-
-            motion(pDev, v, 0, 2, 1, block);
-            ps2LinuxButton(pDev, enqueue, (((b[0] & 4) ? button2 : 0)
-                                           | ((b[0] & 2) ? button3 : 0)
-                                           | ((b[0] & 1) ? button1 : 0)),
-                           block);
-            n -= 3;
-            b += 3;
-        }
-    }
-}
-
-/** Initialize \a pDev. */
-void
-ps2LinuxInit(DevicePtr pDev)
-{
-    GETPRIV;
-    const char *names[] = { "/dev/mouse", "/dev/psaux", NULL };
-    int i;
-
-    if (priv->fd >= 0)
-        return;
-
-    for (i = 0; names[i]; i++) {
-        if ((priv->fd = open(names[i], O_RDWR | O_NONBLOCK, 0)) >= 0)
-            break;
-    }
-    if (priv->fd < 0)
-        FATAL1("ps2LinuxInit: Cannot open mouse port (%s)\n", strerror(errno));
-}
-
-/** Turn \a pDev on (i.e., take input from \a pDev). */
-int
-ps2LinuxOn(DevicePtr pDev)
-{
-    GETPRIV;
-
-    if (priv->fd < 0)
-        ps2LinuxInit(pDev);
-    return priv->fd;
-}
-
-/** Turn \a pDev off (i.e., stop taking input from \a pDev). */
-void
-ps2LinuxOff(DevicePtr pDev)
-{
-    GETPRIV;
-
-    close(priv->fd);
-    priv->fd = -1;
-}
-
-static void
-ps2LinuxGetMap(DevicePtr pDev, unsigned char *map, int *nButtons)
-{
-    int i;
-
-    if (nButtons)
-        *nButtons = 3;
-    if (map)
-        for (i = 0; i <= *nButtons; i++)
-            map[i] = i;
-}
-
-/** Currently unused hook called prior to an VT switch. */
-void
-ps2LinuxVTPreSwitch(void *p)
-{
-}
-
-/** Currently unused hook called after returning from a VT switch. */
-void
-ps2LinuxVTPostSwitch(void *p)
-{
-}
-
-/** Create a private structure for use within this file. */
-void *
-ps2LinuxCreatePrivate(DeviceIntPtr pMouse)
-{
-    myPrivate *priv = calloc(1, sizeof(*priv));
-
-    priv->fd = -1;
-    priv->pMouse = pMouse;
-    return priv;
-}
-
-/** Destroy a private structure. */
-void
-ps2LinuxDestroyPrivate(void *priv)
-{
-    free(priv);
-}
-
-/** Fill the \a info structure with information needed to initialize \a
- * pDev. */
-void
-ps2LinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
-{
-    info->buttonClass = 1;
-    ps2LinuxGetMap(pDev, info->map, &info->numButtons);
-    info->valuatorClass = 1;
-    info->numRelAxes = 2;
-    info->minval[0] = 0;
-    info->maxval[0] = 0;
-    info->res[0] = 1;
-    info->minres[0] = 0;
-    info->maxres[0] = 1;
-    info->ptrFeedbackClass = 1;
-}
diff --git a/hw/dmx/input/lnx-ps2.h b/hw/dmx/input/lnx-ps2.h
deleted file mode 100644
index 339f353..0000000
--- a/hw/dmx/input/lnx-ps2.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2001 Red Hat Inc., Durham, North Carolina.
- *
- * 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 on 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 (including the
- * next paragraph) 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
- * NON-INFRINGEMENT.  IN NO EVENT SHALL RED HAT AND/OR THEIR SUPPLIERS
- * 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.
- */
-
-/*
- * Authors:
- *   Rickard E. (Rik) Faith <faith at redhat.com>
- *
- */
-
-/** \file
- * Interface to Linux PS/2 mouse driver.  \see lnx-ps2.c */
-
-#ifndef _LNX_PS2_H_
-#define _LNX_PS2_H_
-
-extern void *ps2LinuxCreatePrivate(DeviceIntPtr pMouse);
-extern void ps2LinuxDestroyPrivate(void *priv);
-extern void ps2LinuxRead(DevicePtr pDev,
-                         dmxMotionProcPtr motion,
-                         dmxEnqueueProcPtr enqueue,
-                         dmxCheckSpecialProcPtr checkspecial,
-                         DMXBlockType block);
-extern void ps2LinuxInit(DevicePtr pDev);
-extern void ps2LinuxGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info);
-extern int ps2LinuxOn(DevicePtr pDev);
-extern void ps2LinuxOff(DevicePtr pDev);
-extern void ps2LinuxCtrl(DevicePtr pDev, PtrCtrl * ctrl);
-extern void ps2LinuxVTPreSwitch(void *p);
-extern void ps2LinuxVTPostSwitch(void *p);
-
-#endif
diff --git a/hw/dmx/man/Xdmx.man b/hw/dmx/man/Xdmx.man
index 6b3feb1..4a25fdc 100644
--- a/hw/dmx/man/Xdmx.man
+++ b/hw/dmx/man/Xdmx.man
@@ -83,11 +83,8 @@ input events.
 .TP 4
 .B local
 The raw keyboard and pointer from the local computer are used.  A
-comma-separated list of driver names can be appended.  For example, to
-select the example Linux keyboard and PS/2 mouse driver use:
-.BR "-input local,kbd,ps2" .
-The following drivers have been implemented for Linux: kbd, ms (a
-two-button Microsoft mouse driver), ps2 (a PS/2 mouse driver), usb-mou
+comma-separated list of driver names can be appended.
+The following drivers have been implemented for Linux: usb-mou
 (a USB mouse driver), usb-kbd (a USB keyboard driver), and usb-oth (a
 USB non-keyboard, non-mouse driver).  Additional drivers may be
 implemented in the future.  Appropriate defaults will be used if no
@@ -603,7 +600,7 @@ Xdmx :1 -display d0:0 -display d1:0 -input :0 +xinerama
 .PP
 As above, except with core input from the local keyboard and mouse:
 .RS
-Xdmx :1 -display d0:0 -display d1:0 -input local,kbd,ps2 +xinerama
+Xdmx :1 -display d0:0 -display d1:0 -input local,usb-kbd,usb-mou +xinerama
 .RE
 Note that local input can be used under Linux while another X session is
 running on :0 (assuming the user can access the Linux console tty and


More information about the xorg-commit mailing list