xserver: Branch 'master' - 243 commits

Daniel Stone daniels at kemper.freedesktop.org
Thu Nov 2 05:13:39 EET 2006


 .gitignore                                 |    1 
 Makefile.am                                |    8 
 Xi/chgdctl.c                               |  146 +-
 Xi/chgkbd.c                                |  102 -
 Xi/chgkbd.h                                |    5 
 Xi/chgptr.c                                |  132 --
 Xi/chgptr.h                                |    5 
 Xi/exevents.c                              |   53 
 Xi/exglobals.h                             |    7 
 Xi/extinit.c                               |   46 
 Xi/getdctl.c                               |  128 +
 Xi/getdctl.h                               |   18 
 Xi/listdev.c                               |   15 
 Xi/selectev.c                              |   54 
 Xi/stubs.c                                 |   99 -
 config/Makefile.am                         |   10 
 config/config.c                            |  349 +++++
 config/dbus-api                            |   35 
 config/xorg-server.conf                    |   13 
 configure.ac                               |  286 ++--
 dix/Makefile.am                            |    1 
 dix/devices.c                              |  949 +++++++++-----
 dix/dispatch.c                             |    4 
 dix/dixfonts.c                             |   65 -
 dix/events.c                               |   75 -
 dix/getevents.c                            |  781 ++++++++++++
 dix/main.c                                 |   23 
 doc/c-extensions                           |   32 
 hw/darwin/darwinKeyboard.c                 |    2 
 hw/dmx/dmxinput.c                          |    2 
 hw/kdrive/Makefile.am                      |    8 
 hw/kdrive/ati/Makefile.am                  |   10 
 hw/kdrive/ati/ati_stub.c                   |   10 
 hw/kdrive/chips/Makefile.am                |    4 
 hw/kdrive/chips/chipsstub.c                |    3 
 hw/kdrive/ephyr/Makefile.am                |    5 
 hw/kdrive/ephyr/ephyr.c                    |  145 +-
 hw/kdrive/ephyr/ephyr.h                    |    9 
 hw/kdrive/ephyr/ephyrinit.c                |   19 
 hw/kdrive/ephyr/hostx.c                    |   32 
 hw/kdrive/ephyr/hostx.h                    |   17 
 hw/kdrive/ephyr/os.c                       |   30 
 hw/kdrive/epson/Makefile.am                |    2 
 hw/kdrive/epson/epson13806stub.c           |    6 
 hw/kdrive/fake/Makefile.am                 |    9 
 hw/kdrive/fake/fake.c                      |    6 
 hw/kdrive/fake/fake.h                      |    4 
 hw/kdrive/fake/fakeinit.c                  |   17 
 hw/kdrive/fake/kbd.c                       |   48 
 hw/kdrive/fake/mouse.c                     |   26 
 hw/kdrive/fbdev/Makefile.am                |   11 
 hw/kdrive/fbdev/fbdev.c                    |    6 
 hw/kdrive/fbdev/fbinit.c                   |   14 
 hw/kdrive/i810/Makefile.am                 |    2 
 hw/kdrive/i810/i810stub.c                  |    3 
 hw/kdrive/igs/igsstub.c                    |    3 
 hw/kdrive/itsy/kbd.c                       |   51 
 hw/kdrive/itsy/ts.c                        |    7 
 hw/kdrive/linux/Makefile.am                |   13 
 hw/kdrive/linux/bus.c                      |   77 -
 hw/kdrive/linux/evdev.c                    |  386 +++---
 hw/kdrive/linux/keyboard.c                 |  487 ++++++-
 hw/kdrive/linux/linux.c                    |   52 
 hw/kdrive/linux/mouse.c                    |  238 +--
 hw/kdrive/linux/ms.c                       |   61 
 hw/kdrive/linux/ps2.c                      |   84 -
 hw/kdrive/linux/ts.c                       |  138 --
 hw/kdrive/linux/tslib.c                    |  351 ++---
 hw/kdrive/mach64/Makefile.am               |    6 
 hw/kdrive/mach64/mach64stub.c              |    3 
 hw/kdrive/mga/Makefile.am                  |   11 
 hw/kdrive/mga/mgastub.c                    |    3 
 hw/kdrive/neomagic/Makefile.am             |    6 
 hw/kdrive/neomagic/neomagic.h              |    8 
 hw/kdrive/neomagic/neomagicstub.c          |    6 
 hw/kdrive/nvidia/Makefile.am               |    8 
 hw/kdrive/nvidia/nvidiastub.c              |    3 
 hw/kdrive/pcmcia/pcmciastub.c              |    3 
 hw/kdrive/pm2/Makefile.am                  |    5 
 hw/kdrive/pm2/pm2stub.c                    |    3 
 hw/kdrive/r128/Makefile.am                 |    5 
 hw/kdrive/r128/r128stub.c                  |    3 
 hw/kdrive/savage/s3stub.c                  |    8 
 hw/kdrive/sdl/Makefile.am                  |    5 
 hw/kdrive/sis300/Makefile.am               |    6 
 hw/kdrive/sis300/sis_stub.c                |    3 
 hw/kdrive/sis530/sisstub.c                 |    3 
 hw/kdrive/smi/Makefile.am                  |    6 
 hw/kdrive/smi/smistub.c                    |    3 
 hw/kdrive/src/Makefile.am                  |    3 
 hw/kdrive/src/kdrive.c                     |  190 +-
 hw/kdrive/src/kdrive.h                     |  246 ++-
 hw/kdrive/src/kinfo.c                      |   81 -
 hw/kdrive/src/kinput.c                     | 1861 ++++++++++++++++++++---------
 hw/kdrive/src/kkeymap.c                    |   66 -
 hw/kdrive/src/kloadmap.c                   |    1 
 hw/kdrive/trident/tridentstub.c            |    3 
 hw/kdrive/trio/s3stub.c                    |    3 
 hw/kdrive/vesa/Makefile.am                 |    4 
 hw/kdrive/vesa/vesa.c                      |    8 
 hw/kdrive/vesa/vesainit.c                  |   11 
 hw/kdrive/via/Makefile.am                  |    9 
 hw/kdrive/via/viastub.c                    |    3 
 hw/kdrive/vxworks/vxkbd.c                  |    4 
 hw/kdrive/vxworks/vxworks.c                |   33 
 hw/vfb/InitInput.c                         |   13 
 hw/xfree86/common/Makefile.am              |   12 
 hw/xfree86/common/xf86Config.c             |  348 -----
 hw/xfree86/common/xf86Configure.c          |    6 
 hw/xfree86/common/xf86Cursor.c             |    9 
 hw/xfree86/common/xf86DGA.c                |   48 
 hw/xfree86/common/xf86Debug.c              |    2 
 hw/xfree86/common/xf86Events.c             |  796 +-----------
 hw/xfree86/common/xf86Globals.c            |   39 
 hw/xfree86/common/xf86Helper.c             |   28 
 hw/xfree86/common/xf86InPriv.h             |    3 
 hw/xfree86/common/xf86Init.c               |  118 -
 hw/xfree86/common/xf86Io.c                 |  470 -------
 hw/xfree86/common/xf86Kbd.c                |  394 ------
 hw/xfree86/common/xf86KbdBSD.c             | 1265 -------------------
 hw/xfree86/common/xf86KbdLnx.c             |  650 ----------
 hw/xfree86/common/xf86KbdMach.c            |  316 ----
 hw/xfree86/common/xf86MiscExt.c            |   78 -
 hw/xfree86/common/xf86Module.h             |    2 
 hw/xfree86/common/xf86Option.c             |    4 
 hw/xfree86/common/xf86Priv.h               |   17 
 hw/xfree86/common/xf86Privstr.h            |   49 
 hw/xfree86/common/xf86Versions.c           |    3 
 hw/xfree86/common/xf86Xinput.c             | 1423 ++++------------------
 hw/xfree86/common/xf86Xinput.h             |   41 
 hw/xfree86/loader/misym.c                  |    2 
 hw/xfree86/loader/xf86sym.c                |   11 
 hw/xfree86/os-support/Makefile.am          |    5 
 hw/xfree86/os-support/bsd/Makefile.am      |    7 
 hw/xfree86/os-support/bsd/bsd_KbdMap.c     | 1087 ----------------
 hw/xfree86/os-support/bsd/bsd_bell.c       |   81 +
 hw/xfree86/os-support/bsd/bsd_io.c         |  293 ----
 hw/xfree86/os-support/bsd/bsd_kbd.c        |  572 --------
 hw/xfree86/os-support/bsd/bsd_kbd.h        |    4 
 hw/xfree86/os-support/linux/Makefile.am    |   17 
 hw/xfree86/os-support/linux/lnx_KbdMap.c   |  606 ---------
 hw/xfree86/os-support/linux/lnx_bell.c     |   43 
 hw/xfree86/os-support/linux/lnx_io.c       |  246 ---
 hw/xfree86/os-support/linux/lnx_kbd.c      |  530 --------
 hw/xfree86/os-support/linux/lnx_kbd.h      |    4 
 hw/xfree86/os-support/lynxos/Makefile.am   |    1 
 hw/xfree86/os-support/lynxos/lynx_io.c     |  165 --
 hw/xfree86/os-support/sco/Makefile.am      |    4 
 hw/xfree86/os-support/sco/sco_KbdMap.c     |  304 ----
 hw/xfree86/os-support/sco/sco_io.c         |  268 ----
 hw/xfree86/os-support/sco/sco_kbd.c        |  530 --------
 hw/xfree86/os-support/sco/sco_kbd.h        |   20 
 hw/xfree86/os-support/shared/at_scancode.c |  131 --
 hw/xfree86/os-support/shared/kbd.c         |   38 
 hw/xfree86/os-support/shared/std_kbdEv.c   |   49 
 hw/xfree86/os-support/shared/sysv_kbd.c    |  105 -
 hw/xfree86/os-support/solaris/Makefile.am  |    8 
 hw/xfree86/os-support/solaris/sun_bell.c   |  184 ++
 hw/xfree86/os-support/solaris/sun_io.c     |  159 --
 hw/xfree86/os-support/solaris/sun_kbd.c    |  660 ----------
 hw/xfree86/os-support/solaris/sun_kbd.h    |   72 -
 hw/xfree86/os-support/solaris/sun_kbdEv.c  |  854 -------------
 hw/xfree86/os-support/sysv/Makefile.am     |    2 
 hw/xfree86/os-support/sysv/sysv_io.c       |   77 -
 hw/xfree86/os-support/sysv/sysv_mouse.c    |    3 
 hw/xfree86/os-support/sysv/xqueue.c        |  536 --------
 hw/xfree86/os-support/sysv/xqueue.h        |   12 
 hw/xfree86/os-support/usl/Makefile.am      |    8 
 hw/xfree86/os-support/usl/usl_KbdMap.c     |  304 ----
 hw/xfree86/os-support/usl/usl_io.c         |  171 --
 hw/xfree86/os-support/usl/usl_kbd.c        |  455 -------
 hw/xfree86/os-support/usl/usl_kbd.h        |   14 
 hw/xfree86/os-support/usl/usl_mouse.c      |    7 
 hw/xfree86/os-support/usl/usl_xqueue.c     |  360 -----
 hw/xfree86/os-support/usl/usl_xqueue.h     |    9 
 hw/xfree86/os-support/xf86OSKbd.h          |  132 --
 hw/xfree86/os-support/xf86_OSlib.h         |    9 
 hw/xfree86/os-support/xf86_OSproc.h        |   19 
 hw/xfree86/parser/Input.c                  |    5 
 hw/xfree86/parser/Keyboard.c               |  308 ----
 hw/xfree86/parser/Makefile.am              |    1 
 hw/xfree86/parser/configProcs.h            |    2 
 hw/xfree86/parser/read.c                   |    7 
 hw/xfree86/utils/xorgcfg/interface.c       |    3 
 hw/xfree86/utils/xorgcfg/keyboard-cfg.c    |    7 
 hw/xfree86/utils/xorgcfg/mouse-cfg.c       |    3 
 hw/xfree86/utils/xorgcfg/text-mode.c       |   14 
 hw/xfree86/utils/xorgconfig/xorgconfig.c   |   21 
 hw/xfree86/xorgconf.cpp                    |   14 
 hw/xgl/egl/module/xeglmodule.c             |    2 
 hw/xgl/egl/xegl.c                          |    2 
 hw/xgl/egl/xegl.h                          |    2 
 hw/xgl/egl/xeglinit.c                      |    2 
 hw/xgl/glx/module/xglxmodule.c             |    2 
 hw/xgl/glx/xglx.c                          |    2 
 hw/xgl/glx/xglx.h                          |    2 
 hw/xgl/glx/xglxinit.c                      |    2 
 hw/xgl/xglinit.c                           |    2 
 hw/xnest/Args.c                            |   15 
 hw/xnest/Events.c                          |   65 -
 hw/xnest/Init.c                            |    9 
 hw/xnest/Keyboard.c                        |    8 
 hw/xnest/Pointer.c                         |    4 
 hw/xprint/ddxInit.c                        |    2 
 hw/xwin/InitInput.c                        |    2 
 include/Makefile.am                        |    1 
 include/XIstubs.h                          |   12 
 include/config.h                           |   31 
 include/dix-config.h.in                    |   12 
 include/exevents.h                         |   13 
 include/extinit.h                          |    6 
 include/input.h                            |   88 +
 include/inputstr.h                         |   73 -
 include/kdrive-config.h.in                 |    6 
 include/os.h                               |   10 
 mi/mi.h                                    |    4 
 mi/mieq.c                                  |  201 +--
 mi/miinitext.c                             |    4 
 mi/mipointer.c                             |  198 +--
 mi/mipointer.h                             |   65 -
 mi/mipointrst.h                            |   10 
 os/WaitFor.c                               |   20 
 os/connection.c                            |   19 
 os/utils.c                                 |    2 
 xkb/XKBAlloc.c                             |    5 
 xkb/ddxBeep.c                              |   32 
 xkb/ddxLoad.c                              |   24 
 xkb/xkb.c                                  |  500 ++++---
 xkb/xkb.h                                  |    5 
 xkb/xkbAccessX.c                           |   10 
 xkb/xkbLEDs.c                              |   24 
 xkb/xkbUtils.c                             | 1154 +++++++++++++++++
 232 files changed, 8478 insertions(+), 18344 deletions(-)

New commits:
diff-tree 1ecd45fb8e4250fb51daa2bdf1a960af0f8b53fb (from 01afa533aa872d1a101a41153f95d800e68fea3e)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 04:51:03 2006 +0200

    Makefile.am: add config to DIST_SUBDIRS as well

diff --git a/Makefile.am b/Makefile.am
index eebdd0a..f35539e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -91,6 +91,7 @@ DIST_SUBDIRS = \
 	composite \
 	GL \
 	exa \
+	config \
 	hw
 
 # gross hack
diff-tree 01afa533aa872d1a101a41153f95d800e68fea3e (from 57c1409151cb1f6e0e528fb92ebda58f86f12c1a)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 04:32:37 2006 +0200

    xfree86/os-support: axe more unused files

diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am
index 0301a74..9e09fb6 100644
--- a/hw/xfree86/os-support/linux/Makefile.am
+++ b/hw/xfree86/os-support/linux/Makefile.am
@@ -47,5 +47,4 @@ LNX_EXTRA_SOURCES = \
 EXTRA_DIST = \
 	$(LNX_EXTRA_SOURCES) \
 	lnx.h \
-	lnx_kbd.h \
 	$(srcdir)/../shared/xf86Axp.h
diff --git a/hw/xfree86/os-support/lynxos/Makefile.am b/hw/xfree86/os-support/lynxos/Makefile.am
index 0bb514b..4085c49 100644
--- a/hw/xfree86/os-support/lynxos/Makefile.am
+++ b/hw/xfree86/os-support/lynxos/Makefile.am
@@ -1,6 +1,5 @@
 EXTRA_DIST = \
 	lynx_init.c \
-	lynx_io.c \
 	lynx_mmap.c \
 	lynx_mouse.c \
 	lynx_noinline.c \
diff --git a/hw/xfree86/os-support/sysv/Makefile.am b/hw/xfree86/os-support/sysv/Makefile.am
index 85aa764..f9d2f23 100644
--- a/hw/xfree86/os-support/sysv/Makefile.am
+++ b/hw/xfree86/os-support/sysv/Makefile.am
@@ -1 +1 @@
-EXTRA_DIST = sysv_init.c sysv_io.c sysv_mouse.c sysv_video.c
+EXTRA_DIST = sysv_init.c sysv_mouse.c sysv_video.c
diff-tree 57c1409151cb1f6e0e528fb92ebda58f86f12c1a (from de5a4c63747a417cdece919f4fb5a4004a3ee7bb)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 04:21:06 2006 +0200

    xfree86/os-support: remove unused file from dist

diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am
index 131c495..b07e3c9 100644
--- a/hw/xfree86/os-support/Makefile.am
+++ b/hw/xfree86/os-support/Makefile.am
@@ -27,5 +27,4 @@ DISTCLEANFILES = xorgos.c
 # FIXME: These don't seem to be used anywhere
 EXTRA_DIST += \
 	shared/bios_devmem.c \
-	shared/inout.S \
-	shared/kbd.c
+	shared/inout.S
diff-tree de5a4c63747a417cdece919f4fb5a4004a3ee7bb (from 1d65429a9e03871969552d0c31b022546cc46b12)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 04:18:33 2006 +0200

    xkb: note that we allow full xi interaction
    We now allow maps to be set (etc) on different keyboards, so stop putting
    XkbXI_KeyboardsMask in unsupported.

diff --git a/xkb/xkb.c b/xkb/xkb.c
index bceaf49..2c97e05 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5720,7 +5720,6 @@ char *			str;
 	wanted&= ~XkbXI_ButtonActionsMask;
     if ((!dev->kbdfeed)&&(!dev->leds))
 	wanted&= ~XkbXI_IndicatorsMask;
-    wanted&= ~XkbXI_KeyboardsMask;
 
     nameLen= XkbSizeCountedString(dev->name);
     bzero((char *)&rep,SIZEOF(xkbGetDeviceInfoReply));
@@ -5729,8 +5728,8 @@ char *			str;
     rep.sequenceNumber = client->sequence;
     rep.length = nameLen/4;
     rep.present = wanted;
-    rep.supported = XkbXI_AllDeviceFeaturesMask&(~XkbXI_KeyboardsMask);
-    rep.unsupported = XkbXI_KeyboardsMask;
+    rep.supported = XkbXI_AllDeviceFeaturesMask;
+    rep.unsupported = 0;
     rep.firstBtnWanted = rep.nBtnsWanted = 0;
     rep.firstBtnRtrn = rep.nBtnsRtrn = 0;
     if (dev->button)
@@ -6044,7 +6043,7 @@ xkbExtensionDeviceNotify ed;
     change= stuff->change;
 
     CHK_ANY_DEVICE(dev,stuff->deviceSpec);
-    CHK_MASK_LEGAL(0x01,change,(XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask)));
+    CHK_MASK_LEGAL(0x01,change,XkbXI_AllFeaturesMask);
 
     wire= (char *)&stuff[1];
     if (change&XkbXI_ButtonActionsMask) {
diff --git a/xkb/xkbLEDs.c b/xkb/xkbLEDs.c
index ec8e7b1..e94e0bf 100644
--- a/xkb/xkbLEDs.c
+++ b/xkb/xkbLEDs.c
@@ -675,13 +675,13 @@ xkbExtensionDeviceNotify	my_ed;
 	changes->names.changed_indicators|= changed_names;
     }
 
-    ed->reason|=	(XkbXI_IndicatorNamesMask&(~XkbXI_KeyboardsMask));
+    ed->reason|=	XkbXI_IndicatorNamesMask;
     ed->ledClass= 	sli->class;
     ed->ledID=		sli->id;
     ed->ledsDefined=	sli->namesPresent|sli->mapsPresent;
     ed->ledState=	sli->effectiveState;
-    ed->unsupported=	XkbXI_KeyboardsMask;
-    ed->supported=	XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask);
+    ed->unsupported=	0;
+    ed->supported=	XkbXI_AllFeaturesMask;
 
     if (changes!=&my_changes)	changes= NULL;
     if (ed!=&my_ed)		ed= NULL;
@@ -753,13 +753,13 @@ xkbExtensionDeviceNotify	my_ed;
 
     XkbCheckIndicatorMaps(dev,sli,changed_maps);
 
-    ed->reason|=	(XkbXI_IndicatorMapsMask&(~XkbXI_KeyboardsMask));
+    ed->reason|=	XkbXI_IndicatorMapsMask;
     ed->ledClass= 	sli->class;
     ed->ledID=		sli->id;
     ed->ledsDefined=	sli->namesPresent|sli->mapsPresent;
     ed->ledState=	sli->effectiveState;
-    ed->unsupported|=	XkbXI_KeyboardsMask&XkbXI_IndicatorMapsMask;
-    ed->supported=	XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask);
+    ed->unsupported|=	XkbXI_IndicatorMapsMask;
+    ed->supported=	XkbXI_AllFeaturesMask;
 
     XkbUpdateLedAutoState(dev,sli,changed_maps,ed,changes,cause);
 
@@ -834,13 +834,13 @@ Bool				kb_changed;
     if ((kbd==dev)&&(sli->flags&XkbSLI_IsDefault))
 	changes->indicators.state_changes|= affected;
     if (affected) {
-	ed->reason|=		(XkbXI_IndicatorStateMask&(~XkbXI_KeyboardsMask));
+	ed->reason|=		XkbXI_IndicatorStateMask;
 	ed->ledClass= 		sli->class;
 	ed->ledID=		sli->id;
 	ed->ledsDefined=	sli->namesPresent|sli->mapsPresent;
 	ed->ledState=		sli->effectiveState;
-	ed->unsupported|=	XkbXI_KeyboardsMask&XkbXI_IndicatorStateMask;
-	ed->supported=		XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask);
+	ed->unsupported|=	XkbXI_IndicatorStateMask;
+	ed->supported=		XkbXI_AllFeaturesMask;
     }
 
     if (kb_changed) {
@@ -918,13 +918,13 @@ unsigned			oldState;
 	changes->indicators.state_changes|= affected;
     }
 
-    ed->reason|=	(XkbXI_IndicatorStateMask&(~XkbXI_KeyboardsMask));
+    ed->reason|=	XkbXI_IndicatorStateMask;
     ed->ledClass= 	sli->class;
     ed->ledID=		sli->id;
     ed->ledsDefined=	sli->namesPresent|sli->mapsPresent;
     ed->ledState=	sli->effectiveState;
-    ed->unsupported|=	XkbXI_KeyboardsMask&XkbXI_IndicatorStateMask;
-    ed->supported=	XkbXI_AllFeaturesMask&(~XkbXI_KeyboardsMask);
+    ed->unsupported|=	XkbXI_IndicatorStateMask;
+    ed->supported=	XkbXI_AllFeaturesMask;
 
     if (changes!=&my_changes)	changes= NULL;
     if (ed!=&my_ed)		ed= NULL;
diff-tree 1d65429a9e03871969552d0c31b022546cc46b12 (from 64139c1950ea825c0a0124abc5f88499e91f797f)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 04:12:55 2006 +0200

    xfree86: don't attempt to enable and disable non-DIX devices
    Don't try to enable and disable devices with no entry in the DIX, such as
    the evdev brain.

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 4a9f369..6ce9319 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -887,7 +887,8 @@ xf86VTSwitch()
      */
     pInfo = xf86InputDevs;
     while (pInfo) {
-      DisableDevice(pInfo->dev);
+      if (pInfo->dev)
+          DisableDevice(pInfo->dev);
       pInfo = pInfo->next;
     }
 #endif /* !__UNIXOS2__ */
@@ -927,8 +928,10 @@ xf86VTSwitch()
 #if !defined(__UNIXOS2__)
       pInfo = xf86InputDevs;
       while (pInfo) {
-        xf86ReleaseKeys(pInfo->dev);
-	EnableDevice(pInfo->dev);
+        if (pInfo->dev) {
+            xf86ReleaseKeys(pInfo->dev);
+            EnableDevice(pInfo->dev);
+        }
 	pInfo = pInfo->next;
       }
       /* XXX HACK */
@@ -991,8 +994,10 @@ xf86VTSwitch()
 #if !defined(__UNIXOS2__)
     pInfo = xf86InputDevs;
     while (pInfo) {
-      xf86ReleaseKeys(pInfo->dev);
-      EnableDevice(pInfo->dev);
+      if (pInfo->dev) {
+          xf86ReleaseKeys(pInfo->dev);
+          EnableDevice(pInfo->dev);
+      }
       pInfo = pInfo->next;
     }
     /* XXX HACK */
diff-tree 64139c1950ea825c0a0124abc5f88499e91f797f (from 18c246a13b887b865de6a17e6cd1c259b9bc383d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 03:22:09 2006 +0200

    bump to 1.2.99.0

diff --git a/configure.ac b/configure.ac
index 9322a2d..473ff9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,7 +25,7 @@ dnl Process this file with autoconf to c
 AC_PREREQ(2.57)
 dnl This is the not the Xorg version number, it's the server version number.
 dnl Yes, that's weird.
-AC_INIT([xorg-server], 1.1.99.3, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+AC_INIT([xorg-server], 1.2.99.0, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
diff-tree 18c246a13b887b865de6a17e6cd1c259b9bc383d (from parents)
Merge: 794f2e7291ccb4e48f9fbfc8f08302e3aac0f79f 4843d823f4d38d8bd468ce3a8feddbff229ed416
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 03:21:37 2006 +0200

    Merge branch 'input-hotplug'

diff-tree 4843d823f4d38d8bd468ce3a8feddbff229ed416 (from parents)
Merge: ba9f5138fc32a7a7b97bcf941bc92751b7c6c2c0 a7b944f0d96c3e0e15e75378a04def1ac96089fb
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 03:18:13 2006 +0200

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree ba9f5138fc32a7a7b97bcf941bc92751b7c6c2c0 (from be291a6d9764cf29a7d9a8114d47d9f41ce856e9)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 03:16:10 2006 +0200

    xfree86: allow starting with no input devices
    Add a server flag (AllowEmptyInput), which will inhibit adding the
    standard keyboard and mouse drivers, if there are no input devices in the
    config file.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 6777f43..4138eb1 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -747,7 +747,8 @@ typedef enum {
     FLAG_HANDLE_SPECIAL_KEYS,
     FLAG_RANDR,
     FLAG_AIGLX,
-    FLAG_IGNORE_ABI
+    FLAG_IGNORE_ABI,
+    FLAG_ALLOW_EMPTY_INPUT,
 } FlagValues;
    
 static OptionInfoRec FlagOptions[] = {
@@ -819,6 +820,8 @@ static OptionInfoRec FlagOptions[] = {
 	{0}, FALSE },
   { FLAG_AIGLX,			"AIGLX",			OPTV_BOOLEAN,
 	{0}, FALSE },
+  { FLAG_ALLOW_EMPTY_INPUT,     "AllowEmptyInput",              OPTV_BOOLEAN,
+        {0}, FALSE },
   { FLAG_IGNORE_ABI,			"IgnoreABI",			OPTV_BOOLEAN,
 	{0}, FALSE },
   { -1,				NULL,				OPTV_NONE,
@@ -1016,6 +1019,10 @@ configServerFlags(XF86ConfFlagsPtr flags
 	xf86Info.aiglxFrom = X_CONFIG;
     }
 
+    xf86Info.allowEmptyInput = FALSE;
+    if (xf86GetOptValBool(FlagOptions, FLAG_ALLOW_EMPTY_INPUT, &value))
+        xf86Info.allowEmptyInput = TRUE;
+
 /* Make sure that timers don't overflow CARD32's after multiplying */
 #define MAX_TIME_IN_MIN (0x7fffffff / MILLI_PER_MIN)
 
@@ -1657,8 +1664,6 @@ configLayout(serverLayoutPtr servlayoutp
     servlayoutp->options = conf_layout->lay_option_lst;
     from = X_DEFAULT;
 
-    if (!checkCoreInputDevices(servlayoutp, FALSE))
-	return FALSE;
     return TRUE;
 }
 
@@ -1717,7 +1722,7 @@ configImpliedLayout(serverLayoutPtr serv
     indp = xnfalloc(sizeof(IDevRec));
     indp->identifier = NULL;
     servlayoutp->inputs = indp;
-    if (!checkCoreInputDevices(servlayoutp, TRUE))
+    if (!xf86Info.allowEmptyInput && checkCoreInputDevices(servlayoutp, TRUE))
 	return FALSE;
     
     return TRUE;
@@ -2303,6 +2308,12 @@ addDefaultModes(MonPtr monitorp)
     return TRUE;
 }
 
+static void
+checkInput(serverLayoutPtr layout) {
+    if (!xf86Info.allowEmptyInput)
+        checkCoreInputDevices(layout, FALSE);
+}
+
 /*
  * load the config file and fill the global data structure
  */
@@ -2424,6 +2435,8 @@ xf86HandleConfigFile(Bool autoconfig)
              return CONFIG_PARSE_ERROR;
     }
 
+    checkInput(&xf86ConfigLayout);
+
     /*
      * Handle some command line options that can override some of the
      * ServerFlags settings.
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index 7dfcfea..659e566 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -133,6 +133,9 @@ typedef struct {
 	Bool		allowClosedown;
 	ServerGrabInfoRec server;
     } grabInfo;
+
+    Bool        allowEmptyInput;  /* Allow the server to start with no input
+                                   * devices. */
 } xf86InfoRec, *xf86InfoPtr;
 
 #ifdef DPMSExtension
diff-tree be291a6d9764cf29a7d9a8114d47d9f41ce856e9 (from parents)
Merge: a2d6242106bb3a440faa9cad157e0120dbfa7b6e 6fdfd9dad91d7b7aa292f8c4d268dd27c34de8d3
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 03:15:25 2006 +0200

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff --cc configure.ac
index 8935aa0,058759d..9322a2d
@@@ -889,32 -874,9 +891,32 @@@
  PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
  
  XSERVER_CFLAGS="${XSERVERCFLAGS_CFLAGS}"
- XSERVER_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} -lm"
+ XSERVER_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS}"
  AC_SUBST([SYS_LIBS])
  
 +# The Xorg binary needs to export symbols so that they can be used from modules
 +# Some platforms require extra flags to do this.   gcc should set these flags
 +# when -rdynamic is passed to it, other compilers/linkers may need to be added
 +# here.
 +if test "x$GCC" = "xyes"; then
 +       GCC_WARNINGS1="-Wall -Wpointer-arith -Wstrict-prototypes"
 +       GCC_WARNINGS2="-Wmissing-prototypes -Wmissing-declarations"
 +       GCC_WARNINGS3="-Wnested-externs -fno-strict-aliasing"
 +       GCC_WARNINGS="$GCC_WARNINGS1 $GCC_WARNINGS2 $GCC_WARNINGS3"
 +       if test "x$WERROR" = "xyes"; then
 +               GCC_WARNINGS="${GCC_WARNINGS} -Werror"
 +       fi
 +       XSERVER_CFLAGS="$GCC_WARNINGS $XSERVER_CFLAGS"
 +
 +       LD_EXPORT_SYMBOLS_FLAG="-rdynamic"
 +fi
 +case $host_os in
 +       openbsd*)
 +       LD_EXPORT_SYMBOLS_FLAG="-Wl,--export-dynamic"
 +       ;;
 +esac
 +AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])
 +
  AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes],
                 [AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
                               [have_clock_gettime=no])])
@@@ -1044,7 -1007,7 +1047,7 @@@
  AM_CONDITIONAL(XNEST, [test "x$XNEST" = xyes])
  
  if test "x$XNEST" = xyes; then
- 	XNEST_LIBS="$XSERVER_LIBS $FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB"
 -	XNEST_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB $LIBS"
++	XNEST_LIBS="$XSERVER_LIBS $FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB $LIBS"
  	AC_SUBST([XNEST_LIBS])
  fi
  
@@@ -1394,7 -1370,7 +1397,7 @@@
  if test "x$XPRINT" = xyes; then
  	PKG_CHECK_MODULES([XPRINT], [printproto x11 xfont $XDMCP_MODULES xau])
  	XPRINT_EXTENSIONS="$XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $COMPOSITE_LIB $RANDR_LIB $XI_LIB $FIXES_LIB $DAMAGE_LIB $XI_LIB $GLX_LIBS"
- 	XPRINT_LIBS="$XPRINT_LIBS $DIX_LIB $CONFIG_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MI_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB $OS_LIB"
 -	XPRINT_LIBS="$XPRINT_LIBS $DIX_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MI_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB $OS_LIB $LIBS"
++	XPRINT_LIBS="$XPRINT_LIBS $DIX_LIB $CONFIG_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MI_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB $OS_LIB $LIBS"
  	AC_SUBST([XPRINT_CFLAGS])
  	AC_SUBST([XPRINT_LIBS])
  
diff-tree a2d6242106bb3a440faa9cad157e0120dbfa7b6e (from d9a5e3e964b6c91fbca88b50674fce9660b972a4)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 00:46:33 2006 +0200

    kdrive:remove Change{Keyboard,Pointer}Device
    This was removed in the DIX, so just axe it.

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index be18586..83da67f 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2269,21 +2269,6 @@ ProcessInputEvents ()
     KdCheckLock ();
 }
 
-/* We don't want to allow people to change the core devices, because the DIX
- * does magical repeating goodness for us. */
-int
-ChangeKeyboardDevice(DeviceIntPtr pOldDev, DeviceIntPtr pDev)
-{
-    return BadDevice;
-}
-
-int
-ChangePointerDevice(DeviceIntPtr pOldDev, DeviceIntPtr pDev, unsigned char x,
-                    unsigned char y)
-{
-    return BadDevice;
-}
-
 /* FIXME use XSECURITY to work out whether the client should be allowed to
  * open and close. */
 void
diff-tree d9a5e3e964b6c91fbca88b50674fce9660b972a4 (from d7d931abe01a8cf555b027f2bcfcccd5e9053e52)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Nov 2 00:45:23 2006 +0200

    XkbCopyKeymap: be more careful with levels, allocate compat/geom
    Take various extra precautions with copying levels across (thanks Chris
    Lee for a gdb session), including allocating when we don't already have a
    coherent map.
    Only free type components if they're present.
    Allocate geometry and compat components if we don't already have them in
    the dest map.

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 0c1ac9c..627ab20 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1082,52 +1082,61 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
             stype = src->map->types;
             dtype = dst->map->types;
             for (i = 0; i < src->map->num_types; i++, dtype++, stype++) {
-                if (stype->num_levels != dtype->num_levels) {
-                    if (dtype->level_names)
+                if (stype->num_levels) {
+                    if (stype->num_levels != dtype->num_levels &&
+                        dtype->num_levels && dtype->level_names) {
                         tmp = xrealloc(dtype->level_names,
                                        stype->num_levels * sizeof(Atom));
-                    else
+                        if (!tmp)
+                            continue;
+                        dtype->level_names = tmp;
+                    }
+                    else if (!dtype->num_levels || !dtype->level_names) {
                         tmp = xalloc(stype->num_levels * sizeof(Atom));
-                    if (!tmp)
-                        continue; /* don't return FALSE here, try to whack
-                                     all the pointers we can, so we don't
-                                     double-free when going down. */
-                    dtype->level_names = tmp;
+                        if (!tmp)
+                            continue;
+                        dtype->level_names = tmp;
+                    }
                     dtype->num_levels = stype->num_levels;
+                    memcpy(dtype->level_names, stype->level_names,
+                           stype->num_levels * sizeof(Atom));
+                }
+                else {
+                    if (dtype->num_levels && dtype->level_names)
+                        xfree(dtype->level_names);
+                    dtype->num_levels = 0;
+                    dtype->level_names = NULL;
                 }
-                memcpy(dtype->level_names, stype->level_names,
-                       stype->num_levels * sizeof(Atom));
 
                 dtype->name = stype->name;
                 memcpy(&dtype->mods, &stype->mods, sizeof(XkbModsRec));
 
-                if (stype->map) {
-                    if (dtype->map) {
-                        if (stype->map_count != dtype->map_count) {
+                if (stype->map_count) {
+                    if (stype->map) {
+                        if (stype->map_count != dtype->map_count &&
+                            dtype->map_count && dtype->map) {
                             tmp = xrealloc(dtype->map,
                                            stype->map_count *
                                              sizeof(XkbKTMapEntryRec));
                             if (!tmp)
                                 return FALSE;
                             dtype->map = tmp;
+                       }
+                        else if (!dtype->map_count || !dtype->map) {
+                            tmp = xalloc(stype->map_count *
+                                           sizeof(XkbKTMapEntryRec));
+                            if (!tmp)
+                                return FALSE;
+                            dtype->map = tmp;
                         }
-                    }
-                    else {
-                        tmp = xalloc(stype->map_count *
-                                       sizeof(XkbKTMapEntryRec));
-                        if (!tmp)
-                            return FALSE;
-                        dtype->map = tmp;
-                    }
 
-                    dtype->map_count = stype->map_count;
-                    memcpy(dtype->map, stype->map, stype->map_count *
-                                               sizeof(XkbKTMapEntryRec));
-                }
+                        memcpy(dtype->map, stype->map,
+                               stype->map_count * sizeof(XkbKTMapEntryRec));
+                    }
 
-                if (stype->preserve) {
-                    if (dtype->preserve) {
-                        if (stype->map_count != dtype->map_count) {
+                    if (stype->preserve) {
+                        if (stype->map_count != dtype->map_count &&
+                            dtype->map_count && dtype->preserve) {
                             tmp = xrealloc(dtype->preserve,
                                            stype->map_count *
                                              sizeof(XkbModsRec));
@@ -1135,22 +1144,30 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                                 return FALSE;
                             dtype->preserve = tmp;
                         }
-                    }
-                    else {
-                        tmp = xalloc(stype->map_count * sizeof(XkbModsRec));
-                        if (!tmp)
-                            return FALSE;
-                        dtype->preserve = tmp;
+                        else if (!dtype->preserve || !dtype->map_count) {
+                            tmp = xalloc(stype->map_count *
+                                         sizeof(XkbModsRec));
+                            if (!tmp)
+                                return FALSE;
+                            dtype->preserve = tmp;
+                        }
+
+                        memcpy(dtype->preserve, stype->preserve,
+                               stype->map_count * sizeof(XkbModsRec));
                     }
 
-                    memcpy(dtype->preserve, stype->preserve,
-                           stype->map_count * sizeof(XkbModsRec));
+                    dtype->map_count = stype->map_count;
                 }
                 else {
-                    if (dtype->preserve) {
-                        xfree(dtype->preserve);
-                        dtype->preserve = NULL;
+                    if (dtype->map_count) {
+                        if (dtype->map)
+                            xfree(dtype->map);
+                        if (dtype->preserve)
+                            xfree(dtype->preserve);
+                        dtype->map_count = 0;
                     }
+                    dtype->map = NULL;
+                    dtype->preserve = NULL;
                 }
             }
         }
@@ -1160,9 +1177,9 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                      i++, dtype++) {
                     if (dtype->level_names)
                         xfree(dtype->level_names);
-                    if (dtype->map)
+                    if (dtype->map && dtype->map_count)
                         xfree(dtype->map);
-                    if (dtype->preserve)
+                    if (dtype->preserve && dtype->preserve)
                         xfree(dtype->preserve);
                 }
                 xfree(dst->map->types);
@@ -1451,6 +1468,12 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
 
     /* compat */
     if (src->compat) {
+        if (!dst->compat) {
+            dst->compat = xcalloc(1, sizeof(XkbCompatMapRec));
+            if (!dst->compat)
+                return FALSE;
+        }
+
         if (src->compat->sym_interpret) {
             if (src->compat->size_si != dst->compat->size_si) {
                 if (dst->compat->sym_interpret)
@@ -1486,6 +1509,12 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
 
     /* geometry */
     if (src->geom) {
+        if (!dst->geom) {
+            dst->geom = xcalloc(sizeof(XkbGeometryRec), 1);
+            if (!dst->geom)
+                return FALSE;
+        }
+
         /* properties */
         if (src->geom->num_properties) {
             if (src->geom->num_properties != dst->geom->sz_properties) {
diff-tree d7d931abe01a8cf555b027f2bcfcccd5e9053e52 (from 81728558a044fdde0e1d63da7b6314755f77296e)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Nov 1 23:48:58 2006 +0200

    configure.ac: remove check for rate/period
    Keyboard stuff is now handled in the kbd driver.

diff --git a/configure.ac b/configure.ac
index aa6c607..8935aa0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1194,25 +1194,6 @@ dnl has it in libc), or if libdl is need
 		  *)
 			;;
 		esac
-
-		# check whether struct kbd_repeat has the 'period' field.
-		# on kernels < 2.5.42 it's called 'rate' instead.
-		AC_TRY_COMPILE([
-#include <linux/kd.h>
-#ifdef __sparc__
-#include <asm/param.h>
-#include <asm/kbio.h>
-#endif
-],[
-int main () { 
-	struct kbd_repeat k;
-	k.period = 0;
-	return 0;
-}],
-		[period_field="period"],
-		[period_field="rate"])
-		AC_DEFINE_UNQUOTED(LNX_KBD_PERIOD_NAME, [$period_field],
-		                   [Name of the period field in struct kbd_repeat])
 		;;
 	  freebsd* | kfreebsd*-gnu)
 	  	XORG_OS="freebsd"
diff-tree 81728558a044fdde0e1d63da7b6314755f77296e (from 3df454719f9cbf6a046cb7458019ec621b3b42ee)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Nov 1 23:10:26 2006 +0200

    input: add non-keyboard bell ringing function
    Add a generic 'ring the bell' function (console bell on Linux and BSD,
    /dev/audio on Solaris), and add DDX functions for this.  Make this the
    core keyboard's bell.
    Port Xvfb and Xnest to this.
    Port XFree86 to this, with OS-specific hooks for Linux, BSD, and Solaris
    taken from foo_io.c in the old layer.

diff --git a/dix/devices.c b/dix/devices.c
index a554f2f..aa04862 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -211,9 +211,11 @@ ActivateDevice(DeviceIntPtr dev)
 }
 
 static void
-CoreKeyboardBell(int volume, DeviceIntPtr pDev, pointer ctrl, int something)
+CoreKeyboardBell(int volume, DeviceIntPtr pDev, pointer arg, int something)
 {
-    return;
+    KeybdCtrl *ctrl = arg;
+
+    DDXRingBell(volume, ctrl->bell_pitch, ctrl->bell_duration);
 }
 
 static void
diff --git a/hw/vfb/InitInput.c b/hw/vfb/InitInput.c
index 9cb1c02..99cf56c 100644
--- a/hw/vfb/InitInput.c
+++ b/hw/vfb/InitInput.c
@@ -55,6 +55,10 @@ ProcessInputEvents()
     miPointerUpdate();
 }
 
+void DDXRingBell(int volume, int pitch, int duration)
+{
+}
+
 #define VFB_MIN_KEY 8
 #define VFB_MAX_KEY 255
 KeySym  map[MAP_LENGTH * LK201_GLYPHS_PER_KEY];
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 3df201a..4a9f369 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -1128,6 +1128,11 @@ xf86ReloadInputDevs(int sig)
   return;
 }
 
+_X_EXPORT void
+DDXRingBell(int volume, int pitch, int duration) {
+    xf86OSRingBell(volume, pitch, duration);
+}
+
 #ifdef WSCONS_SUPPORT
 
 /* XXX Currently XKB is mandatory. */
diff --git a/hw/xfree86/os-support/bsd/Makefile.am b/hw/xfree86/os-support/bsd/Makefile.am
index 0a0bcab..e456328 100644
--- a/hw/xfree86/os-support/bsd/Makefile.am
+++ b/hw/xfree86/os-support/bsd/Makefile.am
@@ -63,6 +63,7 @@ libbsd_la_SOURCES = \
 	bsd_VTsw.c \
 	bsd_init.c \
 	bsd_mouse.c \
+	bsd_bell.c \
 	$(ARCH_SOURCES) \
 	$(AGP_SOURCES) \
 	$(APM_SOURCES) \
diff --git a/hw/xfree86/os-support/bsd/bsd_bell.c b/hw/xfree86/os-support/bsd/bsd_bell.c
new file mode 100644
index 0000000..60c2ffc
--- /dev/null
+++ b/hw/xfree86/os-support/bsd/bsd_bell.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright 1992 by Rich Murphey <Rich at Rice.edu>
+ * 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 Rich Murphey and David Dawes 
+ * not be used in advertising or publicity pertaining to distribution of 
+ * the software without specific, written prior permission.  Rich Murphey 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.
+ *
+ * RICH MURPHEY AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO 
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+ * FITNESS, IN NO EVENT SHALL RICH MURPHEY OR DAVID DAWES BE LIABLE FOR 
+ * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
+ * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <termios.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#ifdef WSCONS_SUPPORT
+#define KBD_FD(i) ((i).kbdFd != -1 ? (i).kbdFd : (i).consoleFd)
+#endif
+
+_X_EXPORT void
+xf86OSRingBell(int loudness, int pitch, int duration)
+{
+#ifdef WSCONS_SUPPORT
+        struct wskbd_bell_data wsb;
+#endif
+
+        if (loudness && pitch)
+        {
+#ifdef PCCONS_SUPPORT
+                int data[2];
+#endif
+
+                switch (xf86Info.consType) {
+
+#ifdef PCCONS_SUPPORT
+                case PCCONS:
+                        data[0] = pitch;
+                        data[1] = (duration * loudness) / 50;
+                        ioctl(xf86Info.consoleFd, CONSOLE_X_BELL, data);
+                        break;
+#endif
+#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+                case SYSCONS:
+                case PCVT:
+                        ioctl(xf86Info.consoleFd, KDMKTONE,
+                              ((1193190 / pitch) & 0xffff) |
+                              (((unsigned long)duration*loudness/50)<<16));
+                        break;
+#endif
+#if defined (WSCONS_SUPPORT)
+                case WSCONS:
+                        wsb.which = WSKBD_BELL_DOALL;
+                        wsb.pitch = pitch;
+                        wsb.period = duration;
+                        wsb.volume = loudness;
+                        ioctl(KBD_FD(xf86Info), WSKBDIO_COMPLEXBELL,
+                                      &wsb);
+                        break;
+#endif
+                }
+        }
+}
diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am
index fc4243b..673a4e1 100644
--- a/hw/xfree86/os-support/linux/Makefile.am
+++ b/hw/xfree86/os-support/linux/Makefile.am
@@ -20,7 +20,7 @@ XORG_CFLAGS += -DHAVE_APM
 endif
 
 liblinux_la_SOURCES = lnx_init.c lnx_video.c lnx_mouse.c \
-                     lnx_pci.c lnx_agp.c lnx_kmod.c \
+                     lnx_pci.c lnx_agp.c lnx_kmod.c lnx_bell.c \
                      $(srcdir)/../shared/bios_mmap.c \
 		     $(srcdir)/../shared/VTsw_usl.c \
 		     $(srcdir)/../shared/posix_tty.c \
diff --git a/hw/xfree86/os-support/linux/lnx_bell.c b/hw/xfree86/os-support/linux/lnx_bell.c
new file mode 100644
index 0000000..6ef881b
--- /dev/null
+++ b/hw/xfree86/os-support/linux/lnx_bell.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright © 2006 Daniel Stone
+ *
+ * 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 this copyright notice and this permission notice appear in
+ * supporting electronic documentation.
+ *
+ * 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 HOLDERS OR AUTHORS 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.
+ *
+ * Author: Daniel Stone <daniel at fooishbar.org>
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/ioctl.h>
+#include <linux/kd.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+
+_X_EXPORT void
+xf86OSRingBell(int loudness, int pitch, int duration)
+{
+    if (xf86Info.consoleFd == -1 || !pitch || !loudness)
+        return;
+
+    ioctl(xf86Info.consoleFd, KDMKTONE,
+          ((1193190 / pitch) & 0xffff) |
+          (((unsigned long)duration * loudness / 50) << 16));
+}
diff --git a/hw/xfree86/os-support/solaris/Makefile.am b/hw/xfree86/os-support/solaris/Makefile.am
index 9c86079..291c329 100644
--- a/hw/xfree86/os-support/solaris/Makefile.am
+++ b/hw/xfree86/os-support/solaris/Makefile.am
@@ -19,7 +19,7 @@ solaris-$(SOLARIS_INOUT_ARCH).il: solari
 
 noinst_LTLIBRARIES = libsolaris.la
 libsolaris_la_SOURCES = sun_bios.c sun_init.c \
-	sun_mouse.c sun_vid.c $(AGP_SRC) \
+	sun_mouse.c sun_vid.c sun_bell.c $(AGP_SRC) \
 	$(srcdir)/../shared/libc_wrapper.c \
 	$(srcdir)/../shared/kmod_noop.c $(srcdir)/../shared/pm_noop.c \
 	$(srcdir)/../shared/posix_tty.c $(srcdir)/../shared/sigiostubs.c \
diff --git a/hw/xfree86/os-support/solaris/sun_bell.c b/hw/xfree86/os-support/solaris/sun_bell.c
new file mode 100644
index 0000000..369103f
--- /dev/null
+++ b/hw/xfree86/os-support/solaris/sun_bell.c
@@ -0,0 +1,184 @@
+/* Copyright 2004-2005 Sun Microsystems, Inc.  All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, and/or sell copies of the Software, and to permit persons
+ * to whom the Software is furnished to do so, provided that the above
+ * copyright notice(s) and this permission notice appear in all copies of
+ * the Software and that both the above copyright notice(s) and this
+ * permission notice appear in supporting documentation.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+ * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
+ * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
+ * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ * 
+ * Except as contained in this notice, the name of a copyright holder
+ * shall not be used in advertising or otherwise to promote the sale, use
+ * or other dealings in this Software without prior written authorization
+ * of the copyright holder.
+ */
+
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <sys/audio.h>
+#include <sys/uio.h>
+#include <limits.h>
+#include <math.h>
+#include <poll.h>
+
+#include "xf86.h"
+#include "xf86Priv.h"
+
+#define BELL_RATE       48000   /* Samples per second */
+#define BELL_HZ         50      /* Fraction of a second i.e. 1/x */
+#define BELL_MS         (1000/BELL_HZ)  /* MS */
+#define BELL_SAMPLES    (BELL_RATE / BELL_HZ)
+#define BELL_MIN        3       /* Min # of repeats */
+
+#define AUDIO_DEVICE    "/dev/audio"
+
+_X_EXPORT int
+xf86OSRingBell(int loudness, int pitch, int duration)
+{
+    static short    samples[BELL_SAMPLES];
+    static short    silence[BELL_SAMPLES]; /* "The Sound of Silence" */
+    static int      lastFreq;
+    int             cnt; 
+    int             i;
+    int             written;
+    int             repeats;
+    int             freq;
+    audio_info_t    audioInfo;
+    struct iovec    iov[IOV_MAX];
+    int             iovcnt;
+    double          ampl, cyclen, phase;
+    int             audioFD;
+
+    if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) {
+        return 0;
+    }
+
+    lastFreq = 0;
+    bzero(silence, sizeof(silence));
+
+    audioFD = open(AUDIO_DEVICE, O_WRONLY | O_NONBLOCK);
+    if (audioFD == -1) {
+        xf86Msg(X_ERROR, "Bell: cannot open audio device \"%s\": %s\n",
+                AUDIO_DEVICE, strerror(errno));
+        return -1;
+    }
+
+    freq = pitch;
+    freq = min(freq, (BELL_RATE / 2) - 1);
+    freq = max(freq, 2 * BELL_HZ);
+
+    /*
+     * Ensure full waves per buffer
+     */
+    freq -= freq % BELL_HZ;
+
+    if (freq != lastFreq) {
+        lastFreq = freq;
+        ampl =  16384.0;
+
+        cyclen = (double) freq / (double) BELL_RATE;
+        phase = 0.0;
+
+        for (i = 0; i < BELL_SAMPLES; i++) {
+            samples[i] = (short) (ampl * sin(2.0 * M_PI * phase));
+            phase += cyclen;
+            if (phase >= 1.0)
+                phase -= 1.0;
+        }
+    }
+
+    repeats = (duration + (BELL_MS / 2)) / BELL_MS;
+    repeats = max(repeats, BELL_MIN);
+
+    loudness = max(0, loudness);
+    loudness = min(loudness, 100);
+
+#ifdef DEBUG
+    ErrorF("BELL : freq %d volume %d duration %d repeats %d\n",
+           freq, loudness, duration, repeats);
+#endif
+
+    AUDIO_INITINFO(&audioInfo);
+    audioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
+    audioInfo.play.sample_rate = BELL_RATE;
+    audioInfo.play.channels = 2;
+    audioInfo.play.precision = 16;
+    audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100);
+
+    if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){
+        xf86Msg(X_ERROR,
+                "Bell: AUDIO_SETINFO failed on audio device \"%s\": %s\n",
+                AUDIO_DEVICE, strerror(errno));
+        close(audioFD);
+        return -1;
+    }
+
+    iovcnt = 0;
+
+    for (cnt = 0; cnt <= repeats; cnt++) {
+        iov[iovcnt].iov_base = (char *) samples;
+        iov[iovcnt++].iov_len = sizeof(samples);
+        if (cnt == repeats) {
+            /* Insert a bit of silence so that multiple beeps are distinct and
+             * not compressed into a single tone.
+             */
+            iov[iovcnt].iov_base = (char *) silence;
+            iov[iovcnt++].iov_len = sizeof(silence);
+        }
+        if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
+            written = writev(audioFD, iov, iovcnt);
+
+            if ((written < ((int)(sizeof(samples) * iovcnt)))) {
+                /* audio buffer was full! */
+
+                int naptime;
+
+                if (written == -1) {
+                    if (errno != EAGAIN) {
+                        xf86Msg(X_ERROR,
+                               "Bell: writev failed on audio device \"%s\": %s\n",
+                                AUDIO_DEVICE, strerror(errno));
+                        close(audioFD);
+                        return -1;
+                    }
+                    i = iovcnt;
+                } else {
+                    i = ((sizeof(samples) * iovcnt) - written)
+                        / sizeof(samples);
+                }
+                cnt -= i;
+
+                /* sleep a little to allow audio buffer to drain */
+                naptime = BELL_MS * i;
+                poll(NULL, 0, naptime);
+
+                i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples);
+                iovcnt = 0;
+                if ((written != -1) && (i > 0)) {
+                    iov[iovcnt].iov_base = ((char *) samples) + i;
+                    iov[iovcnt++].iov_len = sizeof(samples) - i;
+                }
+            } else {
+                iovcnt = 0;
+            }
+        }
+    }
+
+    close(audioFD);
+    return 0;
+}
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index c987d75..0311b81 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -174,6 +174,7 @@ extern int xf86GetSerialModemState(int f
 extern int xf86SerialModemSetBits(int fd, int bits);
 extern int xf86SerialModemClearBits(int fd, int bits);
 extern int xf86LoadKernelModule(const char *pathname);
+extern void xf86RingBell(int volume, int pitch, int duration);
 
 /* AGP GART interface */
 
diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c
index 26a5ed3..0dacae7 100644
--- a/hw/xnest/Keyboard.c
+++ b/hw/xnest/Keyboard.c
@@ -94,6 +94,12 @@ xnestBell(int volume, DeviceIntPtr pDev,
 }
 
 void
+DDXRingBell(int volume, int pitch, int duration)
+{
+  XBell(xnestDisplay, volume);
+}
+
+void
 xnestChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
 {
 #if 0
diff --git a/include/input.h b/include/input.h
index 3fe6944..f2fe6d1 100644
--- a/include/input.h
+++ b/include/input.h
@@ -441,7 +441,9 @@ extern DeviceIntPtr LookupDeviceIntRec(
 extern int NewInputDeviceRequest(
     InputOption *options);
 
-extern DeviceIntPtr LookupDeviceIntRec(
-    CARD8 deviceid);
+extern void DDXRingBell(
+    int volume,
+    int pitch,
+    int duration);
 
 #endif /* INPUT_H */
diff-tree 3df454719f9cbf6a046cb7458019ec621b3b42ee (from 644ee2434a4e09f5baea00a486911f8c24b9a261)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Nov 1 23:02:57 2006 +0200

    kdrive: add KdRingBell prototype

diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index f0fc909..ced48d7 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -872,6 +872,12 @@ KdEnableInput (void);
 void
 ProcessInputEvents (void);
 
+void
+KdRingBell (KdKeyboardInfo      *ki,
+            int                 volume,
+            int                 pitch,
+            int                 duration);
+
 extern KdPointerDriver	LinuxMouseDriver;
 extern KdPointerDriver	LinuxEvdevDriver;
 extern KdPointerDriver	Ps2MouseDriver;
diff-tree 644ee2434a4e09f5baea00a486911f8c24b9a261 (from 738d2e88171bcce8782d670a1cda9a1d941d7977)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 29 03:52:11 2006 +0300

    kdrive: avoid null dereferences
    Avoid jumping into NULL pointers for OS or card functions which do not
    exist.

diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index f29fdb9..b6ac0b0 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -281,7 +281,7 @@ KdSuspend (void)
 	    for (screen = card->screenList; screen; screen = screen->next)
 		if (screen->mynum == card->selected && screen->pScreen)
 		    KdDisableScreen (screen->pScreen);
-	    if (card->driver)
+	    if (card->driver && card->cfuncs->restore)
 		(*card->cfuncs->restore) (card);
 	}
 	KdDisableInput ();
@@ -295,7 +295,8 @@ KdDisableScreens (void)
     KdSuspend ();
     if (kdEnabled)
     {
-	(*kdOsFuncs->Disable) ();
+        if (kdOsFuncs->Disable)
+            (*kdOsFuncs->Disable) ();
 	kdEnabled = FALSE;
     }
 }
@@ -353,7 +354,8 @@ KdEnableScreens (void)
     if (!kdEnabled)
     {
 	kdEnabled = TRUE;
-	(*kdOsFuncs->Enable) ();
+        if (kdOsFuncs->Enable)
+            (*kdOsFuncs->Enable) ();
     }
     KdResume ();
 }
@@ -373,9 +375,10 @@ AbortDDX(void)
     KdDisableScreens ();
     if (kdOsFuncs)
     {
-	if (kdEnabled)
+	if (kdEnabled && kdOsFuncs->Disable)
 	    (*kdOsFuncs->Disable) ();
-	(*kdOsFuncs->Fini) ();
+        if (kdOsFuncs->Fini)
+            (*kdOsFuncs->Fini) ();
 	KdDoSwitchCmd ("stop");
     }
 
@@ -768,7 +771,8 @@ KdOsInit (KdOsFuncs *pOsFuncs)
 	if (serverGeneration == 1) 
 	{
 	    KdDoSwitchCmd ("start");
-	    (*pOsFuncs->Init) ();
+            if (pOsFuncs->Init)
+                (*pOsFuncs->Init) ();
 	}
     }
 }
diff-tree 738d2e88171bcce8782d670a1cda9a1d941d7977 (from 96e32805d12fc36f0fa0926dbfb0dd8a5cadb739)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 29 03:48:02 2006 +0300

    kdrive: move bell ringing into an OS function
    Move the bell into an OS function, and use that if it's declared; else,
    fall back to using the driver's function.
    Remove the Linux keyboard bell function; just move it into the OS layer.
    Use named initialisers when converting the old structures, and eliminate
    unused functions.

diff --git a/hw/kdrive/ephyr/os.c b/hw/kdrive/ephyr/os.c
index ead1586..1a42495 100644
--- a/hw/kdrive/ephyr/os.c
+++ b/hw/kdrive/ephyr/os.c
@@ -34,34 +34,8 @@ EphyrInit (void)
   return hostx_init();
 }
 
-static void
-EphyrEnable (void)
-{
-  EPHYR_DBG("mark");
-}
-
-static Bool
-EphyrSpecialKey (KeySym sym)
-{
-    return FALSE;
-}
-
-static void
-EphyrDisable (void)
-{
-}
-
-static void
-EphyrFini (void)
-{
-}
-
 KdOsFuncs   EphyrOsFuncs = {
-    EphyrInit,
-    EphyrEnable,
-    EphyrSpecialKey,
-    EphyrDisable,
-    EphyrFini,
-    ephyrPoll
+    .Init = EphyrInit,
+    .pollEvents = ephyrPoll,
 };
 
diff --git a/hw/kdrive/linux/keyboard.c b/hw/kdrive/linux/keyboard.c
index 24653ad..b7571f6 100644
--- a/hw/kdrive/linux/keyboard.c
+++ b/hw/kdrive/linux/keyboard.c
@@ -791,11 +791,6 @@ LinuxKeyboardInit (KdKeyboardInfo *ki)
 }
 
 static void
-LinuxKeyboardFini (KdKeyboardInfo *ki)
-{
-}
-
-static void
 LinuxKeyboardLeds (KdKeyboardInfo *ki, int leds)
 {
     if (!ki)
@@ -804,29 +799,10 @@ LinuxKeyboardLeds (KdKeyboardInfo *ki, i
     ioctl ((int)ki->driverPrivate, KDSETLED, leds & 7);
 }
 
-static void
-LinuxKeyboardBell (KdKeyboardInfo *ki, int volume, int pitch, int duration)
-{
-    if (!ki)
-        return;
-
-    if (volume && pitch)
-    {
-	ioctl((int)ki->driverPrivate, KDMKTONE,
-	      ((1193190 / pitch) & 0xffff) |
-	      (((unsigned long)duration *
-		volume / 50) << 16));
-
-    }
-}
-
 KdKeyboardDriver LinuxKeyboardDriver = {
     "keyboard",
-    LinuxKeyboardInit,
-    LinuxKeyboardEnable,
-    LinuxKeyboardLeds,
-    LinuxKeyboardBell,
-    LinuxKeyboardDisable,
-    LinuxKeyboardFini,
-    NULL,
+    .Init = LinuxKeyboardInit,
+    .Enable = LinuxKeyboardEnable,
+    .Leds = LinuxKeyboardLeds,
+    .Disable = LinuxKeyboardDisable,
 };
diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c
index 7ba99b4..c1fe185 100644
--- a/hw/kdrive/linux/linux.c
+++ b/hw/kdrive/linux/linux.c
@@ -373,26 +373,6 @@ LinuxEnable (void)
     enabled = TRUE;
 }
 
-static Bool
-LinuxSpecialKey (KeySym sym)
-{
-    struct vt_stat  vts;
-    int		    con;
-    
-    if (XK_F1 <= sym && sym <= XK_F12)
-    {
-	con = sym - XK_F1 + 1;
-	memset (&vts, '\0', sizeof (vts));	/* valgrind */
-	ioctl (LinuxConsoleFd, VT_GETSTATE, &vts);
-	if (con != vts.v_active && (vts.v_state & (1 << con)))
-	{
-	    ioctl (LinuxConsoleFd, VT_ACTIVATE, con);
-	    return TRUE;
-	}
-    }
-    return FALSE;
-}
-
 static void
 LinuxDisable (void)
 {
@@ -481,13 +461,20 @@ KdOsAddInputDrivers ()
     KdAddKeyboardDriver(&LinuxKeyboardDriver);
 }
 
+static void
+LinuxBell(int volume, int pitch, int duration)
+{
+    if (volume && pitch)
+        ioctl(LinuxConsoleFd, KDMKTONE, ((1193190 / pitch) & 0xffff) |
+              (((unsigned long)duration * volume / 50) << 16));
+}
+
 KdOsFuncs   LinuxFuncs = {
-    LinuxInit,
-    LinuxEnable,
-    LinuxSpecialKey,
-    LinuxDisable,
-    LinuxFini,
-    0
+    .Init = LinuxInit,
+    .Enable = LinuxEnable,
+    .Disable = LinuxDisable,
+    .Fini = LinuxFini,
+    .Bell = LinuxBell,
 };
 
 void
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 15d7031..f0fc909 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -369,6 +369,7 @@ typedef struct _KdOsFuncs {
     void	    (*Disable) (void);
     void	    (*Fini) (void);
     void	    (*pollEvents) (void);
+    void            (*Bell) (int, int, int);
 } KdOsFuncs;
 
 typedef enum _KdSyncPolarity {
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index fdeed82..be18586 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -523,22 +523,46 @@ LegalModifier(unsigned int key, DeviceIn
 }
 
 static void
-KdBell (int volume, DeviceIntPtr pDev, pointer ctrl, int something)
+KdBell (int volume, DeviceIntPtr pDev, pointer arg, int something)
 {
+    KeybdCtrl *ctrl = arg;
     KdKeyboardInfo *ki = NULL;
-
+    
     for (ki = kdKeyboards; ki; ki = ki->next) {
-        if (ki->dixdev && (ki->dixdev->id == pDev->id))
+        if (ki->dixdev && ki->dixdev->id == pDev->id)
             break;
     }
 
     if (!ki || !ki->dixdev || ki->dixdev->id != pDev->id || !ki->driver)
         return;
-        
-    if (kdInputEnabled) {
-        if (ki->driver->Bell)
-            (*ki->driver->Bell) (ki, volume, ki->bellPitch, ki->bellDuration);
+    
+    KdRingBell(ki, volume, ctrl->bell_pitch, ctrl->bell_duration);
+}
+
+void
+DDXRingBell(int volume, int pitch, int duration)
+{
+    KdKeyboardInfo *ki = NULL;
+
+    if (kdOsFuncs->Bell) {
+        (*kdOsFuncs->Bell)(volume, pitch, duration);
     }
+    else {
+        for (ki = kdKeyboards; ki; ki = ki->next) {
+            if (ki->dixdev->coreEvents)
+                KdRingBell(ki, volume, pitch, duration);
+        }
+    }
+}
+
+void
+KdRingBell(KdKeyboardInfo *ki, int volume, int pitch, int duration)
+{
+    if (!ki || !ki->driver || !ki->driver->Bell)
+        return;
+        
+    if (kdInputEnabled)
+        (*ki->driver->Bell) (ki, volume, pitch, duration);
 }
 
 
diff --git a/hw/kdrive/vxworks/vxworks.c b/hw/kdrive/vxworks/vxworks.c
index aa46001..688de62 100644
--- a/hw/kdrive/vxworks/vxworks.c
+++ b/hw/kdrive/vxworks/vxworks.c
@@ -12,17 +12,6 @@
 #include "kdrive.h"
 #include <X11/keysym.h>
 
-int
-VxWorksInit (void)
-{
-    return 1;
-}
-
-void
-VxWorksEnable (void)
-{
-}
-
 Bool
 VxWorksSpecialKey (KeySym sym)
 {
@@ -38,16 +27,6 @@ VxWorksSpecialKey (KeySym sym)
 }
 
 void
-VxWorksDisable (void)
-{
-}
-
-void
-VxWorksFini (void)
-{
-}
-
-void
 KdOsAddInputDrivers (void)
 {
     KdAddPointerDriver(&VxWorksMouseDriver);
@@ -55,12 +34,7 @@ KdOsAddInputDrivers (void)
 }
 
 KdOsFuncs   VxWorksFuncs = {
-    VxWorksInit,
-    VxWorksEnable,
-    VxWorksSpecialKey,
-    VxWorksDisable,
-    VxWorksFini,
-    0
+    .SpecialKey = VxWorksSpecialKey,
 };
 
 void
diff-tree 96e32805d12fc36f0fa0926dbfb0dd8a5cadb739 (from 68f595ca6c7883e030947b7f95c50e92aa733f2b)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 29 03:43:34 2006 +0300

    Xi: disallow changing core keyboard and pointer
    Just short-circuit the change core keyboard/pointer requests.

diff --git a/Xi/chgkbd.c b/Xi/chgkbd.c
index 289bd85..8134b40 100644
--- a/Xi/chgkbd.c
+++ b/Xi/chgkbd.c
@@ -64,7 +64,6 @@ SOFTWARE.
 #include "XIstubs.h"
 #include "globals.h"
 #include "extnsionst.h"
-#include "extinit.h"	/* LookupDeviceIntRec */
 
 #include "exevents.h"
 #include "exglobals.h"
@@ -99,107 +98,10 @@ SProcXChangeKeyboardDevice(register Clie
 int
 ProcXChangeKeyboardDevice(register ClientPtr client)
 {
-    int i;
-    DeviceIntPtr xkbd = inputInfo.keyboard;
-    DeviceIntPtr dev;
-    FocusClassPtr xf = xkbd->focus;
-    FocusClassPtr df;
-    KeyClassPtr k;
-    xChangeKeyboardDeviceReply rep;
-    changeDeviceNotify ev;
-
     REQUEST(xChangeKeyboardDeviceReq);
     REQUEST_SIZE_MATCH(xChangeKeyboardDeviceReq);
 
-    rep.repType = X_Reply;
-    rep.RepType = X_ChangeKeyboardDevice;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    dev = LookupDeviceIntRec(stuff->deviceid);
-    if (dev == NULL) {
-	rep.status = -1;
-	SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
-			  BadDevice);
-	return Success;
-    }
-
-    k = dev->key;
-    if (k == NULL) {
-	rep.status = -1;
-	SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
-			  BadMatch);
-	return Success;
-    }
-
-    if (((dev->grab) && !SameClient(dev->grab, client)) ||
-	((xkbd->grab) && !SameClient(xkbd->grab, client)))
-	rep.status = AlreadyGrabbed;
-    else if ((dev->sync.frozen &&
-	      dev->sync.other && !SameClient(dev->sync.other, client)) ||
-	     (xkbd->sync.frozen &&
-	      xkbd->sync.other && !SameClient(xkbd->sync.other, client)))
-	rep.status = GrabFrozen;
-    else {
-	if (ChangeKeyboardDevice(xkbd, dev) != Success) {
-	    SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
-			      BadDevice);
-	    return Success;
-	}
-	if (!dev->focus)
-	    InitFocusClassDeviceStruct(dev);
-	if (!dev->kbdfeed)
-	    InitKbdFeedbackClassDeviceStruct(dev, (BellProcPtr) NoopDDA,
-					     (KbdCtrlProcPtr) NoopDDA);
-	df = dev->focus;
-	df->win = xf->win;
-	df->revert = xf->revert;
-	df->time = xf->time;
-	df->traceGood = xf->traceGood;
-	if (df->traceSize != xf->traceSize) {
-	    Must_have_memory = TRUE;	/* XXX */
-	    df->trace = (WindowPtr *) xrealloc(df->trace,
-					       xf->traceSize *
-					       sizeof(WindowPtr));
-	    Must_have_memory = FALSE;	/* XXX */
-	}
-	df->traceSize = xf->traceSize;
-	for (i = 0; i < df->traceSize; i++)
-	    df->trace[i] = xf->trace[i];
-	RegisterOtherDevice(xkbd);
-	RegisterKeyboardDevice(dev);
-
-	ev.type = ChangeDeviceNotify;
-	ev.deviceid = stuff->deviceid;
-	ev.time = currentTime.milliseconds;
-	ev.request = NewKeyboard;
-
-	SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1);
-	SendMappingNotify(MappingKeyboard, k->curKeySyms.minKeyCode,
-			  k->curKeySyms.maxKeyCode - k->curKeySyms.minKeyCode +
-			  1, client);
-
-	rep.status = 0;
-    }
-
-    WriteReplyToClient(client, sizeof(xChangeKeyboardDeviceReply), &rep);
+    SendErrorToClient(client, IReqCode, X_ChangeKeyboardDevice, 0,
+                      BadDevice);
     return Success;
 }
-
-/***********************************************************************
- *
- * This procedure writes the reply for the XChangeKeyboardDevice 
- * function, if the client and server have a different byte ordering.
- *
- */
-
-void
-SRepXChangeKeyboardDevice(ClientPtr client, int size,
-			  xChangeKeyboardDeviceReply * rep)
-{
-    register char n;
-
-    swaps(&rep->sequenceNumber, n);
-    swapl(&rep->length, n);
-    WriteToClient(client, size, (char *)rep);
-}
diff --git a/Xi/chgkbd.h b/Xi/chgkbd.h
index 7a883b7..5f99223 100644
--- a/Xi/chgkbd.h
+++ b/Xi/chgkbd.h
@@ -36,9 +36,4 @@ int SProcXChangeKeyboardDevice(ClientPtr
 int ProcXChangeKeyboardDevice(ClientPtr	/* client */
     );
 
-void SRepXChangeKeyboardDevice(ClientPtr /* client */ ,
-			       int /* size */ ,
-			       xChangeKeyboardDeviceReply *	/* rep */
-    );
-
 #endif /* CHGKBD_H */
diff --git a/Xi/chgptr.c b/Xi/chgptr.c
index b799092..22c8a5f 100644
--- a/Xi/chgptr.c
+++ b/Xi/chgptr.c
@@ -101,97 +101,10 @@ SProcXChangePointerDevice(register Clien
 int
 ProcXChangePointerDevice(register ClientPtr client)
 {
-    DeviceIntPtr xptr = inputInfo.pointer;
-    DeviceIntPtr dev;
-    ValuatorClassPtr v;
-    xChangePointerDeviceReply rep;
-    changeDeviceNotify ev;
-
     REQUEST(xChangePointerDeviceReq);
     REQUEST_SIZE_MATCH(xChangePointerDeviceReq);
 
-    rep.repType = X_Reply;
-    rep.RepType = X_ChangePointerDevice;
-    rep.length = 0;
-    rep.sequenceNumber = client->sequence;
-
-    dev = LookupDeviceIntRec(stuff->deviceid);
-    if (dev == NULL) {
-	rep.status = -1;
-	SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
-			  BadDevice);
-	return Success;
-    }
-
-    v = dev->valuator;
-    if (v == NULL || v->numAxes < 2 ||
-	stuff->xaxis >= v->numAxes || stuff->yaxis >= v->numAxes) {
-	rep.status = -1;
-	SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0, BadMatch);
-	return Success;
-    }
-
-    if (((dev->grab) && !SameClient(dev->grab, client)) ||
-	((xptr->grab) && !SameClient(xptr->grab, client)))
-	rep.status = AlreadyGrabbed;
-    else if ((dev->sync.frozen &&
-	      dev->sync.other && !SameClient(dev->sync.other, client)) ||
-	     (xptr->sync.frozen &&
-	      xptr->sync.other && !SameClient(xptr->sync.other, client)))
-	rep.status = GrabFrozen;
-    else {
-	if (ChangePointerDevice(xptr, dev, stuff->xaxis, stuff->yaxis) !=
-	    Success) {
-	    SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
-			      BadDevice);
-	    return Success;
-	}
-	if (dev->focus)
-	    DeleteFocusClassDeviceStruct(dev);
-	if (!dev->button)
-	    InitButtonClassDeviceStruct(dev, 0, NULL);
-	if (!dev->ptrfeed)
-	    InitPtrFeedbackClassDeviceStruct(dev, (PtrCtrlProcPtr) NoopDDA);
-	RegisterOtherDevice(xptr);
-	RegisterPointerDevice(dev);
-
-	ev.type = ChangeDeviceNotify;
-	ev.deviceid = stuff->deviceid;
-	ev.time = currentTime.milliseconds;
-	ev.request = NewPointer;
-
-	SendEventToAllWindows(dev, ChangeDeviceNotifyMask, (xEvent *) & ev, 1);
-	SendMappingNotify(MappingPointer, 0, 0, client);
-
-	rep.status = 0;
-    }
-
-    WriteReplyToClient(client, sizeof(xChangePointerDeviceReply), &rep);
+    SendErrorToClient(client, IReqCode, X_ChangePointerDevice, 0,
+                      BadDevice);
     return Success;
 }
-
-void
-DeleteFocusClassDeviceStruct(DeviceIntPtr dev)
-{
-    xfree(dev->focus->trace);
-    xfree(dev->focus);
-    dev->focus = NULL;
-}
-
-/***********************************************************************
- *
- * This procedure writes the reply for the XChangePointerDevice 
- * function, if the client and server have a different byte ordering.
- *
- */
-
-void
-SRepXChangePointerDevice(ClientPtr client, int size,
-			 xChangePointerDeviceReply * rep)
-{
-    register char n;
-
-    swaps(&rep->sequenceNumber, n);
-    swapl(&rep->length, n);
-    WriteToClient(client, size, (char *)rep);
-}
diff --git a/Xi/chgptr.h b/Xi/chgptr.h
index aeda822..fb3b5cc 100644
--- a/Xi/chgptr.h
+++ b/Xi/chgptr.h
@@ -53,9 +53,4 @@ void FindInterestedChildren(	/* FIXME: c
 			       int	/* count */
     );
 
-void SRepXChangePointerDevice(ClientPtr /* client */ ,
-			      int /* size */ ,
-			      xChangePointerDeviceReply *	/* rep */
-    );
-
 #endif /* CHGPTR_H */
diff --git a/Xi/extinit.c b/Xi/extinit.c
index c35a964..4548837 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -465,12 +465,6 @@ SReplyIDispatch(ClientPtr client, int le
     else if (rep->RepType == X_GetDeviceMotionEvents)
 	SRepXGetDeviceMotionEvents(client, len,
 				   (xGetDeviceMotionEventsReply *) rep);
-    else if (rep->RepType == X_ChangeKeyboardDevice)
-	SRepXChangeKeyboardDevice(client, len,
-				  (xChangeKeyboardDeviceReply *) rep);
-    else if (rep->RepType == X_ChangePointerDevice)
-	SRepXChangePointerDevice(client, len,
-				 (xChangePointerDeviceReply *) rep);
     else if (rep->RepType == X_GrabDevice)
 	SRepXGrabDevice(client, len, (xGrabDeviceReply *) rep);
     else if (rep->RepType == X_GetDeviceFocus)
diff --git a/Xi/stubs.c b/Xi/stubs.c
index 28ecd8b..e2ed1ce 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -68,86 +68,6 @@ SOFTWARE.
 
 /***********************************************************************
  *
- * Caller:	ProcXChangeKeyboardDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the keyboard device.
- *
- * The X keyboard device has a FocusRec.  If the device that has been 
- * made into the new X keyboard did not have a FocusRec, 
- * ProcXChangeKeyboardDevice will allocate one for it.
- *
- * If you do not want clients to be able to focus the old X keyboard
- * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
- *
- * If you support input devices with keys that you do not want to be 
- * used as the X keyboard, you need to check for them here and return 
- * a BadDevice error.
- *
- * The default implementation is to do nothing (assume you do want
- * clients to be able to focus the old X keyboard).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- */
-
-int
-ChangeKeyboardDevice(DeviceIntPtr old_dev, DeviceIntPtr new_dev)
-{
-    /***********************************************************************
-     DeleteFocusClassDeviceStruct(old_dev);	 * defined in xchgptr.c *
-    **********************************************************************/
-    return BadMatch;
-}
-
-/***********************************************************************
- *
- * Caller:	ProcXChangePointerDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the pointer device.
- *
- * The X pointer device does not have a FocusRec.  If the device that
- * has been made into the new X pointer had a FocusRec, 
- * ProcXChangePointerDevice will free it.
- *
- * If you want clients to be able to focus the old pointer device that
- * has now become accessible through the input extension, you need to 
- * add a FocusRec to it here.
- *
- * The XChangePointerDevice protocol request also allows the client
- * to choose which axes of the new pointer device are used to move 
- * the X cursor in the X- and Y- directions.  If the axes are different
- * than the default ones, you need to keep track of that here.
- *
- * If you support input devices with valuators that you do not want to be 
- * used as the X pointer, you need to check for them here and return a 
- * BadDevice error.
- *
- * The default implementation is to do nothing (assume you don't want
- * clients to be able to focus the old X pointer).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- */
-
-int
-ChangePointerDevice(DeviceIntPtr old_dev,
-		    DeviceIntPtr new_dev, unsigned char x, unsigned char y)
-{
-    /***********************************************************************
-    InitFocusClassDeviceStruct(old_dev);	* allow focusing old ptr*
-
-    x_axis = x;					* keep track of new x-axis*
-    y_axis = y;					* keep track of new y-axis*
-    if (x_axis != 0 || y_axis != 1)
-	axes_changed = TRUE;			* remember axes have changed*
-    else
-	axes_changed = FALSE;
-    *************************************************************************/
-    return BadMatch;
-}
-
-/***********************************************************************
- *
  * Caller:	ProcXCloseDevice
  *
  * Take care of implementation-dependent details of closing a device.
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 915a219..be3368d 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -251,148 +251,12 @@ OpenInputDevice(DeviceIntPtr	dev,
     *status = Success;
 }
 
-
-/***********************************************************************
- *
- * Caller:	ProcXChangeKeyboardDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the keyboard device.
- *
- * The X keyboard device has a FocusRec.  If the device that has been 
- * made into the new X keyboard did not have a FocusRec, 
- * ProcXChangeKeyboardDevice will allocate one for it.
- *
- * If you do not want clients to be able to focus the old X keyboard
- * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
- *
- * If you support input devices with keys that you do not want to be 
- * used as the X keyboard, you need to check for them here and return 
- * a BadDevice error.
- *
- * The default implementation is to do nothing (assume you do want
- * clients to be able to focus the old X keyboard).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- ***********************************************************************
- */
-
-int
-ChangeKeyboardDevice (DeviceIntPtr old_dev, DeviceIntPtr new_dev)
-{
-  /**********************************************************************
-   * DeleteFocusClassDeviceStruct(old_dev);	 * defined in xchgptr.c *
-   **********************************************************************/
-  return !Success;
-}
-
-
-/***********************************************************************
- *
- * Caller:	ProcXChangePointerDevice
- *
- * This procedure does the implementation-dependent portion of the work
- * needed to change the pointer device.
- *
- * The X pointer device does not have a FocusRec.  If the device that
- * has been made into the new X pointer had a FocusRec, 
- * ProcXChangePointerDevice will free it.
- *
- * If you want clients to be able to focus the old pointer device that
- * has now become accessible through the input extension, you need to 
- * add a FocusRec to it here.
- *
- * The XChangePointerDevice protocol request also allows the client
- * to choose which axes of the new pointer device are used to move 
- * the X cursor in the X- and Y- directions.  If the axes are different
- * than the default ones, you need to keep track of that here.
- *
- * If you support input devices with valuators that you do not want to be 
- * used as the X pointer, you need to check for them here and return a 
- * BadDevice error.
- *
- * The default implementation is to do nothing (assume you don't want
- * clients to be able to focus the old X pointer).  The commented-out
- * sample code shows what you might do if you don't want the default.
- *
- ***********************************************************************
- */
-
-int
-ChangePointerDevice (
-     DeviceIntPtr	old_dev,
-     DeviceIntPtr	new_dev,
-     unsigned char	x,
-     unsigned char	y)
-{
-  /************************************************************************
-    InitFocusClassDeviceStruct(old_dev);	* allow focusing old ptr*
-    
-    x_axis = x;					* keep track of new x-axis*
-    y_axis = y;					* keep track of new y-axis*
-    if (x_axis != 0 || y_axis != 1)
-    axes_changed = TRUE;			* remember axes have changed*
-    else
-    axes_changed = FALSE;
-   *************************************************************************/
-
-    return !Success;
-}
-
-
-/***********************************************************************
- *
- * Caller:	ProcXCloseDevice
- *
- * Take care of implementation-dependent details of closing a device.
- * Some implementations may actually close the device, others may just
- * remove this clients interest in that device.
- *
- * The default implementation is to do nothing (assume all input devices
- * are initialized during X server initialization and kept open).
- *
- ***********************************************************************
- */
-
-void
-CloseInputDevice (DeviceIntPtr d, ClientPtr client)
-{
-}
-
-
-/***********************************************************************
- *
- * Caller:	ProcXListInputDevices
- *
- * This is the implementation-dependent routine to initialize an input 
- * device to the point that information about it can be listed.
- * Some implementations open all input devices when the server is first
- * initialized, and never close them.  Other implementations open only
- * the X pointer and keyboard devices during server initialization,
- * and only open other input devices when some client makes an
- * XOpenDevice request.  If some other process has the device open, the
- * server may not be able to get information about the device to list it.
- *
- * This procedure should be used by implementations that do not initialize
- * all input devices at server startup.  It should do device-dependent
- * initialization for any devices not previously initialized, and call
- * AddInputDevice for each of those devices so that a DeviceIntRec will be 
- * created for them.
- *
- * The default implementation is to do nothing (assume all input devices
- * are initialized during X server initialization and kept open).
- * The commented-out sample code shows what you might do if you don't want 
- * the default.
- *
- ***********************************************************************
- */
-
 void
-AddOtherInputDevices ()
+CloseInputDevice(DeviceIntPtr dev,
+                 ClientPtr client)
 {
 }
 
-
 /****************************************************************************
  *
  * Caller:	ProcXSetDeviceMode
@@ -475,6 +339,11 @@ ChangeDeviceControl (ClientPtr client, D
       return (*local->control_proc)(local, control);
   }
 }
+
+void
+AddOtherInputDevices()
+{
+}
 #endif
 
 int
diff --git a/include/XIstubs.h b/include/XIstubs.h
index 45f6eb1..6797e07 100644
--- a/include/XIstubs.h
+++ b/include/XIstubs.h
@@ -26,18 +26,6 @@ OR IN CONNECTION WITH THE USE OR PERFORM
 #ifndef XI_STUBS_H
 #define XI_STUBS_H 1
 
-int
-ChangeKeyboardDevice (
-	DeviceIntPtr           /* old_dev */,
-	DeviceIntPtr           /* new_dev */);
-
-int
-ChangePointerDevice (
-	DeviceIntPtr           /* old_dev */,
-	DeviceIntPtr           /* new_dev */,
-	unsigned char          /* x */,
-	unsigned char          /* y */);
-
 void
 CloseInputDevice (
 	DeviceIntPtr           /* d */,
diff-tree 68f595ca6c7883e030947b7f95c50e92aa733f2b (from 51a06b3c44509c72279b5cfcf2b52b9a35c461b0)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 29 03:41:34 2006 +0300

    GetTimeInMillis: use correct units for clock_gettime
    Make sure we're treating the nanoseconds as a long, not an int, so we
    don't overflow.

diff --git a/os/utils.c b/os/utils.c
index 7d258a4..c7a8964 100644
--- a/os/utils.c
+++ b/os/utils.c
@@ -552,7 +552,7 @@ GetTimeInMillis(void)
 #ifdef MONOTONIC_CLOCK
     struct timespec tp;
     if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
-        return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000);
+        return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
 #endif
 
     X_GETTIMEOFDAY(&tv);
diff-tree 51a06b3c44509c72279b5cfcf2b52b9a35c461b0 (from 196c5836f463c28f633bbba847f59acd5935359d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 29 03:40:57 2006 +0300

    WaitForSomething: only rewind when delta is more than 250ms
    Only rewind time when we're more than (original delta + 250ms) away from
    executing the timer.
    When we're walking the timer list, use a goto to iterate all of them from
    the start again, since timers may drop out of the list.
    Don't bother trying to be smart in TimerSet, we'll pick it up in
    WaitForSomething anyway.

diff --git a/os/WaitFor.c b/os/WaitFor.c
index 896fdf1..6109e34 100644
--- a/os/WaitFor.c
+++ b/os/WaitFor.c
@@ -202,11 +202,12 @@ WaitForSomething(int *pClientsReady)
         {
             now = GetTimeInMillis();
 	    timeout = timers->expires - now;
-            /* time has rewound.  reset the timers. */
-            if (timeout > timers->delta) {
+            if (timeout > 0 && timeout > timers->delta + 250) {
+                /* time has rewound.  reset the timers. */
                 CheckAllTimers(now);
                 timeout = timers->expires - now;
             }
+
             if (timeout < 0)
                 timeout = 0;
 	    waittime.tv_sec = timeout / MILLI_PER_SECOND;
@@ -434,17 +435,18 @@ ANYSET(FdMask *src)
 #endif
 
 /* If time has rewound, re-run every affected timer.
- * TimerForce will change timer->next, but it will _generally_ only
- * promote timers in the list, meaning that we should still be
- * walking every timer. */
+ * Timers might drop out of the list, so we have to restart every time. */
 static void
 CheckAllTimers(CARD32 now)
 {
     OsTimerPtr timer;
 
+start:
     for (timer = timers; timer; timer = timer->next) {
-        if (timer->expires - now > timer->delta)
+        if (timer->expires - now > timer->delta + 250) {
             TimerForce(timer);
+            goto start;
+        }
     }
 }
 
@@ -507,10 +509,8 @@ TimerSet(OsTimerPtr timer, int flags, CA
     }
     for (prev = &timers;
 	 *prev && (int) ((*prev)->expires - millis) <= 0;
-	 prev = &(*prev)->next) {
-        if ((*prev)->expires - now > (*prev)->delta)
-            CheckAllTimers(now);
-    }
+	 prev = &(*prev)->next)
+        ;
     timer->next = *prev;
     *prev = timer;
     return timer;
diff-tree 196c5836f463c28f633bbba847f59acd5935359d (from f9a1e456f8a4eaa1a9c71fd0fe5231140975c22d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 27 01:27:31 2006 +0300

    CoreKeyboardProc: annotate with FIXME
    Setting an empty keymap by default isn't wildly useful.

diff --git a/dix/devices.c b/dix/devices.c
index 01404db..a554f2f 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -261,8 +261,11 @@ CoreKeyboardProc(DeviceIntPtr pDev, int 
         }
         else
 #endif
-        InitKeyboardDeviceStruct((DevicePtr)pDev, &keySyms, modMap,
-                                 CoreKeyboardBell, CoreKeyboardCtl);
+        {
+            /* FIXME Our keymap here isn't exactly useful. */
+            InitKeyboardDeviceStruct((DevicePtr)pDev, &keySyms, modMap,
+                                     CoreKeyboardBell, CoreKeyboardCtl);
+        }
 
         xfree(keySyms.map);
         xfree(modMap);
diff-tree f9a1e456f8a4eaa1a9c71fd0fe5231140975c22d (from a5be65401769fabcb5001dc63035c69f9e4a2712)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 27 01:25:39 2006 +0300

    CoreKeyboardProc: don't leak keymap and modmap
    SetKeySymsMap does a copy here, so try not to leak them.

diff --git a/dix/devices.c b/dix/devices.c
index a5110ff..01404db 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -263,6 +263,10 @@ CoreKeyboardProc(DeviceIntPtr pDev, int 
 #endif
         InitKeyboardDeviceStruct((DevicePtr)pDev, &keySyms, modMap,
                                  CoreKeyboardBell, CoreKeyboardCtl);
+
+        xfree(keySyms.map);
+        xfree(modMap);
+
         break;
 
     case DEVICE_CLOSE:
diff-tree a5be65401769fabcb5001dc63035c69f9e4a2712 (from 85212eb504f860b054eb0f0a5029fed86cb8d1c0)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 27 01:25:21 2006 +0300

    mieqEnqueue: only compare DEVICE_BITS of deviceid
    Only compare DEVICE_BITS of the two deviceids, so we don't decide that
    a valuator event isn't for us, because (id | MORE_EVENTS) != id.

diff --git a/mi/mieq.c b/mi/mieq.c
index 63cd6e1..be76580 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -117,7 +117,8 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e
             !(lastkbp->type == DeviceMotionNotify ||
               lastkbp->type == DeviceButtonPress ||
               lastkbp->type == DeviceButtonRelease) ||
-            (lastkbp->deviceid != v->deviceid)) {
+            ((lastkbp->deviceid & DEVICE_BITS) !=
+             (v->deviceid & DEVICE_BITS))) {
             ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n");
             return;
         }
diff-tree 85212eb504f860b054eb0f0a5029fed86cb8d1c0 (from 8c0556e7cb1de8c387ddd886a03a8f8afff1fd0e)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 27 01:23:58 2006 +0300

    getValuatorEvents: make sure we put MORE_EVENTS in the right places
    Make sure we put MORE_EVENTS in with the device id if there are, in fact,
    more valuator events coming.

diff --git a/dix/getevents.c b/dix/getevents.c
index e34058c..b19a73f 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -365,6 +365,9 @@ getValuatorEvents(xEvent *events, Device
         case 1:
             xv->valuator0 = valuators[i];
         }
+
+        if (i + 6 < final_valuator)
+            xv->deviceid |= MORE_EVENTS;
     }
 
     return events;
diff-tree 794f2e7291ccb4e48f9fbfc8f08302e3aac0f79f (from 004d00e6689f452fc9fdf91f5ffc6d6aed697d54)
Author: Myron Stowe <myron.stowe at hp.com>
Date:   Thu Oct 26 20:38:58 2006 +0300

    xfree86: re-enable chipset-specific drivers for Linux/ia64
    Re-enable chipset-specific support for Linux/ia64, by linking in
    lnx_ia64.c.

diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am
index 6fdc1bc..7f71022 100644
--- a/hw/xfree86/os-support/linux/Makefile.am
+++ b/hw/xfree86/os-support/linux/Makefile.am
@@ -1,7 +1,9 @@
 noinst_LTLIBRARIES = liblinux.la
 
 if LINUX_IA64
-PLATFORM_PCI_SUPPORT = $(srcdir)/../shared/ia64Pci.c
+PLATFORM_PCI_SUPPORT = $(srcdir)/lnx_ia64.c $(srcdir)/../shared/ia64Pci.c
+PLATFORM_DEFINES = -DOS_PROBE_PCI_CHIPSET=lnxProbePciChipset
+PLATFORM_INCLUDES = -I$(srcdir)/../shared
 endif
 if LINUX_ALPHA
 PLATFORM_PCI_SUPPORT = lnx_ev56.c \
@@ -34,14 +36,13 @@ liblinux_la_SOURCES = lnx_init.c lnx_vid
                      $(APM_SOURCES) \
                      $(PLATFORM_PCI_SUPPORT)
 
-AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS)
+AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(PLATFORM_DEFINES)
 
-INCLUDES = $(XORG_INCS) -I/usr/include/drm # FIXME this last part is crack
+INCLUDES = $(XORG_INCS) $(PLATFORM_INCLUDES) -I/usr/include/drm # FIXME this last part is crack
 
 # FIXME: These need to be added to the build
 LNX_EXTRA_SOURCES = \
 	lnx_font.c \
-	lnx_ia64.c \
 	lnx_jstk.c \
 	lnxResource.c
 
@@ -49,5 +50,4 @@ EXTRA_DIST = \
 	$(LNX_EXTRA_SOURCES) \
 	lnx.h \
 	lnx_kbd.h \
-	$(srcdir)/../shared/ia64Pci.h \
 	$(srcdir)/../shared/xf86Axp.h
diff-tree 8c0556e7cb1de8c387ddd886a03a8f8afff1fd0e (from parents)
Merge: cdc8a4b7b2f099b8860a54c5c9f488e6f7c4913a 004d00e6689f452fc9fdf91f5ffc6d6aed697d54
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Oct 26 15:21:22 2006 +0300

    Merge branch 'master' into input-hotplug

diff-tree cdc8a4b7b2f099b8860a54c5c9f488e6f7c4913a (from parents)
Merge: 3da918a16c8908fdfaf89f2a1bcaec19e01528a9 d285833290316cb5dd1e7f1e52c96be3e9cf21cd
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Oct 26 00:28:30 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff --cc configure.ac
index a6eb8cc,0f2ddd5..aa6c607
@@@ -890,32 -873,46 +890,69 @@@
  
  XSERVER_CFLAGS="${XSERVERCFLAGS_CFLAGS}"
  XSERVER_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} -lm"
- AC_SUBST([XSERVER_LIBS])
  AC_SUBST([SYS_LIBS])
  
 +# The Xorg binary needs to export symbols so that they can be used from modules
 +# Some platforms require extra flags to do this.   gcc should set these flags
 +# when -rdynamic is passed to it, other compilers/linkers may need to be added
 +# here.
 +if test "x$GCC" = "xyes"; then
 +       GCC_WARNINGS1="-Wall -Wpointer-arith -Wstrict-prototypes"
 +       GCC_WARNINGS2="-Wmissing-prototypes -Wmissing-declarations"
 +       GCC_WARNINGS3="-Wnested-externs -fno-strict-aliasing"
 +       GCC_WARNINGS="$GCC_WARNINGS1 $GCC_WARNINGS2 $GCC_WARNINGS3"
 +       if test "x$WERROR" = "xyes"; then
 +               GCC_WARNINGS="${GCC_WARNINGS} -Werror"
 +       fi
 +       XSERVER_CFLAGS="$GCC_WARNINGS $XSERVER_CFLAGS"
 +
 +       LD_EXPORT_SYMBOLS_FLAG="-rdynamic"
 +fi
 +case $host_os in
 +       openbsd*)
 +       LD_EXPORT_SYMBOLS_FLAG="-Wl,--export-dynamic"
 +       ;;
 +esac
 +AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])
 +
+ AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes],
+                [AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
+                              [have_clock_gettime=no])])
+ 
+ AC_MSG_CHECKING([for a useful monotonic clock ...])
+ 
+ if ! test "x$have_clock_gettime" = xno; then
+     if ! test "x$have_clock_gettime" = xyes; then
+         LIBS="$have_clock_gettime"
+     else
+         LIBS=""
+     fi
+ 
+     AC_RUN_IFELSE([
+ #define _POSIX_C_SOURCE 199309L
+ #include <time.h>
+ 
+ int main(int argc, char *argv[]) {
+     struct timespec tp;
+ 
+     if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
+         return 0;
+     else
+         return 1;
+ }
+     ], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no],
+        [MONOTONIC_CLOCK="cross compiling"])
+ else
+     MONOTONIC_CLOCK=no
+ fi
+ 
+ AC_MSG_RESULT([$MONOTONIC_CLOCK])
+ 
+ if test "x$MONOTONIC_CLOCK" = xyes; then
+     AC_DEFINE(MONOTONIC_CLOCK, 1, [Have monotonic clock from clock_gettime()])
+     XSERVER_LIBS="$XSERVER_LIBS $LIBS"
+ fi
+ 
  dnl Imake defines SVR4 on SVR4 systems, and many files check for it, so
  dnl we need to replicate that here until those can all be fixed
  AC_MSG_CHECKING([if SVR4 needs to be defined])
diff --cc include/dix-config.h.in
index a920242,35700e4..fc1e69a
@@@ -445,16 -445,7 +445,19 @@@
  /* Define to 1 if modules should avoid the libcwrapper */
  #undef NO_LIBCWRAPPER
  
 +/* Support D-BUS */
 +#undef HAVE_DBUS
 +
 +/* Use only built-in fonts */
 +#undef BUILTIN_FONTS
 +
 +/* Avoid using font servers */
 +#undef NOFONTSERVERACCESS
 +
 +/* Use an empty root cursor */
 +#undef NULL_ROOT_CURSOR
 +
+ /* Have a monotonic clock from clock_gettime() */
+ #undef MONOTONIC_CLOCK
+ 
  #endif /* _DIX_CONFIG_H_ */
diff-tree 3da918a16c8908fdfaf89f2a1bcaec19e01528a9 (from aabc087998e680c2fcf0ebc1c5022c1fe8f58f0c)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Oct 25 02:22:07 2006 +0300

    mipointer: remember to update pointer location
    Update pointer location so it doesn't get quickly reset by the next
    pointer update.

diff --git a/mi/mipointer.c b/mi/mipointer.c
index 679b760..dbe2aae 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -484,4 +484,8 @@ miPointerMoved (DeviceIntPtr pDev, Scree
 	if(!miPointer.pCursor->bits->emptyMask)
 	    (*pScreenPriv->spriteFuncs->MoveCursor) (pScreen, x, y);
     }
+
+    miPointer.x = x;
+    miPointer.y = y;
+    miPointer.pScreen = pScreen;
 }
diff-tree aabc087998e680c2fcf0ebc1c5022c1fe8f58f0c (from 65cd5aa4d754624566c2263015f1a018d137fce1)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Oct 25 02:21:39 2006 +0300

    GetPointerEvents: always ensure correct number of events
    Ensure correct number of valuator events are returned, and that we always
    increment events correctly.

diff --git a/dix/getevents.c b/dix/getevents.c
index 0a228cd..e34058c 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -504,7 +504,7 @@ GetPointerEvents(xEvent *events, DeviceI
         num_events = 1;
 
     /* Do we need to send a DeviceValuator event? */
-    if ((num_valuators + first_valuator) >= 2 && sendValuators) {
+    if ((num_valuators + first_valuator) > 2 && sendValuators) {
         if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS)
             num_valuators = MAX_VALUATOR_EVENTS * 6;
         num_events += ((num_valuators - 1) / 6) + 1;
@@ -614,9 +614,9 @@ GetPointerEvents(xEvent *events, DeviceI
     kbp->root_x = x;
     kbp->root_y = y;
 
+    events++;
     if (final_valuator > 2 && sendValuators) {
         kbp->deviceid |= MORE_EVENTS;
-        events++;
         clipValuators(pDev, first_valuator, num_valuators, valuators);
         events = getValuatorEvents(events, pDev, first_valuator,
                                    num_valuators, valuators);
diff-tree 65cd5aa4d754624566c2263015f1a018d137fce1 (from 0514d53e10b3521bb708a9cbde4bab525248eadb)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Oct 25 01:12:45 2006 +0300

    kdrive/input: remove unnecessary #ifdef XINPUTs
    Xi is now mandatory, so don't bother with the ifdefs.

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 724f724..fdeed82 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -45,14 +45,12 @@
 #include <X11/extensions/XKBsrv.h>
 #endif
 
-#ifdef XINPUT
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
 #include "XIstubs.h" /* even though we don't use stubs.  cute, no? */
 #include "exevents.h"
 #include "extinit.h"
 #include "exglobals.h"
-#endif
 
 #define AtomFromName(x) MakeAtom(x, strlen(x), 1)
 
@@ -394,9 +392,7 @@ KdPointerProc(DeviceIntPtr pDevice, int 
 {
     DevicePtr       pDev = (DevicePtr)pDevice;
     KdPointerInfo   *pi;
-#ifdef XINPUT
     Atom            xiclass;
-#endif
 
     if (!pDev)
 	return BadImplementation;
@@ -719,9 +715,7 @@ KdKeyboardProc(DeviceIntPtr pDevice, int
     Bool        ret;
     DevicePtr   pDev = (DevicePtr)pDevice;
     KdKeyboardInfo *ki;
-#ifdef XINPUT
     Atom xiclass;
-#endif
 
     if (!pDev)
 	return BadImplementation;
@@ -794,11 +788,9 @@ KdKeyboardProc(DeviceIntPtr pDevice, int
 	    return BadImplementation;
         }
 
-#ifdef XINPUT
         xiclass = AtomFromName(XI_KEYBOARD);
         AssignTypeAndName(pDevice, xiclass,
                           ki->name ? ki->name : "Generic KDrive Keyboard");
-#endif
 
         KdResetInputMachine();
 
@@ -987,9 +979,7 @@ KdAddKeyboard (KdKeyboardInfo *ki)
         return !Success;
     }
 
-#ifdef XINPUT
     RegisterOtherDevice(ki->dixdev);
-#endif
 
 #ifdef DEBUG
     ErrorF("added keyboard %s with dix id %d\n", ki->name, ki->dixdev->id);
@@ -1058,9 +1048,7 @@ KdAddPointer (KdPointerInfo *pi)
         return BadDevice;
     }
 
-#ifdef XINPUT
     RegisterOtherDevice(pi->dixdev);
-#endif
 
     for (prev = &kdPointers; *prev; prev = &(*prev)->next);
     *prev = pi;
diff-tree 0514d53e10b3521bb708a9cbde4bab525248eadb (from b1debebf8fe20ded20ba27e871fd1a6a9de029e3)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Oct 25 01:10:44 2006 +0300

    xfree86: remove motion history handling
    Remove motion history handling, as we now deal with this in the DIX.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 36f2362..915a219 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -138,13 +138,6 @@ xf86ProcessCommonOptions(LocalDevicePtr 
     } else {
         xf86Msg(X_CONFIG, "%s: doesn't report drag events\n", local->name);
     }
-    
-    local->history_size = xf86SetIntOption(list, "HistorySize", 0);
-
-    if (local->history_size > 0) {
-        xf86Msg(X_CONFIG, "%s: has a history of %d motions\n", local->name,
-                local->history_size);
-    }
 }
 
 void
@@ -736,57 +729,6 @@ xf86PostKeyboardEvent(DeviceIntPtr      
         mieqEnqueue(device, xf86Events + i);
 }
 
-/* 
- * Motion history management.
- */
-
-_X_EXPORT void
-xf86MotionHistoryAllocate(LocalDevicePtr	local)
-{
-    ValuatorClassPtr	valuator = local->dev->valuator;
-    
-    if (!HAS_MOTION_HISTORY(local))
-        return;
-    if (local->motion_history) xfree(local->motion_history);
-    local->motion_history = xalloc((sizeof(INT32) * valuator->numAxes + sizeof(Time))
-                                   * valuator->numMotionEvents);
-    local->first = 0;
-    local->last	 = 0;
-}
-
-_X_EXPORT int
-xf86GetMotionEvents(DeviceIntPtr	dev,
-                    xTimecoord		*buff,
-                    unsigned long	start,
-                    unsigned long	stop,
-                    ScreenPtr		pScreen)
-{
-    LocalDevicePtr	local	 = (LocalDevicePtr)dev->public.devicePrivate;
-    ValuatorClassPtr	valuator = dev->valuator;
-    int			num  	 = 0;
-    int			loop	 = local->first;
-    int			size;
-    Time		current;
-    
-    if (!HAS_MOTION_HISTORY(local))
-        return 0;
-
-    size = (sizeof(INT32) * valuator->numAxes + sizeof(Time));
-
-    while (loop != local->last) {
-        current = *(Time*)(((char *)local->motion_history)+loop*size);
-        if (current > stop)
-            return num;
-        if (current >= start) {
-            memcpy(((char *)buff)+size*num,
-                   ((char *)local->motion_history)+loop*size, size);
-            num++;
-        }
-        loop = (loop + 1) % valuator->numMotionEvents;
-    }
-    return num;
-}
-
 _X_EXPORT LocalDevicePtr
 xf86FirstLocalDevice()
 {
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 73dcdb7..fe65643 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -86,10 +86,6 @@
 #define XI_PRIVATE(dev) \
 	(((LocalDevicePtr)((dev)->public.devicePrivate))->private)
 
-#ifdef HAS_MOTION_HISTORY
-#undef HAS_MOTION_HISTORY
-#endif
-#define HAS_MOTION_HISTORY(local) ((local)->dev->valuator && (local)->dev->valuator->numMotionEvents)
 
 #ifdef XINPUT
 /* This holds the input driver entry and module information. */
@@ -138,9 +134,6 @@ typedef struct _LocalDeviceRec {
     DeviceIntPtr	    dev;
     pointer		    private;
     int			    private_flags;
-    pointer		    motion_history;
-    ValuatorMotionProcPtr   motion_history_proc;
-    unsigned int	    history_size;   /* only for configuration purpose */
     unsigned int	    first;
     unsigned int	    last;
     int			    old_x;
@@ -176,10 +169,6 @@ void xf86PostKeyEvent(DeviceIntPtr devic
 		      ...);
 void xf86PostKeyboardEvent(DeviceIntPtr device, unsigned int key_code,
                            int is_down);
-void xf86MotionHistoryAllocate(LocalDevicePtr local);
-int xf86GetMotionEvents(DeviceIntPtr dev, xTimecoord *buff,
-			unsigned long start, unsigned long stop,
-			ScreenPtr pScreen);
 void xf86XinputFinalizeInit(DeviceIntPtr dev);
 void xf86ActivateDevice(LocalDevicePtr local);
 Bool xf86CheckButton(int button, int down);
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 8e39373..3051ded 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -697,8 +697,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86PostButtonEvent)
     SYMFUNC(xf86PostKeyEvent)
     SYMFUNC(xf86PostKeyboardEvent)
-    SYMFUNC(xf86GetMotionEvents)
-    SYMFUNC(xf86MotionHistoryAllocate)
     SYMFUNC(xf86FirstLocalDevice)
     SYMFUNC(xf86ActivateDevice)
     SYMFUNC(xf86XInputSetScreen)
diff-tree b1debebf8fe20ded20ba27e871fd1a6a9de029e3 (from b9e180e632d04bf685ade9e32bd0b20882794486)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Oct 25 01:10:20 2006 +0300

    mi: remove mi motion history
    This is now unneeded as we do motion history in the DIX.

diff --git a/hw/xfree86/loader/misym.c b/hw/xfree86/loader/misym.c
index 3f959fa..46d6a02 100644
--- a/hw/xfree86/loader/misym.c
+++ b/hw/xfree86/loader/misym.c
@@ -191,8 +191,6 @@ _X_HIDDEN void *miLookupTab[] = {
     SYMFUNC(miSegregateChildren)
     SYMFUNC(miHookInitVisuals)
     SYMFUNC(miPointerAbsoluteCursor)
-    SYMFUNC(miPointerGetMotionEvents)
-    SYMFUNC(miPointerGetMotionBufferSize)
     SYMFUNC(miOverlayCopyUnderlay)
     SYMFUNC(miOverlaySetTransFunction)
     SYMFUNC(miOverlayCollectUnderlayRegions)
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 7f850ad..679b760 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -128,7 +128,6 @@ miPointerInitialize (pScreen, spriteFunc
     miPointer.confined = FALSE;
     miPointer.x = 0;
     miPointer.y = 0;
-    miPointer.history_start = miPointer.history_end = 0;
     return TRUE;
 }
 
@@ -267,39 +266,6 @@ miPointerWarpCursor (pScreen, x, y)
  * Pointer/CursorDisplay interface routines
  */
 
-_X_EXPORT int
-miPointerGetMotionBufferSize ()
-{
-    return MOTION_SIZE;
-}
-
-_X_EXPORT int
-miPointerGetMotionEvents (pPtr, coords, start, stop, pScreen)
-    DeviceIntPtr    pPtr;
-    xTimecoord	    *coords;
-    unsigned long   start, stop;
-    ScreenPtr	    pScreen;
-{
-    int		    i;
-    int		    count = 0;
-    miHistoryPtr    h;
-
-    for (i = miPointer.history_start; i != miPointer.history_end;)
-    {
-	h = &miPointer.history[i];
-	if (h->event.time >= stop)
-	    break;
-	if (h->event.time >= start)
-	{
-	    *coords++ = h->event;
-	    count++;
-	}
-	if (++i == MOTION_SIZE) i = 0;
-    }
-    return count;
-}
-
-    
 /*
  * miPointerUpdate
  *
@@ -518,44 +484,4 @@ miPointerMoved (DeviceIntPtr pDev, Scree
 	if(!miPointer.pCursor->bits->emptyMask)
 	    (*pScreenPriv->spriteFuncs->MoveCursor) (pScreen, x, y);
     }
-
-    miPointerUpdateHistory(pDev, pScreen, x, y, time);
-}
-
-/* The pointer has moved to x, y; update the motion history. */
-void
-miPointerUpdateHistory (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
-                        unsigned long time)
-{
-    miHistoryPtr	history;
-    int			prev, end, start;
-
-    miPointer.x = x;
-    miPointer.y = y;
-    miPointer.pScreen = pScreen;
-
-    end = miPointer.history_end;
-    start = miPointer.history_start;
-    prev = end - 1;
-    if (end == 0)
-	prev = MOTION_SIZE - 1;
-    history = &miPointer.history[prev];
-    if (end == start || history->event.time != time)
-    {
-    	history = &miPointer.history[end];
-    	if (++end == MOTION_SIZE) 
-	    end = 0;
-    	if (end == start)
-    	{
-	    start = end + 1;
-	    if (start == MOTION_SIZE)
-	    	start = 0;
-	    miPointer.history_start = start;
-    	}
-    	miPointer.history_end = end;
-    }
-    history->event.x = x;
-    history->event.y = y;
-    history->event.time = time;
-    history->pScreen = pScreen;
 }
diff --git a/mi/mipointer.h b/mi/mipointer.h
index 21b55fa..30e8944 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -181,14 +181,6 @@ extern void miPointerMoved(
     int y,
     unsigned long time);
 
-/* Updates the event history. */
-extern void miPointerUpdateHistory(
-    DeviceIntPtr pDev,
-    ScreenPtr pScreen,
-    int x,
-    int y,
-    unsigned long time);
-
 extern int miPointerScreenIndex;
 
 #endif /* MIPOINTER_H */
diff --git a/mi/mipointrst.h b/mi/mipointrst.h
index 2ebf327..a80c52e 100644
--- a/mi/mipointrst.h
+++ b/mi/mipointrst.h
@@ -32,13 +32,6 @@ in this Software without prior written a
 #include "mipointer.h"
 #include "scrnintstr.h"
 
-#define MOTION_SIZE	256
-
-typedef struct {
-    xTimecoord	    event;
-    ScreenPtr	    pScreen;
-} miHistoryRec, *miHistoryPtr;
-
 typedef struct {
     ScreenPtr		    pScreen;    /* current screen */
     ScreenPtr		    pSpriteScreen;/* screen containing current sprite */
@@ -48,8 +41,6 @@ typedef struct {
     Bool		    confined;	/* pointer can't change screens */
     int			    x, y;	/* hot spot location */
     int			    devx, devy;	/* sprite position */
-    miHistoryRec	    history[MOTION_SIZE];
-    int			    history_start, history_end;
 } miPointerRec, *miPointerPtr;
 
 typedef struct {
diff-tree b9e180e632d04bf685ade9e32bd0b20882794486 (from 5b38eb69cdaa154791c7f74e35dbe4d3256b19bd)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Oct 25 01:09:19 2006 +0300

    port all users to the new DIX motion history API
    Port KDrive, Xvfb, and Xnest, as well as the virtual core devices, to the
    new motion history API.  Make GetPointerEvents also update the history.

diff --git a/dix/devices.c b/dix/devices.c
index 86e1e7a..a5110ff 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -285,10 +285,9 @@ CorePointerProc(DeviceIntPtr pDev, int w
     case DEVICE_INIT:
         for (i = 1; i <= 32; i++)
             map[i] = i;
-        /* we don't keep history, for now. */
         InitPointerDeviceStruct((DevicePtr)pDev, map, 32,
-                                NULL, (PtrCtrlProcPtr)NoopDDA,
-                                0, 2);
+                                GetMotionHistory, (PtrCtrlProcPtr)NoopDDA,
+                                GetMotionHistorySize(), 2);
         pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
         pDev->valuator->lastx = pDev->valuator->axisVal[0];
         pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
diff --git a/dix/getevents.c b/dix/getevents.c
index 8e22ad6..0a228cd 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -591,6 +591,8 @@ GetPointerEvents(xEvent *events, DeviceI
     if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
         valuators[1 - first_valuator] = y;
 
+    updateMotionHistory(pDev, ms, first_valuator, num_valuators, valuators);
+
     if (pDev->coreEvents) {
         cp->valuator->lastx = x;
         cp->valuator->lasty = y;
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 78943e4..724f724 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -445,11 +445,10 @@ KdPointerProc(DeviceIntPtr pDevice, int 
         }
 
 	InitPointerDeviceStruct(pDev, pi->map, pi->nButtons,
-	    miPointerGetMotionEvents,
+	    GetMotionHistory,
 	    (PtrCtrlProcPtr)NoopDDA,
-	    miPointerGetMotionBufferSize(), pi->nAxes);
+	    GetMotionHistorySize(), pi->nAxes);
 
-#ifdef XINPUT
         if (pi->inputClass == KD_TOUCHSCREEN) {
             InitAbsoluteClassDeviceStruct(pDevice);
             xiclass = AtomFromName(XI_TOUCHSCREEN);
@@ -460,7 +459,6 @@ KdPointerProc(DeviceIntPtr pDevice, int 
 
         AssignTypeAndName(pi->dixdev, xiclass,
                           pi->name ? pi->name : "Generic KDrive Pointer");
-#endif
 
 	return Success;
 	
diff --git a/hw/vfb/InitInput.c b/hw/vfb/InitInput.c
index c0bfb55..9cb1c02 100644
--- a/hw/vfb/InitInput.c
+++ b/hw/vfb/InitInput.c
@@ -292,8 +292,8 @@ vfbMouseProc(DeviceIntPtr pDevice, int o
 	    map[1] = 1;
 	    map[2] = 2;
 	    map[3] = 3;
-	    InitPointerDeviceStruct(pDev, map, 3, miPointerGetMotionEvents,
-		(PtrCtrlProcPtr)NoopDDA, miPointerGetMotionBufferSize(), 2);
+	    InitPointerDeviceStruct(pDev, map, 3, GetMotionHistory,
+		(PtrCtrlProcPtr)NoopDDA, GetMotionHistorySize(), 2);
 	    break;
 
     case DEVICE_ON:
diff --git a/hw/xnest/Pointer.c b/hw/xnest/Pointer.c
index b5e45db..912b6fa 100644
--- a/hw/xnest/Pointer.c
+++ b/hw/xnest/Pointer.c
@@ -57,9 +57,9 @@ xnestPointerProc(DeviceIntPtr pDev, int 
       for (i = 0; i <= nmap; i++)
 	map[i] = i; /* buttons are already mapped */
       InitPointerDeviceStruct(&pDev->public, map, nmap,
-			      miPointerGetMotionEvents,
+			      GetMotionHistory,
 			      xnestChangePointerControl,
-			      miPointerGetMotionBufferSize(), 2);
+			      GetMotionHistorySize(), 2);
       break;
     case DEVICE_ON: 
       xnestEventMask |= XNEST_POINTER_EVENT_MASK;
diff-tree 5b38eb69cdaa154791c7f74e35dbe4d3256b19bd (from 11fb58be77ac163844e494b2b0a260cf28a7ecd1)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Oct 25 01:08:29 2006 +0300

    dix: add motion history support
    Add motion history support (sort of based on the XFree86 DDX's
    implementation) to the DIX.

diff --git a/dix/devices.c b/dix/devices.c
index 5ea7b14..86e1e7a 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -793,7 +793,12 @@ InitValuatorClassDeviceStruct(DeviceIntP
 				    numAxes * sizeof(unsigned int));
     if (!valc)
 	return FALSE;
+
+    valc->motion = NULL;
+    valc->first_motion = 0;
+    valc->last_motion = 0;
     valc->GetMotionProc = motionProc;
+
     valc->numMotionEvents = numMotionEvents;
     valc->motionHintWindow = NullWindow;
     valc->numAxes = numAxes;
@@ -805,6 +810,11 @@ InitValuatorClassDeviceStruct(DeviceIntP
     valc->dxremaind = 0;
     valc->dyremaind = 0;
     dev->valuator = valc;
+
+    /* biggest hack ever. */
+    if (motionProc == GetMotionHistory)
+        AllocateMotionHistory(dev);
+
     for (i=0; i<numAxes; i++) {
         InitValuatorAxisStruct(dev, i, 0, -1, 0, 0, 0);
 	valc->axisVal[i]=0;
diff --git a/dix/getevents.c b/dix/getevents.c
index bec3c3b..8e22ad6 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -66,6 +66,9 @@ extern Bool XkbCopyKeymap(XkbDescPtr src
 /* Maximum number of valuators, divided by six, rounded up. */
 #define MAX_VALUATOR_EVENTS 6
 
+/* Number of motion history events to store. */
+#define MOTION_HISTORY_SIZE 256
+
 /**
  * Returns the maximum number of events GetKeyboardEvents,
  * GetKeyboardValuatorEvents, and GetPointerEvents will ever return.
@@ -368,6 +371,108 @@ getValuatorEvents(xEvent *events, Device
 }
 
 /**
+ * Pick some arbitrary size for Xi motion history.
+ */
+_X_EXPORT int
+GetMotionHistorySize()
+{
+    return MOTION_HISTORY_SIZE;
+}
+
+/**
+ * Allocate the motion history buffer.
+ */
+_X_EXPORT void
+AllocateMotionHistory(DeviceIntPtr pDev)
+{
+    if (pDev->valuator->motion)
+        xfree(pDev->valuator->motion);
+
+    if (pDev->valuator->numMotionEvents < 1)
+        return;
+
+    pDev->valuator->motion = xalloc(((sizeof(INT32) * pDev->valuator->numAxes) +
+                                     sizeof(Time)) *
+                                    pDev->valuator->numMotionEvents);
+    pDev->valuator->first_motion = 0;
+    pDev->valuator->last_motion = 0;
+}
+
+/**
+ * Dump the motion history between start and stop into the supplied buffer.
+ * Only records the event for a given screen in theory, but in practice, we
+ * sort of ignore this.
+ */
+_X_EXPORT int
+GetMotionHistory(DeviceIntPtr pDev, xTimecoord *buff, unsigned long start,
+                 unsigned long stop, ScreenPtr pScreen)
+{
+    int i = 0, ret = 0;
+    /* The size of a single motion event. */
+    int size = (sizeof(INT32) * pDev->valuator->numAxes) + sizeof(Time);
+    Time current;
+    char *ibuff = NULL, *obuff = (char *) buff;
+
+    if (!pDev->valuator || !pDev->valuator->numMotionEvents)
+        return 0;
+
+    for (i = pDev->valuator->first_motion;
+         i != pDev->valuator->last_motion;
+         i = (i + 1) % pDev->valuator->numMotionEvents) {
+        /* We index the input buffer by which element we're accessing, which
+         * is not monotonic, and the output buffer by how many events we've
+         * written so far. */
+        ibuff = (char *) pDev->valuator->motion + (i * size);
+        memcpy(&current, ibuff, sizeof(Time));
+
+        if (current > stop) {
+            return ret;
+        }
+        else if (current >= start) {
+            memcpy(obuff, ibuff, size);
+            obuff += size;
+            ret++;
+        }
+    }
+
+    return ret;
+}
+
+/**
+ * Update the motion history for a specific device, with the list of
+ * valuators.
+ */
+static void
+updateMotionHistory(DeviceIntPtr pDev, CARD32 ms, int first_valuator,
+                    int num_valuators, int *valuators)
+{
+    char *buff = (char *) pDev->valuator->motion;
+
+    if (!pDev->valuator->numMotionEvents)
+        return;
+
+    buff += ((sizeof(INT32) * pDev->valuator->numAxes) + sizeof(CARD32)) *
+            pDev->valuator->last_motion;
+    memcpy(buff, &ms, sizeof(Time));
+
+    buff += sizeof(Time);
+    bzero(buff, sizeof(INT32) * pDev->valuator->numAxes);
+
+    buff += sizeof(INT32) * first_valuator;
+    memcpy(buff, valuators, sizeof(INT32) * num_valuators);
+
+    pDev->valuator->last_motion = (pDev->valuator->last_motion + 1) %
+                                  pDev->valuator->numMotionEvents;
+    
+    /* If we're wrapping around, just keep the circular buffer going. */
+    if (pDev->valuator->first_motion == pDev->valuator->last_motion)
+        pDev->valuator->first_motion = (pDev->valuator->first_motion + 1) %
+                                       pDev->valuator->numMotionEvents;
+
+    return;
+}
+
+/**
  * Generate a series of xEvents (returned in xE) representing pointer
  * motion, or button presses.  Xi and XKB-aware.
  *
diff --git a/include/input.h b/include/input.h
index f6ef337..3fe6944 100644
--- a/include/input.h
+++ b/include/input.h
@@ -418,6 +418,19 @@ extern int GetProximityEvents(
     int num_valuators,
     int *valuators);
 
+extern int GetMotionHistorySize(
+    void);
+
+extern void AllocateMotionHistory(
+    DeviceIntPtr pDev);
+
+extern int GetMotionHistory(
+    DeviceIntPtr pDev,
+    xTimecoord *buff,
+    unsigned long start,
+    unsigned long stop,
+    ScreenPtr pScreen);
+
 extern void SwitchCoreKeyboard(DeviceIntPtr pDev);
 extern void SwitchCorePointer(DeviceIntPtr pDev);
 
diff --git a/include/inputstr.h b/include/inputstr.h
index 4a48c9d..ada94e6 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -146,15 +146,20 @@ typedef struct _AxisInfo {
 
 typedef struct _ValuatorClassRec {
     ValuatorMotionProcPtr GetMotionProc;
-    int		 	numMotionEvents;
-    WindowPtr    	motionHintWindow;
-    AxisInfoPtr 	axes;
-    unsigned short	numAxes;
-    int			*axisVal;
-    CARD8	 	mode;
-    int                 lastx, lasty; /* last event recorded, not posted to
-                                       * client; see dix/devices.c */
-    int                 dxremaind, dyremaind; /* for acceleration */
+    int		 	  numMotionEvents;
+    int                   first_motion;
+    int                   last_motion;
+    void                  *motion;
+
+    WindowPtr    	  motionHintWindow;
+
+    AxisInfoPtr 	  axes;
+    unsigned short	  numAxes;
+    int			  *axisVal;
+    int                   lastx, lasty; /* last event recorded, not posted to
+                                         * client; see dix/devices.c */
+    int                   dxremaind, dyremaind; /* for acceleration */
+    CARD8	 	  mode;
 } ValuatorClassRec, *ValuatorClassPtr;
 
 typedef struct _ButtonClassRec {
diff-tree 11fb58be77ac163844e494b2b0a260cf28a7ecd1 (from 2a74b8a91da1a98669993078f7fe9081f2d743ce)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Oct 25 01:07:36 2006 +0300

    miscellaneous warning fixes
    Use the correct type for time, and fix the mi prototype of EnqueueEvent.

diff --git a/dix/getevents.c b/dix/getevents.c
index 17a8cb4..bec3c3b 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -117,7 +117,8 @@ _X_EXPORT int
 GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
                           int key_code, int first_valuator,
                           int num_valuators, int *valuators) {
-    int numEvents = 0, ms = 0, i = 0;
+    int numEvents = 0, i = 0;
+    CARD32 ms = 0;
     int final_valuator = first_valuator + num_valuators;
     KeySym sym = pDev->key->curKeySyms.map[key_code *
                                            pDev->key->curKeySyms.mapWidth];
@@ -378,7 +379,8 @@ _X_EXPORT int
 GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
                  int flags, int first_valuator, int num_valuators,
                  int *valuators) {
-    int num_events = 0, ms = 0, final_valuator = 0;
+    int num_events = 0, final_valuator = 0;
+    CARD32 ms = 0;
     deviceKeyButtonPointer *kbp = NULL;
     Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
     DeviceIntPtr cp = inputInfo.pointer;
diff --git a/mi/mipointer.h b/mi/mipointer.h
index 82ff045..21b55fa 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -73,6 +73,7 @@ typedef struct _miPointerScreenFuncRec {
                     int  /* y */
                     );
     void	(*EnqueueEvent)(
+                    DeviceIntPtr /* pDev */,
                     xEventPtr /* event */
                     );
     void	(*NewEventScreen)(
diff-tree 2a74b8a91da1a98669993078f7fe9081f2d743ce (from 37d1fffe79c35ada056ce9a56292c000014fe48a)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Oct 25 01:04:53 2006 +0300

    xfree86: re-bump input abi to 1.0, yet again

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index cf404fb..3c3247e 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -85,7 +85,7 @@ typedef enum {
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 3)
 #define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(1, 1)
-#define ABI_XINPUT_VERSION	SET_ABI_VERSION(0, 6)
+#define ABI_XINPUT_VERSION	SET_ABI_VERSION(1, 0)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(0, 3)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 5)
 
diff-tree 37d1fffe79c35ada056ce9a56292c000014fe48a (from 9f9ac01a819ee96fb5be5d7d346c91f461bf3979)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Oct 24 23:06:57 2006 +0300

    inputstr: try to keep device structs the same size
    Try to make sure DeviceIntRec and friends stay the same size,
    regardless of whether or not XKB is enabled.

diff --git a/include/inputstr.h b/include/inputstr.h
index 1df66da..4a48c9d 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -131,6 +131,8 @@ typedef struct _KeyClassRec {
     unsigned short	prev_state;
 #ifdef XKB
     struct _XkbSrvInfo *xkbInfo;
+#else
+    void               *pad0;
 #endif
 } KeyClassRec, *KeyClassPtr;
 
@@ -163,7 +165,9 @@ typedef struct _ButtonClassRec {
     CARD8		down[DOWN_LENGTH];
     CARD8		map[MAP_LENGTH];
 #ifdef XKB
-    union _XkbAction *	xkb_acts;
+    union _XkbAction    *xkb_acts;
+#else
+    void                *pad0;
 #endif
 } ButtonClassRec, *ButtonClassPtr;
 
@@ -214,6 +218,8 @@ typedef struct _KbdFeedbackClassRec {
     KbdFeedbackPtr	next;
 #ifdef XKB
     struct _XkbSrvLedInfo *xkb_sli;
+#else
+    void                *pad0;
 #endif
 } KbdFeedbackClassRec;
 
@@ -248,6 +254,8 @@ typedef struct _LedFeedbackClassRec {
     LedFeedbackPtr	next;
 #ifdef XKB
     struct _XkbSrvLedInfo *xkb_sli;
+#else
+    void                *pad0;
 #endif
 } LedFeedbackClassRec;
 
@@ -309,7 +317,9 @@ typedef struct _DeviceIntRec {
     BellFeedbackPtr	bell;
     LedFeedbackPtr	leds;
 #ifdef XKB
-    struct _XkbInterest *	xkb_interest;
+    struct _XkbInterest *xkb_interest;
+#else
+    void                *pad0;
 #endif
     DevUnion		*devPrivates;
     int			nPrivates;
diff-tree 9f9ac01a819ee96fb5be5d7d346c91f461bf3979 (from 0cd6a3d8efb5cc1ce4f85ab95bcdf4fb66c7245d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Oct 24 23:01:05 2006 +0300

    inputstr: fix indentation

diff --git a/include/inputstr.h b/include/inputstr.h
index 2c64e0d..1df66da 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -93,15 +93,15 @@ typedef struct _OtherInputMasks {
  */
 
 #define MasksPerDetailMask 8		/* 256 keycodes and 256 possible
-						modifier combinations, but only	
-						3 buttons. */
+                                           modifier combinations, but only	
+                                           3 buttons. */
 
-  typedef struct _DetailRec {		/* Grab details may be bit masks */
-	unsigned short exact;
-	Mask *pMask;
-  } DetailRec;
+typedef struct _DetailRec {		/* Grab details may be bit masks */
+    unsigned short      exact;
+    Mask                *pMask;
+} DetailRec;
 
-  typedef struct _GrabRec {
+typedef struct _GrabRec {
     GrabPtr		next;		/* for chain of passive grabs */
     XID			resource;
     DeviceIntPtr	device;
diff-tree 0cd6a3d8efb5cc1ce4f85ab95bcdf4fb66c7245d (from cccf7ae0ff24d0c84b5144c457f3f86bbbc36e12)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 06:56:07 2006 +0300

    xfree86/input: add proximity support, free valuators
    Re-add support for proximity events, and remember to both va_end our
    varargs, and free our valuators.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index ebd5f72..36f2362 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -585,9 +585,9 @@ xf86PostMotionEvent(DeviceIntPtr	device,
     valuators = xcalloc(sizeof(int), num_valuators);
 
     va_start(var, num_valuators);
-    for (i = 0; i < num_valuators; i++) {
+    for (i = 0; i < num_valuators; i++)
         valuators[i] = va_arg(var, int);
-    }
+    va_end(var);
 
     if (!xf86Events)
         xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
@@ -600,6 +600,8 @@ xf86PostMotionEvent(DeviceIntPtr	device,
 
     for (i = 0; i < nevents; i++)
         mieqEnqueue(device, xf86Events + i);
+
+    xfree(valuators);
 }
 
 _X_EXPORT void
@@ -609,88 +611,28 @@ xf86PostProximityEvent(DeviceIntPtr	devi
                        int		num_valuators,
                        ...)
 {
-    va_list			var;
-    int				loop;
-    Bool			is_core = device->coreEvents;
-
-    ErrorF("xf86PostProximityEvent: no-op event called\n");
-
-#if 0
-    DBG(5, ErrorF("xf86PostProximityEvent BEGIN 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
-                  device, device->name, is_in ? "true" : "false",
-                  is_core ? "True" : "False",
-                  is_absolute ? "True" : "False"));
-    
-    if (is_core) {
-        return;
-    }
-  
-    if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
-        ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
-        return;
-    }
+    va_list var;
+    int i, nevents, *valuators = NULL;
 
-    xev->type = is_in ? ProximityIn : ProximityOut;
-    xev->detail = 0;
-    xev->deviceid = device->id | MORE_EVENTS;
-        
-    xv->type = DeviceValuator;
-    xv->deviceid = device->id;
-    xv->device_state = 0;
+    valuators = xcalloc(sizeof(int), num_valuators);
 
-    if ((device->valuator->mode & 1) == Relative) {
-        num_valuators = 0;
-    }
-  
-    if (num_valuators != 0) {
-        int	*axisvals = val->axisVal;
-            
-        va_start(var, num_valuators);
+    va_start(var, num_valuators);
+    for (i = 0; i < num_valuators; i++)
+        valuators[i] = va_arg(var, int);
+    va_end(var);
 
-        for(loop=0; loop<num_valuators; loop++) {
-            switch (loop % 6) {
-            case 0:
-                xv->valuator0 = is_absolute ? va_arg(var, int) : axisvals[loop]; 
-                break;
-            case 1:
-                xv->valuator1 = is_absolute ? va_arg(var, int) : axisvals[loop];
-                break;
-            case 2:
-                xv->valuator2 = is_absolute ? va_arg(var, int) : axisvals[loop];
-                break;
-            case 3:
-                xv->valuator3 = is_absolute ? va_arg(var, int) : axisvals[loop];
-                break;
-            case 4:
-                xv->valuator4 = is_absolute ? va_arg(var, int) : axisvals[loop];
-                break;
-            case 5:
-                xv->valuator5 = is_absolute ? va_arg(var, int) : axisvals[loop];
-                break;
-            }
-            if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
-                xf86Info.lastEventTime = xev->time = GetTimeInMillis();
-
-                xv->num_valuators = (loop % 6) + 1;
-                xv->first_valuator = first_valuator + (loop / 6) * 6;
-                mieqEnqueue(xE);
-            }
-        }
-        va_end(var);
-    }
-    else {
-        /* no valuator */
-        xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+    if (!xf86Events)
+        xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+    if (!xf86Events)
+        FatalError("Couldn't allocate event store\n");
 
-        xv->num_valuators = 0;
-        xv->first_valuator = 0;
-        mieqEnqueue(xE);
-    }
-    DBG(5, ErrorF("xf86PostProximityEvent END   0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
-                  device, device->name, is_in ? "true" : "false",
-                  is_core ? "True" : "False",
-                  is_absolute ? "True" : "False"));
-#endif
+    nevents = GetProximityEvents(xf86Events, device,
+                                 is_in ? ProximityIn : ProximityOut, 
+                                 first_valuator, num_valuators, valuators);
+    for (i = 0; i < nevents; i++)
+        mieqEnqueue(device, xf86Events + i);
+
+    xfree(valuators);
 }
 
 _X_EXPORT void
@@ -709,9 +651,9 @@ xf86PostButtonEvent(DeviceIntPtr	device,
     valuators = xcalloc(sizeof(int), num_valuators);
 
     va_start(var, num_valuators);
-    for (i = 0; i < num_valuators; i++) {
+    for (i = 0; i < num_valuators; i++)
         valuators[i] = va_arg(var, int);
-    }
+    va_end(var);
 
     if (!xf86Events)
         xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
@@ -726,6 +668,8 @@ xf86PostButtonEvent(DeviceIntPtr	device,
 
     for (i = 0; i < nevents; i++)
         mieqEnqueue(device, xf86Events + i);
+
+    xfree(valuators);
 }
 
 _X_EXPORT void
@@ -761,6 +705,7 @@ xf86PostKeyEvent(DeviceIntPtr	device,
                                             is_down ? KeyPress : KeyRelease,
                                             key_code, first_valuator,
                                             num_valuators, valuators);
+        xfree(valuators);
     }
     else {
         nevents = GetKeyboardEvents(xf86Events, device,
diff-tree cccf7ae0ff24d0c84b5144c457f3f86bbbc36e12 (from 35fa4ac12b3da33f81e2a12bc9661ed075f323ed)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 06:55:21 2006 +0300

    GetProximityEvents: add (untested) function
    Add untested first guess at what GetProximityEvents should look like.

diff --git a/dix/getevents.c b/dix/getevents.c
index 802c4e6..17a8cb4 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -56,6 +56,7 @@ extern Bool XkbCopyKeymap(XkbDescPtr src
 #include "panoramiXsrv.h"
 #endif
 
+#include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
 #include "exglobals.h"
 #include "exevents.h"
@@ -533,6 +534,57 @@ GetPointerEvents(xEvent *events, DeviceI
 }
 
 /**
+ * Post ProximityIn/ProximityOut events, accompanied by valuators.
+ *
+ * events is not NULL-terminated; the return value is the number of events.
+ * The DDX is responsible for allocating the event structure in the first
+ * place via GetMaximumEventsNum(), and for freeing it.
+ */
+_X_EXPORT int
+GetProximityEvents(xEvent *events, DeviceIntPtr pDev, int type,
+                   int first_valuator, int num_valuators, int *valuators)
+{
+    int num_events = 0;
+    deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) events;
+
+    /* Sanity checks. */
+    if (type != ProximityIn && type != ProximityOut)
+        return 0;
+
+    if (!pDev->valuator)
+        return 0;
+
+    /* Do we need to send a DeviceValuator event? */
+    if ((pDev->valuator->mode & 1) == Relative)
+        num_valuators = 0;
+
+    if (num_valuators) {
+        if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS)
+            num_valuators = MAX_VALUATOR_EVENTS * 6;
+        num_events += ((num_valuators - 1) / 6) + 1;
+    }
+
+    /* You fail. */
+    if (first_valuator < 0 ||
+        (num_valuators + first_valuator) > pDev->valuator->numAxes)
+        return 0;
+
+    kbp->type = type;
+    kbp->deviceid = pDev->id;
+    kbp->detail = 0;
+    kbp->time = GetTimeInMillis();
+
+    if (num_valuators) {
+        kbp->deviceid |= MORE_EVENTS;
+        events++;
+        events = getValuatorEvents(events, pDev, first_valuator,
+                                   num_valuators, valuators);
+    }
+
+    return num_events;
+}
+
+/**
  * Note that pDev was the last device to send a core event.  This function
  * copies the complete keymap from the originating device to the core
  * device, and makes sure the appropriate notifications are generated.
diff --git a/include/input.h b/include/input.h
index 4acc856..f6ef337 100644
--- a/include/input.h
+++ b/include/input.h
@@ -410,6 +410,14 @@ extern int GetKeyboardValuatorEvents(
     int num_valuator,
     int *valuators);
 
+extern int GetProximityEvents(
+    xEvent *events,
+    DeviceIntPtr pDev,
+    int type,
+    int first_valuator,
+    int num_valuators,
+    int *valuators);
+
 extern void SwitchCoreKeyboard(DeviceIntPtr pDev);
 extern void SwitchCorePointer(DeviceIntPtr pDev);
 
diff-tree 35fa4ac12b3da33f81e2a12bc9661ed075f323ed (from a7c2d9a15dc2ff253bb69c3b0738ad993521b9c7)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 06:23:45 2006 +0300

    GetPointerEvents: break into separate functions
    Break out clipAxis, clipValuators, and getValuatorEvents, into
    separate functions, to be used by the proximity event code.

diff --git a/dix/getevents.c b/dix/getevents.c
index ca199c6..802c4e6 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -303,6 +303,69 @@ acceleratePointer(DeviceIntPtr pDev, int
 }
 
 /**
+ * Clip an axis to its bounds.
+ */
+static void
+clipAxis(DeviceIntPtr pDev, int axisNum, int *val)
+{
+    AxisInfoPtr axes = pDev->valuator->axes + axisNum;
+
+    if (*val < axes->min_value)
+        *val = axes->min_value;
+    if (axes->max_value >= 0 && *val > axes->max_value)
+        *val = axes->max_value;
+}
+
+/**
+ * Compare the list of valuators against the limits for each axis, and clip
+ * them to those bounds.
+ */
+static void
+clipValuators(DeviceIntPtr pDev, int first_valuator, int num_valuators,
+              int *valuators)
+{
+    AxisInfoPtr axes = pDev->valuator->axes + first_valuator;
+    int i;
+
+    for (i = 0; i < num_valuators; i++, axes++)
+        clipAxis(pDev, i + first_valuator, &(valuators[i]));
+}
+
+/**
+ * Fills events with valuator events for pDev, as given by the other
+ * parameters.
+ */
+static xEvent *
+getValuatorEvents(xEvent *events, DeviceIntPtr pDev, int first_valuator,
+                  int num_valuators, int *valuators) {
+    deviceValuator *xv = (deviceValuator *) events;
+    int i = 0, final_valuator = first_valuator + num_valuators;
+
+    for (i = first_valuator; i < final_valuator; i += 6, xv++, events++) {
+        xv->type = DeviceValuator;
+        xv->first_valuator = i;
+        xv->num_valuators = num_valuators;
+        xv->deviceid = pDev->id;
+        switch (final_valuator - i) {
+        case 6:
+            xv->valuator5 = valuators[i + 5];
+        case 5:
+            xv->valuator4 = valuators[i + 4];
+        case 4:
+            xv->valuator3 = valuators[i + 3];
+        case 3:
+            xv->valuator2 = valuators[i + 2];
+        case 2:
+            xv->valuator1 = valuators[i + 1];
+        case 1:
+            xv->valuator0 = valuators[i];
+        }
+    }
+
+    return events;
+}
+
+/**
  * Generate a series of xEvents (returned in xE) representing pointer
  * motion, or button presses.  Xi and XKB-aware.
  *
@@ -314,22 +377,17 @@ _X_EXPORT int
 GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
                  int flags, int first_valuator, int num_valuators,
                  int *valuators) {
-    int num_events = 0, ms = 0, final_valuator = 0, i = 0;
+    int num_events = 0, ms = 0, final_valuator = 0;
     deviceKeyButtonPointer *kbp = NULL;
-    deviceValuator *xv = NULL;
-    AxisInfoPtr axes = NULL;
     Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
     DeviceIntPtr cp = inputInfo.pointer;
     int x = 0, y = 0;
 
+    /* Sanity checks. */
     if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
         return 0;
 
-    if (!pDev->button || (pDev->coreEvents && (!cp->button || !cp->valuator)))
-        return 0;
-
-    /* You fail. */
-    if (first_valuator < 0)
+    if ((type == ButtonPress || type == ButtonRelease) && !pDev->button)
         return 0;
 
     if (pDev->coreEvents)
@@ -339,9 +397,9 @@ GetPointerEvents(xEvent *events, DeviceI
 
     /* Do we need to send a DeviceValuator event? */
     if ((num_valuators + first_valuator) >= 2 && sendValuators) {
-        if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS)
-            num_valuators = MAX_VALUATOR_EVENTS;
-        num_events += (num_valuators / 6) + 1;
+        if ((((num_valuators - 1) / 6) + 1) > MAX_VALUATOR_EVENTS)
+            num_valuators = MAX_VALUATOR_EVENTS * 6;
+        num_events += ((num_valuators - 1) / 6) + 1;
     }
     else if (type == MotionNotify && num_valuators <= 0) {
         return 0;
@@ -349,6 +407,10 @@ GetPointerEvents(xEvent *events, DeviceI
 
     final_valuator = num_valuators + first_valuator;
 
+    /* You fail. */
+    if (first_valuator < 0 || final_valuator > pDev->valuator->numAxes)
+        return 0;
+
     ms = GetTimeInMillis();
 
     kbp = (deviceKeyButtonPointer *) events;
@@ -405,24 +467,22 @@ GetPointerEvents(xEvent *events, DeviceI
         }
     }
 
-
-    axes = pDev->valuator->axes;
-    if (x < axes->min_value)
-        x = axes->min_value;
-    if (axes->max_value > 0 && x > axes->max_value)
-        x = axes->max_value;
-
-    axes++;
-    if (y < axes->min_value)
-        y = axes->min_value;
-    if (axes->max_value > 0 && y > axes->max_value)
-        y = axes->max_value;
+    /* Clip both x and y to the defined limits (usually co-ord space limit). */
+    clipAxis(pDev, 0, &x);
+    clipAxis(pDev, 1, &y);
 
     /* This takes care of crossing screens for us, as well as clipping
      * to the current screen.  Right now, we only have one history buffer,
      * so we don't set this for both the device and core.*/
     miPointerSetPosition(pDev, &x, &y, ms);
 
+    /* Drop x and y back into the valuators list, if they were originally
+     * present. */
+    if (first_valuator == 0 && num_valuators >= 1)
+        valuators[0] = x;
+    if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
+        valuators[1 - first_valuator] = y;
+
     if (pDev->coreEvents) {
         cp->valuator->lastx = x;
         cp->valuator->lasty = y;
@@ -446,39 +506,13 @@ GetPointerEvents(xEvent *events, DeviceI
 
     if (final_valuator > 2 && sendValuators) {
         kbp->deviceid |= MORE_EVENTS;
-        for (i = first_valuator; i < final_valuator; i += 6) {
-            xv = (deviceValuator *) ++events;
-            xv->type = DeviceValuator;
-            xv->first_valuator = i;
-            xv->num_valuators = num_valuators;
-            xv->deviceid = kbp->deviceid;
-            switch (final_valuator - i) {
-            case 6:
-                xv->valuator5 = valuators[i + 5];
-            case 5:
-                xv->valuator4 = valuators[i + 4];
-            case 4:
-                xv->valuator3 = valuators[i + 3];
-            case 3:
-                xv->valuator2 = valuators[i + 2];
-            case 2:
-                /* x and y may have been accelerated. */
-                if (i == 0)
-                    xv->valuator1 = kbp->root_y;
-                else
-                    xv->valuator1 = valuators[i + 1];
-            case 1:
-                /* x and y may have been accelerated. */
-                if (i == 0)
-                    xv->valuator0 = kbp->root_x;
-                else
-                    xv->valuator0 = valuators[i];
-            }
-        }
+        events++;
+        clipValuators(pDev, first_valuator, num_valuators, valuators);
+        events = getValuatorEvents(events, pDev, first_valuator,
+                                   num_valuators, valuators);
     }
 
     if (pDev->coreEvents) {
-        events++;
         events->u.u.type = type;
         events->u.keyButtonPointer.time = ms;
         events->u.keyButtonPointer.rootX = x;
@@ -562,7 +596,7 @@ SwitchCorePointer(DeviceIntPtr pDev)
 void
 PostSyntheticMotion(int x, int y, int screenNum, unsigned long time)
 {
-    xEvent xE = { 0, };
+    xEvent xE;
 
 #ifdef PANORAMIX
     /* Translate back to the sprite screen since processInputProc
@@ -574,6 +608,7 @@ PostSyntheticMotion(int x, int y, int sc
     }
 #endif
 
+    memset(&xE, 0, sizeof(xEvent));
     xE.u.u.type = MotionNotify;
     xE.u.keyButtonPointer.rootX = x;
     xE.u.keyButtonPointer.rootY = y;
diff-tree a7c2d9a15dc2ff253bb69c3b0738ad993521b9c7 (from c8f76fb3a473a022d497bd0acd6c84f58fc6efbe)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 06:08:27 2006 +0300

    kdrive: numerous warning fixes

diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 1cc2932..f29fdb9 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -619,8 +619,6 @@ KdProcessArgument (int argc, char **argv
 {
     KdCardInfo	    *card;
     KdScreenInfo    *screen;
-    KdPointerInfo   *pi;
-    KdKeyboardInfo  *ki;
 
     if (!strcmp (argv[i], "-card"))
     {
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 7f752e9..15d7031 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -816,6 +816,9 @@ void
 KdUnregisterFds (void *closure, Bool do_close);
 
 void
+KdUnregisterFd (void *closure, int fd, Bool do_close);
+
+void
 KdEnqueueKeyboardEvent(KdKeyboardInfo *ki, unsigned char scan_code,
                     unsigned char is_up);
 
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index c900266..78943e4 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -48,6 +48,7 @@
 #ifdef XINPUT
 #include <X11/extensions/XI.h>
 #include <X11/extensions/XIproto.h>
+#include "XIstubs.h" /* even though we don't use stubs.  cute, no? */
 #include "exevents.h"
 #include "extinit.h"
 #include "exglobals.h"
@@ -131,7 +132,7 @@ KdUnblockSigio (void)
     sigprocmask (SIG_UNBLOCK, &set, 0);
 }
 
-#ifdef DEBUG
+#ifdef DEBUG_SIGIO
 
 void
 KdAssertSigioBlocked (char *where)
@@ -244,7 +245,7 @@ KdUnregisterFd (void *closure, int fd, B
 
     for (i = 0; i < kdNumInputFds; i++) {
 	if (kdInputFds[i].closure == closure &&
-            kdInputFds[i].fd == fd) {
+            (fd == -1 || kdInputFds[i].fd == fd)) {
 	    if (kdInputEnabled)
 		KdRemoveFd (kdInputFds[i].fd);
 	    if (do_close)
@@ -258,6 +259,12 @@ KdUnregisterFd (void *closure, int fd, B
 }
 
 void
+KdUnregisterFds (void *closure, Bool do_close)
+{
+    KdUnregisterFd(closure, -1, do_close);
+}
+
+void
 KdDisableInput (void)
 {
     KdKeyboardInfo *ki;
@@ -348,7 +355,7 @@ KdEnableInput (void)
     KdUnblockSigio ();
 }
 
-KdKeyboardDriver *
+static KdKeyboardDriver *
 KdFindKeyboardDriver (char *name)
 {
     KdKeyboardDriver *ret;
@@ -365,7 +372,7 @@ KdFindKeyboardDriver (char *name)
     return NULL;
 }
 
-KdPointerDriver *
+static KdPointerDriver *
 KdFindPointerDriver (char *name)
 {
     KdPointerDriver *ret;
@@ -444,7 +451,7 @@ KdPointerProc(DeviceIntPtr pDevice, int 
 
 #ifdef XINPUT
         if (pi->inputClass == KD_TOUCHSCREEN) {
-            InitAbsoluteClassDeviceStruct(pDev);
+            InitAbsoluteClassDeviceStruct(pDevice);
             xiclass = AtomFromName(XI_TOUCHSCREEN);
         }
         else {
@@ -2261,7 +2268,8 @@ ChangeKeyboardDevice(DeviceIntPtr pOldDe
 }
 
 int
-ChangePointerDevice(DeviceIntPtr pOldDev, DeviceIntPtr pDev, int x, int y)
+ChangePointerDevice(DeviceIntPtr pOldDev, DeviceIntPtr pDev, unsigned char x,
+                    unsigned char y)
 {
     return BadDevice;
 }
@@ -2277,20 +2285,17 @@ OpenInputDevice(DeviceIntPtr pDev, Clien
         *status = Success;
 }
 
-int
+void
 CloseInputDevice(DeviceIntPtr pDev, ClientPtr client)
 {
-    if (!pDev)
-        return BadDevice;
-
-    return Success;
+    return;
 }
 
 /* We initialise all input devices at startup. */
-int
+void
 AddOtherInputDevices(void)
 {
-    return Success;
+    return;
 }
 
 /* At the moment, absolute/relative is up to the client. */
@@ -2396,4 +2401,6 @@ NewInputDeviceRequest(InputOption *optio
             return BadImplementation;
         }
     }
+
+    return Success;
 }
diff --git a/include/kdrive-config.h.in b/include/kdrive-config.h.in
index 2f454d7..3bc7792 100644
--- a/include/kdrive-config.h.in
+++ b/include/kdrive-config.h.in
@@ -25,4 +25,10 @@
 /* Verbose debugging output hilarity */
 #undef DEBUG
 
+/* Have the backtrace() function. */
+#undef HAVE_BACKTRACE
+
+/* Have execinfo.h for backtrace(). */
+#undef HAVE_EXECINFO_H
+
 #endif /* _KDRIVE_CONFIG_H_ */
diff-tree c8f76fb3a473a022d497bd0acd6c84f58fc6efbe (from c5b5b046e86b159a9d32451308f38246cc4587f7)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 05:12:15 2006 +0300

    xfree86/input: disallow pointer device changes, fix drag event calculation
    Don't allow users to change the core pointer.
    Fix xf86SendDragEvents to check the device button state, not the core
    pointer's.
    Remove unused xf86CheckButton.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index e1fa9c1..ebd5f72 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -107,7 +107,7 @@ xf86SendDragEvents(DeviceIntPtr	device)
 {
     LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
     
-    if (inputInfo.pointer->button->buttonsDown > 0)
+    if (device->button->buttonsDown > 0)
         return (local->flags & XI86_SEND_DRAG_EVENTS);
     else
         return (TRUE);
@@ -115,40 +115,6 @@ xf86SendDragEvents(DeviceIntPtr	device)
 
 /***********************************************************************
  *
- * xf86CheckButton --
- *	
- *	Test if the core pointer button state is coherent with
- * the button event to send.
- *
- ***********************************************************************
- */
-Bool
-xf86CheckButton(int	button,
-                int	down)
-{
-    int	check;
-    int bit = (1 << (button - 1));
-
-    /* XXX FIXME VERDAMMT */
-#if 0
-    check = xf86CoreButtonState & bit;
-    
-    DBG(5, ErrorF("xf86CheckButton "
-                  "button=%d down=%d state=%d check=%d returns ",
-                   button, down, xf86CoreButtonState, check));
-    if ((check && down) || (!check && !down)) {
-        DBG(5, ErrorF("FALSE\n"));
-        return FALSE;
-    }
-    xf86CoreButtonState ^= bit;
-
-    DBG(5, ErrorF("TRUE\n"));
-#endif
-    return TRUE;
-}
-
-/***********************************************************************
- *
  * xf86ProcessCommonOptions --
  * 
  *	Process global options.
@@ -377,30 +343,6 @@ ChangePointerDevice (
     axes_changed = FALSE;
    *************************************************************************/
 
-  /*
-   * We don't allow axis swap or other exotic features.
-   */
-  if (x == 0 && y == 1) {
-      LocalDevicePtr	old_local = (LocalDevicePtr)old_dev->public.devicePrivate;
-      LocalDevicePtr	new_local = (LocalDevicePtr)new_dev->public.devicePrivate;
-      
-      InitFocusClassDeviceStruct(old_dev);
-    
-      /* Restore Extended motion history information */
-      old_dev->valuator->GetMotionProc   = old_local->motion_history_proc;
-      old_dev->valuator->numMotionEvents = old_local->history_size;
-
-      /* Save Extended motion history information */
-      new_local->motion_history_proc = new_dev->valuator->GetMotionProc;
-      new_local->history_size	     = new_dev->valuator->numMotionEvents;
-      
-      /* Set Core motion history information */
-      new_dev->valuator->GetMotionProc   = miPointerGetMotionEvents;
-      new_dev->valuator->numMotionEvents = miPointerGetMotionBufferSize();
-      
-    return Success;
-  }
-  else
     return !Success;
 }
 
diff-tree c5b5b046e86b159a9d32451308f38246cc4587f7 (from parents)
Merge: fab1d37ecbeee9777ad1485b0cc62b55042d5014 948a97b97e93cee05a23f1f1ae699c5e181bc8ce
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:58:30 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree fab1d37ecbeee9777ad1485b0cc62b55042d5014 (from 523fe64ba16cf7a40f4095432d81300726d83e8d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:57:00 2006 +0300

    xfree86/options: don't blindly dereference NULL pointers
    Sure, conf_idev should be initialised, but if it's not, try to make the
    best of a bad situation.

diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
index 0a4c11d..7afb63a 100644
--- a/hw/xfree86/common/xf86Option.c
+++ b/hw/xfree86/common/xf86Option.c
@@ -142,14 +142,14 @@ xf86CollectInputOptions(InputInfoPtr pIn
     if (defaultOpts) {
 	pInfo->options = xf86OptionListCreate(defaultOpts, -1, 0);
     }
-    if (pInfo->conf_idev->commonOptions) {
+    if (pInfo->conf_idev && pInfo->conf_idev->commonOptions) {
 	tmp = xf86optionListDup(pInfo->conf_idev->commonOptions);
 	if (pInfo->options)
 	    pInfo->options = xf86optionListMerge(pInfo->options, tmp);
 	else
 	    pInfo->options = tmp;
     }
-    if (pInfo->conf_idev->extraOptions) {
+    if (pInfo->conf_idev && pInfo->conf_idev->extraOptions) {
 	tmp = xf86optionListDup(pInfo->conf_idev->extraOptions);
 	if (pInfo->options)
 	    pInfo->options = xf86optionListMerge(pInfo->options, tmp);
diff-tree 523fe64ba16cf7a40f4095432d81300726d83e8d (from 57f98e2b72d5c7fea93a9f6da86228ffb4856bf3)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:56:28 2006 +0300

    kdrive/lots of DDXes: make stubs use KdOsAddInputDrivers()
    In theory, removing LinuxPciScan should make these drivers OS-independent.

diff --git a/hw/kdrive/chips/chipsstub.c b/hw/kdrive/chips/chipsstub.c
index 3499a48..7fec1c7 100644
--- a/hw/kdrive/chips/chipsstub.c
+++ b/hw/kdrive/chips/chipsstub.c
@@ -48,7 +48,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/epson/epson13806stub.c b/hw/kdrive/epson/epson13806stub.c
index 125d902..7981782 100644
--- a/hw/kdrive/epson/epson13806stub.c
+++ b/hw/kdrive/epson/epson13806stub.c
@@ -53,10 +53,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
-#ifdef TOUCHSCREEN
-    KdAddMouseDriver (&TsFuncs);
-#endif
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 int
diff --git a/hw/kdrive/i810/i810stub.c b/hw/kdrive/i810/i810stub.c
index c195947..364d16b 100644
--- a/hw/kdrive/i810/i810stub.c
+++ b/hw/kdrive/i810/i810stub.c
@@ -73,7 +73,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/igs/igsstub.c b/hw/kdrive/igs/igsstub.c
index b0ce151..39c6fd4 100644
--- a/hw/kdrive/igs/igsstub.c
+++ b/hw/kdrive/igs/igsstub.c
@@ -56,7 +56,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/mach64/mach64stub.c b/hw/kdrive/mach64/mach64stub.c
index 60808c2..f3fef3c 100644
--- a/hw/kdrive/mach64/mach64stub.c
+++ b/hw/kdrive/mach64/mach64stub.c
@@ -56,7 +56,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/mga/mgastub.c b/hw/kdrive/mga/mgastub.c
index ebb40fd..5afbf7f 100644
--- a/hw/kdrive/mga/mgastub.c
+++ b/hw/kdrive/mga/mgastub.c
@@ -45,7 +45,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/neomagic/neomagicstub.c b/hw/kdrive/neomagic/neomagicstub.c
index 308f4a2..c7ec83b 100644
--- a/hw/kdrive/neomagic/neomagicstub.c
+++ b/hw/kdrive/neomagic/neomagicstub.c
@@ -51,10 +51,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
-#ifdef TOUCHSCREEN
-    KdAddMouseDriver (&TsFuncs);
-#endif
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/nvidia/nvidiastub.c b/hw/kdrive/nvidia/nvidiastub.c
index ea2dd0f..2309419 100644
--- a/hw/kdrive/nvidia/nvidiastub.c
+++ b/hw/kdrive/nvidia/nvidiastub.c
@@ -45,7 +45,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/pcmcia/pcmciastub.c b/hw/kdrive/pcmcia/pcmciastub.c
index c509553..a56d2cb 100644
--- a/hw/kdrive/pcmcia/pcmciastub.c
+++ b/hw/kdrive/pcmcia/pcmciastub.c
@@ -45,7 +45,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 extern pcmciaDisplayModeRec pcmciaDefaultModes[];
diff --git a/hw/kdrive/pm2/pm2stub.c b/hw/kdrive/pm2/pm2stub.c
index fe46951..1f824b3 100644
--- a/hw/kdrive/pm2/pm2stub.c
+++ b/hw/kdrive/pm2/pm2stub.c
@@ -32,7 +32,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/r128/r128stub.c b/hw/kdrive/r128/r128stub.c
index 221648d..dbf3c0e 100644
--- a/hw/kdrive/r128/r128stub.c
+++ b/hw/kdrive/r128/r128stub.c
@@ -48,7 +48,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/savage/s3stub.c b/hw/kdrive/savage/s3stub.c
index 41553e6..776f8da 100644
--- a/hw/kdrive/savage/s3stub.c
+++ b/hw/kdrive/savage/s3stub.c
@@ -60,12 +60,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-#ifdef VXWORKS
-    KdInitInput (&VxWorksMouseFuncs, &VxWorksKeyboardFuncs);
-#endif
-#ifdef linux
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
-#endif
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 extern int	s3CpuTimeout;
diff --git a/hw/kdrive/sis300/sis_stub.c b/hw/kdrive/sis300/sis_stub.c
index 7f2e482..8a4c06c 100644
--- a/hw/kdrive/sis300/sis_stub.c
+++ b/hw/kdrive/sis300/sis_stub.c
@@ -53,7 +53,8 @@ InitOutput(ScreenInfo *pScreenInfo, int 
 void
 InitInput(int argc, char **argv)
 {
-	KdInitInput(&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+        KdOsAddInputDrivers();
+	KdInitInput();
 }
 
 void
diff --git a/hw/kdrive/sis530/sisstub.c b/hw/kdrive/sis530/sisstub.c
index a377dd5..2375f65 100644
--- a/hw/kdrive/sis530/sisstub.c
+++ b/hw/kdrive/sis530/sisstub.c
@@ -53,7 +53,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/smi/smistub.c b/hw/kdrive/smi/smistub.c
index e0f33fe..1db6708 100644
--- a/hw/kdrive/smi/smistub.c
+++ b/hw/kdrive/smi/smistub.c
@@ -47,7 +47,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/trident/tridentstub.c b/hw/kdrive/trident/tridentstub.c
index ebfd7ee..650206a 100644
--- a/hw/kdrive/trident/tridentstub.c
+++ b/hw/kdrive/trident/tridentstub.c
@@ -49,7 +49,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/trio/s3stub.c b/hw/kdrive/trio/s3stub.c
index 68178ed..7531858 100644
--- a/hw/kdrive/trio/s3stub.c
+++ b/hw/kdrive/trio/s3stub.c
@@ -52,7 +52,8 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdOsAddInputDrivers ();
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/via/viastub.c b/hw/kdrive/via/viastub.c
index f63ee0d..1439010 100644
--- a/hw/kdrive/via/viastub.c
+++ b/hw/kdrive/via/viastub.c
@@ -87,7 +87,8 @@ InitOutput( ScreenInfo* pScreenInfo, int
 */
 void
 InitInput( int argc, char** argv ) {
-	KdInitInput( &LinuxMouseFuncs, &LinuxKeyboardFuncs );
+        KdOsAddInputDrivers();
+	KdInitInput();
 }
 
 /*
diff-tree 57f98e2b72d5c7fea93a9f6da86228ffb4856bf3 (from a6dc629052f0ad509cfa30e98217043a63c09552)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:55:41 2006 +0300

    kdrive/tslib: port to new absolute API, remove debugging
    Port to new absolute device (not touchscreen) API, and remove some
    leftover debugging.

diff --git a/hw/kdrive/linux/tslib.c b/hw/kdrive/linux/tslib.c
index bf2a3db..44b4b54 100644
--- a/hw/kdrive/linux/tslib.c
+++ b/hw/kdrive/linux/tslib.c
@@ -74,11 +74,8 @@ TsRead (int fd, void *closure)
     }
 
     while (ts_read(private->tsDev, &event, 1) == 1) {
-#ifdef DEBUG
-        ErrorF("[tslib] originally from (%d, %d)\n", event.x, event.y);
-#endif
         if (event.pressure) {
-            if (event.pressure > pi->dixdev->touchscreen->button_threshold) 
+            if (event.pressure > pi->dixdev->absolute->button_threshold) 
                 flags = KD_BUTTON_8;
             else
                 flags = KD_BUTTON_1;
@@ -109,9 +106,6 @@ TsRead (int fd, void *closure)
             y = private->lasty;
         }
 
-#ifdef DEBUG
-        ErrorF("event at (%lu, %lu), pressure is %d, sending flags %lu\n", x, y, event.pressure, flags);
-#endif
         KdEnqueuePointerEvent (pi, flags, x, y, event.pressure);
     }
 }
@@ -132,13 +126,9 @@ TslibEnable (KdPointerInfo *pi)
             close(private->fd);
         return BadAlloc;
     }
-    if (pi->dixdev && pi->dixdev->touchscreen &&
-        pi->dixdev->touchscreen->button_threshold == 0)
-        pi->dixdev->touchscreen->button_threshold = 115;
-
-#ifdef DEBUG
-    ErrorF("[tslib/TslibEnable] successfully enabled %s\n", pi->path);
-#endif
+    if (pi->dixdev && pi->dixdev->absolute &&
+        pi->dixdev->absolute->button_threshold == 0)
+        pi->dixdev->absolute->button_threshold = 115;
 
     KdRegisterFd(private->fd, TsRead, pi);
   
@@ -186,9 +176,6 @@ TslibInit (KdPointerInfo *pi)
     pi->nAxes = 3;
     pi->name = KdSaveString("Touchscreen");
     pi->inputClass = KD_TOUCHSCREEN;
-#ifdef DEBUG
-    ErrorF("[tslib/TslibInit] successfully inited for device %s\n", pi->path);
-#endif
 
     return Success;
 }
diff-tree a6dc629052f0ad509cfa30e98217043a63c09552 (from ac240b00ff6fc354c1aa641406ae8b49244c0b8b)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:54:59 2006 +0300

    kdrive/os: add KdOsAddInputDrivers
    Add KdOsAddInputDrivers, which adds all relevant input drivers.
    
    Could possibly be refactored to KdAddInputDrivers, which called through
    OsFuncs to a new function, if it existed.

diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c
index e75f8d5..7ba99b4 100644
--- a/hw/kdrive/linux/linux.c
+++ b/hw/kdrive/linux/linux.c
@@ -469,6 +469,18 @@ LinuxFini (void)
     return;
 }
 
+void
+KdOsAddInputDrivers ()
+{
+    KdAddPointerDriver(&LinuxMouseDriver);
+    KdAddPointerDriver(&MsMouseDriver);
+    KdAddPointerDriver(&Ps2MouseDriver);
+#ifdef TSLIB
+    KdAddPointerDriver(&TsDriver);
+#endif
+    KdAddKeyboardDriver(&LinuxKeyboardDriver);
+}
+
 KdOsFuncs   LinuxFuncs = {
     LinuxInit,
     LinuxEnable,
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 7e8712c..7f752e9 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -739,6 +739,9 @@ KdProcessArgument (int argc, char **argv
 void
 KdOsInit (KdOsFuncs *pOsFuncs);
 
+void
+KdOsAddInputDrivers (void);
+
 Bool
 KdAllocatePrivates (ScreenPtr pScreen);
 
diff --git a/hw/kdrive/vxworks/vxworks.c b/hw/kdrive/vxworks/vxworks.c
index ce214ff..aa46001 100644
--- a/hw/kdrive/vxworks/vxworks.c
+++ b/hw/kdrive/vxworks/vxworks.c
@@ -33,12 +33,6 @@ VxWorksSpecialKey (KeySym sym)
     case XK_Break:
 	download(1, "launcher", 0);
 	return TRUE;
-    case XK_Delete:
-	dispatchException |= DE_REBOOT;
-	return TRUE;
-    case XK_BackSpace:
-	dispatchException |= DE_RESET;
-	return TRUE;
     }
     return FALSE;
 }
@@ -53,6 +47,13 @@ VxWorksFini (void)
 {
 }
 
+void
+KdOsAddInputDrivers (void)
+{
+    KdAddPointerDriver(&VxWorksMouseDriver);
+    KdAddPointerDriver(&VxWorksKeyboardDriver);
+}
+
 KdOsFuncs   VxWorksFuncs = {
     VxWorksInit,
     VxWorksEnable,
diff-tree ac240b00ff6fc354c1aa641406ae8b49244c0b8b (from b1ba4b3e8ad427af1fa8618b0bd839f741ec2ce3)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:54:07 2006 +0300

    kdrive/input: use Absolute instead of Touchscreen
    Adjust to suit Zepheniah's new absolute device API.

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index a2e2c0f..c900266 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -444,7 +444,7 @@ KdPointerProc(DeviceIntPtr pDevice, int 
 
 #ifdef XINPUT
         if (pi->inputClass == KD_TOUCHSCREEN) {
-            InitTouchscreenClassDeviceStruct(pDevice);
+            InitAbsoluteClassDeviceStruct(pDev);
             xiclass = AtomFromName(XI_TOUCHSCREEN);
         }
         else {
diff-tree b1ba4b3e8ad427af1fa8618b0bd839f741ec2ce3 (from 29f28dd1a8a7ed07e945a67946e3510f4b32d12a)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:53:15 2006 +0300

    kdrive/neomagic: include vesa.h, use DebugF

diff --git a/hw/kdrive/neomagic/neomagic.h b/hw/kdrive/neomagic/neomagic.h
index b91e81e..9b10005 100644
--- a/hw/kdrive/neomagic/neomagic.h
+++ b/hw/kdrive/neomagic/neomagic.h
@@ -26,14 +26,10 @@
 #include <backend.h>
 #include "kxv.h"
 #include "klinux.h"
+#include "vesa.h"
 
 
-#define DEBUG
-#ifdef DEBUG
-#define DBGOUT(fmt,a...) fprintf (stderr, fmt, ##a)
-#else
-#define DBGOUT(fmt,a...)
-#endif
+#define DBGOUT DebugF
 
 #define ENTER()    DBGOUT("Enter %s\n", __FUNCTION__)
 #define LEAVE() DBGOUT("Leave %s\n", __FUNCTION__)
diff-tree 29f28dd1a8a7ed07e945a67946e3510f4b32d12a (from 2f33f4065d89ae2b6fdda43c7105d72f89920cae)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:52:52 2006 +0300

    configure.ac: add XSERVER_LIBS to XNEST_LIBS

diff --git a/configure.ac b/configure.ac
index 9700d61..a6eb8cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1005,7 +1005,7 @@ AC_MSG_RESULT([$XNEST])
 AM_CONDITIONAL(XNEST, [test "x$XNEST" = xyes])
 
 if test "x$XNEST" = xyes; then
-	XNEST_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB"
+	XNEST_LIBS="$XSERVER_LIBS $FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $CWRAP_LIB $OS_LIB"
 	AC_SUBST([XNEST_LIBS])
 fi
 
diff-tree 2f33f4065d89ae2b6fdda43c7105d72f89920cae (from 08928afb0500d46b0caa0a1d1244dee2ed80e6a0)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:52:35 2006 +0300

    Xnest: port to new input API
    Port Xnest to Get{Pointer,Keyboard}Events, plus the new mieq API.

diff --git a/hw/xnest/Events.c b/hw/xnest/Events.c
index e5cf99e..a209241 100644
--- a/hw/xnest/Events.c
+++ b/hw/xnest/Events.c
@@ -37,10 +37,13 @@ is" without express or implied warranty.
 #include "XNWindow.h"
 #include "Events.h"
 #include "Keyboard.h"
+#include "Pointer.h"
 #include "mipointer.h"
 
 CARD32 lastEventTime = 0;
 
+extern xEvent *xnestEvents;
+
 void
 ProcessInputEvents()
 {
@@ -101,11 +104,12 @@ xnestCollectExposures()
 void
 xnestQueueKeyEvent(int type, unsigned int keycode)
 {
-  xEvent x;
-  x.u.u.type = type;
-  x.u.u.detail = keycode;
-  x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
-  mieqEnqueue(&x);
+  int i, n;
+
+  lastEventTime = GetTimeInMillis();
+  n = GetKeyboardEvents(xnestEvents, xnestKeyboardDevice, type, keycode);
+  for (i = 0; i < n; i++)
+    mieqEnqueue(xnestKeyboardDevice, xnestEvents + i);
 }
 
 void
@@ -113,6 +117,7 @@ xnestCollectEvents()
 {
   XEvent X;
   xEvent x;
+  int i, n, valuators[2];
   ScreenPtr pScreen;
 
   while (XCheckIfEvent(xnestDisplay, &X, xnestNotExposurePredicate, NULL)) {
@@ -129,30 +134,30 @@ xnestCollectEvents()
       
     case ButtonPress:
       xnestUpdateModifierState(X.xkey.state);
-      x.u.u.type = ButtonPress;
-      x.u.u.detail = X.xbutton.button;
-      x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
-      mieqEnqueue(&x);
+      lastEventTime = GetTimeInMillis();
+      n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonPress,
+                           X.xbutton.button, POINTER_RELATIVE, 0, 0, NULL);
+      for (i = 0; i < n; i++)
+        mieqEnqueue(xnestPointerDevice, xnestEvents + i);
       break;
       
     case ButtonRelease:
       xnestUpdateModifierState(X.xkey.state);
-      x.u.u.type = ButtonRelease;
-      x.u.u.detail = X.xbutton.button;
-      x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
-      mieqEnqueue(&x);
+      lastEventTime = GetTimeInMillis();
+      n = GetPointerEvents(xnestEvents, xnestPointerDevice, ButtonRelease,
+                           X.xbutton.button, POINTER_RELATIVE, 0, 0, NULL);
+      for (i = 0; i < n; i++)
+        mieqEnqueue(xnestPointerDevice, xnestEvents + i);
       break;
       
     case MotionNotify:
-#if 0
-      x.u.u.type = MotionNotify;
-      x.u.keyButtonPointer.rootX = X.xmotion.x;
-      x.u.keyButtonPointer.rootY = X.xmotion.y;
-      x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
-      mieqEnqueue(&x);
-#endif 
-      miPointerAbsoluteCursor (X.xmotion.x, X.xmotion.y, 
-			       lastEventTime = GetTimeInMillis());
+      valuators[0] = X.xmotion.x;
+      valuators[1] = X.xmotion.y;
+      lastEventTime = GetTimeInMillis();
+      n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
+                           0, POINTER_ABSOLUTE, 0, 2, valuators);
+      for (i = 0; i < n; i++)
+        mieqEnqueue(xnestPointerDevice, xnestEvents + i);
       break;
       
     case FocusIn:
@@ -179,15 +184,13 @@ xnestCollectEvents()
 	pScreen = xnestScreen(X.xcrossing.window);
 	if (pScreen) {
 	  NewCurrentScreen(pScreen, X.xcrossing.x, X.xcrossing.y);
-#if 0
-	  x.u.u.type = MotionNotify;
-	  x.u.keyButtonPointer.rootX = X.xcrossing.x;
-	  x.u.keyButtonPointer.rootY = X.xcrossing.y;
-	  x.u.keyButtonPointer.time = lastEventTime = GetTimeInMillis();
-	  mieqEnqueue(&x);
-#endif
-	  miPointerAbsoluteCursor (X.xcrossing.x, X.xcrossing.y, 
-				   lastEventTime = GetTimeInMillis());
+          valuators[0] = X.xcrossing.x;
+          valuators[1] = X.xcrossing.y;
+          lastEventTime = GetTimeInMillis();
+          n = GetPointerEvents(xnestEvents, xnestPointerDevice, MotionNotify,
+                               0, POINTER_ABSOLUTE, 0, 2, valuators);
+          for (i = 0; i < n; i++)
+            mieqEnqueue(xnestPointerDevice, xnestEvents + i);
 	  xnestDirectInstallColormaps(pScreen);
 	}
       }
diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c
index 8c397a7..5bf0300 100644
--- a/hw/xnest/Init.c
+++ b/hw/xnest/Init.c
@@ -45,6 +45,8 @@ is" without express or implied warranty.
 
 Bool xnestDoFullGeneration = True;
 
+xEvent *xnestEvents = NULL;
+
 void
 InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
 {
@@ -92,10 +94,15 @@ InitInput(int argc, char *argv[])
   xnestPointerDevice = AddInputDevice(xnestPointerProc, TRUE);
   xnestKeyboardDevice = AddInputDevice(xnestKeyboardProc, TRUE);
 
+  if (!xnestEvents)
+      xnestEvents = (xEvent *) xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+  if (!xnestEvents)
+      FatalError("couldn't allocate room for events\n");
+
   RegisterPointerDevice(xnestPointerDevice);
   RegisterKeyboardDevice(xnestKeyboardDevice);
 
-  mieqInit((DevicePtr)xnestKeyboardDevice, (DevicePtr)xnestPointerDevice);
+  mieqInit();
 
   AddEnabledDevice(XConnectionNumber(xnestDisplay));
 
diff --git a/hw/xnest/Pointer.c b/hw/xnest/Pointer.c
index 4544497..b5e45db 100644
--- a/hw/xnest/Pointer.c
+++ b/hw/xnest/Pointer.c
@@ -59,7 +59,7 @@ xnestPointerProc(DeviceIntPtr pDev, int 
       InitPointerDeviceStruct(&pDev->public, map, nmap,
 			      miPointerGetMotionEvents,
 			      xnestChangePointerControl,
-			      miPointerGetMotionBufferSize());
+			      miPointerGetMotionBufferSize(), 2);
       break;
     case DEVICE_ON: 
       xnestEventMask |= XNEST_POINTER_EVENT_MASK;
diff-tree 08928afb0500d46b0caa0a1d1244dee2ed80e6a0 (from cd3b16a57efaf89108054f18a94c91e2dd74fafa)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:51:52 2006 +0300

    Xnest: disable XKB, reshuffle code
    Disable XKB, as we can't yet use it; move Composite disabling to
    ddxInitGlobals, along with XKB.

diff --git a/hw/xnest/Args.c b/hw/xnest/Args.c
index 5d0a0c0..c2e8b0d 100644
--- a/hw/xnest/Args.c
+++ b/hw/xnest/Args.c
@@ -53,18 +53,21 @@ Window xnestParentWindow = 0;
 /* ddxInitGlobals - called by |InitGlobals| from os/util.c */
 void ddxInitGlobals(void)
 {
-}
-
-int
-ddxProcessArgument (int argc, char *argv[], int i)
-{
-
 #ifdef COMPOSITE
     /* XXX terrible hack */
     extern Bool noCompositeExtension;
     noCompositeExtension = TRUE;
 #endif
 
+#ifdef XKB
+    extern Bool noXkbExtension;
+    noXkbExtension = TRUE;
+#endif
+}
+
+int
+ddxProcessArgument (int argc, char *argv[], int i)
+{
   if (!strcmp(argv[i], "-display")) {
     if (++i < argc) {
       xnestDisplayName = argv[i];
diff-tree cd3b16a57efaf89108054f18a94c91e2dd74fafa (from bf4df9b73f0c1a84093aaf9a2e2cbc56fb341c60)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:51:13 2006 +0300

    Xvfb: port to new mieq API

diff --git a/hw/vfb/InitInput.c b/hw/vfb/InitInput.c
index 17e023a..c0bfb55 100644
--- a/hw/vfb/InitInput.c
+++ b/hw/vfb/InitInput.c
@@ -293,7 +293,7 @@ vfbMouseProc(DeviceIntPtr pDevice, int o
 	    map[2] = 2;
 	    map[3] = 3;
 	    InitPointerDeviceStruct(pDev, map, 3, miPointerGetMotionEvents,
-		(PtrCtrlProcPtr)NoopDDA, miPointerGetMotionBufferSize());
+		(PtrCtrlProcPtr)NoopDDA, miPointerGetMotionBufferSize(), 2);
 	    break;
 
     case DEVICE_ON:
@@ -318,6 +318,5 @@ InitInput(int argc, char *argv[])
     k = AddInputDevice(vfbKeybdProc, TRUE);
     RegisterPointerDevice(p);
     RegisterKeyboardDevice(k);
-    miRegisterPointerDevice(screenInfo.screens[0], p);
-    (void)mieqInit ((DevicePtr) k, (DevicePtr) p);
+    (void)mieqInit();
 }
diff-tree bf4df9b73f0c1a84093aaf9a2e2cbc56fb341c60 (from 4dd91c45abea9fb561a5acb10290e29487df6722)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:50:53 2006 +0300

    include: move POINTER_* flags from inputstr.h to input.h
    Given they're just numeric constants, they should be included in
    input.h, not inputstr.h.

diff --git a/include/input.h b/include/input.h
index e598963..4acc856 100644
--- a/include/input.h
+++ b/include/input.h
@@ -59,6 +59,10 @@ SOFTWARE.
 #define DEVICE_OFF	2
 #define DEVICE_CLOSE	3
 
+#define POINTER_RELATIVE (1 << 1)
+#define POINTER_ABSOLUTE (1 << 2)
+#define POINTER_ACCELERATE (1 << 3)
+
 #define MAP_LENGTH	256
 #define DOWN_LENGTH	32	/* 256/8 => number of bytes to hold 256 bits */
 #define NullGrab ((GrabPtr)NULL)
diff --git a/include/inputstr.h b/include/inputstr.h
index 52175ad..2c64e0d 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -62,10 +62,6 @@ SOFTWARE.
 
 #define EMASKSIZE	MAX_DEVICES
 
-#define POINTER_RELATIVE (1 << 1)
-#define POINTER_ABSOLUTE (1 << 2)
-#define POINTER_ACCELERATE (1 << 3)
-
 extern int CoreDevicePrivatesIndex, CoreDevicePrivatesGeneration;
 
 /* Kludge: OtherClients and InputClients must be compatible, see code */
diff-tree 4dd91c45abea9fb561a5acb10290e29487df6722 (from 562096a012f4bb8f44d5ec6320a32f4010c189e4)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:50:03 2006 +0300

    miinitext: Xi and XKB are not hardware-only extensions
    Xi is now a required extension, and XKB can be used without hardware,
    so include them both when NO_HW_ONLY_EXTS is defined.

diff --git a/mi/miinitext.c b/mi/miinitext.c
index aafd014..f618595 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -549,7 +549,7 @@ InitExtensions(argc, argv)
 #ifdef MULTIBUFFER
     if (!noMultibufferExtension) MultibufferExtensionInit();
 #endif
-#if defined(XINPUT) && !defined(NO_HW_ONLY_EXTS)
+#if defined(XINPUT)
     if (!noXInputExtension) XInputExtensionInit();
 #endif
 #ifdef XTEST
@@ -579,7 +579,7 @@ InitExtensions(argc, argv)
 #ifdef XSYNC
     if (!noSyncExtension) SyncExtensionInit();
 #endif
-#if defined(XKB) && !defined(PRINT_ONLY_SERVER) && !defined(NO_HW_ONLY_EXTS)
+#if defined(XKB) && !defined(PRINT_ONLY_SERVER)
     if (!noXkbExtension) XkbExtensionInit();
 #endif
 #ifdef XCMISC
diff-tree 562096a012f4bb8f44d5ec6320a32f4010c189e4 (from eec182259112fba240751f974f7e5ca09fce8b9d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:49:22 2006 +0300

    XkbCopyKeymap: increment shapes and outlines when copying
    Remember to increment the source and destination shapes when copying,
    instead of just endlessly copying the first one.

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index cddeb9e..0c1ac9c 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1665,7 +1665,7 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
 
             for (i = 0, sshape = src->geom->shapes, dshape = dst->geom->shapes;
                  i < src->geom->num_shapes;
-                 i++) {
+                 i++, sshape++, dshape++) {
                 if (sshape->num_outlines) {
                     tmp = xcalloc(sshape->num_outlines, sizeof(XkbOutlineRec));
                     if (!tmp)
@@ -1676,7 +1676,7 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                           soutline = sshape->outlines,
                           doutline = dshape->outlines;
                          j < sshape->num_outlines;
-                         j++) {
+                         j++, soutline++, doutline++) {
                         if (soutline->num_points) {
                             tmp = xalloc(soutline->num_points *
                                           sizeof(XkbPointRec));
diff-tree eec182259112fba240751f974f7e5ca09fce8b9d (from bc701a14292da5abfb601e3a040651a74f46df8f)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 02:48:30 2006 +0300

    dix/getevents: move SyntheticMotion to getevents.c
    Mostly, this is just a cheesy hack to ensure that getevents.o gets
    included when linking.  Sigh.

diff --git a/dix/events.c b/dix/events.c
index e1a3e75..321c552 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -320,11 +320,16 @@ static CARD8 criticalEvents[32] =
 };
 
 #ifdef PANORAMIX
-
 static void ConfineToShape(RegionPtr shape, int *px, int *py);
-static void SyntheticMotion(int x, int y);
+static void PostSyntheticMotion(int x, int y, int screenNum, int time);
 static void PostNewCursor(void);
 
+#define SyntheticMotion(x, y) \
+    PostSyntheticMotion(x, y, sprite.screen->myNum, \
+                        syncEvents.playingEvents ? \
+                          syncEvents.time.milliseconds : \
+                          currentTime.milliseconds);
+
 static Bool
 XineramaSetCursorPosition(
     int x, 
@@ -667,30 +672,6 @@ SetCriticalEvent(int event)
     criticalEvents[event >> 3] |= 1 << (event & 7);
 }
 
-static void
-SyntheticMotion(int x, int y)
-{
-    xEvent xE;
-
-#ifdef PANORAMIX
-    /* Translate back to the sprite screen since processInputProc
-       will translate from sprite screen to screen 0 upon reentry
-       to the DIX layer */
-    if(!noPanoramiXExtension) {
-	x += panoramiXdataPtr[0].x - panoramiXdataPtr[sprite.screen->myNum].x;
-	y += panoramiXdataPtr[0].y - panoramiXdataPtr[sprite.screen->myNum].y;
-    }
-#endif
-    xE.u.keyButtonPointer.rootX = x;
-    xE.u.keyButtonPointer.rootY = y;
-    if (syncEvents.playingEvents)
-	xE.u.keyButtonPointer.time = syncEvents.time.milliseconds;
-    else
-	xE.u.keyButtonPointer.time = currentTime.milliseconds;
-    xE.u.u.type = MotionNotify;
-    (*inputInfo.pointer->public.processInputProc)(&xE, inputInfo.pointer, 1);
-}
-
 #ifdef SHAPE
 static void
 ConfineToShape(RegionPtr shape, int *px, int *py)
diff --git a/dix/getevents.c b/dix/getevents.c
index 03fe5fe..ca199c6 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -51,6 +51,11 @@ extern Bool XkbCopyKeymap(XkbDescPtr src
 #include "xace.h"
 #endif
 
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
 #include <X11/extensions/XIproto.h>
 #include "exglobals.h"
 #include "exevents.h"
@@ -546,3 +551,32 @@ SwitchCorePointer(DeviceIntPtr pDev)
     if (inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr != pDev)
         inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
 }
+
+
+/**
+ * Synthesize a single motion event for the core pointer.
+ *
+ * Used in cursor functions, e.g. when cursor confinement changes, and we need
+ * to shift the pointer to get it inside the new bounds.
+ */
+void
+PostSyntheticMotion(int x, int y, int screenNum, unsigned long time)
+{
+    xEvent xE = { 0, };
+
+#ifdef PANORAMIX
+    /* Translate back to the sprite screen since processInputProc
+       will translate from sprite screen to screen 0 upon reentry
+       to the DIX layer. */
+    if (!noPanoramiXExtension) {
+        x += panoramiXdataPtr[0].x - panoramiXdataPtr[screenNum].x;
+        y += panoramiXdataPtr[0].y - panoramiXdataPtr[screenNum].y;
+    }
+#endif
+
+    xE.u.u.type = MotionNotify;
+    xE.u.keyButtonPointer.rootX = x;
+    xE.u.keyButtonPointer.rootY = y;
+
+    (*inputInfo.pointer->public.processInputProc)(&xE, inputInfo.pointer, 1);
+}
diff-tree bc701a14292da5abfb601e3a040651a74f46df8f (from b03e2f7029506640a8fe5cb88818b329c23503ff)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 23 00:08:32 2006 +0300

    dix/getevents: cosmetic cleanups, remove keymap copy from GKVE
    Remove keymap copy from GetKeyboardValuatorEvents, as
    SwitchCoreKeyboard now takes care of this for us.
    Remove unused variable and function prototype.
    Update comments to be as informative as possible.

diff --git a/dix/getevents.c b/dix/getevents.c
index c6a35ba..03fe5fe 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -44,7 +44,6 @@
 #ifdef XKB
 #include <X11/extensions/XKBproto.h>
 #include <X11/extensions/XKBsrv.h>
-extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
 extern Bool XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies);
 #endif
 
@@ -99,9 +98,10 @@ GetKeyboardEvents(xEvent *events, Device
  * The DDX is responsible for allocating the event structure in the first
  * place via GetMaximumEventsNum(), and for freeing it.
  *
- * If pDev is set to send core events, then the keymap on the core
- * keyboard will be pivoted to that of the new keyboard and the appropriate
- * MapNotify events (both core and XKB) will be sent.
+ * This function does not change the core keymap to that of the device;
+ * that is done by SwitchCoreKeyboard, which is called from
+ * mieqProcessInputEvents.  If replacing function, take care to call
+ * SetCoreKeyboard before processInputProc, so keymaps are altered to suit.
  *
  * Note that this function recurses!  If called for non-XKB, a repeating
  * key press will trigger a matching KeyRelease, as well as the
@@ -117,7 +117,6 @@ GetKeyboardValuatorEvents(xEvent *events
                                            pDev->key->curKeySyms.mapWidth];
     deviceKeyButtonPointer *kbp = NULL;
     deviceValuator *xv = NULL;
-    KeyClassPtr ckeyc;
 
     if (!events)
         return 0;
@@ -220,40 +219,13 @@ GetKeyboardValuatorEvents(xEvent *events
         events->u.keyButtonPointer.time = ms;
         events->u.u.type = type;
         events->u.u.detail = key_code;
-
-        if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr !=
-            pDev) {
-            ckeyc = inputInfo.keyboard->key;
-            memcpy(ckeyc->modifierMap, pDev->key->modifierMap, MAP_LENGTH);
-            if (ckeyc->modifierKeyMap)
-                xfree(ckeyc->modifierKeyMap);
-            ckeyc->modifierKeyMap = xalloc(8 * pDev->key->maxKeysPerModifier);
-            memcpy(ckeyc->modifierKeyMap, pDev->key->modifierKeyMap,
-                    (8 * pDev->key->maxKeysPerModifier));
-            ckeyc->maxKeysPerModifier = pDev->key->maxKeysPerModifier;
-            ckeyc->curKeySyms.minKeyCode = pDev->key->curKeySyms.minKeyCode;
-            ckeyc->curKeySyms.maxKeyCode = pDev->key->curKeySyms.maxKeyCode;
-            SetKeySymsMap(&ckeyc->curKeySyms, &pDev->key->curKeySyms);
-#ifdef XKB
-            if (!noXkbExtension && pDev->key->xkbInfo &&
-                pDev->key->xkbInfo->desc) {
-                if (!XkbCopyKeymap(pDev->key->xkbInfo->desc,
-                                   ckeyc->xkbInfo->desc, True))
-                    FatalError("Couldn't pivot keymap from device to core!\n");
-            }
-#endif
-            SendMappingNotify(MappingKeyboard, ckeyc->curKeySyms.minKeyCode,
-                              (ckeyc->curKeySyms.maxKeyCode -
-                               ckeyc->curKeySyms.minKeyCode),
-                              serverClient);
-            inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
-        }
     }
 
     return numEvents;
 }
 
-/* Originally a part of xf86PostMotionEvent. */
+/* Originally a part of xf86PostMotionEvent; modifies valuators
+ * in-place. */
 static void
 acceleratePointer(DeviceIntPtr pDev, int first_valuator, int num_valuators,
                   int *valuators)
@@ -277,9 +249,6 @@ acceleratePointer(DeviceIntPtr pDev, int
     if (!dx && !dy)
         return;
 
-    /*
-     * Accelerate
-     */
     if (pDev->ptrfeed && pDev->ptrfeed->ctrl.num) {
         /* modeled from xf86Events.c */
         if (pDev->ptrfeed->ctrl.threshold) {
@@ -524,7 +493,15 @@ GetPointerEvents(xEvent *events, DeviceI
     return num_events;
 }
 
-void SwitchCoreKeyboard(DeviceIntPtr pDev)
+/**
+ * Note that pDev was the last device to send a core event.  This function
+ * copies the complete keymap from the originating device to the core
+ * device, and makes sure the appropriate notifications are generated.
+ *
+ * Call this just before processInputProc.
+ */
+_X_EXPORT void
+SwitchCoreKeyboard(DeviceIntPtr pDev)
 {
     KeyClassPtr ckeyc = inputInfo.keyboard->key;
 
@@ -557,8 +534,14 @@ void SwitchCoreKeyboard(DeviceIntPtr pDe
     }
 }
 
-/* Currently a no-op. */
-void SwitchCorePointer(DeviceIntPtr pDev)
+/**
+ * Note that pDev was the last function to send a core pointer event.
+ * Currently a no-op.
+ *
+ * Call this just before processInputProc.
+ */ 
+_X_EXPORT void
+SwitchCorePointer(DeviceIntPtr pDev)
 {
     if (inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr != pDev)
         inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
diff-tree b03e2f7029506640a8fe5cb88818b329c23503ff (from 90de7ce25a84cfe6c6790f9af2bc2399d25b9b9c)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 22 19:56:49 2006 +0300

    xi: fix NIDR return yet again
    For a one-line function, it was pretty broken.

diff --git a/Xi/stubs.c b/Xi/stubs.c
index 88afec0..28ecd8b 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -308,5 +308,5 @@ ChangeDeviceControl(register ClientPtr c
 int
 NewInputDeviceRequest(InputOption *options)
 {
-    return;
+    return BadValue;
 }
diff-tree 90de7ce25a84cfe6c6790f9af2bc2399d25b9b9c (from f46dc272913ffb6b5b234a7ec6f4ba5cae44a831)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 22 19:54:36 2006 +0300

    xi: fix return type for NIDR

diff --git a/Xi/stubs.c b/Xi/stubs.c
index 0678c4c..88afec0 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -305,7 +305,7 @@ ChangeDeviceControl(register ClientPtr c
  * Add a new device with the specified options.
  *
  */
-void
+int
 NewInputDeviceRequest(InputOption *options)
 {
     return;
diff-tree f46dc272913ffb6b5b234a7ec6f4ba5cae44a831 (from 31a6307b7ba5adaa96deb8101ddfcda0262f537d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 22 19:51:35 2006 +0300

    xi: add NewInputDeviceRequest to stubs

diff --git a/Xi/stubs.c b/Xi/stubs.c
index 27afcea..0678c4c 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -296,3 +296,17 @@ ChangeDeviceControl(register ClientPtr c
 	return (BadMatch);
     }
 }
+
+
+/****************************************************************************
+ *
+ * Caller: configAddDevice (and others)
+ *
+ * Add a new device with the specified options.
+ *
+ */
+void
+NewInputDeviceRequest(InputOption *options)
+{
+    return;
+}
diff-tree 31a6307b7ba5adaa96deb8101ddfcda0262f537d (from eae6594d03a606ddf1f433b5897b5938aa940c1e)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 22 19:49:31 2006 +0300

    xi: change DEVICE_TOUCHSCREEN to ABS_{AREA_CALIB} for stubs

diff --git a/Xi/stubs.c b/Xi/stubs.c
index 90aeddb..27afcea 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -287,7 +287,8 @@ ChangeDeviceControl(register ClientPtr c
     switch (control->control) {
     case DEVICE_RESOLUTION:
 	return (BadMatch);
-    case DEVICE_TOUCHSCREEN:
+    case DEVICE_ABS_CALIB:
+    case DEVICE_ABS_AREA:
         return (BadMatch);
     case DEVICE_CORE:
         return (BadMatch);
diff-tree eae6594d03a606ddf1f433b5897b5938aa940c1e (from be21630164e865eca72ff2a686a38ae4e30fd79c)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 22 16:39:44 2006 +0300

    Xi: swap control in DevicePresenceNotify

diff --git a/Xi/extinit.c b/Xi/extinit.c
index c1ba462..c35a964 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -658,6 +658,7 @@ SDevicePresenceNotifyEvent (devicePresen
     *to = *from;
     swaps(&to->sequenceNumber,n);
     swapl(&to->time, n);
+    swaps(&to->control, n);
 }
 
 /************************************************************************
diff-tree be21630164e865eca72ff2a686a38ae4e30fd79c (from f08b6b2367705cb5b60e996e6328197430bf1919)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 22 16:33:02 2006 +0300

    dix, Xi: make use of deviceid in DevicePresenceNotify
    Use the deviceid and control fields in DevicePresenceNotify since
    the last push to inputproto to send a DPN whenever a control changes
    on a device.

diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index 597955c..badd938 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -66,6 +66,7 @@ SOFTWARE.
 #include "extnsionst.h"
 #include "extinit.h"	/* LookupDeviceIntRec */
 #include "exglobals.h"
+#include "exevents.h"
 
 #include "chgdctl.h"
 
@@ -98,7 +99,7 @@ int
 ProcXChangeDeviceControl(ClientPtr client)
 {
     unsigned len;
-    int i, status;
+    int i, status, ret = BadValue;
     DeviceIntPtr dev;
     xDeviceResolutionCtl *r;
     xChangeDeviceControlReply rep;
@@ -108,6 +109,7 @@ ProcXChangeDeviceControl(ClientPtr clien
     xDeviceAbsAreaCtl *area;
     xDeviceCoreCtl *c;
     xDeviceEnableCtl *e;
+    devicePresenceNotify dpn;
 
     REQUEST(xChangeDeviceControlReq);
     REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
@@ -115,9 +117,8 @@ ProcXChangeDeviceControl(ClientPtr clien
     len = stuff->length - (sizeof(xChangeDeviceControlReq) >> 2);
     dev = LookupDeviceIntRec(stuff->deviceid);
     if (dev == NULL) {
-	SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
-			  BadDevice);
-	return Success;
+        ret = BadDevice;
+        goto out;
     }
 
     rep.repType = X_Reply;
@@ -130,25 +131,22 @@ ProcXChangeDeviceControl(ClientPtr clien
 	r = (xDeviceResolutionCtl *) & stuff[1];
 	if ((len < (sizeof(xDeviceResolutionCtl) >> 2)) ||
 	    (len != (sizeof(xDeviceResolutionCtl) >> 2) + r->num_valuators)) {
-	    SendErrorToClient(client, IReqCode, X_ChangeDeviceControl,
-			      0, BadLength);
-	    return Success;
+            ret = BadLength;
+            goto out;
 	}
 	if (!dev->valuator) {
-	    SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
-			      BadMatch);
-	    return Success;
+            ret = BadMatch;
+            goto out;
 	}
 	if ((dev->grab) && !SameClient(dev->grab, client)) {
 	    rep.status = AlreadyGrabbed;
-	    WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
-	    return Success;
+            ret = Success;
+            goto out;
 	}
 	resolution = (CARD32 *) (r + 1);
 	if (r->first_valuator + r->num_valuators > dev->valuator->numAxes) {
-	    SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
-			      BadValue);
-	    return Success;
+            ret = BadValue;
+            goto out;
 	}
 	status = ChangeDeviceControl(client, dev, (xDeviceCtl *) r);
 	if (status == Success) {
@@ -162,23 +160,21 @@ ProcXChangeDeviceControl(ClientPtr clien
 		}
 	    for (i = 0; i < r->num_valuators; i++)
 		(a++)->resolution = *resolution++;
+
+            ret = Success;
 	} else if (status == DeviceBusy) {
 	    rep.status = DeviceBusy;
-	    WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
-	    return Success;
+            ret = Success;
 	} else {
-	    SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
-			      BadMatch);
-	    return Success;
+            ret = BadMatch;
 	}
 	break;
     case DEVICE_ABS_CALIB:
         calib = (xDeviceAbsCalibCtl *)&stuff[1];
 
         if (calib->button_threshold < 0 || calib->button_threshold > 255) {
-            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
-                              BadValue);
-            return Success;
+            ret = BadValue;
+            goto out;
         }
 
         status = ChangeDeviceControl(client, dev, (xDeviceCtl *) calib);
@@ -192,15 +188,12 @@ ProcXChangeDeviceControl(ClientPtr clien
             dev->absolute->flip_y = calib->flip_y;
             dev->absolute->rotation = calib->rotation;
             dev->absolute->button_threshold = calib->button_threshold;
+            ret = Success;
         } else if (status == DeviceBusy || status == BadValue) {
             rep.status = status;
-            WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
-                               &rep);
-            return Success;
+            ret = Success;
         } else {
-            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
-                              BadMatch);
-            return Success;
+            ret = BadMatch;
         }
 
         break;
@@ -216,15 +209,12 @@ ProcXChangeDeviceControl(ClientPtr clien
             dev->absolute->height = area->height;
             dev->absolute->screen = area->screen;
             dev->absolute->following = area->following;
+            ret = Success;
         } else if (status == DeviceBusy || status == BadValue) {
             rep.status = status;
-            WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
-                               &rep);
-            return Success;
+            ret = Success;
         } else {
-            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
-                              BadMatch);
-            return Success;
+            ret = Success;
         }
 
         break;
@@ -235,15 +225,12 @@ ProcXChangeDeviceControl(ClientPtr clien
 
         if (status == Success) {
             dev->coreEvents = c->status;
+            ret = Success;
         } else if (status == DeviceBusy) {
             rep.status = DeviceBusy;
-            WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
-                               &rep);
-            return Success;
+            ret = Success;
         } else {
-            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
-                              BadMatch);
-            return Success;
+            ret = BadMatch;
         }
 
         break;
@@ -257,23 +244,35 @@ ProcXChangeDeviceControl(ClientPtr clien
                 EnableDevice(dev);
             else
                 DisableDevice(dev);
+            ret = Success;
         } else if (status == DeviceBusy) {
             rep.status = DeviceBusy;
-            WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
-                               &rep);
-            return Success;
+            ret = Success;
         } else {
-            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
-                              BadMatch);
-            return Success;
+            ret = BadMatch;
         }
 
         break;
     default:
-	SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue);
-	return Success;
+        ret = BadValue;
+    }
+
+out:
+    if (ret == Success) {
+        dpn.type = DevicePresenceNotify;
+        dpn.time = currentTime.milliseconds;
+        dpn.devchange = 1;
+        dpn.deviceid = dev->id;
+        dpn.control = stuff->control;
+        SendEventToAllWindows(dev, DevicePresenceNotifyMask,
+                              (xEvent *) &dpn, 1);
+
+        WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
+    }
+    else {
+        SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, ret);
     }
-    WriteReplyToClient(client, sizeof(xChangeDeviceControlReply), &rep);
+
     return Success;
 }
 
diff --git a/dix/devices.c b/dix/devices.c
index c906bcd..5ea7b14 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -201,6 +201,8 @@ ActivateDevice(DeviceIntPtr dev)
     
     ev.type = DevicePresenceNotify;
     ev.time = currentTime.milliseconds;
+    ev.devchange = 0;
+    ev.deviceid = 0;
     dummyDev.id = 0;
     SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
                           (xEvent *) &ev, 1);
@@ -557,6 +559,8 @@ RemoveDevice(DeviceIntPtr dev)
     if (ret == Success) {
         ev.type = DevicePresenceNotify;
         ev.time = currentTime.milliseconds;
+        ev.devchange = 0;
+        ev.deviceid = 0;
         dummyDev.id = 0;
         SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
                               (xEvent *) &ev, 1);
diff-tree f08b6b2367705cb5b60e996e6328197430bf1919 (from 77e724585f6c53feb55475b94d8cfcb6acf1159b)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 22 12:30:02 2006 +0300

    kdrive: change DEVICE_TOUCHSCREEN to DEVICE_ABS_{CALIB,AREA}

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 449be9e..a2e2c0f 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2316,11 +2316,9 @@ ChangeDeviceControl(register ClientPtr c
         /* FIXME do something more intelligent here */
         return BadMatch;
 
-    case DEVICE_TOUCHSCREEN:
-        if (!pDev->touchscreen)
-            return BadDevice;
-        else
-            return Success;
+    case DEVICE_ABS_CALIB:
+    case DEVICE_ABS_AREA:
+        return Success;
 
     case DEVICE_CORE:
         return Success;
diff-tree 77e724585f6c53feb55475b94d8cfcb6acf1159b (from e26a494f417c3c700636ee68892c3015b2e0f27a)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 20 00:44:46 2006 +0300

    minor formatting fixes

diff --git a/dix/getevents.c b/dix/getevents.c
index 42b9df9..c6a35ba 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1,6 +1,6 @@
 /*
  * Copyright © 2006 Nokia Corporation
- * 
+ *
  * 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
@@ -121,7 +121,7 @@ GetKeyboardValuatorEvents(xEvent *events
 
     if (!events)
         return 0;
-    
+
     if (type != KeyPress && type != KeyRelease)
         return 0;
 
@@ -179,7 +179,6 @@ GetKeyboardValuatorEvents(xEvent *events
             events += numEvents;
         }
     }
-    
 
     ms = GetTimeInMillis();
 
diff --git a/mi/mieq.c b/mi/mieq.c
index 0ac68d6..63cd6e1 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -113,7 +113,7 @@ mieqEnqueue(DeviceIntPtr pDev, xEvent *e
             ErrorF("mieqEnqueue: more than six valuator events; dropping.\n");
             return;
         }
-        if (oldtail == miEventQueue.head || 
+        if (oldtail == miEventQueue.head ||
             !(lastkbp->type == DeviceMotionNotify ||
               lastkbp->type == DeviceButtonPress ||
               lastkbp->type == DeviceButtonRelease) ||
diff-tree e26a494f417c3c700636ee68892c3015b2e0f27a (from parents)
Merge: 736b0d5078597abbda80444deef852879260af90 aeba855b07832354f59678e20cc29a085e42bd99
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Sat Oct 21 04:26:14 2006 -0400

    Merge branch 'input-hotplug' of git+ssh://git.freedesktop.org/git/xorg/xserver

diff --cc Xi/chgdctl.c
index 32533c4,4b9c2b6..597955c
@@@ -104,9 -104,9 +104,10 @@@
      xChangeDeviceControlReply rep;
      AxisInfoPtr a;
      CARD32 *resolution;
 -    xDeviceTSCtl *ts;
 +    xDeviceAbsCalibCtl *calib;
 +    xDeviceAbsAreaCtl *area;
      xDeviceCoreCtl *c;
+     xDeviceEnableCtl *e;
  
      REQUEST(xChangeDeviceControlReq);
      REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
diff-tree 736b0d5078597abbda80444deef852879260af90 (from 1b1698af41b9038d9f9dbf521737d0baab5a2237)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Sat Oct 21 04:24:49 2006 -0400

    DEVICE_TOUCHSCREEN becomes DEVICE_ABS_CALIB.
    
    Update the DEVICE_ABS_CALIB stuff to include the new elements.
    
    New DEVICE_ABS_AREA support.
    
    dev->touchscreen becomes dev->absolute, with _CALIB and _AREA stuff in it.
    
    Update xfree86 to compile with this, kdrive needs an update too.

diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index ebe0865..32533c4 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -104,7 +104,8 @@ ProcXChangeDeviceControl(ClientPtr clien
     xChangeDeviceControlReply rep;
     AxisInfoPtr a;
     CARD32 *resolution;
-    xDeviceTSCtl *ts;
+    xDeviceAbsCalibCtl *calib;
+    xDeviceAbsAreaCtl *area;
     xDeviceCoreCtl *c;
 
     REQUEST(xChangeDeviceControlReq);
@@ -170,25 +171,52 @@ ProcXChangeDeviceControl(ClientPtr clien
 	    return Success;
 	}
 	break;
-    case DEVICE_TOUCHSCREEN:
-        ts = (xDeviceTSCtl *)&stuff[1];
+    case DEVICE_ABS_CALIB:
+        calib = (xDeviceAbsCalibCtl *)&stuff[1];
 
-        if (ts->button_threshold < 0 || ts->button_threshold > 255) {
+        if (calib->button_threshold < 0 || calib->button_threshold > 255) {
             SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
                               BadValue);
             return Success;
         }
 
-        status = ChangeDeviceControl(client, dev, (xDeviceCtl *) ts);
+        status = ChangeDeviceControl(client, dev, (xDeviceCtl *) calib);
 
         if (status == Success) {
-            dev->touchscreen->min_x = ts->min_x;
-            dev->touchscreen->max_x = ts->max_x;
-            dev->touchscreen->min_y = ts->min_y;
-            dev->touchscreen->max_y = ts->max_y;
-            dev->touchscreen->button_threshold = ts->button_threshold;
-        } else if (status == DeviceBusy) {
-            rep.status = DeviceBusy;
+            dev->absolute->min_x = calib->min_x;
+            dev->absolute->max_x = calib->max_x;
+            dev->absolute->min_y = calib->min_y;
+            dev->absolute->max_y = calib->max_y;
+            dev->absolute->flip_x = calib->flip_x;
+            dev->absolute->flip_y = calib->flip_y;
+            dev->absolute->rotation = calib->rotation;
+            dev->absolute->button_threshold = calib->button_threshold;
+        } else if (status == DeviceBusy || status == BadValue) {
+            rep.status = status;
+            WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
+                               &rep);
+            return Success;
+        } else {
+            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
+                              BadMatch);
+            return Success;
+        }
+
+        break;
+    case DEVICE_ABS_AREA:
+        area = (xDeviceAbsAreaCtl *)&stuff[1];
+
+        status = ChangeDeviceControl(client, dev, (xDeviceCtl *) area);
+
+        if (status == Success) {
+            dev->absolute->offset_x = area->offset_x;
+            dev->absolute->offset_y = area->offset_y;
+            dev->absolute->width = area->width;
+            dev->absolute->height = area->height;
+            dev->absolute->screen = area->screen;
+            dev->absolute->following = area->following;
+        } else if (status == DeviceBusy || status == BadValue) {
+            rep.status = status;
             WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
                                &rep);
             return Success;
diff --git a/Xi/getdctl.c b/Xi/getdctl.c
index 66342b3..61798f2 100644
--- a/Xi/getdctl.c
+++ b/Xi/getdctl.c
@@ -124,14 +124,23 @@ ProcXGetDeviceControl(ClientPtr client)
 	total_length = sizeof(xDeviceResolutionState) +
 	    (3 * sizeof(int) * dev->valuator->numAxes);
 	break;
-    case DEVICE_TOUCHSCREEN:
-        if (!dev->touchscreen) {
+    case DEVICE_ABS_CALIB:
+        if (!dev->absolute) {
             SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
                               BadMatch);
             return Success;
         }
 
-        total_length = sizeof(xDeviceTSCtl);
+        total_length = sizeof(xDeviceAbsCalibCtl);
+        break;
+    case DEVICE_ABS_AREA:
+        if (!dev->absolute) {
+            SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
+                              BadMatch);
+            return Success;
+        }
+
+        total_length = sizeof(xDeviceAbsAreaCtl);
         break;
     case DEVICE_CORE:
         total_length = sizeof(xDeviceCoreCtl);
@@ -152,8 +161,11 @@ ProcXGetDeviceControl(ClientPtr client)
     case DEVICE_RESOLUTION:
 	CopySwapDeviceResolution(client, dev->valuator, buf, total_length);
 	break;
-    case DEVICE_TOUCHSCREEN:
-        CopySwapDeviceTouchscreen(client, dev->touchscreen, buf);
+    case DEVICE_ABS_CALIB:
+        CopySwapDeviceAbsCalib(client, dev->absolute, buf);
+        break;
+    case DEVICE_ABS_AREA:
+        CopySwapDeviceAbsArea(client, dev->absolute, buf);
         break;
     case DEVICE_CORE:
         CopySwapDeviceCore(client, dev, buf);
@@ -206,28 +218,61 @@ CopySwapDeviceResolution(ClientPtr clien
     }
 }
 
-void CopySwapDeviceTouchscreen (ClientPtr client, TouchscreenClassPtr dts,
+void CopySwapDeviceAbsCalib (ClientPtr client, AbsoluteClassPtr dts,
+                                char *buf)
+{
+    register char n;
+    xDeviceAbsCalibState *calib = (xDeviceAbsCalibState *) buf;
+
+    calib->control = DEVICE_ABS_CALIB;
+    calib->length = sizeof(calib);
+    calib->min_x = dts->min_x;
+    calib->max_x = dts->max_x;
+    calib->min_y = dts->min_y;
+    calib->max_y = dts->max_y;
+    calib->flip_x = dts->flip_x;
+    calib->flip_y = dts->flip_y;
+    calib->rotation = dts->rotation;
+    calib->button_threshold = dts->button_threshold;
+
+    if (client->swapped) {
+        swaps(&calib->control, n);
+        swaps(&calib->length, n);
+        swapl(&calib->min_x, n);
+        swapl(&calib->max_x, n);
+        swapl(&calib->min_y, n);
+        swapl(&calib->max_y, n);
+        swapl(&calib->flip_x, n);
+        swapl(&calib->flip_y, n);
+        swapl(&calib->rotation, n);
+        swapl(&calib->button_threshold, n);
+    }
+}
+
+void CopySwapDeviceAbsArea (ClientPtr client, AbsoluteClassPtr dts,
                                 char *buf)
 {
     register char n;
-    xDeviceTSState *ts = (xDeviceTSState *) buf;
+    xDeviceAbsAreaState *area = (xDeviceAbsAreaState *) buf;
 
-    ts->control = DEVICE_TOUCHSCREEN;
-    ts->length = sizeof(ts);
-    ts->min_x = dts->min_x;
-    ts->max_x = dts->max_x;
-    ts->min_y = dts->min_y;
-    ts->max_y = dts->max_y;
-    ts->button_threshold = dts->button_threshold;
+    area->control = DEVICE_ABS_AREA;
+    area->length = sizeof(area);
+    area->offset_x = dts->offset_x;
+    area->offset_y = dts->offset_y;
+    area->width = dts->width;
+    area->height = dts->height;
+    area->screen = dts->screen;
+    area->following = dts->following;
 
     if (client->swapped) {
-        swaps(&ts->control, n);
-        swaps(&ts->length, n);
-        swapl(&ts->min_x, n);
-        swapl(&ts->max_x, n);
-        swapl(&ts->min_y, n);
-        swapl(&ts->max_y, n);
-        swapl(&ts->button_threshold, n);
+        swaps(&area->control, n);
+        swaps(&area->length, n);
+        swapl(&area->offset_x, n);
+        swapl(&area->offset_y, n);
+        swapl(&area->width, n);
+        swapl(&area->height, n);
+        swapl(&area->screen, n);
+        swapl(&area->following, n);
     }
 }
 
diff --git a/Xi/getdctl.h b/Xi/getdctl.h
index 1417d1b..f6febb2 100644
--- a/Xi/getdctl.h
+++ b/Xi/getdctl.h
@@ -42,10 +42,13 @@ void CopySwapDeviceResolution(ClientPtr 
 			      int	/* length */
     );
 
-void CopySwapDeviceTouchscreen(ClientPtr /* client */ ,
-                               TouchscreenClassPtr /* ts */ ,
-                               char * /* buf */
-    );
+void CopySwapDeviceAbsCalib (ClientPtr client,
+                             AbsoluteClassPtr dts,
+                             char *buf);
+
+void CopySwapDeviceAbsArea (ClientPtr client,
+                            AbsoluteClassPtr dts,
+                            char *buf);
 
 void CopySwapDeviceCore(ClientPtr /* client */ ,
                         DeviceIntPtr /* dev */ ,
diff --git a/dix/devices.c b/dix/devices.c
index 0121eea..bf7592b 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -116,7 +116,7 @@ AddInputDevice(DeviceProc deviceProc, Bo
     dev->button = (ButtonClassPtr)NULL;
     dev->focus = (FocusClassPtr)NULL;
     dev->proximity = (ProximityClassPtr)NULL;
-    dev->touchscreen = (TouchscreenClassPtr)NULL;
+    dev->absolute = (AbsoluteClassPtr)NULL;
     dev->kbdfeed = (KbdFeedbackPtr)NULL;
     dev->ptrfeed = (PtrFeedbackPtr)NULL;
     dev->intfeed = (IntegerFeedbackPtr)NULL;
@@ -805,22 +805,31 @@ InitValuatorClassDeviceStruct(DeviceIntP
 }
 
 _X_EXPORT Bool
-InitTouchscreenClassDeviceStruct(DeviceIntPtr dev)
+InitAbsoluteClassDeviceStruct(DeviceIntPtr dev)
 {
-    register TouchscreenClassPtr tsc;
+    register AbsoluteClassPtr abs;
 
-    tsc = (TouchscreenClassPtr)xalloc(sizeof(TouchscreenClassRec));
-    if (!tsc)
+    abs = (AbsoluteClassPtr)xalloc(sizeof(AbsoluteClassRec));
+    if (!abs)
         return FALSE;
 
     /* we don't do anything sensible with these, but should */
-    tsc->min_x = -1;
-    tsc->min_y = -1;
-    tsc->max_x = -1;
-    tsc->max_y = -1;
+    abs->min_x = -1;
+    abs->min_y = -1;
+    abs->max_x = -1;
+    abs->max_y = -1;
+    abs->flip_x = 0;
+    abs->flip_y = 0;
+    abs->rotation = 0;
+    abs->button_threshold = 0;
+
+    abs->offset_x = 0;
+    abs->offset_y = 0;
+    abs->width = -1;
+    abs->height = -1;
+    abs->following = 0;
 
-    tsc->button_threshold = 0;
-    dev->touchscreen = tsc;
+    dev->absolute = abs;
 
     return TRUE;
 }
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 411dedd..8a5d5b3 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -529,7 +529,8 @@ ChangeDeviceControl (ClientPtr client, D
       switch (control->control) {
       case DEVICE_CORE:
       case DEVICE_RESOLUTION:
-      case DEVICE_TOUCHSCREEN:
+      case DEVICE_ABS_CALIB:
+      case DEVICE_ABS_AREA:
         return Success;
       default:
         return BadMatch;
diff --git a/include/input.h b/include/input.h
index 3e3d16d..79e1de2 100644
--- a/include/input.h
+++ b/include/input.h
@@ -236,7 +236,7 @@ extern Bool InitValuatorClassDeviceStruc
     int /*numMotionEvents*/,
     int /*mode*/);
 
-extern Bool InitTouchscreenClassDeviceStruct(
+extern Bool InitAbsoluteClassDeviceStruct(
     DeviceIntPtr /*device*/);
 
 extern Bool InitFocusClassDeviceStruct(
diff --git a/include/inputstr.h b/include/inputstr.h
index e12b641..1aa16d4 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -184,13 +184,25 @@ typedef struct _ProximityClassRec {
     char	pad;
 } ProximityClassRec, *ProximityClassPtr;
 
-typedef struct _TouchscreenClassRec {
+typedef struct _AbsoluteClassRec {
+    /* Calibration. */
     int         min_x;
     int         max_x;
     int         min_y;
     int         max_y;
+    int         flip_x;
+    int         flip_y;
+    int		rotation;
     int         button_threshold;
-} TouchscreenClassRec, *TouchscreenClassPtr;
+
+    /* Area. */
+    int         offset_x;
+    int         offset_y;
+    int         width;
+    int         height;
+    int         screen;
+    XID		following;
+} AbsoluteClassRec, *AbsoluteClassPtr;
 
 typedef struct _KbdFeedbackClassRec *KbdFeedbackPtr;
 typedef struct _PtrFeedbackClassRec *PtrFeedbackPtr;
@@ -292,7 +304,7 @@ typedef struct _DeviceIntRec {
     ButtonClassPtr	button;
     FocusClassPtr	focus;
     ProximityClassPtr	proximity;
-    TouchscreenClassPtr touchscreen;
+    AbsoluteClassPtr    absolute;
     KbdFeedbackPtr	kbdfeed;
     PtrFeedbackPtr	ptrfeed;
     IntegerFeedbackPtr	intfeed;
diff-tree aeba855b07832354f59678e20cc29a085e42bd99 (from a8d3dad9d9f2b9053843e655abe463a68ba8dcb7)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 20 00:30:28 2006 +0300

    move keymap copy to event processing, from enqueuing
    
    Move the keymap copying to event processing time (in
    ProcessInputEvents), instead of being at event enqueuing time.
    Break SetCore{Pointer,Keyboard} out into separate functions.
    Change mieqEnqueue to take a device pointer, that asks for the
    _original_ device associated with this event.

diff --git a/dix/getevents.c b/dix/getevents.c
index 4f96080..42b9df9 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -481,19 +481,19 @@ GetPointerEvents(xEvent *events, DeviceI
             xv->deviceid = kbp->deviceid;
             switch (final_valuator - i) {
             case 6:
-                xv->valuator5 = valuators[i+5];
+                xv->valuator5 = valuators[i + 5];
             case 5:
-                xv->valuator4 = valuators[i+4];
+                xv->valuator4 = valuators[i + 4];
             case 4:
-                xv->valuator3 = valuators[i+3];
+                xv->valuator3 = valuators[i + 3];
             case 3:
-                xv->valuator2 = valuators[i+2];
+                xv->valuator2 = valuators[i + 2];
             case 2:
                 /* x and y may have been accelerated. */
                 if (i == 0)
                     xv->valuator1 = kbp->root_y;
                 else
-                    xv->valuator1 = valuators[i+1];
+                    xv->valuator1 = valuators[i + 1];
             case 1:
                 /* x and y may have been accelerated. */
                 if (i == 0)
@@ -520,11 +520,47 @@ GetPointerEvents(xEvent *events, DeviceI
         else {
             events->u.u.detail = 0;
         }
-
-        if (inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr !=
-            pDev)
-            inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
     }
 
     return num_events;
 }
+
+void SwitchCoreKeyboard(DeviceIntPtr pDev)
+{
+    KeyClassPtr ckeyc = inputInfo.keyboard->key;
+
+    if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr != pDev) {
+        memcpy(ckeyc->modifierMap, pDev->key->modifierMap, MAP_LENGTH);
+        if (ckeyc->modifierKeyMap)
+            xfree(ckeyc->modifierKeyMap);
+        ckeyc->modifierKeyMap = xalloc(8 * pDev->key->maxKeysPerModifier);
+        memcpy(ckeyc->modifierKeyMap, pDev->key->modifierKeyMap,
+                (8 * pDev->key->maxKeysPerModifier));
+
+        ckeyc->maxKeysPerModifier = pDev->key->maxKeysPerModifier;
+        ckeyc->curKeySyms.minKeyCode = pDev->key->curKeySyms.minKeyCode;
+        ckeyc->curKeySyms.maxKeyCode = pDev->key->curKeySyms.maxKeyCode;
+        SetKeySymsMap(&ckeyc->curKeySyms, &pDev->key->curKeySyms);
+
+#ifdef XKB
+        if (!noXkbExtension && pDev->key->xkbInfo && pDev->key->xkbInfo->desc) {
+            if (!XkbCopyKeymap(pDev->key->xkbInfo->desc, ckeyc->xkbInfo->desc,
+                               True))
+                FatalError("Couldn't pivot keymap from device to core!\n");
+        }
+#endif
+
+        SendMappingNotify(MappingKeyboard, ckeyc->curKeySyms.minKeyCode,
+                          (ckeyc->curKeySyms.maxKeyCode -
+                           ckeyc->curKeySyms.minKeyCode),
+                          serverClient);
+        inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
+    }
+}
+
+/* Currently a no-op. */
+void SwitchCorePointer(DeviceIntPtr pDev)
+{
+    if (inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr != pDev)
+        inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
+}
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 8dd3728..449be9e 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1656,10 +1656,10 @@ char *kdActionNames[] = {
 #endif
 
 static void
-KdQueueEvent (xEvent *ev)
+KdQueueEvent (DeviceIntPtr pDev, xEvent *ev)
 {
     KdAssertSigioBlocked ("KdQueueEvent");
-    mieqEnqueue (ev);
+    mieqEnqueue (pDev, ev);
 }
 
 /* We return true if we're stealing the event. */
@@ -1862,7 +1862,7 @@ KdReleaseAllKeys (void)
                 KdHandleKeyboardEvent(ki, KeyRelease, key);
                 nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key);
                 for (i = 0; i < nEvents; i++)
-                    KdQueueEvent (kdEvents + i);
+                    KdQueueEvent (ki->dixdev, kdEvents + i);
             }
         }
     }
@@ -1934,7 +1934,7 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo   
         ErrorF("KdEnqueueKeyboardEvent: got %d events from GKE\n", nEvents);
 #endif
         for (i = 0; i < nEvents; i++)
-            KdQueueEvent(kdEvents + i);
+            KdQueueEvent(ki->dixdev, kdEvents + i);
     }
     else {
         ErrorF("driver %s wanted to post scancode %d outside of [%d, %d]!\n",
@@ -2052,7 +2052,7 @@ _KdEnqueuePointerEvent (KdPointerInfo *p
     nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel, 0, 3,
                                valuators);
     for (i = 0; i < nEvents; i++)
-        KdQueueEvent(kdEvents + i);
+        KdQueueEvent(pi->dixdev, kdEvents + i);
 }
 
 void
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index cb77839..204457f 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -909,22 +909,6 @@ DGAVTSwitch(void)
 Bool
 DGAStealKeyEvent(int index, xEvent *e)
 {
-   DGAScreenPtr pScreenPriv;
-    dgaEvent	de;
-
-   if(DGAScreenIndex < 0) /* no DGA */
-	return FALSE;
-
-   pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
-
-   if(!pScreenPriv || !pScreenPriv->grabKeyboard) /* no direct mode */
-	return FALSE;
-
-    de.u.u.type = e->u.u.type + *XDGAEventBase;
-    de.u.u.detail = e->u.u.detail;
-    de.u.event.time = e->u.keyButtonPointer.time;
-    mieqEnqueue ((xEvent *) &de);
-   return TRUE;
 }
 
 static int  DGAMouseX, DGAMouseY;
@@ -932,36 +916,6 @@ static int  DGAMouseX, DGAMouseY;
 Bool
 DGAStealMouseEvent(int index, xEvent *e, int dx, int dy)
 {
-   DGAScreenPtr pScreenPriv;
-    dgaEvent	de;
-
-   if(DGAScreenIndex < 0) /* no DGA */
-	return FALSE;
-
-   pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
-
-   if(!pScreenPriv || !pScreenPriv->grabMouse) /* no direct mode */
-	return FALSE;
-    
-    DGAMouseX += dx;
-    if (DGAMouseX < 0)
-	DGAMouseX = 0;
-    else if (DGAMouseX > screenInfo.screens[index]->width)
-	DGAMouseX = screenInfo.screens[index]->width;
-    DGAMouseY += dy;
-    if (DGAMouseY < 0)
-	DGAMouseY = 0;
-    else if (DGAMouseY > screenInfo.screens[index]->height)
-	DGAMouseY = screenInfo.screens[index]->height;
-    de.u.u.type = e->u.u.type + *XDGAEventBase;
-    de.u.u.detail = e->u.u.detail;
-    de.u.event.time = e->u.keyButtonPointer.time;
-    de.u.event.dx = dx;
-    de.u.event.dy = dy;
-    de.u.event.pad1 = DGAMouseX;
-    de.u.event.pad2 = DGAMouseY;
-    mieqEnqueue ((xEvent *) &de);
-    return TRUE;
 }
 
 Bool
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index db259b3..3df201a 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -104,19 +104,12 @@ extern Bool noXkbExtension;
 #define XE_POINTER  1
 #define XE_KEYBOARD 2
 
-#define __EqEnqueue(ev) mieqEnqueue(ev)
-
-#define EqEnqueue(ev) { \
+#define EqEnqueue(pDev, ev) { \
     int __sigstate = xf86BlockSIGIO (); \
-    __EqEnqueue (ev); \
+    mieqEnqueue (pDev, ev); \
     xf86UnblockSIGIO(__sigstate); \
 }
 
-#define ENQUEUE(ev, code, direction, dev_type) \
-  (ev)->u.u.detail = (code); \
-  (ev)->u.u.type   = (direction); \
-  EqEnqueue((ev))
-
 /*
  * The first of many hacks to get VT switching to work under
  * Solaris 2.1 for x86. The basic problem is that Solaris is supposed
@@ -839,7 +832,7 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
                 else {
                     nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i);
                     for (j = 0; j < nevents; j++)
-                        mieqEnqueue(xf86Events + i);
+                        EqEnqueue(pDev, xf86Events + i);
                 }
                 break;
             }
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 411dedd..97c038f 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -656,20 +656,7 @@ xf86PostMotionEvent(DeviceIntPtr	device,
                                valuators);
 
     for (i = 0; i < nevents; i++)
-        mieqEnqueue(xf86Events + i);
-    
-#if 0
-    if (HAS_MOTION_HISTORY(local)) {
-      buff = ((char *)local->motion_history +
-              (sizeof(INT32) * local->dev->valuator->numAxes + sizeof(Time)) * local->last);
-    }
-
-    if (HAS_MOTION_HISTORY(local)) {
-        local->last = (local->last + 1) % device->valuator->numMotionEvents;
-        if (local->last == local->first)
-            local->first = (local->first + 1) % device->valuator->numMotionEvents;
-    }
-#endif
+        mieqEnqueue(device, xf86Events + i);
 }
 
 _X_EXPORT void
@@ -795,7 +782,7 @@ xf86PostButtonEvent(DeviceIntPtr	device,
                                first_valuator, num_valuators, valuators);
 
     for (i = 0; i < nevents; i++)
-        mieqEnqueue(xf86Events + i);
+        mieqEnqueue(device, xf86Events + i);
 }
 
 _X_EXPORT void
@@ -839,7 +826,7 @@ xf86PostKeyEvent(DeviceIntPtr	device,
     }
 
     for (i = 0; i < nevents; i++)
-        mieqEnqueue(xf86Events + i);
+        mieqEnqueue(device, xf86Events + i);
 }
 
 _X_EXPORT void
@@ -858,7 +845,7 @@ xf86PostKeyboardEvent(DeviceIntPtr      
                                 is_down ? KeyPress : KeyRelease, key_code);
 
     for (i = 0; i < nevents; i++)
-        mieqEnqueue(xf86Events + i);
+        mieqEnqueue(device, xf86Events + i);
 }
 
 /* 
diff --git a/include/input.h b/include/input.h
index 3e3d16d..a9eeb3f 100644
--- a/include/input.h
+++ b/include/input.h
@@ -406,6 +406,9 @@ extern int GetKeyboardValuatorEvents(
     int num_valuator,
     int *valuators);
 
+extern void SwitchCoreKeyboard(DeviceIntPtr pDev);
+extern void SwitchCorePointer(DeviceIntPtr pDev);
+
 extern DeviceIntPtr LookupDeviceIntRec(
     CARD8 deviceid);
 
diff --git a/mi/mi.h b/mi/mi.h
index 89d460f..8d9d120 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -173,6 +173,7 @@ extern Bool mieqInit(
 );
 
 extern void mieqEnqueue(
+    DeviceIntPtr /*pDev*/,
     xEventPtr /*e*/
 );
 
diff --git a/mi/mieq.c b/mi/mieq.c
index 16e638c..0ac68d6 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -73,14 +73,14 @@ typedef struct _EventQueue {
 static EventQueueRec miEventQueue;
 
 Bool
-mieqInit ()
+mieqInit()
 {
     miEventQueue.head = miEventQueue.tail = 0;
     miEventQueue.lastEventTime = GetTimeInMillis ();
     miEventQueue.lastMotion = FALSE;
     miEventQueue.pEnqueueScreen = screenInfo.screens[0];
     miEventQueue.pDequeueScreen = miEventQueue.pEnqueueScreen;
-    SetInputCheck (&miEventQueue.head, &miEventQueue.tail);
+    SetInputCheck(&miEventQueue.head, &miEventQueue.tail);
     return TRUE;
 }
 
@@ -92,57 +92,39 @@ mieqInit ()
  */
 
 void
-mieqEnqueue (xEvent *e)
+mieqEnqueue(DeviceIntPtr pDev, xEvent *e)
 {
     HWEventQueueType       oldtail = miEventQueue.tail, newtail;
     int                    isMotion = 0;
-    DeviceIntPtr           pDev = NULL;
-    deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) e;
     deviceValuator         *v = (deviceValuator *) e;
     EventPtr               laste = &miEventQueue.events[oldtail - 1];
     deviceKeyButtonPointer *lastkbp = (deviceKeyButtonPointer *)
                                       &laste->event[0];
 
-    if (e->u.u.type == MotionNotify) {
-        pDev = inputInfo.pointer;
-        isMotion = inputInfo.pointer->id & DEVICE_BITS;
-    }
-    else if (e->u.u.type == KeyPress || e->u.u.type == KeyRelease) {
-        pDev = inputInfo.keyboard;
-    }
-    else if (e->u.u.type == ButtonPress || e->u.u.type == ButtonRelease) {
-        pDev = inputInfo.pointer;
-    }
-    else {
-        pDev = LookupDeviceIntRec(kbp->deviceid & DEVICE_BITS);
-
-        /* We silently steal valuator events: just tack them on to the last
-         * motion event they need to be attached to.  Sigh. */
-        if (e->u.u.type == DeviceValuator) {
-            if (laste->nevents > 6) {
-                ErrorF("mieqEnqueue: more than six valuator events; dropping.\n");
-                return;
-            }
-            if (oldtail == miEventQueue.head || 
-                !(lastkbp->type == DeviceMotionNotify ||
-                  lastkbp->type == DeviceButtonPress ||
-                  lastkbp->type == DeviceButtonRelease) ||
-                ((lastkbp->deviceid & DEVICE_BITS) !=
-                 (v->deviceid & DEVICE_BITS))) {
-                ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n");
-                return;
-            }
-            memcpy(&(laste->event[laste->nevents++]), e, sizeof(xEvent));
+    if (e->u.u.type == MotionNotify)
+        isMotion = inputInfo.pointer->id;
+    else if (e->u.u.type == DeviceMotionNotify)
+        isMotion = pDev->id;
+
+    /* We silently steal valuator events: just tack them on to the last
+     * motion event they need to be attached to.  Sigh. */
+    if (e->u.u.type == DeviceValuator) {
+        if (laste->nevents > 6) {
+            ErrorF("mieqEnqueue: more than six valuator events; dropping.\n");
             return;
         }
-        else if (e->u.u.type == DeviceMotionNotify) {
-            isMotion = pDev->id & DEVICE_BITS;
+        if (oldtail == miEventQueue.head || 
+            !(lastkbp->type == DeviceMotionNotify ||
+              lastkbp->type == DeviceButtonPress ||
+              lastkbp->type == DeviceButtonRelease) ||
+            (lastkbp->deviceid != v->deviceid)) {
+            ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n");
+            return;
         }
+        memcpy(&(laste->event[laste->nevents++]), e, sizeof(xEvent));
+        return;
     }
 
-    if (!pDev)
-        FatalError("Couldn't find device for event!\n");
-
     if (isMotion && isMotion == miEventQueue.lastMotion &&
         oldtail != miEventQueue.head) {
 	if (oldtail == 0)
@@ -164,10 +146,8 @@ mieqEnqueue (xEvent *e)
     memcpy(&(miEventQueue.events[oldtail].event[0]), e, sizeof(xEvent));
     miEventQueue.events[oldtail].nevents = 1;
 
-    /*
-     * Make sure that event times don't go backwards - this
-     * is "unnecessary", but very useful
-     */
+    /* Make sure that event times don't go backwards - this
+     * is "unnecessary", but very useful. */
     if (e->u.keyButtonPointer.time < miEventQueue.lastEventTime &&
 	miEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
 	miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time =
@@ -182,49 +162,59 @@ mieqEnqueue (xEvent *e)
 }
 
 void
-mieqSwitchScreen (ScreenPtr pScreen, Bool fromDIX)
+mieqSwitchScreen(ScreenPtr pScreen, Bool fromDIX)
 {
     miEventQueue.pEnqueueScreen = pScreen;
     if (fromDIX)
 	miEventQueue.pDequeueScreen = pScreen;
 }
 
-/*
- * Call this from ProcessInputEvents()
- */
-
-void mieqProcessInputEvents ()
+/* Call this from ProcessInputEvents(). */
+void
+mieqProcessInputEvents()
 {
-    EventRec	*e;
-    int		x, y;
+    EventRec *e = NULL;
+    int x = 0, y = 0;
+    DeviceIntPtr dev = NULL;
+
+    while (miEventQueue.head != miEventQueue.tail) {
+        if (screenIsSaved == SCREEN_SAVER_ON)
+            SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
+
+        e = &miEventQueue.events[miEventQueue.head];
+        /* Assumption - screen switching can only occur on motion events. */
+        if (e->pScreen != miEventQueue.pDequeueScreen) {
+            miEventQueue.pDequeueScreen = e->pScreen;
+            x = e->event[0].u.keyButtonPointer.rootX;
+            y = e->event[0].u.keyButtonPointer.rootY;
+            if (miEventQueue.head == QUEUE_SIZE - 1)
+                miEventQueue.head = 0;
+            else
+                ++miEventQueue.head;
+            NewCurrentScreen (miEventQueue.pDequeueScreen, x, y);
+        }
+        else {
+            if (miEventQueue.head == QUEUE_SIZE - 1)
+                miEventQueue.head = 0;
+            else
+                ++miEventQueue.head;
+
+            if (e->event[0].u.u.type == KeyPress ||
+                e->event[0].u.u.type == KeyRelease) {
+                SwitchCoreKeyboard(e->pDev);
+                dev = inputInfo.keyboard;
+            }
+            else if (e->event[0].u.u.type == MotionNotify ||
+                     e->event[0].u.u.type == ButtonPress ||
+                     e->event[0].u.u.type == ButtonRelease) {
+                SwitchCorePointer(e->pDev);
+                dev = inputInfo.pointer;
+            }
+            else {
+                dev = e->pDev;
+            }
 
-    while (miEventQueue.head != miEventQueue.tail)
-    {
-	if (screenIsSaved == SCREEN_SAVER_ON)
-	    SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
-
-	e = &miEventQueue.events[miEventQueue.head];
-	/*
-	 * Assumption - screen switching can only occur on motion events
-	 */
-	if (e->pScreen != miEventQueue.pDequeueScreen)
-	{
-	    miEventQueue.pDequeueScreen = e->pScreen;
-	    x = e->event[0].u.keyButtonPointer.rootX;
-	    y = e->event[0].u.keyButtonPointer.rootY;
-	    if (miEventQueue.head == QUEUE_SIZE - 1)
-	    	miEventQueue.head = 0;
-	    else
-	    	++miEventQueue.head;
-	    NewCurrentScreen (miEventQueue.pDequeueScreen, x, y);
-	}
-	else
-	{
-	    if (miEventQueue.head == QUEUE_SIZE - 1)
-	    	miEventQueue.head = 0;
-	    else
-	    	++miEventQueue.head;
-            (*e->pDev->public.processInputProc)(e->event, e->pDev, e->nevents);
-	}
+            dev->public.processInputProc(e->event, dev, e->nevents);
+        }
     }
 }
diff-tree a8d3dad9d9f2b9053843e655abe463a68ba8dcb7 (from b0780312d80ea4af0136227f90fdd7ada3db71c5)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 20 00:28:40 2006 +0300

    xi: add DEVICE_ENABLE control
    
    Add DEVICE_ENABLE control, which allows runtime enabling and disabling
    of specific devices.

diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index ebe0865..4b9c2b6 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -106,6 +106,7 @@ ProcXChangeDeviceControl(ClientPtr clien
     CARD32 *resolution;
     xDeviceTSCtl *ts;
     xDeviceCoreCtl *c;
+    xDeviceEnableCtl *e;
 
     REQUEST(xChangeDeviceControlReq);
     REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
@@ -218,6 +219,28 @@ ProcXChangeDeviceControl(ClientPtr clien
         }
 
         break;
+    case DEVICE_ENABLE:
+        e = (xDeviceEnableCtl *)&stuff[1];
+
+        status = ChangeDeviceControl(client, dev, (xDeviceCtl *) e);
+
+        if (status == Success) {
+            if (e->enable)
+                EnableDevice(dev);
+            else
+                DisableDevice(dev);
+        } else if (status == DeviceBusy) {
+            rep.status = DeviceBusy;
+            WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
+                               &rep);
+            return Success;
+        } else {
+            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
+                              BadMatch);
+            return Success;
+        }
+
+        break;
     default:
 	SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue);
 	return Success;
diff --git a/Xi/getdctl.c b/Xi/getdctl.c
index 66342b3..2ae6ef3 100644
--- a/Xi/getdctl.c
+++ b/Xi/getdctl.c
@@ -136,6 +136,9 @@ ProcXGetDeviceControl(ClientPtr client)
     case DEVICE_CORE:
         total_length = sizeof(xDeviceCoreCtl);
         break;
+    case DEVICE_ENABLE:
+        total_length = sizeof(xDeviceEnableCtl);
+        break;
     default:
 	SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue);
 	return Success;
@@ -157,6 +160,10 @@ ProcXGetDeviceControl(ClientPtr client)
         break;
     case DEVICE_CORE:
         CopySwapDeviceCore(client, dev, buf);
+        break;
+    case DEVICE_ENABLE:
+        CopySwapDeviceEnable(client, dev, buf);
+        break;
     default:
 	break;
     }
@@ -239,6 +246,7 @@ void CopySwapDeviceCore (ClientPtr clien
     c->control = DEVICE_CORE;
     c->length = sizeof(c);
     c->status = dev->coreEvents;
+    c->iscore = (dev == inputInfo.keyboard || dev == inputInfo.pointer);
 
     if (client->swapped) {
         swaps(&c->control, n);
@@ -247,6 +255,22 @@ void CopySwapDeviceCore (ClientPtr clien
     }
 }
 
+void CopySwapDeviceEnable (ClientPtr client, DeviceIntPtr dev, char *buf)
+{
+    register char n;
+    xDeviceEnableState *e = (xDeviceEnableState *) buf;
+
+    e->control = DEVICE_ENABLE;
+    e->length = sizeof(e);
+    e->enable = dev->enabled;
+
+    if (client->swapped) {
+        swaps(&e->control, n);
+        swaps(&e->length, n);
+        swaps(&e->enable, n);
+    }
+}
+
 
 /***********************************************************************
  *
diff --git a/Xi/getdctl.h b/Xi/getdctl.h
index 1417d1b..1331a32 100644
--- a/Xi/getdctl.h
+++ b/Xi/getdctl.h
@@ -52,6 +52,11 @@ void CopySwapDeviceCore(ClientPtr /* cli
                         char * /* buf */
     );
 
+void CopySwapDeviceEnable(ClientPtr /* client */ ,
+                          DeviceIntPtr /* dev */ ,
+                          char * /* buf */
+    );
+
 void SRepXGetDeviceControl(ClientPtr /* client */ ,
 			   int /* size */ ,
 			   xGetDeviceControlReply *	/* rep */
diff --git a/dix/devices.c b/dix/devices.c
index 0121eea..7b4be0e 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -130,6 +130,8 @@ AddInputDevice(DeviceProc deviceProc, Bo
     dev->devPrivates = NULL;
     dev->unwrapProc = NULL;
     dev->coreEvents = TRUE;
+    dev->inited = FALSE;
+    dev->enabled = FALSE;
 
     for (prev = &inputInfo.off_devices; *prev; prev = &(*prev)->next)
         ;
@@ -154,6 +156,7 @@ EnableDevice(register DeviceIntPtr dev)
         ErrorF("couldn't enable device %d\n", dev->id);
 	return FALSE;
     }
+    dev->enabled = TRUE;
     *prev = dev->next;
 
     for (prev = &inputInfo.devices; *prev; prev = &(*prev)->next)
@@ -176,6 +179,7 @@ DisableDevice(register DeviceIntPtr dev)
     if (*prev != dev)
 	return FALSE;
     (void)(*dev->deviceProc)(dev, DEVICE_OFF);
+    dev->enabled = FALSE;
     *prev = dev->next;
     dev->next = inputInfo.off_devices;
     inputInfo.off_devices = dev;
diff --git a/include/inputstr.h b/include/inputstr.h
index e12b641..6476321 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -265,6 +265,7 @@ typedef struct _DeviceIntRec {
 					  used to initialize, turn on, or
 					  turn off the device */
     Bool	inited;			/* TRUE if INIT returns Success */
+    Bool        enabled;                /* TRUE if ON returns Success */
     Bool        coreEvents;             /* TRUE if device also sends core */
     GrabPtr	grab;			/* the grabber - used by DIX */
     struct {
diff-tree b0780312d80ea4af0136227f90fdd7ada3db71c5 (from c5dc997baf57ffa08025efadbbaf761296ce4bc4)
Author: Alan Coopersmith <alan.coopersmith at sun.com>
Date:   Thu Oct 19 13:51:53 2006 -0700

    Pre-release message should tell users to check git, not CVS, for updates

diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index a49bd54..33351f2 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1651,8 +1651,8 @@ xf86PrintBanner()
     "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
     "Select the \"xorg\" product for bugs you find in this release.\n"
     "Before reporting bugs in pre-release versions please check the\n"
-    "latest version in the X.Org Foundation CVS repository.\n"
-    "See http://wiki.x.org/wiki/CvsPage for CVS access instructions.\n");
+    "latest version in the X.Org Foundation git repository.\n"
+    "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
 #endif
   ErrorF("\nX Window System Version %d.%d.%d",
 	 XORG_VERSION_MAJOR,
diff-tree c5dc997baf57ffa08025efadbbaf761296ce4bc4 (from d029c8f1b72019446a5c873f55ffa43504b03dfb)
Author: Joshua Baergen <joshuabaergen at gentoo.org>
Date:   Thu Oct 19 11:14:26 2006 -0700

    Create xorg.conf.example (Gentoo bug #138623).

diff --git a/configure.ac b/configure.ac
index 2467e79..9700d61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -836,6 +836,7 @@ VENDOR_MAN_VERSION="Version ${VENDOR_VER
 
 AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
 AC_DEFINE_DIR(RGB_DB, RGBPATH, [Default RGB path])
+AC_DEFINE_DIR(BASE_FONT_PATH, FONTDIR, [Default base font path])
 AC_DEFINE_DIR(DRI_DRIVER_PATH, DRI_DRIVER_PATH, [Default DRI driver path])
 AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_STRING"], [Vendor name])
 AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_STRING_SHORT"], [Short vendor name])
diff --git a/hw/xfree86/Makefile.am b/hw/xfree86/Makefile.am
index 5cce11d..79d2ec5 100644
--- a/hw/xfree86/Makefile.am
+++ b/hw/xfree86/Makefile.am
@@ -1,3 +1,5 @@
+include $(top_srcdir)/cpprules.in
+
 if DRI
 DRI_SUBDIR = dri
 endif
@@ -82,7 +84,23 @@ endif
 optionsdir = $(libdir)/X11
 dist_options_DATA = Options
 
+BUILT_SOURCES = xorg.conf.example
+CLEAN = xorg.conf.example xorg.conf.example.pre
 EXTRA_DIST = xorgconf.cpp
 
+CPP_FILES_FLAGS = \
+	-DRGBPATH=\"$(RGB_DB)\" \
+	-DLOCALFONTPATH="\"$(BASE_FONT_PATH)/local\"" \
+	-DMISCFONTPATH="\"$(BASE_FONT_PATH)/misc\"" \
+	-DT1FONTPATH="\"$(BASE_FONT_PATH)/Type1\"" \
+	-DTRUETYPEFONTPATH="\"$(BASE_FONT_PATH)/TTF\"" \
+	-DCIDFONTPATH="\"$(BASE_FONT_PATH)/CID\"" \
+	-DDPI75FONTPATH="\"$(BASE_FONT_PATH)/75dpi\"" \
+	-DDPI100FONTPATH="\"$(BASE_FONT_PATH)/100dpi\"" \
+	-DMODULEPATH=\"$(DEFAULT_MODULE_PATH)\"
+
 relink:
 	rm -f Xorg && $(MAKE) Xorg
+
+xorg.conf.example.pre: xorgconf.cpp
+	cp $< $@
diff --git a/hw/xfree86/xorgconf.cpp b/hw/xfree86/xorgconf.cpp
index df6704f..71abe13 100644
--- a/hw/xfree86/xorgconf.cpp
+++ b/hw/xfree86/xorgconf.cpp
@@ -54,12 +54,9 @@ XCOMM command (or a combination of both 
 
     FontPath	LOCALFONTPATH
     FontPath	MISCFONTPATH
-    FontPath	DPI75USFONTPATH
-    FontPath	DPI100USFONTPATH
     FontPath	T1FONTPATH
-    FontPath    TRUETYPEFONTPATH
+    FontPath	TRUETYPEFONTPATH
     FontPath	CIDFONTPATH
-    FontPath	SPFONTPATH
     FontPath	DPI75FONTPATH
     FontPath	DPI100FONTPATH
 
diff-tree d029c8f1b72019446a5c873f55ffa43504b03dfb (from a8a0abdbea0573c861a5af9d58f3ce66790455ca)
Author: Alan Coopersmith <alan.coopersmith at sun.com>
Date:   Wed Oct 18 18:11:06 2006 -0700

    Use getisax() instead of asm code to determine available x86 ISA extensions on Solaris

diff --git a/configure.ac b/configure.ac
index 0d7fb6c..2467e79 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,7 +82,8 @@ AC_TYPE_PID_T
 dnl Checks for library functions.
 AC_FUNC_VPRINTF
 AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
-		strtol getopt getopt_long vsnprintf walkcontext backtrace])
+		strtol getopt getopt_long vsnprintf walkcontext backtrace \
+		getisax])
 AC_FUNC_ALLOCA
 dnl Old HAS_* names used in os/*.c.
 AC_CHECK_FUNC([getdtablesize],
diff --git a/fb/fbpict.c b/fb/fbpict.c
index eb305b9..d839994 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -1435,6 +1435,10 @@ fbPictureInit (ScreenPtr pScreen, PictFo
  */
 #if !defined(__amd64__) && !defined(__x86_64__)
 
+#ifdef HAVE_GETISAX
+#include <sys/auxv.h>
+#endif
+
 enum CPUFeatures {
     NoFeatures = 0,
     MMX = 0x1,
@@ -1445,7 +1449,23 @@ enum CPUFeatures {
 };
 
 static unsigned int detectCPUFeatures(void) {
+    unsigned int features = 0;
     unsigned int result;
+
+#ifdef HAVE_GETISAX
+    if (getisax(&result, 1)) {
+        if (result & AV_386_CMOV)
+            features |= CMOV;
+        if (result & AV_386_MMX)
+            features |= MMX;
+        if (result & AV_386_AMD_MMX)
+            features |= MMX_Extensions;
+        if (result & AV_386_SSE)
+            features |= SSE;
+        if (result & AV_386_SSE2)
+            features |= SSE2;
+    }
+#else
     char vendor[13];
     vendor[0] = 0;
     vendor[12] = 0;
@@ -1454,7 +1474,8 @@ static unsigned int detectCPUFeatures(vo
      * %esp here. We can't declare either one as clobbered
      * since they are special registers (%ebx is the "PIC
      * register" holding an offset to global data, %esp the
-     * stack pointer), so we need to make sure they have their+      * original values when we access the output operands.
+     * stack pointer), so we need to make sure they have their
+     * original values when we access the output operands.
      */
     __asm__ ("pushf\n"
              "pop %%eax\n"
@@ -1490,7 +1511,6 @@ static unsigned int detectCPUFeatures(vo
              : "%eax", "%ecx", "%edx"
         );
 
-    unsigned int features = 0;
     if (result) {
         /* result now contains the standard feature bits */
         if (result & (1 << 15))
@@ -1524,6 +1544,7 @@ static unsigned int detectCPUFeatures(vo
                 features |= MMX_Extensions;
         }
     }
+#endif /* HAVE_GETISAX */
     return features;
 }
 
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 53858e9..a920242 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -112,6 +112,9 @@
 /* Define to 1 if you have the `geteuid' function. */
 #undef HAVE_GETEUID
 
+/* Define to 1 if you have the `getisax' function. */
+#undef HAVE_GETISAX
+
 /* Define to 1 if you have the `getopt' function. */
 #undef HAVE_GETOPT
 
diff-tree a8a0abdbea0573c861a5af9d58f3ce66790455ca (from 80642f37d40216035786eaf490952d16f6b5f597)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Oct 18 10:59:07 2006 +0300

    config/dbus: always unref the connection, not close

diff --git a/config/config.c b/config/config.c
index 4d12a07..5b0d90d 100644
--- a/config/config.c
+++ b/config/config.c
@@ -265,7 +265,7 @@ configInitialise()
     }
 
     if (!dbus_connection_get_unix_fd(bus, &configfd)) {
-        dbus_connection_close(bus);
+        dbus_connection_unref(bus);
         configfd = -1;
         FatalError("[dbus] couldn't get fd for bus\n");
         return;
@@ -275,7 +275,7 @@ configInitialise()
     if (!dbus_bus_request_name(bus, busname, 0, &error) ||
         dbus_error_is_set(&error)) {
         dbus_error_free(&error);
-        dbus_connection_close(bus);
+        dbus_connection_unref(bus);
         configfd = -1;
         FatalError("[dbus] couldn't take over org.x.config: %s (%s)\n",
                    error.name, error.message);
@@ -287,7 +287,7 @@ configInitialise()
     if (dbus_error_is_set(&error)) {
         dbus_error_free(&error);
         dbus_bus_release_name(bus, busname, &error);
-        dbus_connection_close(bus);
+        dbus_connection_unref(bus);
         configfd = -1;
         FatalError("[dbus] couldn't match X.Org rule: %s (%s)\n", error.name,
                    error.message);
@@ -299,7 +299,7 @@ configInitialise()
         configfd = -1;
         dbus_bus_release_name(bus, busname, &error);
         dbus_bus_remove_match(bus, MATCH_RULE, &error);
-        dbus_connection_close(bus);
+        dbus_connection_unref(bus);
         FatalError("[dbus] couldn't register object path\n");
         return;
     }
diff-tree 80642f37d40216035786eaf490952d16f6b5f597 (from 5e17cde27b064174584d478130b0f95dcef78deb)
Author: Adam Jackson <ajax at benzedrine.nwnk.net>
Date:   Tue Oct 17 14:53:28 2006 -0400

    Stop building xorgcfg by default.

diff --git a/configure.ac b/configure.ac
index 7992d77..0d7fb6c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1665,13 +1665,9 @@ fi
 
 dnl xorgcfg GUI configuration utility
 AC_ARG_ENABLE(xorgcfg, AS_HELP_STRING([--enable-xorgcfg], 
-	[Build xorgcfg GUI configuration utility (default: auto)]),
-	[XORGCFG=$enableval],[XORGCFG=auto])
-if test "x$XORGCFG" = xauto && test "x$XORG" = xyes; then
-    XORGCFG=yes
-fi
-
-if test "x$XORGCFG" = xyes; then
+	[Build xorgcfg GUI configuration utility (default: no)]),
+	[XORGCFG=$enableval],[XORGCFG=no])
+if test x$XORGCFG = xyes ; then
 	PKG_CHECK_MODULES([XORGCFG_DEP], 
 	    [xkbui >= 1.0.2 xkbfile xxf86misc xxf86vm xaw7 xmu xt xpm xext x11])
 	AC_CHECK_LIB([curses],[waddstr],
diff-tree 5e17cde27b064174584d478130b0f95dcef78deb (from 205c6788d7a34704e36b23f1a93d89e9b986266a)
Author: Matthias Hopf <mhopf at suse.de>
Date:   Tue Oct 17 17:06:44 2006 +0200

    StorePixels() macro could create invalid *x++=*x... code - fixed.

diff --git a/cfb/cfbteblt8.c b/cfb/cfbteblt8.c
index 1db2996..9d4ce57 100644
--- a/cfb/cfbteblt8.c
+++ b/cfb/cfbteblt8.c
@@ -301,7 +301,7 @@ typedef unsigned int	*glyphPointer;
 #define StorePixels(o,p)    dst[o] = p
 #define Loop		    dst += widthDst;
 #else
-#define StorePixels(o,p)    *dst++ = (p)
+#define StorePixels(o,p)    do { *dst = (p); dst++; } while (0)
 #define Loop		    dst += widthLeft;
 #endif
 
diff-tree 205c6788d7a34704e36b23f1a93d89e9b986266a (from 85ac2f16abe9f6e88b4e71609da334d336a9a600)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 16 23:48:09 2006 +0300

    config/dbus: properly initialise vtable
    
    Properly initialise the vtable, so we don't end up with an unregister_function
    pointing to god knows where.

diff --git a/config/config.c b/config/config.c
index a50302f..4d12a07 100644
--- a/config/config.c
+++ b/config/config.c
@@ -251,7 +251,7 @@ configInitialise()
 {
     DBusConnection *bus = NULL;
     DBusError error;
-    DBusObjectPathVTable vtable;
+    DBusObjectPathVTable vtable = { .message_function = configMessage };
 
     configConnection = NULL;
 
@@ -294,7 +294,6 @@ configInitialise()
         return;
     }
 
-    vtable.message_function = configMessage;
     snprintf(busobject, sizeof(busobject), "/org/x/config/%d", atoi(display));
     if (!dbus_connection_register_object_path(bus, busobject, &vtable, bus)) {
         configfd = -1;
@@ -319,10 +318,7 @@ configFini()
 
     if (configConnection) {
         dbus_error_init(&error);
-        /* This causes a segfault inside libdbus.  Sigh. */
-#if 0
         dbus_connection_unregister_object_path(configConnection, busobject);
-#endif
         dbus_bus_remove_match(configConnection, MATCH_RULE, &error);
         dbus_bus_release_name(configConnection, busname, &error);
         dbus_connection_unref(configConnection);
diff-tree 85ac2f16abe9f6e88b4e71609da334d336a9a600 (from 0901eec87ee9f3a2a067695bdbd569ff42149879)
Author: Alan Hourihane <alanh at fairlite.demon.co.uk>
Date:   Mon Oct 16 12:39:05 2006 +0100

    Small modification to blocking signals when switching modes.

diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 20905b0..46d8128 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -208,7 +208,6 @@ xf86SwitchMode(ScreenPtr pScreen, Displa
   ScreenPtr   pCursorScreen;
   Bool        Switched;
   int         px, py;
-  int         sigstate;
 
   if (!pScr->vtSema || !mode || !pScr->SwitchMode)
     return FALSE;
@@ -228,10 +227,8 @@ xf86SwitchMode(ScreenPtr pScreen, Displa
   if (pScreen == pCursorScreen)
     miPointerGetPosition(inputInfo.pointer, &px, &py);
 
-  sigstate = xf86BlockSIGIO ();
   xf86EnterServerState(SETUP);
   Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0);
-  xf86EnterServerState(OPERATING);
   if (Switched) {
     pScr->currentMode = mode;
 
@@ -266,7 +263,7 @@ xf86SwitchMode(ScreenPtr pScreen, Displa
       pScr->frameY1 = pScr->virtualY - 1;
     }
   }
-  xf86UnblockSIGIO (sigstate);
+  xf86EnterServerState(OPERATING);
 
   if (pScr->AdjustFrame)
     (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
diff-tree 0901eec87ee9f3a2a067695bdbd569ff42149879 (from a232693c8c2a206aac47c07b133c071938204e0b)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Oct 15 16:57:09 2006 +0200

    Fix __glXDRIbindTexImage() for 32 bpp on big endian platforms.

diff --git a/GL/glx/glxdri.c b/GL/glx/glxdri.c
index b572304..170662c 100644
--- a/GL/glx/glxdri.c
+++ b/GL/glx/glxdri.c
@@ -359,7 +359,12 @@ __glXDRIbindTexImage(__GLXcontext *baseC
     if (pixmap->drawable.depth >= 24) {
 	bpp = 4;
 	format = GL_BGRA;
-	type = GL_UNSIGNED_BYTE;
+	type =
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+	    GL_UNSIGNED_BYTE;
+#else
+	    GL_UNSIGNED_INT_8_8_8_8_REV;
+#endif
     } else {
 	bpp = 2;
 	format = GL_RGB;
diff-tree a232693c8c2a206aac47c07b133c071938204e0b (from 5563861ab7e56ec891cfce6b34af43fec53ccee3)
Author: Michel Dänzer <michel at tungstengraphics.com>
Date:   Sun Oct 15 16:48:59 2006 +0200

    Add per-drawable Xv colour key helper function.
    
    This allows overlay Xv adaptors to work slightly better with compositing
    managers.
    
    Bump the video driver ABI minor so drivers only need to check for this at build
    time.

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index f0cf5eb..3c3247e 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -84,7 +84,7 @@ typedef enum {
  * mask is 0xFFFF0000.
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 3)
-#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(1, 0)
+#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(1, 1)
 #define ABI_XINPUT_VERSION	SET_ABI_VERSION(1, 0)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(0, 3)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 5)
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 89cb6ba..3e908b8 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -974,6 +974,7 @@ xf86XVEnlistPortInWindow(WindowPtr pWin,
    if(!winPriv) {
 	winPriv = xalloc(sizeof(XF86XVWindowRec));
 	if(!winPriv) return BadAlloc;
+	memset(winPriv, 0, sizeof(XF86XVWindowRec));
 	winPriv->PortRec = portPriv;
 	winPriv->next = PrivRoot;
 	pWin->devPrivates[XF86XVWindowIndex].ptr = (pointer)winPriv;
@@ -1026,6 +1027,9 @@ xf86XVDestroyWindow(WindowPtr pWin)
 
      pPriv->pDraw = NULL;
      tmp = WinPriv;
+     if(WinPriv->pGC) {
+       FreeGC(WinPriv->pGC, 0);
+     }
      WinPriv = WinPriv->next;
      xfree(tmp);
   }
@@ -1118,6 +1122,8 @@ xf86XVClipNotify(WindowPtr pWin, int dx,
   while(WinPriv) {
      pPriv = WinPriv->PortRec;
 
+     if(!pPriv) goto next;
+ 
      if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
 	REGION_DESTROY(pScreen, pPriv->pCompositeClip);
 
@@ -1148,6 +1154,7 @@ xf86XVClipNotify(WindowPtr pWin, int dx,
 	}
      }
 
+next:
      pPrev = WinPriv;
      WinPriv = WinPriv->next;
   }
@@ -1739,9 +1746,13 @@ xf86XVPutImage(
      REGION_UNINIT(pScreen, &VPReg);
   }
 
-  if(portPriv->pDraw) {
+  /* If we are changing windows, unregister our port in the old window */
+  if(portPriv->pDraw && (portPriv->pDraw != pDraw))
      xf86XVRemovePortFromWindow((WindowPtr)(portPriv->pDraw), portPriv);
-  }
+
+  /* Register our port with the new window */
+  ret =  xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
+  if(ret != Success) goto PUT_IMAGE_BAILOUT;
 
   if(!REGION_NOTEMPTY(pScreen, &ClipRegion)) {
      clippedAway = TRUE;
@@ -1772,7 +1783,6 @@ xf86XVPutImage(
   if((ret == Success) &&
 	(portPriv->AdaptorRec->flags & VIDEO_OVERLAID_IMAGES)) {
 
-     xf86XVEnlistPortInWindow((WindowPtr)pDraw, portPriv);
      portPriv->isOn = XV_ON;
      portPriv->pDraw = pDraw;
      portPriv->drw_x = drw_x;  portPriv->drw_y = drw_y;
@@ -1813,6 +1823,56 @@ xf86XVQueryImageAttributes(
 			format->id, width, height, pitches, offsets);
 }
 
+
+_X_EXPORT void
+xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes)
+{
+   ScreenPtr pScreen = pDraw->pScreen;
+   WindowPtr pWin = (WindowPtr)pDraw;
+   XF86XVWindowPtr pPriv = GET_XF86XV_WINDOW(pWin);
+   GCPtr pGC = NULL;
+   XID pval[2];
+   BoxPtr pbox = REGION_RECTS(clipboxes);
+   int i, nbox = REGION_NUM_RECTS(clipboxes);
+   xRectangle *rects;
+
+   if(!xf86Screens[pScreen->myNum]->vtSema) return;
+
+   if(pPriv)
+      pGC = pPriv->pGC;
+
+   if(!pGC) {
+       int status;
+       pval[0] = key;
+       pval[1] = IncludeInferiors;
+       pGC = CreateGC(pDraw, GCForeground | GCSubwindowMode, pval, &status);
+       if(!pGC) return;
+       ValidateGC(pDraw, pGC);
+       if (pPriv) pPriv->pGC = pGC;
+   } else if (key != pGC->fgPixel){
+       pval[0] = key;
+       ChangeGC(pGC, GCForeground, pval);
+       ValidateGC(pDraw, pGC);
+   }
+
+   REGION_TRANSLATE(pDraw->pScreen, clipboxes, -pDraw->x, -pDraw->y);
+
+   rects = ALLOCATE_LOCAL(nbox * sizeof(xRectangle));
+
+   for(i = 0; i < nbox; i++, pbox++) {
+      rects[i].x = pbox->x1;
+      rects[i].y = pbox->y1;
+      rects[i].width = pbox->x2 - pbox->x1;
+      rects[i].height = pbox->y2 - pbox->y1;
+   }
+
+   (*pGC->ops->PolyFillRect)(pDraw, pGC, nbox, rects);
+
+   if (!pPriv) FreeGC(pGC, 0);
+
+   DEALLOCATE_LOCAL(rects);
+}
+
 _X_EXPORT void
 xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes)
 {
diff --git a/hw/xfree86/common/xf86xv.h b/hw/xfree86/common/xf86xv.h
index e0feb57..817e2b9 100644
--- a/hw/xfree86/common/xf86xv.h
+++ b/hw/xfree86/common/xf86xv.h
@@ -232,6 +232,9 @@ void xf86XVFreeVideoAdaptorRec(XF86Video
 void
 xf86XVFillKeyHelper (ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes);
 
+void
+xf86XVFillKeyHelperDrawable (DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes);
+
 Bool
 xf86XVClipVideoHelper(
     BoxPtr dst,
diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h
index ced0536..e716c9c 100644
--- a/hw/xfree86/common/xf86xvpriv.h
+++ b/hw/xfree86/common/xf86xvpriv.h
@@ -80,6 +80,7 @@ typedef struct {
 typedef struct _XF86XVWindowRec{
    XvPortRecPrivatePtr PortRec;
    struct _XF86XVWindowRec *next;
+   GCPtr pGC;
 } XF86XVWindowRec, *XF86XVWindowPtr;
 
 #endif  /* _XF86XVPRIV_H_ */
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 586d5dc..8e39373 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -621,6 +621,7 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86XVAllocateVideoAdaptorRec)
     SYMFUNC(xf86XVFreeVideoAdaptorRec)
     SYMFUNC(xf86XVFillKeyHelper)
+    SYMFUNC(xf86XVFillKeyHelperDrawable)
     SYMFUNC(xf86XVClipVideoHelper)
     SYMFUNC(xf86XVCopyYUV12ToPacked)
     SYMFUNC(xf86XVCopyPacked)
diff-tree 5563861ab7e56ec891cfce6b34af43fec53ccee3 (from 1b1698af41b9038d9f9dbf521737d0baab5a2237)
Author: Alan Coopersmith <alan.coopersmith at sun.com>
Date:   Fri Oct 13 19:05:28 2006 -0700

    Make sure xorgcfg files are included even when dist made with --disable-xorgcfg

diff --git a/hw/xfree86/utils/xorgcfg/Makefile.am b/hw/xfree86/utils/xorgcfg/Makefile.am
index 73e4042..309ed5c 100644
--- a/hw/xfree86/utils/xorgcfg/Makefile.am
+++ b/hw/xfree86/utils/xorgcfg/Makefile.am
@@ -56,6 +56,7 @@ endif
 if NEED_STRLCAT
 STRL_SRCS = $(top_srcdir)/os/strlcat.c $(top_srcdir)/os/strlcpy.c
 endif
+endif BUILD_XORGCFG
 
 xorgcfg_SOURCES =	\
         accessx.c \
@@ -95,10 +96,7 @@ xorgcfg_SOURCES =	\
         xf86config.h \
 	$(STRL_SRCS)
 
-XBMdir = $(includedir)/X11/bitmaps
-XPMdir = $(includedir)/X11/pixmaps
-
-XBM_DATA = \
+BITMAPS = \
         card.xbm \
         keyboard.xbm \
         monitor.xbm \
@@ -112,7 +110,7 @@ XBM_DATA = \
         shorter.xbm \
         taller.xbm
 
-XPM_DATA = \
+PIXMAPS = \
         card.xpm \
         computer.xpm \
         keyboard.xpm \
@@ -122,6 +120,13 @@ XPM_DATA = \
 # Rules needed to cpp man page & app-defaults
 include $(top_srcdir)/cpprules.in
 
+if BUILD_XORGCFG
+XBMdir = $(includedir)/X11/bitmaps
+XPMdir = $(includedir)/X11/pixmaps
+
+XBM_DATA = $(BITMAPS)
+XPM_DATA = $(PIXMAPS)
+
 # App default files  (*.ad)
 
 appdefaultdir = @APPDEFAULTDIR@
@@ -146,7 +151,6 @@ appman_DATA = $(appman_PRE:man=@APP_MAN_
 
 all-local: $(appman_PRE) $(appman_DATA)
 
-EXTRA_DIST = $(XBM_DATA) $(XPM_DATA) XOrgCfg.pre xorgcfg.man.pre
 BUILT_SOURCES = $(appman_PRE)
 CLEANFILES = $(APPDEFAULTFILES) $(BUILT_SOURCES) $(appman_DATA)
 
@@ -156,4 +160,6 @@ SUFFIXES += .$(APP_MAN_SUFFIX) .man
 	-rm -f $@
 	$(LN_S) $< $@
 
-endif
+endif BUILD_XORGCFG
+
+EXTRA_DIST = $(BITMAPS) $(PIXMAPS) XOrgCfg.pre xorgcfg.man.pre
diff-tree 1b1698af41b9038d9f9dbf521737d0baab5a2237 (from 6dd4fc4652f942724039dc2317c560ea7276ab59)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Wed Oct 18 04:57:22 2006 -0400

    Pass SetDeviceValuators down to the driver.
    NOTE: This changes the LocalDeviceRec struct, which breaks input drivers.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 6927720..411dedd 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -501,7 +501,13 @@ int
 SetDeviceValuators (ClientPtr client, DeviceIntPtr dev, int *valuators,
                     int first_valuator, int num_valuators)
 {
-  return BadMatch;
+    LocalDevicePtr local = (LocalDevicePtr) dev->public.devicePrivate;
+
+    if (local->set_device_valuators)
+	return (*local->set_device_valuators)(local, valuators, first_valuator,
+					      num_valuators);
+
+    return BadMatch;
 }
 
 
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 444b2d4..73dcdb7 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -113,7 +113,7 @@ typedef struct _LocalDeviceRec {
     struct _LocalDeviceRec *next;
     char *		    name;
     int			    flags;
-    
+
     Bool		    (*device_control)(DeviceIntPtr device, int what);
     void		    (*read_input)(struct _LocalDeviceRec *local);
     int			    (*control_proc)(struct _LocalDeviceRec *local,
@@ -128,7 +128,11 @@ typedef struct _LocalDeviceRec {
     Bool		    (*reverse_conversion_proc)(
 					struct _LocalDeviceRec *local,
 					int x, int y, int *valuators);
-    
+    int                     (*set_device_valuators)
+				(struct _LocalDeviceRec *local,
+				 int *valuators, int first_valuator,
+				 int num_valuators);
+
     int			    fd;
     Atom		    atom;
     DeviceIntPtr	    dev;
diff-tree 6dd4fc4652f942724039dc2317c560ea7276ab59 (from a484ba15277e66e7ef9b21b238dcbf760695bc63)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 16 00:22:00 2006 +0300

    xkb: fix virtual modmap size computation
    Compute virtual modmap size bounded by nVModMapKeys-1, rather than
    nVModMapKeys.
    
    This is sort of a best guess.  The other way seems a little more
    logical, but also leads to segfaults pretty quickly if you hammer
    GetMap hard enough.  So let's try this one.

diff --git a/xkb/xkb.c b/xkb/xkb.c
index ba8fc7f..bceaf49 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -1325,7 +1325,7 @@ unsigned short *	pMap;
 
     wire= (xkbVModMapWireDesc *)buf;
     pMap= &xkb->server->vmodmap[rep->firstVModMapKey];
-    for (i=0;i<rep->nVModMapKeys;i++,pMap++) {
+    for (i=0;i<rep->nVModMapKeys-1;i++,pMap++) {
 	if (*pMap!=0) {
 	    wire->key= i+rep->firstVModMapKey;
 	    wire->vmods= *pMap;
diff-tree a484ba15277e66e7ef9b21b238dcbf760695bc63 (from ad355fecee3965be576596aeed5da54d776edf1d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 15 23:47:34 2006 +0300

    XkbCopyKeymap: copy server vmods, and name atoms
    Copy server->vmods, and all the atoms in names.

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index c8044c7..cddeb9e 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1294,6 +1294,8 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
             }
         }
 
+        memcpy(dst->server->vmods, src->server->vmods, XkbNumVirtualMods);
+
         if (src->server->vmodmap) {
             if (src->max_key_code != dst->max_key_code) {
                 if (dst->server->vmodmap)
@@ -1427,6 +1429,20 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                 xfree(dst->names->radio_groups);
         }
         dst->names->num_rg = src->names->num_rg;
+
+        dst->names->keycodes = src->names->keycodes;
+        dst->names->geometry = src->names->geometry;
+        dst->names->symbols = src->names->symbols;
+        dst->names->types = src->names->types;
+        dst->names->compat = src->names->compat;
+        dst->names->phys_symbols = src->names->phys_symbols;
+
+        memcpy(dst->names->vmods, src->names->vmods,
+               XkbNumVirtualMods * sizeof(Atom));
+        memcpy(dst->names->indicators, src->names->indicators,
+               XkbNumIndicators * sizeof(Atom));
+        memcpy(dst->names->groups, src->names->groups,
+               XkbNumKbdGroups * sizeof(Atom));
     }
     else {
         if (dst->names)
diff-tree ad355fecee3965be576596aeed5da54d776edf1d (from 4ae7745a0dc86de6346409a69c1e396e0b954514)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 15 21:59:06 2006 +0300

    xkb: make sure we set the map on the right device, not necessarily core
    Forgot that all XKB requests took a device spec: the comparison of
    'if working on the core keyboard, does this device send core events; or,
    is this device the core keyboard?' was broken.  Instead, what we want is
    'if working on the core keyboard, does this device send core events; or,
    is this device the one we're working on?'.

diff --git a/xkb/xkb.c b/xkb/xkb.c
index 880f113..ba8fc7f 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -555,7 +555,7 @@ ProcXkbLatchLockState(ClientPtr client)
 
     for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
         if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) ||
-            tmpd == inputInfo.keyboard) {
+            tmpd == dev) {
             if (!tmpd->key->xkbInfo)
                 continue;
 
@@ -697,7 +697,7 @@ ProcXkbSetControls(ClientPtr client)
 
     for (tmpd = inputInfo.keyboard; tmpd; tmpd = tmpd->next) {
         if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) ||
-            tmpd == inputInfo.keyboard) {
+            tmpd == dev) {
 
             xkbi = tmpd->key->xkbInfo;
             ctrl = xkbi->desc->ctrls;
@@ -5441,12 +5441,13 @@ ProcXkbGetKbdByName(ClientPtr client)
 	xkb->ctrls->num_groups= nTG;
 
         for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
-            if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) ||
-                tmpd == inputInfo.keyboard) {
+            if (tmpd == dev ||
+                (dev->id == inputInfo.keyboard->id && tmpd->key &&
+                 tmpd->coreEvents)) {
 
                 memcpy(tmpd->key->modifierMap, xkb->map->modmap,
                        xkb->max_key_code + 1);
-                if (dev != inputInfo.keyboard)
+                if (tmpd != dev)
                     XkbCopyKeymap(dev->key->xkbInfo->desc,
                                   tmpd->key->xkbInfo->desc, True);
                 XkbUpdateCoreDescription(tmpd, True);
diff-tree 4ae7745a0dc86de6346409a69c1e396e0b954514 (from acd8419948003032056a56d46adbef7c35e7739c)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 15 21:48:01 2006 +0300

    xfree86 input: always open devices on NewInputDeviceRequest

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index a398740..6927720 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -222,15 +222,8 @@ xf86ActivateDevice(LocalDevicePtr local)
     DeviceIntPtr	dev;
 
     if (local->flags & XI86_CONFIGURED) {
-        int	open_on_init;
-        
-        open_on_init = local->flags & (XI86_OPEN_ON_INIT | XI86_ALWAYS_CORE);
-        
-        dev = AddInputDevice(local->device_control,
-                             open_on_init);
-#ifdef DEBUG
-        ErrorF("activated device %d: %s\n", dev->id, local->name);
-#endif
+        dev = AddInputDevice(local->device_control, TRUE);
+
         if (dev == NULL)
             FatalError("Too many input devices");
         
diff-tree acd8419948003032056a56d46adbef7c35e7739c (from fc9b5f84b244ea08480b73bd15ac919b875800fb)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 15 20:42:31 2006 +0300

    config: unref connection, don't close it
    Just unref the connection instead of explicitly closing it (thanks, Rob
    McQueen).
    Add a commented-out unregister_object_path call: unfortunately, when we
    call it, libdbus segfaults.  But if we don't unregister the path, we
    can't register it again.  So regenerations are broken either way, but a
    little less violently like this.

diff --git a/config/config.c b/config/config.c
index e3c33aa..a50302f 100644
--- a/config/config.c
+++ b/config/config.c
@@ -319,9 +319,13 @@ configFini()
 
     if (configConnection) {
         dbus_error_init(&error);
+        /* This causes a segfault inside libdbus.  Sigh. */
+#if 0
+        dbus_connection_unregister_object_path(configConnection, busobject);
+#endif
         dbus_bus_remove_match(configConnection, MATCH_RULE, &error);
         dbus_bus_release_name(configConnection, busname, &error);
-        dbus_connection_close(configConnection);
+        dbus_connection_unref(configConnection);
         RemoveGeneralSocket(configfd);
         configConnection = NULL;
         configfd = -1;
diff-tree fc9b5f84b244ea08480b73bd15ac919b875800fb (from ec35e7198debf938f1115f584e675ce5995743e3)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 15 20:01:01 2006 +0300

    dix/devices: add devices in proper forward order
    Add devices in forward order with the normal linked list convention.
    Previously, AddInputDevice would add all the devices in reverse order to
    off_devices, before they were added again in reverse order to devices with
    EnableDevice.
    This just makes both work in forward order, which provides the ordering as
    you'd expect when hotplugging devices (i.e. adds them to the head, not the
    tail).

diff --git a/dix/devices.c b/dix/devices.c
index bf8c58a..0121eea 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -86,7 +86,7 @@ int CoreDevicePrivatesIndex = 0, CoreDev
 DeviceIntPtr
 AddInputDevice(DeviceProc deviceProc, Bool autoStart)
 {
-    register DeviceIntPtr dev;
+    register DeviceIntPtr dev, *prev; /* not a typo */
 
     if (inputInfo.numDevices >= MAX_DEVICES)
 	return (DeviceIntPtr)NULL;
@@ -130,8 +130,12 @@ AddInputDevice(DeviceProc deviceProc, Bo
     dev->devPrivates = NULL;
     dev->unwrapProc = NULL;
     dev->coreEvents = TRUE;
-    dev->next = inputInfo.off_devices;
-    inputInfo.off_devices = dev;
+
+    for (prev = &inputInfo.off_devices; *prev; prev = &(*prev)->next)
+        ;
+    *prev = dev;
+    dev->next = NULL;
+
     return dev;
 }
 
@@ -151,8 +155,12 @@ EnableDevice(register DeviceIntPtr dev)
 	return FALSE;
     }
     *prev = dev->next;
-    dev->next = inputInfo.devices;
-    inputInfo.devices = dev;
+
+    for (prev = &inputInfo.devices; *prev; prev = &(*prev)->next)
+        ;
+    *prev = dev;
+    dev->next = NULL;
+
     return TRUE;
 }
 
diff-tree ec35e7198debf938f1115f584e675ce5995743e3 (from a05044cfc14a8bc6cc31236dcecada60bec09924)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 15 19:44:49 2006 +0300

    config: add replies and dbus api documentation
    Add replies, which use standard X error values, to the two currently-supported
    input configuration requests.
    Document the D-BUS API we use.
    Make sure we free everything when we encounter an error.
    Add a _source option to all incoming requests, noting that it came from a
    client.
    Reject all requests to add a device where an option name contains an
    underscore.

diff --git a/config/config.c b/config/config.c
index 8cb4406..e3c33aa 100644
--- a/config/config.c
+++ b/config/config.c
@@ -29,17 +29,26 @@
 #define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbus/dbus.h>
 #include <string.h>
+
+#include <X11/X.h>
+
 #include "opaque.h" /* for 'display': there has to be a better way */
                     /* the above comment lies.  there is no better way. */
 #include "input.h"
+#include "inputstr.h"
 #include "config.h"
+#include "os.h"
 
 #define MATCH_RULE "type='method_call',interface='org.x.config.input'"
 
-#define MALFORMED_MSG "config: malformed message, dropping"
-#define MALFORMED_MESSAGE() DebugF(MALFORMED_MSG)
-#define MALFORMED_MESSAGE_ERROR() DebugF(MALFORMED_MSG ": %s, %s", \
-                                       error.name, error.message)
+#define MALFORMED_MSG "[config] malformed message, dropping"
+#define MALFORMED_MESSAGE() { DebugF(MALFORMED_MSG "\n"); \
+                            ret = BadValue; \
+                            goto unwind; }
+#define MALFORMED_MESSAGE_ERROR() { DebugF(MALFORMED_MSG ": %s, %s", \
+                                       error->name, error->message); \
+                                  ret = BadValue; \
+                                  goto unwind; }
 
 static DBusConnection *configConnection = NULL;
 static int configfd = -1;
@@ -55,130 +64,186 @@ configDispatch()
     dbus_connection_read_write_dispatch(configConnection, 0);
 }
 
-static DBusHandlerResult
-configMessage(DBusConnection *connection, DBusMessage *message, void *closure)
+static int
+configAddDevice(DBusMessage *message, DBusMessageIter *iter, DBusError *error)
 {
-    InputOption *option = NULL, *ret = NULL;
-    DBusMessageIter iter, subiter;
-    DBusError error;
+    DBusMessageIter subiter;
+    InputOption *tmpo = NULL, *options = NULL;
     char *tmp = NULL;
+    int ret = BadMatch;
+
+    DebugF("[config] adding device\n");
+
+    /* signature should be [ss][ss]... */
+    options = (InputOption *) xcalloc(sizeof(InputOption), 1);
+    if (!options) {
+        ErrorF("[config] couldn't allocate option\n");
+        return BadAlloc;
+    }
+
+    options->key = xstrdup("_source");
+    options->value = xstrdup("client/dbus");
+
+    while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_ARRAY) {
+        tmpo = (InputOption *) xcalloc(sizeof(InputOption), 1);
+        if (!tmpo) {
+            ErrorF("[config] couldn't allocate option\n");
+            ret = BadAlloc;
+            goto unwind;
+        }
+
+        dbus_message_iter_recurse(iter, &subiter);
+
+        if (dbus_message_iter_get_arg_type(&subiter) != DBUS_TYPE_STRING)
+            MALFORMED_MESSAGE();
+
+        dbus_message_iter_get_basic(&subiter, &tmp);
+        if (!tmp)
+            MALFORMED_MESSAGE();
+        if (tmp[0] == '_') {
+            ErrorF("[config] attempted subterfuge: option name %s given\n",
+                   tmp);
+            MALFORMED_MESSAGE();
+        }
+        tmpo->key = xstrdup(tmp);
+        if (!tmpo->key) {
+            ErrorF("[config] couldn't duplicate key!\n");
+            ret = BadAlloc;
+            goto unwind;
+        }
+
+        if (!dbus_message_iter_has_next(&subiter))
+            MALFORMED_MESSAGE();
+        dbus_message_iter_next(&subiter);
+        if (dbus_message_iter_get_arg_type(&subiter) != DBUS_TYPE_STRING)
+            MALFORMED_MESSAGE();
+
+        dbus_message_iter_get_basic(&subiter, &tmp);
+        if (!tmp)
+            MALFORMED_MESSAGE();
+        tmpo->value = xstrdup(tmp);
+        if (!tmpo->value) {
+            ErrorF("[config] couldn't duplicate option!\n");
+            ret = BadAlloc;
+            goto unwind;
+        }
+
+        tmpo->next = options;
+        options = tmpo;
+        dbus_message_iter_next(iter);
+    }
+
+    ret = NewInputDeviceRequest(options);
+    if (ret != Success)
+        DebugF("[config] NewInputDeviceRequest failed\n");
+
+    return ret;
+
+unwind:
+    if (tmpo->key)
+        xfree(tmpo->key);
+    if (tmpo->value)
+        xfree(tmpo->value);
+    if (tmpo)
+        xfree(tmpo);
+
+    while (options) {
+        tmpo = options;
+        options = options->next;
+        if (tmpo->key)
+            xfree(tmpo->key);
+        if (tmpo->value)
+            xfree(tmpo->value);
+        xfree(tmpo);
+    }
+
+    return ret;
+}
+
+static int
+configRemoveDevice(DBusMessage *message, DBusMessageIter *iter,
+                   DBusError *error)
+{
     int deviceid = -1;
+    int ret = BadMatch;
     DeviceIntPtr pDev = NULL;
 
+    if (!dbus_message_get_args(message, error, DBUS_TYPE_INT32,
+                               &deviceid, DBUS_TYPE_INVALID)) {
+        MALFORMED_MESSAGE_ERROR();
+    }
+
+    if (deviceid < 0 || !(pDev = LookupDeviceIntRec(deviceid))) {
+        DebugF("[config] bogus device id %d given\n", deviceid);
+        ret = BadMatch;
+        goto unwind;
+    }
+
+    DebugF("[config] removing device %s (id %d)\n", pDev->name, deviceid);
+
+    /* Call PIE here so we don't try to dereference a device that's
+     * already been removed. */
+    OsBlockSignals();
+    ProcessInputEvents();
+    RemoveDevice(pDev);
+    OsReleaseSignals();
+
+    return Success;
+
+unwind:
+    return ret;
+}
+
+static DBusHandlerResult
+configMessage(DBusConnection *connection, DBusMessage *message, void *closure)
+{
+    DBusMessageIter iter;
+    DBusError error;
+    DBusMessage *reply;
+    DBusConnection *bus = closure;
+    int ret = BadDrawable; /* nonsensical value */
+
     dbus_error_init(&error);
 
     if (strcmp(dbus_message_get_interface(message),
                "org.x.config.input") == 0) {
         if (!dbus_message_iter_init(message, &iter)) {
-            ErrorF("config: failed to init iterator\n");
+            ErrorF("[config] failed to init iterator\n");
             dbus_error_free(&error);
             return DBUS_HANDLER_RESULT_NEED_MEMORY; /* ?? */
         }
-        if (strcmp(dbus_message_get_member(message), "add") == 0) {
-            DebugF("config: adding device\n");
-            /* signature should be [ss][ss]... */
-            while (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_ARRAY) {
-                option = (InputOption *)xcalloc(sizeof(InputOption), 1);
-                if (!option) {
-                    while (ret) {
-                        option = ret;
-                        ret = ret->next;
-                        xfree(option);
-                    }
-                    dbus_error_free(&error);
-                    return DBUS_HANDLER_RESULT_NEED_MEMORY;
-                }
-
-                dbus_message_iter_recurse(&iter, &subiter);
-
-                if (dbus_message_iter_get_arg_type(&subiter) !=
-                    DBUS_TYPE_STRING) {
-                    MALFORMED_MESSAGE();
-                    xfree(option);
-                    dbus_error_free(&error);
-                    return DBUS_HANDLER_RESULT_HANDLED;
-                }
-                dbus_message_iter_get_basic(&subiter, &tmp);
-                if (!tmp) {
-                    MALFORMED_MESSAGE();
-                    xfree(option);
-                    break;
-                }
-                option->key = xstrdup(tmp);
-                if (!option->key) {
-                    ErrorF("couldn't duplicate the key!\n");
-                    xfree(option);
-                    break;
-                }
-
-                if (!dbus_message_iter_has_next(&subiter)) {
-                    MALFORMED_MESSAGE();
-                    xfree(option->key);
-                    xfree(option);
-                    dbus_error_free(&error);
-                    return DBUS_HANDLER_RESULT_HANDLED;
-                }
-                dbus_message_iter_next(&subiter);
-
-                if (dbus_message_iter_get_arg_type(&subiter) !=
-                    DBUS_TYPE_STRING) {
-                    MALFORMED_MESSAGE();
-                    xfree(option);
-                    dbus_error_free(&error);
-                    return DBUS_HANDLER_RESULT_HANDLED;
-                }
-                dbus_message_iter_get_basic(&subiter, &tmp);
-                if (!tmp) {
-                    MALFORMED_MESSAGE();
-                    xfree(option->key);
-                    xfree(option);
-                    break;
-                }
-                option->value = xstrdup(tmp);
-                if (!option->value) {
-                    ErrorF("couldn't duplicate the option!\n");
-                    xfree(option->value);
-                    xfree(option);
-                    break;
-                }
-
-                option->next = ret;
-                ret = option;
-                dbus_message_iter_next(&iter);
-            }
-
-            if (NewInputDeviceRequest(ret) != Success) {
-                DebugF("config: NewInputDeviceRequest failed\n");
-            }
-            dbus_error_free(&error);
-            return DBUS_HANDLER_RESULT_HANDLED;
-        }
-        else if (strcmp(dbus_message_get_member(message), "remove") == 0) {
-            ErrorF("config: removing device\n");
-            if (!dbus_message_get_args(message, &error, DBUS_TYPE_INT32,
-                                       &deviceid, DBUS_TYPE_INVALID)) {
-                MALFORMED_MESSAGE_ERROR();
-                dbus_error_free(&error);
-                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-            }
-            if (deviceid < 0 || !(pDev = LookupDeviceIntRec(deviceid))) {
-                DebugF("config: bogus device id %d given\n", deviceid);
-                dbus_error_free(&error);
-                return DBUS_HANDLER_RESULT_HANDLED;
-            }
-            /* Call PIE here so we don't try to dereference a device that's
-             * already been removed.  Technically there's still a small race
-             * here, so we should ensure that SIGIO is blocked. */
-            ProcessInputEvents();
-            RemoveDevice(pDev);
+
+        if (strcmp(dbus_message_get_member(message), "add") == 0)
+            ret = configAddDevice(message, &iter, &error);
+        else if (strcmp(dbus_message_get_member(message), "remove") == 0)
+            ret = configRemoveDevice(message, &iter, &error);
+    }
+
+    if (ret != BadDrawable && ret != BadAlloc) {
+        reply = dbus_message_new_method_return(message);
+        dbus_message_iter_init_append(reply, &iter);
+
+        if (!dbus_message_iter_append_basic(&iter, DBUS_TYPE_INT32, &ret)) {
+            ErrorF("[config] couldn't append to iterator\n");
             dbus_error_free(&error);
             return DBUS_HANDLER_RESULT_HANDLED;
         }
+
+        if (!dbus_connection_send(bus, reply, NULL))
+            ErrorF("[config] failed to send reply\n");
+        dbus_connection_flush(bus);
+
+        dbus_message_unref(reply);
     }
 
     dbus_error_free(&error);
 
-    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+    if (ret == BadAlloc)
+        return DBUS_HANDLER_RESULT_NEED_MEMORY;
+    else if (ret == BadDrawable)
+        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+    else
+        return DBUS_HANDLER_RESULT_HANDLED;
 }
 
 void
@@ -231,7 +296,7 @@ configInitialise()
 
     vtable.message_function = configMessage;
     snprintf(busobject, sizeof(busobject), "/org/x/config/%d", atoi(display));
-    if (!dbus_connection_register_object_path(bus, busobject, &vtable, NULL)) {
+    if (!dbus_connection_register_object_path(bus, busobject, &vtable, bus)) {
         configfd = -1;
         dbus_bus_release_name(bus, busname, &error);
         dbus_bus_remove_match(bus, MATCH_RULE, &error);
@@ -243,9 +308,7 @@ configInitialise()
     DebugF("[dbus] registered object path %s\n", busobject);
 
     dbus_error_free(&error);
-
     configConnection = bus;
-
     AddGeneralSocket(configfd);
 }
 
@@ -265,7 +328,9 @@ configFini()
         dbus_error_free(&error);
     }
 }
-#else
+
+#else /* !HAVE_DBUS */
+
 void
 configDispatch()
 {
@@ -280,4 +345,5 @@ void
 configFini()
 {
 }
-#endif
+
+#endif /* HAVE_DBUS */
diff --git a/config/dbus-api b/config/dbus-api
new file mode 100644
index 0000000..53bb3e4
--- /dev/null
+++ b/config/dbus-api
@@ -0,0 +1,35 @@
+D-BUS Configuration API v0.1
+----------------------------
+
+The X server will register the bus name org.x.config.displayN, and the 
+object /org/x/config/N, where N is the display number.
+
+Currently only hotplugging of input devices is supported.
+
+org.x.config.input:
+    org.x.config.input.add:
+        Takes an argument of key/value option pairs in arrays, e.g.:
+         [ss][ss][ss][ss]
+        is the signature for four options.  These options will be passed
+        to the input driver as with any others.
+        Option names beginning with _ are not allowed; they are reserved
+        for internal use.
+
+        Returns one int32, which is an X Status, as defined in X.h.  If
+        everything is successful, Success will be returned.  BadMatch will
+        be returned if the options given do not match any device.  BadValue
+        is returned for a malformed message.
+
+        Notably, BadAlloc is never returned: the server internally signals
+        to D-BUS that the attempt failed for lack of memory.
+
+        The return does not notify the client of which devices were created
+        or modified as a result of this request: clients are encouraged to
+        listen for the XInput DevicePresenceNotify event to monitor changes
+        in the device list.
+
+    org.x.config.input.remove:
+        Takes one int32 argument, which is the device ID to remove, i.e.:
+         i
+        is the signature.
+        Same return values as org.x.config.input.add.
diff-tree a05044cfc14a8bc6cc31236dcecada60bec09924 (from 4d8030076ed1a7680bdfcb7b89af1045bdc40304)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Oct 14 22:14:56 2006 +0300

    xkb: better support of XkbDfltXIId
    XKB.h specifies that XkbDfltXIId should be used where the client doesn't
    care about the device identifier.  We take this to mean core devices,
    where practical.

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 9a3be31..c8044c7 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -78,6 +78,8 @@ _XkbLookupKeyboard(int id,int *why_rtrn)
 {
 DeviceIntPtr dev = NULL;
 
+    if (id == XkbDfltXIId)
+        id = XkbUseCoreKbd;
     if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
 	return NULL;
     else if ((!dev->key)||(!dev->key->xkbInfo)) {
@@ -108,6 +110,8 @@ _XkbLookupLedDevice(int id,int *why_rtrn
 {
 DeviceIntPtr dev = NULL;
 
+    if (id == XkbDfltXIId)
+        id = XkbUseCorePtr;
     if ((dev= _XkbLookupAnyDevice(id,why_rtrn))==NULL)
 	return NULL;
     else if ((!dev->kbdfeed)&&(!dev->leds)) {
diff-tree 4d8030076ed1a7680bdfcb7b89af1045bdc40304 (from 6afc7c284690b1e2bb7544b5bc4f31a3f6a05519)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Oct 14 22:14:07 2006 +0300

    dix: move GetKeyboardEvents/GetPointerEvents to a new file, export symbols
    Move GKE and GPE to a separate file, to help stem the events.c explosion.
    Mark GKE/GKVE/GPE as _X_EXPORT.

diff --git a/dix/Makefile.am b/dix/Makefile.am
index d26d9ea..724d1d1 100644
--- a/dix/Makefile.am
+++ b/dix/Makefile.am
@@ -17,6 +17,7 @@ libdix_la_SOURCES = 	\
 	extension.c	\
 	ffs.c		\
 	gc.c		\
+	getevents.c	\
 	globals.c	\
 	glyphcurs.c	\
 	grabs.c		\
diff --git a/dix/events.c b/dix/events.c
index ebc43b0..e1a3e75 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -131,13 +131,10 @@ of the copyright holder.
 #endif
 #include "globals.h"
 
-#include "mipointer.h"
-
 #ifdef XKB
 #include <X11/extensions/XKBproto.h>
 #include <X11/extensions/XKBsrv.h>
 extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
-extern Bool XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies);
 #endif
 
 #ifdef XACE
@@ -4592,473 +4589,3 @@ WriteEventsToClient(ClientPtr pClient, i
 	(void)WriteToClient(pClient, count * sizeof(xEvent), (char *) events);
     }
 }
-
-/* Maximum number of valuators, divided by six, rounded up. */
-#define MAX_VALUATOR_EVENTS 6
-
-/**
- * Returns the maximum number of events GetKeyboardEvents,
- * GetKeyboardValuatorEvents, and GetPointerEvents will ever return.
- *
- * Should be used in DIX as:
- * xEvent *events = xcalloc(sizeof(xEvent), GetMaximumEventsNum());
- */
-int
-GetMaximumEventsNum() {
-    /* Two base events -- core and device, plus valuator events.  Multiply
-     * by two if we're doing key repeats. */
-    int ret = 2 + MAX_VALUATOR_EVENTS;
-
-#ifdef XKB
-    if (noXkbExtension)
-#endif
-        ret *= 2;
-
-    return ret;
-}
-
-/**
- * Convenience wrapper around GetKeyboardValuatorEvents, that takes no
- * valuators.
- */
-int
-GetKeyboardEvents(xEvent *events, DeviceIntPtr pDev, int type, int key_code) {
-    return GetKeyboardValuatorEvents(events, pDev, type, key_code, 0, 0, NULL);
-}
-
-/**
- * Returns a set of keyboard events for KeyPress/KeyRelease, optionally
- * also with valuator events.  Handles Xi and XKB.
- *
- * events is not NULL-terminated; the return value is the number of events.
- * The DDX is responsible for allocating the event structure in the first
- * place via GetMaximumEventsNum(), and for freeing it.
- *
- * If pDev is set to send core events, then the keymap on the core
- * keyboard will be pivoted to that of the new keyboard and the appropriate
- * MapNotify events (both core and XKB) will be sent.
- *
- * Note that this function recurses!  If called for non-XKB, a repeating
- * key press will trigger a matching KeyRelease, as well as the
- * KeyPresses.
- */
-int GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
-                              int key_code, int first_valuator,
-                              int num_valuators, int *valuators) {
-    int numEvents = 0, ms = 0, i = 0;
-    int final_valuator = first_valuator + num_valuators;
-    KeySym sym = pDev->key->curKeySyms.map[key_code *
-                                           pDev->key->curKeySyms.mapWidth];
-    deviceKeyButtonPointer *kbp = NULL;
-    deviceValuator *xv = NULL;
-    KeyClassPtr ckeyc;
-
-    if (!events)
-        return 0;
-    
-    if (type != KeyPress && type != KeyRelease)
-        return 0;
-
-    if (!pDev->key || !pDev->focus || !pDev->kbdfeed ||
-        (pDev->coreEvents && !inputInfo.keyboard->key))
-        return 0;
-
-    if (pDev->coreEvents)
-        numEvents = 2;
-    else
-        numEvents = 1;
-
-    if (num_valuators) {
-        if ((num_valuators / 6) + 1 > MAX_VALUATOR_EVENTS)
-            num_valuators = MAX_VALUATOR_EVENTS;
-        numEvents += (num_valuators / 6) + 1;
-    }
-
-#ifdef XKB
-    if (noXkbExtension)
-#endif
-    {
-        switch (sym) {
-            case XK_Num_Lock:
-            case XK_Caps_Lock:
-            case XK_Scroll_Lock:
-            case XK_Shift_Lock:
-                if (type == KeyRelease)
-                    return 0;
-                else if (type == KeyPress &&
-                         (pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
-                        type = KeyRelease;
-        }
-    }
-
-    /* Handle core repeating, via press/release/press/release.
-     * FIXME: In theory, if you're repeating with two keyboards,
-     *        you could get unbalanced events here. */
-    if (type == KeyPress &&
-        (((pDev->key->down[key_code >> 3] & (key_code & 7))) & 1)) {
-        if (!pDev->kbdfeed->ctrl.autoRepeat ||
-            pDev->key->modifierMap[key_code] ||
-            !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
-                & (1 << (key_code & 7))))
-            return 0;
-
-#ifdef XKB
-        if (noXkbExtension)
-#endif
-        {
-            numEvents += GetKeyboardValuatorEvents(events, pDev,
-                                                   KeyRelease, key_code,
-                                                   first_valuator, num_valuators,
-                                                   valuators);
-            events += numEvents;
-        }
-    }
-    
-
-    ms = GetTimeInMillis();
-
-    kbp = (deviceKeyButtonPointer *) events;
-    kbp->time = ms;
-    kbp->deviceid = pDev->id;
-    if (type == KeyPress)
-        kbp->type = DeviceKeyPress;
-    else if (type == KeyRelease)
-        kbp->type = DeviceKeyRelease;
-
-    if (num_valuators) {
-        kbp->deviceid |= MORE_EVENTS;
-        for (i = first_valuator; i < final_valuator; i += 6) {
-            xv = (deviceValuator *) ++events;
-            xv->type = DeviceValuator;
-            xv->first_valuator = i;
-            xv->num_valuators = num_valuators;
-            xv->deviceid = kbp->deviceid;
-            switch (num_valuators - first_valuator) {
-            case 6:
-                xv->valuator5 = valuators[i+5];
-            case 5:
-                xv->valuator4 = valuators[i+4];
-            case 4:
-                xv->valuator3 = valuators[i+3];
-            case 3:
-                xv->valuator2 = valuators[i+2];
-            case 2:
-                xv->valuator1 = valuators[i+1];
-            case 1:
-                xv->valuator0 = valuators[i];
-            }
-        }
-    }
-
-    if (pDev->coreEvents) {
-        events++;
-        events->u.keyButtonPointer.time = ms;
-        events->u.u.type = type;
-        events->u.u.detail = key_code;
-
-        if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr !=
-            pDev) {
-            ckeyc = inputInfo.keyboard->key;
-            memcpy(ckeyc->modifierMap, pDev->key->modifierMap, MAP_LENGTH);
-            if (ckeyc->modifierKeyMap)
-                xfree(ckeyc->modifierKeyMap);
-            ckeyc->modifierKeyMap = xalloc(8 * pDev->key->maxKeysPerModifier);
-            memcpy(ckeyc->modifierKeyMap, pDev->key->modifierKeyMap,
-                    (8 * pDev->key->maxKeysPerModifier));
-            ckeyc->maxKeysPerModifier = pDev->key->maxKeysPerModifier;
-            ckeyc->curKeySyms.minKeyCode = pDev->key->curKeySyms.minKeyCode;
-            ckeyc->curKeySyms.maxKeyCode = pDev->key->curKeySyms.maxKeyCode;
-            SetKeySymsMap(&ckeyc->curKeySyms, &pDev->key->curKeySyms);
-#ifdef XKB
-            if (!noXkbExtension && pDev->key->xkbInfo &&
-                pDev->key->xkbInfo->desc) {
-                if (!XkbCopyKeymap(pDev->key->xkbInfo->desc,
-                                   ckeyc->xkbInfo->desc, True))
-                    FatalError("Couldn't pivot keymap from device to core!\n");
-            }
-#endif
-            SendMappingNotify(MappingKeyboard, ckeyc->curKeySyms.minKeyCode,
-                              (ckeyc->curKeySyms.maxKeyCode -
-                               ckeyc->curKeySyms.minKeyCode),
-                              serverClient);
-            inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
-        }
-    }
-
-    return numEvents;
-}
-
-/* Originally a part of xf86PostMotionEvent. */
-static void
-acceleratePointer(DeviceIntPtr pDev, int first_valuator, int num_valuators,
-                  int *valuators)
-{
-    float mult = 0.0;
-    int dx = 0, dy = 0;
-    int *px = NULL, *py = NULL;
-
-    if (!num_valuators || !valuators)
-        return;
-
-    if (first_valuator == 0) {
-        dx = valuators[0];
-        px = &valuators[0];
-    }
-    if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
-        dy = valuators[1 - first_valuator];
-        py = &valuators[1 - first_valuator];
-    }
-
-    if (!dx && !dy)
-        return;
-
-    /*
-     * Accelerate
-     */
-    if (pDev->ptrfeed && pDev->ptrfeed->ctrl.num) {
-        /* modeled from xf86Events.c */
-        if (pDev->ptrfeed->ctrl.threshold) {
-            if ((abs(dx) + abs(dy)) >= pDev->ptrfeed->ctrl.threshold) {
-                pDev->valuator->dxremaind = ((float)dx *
-                                             (float)(pDev->ptrfeed->ctrl.num)) /
-                                             (float)(pDev->ptrfeed->ctrl.den) +
-                                            pDev->valuator->dxremaind;
-                if (px) {
-                    *px = (int)pDev->valuator->dxremaind;
-                    pDev->valuator->dxremaind = pDev->valuator->dxremaind -
-                                                (float)(*px);
-                }
-
-                pDev->valuator->dyremaind = ((float)dy *
-                                             (float)(pDev->ptrfeed->ctrl.num)) /
-                                             (float)(pDev->ptrfeed->ctrl.den) +
-                                            pDev->valuator->dyremaind;
-                if (py) {
-                    *py = (int)pDev->valuator->dyremaind;
-                    pDev->valuator->dyremaind = pDev->valuator->dyremaind -
-                                                (float)(*py);
-                }
-            }
-        }
-        else {
-            mult = pow((float)(dx * dx + dy * dy),
-                       ((float)(pDev->ptrfeed->ctrl.num) /
-                        (float)(pDev->ptrfeed->ctrl.den) - 1.0) /
-                       2.0) / 2.0;
-            if (dx) {
-                pDev->valuator->dxremaind = mult * (float)dx +
-                                            pDev->valuator->dxremaind;
-                *px = (int)pDev->valuator->dxremaind;
-                pDev->valuator->dxremaind = pDev->valuator->dxremaind -
-                                            (float)(*px);
-            }
-            if (dy) {
-                pDev->valuator->dyremaind = mult * (float)dy +
-                                            pDev->valuator->dyremaind;
-                *py = (int)pDev->valuator->dyremaind;
-                pDev->valuator->dyremaind = pDev->valuator->dyremaind -
-                                            (float)(*py);
-            }
-        }
-    }
-}
-
-/**
- * Generate a series of xEvents (returned in xE) representing pointer
- * motion, or button presses.  Xi and XKB-aware.
- *
- * events is not NULL-terminated; the return value is the number of events.
- * The DDX is responsible for allocating the event structure in the first
- * place via GetMaximumEventsNum(), and for freeing it.
- */
-int
-GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
-                 int flags, int first_valuator, int num_valuators,
-                 int *valuators) {
-    int num_events = 0, ms = 0, final_valuator = 0, i = 0;
-    deviceKeyButtonPointer *kbp = NULL;
-    deviceValuator *xv = NULL;
-    AxisInfoPtr axes = NULL;
-    Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
-    DeviceIntPtr cp = inputInfo.pointer;
-    int x = 0, y = 0;
-
-    if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
-        return 0;
-
-    if (!pDev->button || (pDev->coreEvents && (!cp->button || !cp->valuator)))
-        return 0;
-
-    /* You fail. */
-    if (first_valuator < 0)
-        return 0;
-
-    if (pDev->coreEvents)
-        num_events = 2;
-    else
-        num_events = 1;
-
-    /* Do we need to send a DeviceValuator event? */
-    if ((num_valuators + first_valuator) >= 2 && sendValuators) {
-        if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS)
-            num_valuators = MAX_VALUATOR_EVENTS;
-        num_events += (num_valuators / 6) + 1;
-    }
-    else if (type == MotionNotify && num_valuators <= 0) {
-        return 0;
-    }
-
-    final_valuator = num_valuators + first_valuator;
-
-    ms = GetTimeInMillis();
-
-    kbp = (deviceKeyButtonPointer *) events;
-    kbp->time = ms;
-    kbp->deviceid = pDev->id;
-
-    if (flags & POINTER_ABSOLUTE) {
-        if (num_valuators >= 1 && first_valuator == 0) {
-            x = valuators[0];
-        }
-        else {
-            if (pDev->coreEvents)
-                x = cp->valuator->lastx;
-            else
-                x = pDev->valuator->lastx;
-        }
-
-        if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
-            y = valuators[1 - first_valuator];
-        }
-        else {
-            if (pDev->coreEvents)
-                x = cp->valuator->lasty;
-            else
-                y = pDev->valuator->lasty;
-        }
-    }
-    else {
-        if (flags & POINTER_ACCELERATE)
-            acceleratePointer(pDev, first_valuator, num_valuators,
-                              valuators);
-
-        if (pDev->coreEvents) {
-            if (first_valuator == 0 && num_valuators >= 1)
-                x = cp->valuator->lastx + valuators[0];
-            else
-                x = cp->valuator->lastx;
-
-            if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
-                y = cp->valuator->lasty + valuators[1 - first_valuator];
-            else
-                y = cp->valuator->lasty;
-        }
-        else {
-            if (first_valuator == 0 && num_valuators >= 1)
-                x = pDev->valuator->lastx + valuators[0];
-            else
-                x = pDev->valuator->lastx;
-
-            if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
-                y = pDev->valuator->lasty + valuators[1 - first_valuator];
-            else
-                y = pDev->valuator->lasty;
-        }
-    }
-
-
-    axes = pDev->valuator->axes;
-    if (x < axes->min_value)
-        x = axes->min_value;
-    if (axes->max_value > 0 && x > axes->max_value)
-        x = axes->max_value;
-
-    axes++;
-    if (y < axes->min_value)
-        y = axes->min_value;
-    if (axes->max_value > 0 && y > axes->max_value)
-        y = axes->max_value;
-
-    /* This takes care of crossing screens for us, as well as clipping
-     * to the current screen.  Right now, we only have one history buffer,
-     * so we don't set this for both the device and core.*/
-    miPointerSetPosition(pDev, &x, &y, ms);
-
-    if (pDev->coreEvents) {
-        cp->valuator->lastx = x;
-        cp->valuator->lasty = y;
-    }
-    pDev->valuator->lastx = x;
-    pDev->valuator->lasty = y;
-
-    if (type == MotionNotify) {
-        kbp->type = DeviceMotionNotify;
-    }
-    else {
-        if (type == ButtonPress)
-            kbp->type = DeviceButtonPress;
-        else if (type == ButtonRelease)
-            kbp->type = DeviceButtonRelease;
-        kbp->detail = pDev->button->map[buttons];
-    }
-
-    kbp->root_x = x;
-    kbp->root_y = y;
-
-    if (final_valuator > 2 && sendValuators) {
-        kbp->deviceid |= MORE_EVENTS;
-        for (i = first_valuator; i < final_valuator; i += 6) {
-            xv = (deviceValuator *) ++events;
-            xv->type = DeviceValuator;
-            xv->first_valuator = i;
-            xv->num_valuators = num_valuators;
-            xv->deviceid = kbp->deviceid;
-            switch (final_valuator - i) {
-            case 6:
-                xv->valuator5 = valuators[i+5];
-            case 5:
-                xv->valuator4 = valuators[i+4];
-            case 4:
-                xv->valuator3 = valuators[i+3];
-            case 3:
-                xv->valuator2 = valuators[i+2];
-            case 2:
-                /* x and y may have been accelerated. */
-                if (i == 0)
-                    xv->valuator1 = kbp->root_y;
-                else
-                    xv->valuator1 = valuators[i+1];
-            case 1:
-                /* x and y may have been accelerated. */
-                if (i == 0)
-                    xv->valuator0 = kbp->root_x;
-                else
-                    xv->valuator0 = valuators[i];
-            }
-        }
-    }
-
-    if (pDev->coreEvents) {
-        events++;
-        events->u.u.type = type;
-        events->u.keyButtonPointer.time = ms;
-        events->u.keyButtonPointer.rootX = x;
-        events->u.keyButtonPointer.rootY = y;
-
-        if (type == ButtonPress || type == ButtonRelease) {
-            /* We hijack SetPointerMapping to work on all core-sending
-             * devices, so we use the device-specific map here instead of
-             * the core one. */
-            events->u.u.detail = pDev->button->map[buttons];
-        }
-        else {
-            events->u.u.detail = 0;
-        }
-
-        if (inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr !=
-            pDev)
-            inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
-    }
-
-    return num_events;
-}
diff --git a/dix/getevents.c b/dix/getevents.c
new file mode 100644
index 0000000..4f96080
--- /dev/null
+++ b/dix/getevents.c
@@ -0,0 +1,530 @@
+/*
+ * Copyright © 2006 Nokia Corporation
+ * 
+ * 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 this copyright notice and this permission notice appear in
+ * supporting electronic documentation.
+ *
+ * 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 HOLDERS OR AUTHORS 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.
+ *
+ * Author: Daniel Stone <daniel at fooishbar.org>
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include <X11/keysym.h>
+#include "misc.h"
+#include "resource.h"
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include <X11/Xproto.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "cursorstr.h"
+
+#include "dixstruct.h"
+#include "globals.h"
+
+#include "mipointer.h"
+
+#ifdef XKB
+#include <X11/extensions/XKBproto.h>
+#include <X11/extensions/XKBsrv.h>
+extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
+extern Bool XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies);
+#endif
+
+#ifdef XACE
+#include "xace.h"
+#endif
+
+#include <X11/extensions/XIproto.h>
+#include "exglobals.h"
+#include "exevents.h"
+#include "exglobals.h"
+#include "extnsionst.h"
+
+/* Maximum number of valuators, divided by six, rounded up. */
+#define MAX_VALUATOR_EVENTS 6
+
+/**
+ * Returns the maximum number of events GetKeyboardEvents,
+ * GetKeyboardValuatorEvents, and GetPointerEvents will ever return.
+ *
+ * Should be used in DIX as:
+ * xEvent *events = xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+ */
+_X_EXPORT int
+GetMaximumEventsNum() {
+    /* Two base events -- core and device, plus valuator events.  Multiply
+     * by two if we're doing key repeats. */
+    int ret = 2 + MAX_VALUATOR_EVENTS;
+
+#ifdef XKB
+    if (noXkbExtension)
+#endif
+        ret *= 2;
+
+    return ret;
+}
+
+/**
+ * Convenience wrapper around GetKeyboardValuatorEvents, that takes no
+ * valuators.
+ */
+_X_EXPORT int
+GetKeyboardEvents(xEvent *events, DeviceIntPtr pDev, int type, int key_code) {
+    return GetKeyboardValuatorEvents(events, pDev, type, key_code, 0, 0, NULL);
+}
+
+/**
+ * Returns a set of keyboard events for KeyPress/KeyRelease, optionally
+ * also with valuator events.  Handles Xi and XKB.
+ *
+ * events is not NULL-terminated; the return value is the number of events.
+ * The DDX is responsible for allocating the event structure in the first
+ * place via GetMaximumEventsNum(), and for freeing it.
+ *
+ * If pDev is set to send core events, then the keymap on the core
+ * keyboard will be pivoted to that of the new keyboard and the appropriate
+ * MapNotify events (both core and XKB) will be sent.
+ *
+ * Note that this function recurses!  If called for non-XKB, a repeating
+ * key press will trigger a matching KeyRelease, as well as the
+ * KeyPresses.
+ */
+_X_EXPORT int
+GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
+                          int key_code, int first_valuator,
+                          int num_valuators, int *valuators) {
+    int numEvents = 0, ms = 0, i = 0;
+    int final_valuator = first_valuator + num_valuators;
+    KeySym sym = pDev->key->curKeySyms.map[key_code *
+                                           pDev->key->curKeySyms.mapWidth];
+    deviceKeyButtonPointer *kbp = NULL;
+    deviceValuator *xv = NULL;
+    KeyClassPtr ckeyc;
+
+    if (!events)
+        return 0;
+    
+    if (type != KeyPress && type != KeyRelease)
+        return 0;
+
+    if (!pDev->key || !pDev->focus || !pDev->kbdfeed ||
+        (pDev->coreEvents && !inputInfo.keyboard->key))
+        return 0;
+
+    if (pDev->coreEvents)
+        numEvents = 2;
+    else
+        numEvents = 1;
+
+    if (num_valuators) {
+        if ((num_valuators / 6) + 1 > MAX_VALUATOR_EVENTS)
+            num_valuators = MAX_VALUATOR_EVENTS;
+        numEvents += (num_valuators / 6) + 1;
+    }
+
+#ifdef XKB
+    if (noXkbExtension)
+#endif
+    {
+        switch (sym) {
+            case XK_Num_Lock:
+            case XK_Caps_Lock:
+            case XK_Scroll_Lock:
+            case XK_Shift_Lock:
+                if (type == KeyRelease)
+                    return 0;
+                else if (type == KeyPress &&
+                         (pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
+                        type = KeyRelease;
+        }
+    }
+
+    /* Handle core repeating, via press/release/press/release.
+     * FIXME: In theory, if you're repeating with two keyboards,
+     *        you could get unbalanced events here. */
+    if (type == KeyPress &&
+        (((pDev->key->down[key_code >> 3] & (key_code & 7))) & 1)) {
+        if (!pDev->kbdfeed->ctrl.autoRepeat ||
+            pDev->key->modifierMap[key_code] ||
+            !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
+                & (1 << (key_code & 7))))
+            return 0;
+
+#ifdef XKB
+        if (noXkbExtension)
+#endif
+        {
+            numEvents += GetKeyboardValuatorEvents(events, pDev,
+                                                   KeyRelease, key_code,
+                                                   first_valuator, num_valuators,
+                                                   valuators);
+            events += numEvents;
+        }
+    }
+    
+
+    ms = GetTimeInMillis();
+
+    kbp = (deviceKeyButtonPointer *) events;
+    kbp->time = ms;
+    kbp->deviceid = pDev->id;
+    if (type == KeyPress)
+        kbp->type = DeviceKeyPress;
+    else if (type == KeyRelease)
+        kbp->type = DeviceKeyRelease;
+
+    if (num_valuators) {
+        kbp->deviceid |= MORE_EVENTS;
+        for (i = first_valuator; i < final_valuator; i += 6) {
+            xv = (deviceValuator *) ++events;
+            xv->type = DeviceValuator;
+            xv->first_valuator = i;
+            xv->num_valuators = num_valuators;
+            xv->deviceid = kbp->deviceid;
+            switch (num_valuators - first_valuator) {
+            case 6:
+                xv->valuator5 = valuators[i+5];
+            case 5:
+                xv->valuator4 = valuators[i+4];
+            case 4:
+                xv->valuator3 = valuators[i+3];
+            case 3:
+                xv->valuator2 = valuators[i+2];
+            case 2:
+                xv->valuator1 = valuators[i+1];
+            case 1:
+                xv->valuator0 = valuators[i];
+            }
+        }
+    }
+
+    if (pDev->coreEvents) {
+        events++;
+        events->u.keyButtonPointer.time = ms;
+        events->u.u.type = type;
+        events->u.u.detail = key_code;
+
+        if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr !=
+            pDev) {
+            ckeyc = inputInfo.keyboard->key;
+            memcpy(ckeyc->modifierMap, pDev->key->modifierMap, MAP_LENGTH);
+            if (ckeyc->modifierKeyMap)
+                xfree(ckeyc->modifierKeyMap);
+            ckeyc->modifierKeyMap = xalloc(8 * pDev->key->maxKeysPerModifier);
+            memcpy(ckeyc->modifierKeyMap, pDev->key->modifierKeyMap,
+                    (8 * pDev->key->maxKeysPerModifier));
+            ckeyc->maxKeysPerModifier = pDev->key->maxKeysPerModifier;
+            ckeyc->curKeySyms.minKeyCode = pDev->key->curKeySyms.minKeyCode;
+            ckeyc->curKeySyms.maxKeyCode = pDev->key->curKeySyms.maxKeyCode;
+            SetKeySymsMap(&ckeyc->curKeySyms, &pDev->key->curKeySyms);
+#ifdef XKB
+            if (!noXkbExtension && pDev->key->xkbInfo &&
+                pDev->key->xkbInfo->desc) {
+                if (!XkbCopyKeymap(pDev->key->xkbInfo->desc,
+                                   ckeyc->xkbInfo->desc, True))
+                    FatalError("Couldn't pivot keymap from device to core!\n");
+            }
+#endif
+            SendMappingNotify(MappingKeyboard, ckeyc->curKeySyms.minKeyCode,
+                              (ckeyc->curKeySyms.maxKeyCode -
+                               ckeyc->curKeySyms.minKeyCode),
+                              serverClient);
+            inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
+        }
+    }
+
+    return numEvents;
+}
+
+/* Originally a part of xf86PostMotionEvent. */
+static void
+acceleratePointer(DeviceIntPtr pDev, int first_valuator, int num_valuators,
+                  int *valuators)
+{
+    float mult = 0.0;
+    int dx = 0, dy = 0;
+    int *px = NULL, *py = NULL;
+
+    if (!num_valuators || !valuators)
+        return;
+
+    if (first_valuator == 0) {
+        dx = valuators[0];
+        px = &valuators[0];
+    }
+    if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
+        dy = valuators[1 - first_valuator];
+        py = &valuators[1 - first_valuator];
+    }
+
+    if (!dx && !dy)
+        return;
+
+    /*
+     * Accelerate
+     */
+    if (pDev->ptrfeed && pDev->ptrfeed->ctrl.num) {
+        /* modeled from xf86Events.c */
+        if (pDev->ptrfeed->ctrl.threshold) {
+            if ((abs(dx) + abs(dy)) >= pDev->ptrfeed->ctrl.threshold) {
+                pDev->valuator->dxremaind = ((float)dx *
+                                             (float)(pDev->ptrfeed->ctrl.num)) /
+                                             (float)(pDev->ptrfeed->ctrl.den) +
+                                            pDev->valuator->dxremaind;
+                if (px) {
+                    *px = (int)pDev->valuator->dxremaind;
+                    pDev->valuator->dxremaind = pDev->valuator->dxremaind -
+                                                (float)(*px);
+                }
+
+                pDev->valuator->dyremaind = ((float)dy *
+                                             (float)(pDev->ptrfeed->ctrl.num)) /
+                                             (float)(pDev->ptrfeed->ctrl.den) +
+                                            pDev->valuator->dyremaind;
+                if (py) {
+                    *py = (int)pDev->valuator->dyremaind;
+                    pDev->valuator->dyremaind = pDev->valuator->dyremaind -
+                                                (float)(*py);
+                }
+            }
+        }
+        else {
+            mult = pow((float)(dx * dx + dy * dy),
+                       ((float)(pDev->ptrfeed->ctrl.num) /
+                        (float)(pDev->ptrfeed->ctrl.den) - 1.0) /
+                       2.0) / 2.0;
+            if (dx) {
+                pDev->valuator->dxremaind = mult * (float)dx +
+                                            pDev->valuator->dxremaind;
+                *px = (int)pDev->valuator->dxremaind;
+                pDev->valuator->dxremaind = pDev->valuator->dxremaind -
+                                            (float)(*px);
+            }
+            if (dy) {
+                pDev->valuator->dyremaind = mult * (float)dy +
+                                            pDev->valuator->dyremaind;
+                *py = (int)pDev->valuator->dyremaind;
+                pDev->valuator->dyremaind = pDev->valuator->dyremaind -
+                                            (float)(*py);
+            }
+        }
+    }
+}
+
+/**
+ * Generate a series of xEvents (returned in xE) representing pointer
+ * motion, or button presses.  Xi and XKB-aware.
+ *
+ * events is not NULL-terminated; the return value is the number of events.
+ * The DDX is responsible for allocating the event structure in the first
+ * place via GetMaximumEventsNum(), and for freeing it.
+ */
+_X_EXPORT int
+GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
+                 int flags, int first_valuator, int num_valuators,
+                 int *valuators) {
+    int num_events = 0, ms = 0, final_valuator = 0, i = 0;
+    deviceKeyButtonPointer *kbp = NULL;
+    deviceValuator *xv = NULL;
+    AxisInfoPtr axes = NULL;
+    Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
+    DeviceIntPtr cp = inputInfo.pointer;
+    int x = 0, y = 0;
+
+    if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
+        return 0;
+
+    if (!pDev->button || (pDev->coreEvents && (!cp->button || !cp->valuator)))
+        return 0;
+
+    /* You fail. */
+    if (first_valuator < 0)
+        return 0;
+
+    if (pDev->coreEvents)
+        num_events = 2;
+    else
+        num_events = 1;
+
+    /* Do we need to send a DeviceValuator event? */
+    if ((num_valuators + first_valuator) >= 2 && sendValuators) {
+        if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS)
+            num_valuators = MAX_VALUATOR_EVENTS;
+        num_events += (num_valuators / 6) + 1;
+    }
+    else if (type == MotionNotify && num_valuators <= 0) {
+        return 0;
+    }
+
+    final_valuator = num_valuators + first_valuator;
+
+    ms = GetTimeInMillis();
+
+    kbp = (deviceKeyButtonPointer *) events;
+    kbp->time = ms;
+    kbp->deviceid = pDev->id;
+
+    if (flags & POINTER_ABSOLUTE) {
+        if (num_valuators >= 1 && first_valuator == 0) {
+            x = valuators[0];
+        }
+        else {
+            if (pDev->coreEvents)
+                x = cp->valuator->lastx;
+            else
+                x = pDev->valuator->lastx;
+        }
+
+        if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
+            y = valuators[1 - first_valuator];
+        }
+        else {
+            if (pDev->coreEvents)
+                x = cp->valuator->lasty;
+            else
+                y = pDev->valuator->lasty;
+        }
+    }
+    else {
+        if (flags & POINTER_ACCELERATE)
+            acceleratePointer(pDev, first_valuator, num_valuators,
+                              valuators);
+
+        if (pDev->coreEvents) {
+            if (first_valuator == 0 && num_valuators >= 1)
+                x = cp->valuator->lastx + valuators[0];
+            else
+                x = cp->valuator->lastx;
+
+            if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
+                y = cp->valuator->lasty + valuators[1 - first_valuator];
+            else
+                y = cp->valuator->lasty;
+        }
+        else {
+            if (first_valuator == 0 && num_valuators >= 1)
+                x = pDev->valuator->lastx + valuators[0];
+            else
+                x = pDev->valuator->lastx;
+
+            if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
+                y = pDev->valuator->lasty + valuators[1 - first_valuator];
+            else
+                y = pDev->valuator->lasty;
+        }
+    }
+
+
+    axes = pDev->valuator->axes;
+    if (x < axes->min_value)
+        x = axes->min_value;
+    if (axes->max_value > 0 && x > axes->max_value)
+        x = axes->max_value;
+
+    axes++;
+    if (y < axes->min_value)
+        y = axes->min_value;
+    if (axes->max_value > 0 && y > axes->max_value)
+        y = axes->max_value;
+
+    /* This takes care of crossing screens for us, as well as clipping
+     * to the current screen.  Right now, we only have one history buffer,
+     * so we don't set this for both the device and core.*/
+    miPointerSetPosition(pDev, &x, &y, ms);
+
+    if (pDev->coreEvents) {
+        cp->valuator->lastx = x;
+        cp->valuator->lasty = y;
+    }
+    pDev->valuator->lastx = x;
+    pDev->valuator->lasty = y;
+
+    if (type == MotionNotify) {
+        kbp->type = DeviceMotionNotify;
+    }
+    else {
+        if (type == ButtonPress)
+            kbp->type = DeviceButtonPress;
+        else if (type == ButtonRelease)
+            kbp->type = DeviceButtonRelease;
+        kbp->detail = pDev->button->map[buttons];
+    }
+
+    kbp->root_x = x;
+    kbp->root_y = y;
+
+    if (final_valuator > 2 && sendValuators) {
+        kbp->deviceid |= MORE_EVENTS;
+        for (i = first_valuator; i < final_valuator; i += 6) {
+            xv = (deviceValuator *) ++events;
+            xv->type = DeviceValuator;
+            xv->first_valuator = i;
+            xv->num_valuators = num_valuators;
+            xv->deviceid = kbp->deviceid;
+            switch (final_valuator - i) {
+            case 6:
+                xv->valuator5 = valuators[i+5];
+            case 5:
+                xv->valuator4 = valuators[i+4];
+            case 4:
+                xv->valuator3 = valuators[i+3];
+            case 3:
+                xv->valuator2 = valuators[i+2];
+            case 2:
+                /* x and y may have been accelerated. */
+                if (i == 0)
+                    xv->valuator1 = kbp->root_y;
+                else
+                    xv->valuator1 = valuators[i+1];
+            case 1:
+                /* x and y may have been accelerated. */
+                if (i == 0)
+                    xv->valuator0 = kbp->root_x;
+                else
+                    xv->valuator0 = valuators[i];
+            }
+        }
+    }
+
+    if (pDev->coreEvents) {
+        events++;
+        events->u.u.type = type;
+        events->u.keyButtonPointer.time = ms;
+        events->u.keyButtonPointer.rootX = x;
+        events->u.keyButtonPointer.rootY = y;
+
+        if (type == ButtonPress || type == ButtonRelease) {
+            /* We hijack SetPointerMapping to work on all core-sending
+             * devices, so we use the device-specific map here instead of
+             * the core one. */
+            events->u.u.detail = pDev->button->map[buttons];
+        }
+        else {
+            events->u.u.detail = 0;
+        }
+
+        if (inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr !=
+            pDev)
+            inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
+    }
+
+    return num_events;
+}
diff-tree 6afc7c284690b1e2bb7544b5bc4f31a3f6a05519 (from 93302452e737bd91a893eb495592538d40d921e5)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Oct 14 15:54:35 2006 +0300

    dix/devices: remove XACE merge debris

diff --git a/dix/devices.c b/dix/devices.c
index 09e36c7..bf8c58a 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1438,12 +1438,6 @@ DoChangeKeyboardControl (ClientPtr clien
     BITS32 index2;
     int mask = vmask, i;
 
-    REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
-    vmask = stuff->mask;
-    if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask))
-	return BadLength;
-
-    vlist = (XID *)&stuff[1];		/* first word of values */
     ctrl = keybd->kbdfeed->ctrl;
     while (vmask) {
 	index2 = (BITS32) lowbit (vmask);
diff-tree 93302452e737bd91a893eb495592538d40d921e5 (from 335b503c5e7041bb0c44611e496d1c46f554e630)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Oct 14 15:54:12 2006 +0300

    XkbCopyKeymap: add geometry support
    Add a first cut at geometry support, which seems to generally work.

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 86983c8..9a3be31 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -964,13 +964,22 @@ XkbConvertCase(register KeySym sym, KeyS
  * Returns TRUE on success, or FALSE on failure.  If this function fails,
  * dst may be in an inconsistent state: all its pointers are guaranteed
  * to remain valid, but part of the map may be from src and part from dst.
+ *
+ * FIXME: This function wants to be broken up into multiple functions.
  */
 Bool
 XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
 {
-    int i = 0, j = 0;
+    int i = 0, j = 0, k = 0;
     void *tmp = NULL;
+    XkbColorPtr scolor = NULL, dcolor = NULL;
+    XkbDoodadPtr sdoodad = NULL, ddoodad = NULL;
     XkbKeyTypePtr stype = NULL, dtype = NULL;
+    XkbOutlinePtr soutline = NULL, doutline = NULL;
+    XkbPropertyPtr sprop = NULL, dprop = NULL;
+    XkbRowPtr srow = NULL, drow = NULL;
+    XkbSectionPtr ssection = NULL, dsection = NULL;
+    XkbShapePtr sshape = NULL, dshape = NULL;
     DeviceIntPtr pDev = NULL, tmpDev = NULL;
     xkbMapNotify mn;
     xkbNewKeyboardNotify nkn;
@@ -1456,19 +1465,491 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
     }
 
     /* geometry */
-    /* not implemented yet because oh god the pain. */
-#if 0
     if (src->geom) {
         /* properties */
+        if (src->geom->num_properties) {
+            if (src->geom->num_properties != dst->geom->sz_properties) {
+                if (src->geom->num_properties < dst->geom->sz_properties) {
+                    for (i = src->geom->num_properties,
+                          dprop = dst->geom->properties +
+                                  src->geom->num_properties;
+                         i < dst->geom->num_properties;
+                         i++, dprop++) {
+                        xfree(dprop->name);
+                        xfree(dprop->value);
+                    }
+                }
+
+                if (dst->geom->sz_properties)
+                    tmp = xrealloc(dst->geom->properties,
+                                   src->geom->num_properties *
+                                    sizeof(XkbPropertyRec));
+                else
+                    tmp = xalloc(src->geom->num_properties *
+                                  sizeof(XkbPropertyRec));
+                if (!tmp)
+                    return FALSE;
+                dst->geom->properties = tmp;
+            }
+
+            dst->geom->sz_properties = src->geom->num_properties;
+
+            if (dst->geom->sz_properties > dst->geom->num_properties) {
+                bzero(dst->geom->properties + dst->geom->num_properties,
+                      (dst->geom->sz_properties - dst->geom->num_properties) *
+                      sizeof(XkbPropertyRec));
+            }
+
+            for (i = 0,
+                  sprop = src->geom->properties,
+                  dprop = dst->geom->properties;
+                 i < src->geom->num_properties;
+                 i++, sprop++, dprop++) {
+                if (i < dst->geom->num_properties) {
+                    if (strlen(sprop->name) != strlen(dprop->name)) {
+                        tmp = xrealloc(dprop->name, strlen(sprop->name) + 1);
+                        if (!tmp)
+                            return FALSE;
+                        dprop->name = tmp;
+                    }
+                    if (strlen(sprop->value) != strlen(dprop->value)) {
+                        tmp = xrealloc(dprop->value, strlen(sprop->value) + 1);
+                        if (!tmp)
+                            return FALSE;
+                        dprop->value = tmp;
+                    }
+                    strcpy(dprop->name, sprop->name);
+                    strcpy(dprop->value, sprop->value);
+                }
+                else {
+                    dprop->name = xstrdup(sprop->name);
+                    dprop->value = xstrdup(sprop->value);
+                }
+            }
+
+            dst->geom->num_properties = dst->geom->sz_properties;
+        }
+        else {
+            if (dst->geom->sz_properties) {
+                for (i = 0, dprop = dst->geom->properties;
+                     i < dst->geom->num_properties;
+                     i++, dprop++) {
+                    xfree(dprop->name);
+                    xfree(dprop->value);
+                }
+                xfree(dst->geom->properties);
+                dst->geom->properties = NULL;
+            }
+
+            dst->geom->num_properties = 0;
+            dst->geom->sz_properties = 0;
+        }
+
         /* colors */
+        if (src->geom->num_colors) {
+            if (src->geom->num_colors != dst->geom->sz_colors) {
+                if (src->geom->num_colors < dst->geom->sz_colors) {
+                    for (i = src->geom->num_colors,
+                          dcolor = dst->geom->colors +
+                                   src->geom->num_colors;
+                         i < dst->geom->num_colors;
+                         i++, dcolor++) {
+                        xfree(dcolor->spec);
+                    }
+                }
+
+                if (dst->geom->sz_colors)
+                    tmp = xrealloc(dst->geom->colors,
+                                   src->geom->num_colors *
+                                    sizeof(XkbColorRec));
+                else
+                    tmp = xalloc(src->geom->num_colors *
+                                  sizeof(XkbColorRec));
+                if (!tmp)
+                    return FALSE;
+                dst->geom->colors = tmp;
+            }
+
+            dst->geom->sz_colors = src->geom->num_colors;
+
+            if (dst->geom->sz_colors > dst->geom->num_colors) {
+                bzero(dst->geom->colors + dst->geom->num_colors,
+                      (dst->geom->sz_colors - dst->geom->num_colors) *
+                      sizeof(XkbColorRec));
+            }
+
+            for (i = 0,
+                  scolor = src->geom->colors,
+                  dcolor = dst->geom->colors;
+                 i < src->geom->num_colors;
+                 i++, scolor++, dcolor++) {
+                if (i < dst->geom->num_colors) {
+                    if (strlen(scolor->spec) != strlen(dcolor->spec)) {
+                        tmp = xrealloc(dcolor->spec, strlen(scolor->spec) + 1);
+                        if (!tmp)
+                            return FALSE;
+                        dcolor->spec = tmp;
+                    }
+                    strcpy(dcolor->spec, scolor->spec);
+                }
+                else {
+                    dcolor->spec = xstrdup(scolor->spec);
+                }
+            }
+
+            dst->geom->num_colors = dst->geom->sz_colors;
+        }
+        else {
+            if (dst->geom->sz_colors) {
+                for (i = 0, dcolor = dst->geom->colors;
+                     i < dst->geom->num_colors;
+                     i++, dcolor++) {
+                    xfree(dcolor->spec);
+                }
+                xfree(dst->geom->colors);
+                dst->geom->colors = NULL;
+            }
+
+            dst->geom->num_colors = 0;
+            dst->geom->sz_colors = 0;
+        }
+
         /* shapes */
+        /* shapes break down into outlines, which break down into points. */
+        if (dst->geom->num_shapes) {
+            for (i = 0, dshape = dst->geom->shapes;
+                 i < dst->geom->num_shapes;
+                 i++, dshape++) {
+                for (j = 0, doutline = dshape->outlines;
+                     j < dshape->num_outlines;
+                     j++, doutline++) {
+                    if (doutline->sz_points)
+                        xfree(doutline->points);
+                }
+
+                if (dshape->sz_outlines) {
+                    xfree(dshape->outlines);
+                    dshape->outlines = NULL;
+                }
+
+                dshape->num_outlines = 0;
+                dshape->sz_outlines = 0;
+            }
+        }
+
+        if (src->geom->num_shapes) {
+            tmp = xcalloc(src->geom->num_shapes, sizeof(XkbShapeRec));
+            if (!tmp)
+                return FALSE;
+            dst->geom->shapes = tmp;
+
+            for (i = 0, sshape = src->geom->shapes, dshape = dst->geom->shapes;
+                 i < src->geom->num_shapes;
+                 i++) {
+                if (sshape->num_outlines) {
+                    tmp = xcalloc(sshape->num_outlines, sizeof(XkbOutlineRec));
+                    if (!tmp)
+                        return FALSE;
+                    dshape->outlines = tmp;
+                    
+                    for (j = 0,
+                          soutline = sshape->outlines,
+                          doutline = dshape->outlines;
+                         j < sshape->num_outlines;
+                         j++) {
+                        if (soutline->num_points) {
+                            tmp = xalloc(soutline->num_points *
+                                          sizeof(XkbPointRec));
+                            if (!tmp)
+                                return FALSE;
+                            doutline->points = tmp;
+
+                            memcpy(doutline->points, soutline->points,
+                                   soutline->num_points * sizeof(XkbPointRec));
+                        }
+
+                        doutline->num_points = soutline->num_points;
+                        doutline->sz_points = soutline->sz_points;
+                    }
+                }
+
+                dshape->num_outlines = sshape->num_outlines;
+                dshape->sz_outlines = sshape->num_outlines;
+            }
+
+            dst->geom->num_shapes = src->geom->num_shapes;
+            dst->geom->sz_shapes = src->geom->num_shapes;
+        }
+        else {
+            if (dst->geom->sz_shapes) {
+                xfree(dst->geom->shapes);
+                dst->geom->shapes = NULL;
+            }
+            
+            dst->geom->num_shapes = 0;
+            dst->geom->sz_shapes = 0;
+        }
+
         /* sections */
+        /* sections break down into doodads, and also into rows, which break
+         * down into keys. */
+        if (dst->geom->num_sections) {
+            for (i = 0, dsection = dst->geom->sections;
+                 i < dst->geom->num_sections;
+                 i++, dsection++) {
+                for (j = 0, drow = dsection->rows;
+                     j < dsection->num_rows;
+                     j++, drow++) {
+                    if (drow->num_keys)
+                        xfree(drow->keys);
+                }
+
+                if (dsection->num_rows)
+                    xfree(dsection->rows);
+
+                /* cut and waste from geom/doodad below. */
+                for (j = 0, ddoodad = dsection->doodads;
+                     j < dsection->num_doodads;
+                     j++, ddoodad++) {
+                    if (ddoodad->any.type == XkbTextDoodad) {
+                        if (ddoodad->text.text) {
+                            xfree(ddoodad->text.text);
+                            ddoodad->text.text = NULL;
+                        }
+                        if (ddoodad->text.font) {
+                            xfree(ddoodad->text.font);
+                            ddoodad->text.font = NULL;
+                        }
+                     }
+                     else if (ddoodad->any.type == XkbLogoDoodad) {
+                        if (ddoodad->logo.logo_name) {
+                            xfree(ddoodad->logo.logo_name);
+                            ddoodad->logo.logo_name = NULL;
+                        }
+                    }
+                }
+
+                if (dsection->num_doodads)
+                    xfree(dsection->doodads);
+            }
+
+            dst->geom->num_sections = 0;
+        }
+
+        if (src->geom->num_sections) {
+            if (dst->geom->sz_sections)
+                tmp = xrealloc(dst->geom->sections,
+                               src->geom->num_sections *
+                                sizeof(XkbSectionRec));
+            else
+                tmp = xalloc(src->geom->num_sections * sizeof(XkbSectionRec));
+            if (!tmp)
+                return FALSE;
+            dst->geom->sections = tmp;
+
+            for (i = 0,
+                  ssection = src->geom->sections,
+                  dsection = dst->geom->sections;
+                 i < src->geom->num_sections;
+                 i++, ssection++, dsection++) {
+                if (ssection->num_rows) {
+                    tmp = xcalloc(ssection->num_rows, sizeof(XkbRowRec));
+                    if (!tmp)
+                        return FALSE;
+                    dsection->rows = tmp;
+                }
+                for (j = 0, srow = ssection->rows, drow = dsection->rows;
+                     j < ssection->num_rows;
+                     j++, srow++, drow++) {
+                    if (srow->num_keys) {
+                        tmp = xalloc(srow->num_keys * sizeof(XkbKeyRec));
+                        if (!tmp)
+                            return FALSE;
+                        drow->keys = tmp;
+                        memcpy(drow->keys, srow->keys,
+                               srow->num_keys * sizeof(XkbKeyRec));
+                    }
+                    drow->num_keys = srow->num_keys;
+                    drow->sz_keys = srow->num_keys;
+                }
+
+                if (ssection->num_doodads) {
+                    tmp = xcalloc(ssection->num_doodads, sizeof(XkbDoodadRec));
+                    if (!tmp)
+                        return FALSE;
+                    dsection->doodads = tmp;
+                }
+                for (k = 0,
+                      sdoodad = ssection->doodads,
+                      ddoodad = dsection->doodads;
+                     k < ssection->num_doodads;
+                     k++, sdoodad++, ddoodad++) {
+                    if (sdoodad->any.type == XkbTextDoodad) {
+                        if (sdoodad->text.text)
+                            ddoodad->text.text =
+                             xstrdup(sdoodad->text.text);
+                        if (sdoodad->text.font)
+                            ddoodad->text.font =
+                             xstrdup(sdoodad->text.font);
+                    }
+                    else if (sdoodad->any.type == XkbLogoDoodad) {
+                        if (sdoodad->logo.logo_name)
+                            ddoodad->logo.logo_name =
+                             xstrdup(sdoodad->logo.logo_name);
+                    }
+                    ddoodad->any.type = sdoodad->any.type;
+                }
+                dsection->num_doodads = ssection->num_doodads;
+                dsection->sz_doodads = ssection->num_doodads;
+            }
+        }
+        else {
+            if (dst->geom->sz_sections) {
+                xfree(dst->geom->sections);
+                dst->geom->sections = NULL;
+            }
+
+            dst->geom->num_sections = 0;
+            dst->geom->sz_sections = 0;
+        }
+
         /* doodads */
+        if (dst->geom->num_doodads) {
+            for (i = src->geom->num_doodads,
+                  ddoodad = dst->geom->doodads +
+                             src->geom->num_doodads;
+                 i < dst->geom->num_doodads;
+                 i++, ddoodad++) {
+                 if (ddoodad->any.type == XkbTextDoodad) {
+                    if (ddoodad->text.text) {
+                        xfree(ddoodad->text.text);
+                        ddoodad->text.text = NULL;
+                    }
+                    if (ddoodad->text.font) {
+                        xfree(ddoodad->text.font);
+                        ddoodad->text.font = NULL;
+                    }
+                 }
+                 else if (ddoodad->any.type == XkbLogoDoodad) {
+                    if (ddoodad->logo.logo_name) {
+                        xfree(ddoodad->logo.logo_name);
+                        ddoodad->logo.logo_name = NULL;
+                    }
+                }
+            }
+        }
+
+        if (src->geom->num_doodads) {
+            if (dst->geom->sz_doodads)
+                tmp = xrealloc(dst->geom->doodads,
+                               src->geom->num_doodads *
+                                sizeof(XkbDoodadRec));
+            else
+                tmp = xalloc(src->geom->num_doodads *
+                              sizeof(XkbDoodadRec));
+            if (!tmp)
+                return FALSE;
+            bzero(tmp, src->geom->num_doodads * sizeof(XkbDoodadRec));
+            dst->geom->doodads = tmp;
+
+            dst->geom->sz_doodads = src->geom->num_doodads;
+
+            for (i = 0,
+                  sdoodad = src->geom->doodads,
+                  ddoodad = dst->geom->doodads;
+                 i < src->geom->num_doodads;
+                 i++, sdoodad++, ddoodad++) {
+                ddoodad->any.type = sdoodad->any.type;
+                if (sdoodad->any.type == XkbTextDoodad) {
+                    if (sdoodad->text.text)
+                        ddoodad->text.text = xstrdup(sdoodad->text.text);
+                    if (sdoodad->text.font)
+                        ddoodad->text.font = xstrdup(sdoodad->text.font);
+                }
+                else if (sdoodad->any.type == XkbLogoDoodad) {
+                    if (sdoodad->logo.logo_name)
+                        ddoodad->logo.logo_name =
+                          xstrdup(sdoodad->logo.logo_name);
+                }
+            }
+
+            dst->geom->num_doodads = dst->geom->sz_doodads;
+        }
+        else {
+            if (dst->geom->sz_doodads) {
+                xfree(dst->geom->doodads);
+                dst->geom->doodads = NULL;
+            }
+
+            dst->geom->num_doodads = 0;
+            dst->geom->sz_doodads = 0;
+        }
+
         /* key aliases */
-        /* font?!? */
+        if (src->geom->num_key_aliases) {
+            if (src->geom->num_key_aliases != dst->geom->sz_key_aliases) {
+                if (dst->geom->sz_key_aliases)
+                    tmp = xrealloc(dst->geom->key_aliases,
+                                   src->geom->num_key_aliases *
+                                    2 * XkbKeyNameLength);
+                else
+                    tmp = xalloc(src->geom->num_key_aliases *
+                                  2 * XkbKeyNameLength);
+                if (!tmp)
+                    return FALSE;
+                dst->geom->key_aliases = tmp;
+
+                dst->geom->sz_key_aliases = src->geom->num_key_aliases;
+            }
+
+            memcpy(dst->geom->key_aliases, src->geom->key_aliases,
+                   src->geom->num_key_aliases * 2 * XkbKeyNameLength);
+
+            dst->geom->num_key_aliases = dst->geom->sz_key_aliases;
+        }
+        else {
+            if (dst->geom->sz_key_aliases) {
+                xfree(dst->geom->key_aliases);
+                dst->geom->key_aliases = NULL;
+            }
+            dst->geom->num_key_aliases = 0;
+            dst->geom->sz_key_aliases = 0;
+        }
+        
+        /* font */
+        if (src->geom->label_font) {
+            if (strlen(src->geom->label_font) !=
+                strlen(dst->geom->label_font)) {
+                if (dst->geom->label_font)
+                    tmp = xrealloc(dst->geom->label_font,
+                                   strlen(src->geom->label_font));
+                else
+                    tmp = xalloc(strlen(src->geom->label_font));
+                if (!tmp)
+                    return FALSE;
+                dst->geom->label_font = tmp;
+            }
+
+            strcpy(dst->geom->label_font, src->geom->label_font);
+            i = XkbGeomColorIndex(src->geom, src->geom->label_color);
+            dst->geom->label_color = &(src->geom->colors[i]);
+            i = XkbGeomColorIndex(src->geom, src->geom->base_color);
+            dst->geom->base_color = &(src->geom->colors[i]);
+        }
+        else {
+            if (dst->geom->label_font) {
+                xfree(dst->geom->label_font);
+                dst->geom->label_font = NULL;
+            }
+            dst->geom->label_color = NULL;
+            dst->geom->base_color = NULL;
+        }
+
+        dst->geom->name = src->geom->name;
+        dst->geom->width_mm = src->geom->width_mm;
+        dst->geom->height_mm = src->geom->height_mm;
     }
     else
-#endif
     {
         if (dst->geom) {
             /* I LOVE THE DIFFERENT CALL SIGNATURE.  REALLY, I DO. */
diff-tree 335b503c5e7041bb0c44611e496d1c46f554e630 (from parents)
Merge: bd3d93be82d91e4cf35ae317dfd658d1706257ea cf948b7b04dfeb61a294889027b9a54f6b9b478e
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 13 18:10:45 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff --cc configure.ac
index e1342f1,7222106..7992d77
@@@ -417,9 -411,11 +417,11 @@@
  AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]), [GLX_USE_TLS=$enableval], [GLX_USE_TLS=no])
  AC_ARG_ENABLE(dri,            AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
  AC_ARG_ENABLE(xinerama,	      AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
 -AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: enabled)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=yes])
 -AC_ARG_ENABLE(xf86misc,       AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: enabled)]), [XF86MISC=$enableval], [XF86MISC=yes])
 +AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
 +AC_ARG_ENABLE(xf86misc,       AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: auto)]), [XF86MISC=$enableval], [XF86MISC=auto])
- AC_ARG_ENABLE(xcsecurity,     AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: enabled)]), [XCSECURITY=$enableval], [XCSECURITY=yes])
+ AC_ARG_ENABLE(xace,     AS_HELP_STRING([--disable-xace], [Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes])
+ AC_ARG_ENABLE(xcsecurity,     AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: enabled)]), [XCSECURITY=$enableval], [XCSECURITY=$XACE])
+ AC_ARG_ENABLE(appgroup,       AS_HELP_STRING([--disable-appgroup], [Build XC-APPGROUP extension (default: enabled)]), [APPGROUP=$enableval], [APPGROUP=$XCSECURITY])
  AC_ARG_ENABLE(xcalibrate,     AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no])
  AC_ARG_ENABLE(tslib,          AS_HELP_STRING([--enable-tslib], [Build kdrive tslib touchscreen support (default: disabled)]), [TSLIB=$enableval], [TSLIB=no])
  AC_ARG_ENABLE(xevie,          AS_HELP_STRING([--disable-xevie], [Build XEvIE extension (default: enabled)]), [XEVIE=$enableval], [XEVIE=yes])
diff --cc dix/devices.c
index 2149769,6075102..09e36c7
@@@ -1115,75 -909,6 +1115,78 @@@
      return TRUE;
  }
  
 +static int
 +DoSetModifierMapping(ClientPtr client, KeyCode *inputMap,
 +                     int numKeyPerModifier)
 +{
 +    DeviceIntPtr pDev = NULL;
 +    int i = 0, inputMapLen = numKeyPerModifier * 8;
 +
 +    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
 +        if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
 +            for (i = 0; i < inputMapLen; i++) {
 +                /* Check that all the new modifiers fall within the advertised
 +                 * keycode range, and are okay with the DDX. */
 +                if (inputMap[i] && ((inputMap[i] < pDev->key->curKeySyms.minKeyCode ||
 +                                    inputMap[i] > pDev->key->curKeySyms.maxKeyCode) ||
 +                                    !LegalModifier(inputMap[i], pDev))) {
 +                    client->errorValue = inputMap[i];
 +                    return BadValue;
 +                }
 +            }
- #ifdef XCSECURITY
-             if (!SecurityCheckDeviceAccess(client, pDev, TRUE))
++
++#ifdef XACE
++            if (!XaceHook(XACE_DEVICE_ACCESS, client, pDev, TRUE))
 +                return BadAccess;
 +#endif 
++
 +            /* None of the modifiers (old or new) may be down while we change
 +             * the map. */
 +            if (!AllModifierKeysAreUp(pDev, pDev->key->modifierKeyMap,
 +                                      pDev->key->maxKeysPerModifier,
 +                                      inputMap, numKeyPerModifier) ||
 +                !AllModifierKeysAreUp(pDev, inputMap, numKeyPerModifier,
 +                                      pDev->key->modifierKeyMap,
 +                                      pDev->key->maxKeysPerModifier)) {
 +                return MappingBusy;
 +            }
 +        }
 +    }
 +
 +    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
++
 +        if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
 +            bzero(pDev->key->modifierMap, MAP_LENGTH);
 +
 +            /* Annoyingly, we lack a modifierKeyMap size, so we have to just free
 +             * and re-alloc it every time. */
 +            if (pDev->key->modifierKeyMap)
 +                xfree(pDev->key->modifierKeyMap);
 +
 +            if (inputMapLen) {
 +                pDev->key->modifierKeyMap = (KeyCode *) xalloc(inputMapLen);
 +                if (!pDev->key->modifierKeyMap)
 +                    return BadAlloc;
 +
 +                memcpy(pDev->key->modifierKeyMap, inputMap, inputMapLen);
 +                pDev->key->maxKeysPerModifier = numKeyPerModifier;
 +
 +                for (i = 0; i < inputMapLen; i++) {
 +                    if (inputMap[i]) {
 +                        pDev->key->modifierMap[inputMap[i]] |=
 +                            (1 << (((unsigned int)i) / numKeyPerModifier));
 +                    }
 +                }
 +            }
 +            else {
 +                pDev->key->modifierKeyMap = NULL;
 +            }
 +        }
 +    }
 +
 +    return Success;
 +}
 +
  int 
  ProcSetModifierMapping(ClientPtr client)
  {
@@@ -1255,16 -1063,10 +1258,16 @@@
  	    client->errorValue = stuff->keySymsPerKeyCode;
  	    return BadValue;
      }
 +
- #ifdef XCSECURITY
+ #ifdef XACE
 -    if (!XaceHook(XACE_DEVICE_ACCESS, client, inputInfo.keyboard, TRUE))
 -	return BadAccess;
 +    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
 +        if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
-             if (!SecurityCheckDeviceAccess(client, pDev, TRUE))
++            if (!XaceHook(XACE_DEVICE_ACCESS, client, pDev, TRUE))
 +                return BadAccess;
 +        }
 +    }
  #endif 
 +
      keysyms.minKeyCode = stuff->firstKeyCode;
      keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1;
      keysyms.mapWidth = stuff->keySymsPerKeyCode;
@@@ -1432,14 -1200,28 +1435,20 @@@
 -    DeviceIntPtr keybd = inputInfo.keyboard;
 -    XID *vlist;
      int t;
      int led = DO_ALL;
      int key = DO_ALL;
 -    BITS32 vmask, index2;
 -    int mask, i;
 -    REQUEST(xChangeKeyboardControlReq);
 +    BITS32 index2;
 +    int mask = vmask, i;
  
+     REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
+     vmask = stuff->mask;
+     if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask))
+ 	return BadLength;
 -#ifdef XACE
 -    if (!XaceHook(XACE_DEVICE_ACCESS, client, keybd, TRUE))
 -	return BadAccess;
 -#endif 
++
+     vlist = (XID *)&stuff[1];		/* first word of values */
      ctrl = keybd->kbdfeed->ctrl;
 -    while (vmask)
 -    {
 +    while (vmask) {
  	index2 = (BITS32) lowbit (vmask);
  	vmask &= ~index2;
 -	switch (index2)
 -	{
 +	switch (index2) {
  	case KBKeyClickPercent: 
  	    t = (INT8)*vlist;
  	    vlist++;
@@@ -1593,45 -1383,6 +1602,45 @@@
  } 
  
  int
 +ProcChangeKeyboardControl (ClientPtr client)
 +{
 +    XID *vlist;
 +    BITS32 vmask;
 +    int ret = Success, error = Success;
 +    DeviceIntPtr pDev = NULL;
 +    REQUEST(xChangeKeyboardControlReq);
 +
 +    REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
 +
 +    vmask = stuff->mask;
 +    vlist = (XID *)&stuff[1];
 +
 +    if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask))
 +	return BadLength;
 +
- #ifdef XCSECURITY
++#ifdef XACE
 +    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
 +        if ((pDev->coreEvents || pDev == inputInfo.keyboard) &&
 +            pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
-             if (!SecurityCheckDeviceAccess(client, pDev, TRUE))
++            if (!XaceHook(XACE_DEVICE_ACCESS, client, pDev, TRUE))
 +                return BadAccess;
 +        }
 +    }
 +#endif 
 +
 +    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
 +        if ((pDev->coreEvents || pDev == inputInfo.keyboard) &&
 +            pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
 +            ret = DoChangeKeyboardControl(client, pDev, vlist, vmask);
 +            if (ret != Success)
 +                error = ret;
 +        }
 +    }
 +
 +    return error;
 +}
 +
 +int
  ProcGetKeyboardControl (ClientPtr client)
  {
      int i;
diff --cc dix/events.c
index 646a9ba,c57a30e..ebc43b0
@@@ -131,17 -130,13 +131,17 @@@
  #endif
  #include "globals.h"
  
 +#include "mipointer.h"
 +
  #ifdef XKB
 +#include <X11/extensions/XKBproto.h>
  #include <X11/extensions/XKBsrv.h>
  extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
 +extern Bool XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies);
  #endif
  
- #ifdef XCSECURITY
- #include "securitysrv.h"
+ #ifdef XACE
+ #include "xace.h"
  #endif
  
  #ifdef XEVIE
diff --cc hw/xfree86/common/xf86Cursor.c
index ee42b75,8bb12ae..20905b0
@@@ -223,10 -229,11 +224,11 @@@
    if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY)
      return FALSE;
  
 -  pCursorScreen = miPointerCurrentScreen();
 +  pCursorScreen = miPointerGetScreen(inputInfo.pointer);
    if (pScreen == pCursorScreen)
 -    miPointerPosition(&px, &py);
 +    miPointerGetPosition(inputInfo.pointer, &px, &py);
  
+   sigstate = xf86BlockSIGIO ();
    xf86EnterServerState(SETUP);
    Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0);
    xf86EnterServerState(OPERATING);
diff-tree bd3d93be82d91e4cf35ae317dfd658d1706257ea (from 33406da096b4ae21134484113b280e07d0c8f0d9)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 23:21:12 2006 +0300

    xkb: remove random broken vendor workarounds

diff --git a/xkb/ddxBeep.c b/xkb/ddxBeep.c
index ff9dd99..53f3a6f 100644
--- a/xkb/ddxBeep.c
+++ b/xkb/ddxBeep.c
@@ -39,12 +39,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/extensions/XKBsrv.h>
 #include <X11/extensions/XI.h>
 
-#if (defined(__osf__) && defined(__alpha))
-#include <sys/sysinfo.h>
-#include <alpha/hal_sysinfo.h>
-#include <alpha/prom.h>
-#endif
-
 /*#define FALLING_TONE	1*/
 /*#define RISING_TONE	1*/
 #define FALLING_TONE	10
@@ -116,32 +110,6 @@ _XkbDDXBeepInitAtoms(void)
     stickyLock=		MAKE_ATOM(STICKY_LOCK);
     stickyUnlock= 	MAKE_ATOM(STICKY_UNLOCK);
     bounceReject= 	MAKE_ATOM(BOUNCE_REJECT);
-#if (defined(__osf__) && defined(__alpha))
-    /* [[[ WDW - Some bells do not allow for pitch changes.
-     * Maybe this could become part of the keymap? ]]]
-     */
-    {
-	char keyboard[8];
-
-	/* Find the class of keyboard being used.
-	 */
-	keyboard[0] = '\0';
-	if (-1 == getsysinfo(GSI_KEYBOARD, 
-			     keyboard, sizeof(keyboard), 
-			     0, NULL))
-	    keyboard[0] = '\0';
-
-	if ((strcmp(keyboard,"LK201") == 0) ||
-	    (strcmp(keyboard,"LK401") == 0) ||
-	    (strcmp(keyboard,"LK421") == 0) ||
-	    (strcmp(keyboard,"LK443") == 0))
-	    doesPitch = 0;
-    }
-#else
-#if defined(sun)
-    doesPitch = 0;
-#endif
-#endif
     return;
 }
 
diff --git a/xkb/xkbAccessX.c b/xkb/xkbAccessX.c
index 7b57611..0ab3dad 100644
--- a/xkb/xkbAccessX.c
+++ b/xkb/xkbAccessX.c
@@ -361,10 +361,7 @@ XkbControlsPtr	ctrls;
 	if (keybd->kbdfeed->ctrl.autoRepeat && 
 	    ((xkbi->slowKey != xkbi->mouseKey) || (!xkbi->mouseKeysAccel)) &&
 	     (ctrls->enabled_ctrls&XkbRepeatKeysMask)) {
-#ifndef AIXV3
-	    if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,xkbi->slowKey))
-#endif
-	    {
+	    if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,xkbi->slowKey)) {
 		xkbi->repeatKey = xkbi->slowKey;
 		xkbi->repeatKeyTimer= TimerSet(xkbi->repeatKeyTimer,
 					0, ctrls->repeat_delay,
@@ -530,10 +527,7 @@ KeySym *	sym = XkbKeySymsPtr(xkbi->desc,
 	if ((keybd->kbdfeed->ctrl.autoRepeat) &&
 		((ctrls->enabled_ctrls&(XkbSlowKeysMask|XkbRepeatKeysMask))==
 							XkbRepeatKeysMask)) {
-#ifndef AIXV3
-	    if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,key))
-#endif
-	    {
+	    if (BitIsOn(keybd->kbdfeed->ctrl.autoRepeats,key)) {
 #ifdef DEBUG
 		if (xkbDebugFlags&0x10)
 		    ErrorF("Starting software autorepeat...\n");
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 9f6af30..86983c8 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -45,24 +45,10 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <X11/extensions/XKBgeom.h>
 #include "xkb.h"
 
-#ifdef MODE_SWITCH
-extern Bool noKME; /* defined in os/utils.c */
-#endif
-
 int	XkbDisableLockActions = 0;
 
 /***====================================================================***/
 
-#ifndef RETURN_SHOULD_REPEAT
-#if (defined(__osf__) && defined(__alpha))
-#define RETURN_SHOULD_REPEAT 1
-#else
-#define	RETURN_SHOULD_REPEAT 0
-#endif
-#endif
-
-/***====================================================================***/
-
 DeviceIntPtr
 _XkbLookupAnyDevice(int id,int *why_rtrn)
 {
@@ -560,12 +546,6 @@ CARD8			keysPerMod[XkbNumModifiers];
 	    }
 	}
     }
-#ifdef MODE_SWITCH
-    /* Fix up any of the KME stuff if we changed the core description.
-     */
-    if (!noKME)
-	HandleKeyBinding(keyc, &keyc->curKeySyms);
-#endif
     return;
 }
 
diff-tree 33406da096b4ae21134484113b280e07d0c8f0d9 (from ef7e05e9de57b9c9c27ed3307eede6d8fc6c1af3)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 23:20:56 2006 +0300

    GetKeyboardEvents: add first_valuator argument to GKVE

diff --git a/dix/events.c b/dix/events.c
index 91aa673..646a9ba 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4619,7 +4619,7 @@ GetMaximumEventsNum() {
  */
 int
 GetKeyboardEvents(xEvent *events, DeviceIntPtr pDev, int type, int key_code) {
-    return GetKeyboardValuatorEvents(events, pDev, type, key_code, 0, NULL);
+    return GetKeyboardValuatorEvents(events, pDev, type, key_code, 0, 0, NULL);
 }
 
 /**
@@ -4704,7 +4704,8 @@ int GetKeyboardValuatorEvents(xEvent *ev
         {
             numEvents += GetKeyboardValuatorEvents(events, pDev,
                                                    KeyRelease, key_code,
-                                                   num_valuators, valuators);
+                                                   first_valuator, num_valuators,
+                                                   valuators);
             events += numEvents;
         }
     }
diff-tree ef7e05e9de57b9c9c27ed3307eede6d8fc6c1af3 (from 1546a398144619a14ff06aaf84ebc1bf293eac66)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 21:42:15 2006 +0300

    xfree86/xinput: pass first_valuator params, don't clip to first screen bound
    Pass first_valuator to GetPointerEvents/GetKeyboardValuatorEvents.
    Don't clip axis bounds to that of screen 0 when initialising axes.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index ee32adc..a398740 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -653,7 +653,8 @@ xf86PostMotionEvent(DeviceIntPtr	device,
         FatalError("Couldn't allocate event store\n");
 
     nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0,
-                               flags, 0, num_valuators, valuators);
+                               flags, first_valuator, num_valuators,
+                               valuators);
 
     for (i = 0; i < nevents; i++)
         mieqEnqueue(xf86Events + i);
@@ -792,7 +793,7 @@ xf86PostButtonEvent(DeviceIntPtr	device,
                                is_down ? ButtonPress : ButtonRelease, button,
                                is_absolute ? POINTER_ABSOLUTE :
                                              POINTER_RELATIVE,
-                               0, num_valuators, valuators);
+                               first_valuator, num_valuators, valuators);
 
     for (i = 0; i < nevents; i++)
         mieqEnqueue(xf86Events + i);
@@ -829,8 +830,8 @@ xf86PostKeyEvent(DeviceIntPtr	device,
 
         nevents = GetKeyboardValuatorEvents(xf86Events, device,
                                             is_down ? KeyPress : KeyRelease,
-                                            key_code, num_valuators,
-                                            valuators);
+                                            key_code, first_valuator,
+                                            num_valuators, valuators);
     }
     else {
         nevents = GetKeyboardEvents(xf86Events, device,
@@ -971,10 +972,9 @@ xf86XInputSetScreen(LocalDevicePtr	local
 		    int			x,
 		    int			y)
 {
-    if (local->dev->coreEvents &&
-	(miPointerGetScreen(inputInfo.pointer) !=
-          screenInfo.screens[screen_number])) {
-	miPointerSetScreen(inputInfo.pointer, screen_number, x, y);
+    if (miPointerGetScreen(local->dev) !=
+          screenInfo.screens[screen_number]) {
+	miPointerSetScreen(local->dev, screen_number, x, y);
     }
 }
 
@@ -983,20 +983,11 @@ _X_EXPORT void
 xf86InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval,
 			   int resolution, int min_res, int max_res)
 {
-#ifdef XINPUT
     if (!dev || !dev->valuator)
         return;
 
-    if (maxval == -1) {
-	if (axnum == 0)
-	    maxval = screenInfo.screens[0]->width - 1;
-	else if (axnum == 1)
-	    maxval = screenInfo.screens[0]->height - 1;
-	/* else? */
-    }
     InitValuatorAxisStruct(dev, axnum, minval, maxval, resolution, min_res,
 			   max_res);
-#endif
 }
 
 /*
@@ -1006,7 +997,6 @@ xf86InitValuatorAxisStruct(DeviceIntPtr 
 _X_EXPORT void
 xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
 {
-#ifdef XINPUT
     if (axnum == 0) {
 	dev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
         dev->valuator->lastx = dev->valuator->axisVal[0];
@@ -1015,7 +1005,6 @@ xf86InitValuatorDefaults(DeviceIntPtr de
 	dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
         dev->valuator->lasty = dev->valuator->axisVal[1];
     }
-#endif
 }
 
 /* end of xf86Xinput.c */
diff-tree 1546a398144619a14ff06aaf84ebc1bf293eac66 (from b05a11478edc7e6d1e38ef7f8d6788c7bd917493)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 21:40:53 2006 +0300

    GetKeyboardValuatorEvents: also take first_valuator param
    Take a first_valuator parameter, which specifies the first valuator.

diff --git a/dix/events.c b/dix/events.c
index e6d6c77..91aa673 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4639,9 +4639,10 @@ GetKeyboardEvents(xEvent *events, Device
  * KeyPresses.
  */
 int GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
-                              int key_code, int num_valuators,
-                              int *valuators) {
-    int numEvents = 0, ms = 0, first_valuator = 0;
+                              int key_code, int first_valuator,
+                              int num_valuators, int *valuators) {
+    int numEvents = 0, ms = 0, i = 0;
+    int final_valuator = first_valuator + num_valuators;
     KeySym sym = pDev->key->curKeySyms.map[key_code *
                                            pDev->key->curKeySyms.mapWidth];
     deviceKeyButtonPointer *kbp = NULL;
@@ -4721,27 +4722,26 @@ int GetKeyboardValuatorEvents(xEvent *ev
 
     if (num_valuators) {
         kbp->deviceid |= MORE_EVENTS;
-        while (first_valuator < num_valuators) {
+        for (i = first_valuator; i < final_valuator; i += 6) {
             xv = (deviceValuator *) ++events;
             xv->type = DeviceValuator;
-            xv->first_valuator = first_valuator;
+            xv->first_valuator = i;
             xv->num_valuators = num_valuators;
             xv->deviceid = kbp->deviceid;
             switch (num_valuators - first_valuator) {
             case 6:
-                xv->valuator5 = valuators[first_valuator+5];
+                xv->valuator5 = valuators[i+5];
             case 5:
-                xv->valuator4 = valuators[first_valuator+4];
+                xv->valuator4 = valuators[i+4];
             case 4:
-                xv->valuator3 = valuators[first_valuator+3];
+                xv->valuator3 = valuators[i+3];
             case 3:
-                xv->valuator2 = valuators[first_valuator+2];
+                xv->valuator2 = valuators[i+2];
             case 2:
-                xv->valuator1 = valuators[first_valuator+1];
+                xv->valuator1 = valuators[i+1];
             case 1:
-                xv->valuator0 = valuators[first_valuator];
+                xv->valuator0 = valuators[i];
             }
-            first_valuator += 6;
         }
     }
 
diff --git a/include/input.h b/include/input.h
index 72f67c2..3e3d16d 100644
--- a/include/input.h
+++ b/include/input.h
@@ -402,7 +402,8 @@ extern int GetKeyboardValuatorEvents(
     DeviceIntPtr pDev,
     int type,
     int key_code,
-    int num_axes,
+    int first_valuator,
+    int num_valuator,
     int *valuators);
 
 extern DeviceIntPtr LookupDeviceIntRec(
diff-tree b05a11478edc7e6d1e38ef7f8d6788c7bd917493 (from 41bb9fce47f6366cc3f7d45790f7883f74289b5a)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 21:23:12 2006 +0300

    doc/extensions: rename to c-extensions
    The old name could be somewhat confusing.

diff --git a/doc/c-extensions b/doc/c-extensions
new file mode 100644
index 0000000..db2ba7d
--- /dev/null
+++ b/doc/c-extensions
@@ -0,0 +1,32 @@
+Use of extensions throughout the X server tree
+----------------------------------------------
+
+Optional extensions:
+The server will still build if your toolchain does not support these
+extensions, although the results may not be optimal.
+
+    * _X_SENTINEL(x): member x of the passed structure must be NULL, e.g.:
+                      void parseOptions(Option *options _X_SENTINEL(0));
+                      parseOptions("foo", "bar", NULL); /* this is OK */
+                      parseOptions("foo", "bar", "baz"); /* this is not */
+                      This definition comes from Xfuncproto.h in the core
+                      protocol headers.
+    * _X_ATTRIBUTE_PRINTF(x, y): This function has printf-like semantics;
+                                 check the format string when built with
+                                 -Wformat (gcc) or similar.
+    * _X_EXPORT: this function should appear in symbol tables.
+    * _X_HIDDEN: this function should not appear in the _dynamic_ symbol
+                 table.
+    * _X_INTERNAL: like _X_HIDDEN, but attempt to ensure that this function
+                   is never called from another module.
+    * _X_INLINE: inline this functon if possible (generally obeyed unless
+                 disabling optimisations).
+    * _X_DEPRECATED: warn on use of this function.
+
+Mandatory extensions:
+The server will not build if your toolchain does not support these extensions.
+
+    * named initialisers: explicitly initialising structure members, e.g.:
+                          struct foo bar = { .baz = quux, .brian = "dog" };
+    * variadic macros: macros with a variable number of arguments, e.g.:
+                       #define DebugF(x, ...) /**/
diff --git a/doc/extensions b/doc/extensions
deleted file mode 100644
index db2ba7d..0000000
--- a/doc/extensions
+++ /dev/null
@@ -1,32 +0,0 @@
-Use of extensions throughout the X server tree
-----------------------------------------------
-
-Optional extensions:
-The server will still build if your toolchain does not support these
-extensions, although the results may not be optimal.
-
-    * _X_SENTINEL(x): member x of the passed structure must be NULL, e.g.:
-                      void parseOptions(Option *options _X_SENTINEL(0));
-                      parseOptions("foo", "bar", NULL); /* this is OK */
-                      parseOptions("foo", "bar", "baz"); /* this is not */
-                      This definition comes from Xfuncproto.h in the core
-                      protocol headers.
-    * _X_ATTRIBUTE_PRINTF(x, y): This function has printf-like semantics;
-                                 check the format string when built with
-                                 -Wformat (gcc) or similar.
-    * _X_EXPORT: this function should appear in symbol tables.
-    * _X_HIDDEN: this function should not appear in the _dynamic_ symbol
-                 table.
-    * _X_INTERNAL: like _X_HIDDEN, but attempt to ensure that this function
-                   is never called from another module.
-    * _X_INLINE: inline this functon if possible (generally obeyed unless
-                 disabling optimisations).
-    * _X_DEPRECATED: warn on use of this function.
-
-Mandatory extensions:
-The server will not build if your toolchain does not support these extensions.
-
-    * named initialisers: explicitly initialising structure members, e.g.:
-                          struct foo bar = { .baz = quux, .brian = "dog" };
-    * variadic macros: macros with a variable number of arguments, e.g.:
-                       #define DebugF(x, ...) /**/
diff-tree 41bb9fce47f6366cc3f7d45790f7883f74289b5a (from be8dfafd1d58b27bbfd953fc1216311523353db1)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 20:34:32 2006 +0300

    mipointer: take device arguments, split miPointerAbsoluteCursor
    Update mipointer API to take a device argument to (almost) all functions,
    and split miPointerAbsoluteCursor into a couple of separate functions.
    Remove miPointerAbsoluteCursor call from mieq, as we now deal with it in
    GetPointerEvents.
    Make miPointerSetPosition (successor of miPointerAbsoluteCursor) take
    pointers to x and y, so it can return the clipped values.
    Modify callers of miPointer*() functions to generally use the new
    functions.
    This should fix things with multi-head setups.

diff --git a/dix/events.c b/dix/events.c
index f81de5f..e6d6c77 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -131,6 +131,8 @@ of the copyright holder.
 #endif
 #include "globals.h"
 
+#include "mipointer.h"
+
 #ifdef XKB
 #include <X11/extensions/XKBproto.h>
 #include <X11/extensions/XKBsrv.h>
@@ -4874,6 +4876,7 @@ GetPointerEvents(xEvent *events, DeviceI
     AxisInfoPtr axes = NULL;
     Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
     DeviceIntPtr cp = inputInfo.pointer;
+    int x = 0, y = 0;
 
     if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
         return 0;
@@ -4910,23 +4913,23 @@ GetPointerEvents(xEvent *events, DeviceI
 
     if (flags & POINTER_ABSOLUTE) {
         if (num_valuators >= 1 && first_valuator == 0) {
-            kbp->root_x = valuators[0];
+            x = valuators[0];
         }
         else {
             if (pDev->coreEvents)
-                kbp->root_x = cp->valuator->lastx;
+                x = cp->valuator->lastx;
             else
-                kbp->root_x = pDev->valuator->lastx;
+                x = pDev->valuator->lastx;
         }
 
         if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
-            kbp->root_y = valuators[1 - first_valuator];
+            y = valuators[1 - first_valuator];
         }
         else {
             if (pDev->coreEvents)
-                kbp->root_x = cp->valuator->lasty;
+                x = cp->valuator->lasty;
             else
-                kbp->root_y = pDev->valuator->lasty;
+                y = pDev->valuator->lasty;
         }
     }
     else {
@@ -4936,49 +4939,52 @@ GetPointerEvents(xEvent *events, DeviceI
 
         if (pDev->coreEvents) {
             if (first_valuator == 0 && num_valuators >= 1)
-                kbp->root_x = cp->valuator->lastx + valuators[0];
+                x = cp->valuator->lastx + valuators[0];
             else
-                kbp->root_x = cp->valuator->lastx;
+                x = cp->valuator->lastx;
 
             if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
-                kbp->root_y = cp->valuator->lasty +
-                              valuators[1 - first_valuator];
+                y = cp->valuator->lasty + valuators[1 - first_valuator];
             else
-                kbp->root_y = cp->valuator->lasty;
+                y = cp->valuator->lasty;
         }
         else {
             if (first_valuator == 0 && num_valuators >= 1)
-                kbp->root_x = pDev->valuator->lastx + valuators[0];
+                x = pDev->valuator->lastx + valuators[0];
             else
-                kbp->root_x = pDev->valuator->lastx;
+                x = pDev->valuator->lastx;
 
             if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
-                kbp->root_y = pDev->valuator->lasty +
-                              valuators[1 - first_valuator];
+                y = pDev->valuator->lasty + valuators[1 - first_valuator];
             else
-                kbp->root_y = pDev->valuator->lasty;
+                y = pDev->valuator->lasty;
         }
     }
 
-    /* FIXME: need mipointer-like semantics to move on to different screens. */
+
     axes = pDev->valuator->axes;
-    if (kbp->root_x < axes->min_value)
-        kbp->root_x = axes->min_value;
-    if (axes->max_value > 0 && kbp->root_x > axes->max_value)
-        kbp->root_x = axes->max_value;
+    if (x < axes->min_value)
+        x = axes->min_value;
+    if (axes->max_value > 0 && x > axes->max_value)
+        x = axes->max_value;
 
     axes++;
-    if (kbp->root_y < axes->min_value)
-        kbp->root_y = axes->min_value;
-    if (axes->max_value > 0 && kbp->root_y > axes->max_value)
-        kbp->root_y = axes->max_value;
+    if (y < axes->min_value)
+        y = axes->min_value;
+    if (axes->max_value > 0 && y > axes->max_value)
+        y = axes->max_value;
+
+    /* This takes care of crossing screens for us, as well as clipping
+     * to the current screen.  Right now, we only have one history buffer,
+     * so we don't set this for both the device and core.*/
+    miPointerSetPosition(pDev, &x, &y, ms);
 
     if (pDev->coreEvents) {
-        cp->valuator->lastx = kbp->root_x;
-        cp->valuator->lasty = kbp->root_y;
+        cp->valuator->lastx = x;
+        cp->valuator->lasty = y;
     }
-    pDev->valuator->lastx = kbp->root_x;
-    pDev->valuator->lasty = kbp->root_y;
+    pDev->valuator->lastx = x;
+    pDev->valuator->lasty = y;
 
     if (type == MotionNotify) {
         kbp->type = DeviceMotionNotify;
@@ -4991,6 +4997,9 @@ GetPointerEvents(xEvent *events, DeviceI
         kbp->detail = pDev->button->map[buttons];
     }
 
+    kbp->root_x = x;
+    kbp->root_y = y;
+
     if (final_valuator > 2 && sendValuators) {
         kbp->deviceid |= MORE_EVENTS;
         for (i = first_valuator; i < final_valuator; i += 6) {
@@ -5028,10 +5037,8 @@ GetPointerEvents(xEvent *events, DeviceI
         events++;
         events->u.u.type = type;
         events->u.keyButtonPointer.time = ms;
-        events->u.keyButtonPointer.rootX = kbp->root_x;
-        events->u.keyButtonPointer.rootY = kbp->root_y;
-        cp->valuator->lastx = kbp->root_x;
-        cp->valuator->lasty = kbp->root_y;
+        events->u.keyButtonPointer.rootX = x;
+        events->u.keyButtonPointer.rootY = y;
 
         if (type == ButtonPress || type == ButtonRelease) {
             /* We hijack SetPointerMapping to work on all core-sending
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index c7b9710..ee42b75 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -223,9 +223,9 @@ xf86SwitchMode(ScreenPtr pScreen, Displa
   if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY)
     return FALSE;
 
-  pCursorScreen = miPointerCurrentScreen();
+  pCursorScreen = miPointerGetScreen(inputInfo.pointer);
   if (pScreen == pCursorScreen)
-    miPointerPosition(&px, &py);
+    miPointerGetPosition(inputInfo.pointer, &px, &py);
 
   xf86EnterServerState(SETUP);
   Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0);
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index ff3840c..db259b3 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -253,9 +253,9 @@ ProcessInputEvents ()
   xf86Info.inputPending = FALSE;
 
   mieqProcessInputEvents();
-  miPointerUpdate();
+  miPointerUpdateSprite(inputInfo.pointer);
 
-  miPointerPosition(&x, &y);
+  miPointerGetPosition(inputInfo.pointer, &x, &y);
   xf86SetViewport(xf86Info.currentScreen, x, y);
 }
 
@@ -793,7 +793,7 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
 {
     KeyClassPtr keyc = NULL;
     KeySym *map = NULL;
-    xEvent *events = NULL, ke;
+    xEvent ke;
     int i = 0, j = 0, nevents = 0;
 
     ErrorF("releasekeys: called on device %s (%d)\n", pDev->name, pDev->id);
@@ -818,7 +818,6 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
     for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
          i < keyc->curKeySyms.maxKeyCode;
          i++, map += keyc->curKeySyms.mapWidth) {
-        ErrorF("key %d: pressed is %s\n", i, KeyPressed(i) ? "true" : "false");
         if (KeyPressed(i)) {
             switch (*map) {
             /* Don't release the lock keys */
@@ -838,10 +837,9 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
                     (*pDev->public.processInputProc) (&ke, pDev, 1);
                 }
                 else {
-                    nevents = GetKeyboardEvents(&events, pDev, KeyRelease, i);
-                    ErrorF("device %s: got %d events for %d key\n", pDev->name, nevents, i);
+                    nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i);
                     for (j = 0; j < nevents; j++)
-                        mieqEnqueue(events++);
+                        mieqEnqueue(xf86Events + i);
                 }
                 break;
             }
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index cd6a4ab..9279dbd 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -203,6 +203,9 @@ void xf86UnlockServer(void);
 
 void xf86InitXkb(void);
 
+/* xf86Xinput.c */
+extern xEvent *xf86Events;
+
 #endif /* _NO_XF86_PROTOTYPES */
 
 
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index e5bff0c..ee32adc 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -88,27 +88,19 @@
 #include <X11/Xpoll.h>
 #include "xf86_OSproc.h"	/* sigio stuff */
 
+#include "mi.h"
+
 /******************************************************************************
  * debugging macro
  *****************************************************************************/
-#ifdef DBG
-#undef DBG
-#endif
 #ifdef DEBUG
-#undef DEBUG
-#endif
-
-#define DEBUG 0
-
-#if DEBUG
 static int      debug_level = 0;
-
 #define DBG(lvl, f) {if ((lvl) <= debug_level) f;}
 #else
 #define DBG(lvl, f)
 #endif
 
-static xEvent *xf86Events = NULL;
+xEvent *xf86Events = NULL;
 
 static Bool
 xf86SendDragEvents(DeviceIntPtr	device)
@@ -558,7 +550,6 @@ NewInputDeviceRequest (InputOption *opti
     InputInfoPtr pInfo = NULL;
     InputOption *option = NULL;
     DeviceIntPtr dev = NULL;
-    int i;
 
     idev = xcalloc(sizeof(*idev), 1);
     if (!idev)
@@ -981,8 +972,9 @@ xf86XInputSetScreen(LocalDevicePtr	local
 		    int			y)
 {
     if (local->dev->coreEvents &&
-	(miPointerCurrentScreen() != screenInfo.screens[screen_number])) {
-	miPointerSetNewScreen (screen_number, x, y);
+	(miPointerGetScreen(inputInfo.pointer) !=
+          screenInfo.screens[screen_number])) {
+	miPointerSetScreen(inputInfo.pointer, screen_number, x, y);
     }
 }
 
diff --git a/mi/mieq.c b/mi/mieq.c
index 856aa25..16e638c 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -104,9 +104,6 @@ mieqEnqueue (xEvent *e)
                                       &laste->event[0];
 
     if (e->u.u.type == MotionNotify) {
-        miPointerSetPosition(pDev, e->u.keyButtonPointer.rootX,
-                             e->u.keyButtonPointer.rootY,
-                             e->u.keyButtonPointer.time);
         pDev = inputInfo.pointer;
         isMotion = inputInfo.pointer->id & DEVICE_BITS;
     }
diff --git a/mi/mipointer.c b/mi/mipointer.c
index c9b80bf..7f850ad 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -320,13 +320,18 @@ miPointerUpdateSprite (DeviceIntPtr pDev
     CursorPtr		pCursor;
     int			x, y, devx, devy;
 
+    if (!pDev || !(pDev->coreEvents || pDev == inputInfo.pointer))
+        return;
+
     pScreen = miPointer.pScreen;
+    if (!pScreen)
+	return;
+
     x = miPointer.x;
     y = miPointer.y;
     devx = miPointer.devx;
     devy = miPointer.devy;
-    if (!pScreen)
-	return;
+
     pScreenPriv = GetScreenPrivate (pScreen);
     /*
      * if the cursor has switched screens, disable the sprite
@@ -385,13 +390,20 @@ miPointerUpdateSprite (DeviceIntPtr pDev
 void
 miPointerDeltaCursor (int dx, int dy, unsigned long time)
 {
-    miPointerSetPosition(inputInfo.pointer, miPointer.x + dx,
-                         miPointer.y + dy, time);
+    int x = miPointer.x + dx, y = miPointer.y + dy;
+
+    miPointerSetPosition(inputInfo.pointer, &x, &y, time);
 }
 
 void
 miPointerSetNewScreen(int screen_no, int x, int y)
 {
+    miPointerSetScreen(inputInfo.pointer, screen_no, x, y);
+}
+
+void
+miPointerSetScreen(DeviceIntPtr pDev, int screen_no, int x, int y)
+{
 	miPointerScreenPtr pScreenPriv;
 	ScreenPtr pScreen;
 
@@ -406,21 +418,26 @@ miPointerSetNewScreen(int screen_no, int
 _X_EXPORT ScreenPtr
 miPointerCurrentScreen ()
 {
-	return (miPointer.pScreen);
+    return miPointerGetScreen(inputInfo.pointer);
 }
 
-/*
- * miPointerAbsoluteCursor.  The pointer has moved to x,y
- */
+_X_EXPORT ScreenPtr
+miPointerGetScreen(DeviceIntPtr pDev)
+{
+    return miPointer.pScreen;
+}
 
+/* Move the pointer to x, y on the current screen, update the sprite, and
+ * the motion history.  Generates no events.  Does not return changed x
+ * and y if they are clipped; use miPointerSetPosition instead. */
 _X_EXPORT void
 miPointerAbsoluteCursor (int x, int y, unsigned long time)
 {
-    miPointerSetPosition(inputInfo.pointer, x, y, time);
+    miPointerSetPosition(inputInfo.pointer, &x, &y, time);
 }
 
 _X_EXPORT void
-miPointerSetPosition(DeviceIntPtr pDev, int x, int y, unsigned long time)
+miPointerSetPosition(DeviceIntPtr pDev, int *x, int *y, unsigned long time)
 {
     miPointerScreenPtr	pScreenPriv;
     ScreenPtr		pScreen;
@@ -430,13 +447,16 @@ miPointerSetPosition(DeviceIntPtr pDev, 
     if (!pScreen)
 	return;	    /* called before ready */
 
-    if (x < 0 || x >= pScreen->width || y < 0 || y >= pScreen->height)
+    if (!pDev || !(pDev->coreEvents || pDev == inputInfo.pointer))
+        return;
+
+    if (*x < 0 || *x >= pScreen->width || *y < 0 || *y >= pScreen->height)
     {
 	pScreenPriv = GetScreenPrivate (pScreen);
 	if (!miPointer.confined)
 	{
 	    newScreen = pScreen;
-	    (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, &x, &y);
+	    (*pScreenPriv->screenFuncs->CursorOffScreen) (&newScreen, x, y);
 	    if (newScreen != pScreen)
 	    {
 		pScreen = newScreen;
@@ -448,21 +468,20 @@ miPointerSetPosition(DeviceIntPtr pDev, 
 	    }
 	}
     }
-    /*
-     * constrain the hot-spot to the current
-     * limits
-     */
-    if (x < miPointer.limits.x1)
-	x = miPointer.limits.x1;
-    if (x >= miPointer.limits.x2)
-	x = miPointer.limits.x2 - 1;
-    if (y < miPointer.limits.y1)
-	y = miPointer.limits.y1;
-    if (y >= miPointer.limits.y2)
-	y = miPointer.limits.y2 - 1;
-    if (miPointer.x == x && miPointer.y == y && miPointer.pScreen == pScreen)
+    /* Constrain the sprite to the current limits. */
+    if (*x < miPointer.limits.x1)
+	*x = miPointer.limits.x1;
+    if (*x >= miPointer.limits.x2)
+	*x = miPointer.limits.x2 - 1;
+    if (*y < miPointer.limits.y1)
+	*y = miPointer.limits.y1;
+    if (*y >= miPointer.limits.y2)
+	*y = miPointer.limits.y2 - 1;
+
+    if (miPointer.x == *x && miPointer.y == *y && miPointer.pScreen == pScreen)
 	return;
-    miPointerMove (pScreen, x, y, time);
+
+    miPointerMoved(pDev, pScreen, *x, *y, time);
 }
 
 _X_EXPORT void
@@ -478,27 +497,39 @@ miPointerGetPosition(DeviceIntPtr pDev, 
     *y = miPointer.y;
 }
 
-/*
- * miPointerMove.  The pointer has moved to x,y on current screen
- */
+void
+miPointerMove (ScreenPtr pScreen, int x, int y, unsigned long time)
+{
+    miPointerMoved(inputInfo.pointer, pScreen, x, y, time);
+}
 
-static void
-miPointerMove (pScreen, x, y, time)
-    ScreenPtr	    pScreen;
-    int		    x, y;
-    unsigned long   time;
+/* Move the pointer on the current screen,  and update the sprite. */
+void
+miPointerMoved (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
+                     unsigned long time)
 {
     SetupScreen(pScreen);
-    miHistoryPtr	history;
-    int			prev, end, start;
 
-    if (!pScreenPriv->waitForUpdate && pScreen == miPointer.pSpriteScreen)
+    if (pDev && (pDev->coreEvents || pDev == inputInfo.pointer) &&
+        !pScreenPriv->waitForUpdate && pScreen == miPointer.pSpriteScreen)
     {
 	miPointer.devx = x;
 	miPointer.devy = y;
 	if(!miPointer.pCursor->bits->emptyMask)
 	    (*pScreenPriv->spriteFuncs->MoveCursor) (pScreen, x, y);
     }
+
+    miPointerUpdateHistory(pDev, pScreen, x, y, time);
+}
+
+/* The pointer has moved to x, y; update the motion history. */
+void
+miPointerUpdateHistory (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y,
+                        unsigned long time)
+{
+    miHistoryPtr	history;
+    int			prev, end, start;
+
     miPointer.x = x;
     miPointer.y = y;
     miPointer.pScreen = pScreen;
diff --git a/mi/mipointer.h b/mi/mipointer.h
index a910de6..82ff045 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -149,22 +149,45 @@ extern ScreenPtr miPointerCurrentScreen(
 extern ScreenPtr miPointerGetScreen(
     DeviceIntPtr pDev);
 extern void miPointerSetScreen(
-    DeviceIntPtr pDev);
+    DeviceIntPtr pDev,
+    int screen_num,
+    int x,
+    int y);
 
+/* Returns the current cursor position. */
 extern void miPointerGetPosition(
     DeviceIntPtr pDev,
     int *x,
     int *y);
 
+/* Moves the cursor to the specified position.  May clip the co-ordinates:
+ * x and y are modified in-place. */
 extern void miPointerSetPosition(
     DeviceIntPtr pDev,
-    int x,
-    int y,
+    int *x,
+    int *y,
     unsigned long time);
 
 extern void miPointerUpdateSprite(
     DeviceIntPtr pDev);
 
+/* Moves the sprite to x, y on the current screen, and updates the event
+ * history. */
+extern void miPointerMoved(
+    DeviceIntPtr pDev,
+    ScreenPtr pScreen,
+    int x,
+    int y,
+    unsigned long time);
+
+/* Updates the event history. */
+extern void miPointerUpdateHistory(
+    DeviceIntPtr pDev,
+    ScreenPtr pScreen,
+    int x,
+    int y,
+    unsigned long time);
+
 extern int miPointerScreenIndex;
 
 #endif /* MIPOINTER_H */
diff-tree be8dfafd1d58b27bbfd953fc1216311523353db1 (from ca474e0920dd29ebe7ccf346cddc526732ad01ba)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 20:32:16 2006 +0300

    warning cleanups
    Fix still more warnings.

diff --git a/dix/devices.c b/dix/devices.c
index 54332e7..2149769 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -77,10 +77,9 @@ SOFTWARE.
 #include "swaprep.h"
 #include "dixevents.h"
 
-#ifdef XINPUT
 #include <X11/extensions/XIproto.h>
 #include "exglobals.h"
-#endif
+#include "exevents.h"
 
 int CoreDevicePrivatesIndex = 0, CoreDevicePrivatesGeneration = -1;
 
@@ -179,10 +178,8 @@ int
 ActivateDevice(DeviceIntPtr dev)
 {
     int ret = Success;
-#ifdef XINPUT
     devicePresenceNotify ev;
     DeviceIntRec dummyDev;
-#endif
 
     if (!dev || !dev->deviceProc)
         return BadImplementation;
@@ -190,13 +187,11 @@ ActivateDevice(DeviceIntPtr dev)
     ret = (*dev->deviceProc) (dev, DEVICE_INIT);
     dev->inited = (ret == Success);
     
-#ifdef XINPUT
     ev.type = DevicePresenceNotify;
     ev.time = currentTime.milliseconds;
     dummyDev.id = 0;
     SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
-                          &ev, 1);
-#endif
+                          (xEvent *) &ev, 1);
 
     return ret;
 }
@@ -509,10 +504,8 @@ RemoveDevice(DeviceIntPtr dev)
 {
     DeviceIntPtr prev,tmp,next;
     int ret = BadMatch;
-#ifdef XINPUT
     devicePresenceNotify ev;
     DeviceIntRec dummyDev;
-#endif
 
     DebugF("(dix) removing device %d\n", dev->id);
 
@@ -549,15 +542,13 @@ RemoveDevice(DeviceIntPtr dev)
 	}
     }
     
-#ifdef XINPUT
     if (ret == Success) {
         ev.type = DevicePresenceNotify;
         ev.time = currentTime.milliseconds;
         dummyDev.id = 0;
         SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
-                              &ev, 1);
+                              (xEvent *) &ev, 1);
     }
-#endif
 
     return ret;
 }
@@ -1128,9 +1119,7 @@ static int
 DoSetModifierMapping(ClientPtr client, KeyCode *inputMap,
                      int numKeyPerModifier)
 {
-    KeyClassPtr keyc = NULL;
     DeviceIntPtr pDev = NULL;
-    KeyCode *map = NULL;
     int i = 0, inputMapLen = numKeyPerModifier * 8;
 
     for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
@@ -1200,8 +1189,6 @@ ProcSetModifierMapping(ClientPtr client)
 {
     xSetModifierMappingReply rep;
     REQUEST(xSetModifierMappingReq);
-    register int i;
-    DeviceIntPtr keybd = inputInfo.keyboard;
     
     REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
 
@@ -1332,7 +1319,6 @@ ProcSetPointerMapping(ClientPtr client)
     BYTE *map;
     int ret;
     xSetPointerMappingReply rep;
-    unsigned int i;
 
     REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
     if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2)
@@ -1448,7 +1434,6 @@ DoChangeKeyboardControl (ClientPtr clien
     int key = DO_ALL;
     BITS32 index2;
     int mask = vmask, i;
-    DeviceIntPtr dev = NULL;
 
     ctrl = keybd->kbdfeed->ctrl;
     while (vmask) {
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 7ef411c..cb77839 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -47,6 +47,8 @@
 #endif
 #include "xf86Xinput.h"
 
+#include "mi.h"
+
 static unsigned long DGAGeneration = 0;
 static int DGAScreenIndex = -1;
 
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index ff1c904..a49bd54 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -981,7 +981,6 @@ InitInput(argc, argv)
     IDevPtr pDev;
     InputDriverPtr pDrv;
     InputInfoPtr pInfo;
-    static InputInfoPtr coreKeyboard = NULL, corePointer = NULL;
 
     xf86Info.vtRequestsPending = FALSE;
     xf86Info.inputPending = FALSE;
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 4658f23..444b2d4 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -86,11 +86,6 @@
 #define XI_PRIVATE(dev) \
 	(((LocalDevicePtr)((dev)->public.devicePrivate))->private)
 
-#ifdef DBG
-#undef DBG
-#endif
-#define DBG(lvl, f) {if ((lvl) <= xf86GetVerbosity()) f;}
-
 #ifdef HAS_MOTION_HISTORY
 #undef HAS_MOTION_HISTORY
 #endif
diff-tree ca474e0920dd29ebe7ccf346cddc526732ad01ba (from c2fab469b66f2796c541e911202faa411d116b04)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 20:30:49 2006 +0300

    Xi: move SendEventToAllWindows and FindInterestedChildren to exevents
    Move SendEventToAllWindows and FindInterestedChildren from chgptr to exevents,
    so the DIX can more easily use it.
    Clean up two warnings (type mismatch, unused variable) in exevents.c.

diff --git a/Xi/chgptr.c b/Xi/chgptr.c
index f6f4b8b..b799092 100644
--- a/Xi/chgptr.c
+++ b/Xi/chgptr.c
@@ -180,47 +180,6 @@ DeleteFocusClassDeviceStruct(DeviceIntPt
 
 /***********************************************************************
  *
- * Send an event to interested clients in all windows on all screens.
- *
- */
-
-void
-SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
-{
-    int i;
-    WindowPtr pWin, p1;
-
-    for (i = 0; i < screenInfo.numScreens; i++) {
-	pWin = WindowTable[i];
-	(void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id);
-	p1 = pWin->firstChild;
-	FindInterestedChildren(dev, p1, mask, ev, count);
-    }
-}
-
-/***********************************************************************
- *
- * Walk through the window tree, finding all clients that want to know
- * about the ChangeDeviceNotify Event.
- *
- */
-
-void
-FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask,
-		       xEvent * ev, int count)
-{
-    WindowPtr p2;
-
-    while (p1) {
-	p2 = p1->firstChild;
-	(void)DeliverEventsToWindow(p1, ev, count, mask, NullGrab, dev->id);
-	FindInterestedChildren(dev, p2, mask, ev, count);
-	p1 = p1->nextSib;
-    }
-}
-
-/***********************************************************************
- *
  * This procedure writes the reply for the XChangePointerDevice 
  * function, if the client and server have a different byte ordering.
  *
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 9fdea6d..92a5f05 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -71,8 +71,7 @@ SOFTWARE.
 #include "exglobals.h"
 #include "dixevents.h"	/* DeliverFocusedEvent */
 #include "dixgrabs.h"	/* CreateGrab() */
-
-#include "chgptr.h"
+#include "scrnintstr.h"
 
 #define WID(w) ((w) ? ((w)->drawable.id) : 0)
 #define AllModifiersMask ( \
@@ -305,7 +304,7 @@ InitValuatorAxisStruct(DeviceIntPtr dev,
     register AxisInfoPtr ax;
    
     if (!dev || !dev->valuator)
-        return NULL;
+        return;
 
     ax = dev->valuator->axes + axnum;
 
@@ -903,7 +902,7 @@ SetModifierMapping(ClientPtr client, Dev
 	return MappingBusy;
     } else {
 	for (i = 0; i < inputMapLen; i++) {
-	    if (inputMap[i] && !LegalModifier(inputMap[i], (DevicePtr) dev)) {
+	    if (inputMap[i] && !LegalModifier(inputMap[i], dev)) {
 		return MappingFailed;
 	    }
 	}
@@ -1214,3 +1213,44 @@ ShouldFreeInputMasks(WindowPtr pWin, Boo
     else
 	return FALSE;
 }
+
+/***********************************************************************
+ *
+ * Walk through the window tree, finding all clients that want to know
+ * about the Event.
+ *
+ */
+
+void
+FindInterestedChildren(DeviceIntPtr dev, WindowPtr p1, Mask mask,
+                       xEvent * ev, int count)
+{
+    WindowPtr p2;
+
+    while (p1) {
+        p2 = p1->firstChild;
+        (void)DeliverEventsToWindow(p1, ev, count, mask, NullGrab, dev->id);
+        FindInterestedChildren(dev, p2, mask, ev, count);
+        p1 = p1->nextSib;
+    }
+}
+
+/***********************************************************************
+ *
+ * Send an event to interested clients in all windows on all screens.
+ *
+ */
+
+void
+SendEventToAllWindows(DeviceIntPtr dev, Mask mask, xEvent * ev, int count)
+{
+    int i;
+    WindowPtr pWin, p1;
+
+    for (i = 0; i < screenInfo.numScreens; i++) {
+        pWin = WindowTable[i];
+        (void)DeliverEventsToWindow(pWin, ev, count, mask, NullGrab, dev->id);
+        p1 = pWin->firstChild;
+        FindInterestedChildren(dev, p1, mask, ev, count);
+    }
+}
diff --git a/include/exevents.h b/include/exevents.h
index 1169a6c..7fbaddb 100644
--- a/include/exevents.h
+++ b/include/exevents.h
@@ -179,4 +179,17 @@ extern int DeviceEventSuppressForWindow(
 	Mask                   /* mask */,
 	int                    /* maskndx */);
 
+void FindInterestedChildren(
+        DeviceIntPtr           /* dev */,
+        WindowPtr              /* p1 */,
+        Mask                   /* mask */,
+        xEvent *               /* ev */,
+        int                    /* count */);
+
+void SendEventToAllWindows(
+        DeviceIntPtr           /* dev */,
+        Mask                   /* mask */,
+        xEvent *               /* ev */,
+        int                    /* count */);
+
 #endif /* EXEVENTS_H */
diff-tree c2fab469b66f2796c541e911202faa411d116b04 (from 4493acb88c59721f7807093a3ed3c39396c2076d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 18:26:26 2006 +0300

    dix/devices: clean up debugging

diff --git a/dix/devices.c b/dix/devices.c
index 74474c9..54332e7 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -149,9 +149,6 @@ EnableDevice(register DeviceIntPtr dev)
     if ((*prev != dev) || !dev->inited ||
 	((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) {
         ErrorF("couldn't enable device %d\n", dev->id);
-#ifdef DEBUG
-        ErrorF("prev is %p, dev is %p, dev->inited is %d, ret is %d\n", prev, dev, dev->inited, ret);
-#endif
 	return FALSE;
     }
     *prev = dev->next;
@@ -365,25 +362,15 @@ InitAndStartDevices()
     register DeviceIntPtr dev, next;
 
     for (dev = inputInfo.off_devices; dev; dev = dev->next) {
-#ifdef DEBUG
-        ErrorF("(dix) initialising device %d\n", dev->id);
-#endif
+        DebugF("(dix) initialising device %d\n", dev->id);
 	ActivateDevice(dev);
-#ifdef DEBUG
-        ErrorF("(dix) finished device %d, inited is %d\n", dev->id, dev->inited);
-#endif
     }
     for (dev = inputInfo.off_devices; dev; dev = next)
     {
-#ifdef DEBUG
-        ErrorF("(dix) enabling device %d\n", dev->id);
-#endif
+        DebugF("(dix) enabling device %d\n", dev->id);
 	next = dev->next;
 	if (dev->inited && dev->startup)
 	    (void)EnableDevice(dev);
-#ifdef DEBUG
-        ErrorF("(dix) finished device %d\n", dev->id);
-#endif
     }
     for (dev = inputInfo.devices;
 	 dev && (dev != inputInfo.keyboard);
@@ -527,9 +514,7 @@ RemoveDevice(DeviceIntPtr dev)
     DeviceIntRec dummyDev;
 #endif
 
-#ifdef DEBUG
-    ErrorF("want to remove device %p, kb is %p, pointer is %p\n", dev, inputInfo.keyboard, inputInfo.pointer);
-#endif
+    DebugF("(dix) removing device %d\n", dev->id);
 
     if (!dev || dev == inputInfo.keyboard || dev == inputInfo.pointer)
         return BadImplementation;
diff-tree 4493acb88c59721f7807093a3ed3c39396c2076d (from ef68273f5bdb27a492ec0b69548ec4fbede46c08)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 17:51:03 2006 +0300

    xkb: add FIXMEs to procedures which need to act on all core devices
    Add FIXME comments above request handlers which need to act on all core-sending
    devices if called on the core keyboard.

diff --git a/xkb/xkb.c b/xkb/xkb.c
index 4655d8a..880f113 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -347,6 +347,7 @@ ProcXkbSelectEvents(ClientPtr client)
 
 /***====================================================================***/
 
+/* FIXME: Needs to ding on all core-sending devices. */
 int
 ProcXkbBell(ClientPtr client)
 {
@@ -894,6 +895,7 @@ ProcXkbSetControls(ClientPtr client)
     return client->noClientException;
 }
 
+/* FIXME: Needs to set rate on all core-sending devices. */
 int
 XkbSetRepeatRate(DeviceIntPtr dev,int timeout,int interval,int major,int minor)
 {
@@ -2325,6 +2327,7 @@ XkbServerMapPtr		srv = xkbi->desc->serve
     return (char *)wire;
 }
 
+/* FIXME: Needs to set map on all core-sending devices. */
 int
 ProcXkbSetMap(ClientPtr client)
 {
@@ -2641,6 +2644,7 @@ ProcXkbGetCompatMap(ClientPtr client)
     return XkbSendCompatMap(client,compat,&rep);
 }
 
+/* FIXME: Needs to set compat map on all core-sending devices. */
 int
 ProcXkbSetCompatMap(ClientPtr client)
 {
@@ -2918,6 +2922,7 @@ XkbIndicatorPtr		leds;
     return XkbSendIndicatorMap(client,leds,&rep);
 }
 
+/* FIXME: Needs to set indicator map on all core-sending devices. */
 int
 ProcXkbSetIndicatorMap(ClientPtr client)
 {
@@ -3081,6 +3086,7 @@ ProcXkbGetNamedIndicator(ClientPtr clien
     return client->noClientException;
 }
 
+/* FIXME: Needs to set indicator on all core-sending devices. */
 int
 ProcXkbSetNamedIndicator(ClientPtr client)
 {
@@ -3569,6 +3575,7 @@ char *	str;
     return True;
 }
 
+/* FIXME: Needs to set names on all core-sending devices. */
 int
 ProcXkbSetNames(ClientPtr client)
 {
@@ -4866,6 +4873,7 @@ char *		wire;
     return Success;
 }
 
+/* FIXME: Needs to set geom on all core-sending devices. */
 int
 ProcXkbSetGeometry(ClientPtr client)
 {
@@ -6017,6 +6025,7 @@ DeviceIntPtr			kbd;
     return (char *)ledWire;
 }
 
+/* FIXME: Needs to set info on all core-sending devices. */
 int
 ProcXkbSetDeviceInfo(ClientPtr client)
 {
diff-tree ef68273f5bdb27a492ec0b69548ec4fbede46c08 (from 6eab4c55890660089067da0e944256b1ed3a8c67)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 17:44:37 2006 +0300

    mi/mipointer: deprecate functions which don't take a device
    Deprecate all mi pointer functions which don't take a device argument, and
    replace them with versions which do, in preparation for MPX.

diff --git a/mi/mieq.c b/mi/mieq.c
index 63b900c..856aa25 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -104,9 +104,9 @@ mieqEnqueue (xEvent *e)
                                       &laste->event[0];
 
     if (e->u.u.type == MotionNotify) {
-        miPointerAbsoluteCursor(e->u.keyButtonPointer.rootX,
-                                e->u.keyButtonPointer.rootY,
-                                e->u.keyButtonPointer.time);
+        miPointerSetPosition(pDev, e->u.keyButtonPointer.rootX,
+                             e->u.keyButtonPointer.rootY,
+                             e->u.keyButtonPointer.time);
         pDev = inputInfo.pointer;
         isMotion = inputInfo.pointer->id & DEVICE_BITS;
     }
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 206a3fc..c9b80bf 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -44,6 +44,7 @@ in this Software without prior written a
 # include   "mipointrst.h"
 # include   "cursorstr.h"
 # include   "dixstruct.h"
+# include   "inputstr.h"
 
 _X_EXPORT int miPointerScreenIndex;
 static unsigned long miPointerGeneration = 0;
@@ -178,7 +179,7 @@ miPointerDisplayCursor (pScreen, pCursor
 {
     miPointer.pCursor = pCursor;
     miPointer.pScreen = pScreen;
-    miPointerUpdate ();
+    miPointerUpdateSprite(inputInfo.pointer);
     return TRUE;
 }
 
@@ -225,7 +226,7 @@ miPointerSetCursorPosition(pScreen, x, y
     /* device dependent - must pend signal and call miPointerWarpCursor */
     (*pScreenPriv->screenFuncs->WarpCursor) (pScreen, x, y);
     if (!generateEvent)
-	miPointerUpdate();
+	miPointerUpdateSprite(inputInfo.pointer);
     return TRUE;
 }
 
@@ -308,6 +309,12 @@ miPointerGetMotionEvents (pPtr, coords, 
 void
 miPointerUpdate ()
 {
+    miPointerUpdateSprite(inputInfo.pointer);
+}
+
+void
+miPointerUpdateSprite (DeviceIntPtr pDev)
+{
     ScreenPtr		pScreen;
     miPointerScreenPtr	pScreenPriv;
     CursorPtr		pCursor;
@@ -376,11 +383,10 @@ miPointerUpdate ()
  */
 
 void
-miPointerDeltaCursor (dx, dy, time)
-    int		    dx, dy;
-    unsigned long   time;
+miPointerDeltaCursor (int dx, int dy, unsigned long time)
 {
-    miPointerAbsoluteCursor (miPointer.x + dx, miPointer.y + dy, time);
+    miPointerSetPosition(inputInfo.pointer, miPointer.x + dx,
+                         miPointer.y + dy, time);
 }
 
 void
@@ -408,9 +414,13 @@ miPointerCurrentScreen ()
  */
 
 _X_EXPORT void
-miPointerAbsoluteCursor (x, y, time)
-    int		    x, y;
-    unsigned long   time;
+miPointerAbsoluteCursor (int x, int y, unsigned long time)
+{
+    miPointerSetPosition(inputInfo.pointer, x, y, time);
+}
+
+_X_EXPORT void
+miPointerSetPosition(DeviceIntPtr pDev, int x, int y, unsigned long time)
 {
     miPointerScreenPtr	pScreenPriv;
     ScreenPtr		pScreen;
@@ -419,6 +429,7 @@ miPointerAbsoluteCursor (x, y, time)
     pScreen = miPointer.pScreen;
     if (!pScreen)
 	return;	    /* called before ready */
+
     if (x < 0 || x >= pScreen->width || y < 0 || y >= pScreen->height)
     {
 	pScreenPriv = GetScreenPrivate (pScreen);
@@ -455,8 +466,13 @@ miPointerAbsoluteCursor (x, y, time)
 }
 
 _X_EXPORT void
-miPointerPosition (x, y)
-    int	    *x, *y;
+miPointerPosition (int *x, int *y)
+{
+    miPointerGetPosition(inputInfo.pointer, x, y);
+}
+
+_X_EXPORT void
+miPointerGetPosition(DeviceIntPtr pDev, int *x, int *y)
 {
     *x = miPointer.x;
     *y = miPointer.y;
@@ -473,7 +489,6 @@ miPointerMove (pScreen, x, y, time)
     unsigned long   time;
 {
     SetupScreen(pScreen);
-    xEvent		xE;
     miHistoryPtr	history;
     int			prev, end, start;
 
diff --git a/mi/mipointer.h b/mi/mipointer.h
index b4e74ea..a910de6 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -111,40 +111,59 @@ extern int miPointerGetMotionEvents(
     ScreenPtr /*pScreen*/
 );
 
+/* Deprecated in favour of miPointerUpdateSprite. */
 extern void miPointerUpdate(
     void
 ) _X_DEPRECATED;
 
+/* Deprecated in favour of miSetPointerPosition. */
 extern void miPointerDeltaCursor(
     int /*dx*/,
     int /*dy*/,
     unsigned long /*time*/
 ) _X_DEPRECATED;
-
 extern void miPointerAbsoluteCursor(
     int /*x*/,
     int /*y*/,
     unsigned long /*time*/
 ) _X_DEPRECATED;
 
+/* Deprecated in favour of miGetPointerPosition. */
 extern void miPointerPosition(
     int * /*x*/,
     int * /*y*/
 ) _X_DEPRECATED;
 
+/* Deprecated in favour of miPointerSetScreen. */
 extern void miPointerSetNewScreen(
     int, /*screen_no*/
-	int, /*x*/
-	int /*y*/
+    int, /*x*/
+    int /*y*/
 ) _X_DEPRECATED;
+
+/* Deprecated in favour of miPointerGetScreen. */
 extern ScreenPtr miPointerCurrentScreen(
     void
 ) _X_DEPRECATED;
 
-extern void miRegisterPointerDevice(
-    ScreenPtr /*pScreen*/,
-    DeviceIntPtr /*pDevice*/
-);
+extern ScreenPtr miPointerGetScreen(
+    DeviceIntPtr pDev);
+extern void miPointerSetScreen(
+    DeviceIntPtr pDev);
+
+extern void miPointerGetPosition(
+    DeviceIntPtr pDev,
+    int *x,
+    int *y);
+
+extern void miPointerSetPosition(
+    DeviceIntPtr pDev,
+    int x,
+    int y,
+    unsigned long time);
+
+extern void miPointerUpdateSprite(
+    DeviceIntPtr pDev);
 
 extern int miPointerScreenIndex;
 
diff-tree 6eab4c55890660089067da0e944256b1ed3a8c67 (from 80cdd26581508dd17c5d0a5739cd540113996bbb)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 17:24:33 2006 +0300

    doc/extensions: document C extension use in the X server

diff --git a/doc/extensions b/doc/extensions
new file mode 100644
index 0000000..db2ba7d
--- /dev/null
+++ b/doc/extensions
@@ -0,0 +1,32 @@
+Use of extensions throughout the X server tree
+----------------------------------------------
+
+Optional extensions:
+The server will still build if your toolchain does not support these
+extensions, although the results may not be optimal.
+
+    * _X_SENTINEL(x): member x of the passed structure must be NULL, e.g.:
+                      void parseOptions(Option *options _X_SENTINEL(0));
+                      parseOptions("foo", "bar", NULL); /* this is OK */
+                      parseOptions("foo", "bar", "baz"); /* this is not */
+                      This definition comes from Xfuncproto.h in the core
+                      protocol headers.
+    * _X_ATTRIBUTE_PRINTF(x, y): This function has printf-like semantics;
+                                 check the format string when built with
+                                 -Wformat (gcc) or similar.
+    * _X_EXPORT: this function should appear in symbol tables.
+    * _X_HIDDEN: this function should not appear in the _dynamic_ symbol
+                 table.
+    * _X_INTERNAL: like _X_HIDDEN, but attempt to ensure that this function
+                   is never called from another module.
+    * _X_INLINE: inline this functon if possible (generally obeyed unless
+                 disabling optimisations).
+    * _X_DEPRECATED: warn on use of this function.
+
+Mandatory extensions:
+The server will not build if your toolchain does not support these extensions.
+
+    * named initialisers: explicitly initialising structure members, e.g.:
+                          struct foo bar = { .baz = quux, .brian = "dog" };
+    * variadic macros: macros with a variable number of arguments, e.g.:
+                       #define DebugF(x, ...) /**/
diff-tree 80cdd26581508dd17c5d0a5739cd540113996bbb (from 97030b6c6b0fb6ff629ae31e483704d0a2207a53)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 17:23:54 2006 +0300

    mi/pointer: mark public pointer functions as deprecated
    Deprecate miPointer functions which don't take a device pointer.  Pointer
    movement should be handled through GetPointerEvents, and functions which
    take a device as an argument (e.g. miPointerPosition) will be added.

diff --git a/mi/mipointer.h b/mi/mipointer.h
index aae3837..b4e74ea 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -97,11 +97,11 @@ extern void miPointerWarpCursor(
     ScreenPtr /*pScreen*/,
     int /*x*/,
     int /*y*/
-);
+) _X_DEPRECATED;
 
 extern int miPointerGetMotionBufferSize(
     void
-);
+) _X_DEPRECATED;
 
 extern int miPointerGetMotionEvents(
     DeviceIntPtr /*pPtr*/,
@@ -113,33 +113,33 @@ extern int miPointerGetMotionEvents(
 
 extern void miPointerUpdate(
     void
-);
+) _X_DEPRECATED;
 
 extern void miPointerDeltaCursor(
     int /*dx*/,
     int /*dy*/,
     unsigned long /*time*/
-);
+) _X_DEPRECATED;
 
 extern void miPointerAbsoluteCursor(
     int /*x*/,
     int /*y*/,
     unsigned long /*time*/
-);
+) _X_DEPRECATED;
 
 extern void miPointerPosition(
     int * /*x*/,
     int * /*y*/
-);
+) _X_DEPRECATED;
 
 extern void miPointerSetNewScreen(
     int, /*screen_no*/
 	int, /*x*/
 	int /*y*/
-);
+) _X_DEPRECATED;
 extern ScreenPtr miPointerCurrentScreen(
     void
-);
+) _X_DEPRECATED;
 
 extern void miRegisterPointerDevice(
     ScreenPtr /*pScreen*/,
diff-tree 97030b6c6b0fb6ff629ae31e483704d0a2207a53 (from 14b157bdb1f2cd5feba03ba0815d7c5b2dd6633f)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 17:07:05 2006 +0300

    config: fix compilation
    Accidentally built with --disable-config, didn't notice that the previous
    commit to clean up the debugging broke things horribly.

diff --git a/config/config.c b/config/config.c
index f74495e..8cb4406 100644
--- a/config/config.c
+++ b/config/config.c
@@ -37,8 +37,8 @@
 #define MATCH_RULE "type='method_call',interface='org.x.config.input'"
 
 #define MALFORMED_MSG "config: malformed message, dropping"
-#define MALFORMED_MESSAGE DebugF(MALFORMED_MSG)
-#define MALFORMED_MESSAGE_ERROR DEBUGF(MALFORMED_MSG ": %s, %s", \
+#define MALFORMED_MESSAGE() DebugF(MALFORMED_MSG)
+#define MALFORMED_MESSAGE_ERROR() DebugF(MALFORMED_MSG ": %s, %s", \
                                        error.name, error.message)
 
 static DBusConnection *configConnection = NULL;
diff-tree 14b157bdb1f2cd5feba03ba0815d7c5b2dd6633f (from 9e37de193f5d7412ffd8de76d5eed0158c0a3609)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 17:04:12 2006 +0300

    include: actually declare DebugF
    DebugF is ErrorF when DEBUG is defined, else a no-op.

diff --git a/include/os.h b/include/os.h
index fbe1592..d4eed22 100644
--- a/include/os.h
+++ b/include/os.h
@@ -510,6 +510,12 @@ __attribute((noreturn))
 #endif
 ;
 
+#ifdef DEBUG
+#define DebugF ErrorF
+#else
+#define DebugF(x, ...) /* */
+#endif
+
 extern void VErrorF(const char *f, va_list args);
 extern void ErrorF(const char *f, ...) _printf_attribute(1,2);
 extern void Error(char *str);
diff-tree 9e37de193f5d7412ffd8de76d5eed0158c0a3609 (from b559cbb1601f93cb03ea3dcfb2c5ca94ee6b73bb)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 16:32:15 2006 +0300

    configure.ac: reactivate warnings when building with gcc
    We were inadvertently stomping XSERVER_CFLAGS after adding the warnings, so
    move them after we do that.

diff --git a/configure.ac b/configure.ac
index 0397b58..e1342f1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -848,28 +848,6 @@ else
 fi
 AM_CONDITIONAL(DEBUG, [test "x$DEBUGGING" = xyes])
 
-# The Xorg binary needs to export symbols so that they can be used from modules
-# Some platforms require extra flags to do this.   gcc should set these flags
-# when -rdynamic is passed to it, other compilers/linkers may need to be added
-# here.
-if test "x$GCC" = "xyes"; then
-       GCC_WARNINGS1="-Wall -Wpointer-arith -Wstrict-prototypes"
-       GCC_WARNINGS2="-Wmissing-prototypes -Wmissing-declarations"
-       GCC_WARNINGS3="-Wnested-externs -fno-strict-aliasing"
-       GCC_WARNINGS="$GCC_WARNINGS1 $GCC_WARNINGS2 $GCC_WARNINGS3"
-       if test "x$WERROR" = "xyes"; then
-               GCC_WARNINGS="${GCC_WARNINGS} -Werror"
-       fi
-       XSERVER_CFLAGS="$GCC_WARNINGS $XSERVER_CFLAGS"
-       LD_EXPORT_SYMBOLS_FLAG="-rdynamic"
-fi
-case $host_os in
-       openbsd*)
-       LD_EXPORT_SYMBOLS_FLAG="-Wl,--export-dynamic"
-       ;;
-esac
-AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])
-
 AC_DEFINE(USE_RGB_TXT, 1, [Use rgb.txt directly])
 AC_DEFINE(MITMISC, 1, [Support MIT Misc extension])
 AC_DEFINE(XTEST, 1, [Support XTest extension])
@@ -900,6 +878,29 @@ XSERVER_LIBS="${XSERVERLIBS_LIBS} ${SYS_
 AC_SUBST([XSERVER_LIBS])
 AC_SUBST([SYS_LIBS])
 
+# The Xorg binary needs to export symbols so that they can be used from modules
+# Some platforms require extra flags to do this.   gcc should set these flags
+# when -rdynamic is passed to it, other compilers/linkers may need to be added
+# here.
+if test "x$GCC" = "xyes"; then
+       GCC_WARNINGS1="-Wall -Wpointer-arith -Wstrict-prototypes"
+       GCC_WARNINGS2="-Wmissing-prototypes -Wmissing-declarations"
+       GCC_WARNINGS3="-Wnested-externs -fno-strict-aliasing"
+       GCC_WARNINGS="$GCC_WARNINGS1 $GCC_WARNINGS2 $GCC_WARNINGS3"
+       if test "x$WERROR" = "xyes"; then
+               GCC_WARNINGS="${GCC_WARNINGS} -Werror"
+       fi
+       XSERVER_CFLAGS="$GCC_WARNINGS $XSERVER_CFLAGS"
+
+       LD_EXPORT_SYMBOLS_FLAG="-rdynamic"
+fi
+case $host_os in
+       openbsd*)
+       LD_EXPORT_SYMBOLS_FLAG="-Wl,--export-dynamic"
+       ;;
+esac
+AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])
+
 dnl Imake defines SVR4 on SVR4 systems, and many files check for it, so
 dnl we need to replicate that here until those can all be fixed
 AC_MSG_CHECKING([if SVR4 needs to be defined])
diff-tree b559cbb1601f93cb03ea3dcfb2c5ca94ee6b73bb (from 3ae4d250185e71a0a218c062426f92b9b1adbf05)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 16:23:14 2006 +0300

    dix/CoreProcessKeyboardEvent: remove debugging for every key event
    Also change #ifdef DEBUG/ErrorF/#endif to DebugF in FixKeyState.

diff --git a/dix/events.c b/dix/events.c
index 24fa50d..f81de5f 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -2777,12 +2777,6 @@ drawable.id:0;
     }
 #endif
 
-#ifdef DEBUG
-    if (((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
-	ErrorF("CoreProcessKbdEvent: Key %d %s\n",key,
-			(xE->u.u.type==KeyPress?"down":"up"));
-    }
-#endif
     switch (xE->u.u.type)
     {
 	case KeyPress: 
@@ -2863,12 +2857,12 @@ FixKeyState (register xEvent *xE, regist
     key = xE->u.u.detail;
     kptr = &keyc->down[key >> 3];
     bit = 1 << (key & 7);
-#ifdef DEBUG
+
     if (((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
-	ErrorF("FixKeyState: Key %d %s\n",key,
+	DebugF("FixKeyState: Key %d %s\n",key,
 			(xE->u.u.type==KeyPress?"down":"up"));
     }
-#endif
+
     switch (xE->u.u.type)
     {
 	case KeyPress: 
diff-tree 3ae4d250185e71a0a218c062426f92b9b1adbf05 (from 58314756aeecbb8fb04706c3e04d98e9ac531a02)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 16:20:42 2006 +0300

    xfree86 Xinput: remove still more excessive debugging
    There isn't any more debugging left for input events in the XFree86 DDX.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 4bbca71..e5bff0c 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -644,10 +644,6 @@ xf86PostMotionEvent(DeviceIntPtr	device,
     int *valuators = NULL;
     int flags = 0;
 
-#ifdef DEBUG
-    ErrorF("xf8PostMotionEvent enter: is_absolute %s\n",
-           is_absolute ? "yes" : "no");
-#endif
     if (is_absolute)
         flags = POINTER_ABSOLUTE;
     else
@@ -658,9 +654,6 @@ xf86PostMotionEvent(DeviceIntPtr	device,
     va_start(var, num_valuators);
     for (i = 0; i < num_valuators; i++) {
         valuators[i] = va_arg(var, int);
-#ifdef DEBUG
-        ErrorF("valuator %d: %d\n", i, valuators[i]);
-#endif
     }
 
     if (!xf86Events)
@@ -699,10 +692,8 @@ xf86PostProximityEvent(DeviceIntPtr	devi
     int				loop;
     Bool			is_core = device->coreEvents;
 
-#ifdef DEBUG
-    ErrorF("xf86PostProximityEvent enter\n");
-#endif
-    
+    ErrorF("xf86PostProximityEvent: no-op event called\n");
+
 #if 0
     DBG(5, ErrorF("xf86PostProximityEvent BEGIN 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
                   device, device->name, is_in ? "true" : "false",
@@ -794,20 +785,10 @@ xf86PostButtonEvent(DeviceIntPtr	device,
     int *valuators = NULL;
     int i = 0, nevents = 0;
     
-#ifdef DEBUG
-    ErrorF("xf86PostButtonEvent BEGIN 0x%x(%s) button=%d down=%s is_absolute=%s\n",
-                  device, device->name, button,
-                  is_down ? "True" : "False",
-                  is_absolute ? "True" : "False");
-#endif
-
     valuators = xcalloc(sizeof(int), num_valuators);
 
     va_start(var, num_valuators);
     for (i = 0; i < num_valuators; i++) {
-#ifdef DEBUG
-        ErrorF("valuator %d: %d\n", i, valuators[i]);
-#endif
         valuators[i] = va_arg(var, int);
     }
 
@@ -839,7 +820,7 @@ xf86PostKeyEvent(DeviceIntPtr	device,
     int i = 0, nevents = 0, *valuators = NULL;
 
     /* instil confidence in the user */
-    ErrorF("this function has never been tested properly.  if things go quite "
+    DebugF("this function has never been tested properly.  if things go quite "
            "badly south after this message, then xf86PostKeyEvent is "
            "broken.\n");
 
@@ -848,8 +829,6 @@ xf86PostKeyEvent(DeviceIntPtr	device,
     if (!xf86Events)
         FatalError("Couldn't allocate event store\n");
 
-    /* the spec says that dkp/dkr events should only get valuators in
-     * absolute mode.  the spec knows all.  BOW BEFORE etc. */
     if (is_absolute) {
         valuators = xcalloc(sizeof(int), num_valuators);
         va_start(var, num_valuators);
@@ -879,11 +858,6 @@ xf86PostKeyboardEvent(DeviceIntPtr      
 {
     int nevents = 0, i = 0;
 
-#ifdef DEBUG
-    ErrorF("xf86PKE enter: keycode %d is %s, device %d\n", key_code,
-           is_down ? "down" : "up", device->id);
-#endif
-
     if (!xf86Events)
         xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
     if (!xf86Events)
diff-tree 58314756aeecbb8fb04706c3e04d98e9ac531a02 (from 84f5d2291c1fe92fd8358e999e909bf3aab86c98)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 16:18:05 2006 +0300

    GetPointerEvents: add first_valuator parameter
    Add a first_valuator parameter.  Looks correct by inspection, but untested
    with first_valuator != 0 as yet.

diff --git a/dix/events.c b/dix/events.c
index 07cf03f..24fa50d 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4789,15 +4789,28 @@ int GetKeyboardValuatorEvents(xEvent *ev
 
 /* Originally a part of xf86PostMotionEvent. */
 static void
-acceleratePointer(DeviceIntPtr pDev, int num_valuators, int *valuators)
+acceleratePointer(DeviceIntPtr pDev, int first_valuator, int num_valuators,
+                  int *valuators)
 {
     float mult = 0.0;
-    int dx = num_valuators >= 1 ? valuators[0] : 0;
-    int dy = num_valuators >= 2 ? valuators[1] : 0;
+    int dx = 0, dy = 0;
+    int *px = NULL, *py = NULL;
 
     if (!num_valuators || !valuators)
         return;
 
+    if (first_valuator == 0) {
+        dx = valuators[0];
+        px = &valuators[0];
+    }
+    if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
+        dy = valuators[1 - first_valuator];
+        py = &valuators[1 - first_valuator];
+    }
+
+    if (!dx && !dy)
+        return;
+
     /*
      * Accelerate
      */
@@ -4809,20 +4822,24 @@ acceleratePointer(DeviceIntPtr pDev, int
                                              (float)(pDev->ptrfeed->ctrl.num)) /
                                              (float)(pDev->ptrfeed->ctrl.den) +
                                             pDev->valuator->dxremaind;
-                valuators[0] = (int)pDev->valuator->dxremaind;
-                pDev->valuator->dxremaind = pDev->valuator->dxremaind -
-                                            (float)valuators[0];
+                if (px) {
+                    *px = (int)pDev->valuator->dxremaind;
+                    pDev->valuator->dxremaind = pDev->valuator->dxremaind -
+                                                (float)(*px);
+                }
 
                 pDev->valuator->dyremaind = ((float)dy *
                                              (float)(pDev->ptrfeed->ctrl.num)) /
                                              (float)(pDev->ptrfeed->ctrl.den) +
                                             pDev->valuator->dyremaind;
-                valuators[1] = (int)pDev->valuator->dyremaind;
-                pDev->valuator->dyremaind = pDev->valuator->dyremaind -
-                                            (float)valuators[1];
+                if (py) {
+                    *py = (int)pDev->valuator->dyremaind;
+                    pDev->valuator->dyremaind = pDev->valuator->dyremaind -
+                                                (float)(*py);
+                }
             }
         }
-        else if (dx || dy) {
+        else {
             mult = pow((float)(dx * dx + dy * dy),
                        ((float)(pDev->ptrfeed->ctrl.num) /
                         (float)(pDev->ptrfeed->ctrl.den) - 1.0) /
@@ -4830,16 +4847,16 @@ acceleratePointer(DeviceIntPtr pDev, int
             if (dx) {
                 pDev->valuator->dxremaind = mult * (float)dx +
                                             pDev->valuator->dxremaind;
-                valuators[0] = (int)pDev->valuator->dxremaind;
+                *px = (int)pDev->valuator->dxremaind;
                 pDev->valuator->dxremaind = pDev->valuator->dxremaind -
-                                            (float)valuators[0];
+                                            (float)(*px);
             }
             if (dy) {
                 pDev->valuator->dyremaind = mult * (float)dy +
                                             pDev->valuator->dyremaind;
-                valuators[1] = (int)pDev->valuator->dyremaind;
+                *py = (int)pDev->valuator->dyremaind;
                 pDev->valuator->dyremaind = pDev->valuator->dyremaind -
-                                            (float)valuators[1];
+                                            (float)(*py);
             }
         }
     }
@@ -4855,8 +4872,9 @@ acceleratePointer(DeviceIntPtr pDev, int
  */
 int
 GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
-                 int flags, int num_valuators, int *valuators) {
-    int numEvents = 0, ms = 0, first_valuator = 0;
+                 int flags, int first_valuator, int num_valuators,
+                 int *valuators) {
+    int num_events = 0, ms = 0, final_valuator = 0, i = 0;
     deviceKeyButtonPointer *kbp = NULL;
     deviceValuator *xv = NULL;
     AxisInfoPtr axes = NULL;
@@ -4869,20 +4887,27 @@ GetPointerEvents(xEvent *events, DeviceI
     if (!pDev->button || (pDev->coreEvents && (!cp->button || !cp->valuator)))
         return 0;
 
+    /* You fail. */
+    if (first_valuator < 0)
+        return 0;
+
     if (pDev->coreEvents)
-        numEvents = 2;
+        num_events = 2;
     else
-        numEvents = 1;
+        num_events = 1;
 
-    if (num_valuators > 2 && sendValuators) {
+    /* Do we need to send a DeviceValuator event? */
+    if ((num_valuators + first_valuator) >= 2 && sendValuators) {
         if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS)
             num_valuators = MAX_VALUATOR_EVENTS;
-        numEvents += (num_valuators / 6) + 1;
+        num_events += (num_valuators / 6) + 1;
     }
-    else if (type == MotionNotify && num_valuators < 2) {
+    else if (type == MotionNotify && num_valuators <= 0) {
         return 0;
     }
 
+    final_valuator = num_valuators + first_valuator;
+
     ms = GetTimeInMillis();
 
     kbp = (deviceKeyButtonPointer *) events;
@@ -4890,7 +4915,7 @@ GetPointerEvents(xEvent *events, DeviceI
     kbp->deviceid = pDev->id;
 
     if (flags & POINTER_ABSOLUTE) {
-        if (num_valuators >= 1) {
+        if (num_valuators >= 1 && first_valuator == 0) {
             kbp->root_x = valuators[0];
         }
         else {
@@ -4899,8 +4924,9 @@ GetPointerEvents(xEvent *events, DeviceI
             else
                 kbp->root_x = pDev->valuator->lastx;
         }
-        if (num_valuators >= 2) {
-            kbp->root_y = valuators[1];
+
+        if (first_valuator <= 1 && num_valuators >= (2 - first_valuator)) {
+            kbp->root_y = valuators[1 - first_valuator];
         }
         else {
             if (pDev->coreEvents)
@@ -4911,25 +4937,30 @@ GetPointerEvents(xEvent *events, DeviceI
     }
     else {
         if (flags & POINTER_ACCELERATE)
-            acceleratePointer(pDev, num_valuators, valuators);
+            acceleratePointer(pDev, first_valuator, num_valuators,
+                              valuators);
 
         if (pDev->coreEvents) {
-            if (num_valuators >= 1)
+            if (first_valuator == 0 && num_valuators >= 1)
                 kbp->root_x = cp->valuator->lastx + valuators[0];
             else
                 kbp->root_x = cp->valuator->lastx;
-            if (num_valuators >= 2)
-                kbp->root_y = cp->valuator->lasty + valuators[1];
+
+            if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
+                kbp->root_y = cp->valuator->lasty +
+                              valuators[1 - first_valuator];
             else
                 kbp->root_y = cp->valuator->lasty;
         }
         else {
-            if (num_valuators >= 1)
+            if (first_valuator == 0 && num_valuators >= 1)
                 kbp->root_x = pDev->valuator->lastx + valuators[0];
             else
                 kbp->root_x = pDev->valuator->lastx;
-            if (num_valuators >= 2)
-                kbp->root_y = pDev->valuator->lasty + valuators[1];
+
+            if (first_valuator <= 1 && num_valuators >= (2 - first_valuator))
+                kbp->root_y = pDev->valuator->lasty +
+                              valuators[1 - first_valuator];
             else
                 kbp->root_y = pDev->valuator->lasty;
         }
@@ -4941,6 +4972,7 @@ GetPointerEvents(xEvent *events, DeviceI
         kbp->root_x = axes->min_value;
     if (axes->max_value > 0 && kbp->root_x > axes->max_value)
         kbp->root_x = axes->max_value;
+
     axes++;
     if (kbp->root_y < axes->min_value)
         kbp->root_y = axes->min_value;
@@ -4965,35 +4997,36 @@ GetPointerEvents(xEvent *events, DeviceI
         kbp->detail = pDev->button->map[buttons];
     }
 
-    if (num_valuators > 2 && sendValuators) {
+    if (final_valuator > 2 && sendValuators) {
         kbp->deviceid |= MORE_EVENTS;
-        while (first_valuator < num_valuators) {
+        for (i = first_valuator; i < final_valuator; i += 6) {
             xv = (deviceValuator *) ++events;
             xv->type = DeviceValuator;
-            xv->first_valuator = first_valuator;
+            xv->first_valuator = i;
             xv->num_valuators = num_valuators;
             xv->deviceid = kbp->deviceid;
-            switch (num_valuators - first_valuator) {
+            switch (final_valuator - i) {
             case 6:
-                xv->valuator5 = valuators[first_valuator+5];
+                xv->valuator5 = valuators[i+5];
             case 5:
-                xv->valuator4 = valuators[first_valuator+4];
+                xv->valuator4 = valuators[i+4];
             case 4:
-                xv->valuator3 = valuators[first_valuator+3];
+                xv->valuator3 = valuators[i+3];
             case 3:
-                xv->valuator2 = valuators[first_valuator+2];
+                xv->valuator2 = valuators[i+2];
             case 2:
-                if (first_valuator == 0)
+                /* x and y may have been accelerated. */
+                if (i == 0)
                     xv->valuator1 = kbp->root_y;
                 else
-                    xv->valuator1 = valuators[first_valuator+1];
+                    xv->valuator1 = valuators[i+1];
             case 1:
-                if (first_valuator == 0)
+                /* x and y may have been accelerated. */
+                if (i == 0)
                     xv->valuator0 = kbp->root_x;
                 else
-                    xv->valuator0 = valuators[first_valuator];
+                    xv->valuator0 = valuators[i];
             }
-            first_valuator += 6;
         }
     }
 
@@ -5005,8 +5038,11 @@ GetPointerEvents(xEvent *events, DeviceI
         events->u.keyButtonPointer.rootY = kbp->root_y;
         cp->valuator->lastx = kbp->root_x;
         cp->valuator->lasty = kbp->root_y;
+
         if (type == ButtonPress || type == ButtonRelease) {
-            /* Core buttons remapping shouldn't be transitive. */
+            /* We hijack SetPointerMapping to work on all core-sending
+             * devices, so we use the device-specific map here instead of
+             * the core one. */
             events->u.u.detail = pDev->button->map[buttons];
         }
         else {
@@ -5018,5 +5054,5 @@ GetPointerEvents(xEvent *events, DeviceI
             inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
     }
 
-    return numEvents;
+    return num_events;
 }
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index cdb26b1..8dd3728 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2049,7 +2049,7 @@ _KdEnqueuePointerEvent (KdPointerInfo *p
     if (!force && KdHandlePointerEvent(pi, type, x, y, z, b, absrel))
         return;
 
-    nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel, 3,
+    nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel, 0, 3,
                                valuators);
     for (i = 0; i < nEvents; i++)
         KdQueueEvent(kdEvents + i);
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 070645d..4bbca71 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -669,7 +669,7 @@ xf86PostMotionEvent(DeviceIntPtr	device,
         FatalError("Couldn't allocate event store\n");
 
     nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0,
-                               flags, num_valuators, valuators);
+                               flags, 0, num_valuators, valuators);
 
     for (i = 0; i < nevents; i++)
         mieqEnqueue(xf86Events + i);
@@ -820,7 +820,7 @@ xf86PostButtonEvent(DeviceIntPtr	device,
                                is_down ? ButtonPress : ButtonRelease, button,
                                is_absolute ? POINTER_ABSOLUTE :
                                              POINTER_RELATIVE,
-                               num_valuators, valuators);
+                               0, num_valuators, valuators);
 
     for (i = 0; i < nevents; i++)
         mieqEnqueue(xf86Events + i);
diff --git a/include/input.h b/include/input.h
index 66d03d0..72f67c2 100644
--- a/include/input.h
+++ b/include/input.h
@@ -387,7 +387,8 @@ extern int GetPointerEvents(
     int type,
     int buttons,
     int flags,
-    int num_axes,
+    int first_valuator,
+    int num_valuators,
     int *valuators);
 
 extern int GetKeyboardEvents(
diff-tree 84f5d2291c1fe92fd8358e999e909bf3aab86c98 (from cfc3e9ede2dc83741bd38bf3df13f096ecb8adc0)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 15:30:24 2006 +0300

    GetPointerEvents: fix relatively harmless typo
    Change !(cp->button || !cp->valuator) to (!cp->button || !cp->valuator).

diff --git a/dix/events.c b/dix/events.c
index c95a942..07cf03f 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4866,7 +4866,7 @@ GetPointerEvents(xEvent *events, DeviceI
     if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
         return 0;
 
-    if (!pDev->button || (pDev->coreEvents && !(cp->button || !cp->valuator)))
+    if (!pDev->button || (pDev->coreEvents && (!cp->button || !cp->valuator)))
         return 0;
 
     if (pDev->coreEvents)
diff-tree cfc3e9ede2dc83741bd38bf3df13f096ecb8adc0 (from 8d8e7f8bae4099f9e90ef9aac687607dae1d32bf)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 15:27:52 2006 +0300

    config: remove excessive debugging

diff --git a/config/config.c b/config/config.c
index d980f76..f74495e 100644
--- a/config/config.c
+++ b/config/config.c
@@ -36,6 +36,11 @@
 
 #define MATCH_RULE "type='method_call',interface='org.x.config.input'"
 
+#define MALFORMED_MSG "config: malformed message, dropping"
+#define MALFORMED_MESSAGE DebugF(MALFORMED_MSG)
+#define MALFORMED_MESSAGE_ERROR DEBUGF(MALFORMED_MSG ": %s, %s", \
+                                       error.name, error.message)
+
 static DBusConnection *configConnection = NULL;
 static int configfd = -1;
 static char busobject[32] = { 0 };
@@ -60,32 +65,17 @@ configMessage(DBusConnection *connection
     int deviceid = -1;
     DeviceIntPtr pDev = NULL;
 
-#ifdef DEBUG
-    ErrorF("[dbus] new message!\n");
-    ErrorF("       source: %s\n", dbus_message_get_sender(message));
-    ErrorF("       destination: %s\n", dbus_message_get_destination(message));
-    ErrorF("       signature: %s\n", dbus_message_get_signature(message));
-    ErrorF("       path: %s\n", dbus_message_get_path(message));
-    ErrorF("       interface: %s\n", dbus_message_get_interface(message));
-    ErrorF("       member: %s\n", dbus_message_get_member(message));
-    ErrorF("       method call? %s\n", (dbus_message_get_type(message) ==
-                                         DBUS_MESSAGE_TYPE_METHOD_CALL) ?
-                                        "yes" : "no");
-#endif
-
     dbus_error_init(&error);
 
     if (strcmp(dbus_message_get_interface(message),
                "org.x.config.input") == 0) {
         if (!dbus_message_iter_init(message, &iter)) {
-            ErrorF("failed to init iterator! this is probably bad.\n");
+            ErrorF("config: failed to init iterator\n");
             dbus_error_free(&error);
             return DBUS_HANDLER_RESULT_NEED_MEMORY; /* ?? */
         }
         if (strcmp(dbus_message_get_member(message), "add") == 0) {
-#ifdef DEBUG
-            ErrorF("       we want to add a device!\n");
-#endif
+            DebugF("config: adding device\n");
             /* signature should be [ss][ss]... */
             while (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_ARRAY) {
                 option = (InputOption *)xcalloc(sizeof(InputOption), 1);
@@ -103,14 +93,14 @@ configMessage(DBusConnection *connection
 
                 if (dbus_message_iter_get_arg_type(&subiter) !=
                     DBUS_TYPE_STRING) {
-                    ErrorF("couldn't get the arg type\n");
+                    MALFORMED_MESSAGE();
                     xfree(option);
                     dbus_error_free(&error);
                     return DBUS_HANDLER_RESULT_HANDLED;
                 }
                 dbus_message_iter_get_basic(&subiter, &tmp);
                 if (!tmp) {
-                    ErrorF("couldn't get the key!\n");
+                    MALFORMED_MESSAGE();
                     xfree(option);
                     break;
                 }
@@ -122,7 +112,7 @@ configMessage(DBusConnection *connection
                 }
 
                 if (!dbus_message_iter_has_next(&subiter)) {
-                    ErrorF("broken message: no next\n");
+                    MALFORMED_MESSAGE();
                     xfree(option->key);
                     xfree(option);
                     dbus_error_free(&error);
@@ -132,14 +122,14 @@ configMessage(DBusConnection *connection
 
                 if (dbus_message_iter_get_arg_type(&subiter) !=
                     DBUS_TYPE_STRING) {
-                    ErrorF("couldn't get the arg type\n");
+                    MALFORMED_MESSAGE();
                     xfree(option);
                     dbus_error_free(&error);
                     return DBUS_HANDLER_RESULT_HANDLED;
                 }
                 dbus_message_iter_get_basic(&subiter, &tmp);
                 if (!tmp) {
-                    ErrorF("couldn't get the value!\n");
+                    MALFORMED_MESSAGE();
                     xfree(option->key);
                     xfree(option);
                     break;
@@ -158,23 +148,21 @@ configMessage(DBusConnection *connection
             }
 
             if (NewInputDeviceRequest(ret) != Success) {
-                ErrorF("[config] NIDR failed\n");
+                DebugF("config: NewInputDeviceRequest failed\n");
             }
             dbus_error_free(&error);
             return DBUS_HANDLER_RESULT_HANDLED;
         }
         else if (strcmp(dbus_message_get_member(message), "remove") == 0) {
-#ifdef DEBUG
-            ErrorF("        we want to remove a device!\n");
-#endif
+            ErrorF("config: removing device\n");
             if (!dbus_message_get_args(message, &error, DBUS_TYPE_INT32,
                                        &deviceid, DBUS_TYPE_INVALID)) {
-                ErrorF("couldn't get args: %s %s\n", error.name, error.message);
+                MALFORMED_MESSAGE_ERROR();
                 dbus_error_free(&error);
                 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
             }
             if (deviceid < 0 || !(pDev = LookupDeviceIntRec(deviceid))) {
-                ErrorF("bogus device id %d\n", deviceid);
+                DebugF("config: bogus device id %d given\n", deviceid);
                 dbus_error_free(&error);
                 return DBUS_HANDLER_RESULT_HANDLED;
             }
@@ -251,10 +239,8 @@ configInitialise()
         FatalError("[dbus] couldn't register object path\n");
         return;
     }
-#ifdef DEBUG
-    ErrorF("[dbus] registered object path %s\n", busobject);
-    ErrorF("[dbus] registered and listening\n");
-#endif
+
+    DebugF("[dbus] registered object path %s\n", busobject);
 
     dbus_error_free(&error);
 
diff-tree 8d8e7f8bae4099f9e90ef9aac687607dae1d32bf (from 22a836fafd39a8ef413826dc2c94bc5f96990e2d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Oct 8 15:26:54 2006 +0300

    kdrive/input: remove excessive debugging in NIDR

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 3915436..cdb26b1 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2362,7 +2362,6 @@ NewInputDeviceRequest(InputOption *optio
     }
 
     for (option = options; option; option = option->next) {
-        ErrorF("option '%s': '%s'\n", option->key, option->value);
         if (strcmp(option->key, "driver") == 0) {
             if (pi) {
                 pi->driver = KdFindPointerDriver(option->value);
diff-tree 22a836fafd39a8ef413826dc2c94bc5f96990e2d (from 3686cd0fbf56d883f2f3b3fda11ffba1058b74e4)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Oct 7 14:16:51 2006 +0300

    xfree86/loader: bump input major ABI version
    Bump input major ABI version to 1.0, since we removed the OS keyboard
    layer.

diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index f54be49..f0cf5eb 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -85,7 +85,7 @@ typedef enum {
  */
 #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 3)
 #define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(1, 0)
-#define ABI_XINPUT_VERSION	SET_ABI_VERSION(0, 6)
+#define ABI_XINPUT_VERSION	SET_ABI_VERSION(1, 0)
 #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(0, 3)
 #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 5)
 
diff-tree 3686cd0fbf56d883f2f3b3fda11ffba1058b74e4 (from 7b4dc171b036107cfba87a1a16bf692b982005a5)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 6 17:20:42 2006 +0300

    xkb: make XkbSetControls work on all core-sending devices

diff --git a/xkb/xkb.c b/xkb/xkb.c
index 7a17db6..4655d8a 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -677,7 +677,7 @@ ProcXkbGetControls(ClientPtr client)
 int
 ProcXkbSetControls(ClientPtr client)
 {
-    DeviceIntPtr 	dev;
+    DeviceIntPtr 	dev, tmpd;
     XkbSrvInfoPtr	xkbi;
     XkbControlsPtr	ctrl;
     XkbControlsRec	new,old;
@@ -688,159 +688,207 @@ ProcXkbSetControls(ClientPtr client)
     REQUEST(xkbSetControlsReq);
     REQUEST_SIZE_MATCH(xkbSetControlsReq);
 
-    if (!(client->xkbClientFlags&_XkbClientInitialized))
+    if (!(client->xkbClientFlags & _XkbClientInitialized))
 	return BadAccess;
 
-    CHK_KBD_DEVICE(dev,stuff->deviceSpec);
-    CHK_MASK_LEGAL(0x01,stuff->changeCtrls,XkbAllControlsMask);
+    CHK_KBD_DEVICE(dev, stuff->deviceSpec);
+    CHK_MASK_LEGAL(0x01, stuff->changeCtrls, XkbAllControlsMask);
 
-    xkbi = dev->key->xkbInfo;
-    ctrl = xkbi->desc->ctrls;
-    new = *ctrl;
-    XkbSetCauseXkbReq(&cause,X_kbSetControls,client);
-    if (stuff->changeCtrls&XkbInternalModsMask) {
-	CHK_MASK_MATCH(0x02,stuff->affectInternalMods,stuff->internalMods);
-	CHK_MASK_MATCH(0x03,stuff->affectInternalVMods,stuff->internalVMods);
-	new.internal.real_mods&=~stuff->affectInternalMods;
-	new.internal.real_mods|=(stuff->affectInternalMods&stuff->internalMods);
-	new.internal.vmods&=~stuff->affectInternalVMods;
-	new.internal.vmods|= (stuff->affectInternalVMods&stuff->internalVMods);
-	new.internal.mask= new.internal.real_mods|
-	      XkbMaskForVMask(xkbi->desc,new.internal.vmods);
-    }
-    if (stuff->changeCtrls&XkbIgnoreLockModsMask) {
-	CHK_MASK_MATCH(0x4,stuff->affectIgnoreLockMods,stuff->ignoreLockMods);
-	CHK_MASK_MATCH(0x5,stuff->affectIgnoreLockVMods,stuff->ignoreLockVMods);
-	new.ignore_lock.real_mods&=~stuff->affectIgnoreLockMods;
-	new.ignore_lock.real_mods|=
-	      (stuff->affectIgnoreLockMods&stuff->ignoreLockMods);
-	new.ignore_lock.vmods&= ~stuff->affectIgnoreLockVMods;
-	new.ignore_lock.vmods|=
-	      (stuff->affectIgnoreLockVMods&stuff->ignoreLockVMods);
-	new.ignore_lock.mask= new.ignore_lock.real_mods|
-	      XkbMaskForVMask(xkbi->desc,new.ignore_lock.vmods);
-    }
-    CHK_MASK_MATCH(0x06,stuff->affectEnabledCtrls,stuff->enabledCtrls);
-    if (stuff->affectEnabledCtrls) {
-	CHK_MASK_LEGAL(0x07,stuff->affectEnabledCtrls,XkbAllBooleanCtrlsMask);
-	new.enabled_ctrls&= ~stuff->affectEnabledCtrls;
-	new.enabled_ctrls|= (stuff->affectEnabledCtrls&stuff->enabledCtrls);
-    }
-    if (stuff->changeCtrls&XkbRepeatKeysMask) {
-	if ((stuff->repeatDelay<1)||(stuff->repeatInterval<1)) {
-	   client->errorValue = _XkbErrCode3(0x08,stuff->repeatDelay,
-							stuff->repeatInterval);
-	   return BadValue;
-	}
-	new.repeat_delay = stuff->repeatDelay;
-	new.repeat_interval = stuff->repeatInterval;
-    }
-    if (stuff->changeCtrls&XkbSlowKeysMask) {
-	if (stuff->slowKeysDelay<1) {
-	    client->errorValue = _XkbErrCode2(0x09,stuff->slowKeysDelay);
-	    return BadValue;
-	}
-	new.slow_keys_delay = stuff->slowKeysDelay;
-    }
-    if (stuff->changeCtrls&XkbBounceKeysMask) {
-	if (stuff->debounceDelay<1) {
-	    client->errorValue = _XkbErrCode2(0x0A,stuff->debounceDelay);
-	    return BadValue;
-	}
-	new.debounce_delay = stuff->debounceDelay;
-    }
-    if (stuff->changeCtrls&XkbMouseKeysMask) {
-	if (stuff->mkDfltBtn>XkbMaxMouseKeysBtn) {
-	    client->errorValue = _XkbErrCode2(0x0B,stuff->mkDfltBtn);
-	    return BadValue;
-	}
-	new.mk_dflt_btn = stuff->mkDfltBtn;
-    }
-    if (stuff->changeCtrls&XkbMouseKeysAccelMask) {
-	if ((stuff->mkDelay<1) || (stuff->mkInterval<1) ||
-	    (stuff->mkTimeToMax<1) || (stuff->mkMaxSpeed<1)||
-	    (stuff->mkCurve<-1000)) {
-	    client->errorValue = _XkbErrCode2(0x0C,0);
-	    return BadValue;
-	}
-	new.mk_delay = stuff->mkDelay;
-	new.mk_interval = stuff->mkInterval;
-	new.mk_time_to_max = stuff->mkTimeToMax;
-	new.mk_max_speed = stuff->mkMaxSpeed;
-	new.mk_curve = stuff->mkCurve;
-	AccessXComputeCurveFactor(xkbi,&new);
-    }
-    if (stuff->changeCtrls&XkbGroupsWrapMask) {
-	unsigned act,num;
-	act= XkbOutOfRangeGroupAction(stuff->groupsWrap);
-	switch (act) {
-	    case XkbRedirectIntoRange:
-		num= XkbOutOfRangeGroupNumber(stuff->groupsWrap);
-		if (num>=new.num_groups) {
-		    client->errorValue= _XkbErrCode3(0x0D,new.num_groups,num);
-		    return BadValue;
-		}
-	    case XkbWrapIntoRange:
-	    case XkbClampIntoRange:
-		break;
-	    default:
-		client->errorValue= _XkbErrCode2(0x0E,act);
-		return BadValue;
-	}
-	new.groups_wrap= stuff->groupsWrap;
-    }
-    CHK_MASK_LEGAL(0x0F,stuff->axOptions,XkbAX_AllOptionsMask);
-    if (stuff->changeCtrls&XkbAccessXKeysMask)
-	new.ax_options = stuff->axOptions&XkbAX_AllOptionsMask;
-    else {
-	if (stuff->changeCtrls&XkbStickyKeysMask) {
-	   new.ax_options&= ~XkbAX_SKOptionsMask;
-	   new.ax_options|= stuff->axOptions&XkbAX_SKOptionsMask;
-	}
-	if (stuff->changeCtrls&XkbAccessXFeedbackMask) {
-	   new.ax_options&= ~XkbAX_FBOptionsMask;
-	   new.ax_options|= stuff->axOptions&XkbAX_FBOptionsMask;
-	}
-    }
+    for (tmpd = inputInfo.keyboard; tmpd; tmpd = tmpd->next) {
+        if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) ||
+            tmpd == inputInfo.keyboard) {
+
+            xkbi = tmpd->key->xkbInfo;
+            ctrl = xkbi->desc->ctrls;
+            new = *ctrl;
+            XkbSetCauseXkbReq(&cause, X_kbSetControls, client);
+
+            if (stuff->changeCtrls & XkbInternalModsMask) {
+                CHK_MASK_MATCH(0x02, stuff->affectInternalMods,
+                               stuff->internalMods);
+                CHK_MASK_MATCH(0x03, stuff->affectInternalVMods,
+                               stuff->internalVMods);
+
+                new.internal.real_mods &= ~(stuff->affectInternalMods);
+                new.internal.real_mods |= (stuff->affectInternalMods &
+                                           stuff->internalMods);
+                new.internal.vmods &= ~(stuff->affectInternalVMods);
+                new.internal.vmods |= (stuff->affectInternalVMods &
+                                       stuff->internalVMods);
+                new.internal.mask = new.internal.real_mods |
+                                    XkbMaskForVMask(xkbi->desc,
+                                                    new.internal.vmods);
+            }
 
-    if (stuff->changeCtrls&XkbAccessXTimeoutMask) {
-	if (stuff->axTimeout<1) {
-	    client->errorValue = _XkbErrCode2(0x10,stuff->axTimeout);
-	    return BadValue;
-	}
-	CHK_MASK_MATCH(0x11,stuff->axtCtrlsMask,stuff->axtCtrlsValues);
-	CHK_MASK_LEGAL(0x12,stuff->axtCtrlsMask,XkbAllBooleanCtrlsMask);
-	CHK_MASK_MATCH(0x13,stuff->axtOptsMask,stuff->axtOptsValues);
-	CHK_MASK_LEGAL(0x14,stuff->axtOptsMask,XkbAX_AllOptionsMask);
-	new.ax_timeout = stuff->axTimeout;
-	new.axt_ctrls_mask = stuff->axtCtrlsMask;
-	new.axt_ctrls_values = (stuff->axtCtrlsValues&stuff->axtCtrlsMask);
-	new.axt_opts_mask = stuff->axtOptsMask;
-	new.axt_opts_values= (stuff->axtOptsValues&stuff->axtOptsMask);
-    }
-    if (stuff->changeCtrls&XkbPerKeyRepeatMask) {
-	memcpy(new.per_key_repeat,stuff->perKeyRepeat,XkbPerKeyBitArraySize);
-    }
-
-    old= *ctrl;
-    *ctrl= new;
-    XkbDDXChangeControls(dev,&old,ctrl);
+            if (stuff->changeCtrls & XkbIgnoreLockModsMask) {
+                CHK_MASK_MATCH(0x4, stuff->affectIgnoreLockMods,
+                               stuff->ignoreLockMods);
+                CHK_MASK_MATCH(0x5, stuff->affectIgnoreLockVMods,
+                               stuff->ignoreLockVMods);
+
+                new.ignore_lock.real_mods &= ~(stuff->affectIgnoreLockMods);
+                new.ignore_lock.real_mods |= (stuff->affectIgnoreLockMods &
+                                              stuff->ignoreLockMods);
+                new.ignore_lock.vmods &= ~(stuff->affectIgnoreLockVMods);
+                new.ignore_lock.vmods |= (stuff->affectIgnoreLockVMods &
+                                          stuff->ignoreLockVMods);
+                new.ignore_lock.mask = new.ignore_lock.real_mods |
+                                       XkbMaskForVMask(xkbi->desc,
+                                                       new.ignore_lock.vmods);
+            }
 
-    if (XkbComputeControlsNotify(dev,&old,ctrl,&cn,False)) {
-	cn.keycode= 0;
-	cn.eventType = 0;
-	cn.requestMajor = XkbReqCode;
-	cn.requestMinor = X_kbSetControls;
-	XkbSendControlsNotify(dev,&cn);
-    }
+            CHK_MASK_MATCH(0x06, stuff->affectEnabledCtrls,
+                           stuff->enabledCtrls);
+            if (stuff->affectEnabledCtrls) {
+                CHK_MASK_LEGAL(0x07, stuff->affectEnabledCtrls,
+                               XkbAllBooleanCtrlsMask);
+
+                new.enabled_ctrls &= ~(stuff->affectEnabledCtrls);
+                new.enabled_ctrls |= (stuff->affectEnabledCtrls &
+                                      stuff->enabledCtrls);
+            }
+
+            if (stuff->changeCtrls & XkbRepeatKeysMask) {
+                if (stuff->repeatDelay < 1 || stuff->repeatInterval < 1) {
+                    client->errorValue = _XkbErrCode3(0x08, stuff->repeatDelay,
+                                                      stuff->repeatInterval);
+                    return BadValue;
+                }
 
-    if ((sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0))!=NULL)
-	XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
-
-    /* If sticky keys were disabled, clear all locks and latches */
-    if ((old.enabled_ctrls&XkbStickyKeysMask)&&
-	(!(ctrl->enabled_ctrls&XkbStickyKeysMask))) {
-	XkbClearAllLatchesAndLocks(dev,xkbi,True,&cause);
+                new.repeat_delay = stuff->repeatDelay;
+                new.repeat_interval = stuff->repeatInterval;
+            }
+
+            if (stuff->changeCtrls & XkbSlowKeysMask) {
+                if (stuff->slowKeysDelay < 1) {
+                    client->errorValue = _XkbErrCode2(0x09,
+                                                      stuff->slowKeysDelay);
+                    return BadValue;
+                }
+
+                new.slow_keys_delay = stuff->slowKeysDelay;
+            }
+
+            if (stuff->changeCtrls & XkbBounceKeysMask) {
+                if (stuff->debounceDelay < 1) {
+                    client->errorValue = _XkbErrCode2(0x0A,
+                                                      stuff->debounceDelay);
+                    return BadValue;
+                }
+
+                new.debounce_delay = stuff->debounceDelay;
+            }
+
+            if (stuff->changeCtrls & XkbMouseKeysMask) {
+                if (stuff->mkDfltBtn > XkbMaxMouseKeysBtn) {
+                    client->errorValue = _XkbErrCode2(0x0B, stuff->mkDfltBtn);
+                    return BadValue;
+                }
+
+                new.mk_dflt_btn = stuff->mkDfltBtn;
+            }
+
+            if (stuff->changeCtrls & XkbMouseKeysAccelMask) {
+                if (stuff->mkDelay < 1 || stuff->mkInterval < 1 ||
+                    stuff->mkTimeToMax < 1 || stuff->mkMaxSpeed < 1 ||
+                    stuff->mkCurve < -1000) {
+                    client->errorValue = _XkbErrCode2(0x0C,0);
+                    return BadValue;
+                }
+
+                new.mk_delay = stuff->mkDelay;
+                new.mk_interval = stuff->mkInterval;
+                new.mk_time_to_max = stuff->mkTimeToMax;
+                new.mk_max_speed = stuff->mkMaxSpeed;
+                new.mk_curve = stuff->mkCurve;
+                AccessXComputeCurveFactor(xkbi, &new);
+            }
+
+            if (stuff->changeCtrls & XkbGroupsWrapMask) {
+                unsigned act, num;
+
+                act = XkbOutOfRangeGroupAction(stuff->groupsWrap);
+                switch (act) {
+                case XkbRedirectIntoRange:
+                    num = XkbOutOfRangeGroupNumber(stuff->groupsWrap);
+                    if (num >= new.num_groups) {
+                        client->errorValue = _XkbErrCode3(0x0D, new.num_groups,
+                                                          num);
+                        return BadValue;
+                    }
+                case XkbWrapIntoRange:
+                case XkbClampIntoRange:
+                    break;
+                default:
+                    client->errorValue = _XkbErrCode2(0x0E, act);
+                    return BadValue;
+                }
+
+                new.groups_wrap= stuff->groupsWrap;
+            }
+
+            CHK_MASK_LEGAL(0x0F, stuff->axOptions, XkbAX_AllOptionsMask);
+            if (stuff->changeCtrls & XkbAccessXKeysMask) {
+                new.ax_options = stuff->axOptions & XkbAX_AllOptionsMask;
+            }
+            else {
+                if (stuff->changeCtrls & XkbStickyKeysMask) {
+                    new.ax_options &= ~(XkbAX_SKOptionsMask);
+                    new.ax_options |= (stuff->axOptions & XkbAX_SKOptionsMask);
+                }
+            
+                if (stuff->changeCtrls & XkbAccessXFeedbackMask) {
+                    new.ax_options &= ~(XkbAX_FBOptionsMask);
+                    new.ax_options |= (stuff->axOptions & XkbAX_FBOptionsMask);
+                }
+            }
+
+            if (stuff->changeCtrls & XkbAccessXTimeoutMask) {
+                if (stuff->axTimeout < 1) {
+                    client->errorValue = _XkbErrCode2(0x10, stuff->axTimeout);
+                    return BadValue;
+                }
+                CHK_MASK_MATCH(0x11, stuff->axtCtrlsMask,
+                               stuff->axtCtrlsValues);
+                CHK_MASK_LEGAL(0x12, stuff->axtCtrlsMask,
+                               XkbAllBooleanCtrlsMask);
+                CHK_MASK_MATCH(0x13, stuff->axtOptsMask, stuff->axtOptsValues);
+                CHK_MASK_LEGAL(0x14, stuff->axtOptsMask, XkbAX_AllOptionsMask);
+                new.ax_timeout = stuff->axTimeout;
+                new.axt_ctrls_mask = stuff->axtCtrlsMask;
+                new.axt_ctrls_values = (stuff->axtCtrlsValues &
+                                        stuff->axtCtrlsMask);
+                new.axt_opts_mask = stuff->axtOptsMask;
+                new.axt_opts_values = (stuff->axtOptsValues &
+                                       stuff->axtOptsMask);
+            }
+
+            if (stuff->changeCtrls & XkbPerKeyRepeatMask)
+                memcpy(new.per_key_repeat, stuff->perKeyRepeat,
+                       XkbPerKeyBitArraySize);
+
+            old= *ctrl;
+            *ctrl= new;
+            XkbDDXChangeControls(tmpd, &old, ctrl);
+
+            if (XkbComputeControlsNotify(tmpd, &old, ctrl, &cn, False)) {
+                cn.keycode = 0;
+                cn.eventType = 0;
+                cn.requestMajor = XkbReqCode;
+                cn.requestMinor = X_kbSetControls;
+                XkbSendControlsNotify(tmpd, &cn);
+            }
+
+            sli = XkbFindSrvLedInfo(tmpd, XkbDfltXIClass, XkbDfltXIId, 0);
+            if (sli)
+                XkbUpdateIndicators(tmpd, sli->usesControls, True, NULL,
+                                    &cause);
+
+            /* If sticky keys were disabled, clear all locks and latches */
+            if ((old.enabled_ctrls & XkbStickyKeysMask) &&
+                !(ctrl->enabled_ctrls & XkbStickyKeysMask))
+                XkbClearAllLatchesAndLocks(tmpd, xkbi, True, &cause);
+        }
     }
 
     return client->noClientException;
diff-tree 7b4dc171b036107cfba87a1a16bf692b982005a5 (from ab56f0c5b516269bb99ae8b5f479e49e61a3af76)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 6 16:26:54 2006 +0300

    xkb: remove unused #ifndef

diff --git a/xkb/xkb.c b/xkb/xkb.c
index d4830b9..7a17db6 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -821,9 +821,11 @@ ProcXkbSetControls(ClientPtr client)
     if (stuff->changeCtrls&XkbPerKeyRepeatMask) {
 	memcpy(new.per_key_repeat,stuff->perKeyRepeat,XkbPerKeyBitArraySize);
     }
+
     old= *ctrl;
     *ctrl= new;
     XkbDDXChangeControls(dev,&old,ctrl);
+
     if (XkbComputeControlsNotify(dev,&old,ctrl,&cn,False)) {
 	cn.keycode= 0;
 	cn.eventType = 0;
@@ -831,15 +833,16 @@ ProcXkbSetControls(ClientPtr client)
 	cn.requestMinor = X_kbSetControls;
 	XkbSendControlsNotify(dev,&cn);
     }
+
     if ((sli= XkbFindSrvLedInfo(dev,XkbDfltXIClass,XkbDfltXIId,0))!=NULL)
 	XkbUpdateIndicators(dev,sli->usesControls,True,NULL,&cause);
-#ifndef NO_CLEAR_LATCHES_FOR_STICKY_KEYS_OFF
+
     /* If sticky keys were disabled, clear all locks and latches */
     if ((old.enabled_ctrls&XkbStickyKeysMask)&&
 	(!(ctrl->enabled_ctrls&XkbStickyKeysMask))) {
 	XkbClearAllLatchesAndLocks(dev,xkbi,True,&cause);
     }
-#endif
+
     return client->noClientException;
 }
 
diff-tree ab56f0c5b516269bb99ae8b5f479e49e61a3af76 (from 4b6e2f12f7296e17b2850f36b3adcf8156125cbe)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 6 16:12:36 2006 +0300

    xkb: simplify core device loop in GetKeyboardByName

diff --git a/xkb/xkb.c b/xkb/xkb.c
index 3052288..d4830b9 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -570,7 +570,7 @@ ProcXkbLatchLockState(ClientPtr client)
                 status = XkbLatchModifiers(tmpd, stuff->affectModLatches,
                                            stuff->modLatches);
             if (status == Success && stuff->latchGroup)
-                status = XkbLatchGroup(tmp, stuff->groupLatch);
+                status = XkbLatchGroup(tmpd, stuff->groupLatch);
 
             if (status != Success)
                 return status;
@@ -5111,6 +5111,8 @@ ProcXkbGetKbdByName(ClientPtr client)
     unsigned			fwant,fneed,reported;
     int				status;
     Bool			geom_changed;
+    XkbSrvLedInfoPtr            old_sli;
+    XkbSrvLedInfoPtr            sli;
 
     REQUEST(xkbGetKbdByNameReq);
     REQUEST_AT_LEAST_SIZE(xkbGetKbdByNameReq);
@@ -5379,45 +5381,27 @@ ProcXkbGetKbdByName(ClientPtr client)
 	}
 	xkb->ctrls->num_groups= nTG;
 
-	memcpy(dev->key->modifierMap,xkb->map->modmap,xkb->max_key_code+1);
-	XkbUpdateCoreDescription(dev,True);
-
-	if (dev->kbdfeed && dev->kbdfeed->xkb_sli) {
-            XkbSrvLedInfoPtr	old_sli;
-            XkbSrvLedInfoPtr	sli;
-            old_sli = dev->kbdfeed->xkb_sli;
-            dev->kbdfeed->xkb_sli = NULL;
-	    sli = XkbAllocSrvLedInfo(dev,dev->kbdfeed,NULL,0);
-            if (sli) {
-               sli->explicitState = old_sli->explicitState;
-               sli->effectiveState = old_sli->effectiveState;
-            }
-            dev->kbdfeed->xkb_sli = sli;
-	    XkbFreeSrvLedInfo(old_sli);
-	}
-
-        if (dev == inputInfo.keyboard) {
-            for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
-                if (tmpd->key && tmpd->coreEvents) {
-                    memcpy(tmpd->key->modifierMap, xkb->map->modmap,
-                           xkb->max_key_code + 1);
+        for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
+            if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) ||
+                tmpd == inputInfo.keyboard) {
+
+                memcpy(tmpd->key->modifierMap, xkb->map->modmap,
+                       xkb->max_key_code + 1);
+                if (dev != inputInfo.keyboard)
                     XkbCopyKeymap(dev->key->xkbInfo->desc,
                                   tmpd->key->xkbInfo->desc, True);
-                    XkbUpdateCoreDescription(tmpd, True);
+                XkbUpdateCoreDescription(tmpd, True);
 
-	            if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) {
-                        XkbSrvLedInfoPtr old_sli;
-                        XkbSrvLedInfoPtr sli;
-                        old_sli = tmpd->kbdfeed->xkb_sli;
-                        tmpd->kbdfeed->xkb_sli = NULL;
-                        sli = XkbAllocSrvLedInfo(tmpd, tmpd->kbdfeed, NULL, 0);
-                        if (sli) {
-                            sli->explicitState = old_sli->explicitState;
-                            sli->effectiveState = old_sli->effectiveState;
-                        }
-                        tmpd->kbdfeed->xkb_sli = sli;
-                        XkbFreeSrvLedInfo(old_sli);
+                if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) {
+                    old_sli = tmpd->kbdfeed->xkb_sli;
+                    tmpd->kbdfeed->xkb_sli = NULL;
+                    sli = XkbAllocSrvLedInfo(tmpd, tmpd->kbdfeed, NULL, 0);
+                    if (sli) {
+                        sli->explicitState = old_sli->explicitState;
+                        sli->effectiveState = old_sli->effectiveState;
                     }
+                    tmpd->kbdfeed->xkb_sli = sli;
+                    XkbFreeSrvLedInfo(old_sli);
                 }
             }
         }
diff-tree 4b6e2f12f7296e17b2850f36b3adcf8156125cbe (from ebf9b3bbbb04acb78cdf8a84e47a96755fbfe854)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 6 16:08:21 2006 +0300

    xkb: make LatchLockGroup work on all core-sending devices
    Apply the settings to all devices sending core events, if we're working on the
    core keyboard.

diff --git a/xkb/xkb.c b/xkb/xkb.c
index 23b9798..3052288 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -534,56 +534,67 @@ int
 ProcXkbLatchLockState(ClientPtr client)
 {
     int status;
-    DeviceIntPtr dev;
+    DeviceIntPtr dev, tmpd;
     XkbStateRec	oldState,*newState;
     CARD16 changed;
+    xkbStateNotify sn;
+    XkbEventCauseRec cause;
 
     REQUEST(xkbLatchLockStateReq);
     REQUEST_SIZE_MATCH(xkbLatchLockStateReq);
 
-    if (!(client->xkbClientFlags&_XkbClientInitialized))
+    if (!(client->xkbClientFlags & _XkbClientInitialized))
 	return BadAccess;
 
-    CHK_KBD_DEVICE(dev,stuff->deviceSpec);
-    CHK_MASK_MATCH(0x01,stuff->affectModLocks,stuff->modLocks);
-    CHK_MASK_MATCH(0x01,stuff->affectModLatches,stuff->modLatches);
+    CHK_KBD_DEVICE(dev, stuff->deviceSpec);
+    CHK_MASK_MATCH(0x01, stuff->affectModLocks, stuff->modLocks);
+    CHK_MASK_MATCH(0x01, stuff->affectModLatches, stuff->modLatches);
 
     status = Success;
-    oldState= dev->key->xkbInfo->state;
-    newState= &dev->key->xkbInfo->state;
-    if ( stuff->affectModLocks ) {
-	newState->locked_mods&= ~stuff->affectModLocks;
-	newState->locked_mods|= (stuff->affectModLocks&stuff->modLocks);
-    }
-    if (( status == Success ) && stuff->lockGroup )
-	newState->locked_group = stuff->groupLock;
-    if (( status == Success ) && stuff->affectModLatches )
-	status=XkbLatchModifiers(dev,stuff->affectModLatches,stuff->modLatches);
-    if (( status == Success ) && stuff->latchGroup )
-	status=XkbLatchGroup(dev,stuff->groupLatch);
-
-    if ( status != Success )
-	return status;
-
-    XkbComputeDerivedState(dev->key->xkbInfo);
-    dev->key->state= XkbStateFieldFromRec(newState);
 
-    changed = XkbStateChangedFlags(&oldState,newState);
-    if (changed) {
-	xkbStateNotify	sn;
-	sn.keycode= 0;
-	sn.eventType= 0;
-	sn.requestMajor = XkbReqCode;
-	sn.requestMinor = X_kbLatchLockState;
-	sn.changed= changed;
-	XkbSendStateNotify(dev,&sn);
-	changed= XkbIndicatorsToUpdate(dev,changed,False);
-	if (changed) {
-	    XkbEventCauseRec	cause;
-	    XkbSetCauseXkbReq(&cause,X_kbLatchLockState,client);
-	    XkbUpdateIndicators(dev,changed,True,NULL,&cause);
-	}
+    for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
+        if ((dev == inputInfo.keyboard && tmpd->key && tmpd->coreEvents) ||
+            tmpd == inputInfo.keyboard) {
+            if (!tmpd->key->xkbInfo)
+                continue;
+
+            oldState = tmpd->key->xkbInfo->state;
+            newState = &tmpd->key->xkbInfo->state;
+            if (stuff->affectModLocks) {
+                newState->locked_mods &= ~stuff->affectModLocks;
+                newState->locked_mods |= (stuff->affectModLocks & stuff->modLocks);
+            }
+            if (status == Success && stuff->lockGroup)
+                newState->locked_group = stuff->groupLock;
+            if (status == Success && stuff->affectModLatches)
+                status = XkbLatchModifiers(tmpd, stuff->affectModLatches,
+                                           stuff->modLatches);
+            if (status == Success && stuff->latchGroup)
+                status = XkbLatchGroup(tmp, stuff->groupLatch);
+
+            if (status != Success)
+                return status;
+
+            XkbComputeDerivedState(tmpd->key->xkbInfo);
+            tmpd->key->state = XkbStateFieldFromRec(newState);
+
+            changed = XkbStateChangedFlags(&oldState, newState);
+            if (changed) {
+                sn.keycode = 0;
+                sn.eventType = 0;
+                sn.requestMajor = XkbReqCode;
+                sn.requestMinor = X_kbLatchLockState;
+                sn.changed = changed;
+                XkbSendStateNotify(tmpd, &sn);
+                changed = XkbIndicatorsToUpdate(tmpd, changed, False);
+                if (changed) {
+                    XkbSetCauseXkbReq(&cause, X_kbLatchLockState, client);
+                    XkbUpdateIndicators(tmpd, changed, True, NULL, &cause);
+	        }
+            }
+        }
     }
+
     return client->noClientException;
 }
 
diff-tree ebf9b3bbbb04acb78cdf8a84e47a96755fbfe854 (from de63a469dcd0a8ae98554bca540ac0106cccf2a5)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Oct 6 14:17:59 2006 +0300

    xkb: update all core-sending keyboards on GetKeyboardByName
    Update the keymaps of all keyboards which send core events on
    GetKeyboardByName; still a few other procedures which need this treatment.

diff --git a/xkb/xkb.c b/xkb/xkb.c
index f892c43..23b9798 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5084,6 +5084,7 @@ int
 ProcXkbGetKbdByName(ClientPtr client)
 {
     DeviceIntPtr 		dev;
+    DeviceIntPtr                tmpd;
     XkbFileInfo			finfo;
     xkbGetKbdByNameReply 	rep;
     xkbGetMapReply		mrep;
@@ -5169,8 +5170,10 @@ ProcXkbGetKbdByName(ClientPtr client)
 	fneed|= XkmKeyNamesIndex|XkmTypesIndex;
 	fwant|= XkmIndicatorsIndex;
     }
+
+    /* We pass dev in here so we can get the old names out if needed. */
     rep.found = XkbDDXLoadKeymapByNames(dev,&names,fwant,fneed,&finfo,
-							mapFile,PATH_MAX);
+                                        mapFile,PATH_MAX);
     rep.newKeyboard= False;
     rep.pad1= rep.pad2= rep.pad3= rep.pad4= 0;
 
@@ -5382,6 +5385,34 @@ ProcXkbGetKbdByName(ClientPtr client)
 	    XkbFreeSrvLedInfo(old_sli);
 	}
 
+        if (dev == inputInfo.keyboard) {
+            for (tmpd = inputInfo.devices; tmpd; tmpd = tmpd->next) {
+                if (tmpd->key && tmpd->coreEvents) {
+                    memcpy(tmpd->key->modifierMap, xkb->map->modmap,
+                           xkb->max_key_code + 1);
+                    XkbCopyKeymap(dev->key->xkbInfo->desc,
+                                  tmpd->key->xkbInfo->desc, True);
+                    XkbUpdateCoreDescription(tmpd, True);
+
+	            if (tmpd->kbdfeed && tmpd->kbdfeed->xkb_sli) {
+                        XkbSrvLedInfoPtr old_sli;
+                        XkbSrvLedInfoPtr sli;
+                        old_sli = tmpd->kbdfeed->xkb_sli;
+                        tmpd->kbdfeed->xkb_sli = NULL;
+                        sli = XkbAllocSrvLedInfo(tmpd, tmpd->kbdfeed, NULL, 0);
+                        if (sli) {
+                            sli->explicitState = old_sli->explicitState;
+                            sli->effectiveState = old_sli->effectiveState;
+                        }
+                        tmpd->kbdfeed->xkb_sli = sli;
+                        XkbFreeSrvLedInfo(old_sli);
+                    }
+                }
+            }
+        }
+
+        /* this should be either a MN or an NKN, depending on whether or not
+         * the keycode range changed? */
 	nkn.deviceID= nkn.oldDeviceID= dev->id;
 	nkn.minKeyCode= finfo.xkb->min_key_code;
 	nkn.maxKeyCode= finfo.xkb->max_key_code;
diff-tree de63a469dcd0a8ae98554bca540ac0106cccf2a5 (from parents)
Merge: 9c7440bdf5a4ecd113e102004c804a2ba354c422 8382234a7f318057de66490299d63807cefb5201
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Oct 5 20:29:19 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree 9c7440bdf5a4ecd113e102004c804a2ba354c422 (from 3c98cebb6e954855528794fec46830f456cbdec1)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 2 20:58:33 2006 +0300

    xkb: remove the world's most staggeringly broken vendor workaround
    Certain versions of LynxOS needed to sleep up to five seconds for closing a
    pipe to actually, y'know, be useful.

diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 5795f8b..6e8f892 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -403,30 +403,6 @@ char tmpname[PATH_MAX];
 		strncpy(nameRtrn,keymap,nameRtrnLen);
 		nameRtrn[nameRtrnLen-1]= '\0';
 	    }
-#if defined(Lynx) && defined(__i386__) && defined(NEED_POPEN_WORKAROUND)
-	/* somehow popen/pclose is broken on LynxOS AT 2.3.0/2.4.0!
-	 * the problem usually shows up with XF86Setup
-	 * this hack waits at max 5 seconds after pclose() returns
-	 * for the output of the xkbcomp output file.
-	 * I didn't manage to get a patch in time for the 3.2 release
-	 */
-            {
-		int i;
-		char name[PATH_MAX];
-                if (XkbBaseDirectory!=NULL)
-		    sprintf(name,"%s/%s%s.xkm", XkbBaseDirectory
-			,xkm_output_dir, keymap);
-		else
-                    sprintf(name,"%s%s.xkm", xkm_output_dir, keymap);
-		for (i = 0; i < 10; i++) {
-	            if (access(name, 0) == 0) break;
-		    usleep(500000);
-		}
-#ifdef DEBUG
-		if (i) ErrorF(">>>> Waited %d times for %s\n", i, name);
-#endif
-	    }
-#endif
             if (buf != NULL)
                 xfree (buf);
 	    return True;
diff-tree 3c98cebb6e954855528794fec46830f456cbdec1 (from parents)
Merge: fa1ac94178cf976d4c8dae9a4dc8703303a62d4b 2cf1098436d6b4382d9ed3f6b88214d37bdd8ddb
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 2 02:18:17 2006 +0300

    Merge branch 'input-hotplug' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree fa1ac94178cf976d4c8dae9a4dc8703303a62d4b (from c31672e6aab168262bd7824a8082ecdf841fc3c0)
Author: Ivan Pascal <pascal at info.tsu.ru>
Date:   Mon Oct 2 02:17:14 2006 +0300

    xkb: fix wrapping when switching between groups
    Use XkbCharToInt as that's what we're doing.

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index ee0abbe..26ff35e 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -754,12 +754,12 @@ unsigned char	grp;
 
 
     grp= state->locked_group;
-    if (grp>=ctrls->num_groups || grp < 0)
-	state->locked_group= XkbAdjustGroup(grp,ctrls);
+    if (grp>=ctrls->num_groups)
+	state->locked_group= XkbAdjustGroup(XkbCharToInt(grp),ctrls);
 
     grp= state->locked_group+state->base_group+state->latched_group;
-    if (grp>=ctrls->num_groups || grp < 0)
-	 state->group= XkbAdjustGroup(grp,ctrls);
+    if (grp>=ctrls->num_groups)
+	 state->group= XkbAdjustGroup(XkbCharToInt(grp),ctrls);
     else state->group= grp;
     XkbComputeCompatState(xkbi);
     return;
diff-tree c31672e6aab168262bd7824a8082ecdf841fc3c0 (from 84eb2c0a06de60e88e14bb03fabe661d7cd8f1d3)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Oct 2 02:15:36 2006 +0300

    symlink-mesa.sh: expand *.{c,h}

diff --git a/GL/symlink-mesa.sh b/GL/symlink-mesa.sh
index 88dddfc..c14c683 100755
--- a/GL/symlink-mesa.sh
+++ b/GL/symlink-mesa.sh
@@ -62,7 +62,7 @@ symlink_mesa_glapi() {
     src_dir src/mesa/glapi
     dst_dir mesa/glapi
 
-    for src in $REAL_SRC_DIR/*.{c,h}; do
+    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
         action `basename $src`
     done
 }
@@ -71,7 +71,7 @@ symlink_mesa_main() {
     src_dir src/mesa/main
     dst_dir mesa/main
 
-    for src in $REAL_SRC_DIR/*.{c,h}; do
+    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
         action `basename $src`
     done
 }
@@ -80,7 +80,7 @@ symlink_mesa_math() {
     src_dir src/mesa/math
     dst_dir mesa/math
 
-    for src in $REAL_SRC_DIR/*.{c,h}; do
+    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
         action `basename $src`
     done
 }
@@ -89,7 +89,7 @@ symlink_mesa_ac() {
     src_dir src/mesa/array_cache
     dst_dir mesa/array_cache
 
-    for src in $REAL_SRC_DIR/*.{c,h}; do
+    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
         action `basename $src`
     done
 }
@@ -98,7 +98,7 @@ symlink_mesa_swrast() {
     src_dir src/mesa/swrast
     dst_dir mesa/swrast
 
-    for src in $REAL_SRC_DIR/*.{c,h}; do
+    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
         action `basename $src`
     done
 }
@@ -107,7 +107,7 @@ symlink_mesa_ss() {
     src_dir src/mesa/swrast_setup
     dst_dir mesa/swrast_setup
 
-    for src in $REAL_SRC_DIR/*.{c,h}; do
+    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
         action `basename $src`
     done
 }
@@ -116,7 +116,7 @@ symlink_mesa_tnl() {
     src_dir src/mesa/tnl
     dst_dir mesa/tnl
 
-    for src in $REAL_SRC_DIR/*.{c,h}; do
+    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
         action `basename $src`
     done
 }
@@ -125,7 +125,7 @@ symlink_mesa_shader() {
     src_dir src/mesa/shader
     dst_dir mesa/shader
 
-    for src in $REAL_SRC_DIR/*.{c,h}; do
+    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
         action `basename $src`
     done
 }
@@ -134,7 +134,7 @@ symlink_mesa_shader_grammar() {
     src_dir src/mesa/shader/grammar
     dst_dir mesa/shader/grammar
 
-    for src in $REAL_SRC_DIR/*.{c,h}; do
+    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
         action `basename $src`
     done
 }
@@ -143,7 +143,7 @@ symlink_mesa_shader_slang() {
     src_dir src/mesa/shader/slang
     dst_dir mesa/shader/slang
 
-    for src in $REAL_SRC_DIR/*.{c,h}; do
+    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
         action `basename $src`
     done
 }
@@ -152,7 +152,7 @@ symlink_mesa_shader_slang_library() {
     src_dir src/mesa/shader/slang/library
     dst_dir mesa/shader/slang/library
 
-    for src in $REAL_SRC_DIR/*.{c,h}; do
+    for src in $REAL_SRC_DIR/*.c $REAL_SRC_DIR/*.h; do
         action `basename $src`
     done
 }        
diff-tree 2cf1098436d6b4382d9ed3f6b88214d37bdd8ddb (from 518db35ca3f569e7cb95dbddeddb93f3691de498)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Sep 30 17:05:46 2006 +0300

    dix/events, mi/eq: remove utterly ridiculous debugging
    Remove debugging which can cause long-lived Xorg logs to grow well above 1GB
    if built with --enable-debug.

diff --git a/dix/events.c b/dix/events.c
index 34ee9fb..c95a942 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -211,9 +211,6 @@ _X_EXPORT CallbackListPtr DeviceEventCal
 Mask DontPropagateMasks[DNPMCOUNT];
 static int DontPropagateRefCnts[DNPMCOUNT];
 
-#ifdef DEBUG
-static int debug_events = 0;
-#endif
 _X_EXPORT InputInfo inputInfo;
 
 static struct {
@@ -1536,9 +1533,8 @@ TryClientEvents (ClientPtr client, xEven
     int i;
     int type;
 
-#ifdef DEBUG
-    if (debug_events) ErrorF(
-	"Event([%d, %d], mask=0x%x), client=%d",
+#ifdef DEBUG_EVENTS
+    ErrorF("Event([%d, %d], mask=0x%x), client=%d",
 	pEvents->u.u.type, pEvents->u.u.detail, mask, client->index);
 #endif
     if ((client) && (client != serverClient) && (!client->clientGone) &&
@@ -1554,9 +1550,9 @@ TryClientEvents (ClientPtr client, xEven
 		if (WID(inputInfo.pointer->valuator->motionHintWindow) ==
 		    pEvents->u.keyButtonPointer.event)
 		{
-#ifdef DEBUG
-		    if (debug_events) ErrorF("\n");
-	    fprintf(stderr,"motionHintWindow == keyButtonPointer.event\n");
+#ifdef DEBUG_EVENTS
+		    ErrorF("\n");
+	    ErrorF("motionHintWindow == keyButtonPointer.event\n");
 #endif
 		    return 1; /* don't send, but pretend we did */
 		}
@@ -1594,15 +1590,15 @@ TryClientEvents (ClientPtr client, xEven
 	}
 
 	WriteEventsToClient(client, count, pEvents);
-#ifdef DEBUG
-	if (debug_events) ErrorF(  " delivered\n");
+#ifdef DEBUG_EVENTS
+	ErrorF(  " delivered\n");
 #endif
 	return 1;
     }
     else
     {
-#ifdef DEBUG
-	if (debug_events) ErrorF("\n");
+#ifdef DEBUG_EVENTS
+	ErrorF("\n");
 #endif
 	return 0;
     }
@@ -2782,8 +2778,7 @@ drawable.id:0;
 #endif
 
 #ifdef DEBUG
-    if ((xkbDebugFlags&0x4)&&
-	((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
+    if (((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
 	ErrorF("CoreProcessKbdEvent: Key %d %s\n",key,
 			(xE->u.u.type==KeyPress?"down":"up"));
     }
@@ -2869,8 +2864,7 @@ FixKeyState (register xEvent *xE, regist
     kptr = &keyc->down[key >> 3];
     bit = 1 << (key & 7);
 #ifdef DEBUG
-    if ((xkbDebugFlags&0x4)&&
-	((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
+    if (((xE->u.u.type==KeyPress)||(xE->u.u.type==KeyRelease))) {
 	ErrorF("FixKeyState: Key %d %s\n",key,
 			(xE->u.u.type==KeyPress?"down":"up"));
     }
@@ -4753,9 +4747,6 @@ int GetKeyboardValuatorEvents(xEvent *ev
             }
             first_valuator += 6;
         }
-#ifdef DEBUG
-        ErrorF("GKVE: DV event with %d valuators\n", xv->num_valuators);
-#endif
     }
 
     if (pDev->coreEvents) {
@@ -4793,10 +4784,6 @@ int GetKeyboardValuatorEvents(xEvent *ev
         }
     }
 
-#ifdef DEBUG
-    ErrorF("GKVE: putting out %d events with detail %d\n", numEvents, key_code);
-#endif
-
     return numEvents;
 }
 
@@ -4882,12 +4869,6 @@ GetPointerEvents(xEvent *events, DeviceI
     if (!pDev->button || (pDev->coreEvents && !(cp->button || !cp->valuator)))
         return 0;
 
-#ifdef DEBUG
-    ErrorF("GPE: called with device %d, type %d\n", pDev->id, type);
-    ErrorF("GPE: relative %s, accelerate %s\n", flags & POINTER_RELATIVE ? "yes" : "no",
-           flags & POINTER_ACCELERATE ? "yes" : "no");
-#endif
-
     if (pDev->coreEvents)
         numEvents = 2;
     else
@@ -4967,15 +4948,7 @@ GetPointerEvents(xEvent *events, DeviceI
         kbp->root_y = axes->max_value;
 
     if (pDev->coreEvents) {
-#ifdef DEBUG
-        ErrorF("warping core lastx from %d to %d\n", cp->valuator->lastx, kbp->root_x);
-        ErrorF("x value given was %d\n", valuators[0]);
-#endif
         cp->valuator->lastx = kbp->root_x;
-#ifdef DEBUG
-        ErrorF("warping core lasty from %d to %d\n", cp->valuator->lasty, kbp->root_y);
-        ErrorF("y value given was %d\n", valuators[1]);
-#endif
         cp->valuator->lasty = kbp->root_y;
     }
     pDev->valuator->lastx = kbp->root_x;
@@ -4983,18 +4956,12 @@ GetPointerEvents(xEvent *events, DeviceI
 
     if (type == MotionNotify) {
         kbp->type = DeviceMotionNotify;
-#ifdef DEBUG
-        ErrorF("GPE: motion at %d, %d\n", kbp->root_x, kbp->root_y);
-#endif
     }
     else {
         if (type == ButtonPress)
             kbp->type = DeviceButtonPress;
         else if (type == ButtonRelease)
             kbp->type = DeviceButtonRelease;
-#ifdef DEBUG
-        ErrorF("GPE: detail is %d\n", buttons);
-#endif
         kbp->detail = pDev->button->map[buttons];
     }
 
@@ -5028,29 +4995,17 @@ GetPointerEvents(xEvent *events, DeviceI
             }
             first_valuator += 6;
         }
-#ifdef DEBUG
-        ErrorF("GPE: DV event with %d valuators\n", xv->num_valuators);
-#endif
     }
 
     if (pDev->coreEvents) {
         events++;
         events->u.u.type = type;
-#ifdef DEBUG
-        ErrorF("GPE: core type is %d\n", type);
-#endif
         events->u.keyButtonPointer.time = ms;
         events->u.keyButtonPointer.rootX = kbp->root_x;
         events->u.keyButtonPointer.rootY = kbp->root_y;
         cp->valuator->lastx = kbp->root_x;
         cp->valuator->lasty = kbp->root_y;
-#ifdef DEBUG
-        ErrorF("GPE: core co-ords at %d, %d\n", kbp->root_x, kbp->root_y);
-#endif
         if (type == ButtonPress || type == ButtonRelease) {
-#ifdef DEBUG
-            ErrorF("GPE: core detail is %d\n", buttons);
-#endif
             /* Core buttons remapping shouldn't be transitive. */
             events->u.u.detail = pDev->button->map[buttons];
         }
diff --git a/mi/mieq.c b/mi/mieq.c
index aec2371..63b900c 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -103,11 +103,6 @@ mieqEnqueue (xEvent *e)
     deviceKeyButtonPointer *lastkbp = (deviceKeyButtonPointer *)
                                       &laste->event[0];
 
-#ifdef DEBUG
-    ErrorF("mieqEnqueue: slamming an event on to the queue from %d\n", kbp->deviceid & DEVICE_BITS);
-    ErrorF("    type %d, detail %d\n", e->u.u.type, e->u.u.detail);
-#endif
-
     if (e->u.u.type == MotionNotify) {
         miPointerAbsoluteCursor(e->u.keyButtonPointer.rootX,
                                 e->u.keyButtonPointer.rootY,
@@ -178,15 +173,9 @@ mieqEnqueue (xEvent *e)
      */
     if (e->u.keyButtonPointer.time < miEventQueue.lastEventTime &&
 	miEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
-    {
-#ifdef DEBUG
-        ErrorF("mieq: rewinding event time from %d to %d\n",
-               miEventQueue.lastEventTime,
-               miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time);
-#endif
 	miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time =
 	    miEventQueue.lastEventTime;
-    }
+
     miEventQueue.lastEventTime =
 	miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time;
     miEventQueue.events[oldtail].pScreen = miEventQueue.pEnqueueScreen;
diff-tree 518db35ca3f569e7cb95dbddeddb93f3691de498 (from parents)
Merge: 5d99e05f05a42a82a9f02844df9bfebaa673759d 84eb2c0a06de60e88e14bb03fabe661d7cd8f1d3
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Sep 29 00:35:21 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree 5d99e05f05a42a82a9f02844df9bfebaa673759d (from parents)
Merge: ad631afcf3fbc74024cddaaacd05d38addc047a2 58933757862c458e2da39bd464e50d9c0e41b313
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Sep 29 00:35:07 2006 +0300

    Merge branch 'input-hotplug' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree ad631afcf3fbc74024cddaaacd05d38addc047a2 (from a5d639cd87f30f9b3d765352d27253940f33b2b7)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Sep 29 00:34:23 2006 +0300

    make core keyboard/pointer map functions act on all core-sending devices
    Make Set{Keyboard,Modifier,Pointer}Mapping act on all devices which send core
    events.
    Change LegalModifier to accept a DeviceIntPtr.

diff --git a/dix/devices.c b/dix/devices.c
index 60c2d29..74474c9 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1139,112 +1139,102 @@ AllModifierKeysAreUp(dev, map1, per1, ma
     return TRUE;
 }
 
+static int
+DoSetModifierMapping(ClientPtr client, KeyCode *inputMap,
+                     int numKeyPerModifier)
+{
+    KeyClassPtr keyc = NULL;
+    DeviceIntPtr pDev = NULL;
+    KeyCode *map = NULL;
+    int i = 0, inputMapLen = numKeyPerModifier * 8;
+
+    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
+        if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
+            for (i = 0; i < inputMapLen; i++) {
+                /* Check that all the new modifiers fall within the advertised
+                 * keycode range, and are okay with the DDX. */
+                if (inputMap[i] && ((inputMap[i] < pDev->key->curKeySyms.minKeyCode ||
+                                    inputMap[i] > pDev->key->curKeySyms.maxKeyCode) ||
+                                    !LegalModifier(inputMap[i], pDev))) {
+                    client->errorValue = inputMap[i];
+                    return BadValue;
+                }
+            }
+#ifdef XCSECURITY
+            if (!SecurityCheckDeviceAccess(client, pDev, TRUE))
+                return BadAccess;
+#endif 
+            /* None of the modifiers (old or new) may be down while we change
+             * the map. */
+            if (!AllModifierKeysAreUp(pDev, pDev->key->modifierKeyMap,
+                                      pDev->key->maxKeysPerModifier,
+                                      inputMap, numKeyPerModifier) ||
+                !AllModifierKeysAreUp(pDev, inputMap, numKeyPerModifier,
+                                      pDev->key->modifierKeyMap,
+                                      pDev->key->maxKeysPerModifier)) {
+                return MappingBusy;
+            }
+        }
+    }
+
+    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
+        if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
+            bzero(pDev->key->modifierMap, MAP_LENGTH);
+
+            /* Annoyingly, we lack a modifierKeyMap size, so we have to just free
+             * and re-alloc it every time. */
+            if (pDev->key->modifierKeyMap)
+                xfree(pDev->key->modifierKeyMap);
+
+            if (inputMapLen) {
+                pDev->key->modifierKeyMap = (KeyCode *) xalloc(inputMapLen);
+                if (!pDev->key->modifierKeyMap)
+                    return BadAlloc;
+
+                memcpy(pDev->key->modifierKeyMap, inputMap, inputMapLen);
+                pDev->key->maxKeysPerModifier = numKeyPerModifier;
+
+                for (i = 0; i < inputMapLen; i++) {
+                    if (inputMap[i]) {
+                        pDev->key->modifierMap[inputMap[i]] |=
+                            (1 << (((unsigned int)i) / numKeyPerModifier));
+                    }
+                }
+            }
+            else {
+                pDev->key->modifierKeyMap = NULL;
+            }
+        }
+    }
+
+    return Success;
+}
+
 int 
 ProcSetModifierMapping(ClientPtr client)
 {
     xSetModifierMappingReply rep;
     REQUEST(xSetModifierMappingReq);
-    KeyCode *inputMap;
-    int inputMapLen;
     register int i;
     DeviceIntPtr keybd = inputInfo.keyboard;
-    register KeyClassPtr keyc = keybd->key;
     
     REQUEST_AT_LEAST_SIZE(xSetModifierMappingReq);
 
-    if (client->req_len != ((stuff->numKeyPerModifier<<1) +
-			    (sizeof (xSetModifierMappingReq)>>2)))
+    if (client->req_len != ((stuff->numKeyPerModifier << 1) +
+			    (sizeof (xSetModifierMappingReq) >> 2)))
 	return BadLength;
 
-    inputMapLen = 8*stuff->numKeyPerModifier;
-    inputMap = (KeyCode *)&stuff[1];
-
-    /*
-     *	Now enforce the restriction that "all of the non-zero keycodes must be
-     *	in the range specified by min-keycode and max-keycode in the
-     *	connection setup (else a Value error)"
-     */
-    i = inputMapLen;
-    while (i--)
-    {
-	if (inputMap[i]
-	    && (inputMap[i] < keyc->curKeySyms.minKeyCode
-		|| inputMap[i] > keyc->curKeySyms.maxKeyCode))
-	{
-	    client->errorValue = inputMap[i];
-	    return BadValue;
-	}
-    }
-
-#ifdef XCSECURITY
-    if (!SecurityCheckDeviceAccess(client, keybd, TRUE))
-	return BadAccess;
-#endif 
-
     rep.type = X_Reply;
     rep.length = 0;
     rep.sequenceNumber = client->sequence;
-    rep.success = MappingSuccess;
 
-    /*
-     *	Now enforce the restriction that none of the old or new
-     *	modifier keys may be down while we change the mapping,  and
-     *	that the DDX layer likes the choice.
-     */
-    if (!AllModifierKeysAreUp(keybd, keyc->modifierKeyMap,
-			      (int)keyc->maxKeysPerModifier,
-			      inputMap, (int)stuff->numKeyPerModifier)
-	    ||
-	!AllModifierKeysAreUp(keybd, inputMap, (int)stuff->numKeyPerModifier,
-			      keyc->modifierKeyMap,
-			      (int)keyc->maxKeysPerModifier))
-    {
-	rep.success = MappingBusy;
-    }
-    else
-    {
-	for (i = 0; i < inputMapLen; i++)
-	{
-	    if (inputMap[i] && !LegalModifier(inputMap[i], (DevicePtr)keybd))
-	    {
-		rep.success = MappingFailed;
-		break;
-	    }
-	}
-    }
-
-    if (rep.success == MappingSuccess)
-    {
-	KeyCode *map;
-	/*
-	 *	Now build the keyboard's modifier bitmap from the
-	 *	list of keycodes.
-	 */
-	map = (KeyCode *)xalloc(inputMapLen);
-	if (!map && inputMapLen)
-	    return BadAlloc;
-	if (keyc->modifierKeyMap)
-	    xfree(keyc->modifierKeyMap);
-	keyc->modifierKeyMap = map;
-	memmove((char *)map, (char *)inputMap, inputMapLen);
-
-	keyc->maxKeysPerModifier = stuff->numKeyPerModifier;
-	for (i = 0; i < MAP_LENGTH; i++)
-	    keyc->modifierMap[i] = 0;
-	for (i = 0; i < inputMapLen; i++)
-	{
-	    if (inputMap[i])
-		keyc->modifierMap[inputMap[i]] |=
-		    (1<<(((unsigned int)i)/keyc->maxKeysPerModifier));
-	}
-    }
-
-    if (rep.success == MappingSuccess)
-        SendMappingNotify(MappingModifier, 0, 0, client);
+    rep.success = DoSetModifierMapping(client, (KeyCode *)&stuff[1],
+                                       stuff->numKeyPerModifier);
 
+    /* FIXME: Send mapping notifies for all the extended devices as well. */
+    SendMappingNotify(MappingModifier, 0, 0, client);
     WriteReplyToClient(client, sizeof(xSetModifierMappingReply), &rep);
-
-    return(client->noClientException);
+    return client->noClientException;
 }
 
 int
@@ -1274,40 +1264,80 @@ ProcChangeKeyboardMapping(ClientPtr clie
     REQUEST(xChangeKeyboardMappingReq);
     unsigned len;
     KeySymsRec keysyms;
-    register KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms;
+    KeySymsPtr curKeySyms = &inputInfo.keyboard->key->curKeySyms;
+    DeviceIntPtr pDev = NULL;
     REQUEST_AT_LEAST_SIZE(xChangeKeyboardMappingReq);
 
     len = client->req_len - (sizeof(xChangeKeyboardMappingReq) >> 2);  
     if (len != (stuff->keyCodes * stuff->keySymsPerKeyCode))
             return BadLength;
+
     if ((stuff->firstKeyCode < curKeySyms->minKeyCode) ||
-	(stuff->firstKeyCode > curKeySyms->maxKeyCode))
-    {
+	(stuff->firstKeyCode > curKeySyms->maxKeyCode)) {
 	    client->errorValue = stuff->firstKeyCode;
 	    return BadValue;
+
     }
-    if ( ((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) >
-	  curKeySyms->maxKeyCode) ||
-	(stuff->keySymsPerKeyCode == 0))
-    {
+    if (((unsigned)(stuff->firstKeyCode + stuff->keyCodes - 1) >
+        curKeySyms->maxKeyCode) || (stuff->keySymsPerKeyCode == 0)) {
 	    client->errorValue = stuff->keySymsPerKeyCode;
 	    return BadValue;
     }
+
 #ifdef XCSECURITY
-    if (!SecurityCheckDeviceAccess(client, inputInfo.keyboard,
-				   TRUE))
-	return BadAccess;
+    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
+        if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
+            if (!SecurityCheckDeviceAccess(client, pDev, TRUE))
+                return BadAccess;
+        }
+    }
 #endif 
+
     keysyms.minKeyCode = stuff->firstKeyCode;
     keysyms.maxKeyCode = stuff->firstKeyCode + stuff->keyCodes - 1;
     keysyms.mapWidth = stuff->keySymsPerKeyCode;
     keysyms.map = (KeySym *)&stuff[1];
-    if (!SetKeySymsMap(curKeySyms, &keysyms))
-	return BadAlloc;
+    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
+        if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key) {
+            if (!SetKeySymsMap(&pDev->key->curKeySyms, &keysyms))
+                return BadAlloc;
+        }
+    }
+
+    /* FIXME: Send mapping notifies for all the extended devices as well. */
     SendMappingNotify(MappingKeyboard, stuff->firstKeyCode, stuff->keyCodes,
-									client);
+                      client);
     return client->noClientException;
+}
+
+static int
+DoSetPointerMapping(DeviceIntPtr device, BYTE *map, int n)
+{
+    int i = 0;
+    DeviceIntPtr dev = NULL;
+
+    if (!device || !device->button)
+        return BadDevice;
+
+    for (dev = inputInfo.devices; dev; dev = dev->next) {
+        if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) {
+            for (i = 0; i < n; i++) {
+                if ((device->button->map[i + 1] != map[i]) &&
+                    BitIsOn(device->button->down, i + 1)) {
+                    return MappingBusy;
+                }
+            }
+        }
+    }
+
+    for (dev = inputInfo.devices; dev; dev = dev->next) {
+        if ((dev->coreEvents || dev == inputInfo.pointer) && dev->button) {
+            for (i = 0; i < n; i++)
+                dev->button->map[i + 1] = map[i];
+        }
+    }
 
+    return Success;
 }
 
 int
@@ -1315,9 +1345,9 @@ ProcSetPointerMapping(ClientPtr client)
 {
     REQUEST(xSetPointerMappingReq);
     BYTE *map;
+    int ret;
     xSetPointerMappingReply rep;
-    register unsigned int i;
-    DeviceIntPtr mouse = inputInfo.pointer;
+    unsigned int i;
 
     REQUEST_AT_LEAST_SIZE(xSetPointerMappingReq);
     if (client->req_len != (sizeof(xSetPointerMappingReq)+stuff->nElts+3) >> 2)
@@ -1327,23 +1357,24 @@ ProcSetPointerMapping(ClientPtr client)
     rep.sequenceNumber = client->sequence;
     rep.success = MappingSuccess;
     map = (BYTE *)&stuff[1];
-    if (stuff->nElts != mouse->button->numButtons)
-    {
+    
+    /* So we're bounded here by the number of core buttons.  This check
+     * probably wants disabling through XFixes. */
+    if (stuff->nElts != inputInfo.pointer->button->numButtons) {
 	client->errorValue = stuff->nElts;
 	return BadValue;
     }
     if (BadDeviceMap(&map[0], (int)stuff->nElts, 1, 255, &client->errorValue))
 	return BadValue;
-    for (i=0; i < stuff->nElts; i++)
-	if ((mouse->button->map[i + 1] != map[i]) &&
-	    BitIsOn(mouse->button->down, i + 1))
-	{
-    	    rep.success = MappingBusy;
-	    WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
-            return Success;
-	}
-    for (i = 0; i < stuff->nElts; i++)
-	mouse->button->map[i + 1] = map[i];
+
+    ret = DoSetPointerMapping(inputInfo.pointer, map, stuff->nElts);
+    if (ret != Success) {
+        rep.success = ret;
+        WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
+        return Success;
+    }
+
+    /* FIXME: Send mapping notifies for all the extended devices as well. */
     SendMappingNotify(MappingPointer, 0, 0, client);
     WriteReplyToClient(client, sizeof(xSetPointerMappingReply), &rep);
     return Success;
@@ -1359,14 +1390,12 @@ ProcGetKeyboardMapping(ClientPtr client)
     REQUEST_SIZE_MATCH(xGetKeyboardMappingReq);
 
     if ((stuff->firstKeyCode < curKeySyms->minKeyCode) ||
-        (stuff->firstKeyCode > curKeySyms->maxKeyCode))
-    {
+        (stuff->firstKeyCode > curKeySyms->maxKeyCode)) {
 	client->errorValue = stuff->firstKeyCode;
 	return BadValue;
     }
     if (stuff->firstKeyCode + stuff->count >
-	(unsigned)(curKeySyms->maxKeyCode + 1))
-    {
+	(unsigned)(curKeySyms->maxKeyCode + 1)) {
 	client->errorValue = stuff->count;
         return BadValue;
     }
@@ -1423,47 +1452,31 @@ Ones(unsigned long mask)             /* 
     return (((y + (y >> 3)) & 030707070707) % 077);
 }
 
-int
-ProcChangeKeyboardControl (ClientPtr client)
+static int
+DoChangeKeyboardControl (ClientPtr client, DeviceIntPtr keybd, XID *vlist,
+                         BITS32 vmask)
 {
 #define DO_ALL    (-1)
     KeybdCtrl ctrl;
-    DeviceIntPtr keybd = inputInfo.keyboard;
-    XID *vlist;
     int t;
     int led = DO_ALL;
     int key = DO_ALL;
-    BITS32 vmask, index2;
-    int mask, i;
-    REQUEST(xChangeKeyboardControlReq);
-
-    REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
+    BITS32 index2;
+    int mask = vmask, i;
+    DeviceIntPtr dev = NULL;
 
-    if (!keybd->kbdfeed->CtrlProc)
-        return BadDevice;
-    
-    vmask = stuff->mask;
-    if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask))
-	return BadLength;
-#ifdef XCSECURITY
-    if (!SecurityCheckDeviceAccess(client, keybd, TRUE))
-	return BadAccess;
-#endif 
-    vlist = (XID *)&stuff[1];		/* first word of values */
     ctrl = keybd->kbdfeed->ctrl;
-    while (vmask)
-    {
+    while (vmask) {
 	index2 = (BITS32) lowbit (vmask);
 	vmask &= ~index2;
-	switch (index2)
-	{
+	switch (index2) {
 	case KBKeyClickPercent: 
 	    t = (INT8)*vlist;
 	    vlist++;
-	    if (t == -1)
+	    if (t == -1) {
 		t = defaultKeyboardControl.click;
-	    else if (t < 0 || t > 100)
-	    {
+            }
+	    else if (t < 0 || t > 100) {
 		client->errorValue = t;
 		return BadValue;
 	    }
@@ -1472,10 +1485,10 @@ ProcChangeKeyboardControl (ClientPtr cli
 	case KBBellPercent:
 	    t = (INT8)*vlist;
 	    vlist++;
-	    if (t == -1)
+	    if (t == -1) {
 		t = defaultKeyboardControl.bell;
-	    else if (t < 0 || t > 100)
-	    {
+            }
+	    else if (t < 0 || t > 100) {
 		client->errorValue = t;
 		return BadValue;
 	    }
@@ -1484,10 +1497,10 @@ ProcChangeKeyboardControl (ClientPtr cli
 	case KBBellPitch:
 	    t = (INT16)*vlist;
 	    vlist++;
-	    if (t == -1)
+	    if (t == -1) {
 		t = defaultKeyboardControl.bell_pitch;
-	    else if (t < 0)
-	    {
+            }
+	    else if (t < 0) {
 		client->errorValue = t;
 		return BadValue;
 	    }
@@ -1498,8 +1511,7 @@ ProcChangeKeyboardControl (ClientPtr cli
 	    vlist++;
 	    if (t == -1)
 		t = defaultKeyboardControl.bell_duration;
-	    else if (t < 0)
-	    {
+	    else if (t < 0) {
 		client->errorValue = t;
 		return BadValue;
 	    }
@@ -1508,56 +1520,51 @@ ProcChangeKeyboardControl (ClientPtr cli
 	case KBLed:
 	    led = (CARD8)*vlist;
 	    vlist++;
-	    if (led < 1 || led > 32)
-	    {
+	    if (led < 1 || led > 32) {
 		client->errorValue = led;
 		return BadValue;
 	    }
-	    if (!(stuff->mask & KBLedMode))
+	    if (!(mask & KBLedMode))
 		return BadMatch;
 	    break;
 	case KBLedMode:
 	    t = (CARD8)*vlist;
 	    vlist++;
-	    if (t == LedModeOff)
-	    {
+	    if (t == LedModeOff) {
 		if (led == DO_ALL)
 		    ctrl.leds = 0x0;
 		else
 		    ctrl.leds &= ~(((Leds)(1)) << (led - 1));
 	    }
-	    else if (t == LedModeOn)
-	    {
+	    else if (t == LedModeOn) {
 		if (led == DO_ALL)
 		    ctrl.leds = ~0L;
 		else
 		    ctrl.leds |= (((Leds)(1)) << (led - 1));
 	    }
-	    else
-	    {
+	    else {
 		client->errorValue = t;
 		return BadValue;
 	    }
 #ifdef XKB
-	    if (!noXkbExtension) {
-		XkbEventCauseRec	cause;
-		XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client);
-		XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))),
+            if (!noXkbExtension) {
+                XkbEventCauseRec cause;
+                XkbSetCauseCoreReq(&cause,X_ChangeKeyboardControl,client);
+                XkbSetIndicators(keybd,((led == DO_ALL) ? ~0L : (1L<<(led-1))),
 				 			ctrl.leds, &cause);
-		ctrl.leds = keybd->kbdfeed->ctrl.leds;
-	    }
+                ctrl.leds = keybd->kbdfeed->ctrl.leds;
+            }
 #endif
 	    break;
 	case KBKey:
 	    key = (KeyCode)*vlist;
 	    vlist++;
 	    if ((KeyCode)key < inputInfo.keyboard->key->curKeySyms.minKeyCode ||
-		(KeyCode)key > inputInfo.keyboard->key->curKeySyms.maxKeyCode)
-	    {
+		(KeyCode)key > inputInfo.keyboard->key->curKeySyms.maxKeyCode) {
 		client->errorValue = key;
 		return BadValue;
 	    }
-	    if (!(stuff->mask & KBAutoRepeatMode))
+	    if (!(mask & KBAutoRepeatMode))
 		return BadMatch;
 	    break;
 	case KBAutoRepeatMode:
@@ -1566,25 +1573,22 @@ ProcChangeKeyboardControl (ClientPtr cli
 	    t = (CARD8)*vlist;
 	    vlist++;
 #ifdef XKB
-	    if (!noXkbExtension && key != DO_ALL)
-		XkbDisableComputedAutoRepeats(keybd,key);
+            if (!noXkbExtension && key != DO_ALL)
+                XkbDisableComputedAutoRepeats(keybd,key);
 #endif
-	    if (t == AutoRepeatModeOff)
-	    {
+	    if (t == AutoRepeatModeOff) {
 		if (key == DO_ALL)
 		    ctrl.autoRepeat = FALSE;
 		else
 		    ctrl.autoRepeats[i] &= ~mask;
 	    }
-	    else if (t == AutoRepeatModeOn)
-	    {
+	    else if (t == AutoRepeatModeOn) {
 		if (key == DO_ALL)
 		    ctrl.autoRepeat = TRUE;
 		else
 		    ctrl.autoRepeats[i] |= mask;
 	    }
-	    else if (t == AutoRepeatModeDefault)
-	    {
+	    else if (t == AutoRepeatModeDefault) {
 		if (key == DO_ALL)
 		    ctrl.autoRepeat = defaultKeyboardControl.autoRepeat;
 		else
@@ -1592,32 +1596,72 @@ ProcChangeKeyboardControl (ClientPtr cli
 			    (ctrl.autoRepeats[i] & ~mask) |
 			    (defaultKeyboardControl.autoRepeats[i] & mask);
 	    }
-	    else
-	    {
+	    else {
 		client->errorValue = t;
 		return BadValue;
 	    }
 	    break;
 	default:
-	    client->errorValue = stuff->mask;
+	    client->errorValue = mask;
 	    return BadValue;
 	}
     }
     keybd->kbdfeed->ctrl = ctrl;
+
 #ifdef XKB
     /* The XKB RepeatKeys control and core protocol global autorepeat */
     /* value are linked	*/
-    if (!noXkbExtension) {
-	XkbSetRepeatKeys(keybd,key,keybd->kbdfeed->ctrl.autoRepeat);
-    }
+    if (!noXkbExtension)
+        XkbSetRepeatKeys(keybd, key, keybd->kbdfeed->ctrl.autoRepeat);
     else
 #endif
-    (*keybd->kbdfeed->CtrlProc)(keybd, &keybd->kbdfeed->ctrl);
+        (*keybd->kbdfeed->CtrlProc)(keybd, &keybd->kbdfeed->ctrl);
+
     return Success;
+
 #undef DO_ALL
 } 
 
 int
+ProcChangeKeyboardControl (ClientPtr client)
+{
+    XID *vlist;
+    BITS32 vmask;
+    int ret = Success, error = Success;
+    DeviceIntPtr pDev = NULL;
+    REQUEST(xChangeKeyboardControlReq);
+
+    REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
+
+    vmask = stuff->mask;
+    vlist = (XID *)&stuff[1];
+
+    if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask))
+	return BadLength;
+
+#ifdef XCSECURITY
+    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
+        if ((pDev->coreEvents || pDev == inputInfo.keyboard) &&
+            pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
+            if (!SecurityCheckDeviceAccess(client, pDev, TRUE))
+                return BadAccess;
+        }
+    }
+#endif 
+
+    for (pDev = inputInfo.devices; pDev; pDev = pDev->next) {
+        if ((pDev->coreEvents || pDev == inputInfo.keyboard) &&
+            pDev->kbdfeed && pDev->kbdfeed->CtrlProc) {
+            ret = DoChangeKeyboardControl(client, pDev, vlist, vmask);
+            if (ret != Success)
+                error = ret;
+        }
+    }
+
+    return error;
+}
+
+int
 ProcGetKeyboardControl (ClientPtr client)
 {
     int i;
@@ -1652,24 +1696,31 @@ ProcBell(ClientPtr client)
     if (!keybd->kbdfeed->BellProc)
         return BadDevice;
     
-    if (stuff->percent < -100 || stuff->percent > 100)
-    {
+    if (stuff->percent < -100 || stuff->percent > 100) {
 	client->errorValue = stuff->percent;
 	return BadValue;
     }
+
     newpercent = (base * stuff->percent) / 100;
     if (stuff->percent < 0)
         newpercent = base + newpercent;
     else
     	newpercent = base - newpercent + stuff->percent;
+
+    for (keybd = inputInfo.devices; keybd; keybd = keybd->next) {
+        if ((keybd->coreEvents || keybd == inputInfo.keyboard) &&
+            keybd->kbdfeed && keybd->kbdfeed->BellProc) {
 #ifdef XKB
-    if (!noXkbExtension)
-	XkbHandleBell(FALSE,FALSE, keybd, newpercent, &keybd->kbdfeed->ctrl, 0, 
-		      None, NULL, client);
-	else
+            if (!noXkbExtension)
+                XkbHandleBell(FALSE, FALSE, keybd, newpercent,
+                              &keybd->kbdfeed->ctrl, 0, None, NULL, client);
+            else
 #endif
-    (*keybd->kbdfeed->BellProc)(newpercent, keybd,
-                                (pointer) &keybd->kbdfeed->ctrl, 0);
+                (*keybd->kbdfeed->BellProc)(newpercent, keybd,
+                                            &keybd->kbdfeed->ctrl, 0);
+        }
+    }
+
     return Success;
 } 
 
@@ -1686,48 +1737,59 @@ ProcChangePointerControl(ClientPtr clien
         return BadDevice;
     
     ctrl = mouse->ptrfeed->ctrl;
-    if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse))
-    {
+    if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse)) {
 	client->errorValue = stuff->doAccel;
 	return(BadValue);
     }
-    if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse))
-    {
+    if ((stuff->doThresh != xTrue) && (stuff->doThresh != xFalse)) {
 	client->errorValue = stuff->doThresh;
 	return(BadValue);
     }
-    if (stuff->doAccel)
-    {
-	if (stuff->accelNum == -1)
+    if (stuff->doAccel) {
+	if (stuff->accelNum == -1) {
 	    ctrl.num = defaultPointerControl.num;
-	else if (stuff->accelNum < 0)
-	{
+        }
+	else if (stuff->accelNum < 0) {
 	    client->errorValue = stuff->accelNum;
 	    return BadValue;
 	}
-	else ctrl.num = stuff->accelNum;
-	if (stuff->accelDenum == -1)
+	else {
+            ctrl.num = stuff->accelNum;
+        }
+
+	if (stuff->accelDenum == -1) {
 	    ctrl.den = defaultPointerControl.den;
-	else if (stuff->accelDenum <= 0)
-	{
+        }
+	else if (stuff->accelDenum <= 0) {
 	    client->errorValue = stuff->accelDenum;
 	    return BadValue;
 	}
-	else ctrl.den = stuff->accelDenum;
+	else {
+            ctrl.den = stuff->accelDenum;
+        }
     }
-    if (stuff->doThresh)
-    {
-	if (stuff->threshold == -1)
+    if (stuff->doThresh) {
+	if (stuff->threshold == -1) {
 	    ctrl.threshold = defaultPointerControl.threshold;
-	else if (stuff->threshold < 0)
-	{
+        }
+	else if (stuff->threshold < 0) {
 	    client->errorValue = stuff->threshold;
 	    return BadValue;
 	}
-	else ctrl.threshold = stuff->threshold;
+	else {
+            ctrl.threshold = stuff->threshold;
+        }
     }
-    mouse->ptrfeed->ctrl = ctrl;
-    (*mouse->ptrfeed->CtrlProc)(mouse, &mouse->ptrfeed->ctrl);
+
+
+    for (mouse = inputInfo.devices; mouse; mouse = mouse->next) {
+        if ((mouse->coreEvents || mouse == inputInfo.pointer) &&
+            mouse->ptrfeed && mouse->ptrfeed->CtrlProc) {
+            mouse->ptrfeed->ctrl = ctrl;
+            (*mouse->ptrfeed->CtrlProc)(mouse, &mouse->ptrfeed->ctrl);
+        }
+    }
+
     return Success;
 } 
 
diff --git a/hw/darwin/darwinKeyboard.c b/hw/darwin/darwinKeyboard.c
index c148d96..1cc49fe 100644
--- a/hw/darwin/darwinKeyboard.c
+++ b/hw/darwin/darwinKeyboard.c
@@ -1020,7 +1020,7 @@ int DarwinModifierStringToNXKey(const ch
  *      This allows the ddx layer to prevent some keys from being remapped
  *      as modifier keys.
  */
-Bool LegalModifier(unsigned int key, DevicePtr pDev)
+Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
 {
     return 1;
 }
diff --git a/hw/dmx/dmxinput.c b/hw/dmx/dmxinput.c
index 7c376de..37f4583 100644
--- a/hw/dmx/dmxinput.c
+++ b/hw/dmx/dmxinput.c
@@ -53,7 +53,7 @@
 /** Returns TRUE if the key is a valid modifier.  For PC-class
  * keyboards, all keys can be used as modifiers, so return TRUE
  * always. */
-Bool LegalModifier(unsigned int key, DevicePtr pDev)
+Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
 {
     return TRUE;
 }
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index a41fddb..3915436 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -516,7 +516,7 @@ KdPointerProc(DeviceIntPtr pDevice, int 
 }
 
 Bool
-LegalModifier(unsigned int key, DevicePtr pDev)
+LegalModifier(unsigned int key, DeviceIntPtr pDev)
 {
     return TRUE;
 }
diff --git a/hw/vfb/InitInput.c b/hw/vfb/InitInput.c
index 773c454..17e023a 100644
--- a/hw/vfb/InitInput.c
+++ b/hw/vfb/InitInput.c
@@ -43,7 +43,7 @@ from The Open Group.
 #include <X11/keysym.h>
 
 Bool
-LegalModifier(unsigned int key, DevicePtr pDev)
+LegalModifier(unsigned int key, DeviceIntPtr pDev)
 {
     return TRUE;
 }
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 45a50d8..ff3840c 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -164,7 +164,7 @@ static IHPtr InputHandlers = NULL;
 
 
 Bool
-LegalModifier(unsigned int key, DevicePtr pDev)
+LegalModifier(unsigned int key, DeviceIntPtr pDev)
 {
     return TRUE;
 }
diff --git a/hw/xgl/egl/module/xeglmodule.c b/hw/xgl/egl/module/xeglmodule.c
index ff695f6..abd0d0d 100644
--- a/hw/xgl/egl/module/xeglmodule.c
+++ b/hw/xgl/egl/module/xeglmodule.c
@@ -52,7 +52,7 @@ InitOutput (ScreenInfo *pScreenInfo,
 
 Bool
 LegalModifier (unsigned int key,
-	       DevicePtr    pDev)
+	       DeviceIntPtr    pDev)
 {
     return xeglLegalModifier (key, pDev);
 }
diff --git a/hw/xgl/egl/xegl.c b/hw/xgl/egl/xegl.c
index 70db7c0..c671dbe 100644
--- a/hw/xgl/egl/xegl.c
+++ b/hw/xgl/egl/xegl.c
@@ -252,7 +252,7 @@ xeglInitInput (int  argc,
 
 Bool
 xeglLegalModifier (unsigned int key,
-		   DevicePtr    pDev)
+		   DeviceIntPtr pDev)
 {
     return KdLegalModifier (key, pDev);
 }
diff --git a/hw/xgl/egl/xegl.h b/hw/xgl/egl/xegl.h
index cf21fca..be9b48c 100644
--- a/hw/xgl/egl/xegl.h
+++ b/hw/xgl/egl/xegl.h
@@ -173,7 +173,7 @@ KdWakeupHandler (pointer data,
 
 Bool
 KdLegalModifier (unsigned int key, 
-		 DevicePtr    pDev);
+		 DeviceIntPtr pDev);
 
 void
 KdProcessInputEvents (void);
diff --git a/hw/xgl/egl/xeglinit.c b/hw/xgl/egl/xeglinit.c
index 51100a4..c28d946 100644
--- a/hw/xgl/egl/xeglinit.c
+++ b/hw/xgl/egl/xeglinit.c
@@ -58,7 +58,7 @@ InitOutput (ScreenInfo *pScreenInfo,
 
 Bool
 LegalModifier (unsigned int key,
-	       DevicePtr    pDev)
+	       DeviceIntPtr pDev)
 {
     return xeglLegalModifier (key, pDev);
 }
diff --git a/hw/xgl/glx/module/xglxmodule.c b/hw/xgl/glx/module/xglxmodule.c
index 066cb80..40af890 100644
--- a/hw/xgl/glx/module/xglxmodule.c
+++ b/hw/xgl/glx/module/xglxmodule.c
@@ -52,7 +52,7 @@ InitOutput (ScreenInfo *pScreenInfo,
 
 Bool
 LegalModifier (unsigned int key,
-	       DevicePtr    pDev)
+	       DeviceIntPtr pDev)
 {
     return xglxLegalModifier (key, pDev);
 }
diff --git a/hw/xgl/glx/xglx.c b/hw/xgl/glx/xglx.c
index 1ded3e3..57cb847 100644
--- a/hw/xgl/glx/xglx.c
+++ b/hw/xgl/glx/xglx.c
@@ -1243,7 +1243,7 @@ xglxKeybdProc (DeviceIntPtr pDevice,
 
 Bool
 xglxLegalModifier (unsigned int key,
-		   DevicePtr    pDev)
+		   DeviceIntPtr pDev)
 {
     return TRUE;
 }
diff --git a/hw/xgl/glx/xglx.h b/hw/xgl/glx/xglx.h
index b0c5d3d..a8c8946 100644
--- a/hw/xgl/glx/xglx.h
+++ b/hw/xgl/glx/xglx.h
@@ -91,7 +91,7 @@ xglxInitOutput (ScreenInfo *pScreenInfo,
 
 Bool
 xglxLegalModifier (unsigned int key,
-		   DevicePtr    pDev);
+		   DeviceIntPtr pDev);
 
 void
 xglxProcessInputEvents (void);
diff --git a/hw/xgl/glx/xglxinit.c b/hw/xgl/glx/xglxinit.c
index 50bbca5..b87e5d6 100644
--- a/hw/xgl/glx/xglxinit.c
+++ b/hw/xgl/glx/xglxinit.c
@@ -81,7 +81,7 @@ InitOutput (ScreenInfo *pScreenInfo,
 
 Bool
 LegalModifier (unsigned int key,
-	       DevicePtr    pDev)
+	       DeviceIntPtr pDev)
 {
     return xglxLegalModifier (key, pDev);
 }
diff --git a/hw/xgl/xglinit.c b/hw/xgl/xglinit.c
index 3d93c46..e0c9e7d 100644
--- a/hw/xgl/xglinit.c
+++ b/hw/xgl/xglinit.c
@@ -192,7 +192,7 @@ InitOutput (ScreenInfo *pScreenInfo,
 
 Bool
 LegalModifier (unsigned int key,
-	       DevicePtr    pDev)
+	       DeviceIntPtr    pDev)
 {
     return (*__ddxFunc.legalModifier) (key, pDev);
 }
diff --git a/hw/xnest/Keyboard.c b/hw/xnest/Keyboard.c
index f18cc97..26a5ed3 100644
--- a/hw/xnest/Keyboard.c
+++ b/hw/xnest/Keyboard.c
@@ -253,7 +253,7 @@ XkbError:
 }
 
 Bool
-LegalModifier(unsigned int key, DevicePtr pDev)
+LegalModifier(unsigned int key, DeviceIntPtr pDev)
 {
   return TRUE;
 }
diff --git a/hw/xprint/ddxInit.c b/hw/xprint/ddxInit.c
index 6cd3cfd..77b532f 100644
--- a/hw/xprint/ddxInit.c
+++ b/hw/xprint/ddxInit.c
@@ -189,7 +189,7 @@ InitInput(
 Bool
 LegalModifier(
      unsigned int key,
-     DevicePtr dev)
+     DeviceIntPtr dev)
 {
     return TRUE;
 }
diff --git a/hw/xwin/InitInput.c b/hw/xwin/InitInput.c
index f4796e0..52f837e 100644
--- a/hw/xwin/InitInput.c
+++ b/hw/xwin/InitInput.c
@@ -79,7 +79,7 @@ extern winDispatchProcPtr	winProcQueryTr
  */
 
 Bool
-LegalModifier (unsigned int uiKey, DevicePtr pDevice)
+LegalModifier (unsigned int uiKey, DeviceIntPtr pDevice)
 {
   return TRUE;
 }
diff --git a/include/input.h b/include/input.h
index 6573a1f..66d03d0 100644
--- a/include/input.h
+++ b/include/input.h
@@ -371,7 +371,7 @@ extern void CoreProcessKeyboardEvent(
 
 extern Bool LegalModifier(
     unsigned int /*key*/, 
-    DevicePtr /*pDev*/);
+    DeviceIntPtr /*pDev*/);
 
 extern void ProcessInputEvents(void);
 
diff-tree a5d639cd87f30f9b3d765352d27253940f33b2b7 (from ad321fad4b9ab3a2c70cfff37ca6c8faaa5cce9c)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Sep 27 16:15:27 2006 +0300

    remove merge detritus

diff --git a/configure.ac b/configure.ac
index 0a9fe52..0397b58 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1507,7 +1507,6 @@ if test "$KDRIVE" = yes; then
     fi
     
     # tslib...
-<<<<<<< HEAD/configure.ac
     AC_CHECK_LIB(ts, ts_open, [HAVE_TSLIB="yes"])
     if test "x$TSLIB" = xauto && test "x$HAVE_TSLIB" = xyes; then
         TSLIB=yes
diff-tree ad321fad4b9ab3a2c70cfff37ca6c8faaa5cce9c (from parents)
Merge: 5e9d33fe87f9d24e55c468d4b2bb761c9efdb26a f7c1d942416db8d0d4c5a21f5ece1ccacb926b69
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Sep 24 17:56:43 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff --cc configure.ac
index 8aa6a34,76f5e04..0a9fe52
@@@ -431,7 -425,8 +431,8 @@@
  AC_ARG_ENABLE(dbe,            AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes])
  AC_ARG_ENABLE(xf86bigfont,    AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big Font extension (default: enabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=yes])
  AC_ARG_ENABLE(dpms,           AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes])
 -AC_ARG_ENABLE(xinput,         AS_HELP_STRING([--disable-xinput], [Build XInput Extension (default: enabled)]), [XINPUT=$enableval], [XINPUT=yes])
 +AC_ARG_ENABLE(dbus,           AS_HELP_STRING([--disable-dbus], [Build D-BUS support (default: auto)]), [DBUS=$enableval], [DBUS=auto])
+ AC_ARG_ENABLE(xfree86-utils,     AS_HELP_STRING([--enable-xfree86-utils], [Build xfree86 DDX utilities (default: enabled)]), [XF86UTILS=$enableval], [XF86UTILS=yes])
  
  dnl DDXes.
  AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
@@@ -742,10 -729,15 +743,12 @@@
  fi
  MIEXT_DAMAGE_INC='-I$(top_srcdir)/miext/damage'
  
 -AM_CONDITIONAL(XINPUT, [test "x$XINPUT" = xyes])
 -if test "x$XINPUT" = xyes; then
 -   	AC_DEFINE(XINPUT, 1, [Support X Input extension])
 -	XI_LIB='$(top_builddir)/Xi/libXi.la'
 -	XI_INC='-I$(top_srcdir)/Xi'
 -fi
 +AC_DEFINE(XINPUT, 1, [Support X Input extension])
 +XI_LIB='$(top_builddir)/Xi/libXi.la'
 +XI_INC='-I$(top_srcdir)/Xi'
  
+ AM_CONDITIONAL(XF86UTILS, test "x$XF86UTILS" = xyes)
+ 
  AC_DEFINE(SHAPE, 1, [Support SHAPE extension])
  
  AC_DEFINE(XKB, 1, [Build XKB])
diff-tree 58933757862c458e2da39bd464e50d9c0e41b313 (from 0a3740a0000191e3039fe183ae51b938d0548340)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Sun Sep 10 15:50:51 2006 -0400

    Warning fix, and a syntax fix in a #if 0 section of code.

diff --git a/dix/events.c b/dix/events.c
index c2c0395..34ee9fb 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -135,6 +135,7 @@ of the copyright holder.
 #include <X11/extensions/XKBproto.h>
 #include <X11/extensions/XKBsrv.h>
 extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
+extern Bool XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies);
 #endif
 
 #ifdef XCSECURITY
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 0fde727..cbf46d8 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -242,7 +242,7 @@ XkbMapChangesPtr	mc;
 	    xkb->min_key_code= first;
 	    /* 1/12/95 (ef) -- XXX! should zero out the new maps */
 	    changes->map.changed|= XkbKeycodesMask;
-generate a NewKeyboard notify here?
+/* generate a NewKeyboard notify here? */
 	}
     }
 #endif
diff-tree 0a3740a0000191e3039fe183ae51b938d0548340 (from 8d709f0280b458515b32c2b87938749428e5c149)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Sun Sep 10 15:49:25 2006 -0400

    Typo correction, 'i' is not a '1', so no longer crash on some Xi requests.

diff --git a/Xi/selectev.c b/Xi/selectev.c
index 1f6713a..7d3ef9d 100644
--- a/Xi/selectev.c
+++ b/Xi/selectev.c
@@ -178,7 +178,7 @@ ProcXSelectExtensionEvent(register Clien
 	return Success;
     }
 
-    if (HandleDevicePresenceMask(client, pWin, (XEventClass *) & stuff[i],
+    if (HandleDevicePresenceMask(client, pWin, (XEventClass *) & stuff[1],
                                 &stuff->count) != Success) {
        SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
                          BadAlloc);
diff-tree 8d709f0280b458515b32c2b87938749428e5c149 (from 60db190ecfce52cbfa888c0af3210634f9186bed)
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Sun Sep 10 15:48:35 2006 -0400

    Remove a merge artifact so that we can compile.

diff --git a/configure.ac b/configure.ac
index 8aa6a34..047857a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1504,7 +1504,6 @@ if test "$KDRIVE" = yes; then
     fi
     
     # tslib...
-<<<<<<< HEAD/configure.ac
     AC_CHECK_LIB(ts, ts_open, [HAVE_TSLIB="yes"])
     if test "x$TSLIB" = xauto && test "x$HAVE_TSLIB" = xyes; then
         TSLIB=yes
diff-tree 60db190ecfce52cbfa888c0af3210634f9186bed (from parents)
Merge: 5e9d33fe87f9d24e55c468d4b2bb761c9efdb26a 65256109bb8f5a26704ed960e1dd113981df5787
Author: Zephaniah E. Hull <warp at agamemnon.b5>
Date:   Sun Sep 10 03:49:17 2006 -0400

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver

diff-tree 5e9d33fe87f9d24e55c468d4b2bb761c9efdb26a (from parents)
Merge: 629798c73ad76a77fa6a55bc6403fd9b95ade2bb 64479fffa22581cc7d753065c33eda5520b7db9a
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Sep 7 15:43:31 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff --cc configure.ac
index 50353ed,798c8f0..8aa6a34
@@@ -417,9 -411,11 +417,11 @@@
  AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]), [GLX_USE_TLS=$enableval], [GLX_USE_TLS=no])
  AC_ARG_ENABLE(dri,            AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
  AC_ARG_ENABLE(xinerama,	      AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
 -AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: enabled)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=yes])
 -AC_ARG_ENABLE(xf86misc,       AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: enabled)]), [XF86MISC=$enableval], [XF86MISC=yes])
 +AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
 +AC_ARG_ENABLE(xf86misc,       AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: auto)]), [XF86MISC=$enableval], [XF86MISC=auto])
  AC_ARG_ENABLE(xcsecurity,     AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: enabled)]), [XCSECURITY=$enableval], [XCSECURITY=yes])
+ AC_ARG_ENABLE(xcalibrate,     AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no])
+ AC_ARG_ENABLE(tslib,          AS_HELP_STRING([--enable-tslib], [Build kdrive tslib touchscreen support (default: disabled)]), [TSLIB=$enableval], [TSLIB=no])
  AC_ARG_ENABLE(xevie,          AS_HELP_STRING([--disable-xevie], [Build XEvIE extension (default: enabled)]), [XEVIE=$enableval], [XEVIE=yes])
  AC_ARG_ENABLE(appgroup,       AS_HELP_STRING([--disable-appgroup], [Build XC-APPGROUP extension (default: enabled)]), [APPGROUP=$enableval], [APPGROUP=yes])
  AC_ARG_ENABLE(cup,            AS_HELP_STRING([--disable-cup], [Build TOG-CUP extension (default: enabled)]), [CUP=$enableval], [CUP=yes])
@@@ -705,11 -698,14 +707,19 @@@
  	REQUIRED_MODULES="$REQUIRED_MODULES printproto"
  fi
  
 +if test "x$BUILTIN_FONTS" = xyes; then
 +       AC_DEFINE(BUILTIN_FONTS, 1, [Use only built-in fonts])
 +       AC_DEFINE(NOFONTSERVERACCESS, 1, [Avoid using a font server])
 +fi
 +
+ if test "x$XCALIBRATE" = xyes && test "$KDRIVE" = yes; then
+    AC_DEFINE(XCALIBRATE, 1, [Build XCalibrate extension])
+    REQUIRED_MODULES="$REQUIRED_MODULES xcalibrateproto"
+ else
+    XCALIBRATE=no
+ fi
+ AM_CONDITIONAL(XCALIBRATE, [test "x$XCALIBRATE" = xyes])
+ 
  AC_DEFINE(RENDER, 1, [Support RENDER extension])
  RENDER_LIB='$(top_builddir)/render/librender.la'
  RENDER_INC='-I$(top_srcdir)/render'
@@@ -1495,39 -1449,13 +1504,47 @@@
      fi
      
      # tslib...
++<<<<<<< HEAD/configure.ac
 +    AC_CHECK_LIB(ts, ts_open, [HAVE_TSLIB="yes"])
 +    if test "x$TSLIB" = xauto && test "x$HAVE_TSLIB" = xyes; then
 +        TSLIB=yes
 +    fi
 +
 +    if test "x$TSLIB" = xyes; then
 +        if ! test "x$HAVE_TSLIB" = xyes; then
 +            AC_MSG_ERROR([tslib must be installed to build the tslib input driver.])
 +        fi
 +        TSLIB_LIBS="-lts"
 +        AC_DEFINE(TSLIB, 1, [Have tslib support])
 +    fi
 +
 +    if test x"$ac_cv_header_SDL_SDL_h" = xyes && test "x$XSDL" = xauto; then
 +       XSDL=yes
 +    fi
 +
 +    if test x"$XSDL" = xyes; then
 +       # PKG_CHECK_MODULES(XSDL_EXTRA, Xfont xau $XDMCP_MODULES)
 +       AC_DEFINE(XSDLSERVER,1,[Build Xsdl server])
 +       XSDL_LIBS="`sdl-config --libs` $XSERVER_LIBS"
 +       XSDL_INCS="`sdl-config --cflags` $XSERVER_CFLAGS"
 +    fi
 +
 +    PKG_CHECK_MODULES(XEPHYR, x11 xext xfont xau xdmcp, [xephyr="yes"], [xephyr="no"])
 +    if test "x$XEPHYR" = xauto; then
 +        XEPHYR=$xephyr
 +    fi
 +
 +    # Xephyr needs nanosleep() which is in librt on Solaris
 +    AC_CHECK_FUNC([nanosleep], [],
 +        AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
 +    XEPHYR_LIBS="$XEPHYR_LIBS $XSERVER_LIBS"
+     if test "x$TSLIB" = xyes; then
+         PKG_CHECK_MODULES([TSLIB], [tslib-0.0], [HAVE_TSLIB="yes"], [HAVE_TSLIB="no"])
+         if test "x$HAVE_TSLIB" = xno; then
+             AC_MSG_ERROR([tslib must be installed to build the tslib driver. See http://tslib.berlios.de/])
+         fi
+         AC_DEFINE(TSLIB, 1, [Have tslib support])
+     fi
  
      # damage shadow extension glx (NOTYET) fb mi
      KDRIVE_INC='-I$(top_srcdir)/hw/kdrive/src'
@@@ -1548,32 -1476,42 +1565,39 @@@
  
      # check if we can build Xephyr
      PKG_CHECK_MODULES(XEPHYR, x11 xext xfont xau xdmcp, [xephyr="yes"], [xephyr="no"])
 -    
 +    XEPHYR_LIBS="$XEPHYR_LIBS $XSERVER_LIBS"
 +
 +    # Xephyr needs nanosleep() which is in librt on Solaris
 +    AC_CHECK_FUNC([nanosleep], [],
 +        AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
 +
+     # check for SDL SDK
+     AC_CHECK_HEADERS([SDL/SDL.h])
+     if test "x$XSDL" = xauto; then
+         XSDL="$ac_cv_header_SDL_SDL_h"
+     fi
 -fi
 -AC_SUBST(KDRIVE_INCS)
 -AC_SUBST(KDRIVE_PURE_INCS)
 -AC_SUBST(KDRIVE_CFLAGS)
 -AC_SUBST(KDRIVE_PURE_LIBS)
 -AC_SUBST(KDRIVE_LIBS)
++
 +    AC_SUBST([XEPHYR_LIBS])
 +    AC_SUBST([XEPHYR_INCS])
 +    AC_SUBST([XSDL_LIBS])
 +    AC_SUBST([XSDL_INCS])
 +fi
 +AC_SUBST([KDRIVE_INCS])
 +AC_SUBST([KDRIVE_PURE_INCS])
 +AC_SUBST([KDRIVE_CFLAGS])
 +AC_SUBST([KDRIVE_PURE_LIBS])
 +AC_SUBST([KDRIVE_LIBS])
- AM_CONDITIONAL(TSLIB, [test "x$TSLIB" = xyes])
+ AM_CONDITIONAL(TSLIB, [test "x$HAVE_TSLIB" = xyes])
  AM_CONDITIONAL(H3600_TS, false)
 +AM_CONDITIONAL(KDRIVEVESA, [test "x$KDRIVEVESA" = xyes])
 +AM_CONDITIONAL(KDRIVEFBDEV, [test "x$XFBDEV" = xyes])
 +AM_CONDITIONAL(XSDLSERVER, [test x"$XSDL" = xyes])
 +AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes])
 +AM_CONDITIONAL(BUILD_KDRIVEFBDEVLIB, [test "x$KDRIVE" = xyes && test "x$KDRIVEFBDEVLIB" = xyes])
 +AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
- 
+ AM_CONDITIONAL(KDRIVEVESA, [test x"$ac_cv_header_sys_vm86_h" = xyes])
+ AM_CONDITIONAL(KDRIVEFBDEV, [test x"$ac_cv_header_linux_fb_h" = xyes])
  
 -# Xephyr needs nanosleep() which is in librt on Solaris
 -AC_CHECK_FUNC([nanosleep], [],
 -	AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
 -
 -AM_CONDITIONAL(XEPHYR, [test x"$xephyr" = xyes])
 -XEPHYR_LIBS="$XEPHYR_LIBS $XSERVER_LIBS"
 -AC_SUBST([XEPHYR_LIBS])
 -AC_SUBST([XEPHYR_INCS])
 -
 -if test x"$XSDL" = xyes; then
 -    AC_DEFINE(XSDLSERVER,,[Build Xsdl server])
 -    XSDL_LIBS="`sdl-config --libs` $XSERVER_LIBS"
 -    XSDL_INCS="`sdl-config --cflags` $XSERVER_CFLAGS"
 -fi
 -AM_CONDITIONAL(XSDLSERVER, [test x"$XSDL" = xyes])
 -AC_SUBST([XSDL_LIBS])
 -AC_SUBST([XSDL_INCS])
 -
 -
  dnl these only go in xkb-config.h (which is shared by the Xorg and Xnest servers)
  AC_DEFINE(__XKBDEFRULES__, "xorg", [Default XKB rules])
  AC_DEFINE_DIR(XKB_BASE_DIRECTORY, XKBPATH, [Path to XKB data])
diff --cc hw/kdrive/ati/Makefile.am
index 94d525e,3732d7d..76635fb
@@@ -65,5 -61,12 +61,4 @@@
  Xati_LDADD = \
  	$(ATI_LIBS)			\
  	@KDRIVE_LIBS@			\
- 	@XSERVER_LIBS@			\
- 	$(TSLIB_FLAG)
 -	@XSERVER_LIBS@			
 -
 -
 -Xati_DEPENDENCIES =                     \
 -        libati.a                        \
 -        $(FBDEV_LIBS)                   \
 -        $(VESA_LIBS)                    \
 -        $(DRI_LIBS)                     
 -
++	@XSERVER_LIBS@
diff --cc hw/kdrive/ephyr/Makefile.am
index b8f12c5,8f51bbe..c201fe9
@@@ -33,5 -28,5 +28,4 @@@
  	libxephyr-hostx.a			        \
  	../../../exa/libexa.la				\
  	@KDRIVE_LIBS@					\
-         $(TSLIB_LIBS)                                   \
 -	@KDRIVE_LIBS@					\
          @XEPHYR_LIBS@
diff --cc hw/kdrive/fake/Makefile.am
index a9c9aff,3a53e3d..d7ebfc2
@@@ -6,10 -6,10 +6,6 @@@
  
  bin_PROGRAMS = Xfake
  
--if TSLIB
--TSLIB_FLAG = -lts
--endif
--
  libfake_a_SOURCES =	\
  	fake.c		\
  	kbd.c		\
@@@ -23,6 -23,6 +19,4 @@@
  Xfake_LDADD = 						\
  	libfake.a					\
  	@KDRIVE_LIBS@					\
--	@KDRIVE_LIBS@					\
--	$(TSLIB_FLAG)                                   \
          @XSERVER_LIBS@
diff --cc hw/kdrive/fbdev/Makefile.am
index deed3c9,3a8c65b..cb71801
@@@ -4,10 -4,8 +4,6 @@@
  
  noinst_LIBRARIES = libfbdev.a
  
- if TSLIB
- TSLIB_FLAG = -lts
- endif
- 
 -bin_PROGRAMS = Xfbdev
 -
  libfbdev_a_SOURCES =	\
  	fbdev.c		\
  	fbdev.h
@@@ -21,6 -16,7 +17,5 @@@
  Xfbdev_LDADD = 						\
  	libfbdev.a					\
  	@KDRIVE_LIBS@					\
- 	@XSERVER_LIBS@					\
- 	$(TSLIB_FLAG)
 -	@XSERVER_LIBS@					
 -
 -Xfbdev_DEPENDENCIES =					\
 -	libfbdev.a
++	@XSERVER_LIBS@
 +endif
diff --cc hw/kdrive/mach64/Makefile.am
index 3040a89,e924aef..67712e2
@@@ -30,5 -30,8 +30,4 @@@
  Xmach64_LDADD = 					\
  	$(MACH64_LIBS)					\
  	@KDRIVE_LIBS@					\
--	@XSERVER_LIBS@					\
--	$(TSLIB_FLAG)
 -
 -
 -Xmach64_DEPENDENCIES = $(MACH64_LIBS)
++	@XSERVER_LIBS@
diff --cc hw/kdrive/mga/Makefile.am
index 7853cba,d8ebae9..ee07989
@@@ -7,10 -7,10 +7,6 @@@
  
  noinst_LIBRARIES = libmga.a
  
--if TSLIB
--TSLIB_FLAG = -lts
--endif
--
  libmga_a_SOURCES = 		\
  	mgadraw.c		\
  	g400_composite.c	\
@@@ -29,5 -29,9 +25,4 @@@
  Xmga_LDADD = \
  	$(MGA_LIBS)					\
  	@KDRIVE_LIBS@                                  \
--	@XSERVER_LIBS@					\
--	$(TSLIB_FLAG)
 -
 -Xmga_DEPENDENCIES = 					\
 -	libmga.a 					\
 -	$(top_builddir)/hw/kdrive/vesa/libvesa.a	
++	@XSERVER_LIBS@
diff --cc hw/kdrive/nvidia/Makefile.am
index 848b4cc,d7b26cf..67eff69
@@@ -7,10 -7,10 +7,6 @@@
  
  noinst_LIBRARIES = libnvidia.a
  
--if TSLIB
--TSLIB_FLAG = -lts
--endif
--
  #	nvidiavideo.c
  
  libnvidia_a_SOURCES = 	\
diff --cc hw/kdrive/sdl/Makefile.am
index cc3873c,cc3873c..f5abb86
@@@ -5,14 -5,14 +5,9 @@@
  
  bin_PROGRAMS = Xsdl
  
--if TSLIB
--TSLIB_FLAG = -lts
--endif
--
  Xsdl_SOURCES = sdl.c
  
  Xsdl_LDADD = @KDRIVE_PURE_LIBS@				\
  	@KDRIVE_LIBS@                                  \
  	@XSERVER_LIBS@					\
--	$(TSLIB_FLAG)					\
  	@XSDL_LIBS@
diff --cc hw/kdrive/sis300/Makefile.am
index e7200a2,6a6e0bf..9802074
@@@ -17,10 -17,10 +17,6 @@@
  
  bin_PROGRAMS = Xsis
  
--if TSLIB
--TSLIB_FLAG = -lts
--endif
--
  noinst_LIBRARIES = libsis.a
  
  libsis_a_SOURCES = 	\
diff --cc hw/kdrive/vesa/Makefile.am
index 8f36ddf,70ba55f..54a6f47
@@@ -27,6 -22,5 +22,4 @@@
  Xvesa_LDADD = \
  	libvesa.a 				\
  	@KDRIVE_LIBS@				\
--	@KDRIVE_LIBS@                          \
- 	$(TSLIB_FLAG)				\
  	@XSERVER_LIBS@
diff --cc hw/kdrive/via/Makefile.am
index 6e2045a,7dcfd7c..0ea8881
@@@ -5,10 -5,10 +5,6 @@@
  
  bin_PROGRAMS = Xvia
  
--if TSLIB
--TSLIB_FLAG = -lts
--endif
--
  noinst_LIBRARIES = libvia.a
  
  libvia_a_SOURCES = 	\
@@@ -28,5 -28,7 +24,4 @@@
  Xvia_LDADD =						\
  	$(VIA_LIBS)					\
  	@KDRIVE_LIBS@					\
--	@XSERVER_LIBS@					\
--	$(TSLIB_FLAG)					
 -
 -Xvia_DEPENDENCIES = $(VIA_LIBS)
++	@XSERVER_LIBS@
diff-tree 629798c73ad76a77fa6a55bc6403fd9b95ade2bb (from 4524a2bf6f22c871ed109b027a065f0262137dc5)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Sep 7 15:17:04 2006 +0300

    XkbCopyKeymap/SrvXkbCopyKeymap: free geom harder, add cheery comments
    Unconditionally free geometry when copying the keymap (so we have none on
    core, oh well), add a couple of heartening comments.

diff --git a/xkb/XKBAlloc.c b/xkb/XKBAlloc.c
index 8356e47..c474733 100644
--- a/xkb/XKBAlloc.c
+++ b/xkb/XKBAlloc.c
@@ -324,8 +324,11 @@ XkbFreeKeyboard(XkbDescPtr xkb,unsigned 
 	XkbFreeIndicatorMaps(xkb);
     if (which&XkbNamesMask)
 	XkbFreeNames(xkb,XkbAllNamesMask,True);
-    if ((which&XkbGeometryMask) && (xkb->geom!=NULL))
+    if ((which&XkbGeometryMask) && (xkb->geom!=NULL)) {
 	XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True);
+        /* PERHAPS BONGHITS etc */
+        xkb->geom = NULL;
+    }
     if (which&XkbControlsMask)
 	XkbFreeControls(xkb,XkbAllControlsMask,True);
     if (freeAll)
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 813801d..0fde727 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1476,6 +1476,8 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
     }
 
     /* geometry */
+    /* not implemented yet because oh god the pain. */
+#if 0
     if (src->geom) {
         /* properties */
         /* colors */
@@ -1485,9 +1487,13 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
         /* key aliases */
         /* font?!? */
     }
-    else {
+    else
+#endif
+    {
         if (dst->geom) {
+            /* I LOVE THE DIFFERENT CALL SIGNATURE.  REALLY, I DO. */
             XkbFreeGeometry(dst->geom, XkbGeomAllMask, True);
+            dst->geom = NULL;
         }
     }
 
@@ -1520,7 +1526,8 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
         }
         else {
             /* send NewKeyboardNotify if the keycode range changed, else
-             * just MapNotify. */
+             * just MapNotify.  we also need to send NKN if the geometry
+             * changed (obviously ...). */
             if ((src->min_key_code != dst->min_key_code ||
                  src->max_key_code != dst->max_key_code) && sendNotifies) {
                 nkn.oldMinKeyCode = dst->min_key_code;
diff-tree 4524a2bf6f22c871ed109b027a065f0262137dc5 (from 260c3f32b69c98f8fc5360f860f69d32c19f04a7)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Aug 29 23:49:26 2006 +0300

    configure.ac: move tslib from KDRIVE_PURE_LIBS to KDRIVE_LIBS
    Yeah.  That was dumb.

diff --git a/configure.ac b/configure.ac
index a28ba08..50353ed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1540,11 +1540,11 @@ if test "$KDRIVE" = yes; then
     # dix os fb mi extension glx (NOTYET) damage shadow xpstubs
     #KDRIVE_PURE_LIBS="$DIX_LIB $OS_LIB $FB_LIB $XEXT_LIB $MIEXT_DAMAGE_LIB \
     #    $MIEXT_SHADOW_LIB $XPSTUBS_LIB"
-    KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $TSLIB_LIBS $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $OS_LIB"
+    KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $OS_LIB"
     KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.a'
     KDRIVE_OS_LIB='$(top_builddir)/hw/kdrive/linux/liblinux.a'
     KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.a'
-    KDRIVE_LIBS="$XSERVERLIBS_LIBS $DIX_LIB $CONFIG_LIB $KDRIVE_LIB $KDRIVE_OS_LIB $KDRIVE_PURE_LIBS $KDRIVE_STUB_LIB"
+    KDRIVE_LIBS="$XSERVERLIBS_LIBS $DIX_LIB $CONFIG_LIB $KDRIVE_LIB $TSLIB_LIBS $KDRIVE_OS_LIB $KDRIVE_PURE_LIBS $KDRIVE_STUB_LIB"
 
     # check if we can build Xephyr
     PKG_CHECK_MODULES(XEPHYR, x11 xext xfont xau xdmcp, [xephyr="yes"], [xephyr="no"])
diff-tree 260c3f32b69c98f8fc5360f860f69d32c19f04a7 (from 89d272bb183e85715d8e6047929fb2d912033d82)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Aug 29 23:18:12 2006 +0300

    configure.ac: fix XSDL test

diff --git a/configure.ac b/configure.ac
index 360f61c..a28ba08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1508,7 +1508,7 @@ if test "$KDRIVE" = yes; then
         AC_DEFINE(TSLIB, 1, [Have tslib support])
     fi
 
-    if test x"$ac_cv_header_SDL_SDL_h" = xyes && "x$XSDL" = xauto; then
+    if test x"$ac_cv_header_SDL_SDL_h" = xyes && test "x$XSDL" = xauto; then
        XSDL=yes
     fi
 
diff-tree 89d272bb183e85715d8e6047929fb2d912033d82 (from bd6f539ff9409aa7d9056fabe120b457b0a15997)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Tue Aug 29 15:05:31 2006 +0300

    [PATCH] kdrive/linux keyboard: remove more debugging spew

diff --git a/hw/kdrive/linux/keyboard.c b/hw/kdrive/linux/keyboard.c
index eb4a8f1..24653ad 100644
--- a/hw/kdrive/linux/keyboard.c
+++ b/hw/kdrive/linux/keyboard.c
@@ -579,7 +579,9 @@ LinuxKeyboardRead (int fd, void *closure
                 if (!prefix && ((b[0] & 0x7f) == KEY_Prefix0))
                 {
                         prefix = KEY_Prefix0;
+#ifdef DEBUG
                         ErrorF("Prefix0");
+#endif
                         /* swallow this up */
                         b++;
                         continue;
@@ -598,7 +600,9 @@ LinuxKeyboardRead (int fd, void *closure
                         /* from xf86Events.c */
                         case KEY_Prefix0:
                         {
+#ifdef DEBUG
                             ErrorF("Prefix0 scancode: 0x%02x\n", scancode);
+#endif
                             switch (scancode) {
                                 case KEY_KP_7:
                                     scancode = KEY_Home;      break;  /* curs home */
diff-tree bd6f539ff9409aa7d9056fabe120b457b0a15997 (from 5436fce09003e20744a388fa4ae49007c9cf8ede)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Tue Aug 29 13:21:58 2006 +0300

    [PATCH] kdrive/linux keyboard: silence excessive debugging noise

diff --git a/hw/kdrive/linux/keyboard.c b/hw/kdrive/linux/keyboard.c
index 9400e6b..eb4a8f1 100644
--- a/hw/kdrive/linux/keyboard.c
+++ b/hw/kdrive/linux/keyboard.c
@@ -659,8 +659,10 @@ LinuxKeyboardRead (int fd, void *closure
                                     prefix = 0;
                                     continue;
                                 default:
+#ifdef DEBUG
                                     ErrorF("Unreported Prefix0 scancode: 0x%02x\n",
                                            scancode);
+#endif
                                      /*
                                       * "Internet" keyboards are generating lots of new
                                       * codes.  Let them pass.  There is little consistency
@@ -675,7 +677,9 @@ LinuxKeyboardRead (int fd, void *closure
                         case KEY_Prefix1:
                         {
                             /* we do no handle these */
+#ifdef DEBUG
                             ErrorF("Prefix1 scancode: 0x%02x\n", scancode);
+#endif
                             b++;
                             prefix = 0;
                             continue;
@@ -683,7 +687,10 @@ LinuxKeyboardRead (int fd, void *closure
 
                         default: /* should not happen*/
                         case 0: /* do nothing */
+#ifdef DEBUG
                             ErrorF("Plain scancode: 0x%02x\n", scancode);
+#endif
+                            ;
                 }
 
                 prefix = 0;
diff-tree 5436fce09003e20744a388fa4ae49007c9cf8ede (from 0eb7299f445455a7bcacf2410e83227b23259675)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Tue Aug 29 13:21:40 2006 +0300

    [PATCH] GetKeyboardValutorEvents: be even more careful
    
    Don't accept devices without a keyboard feedback class.

diff --git a/dix/events.c b/dix/events.c
index 581fa08..c2c0395 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4663,7 +4663,7 @@ int GetKeyboardValuatorEvents(xEvent *ev
     if (type != KeyPress && type != KeyRelease)
         return 0;
 
-    if (!pDev->key || !pDev->focus ||
+    if (!pDev->key || !pDev->focus || !pDev->kbdfeed ||
         (pDev->coreEvents && !inputInfo.keyboard->key))
         return 0;
 
diff-tree 0eb7299f445455a7bcacf2410e83227b23259675 (from 7fa3383e3c8eea7d1eb0e556393f2431cf8e6ed2)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Tue Aug 29 13:19:12 2006 +0300

    [PATCH] XkbCopyKeymap: still more range fixes
    
    Make sure we don't stomp preserve if it doesn't already exist, and fix a
    couple of range-related thinkos in level name copying.

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 5f1176b..813801d 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1059,6 +1059,9 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                 if (dst->map->types) {
                     tmp = xrealloc(dst->map->types,
                                    src->map->size_types * sizeof(XkbKeyTypeRec));
+                    if (!tmp)
+                        return FALSE;
+                    dst->map->types = tmp;
                     bzero(dst->map->types +
                             (dst->map->size_types * sizeof(XkbKeyTypeRec)),
                           (src->map->size_types - dst->map->size_types) *
@@ -1066,10 +1069,10 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                 }
                 else {
                     tmp = xcalloc(src->map->size_types, sizeof(XkbKeyTypeRec));
+                    if (!tmp)
+                        return FALSE;
+                    dst->map->types = tmp;
                 }
-                if (!tmp)
-                    return FALSE;
-                dst->map->types = tmp;
             }
             else if (src->map->size_types < dst->map->size_types) {
                 if (dst->map->types) {
@@ -1085,7 +1088,7 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
 
             stype = src->map->types;
             dtype = dst->map->types;
-            for (i = 0; i < dst->map->num_types; i++, dtype++, stype++) {
+            for (i = 0; i < src->map->num_types; i++, dtype++, stype++) {
                 if (stype->num_levels != dtype->num_levels) {
                     if (dtype->level_names)
                         tmp = xrealloc(dtype->level_names,
@@ -1105,41 +1108,69 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                 dtype->name = stype->name;
                 memcpy(&dtype->mods, &stype->mods, sizeof(XkbModsRec));
 
-                if (stype->map_count != dtype->map_count) {
-                    if (dtype->map)
-                        tmp = xrealloc(dtype->map,
-                                       stype->map_count *
-                                         sizeof(XkbKTMapEntryRec));
-                    else
+                if (stype->map) {
+                    if (dtype->map) {
+                        if (stype->map_count != dtype->map_count) {
+                            tmp = xrealloc(dtype->map,
+                                           stype->map_count *
+                                             sizeof(XkbKTMapEntryRec));
+                            if (!tmp)
+                                return FALSE;
+                            dtype->map = tmp;
+                        }
+                    }
+                    else {
                         tmp = xalloc(stype->map_count *
-                                     sizeof(XkbKTMapEntryRec));
-                    if (!tmp)
-                        return FALSE;
-                    dtype->map = tmp;
+                                       sizeof(XkbKTMapEntryRec));
+                        if (!tmp)
+                            return FALSE;
+                        dtype->map = tmp;
+                    }
 
-                    if (dtype->preserve)
-                        tmp = xrealloc(dtype->preserve,
-                                       stype->map_count * sizeof(XkbModsRec));
-                    else
+                    dtype->map_count = stype->map_count;
+                    memcpy(dtype->map, stype->map, stype->map_count *
+                                               sizeof(XkbKTMapEntryRec));
+                }
+
+                if (stype->preserve) {
+                    if (dtype->preserve) {
+                        if (stype->map_count != dtype->map_count) {
+                            tmp = xrealloc(dtype->preserve,
+                                           stype->map_count *
+                                             sizeof(XkbModsRec));
+                            if (!tmp)
+                                return FALSE;
+                            dtype->preserve = tmp;
+                        }
+                    }
+                    else {
                         tmp = xalloc(stype->map_count * sizeof(XkbModsRec));
-                    if (!tmp)
-                        return FALSE;
-                    dtype->preserve = tmp;
+                        if (!tmp)
+                            return FALSE;
+                        dtype->preserve = tmp;
+                    }
+
+                    memcpy(dtype->preserve, stype->preserve,
+                           stype->map_count * sizeof(XkbModsRec));
+                }
+                else {
+                    if (dtype->preserve) {
+                        xfree(dtype->preserve);
+                        dtype->preserve = NULL;
+                    }
                 }
-                dtype->map_count = stype->map_count;
-                memcpy(dtype->map, stype->map, stype->map_count *
-                                               sizeof(XkbKTMapEntryRec));
-                memcpy(dtype->preserve, stype->preserve, stype->map_count *
-                                                         sizeof(XkbModsRec));
             }
         }
         else {
             if (dst->map->types) {
                 for (i = 0, dtype = dst->map->types; i < dst->map->num_types;
                      i++, dtype++) {
-                    xfree(dtype->level_names);
-                    xfree(dtype->map);
-                    xfree(dtype->preserve);
+                    if (dtype->level_names)
+                        xfree(dtype->level_names);
+                    if (dtype->map)
+                        xfree(dtype->map);
+                    if (dtype->preserve)
+                        xfree(dtype->preserve);
                 }
                 xfree(dst->map->types);
                 dst->map->types = NULL;
@@ -1490,8 +1521,8 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
         else {
             /* send NewKeyboardNotify if the keycode range changed, else
              * just MapNotify. */
-            if (src->min_key_code != dst->min_key_code ||
-                src->max_key_code != dst->max_key_code && sendNotifies) {
+            if ((src->min_key_code != dst->min_key_code ||
+                 src->max_key_code != dst->max_key_code) && sendNotifies) {
                 nkn.oldMinKeyCode = dst->min_key_code;
                 nkn.oldMaxKeyCode = dst->max_key_code;
                 nkn.deviceID = nkn.oldDeviceID = pDev->id;
diff-tree 7fa3383e3c8eea7d1eb0e556393f2431cf8e6ed2 (from parents)
Merge: 8d77d44fda3aacbae62864a3620e09095b79e92d ebbdc1342a243b301723390696f742dc91f59764
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Aug 29 15:16:01 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree 8d77d44fda3aacbae62864a3620e09095b79e92d (from parents)
Merge: d6f36bd28009881ef7f7a20cdadb3808d808ed97 2fde560bbb9c1148f26fd969dc30c4e736672b7c
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Aug 27 23:08:49 2006 +0300

    Merge branch 'origin' into input-hotplug

diff-tree d6f36bd28009881ef7f7a20cdadb3808d808ed97 (from 7c4167f0d6b33c9c602b04fcfd246fd3aeddd709)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Aug 25 12:43:17 2006 +0300

    xfree86/parser: use 'kbd' driver when 'keyboard' specified
    Now that we've completely ditched the old driver, we should probably make a
    best-effort attempt to keep configs working.

diff --git a/hw/xfree86/parser/Input.c b/hw/xfree86/parser/Input.c
index 3e2186a..3d98019 100644
--- a/hw/xfree86/parser/Input.c
+++ b/hw/xfree86/parser/Input.c
@@ -102,7 +102,10 @@ xf86parseInputSection (void)
 		case DRIVER:
 			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
 				Error (QUOTE_MSG, "Driver");
-			ptr->inp_driver = val.str;
+                        if (strcmp(val.str, "keyboard") == 0)
+                            ptr->inp_driver = "kbd";
+                        else
+			    ptr->inp_driver = val.str;
 			break;
 		case OPTION:
 			ptr->inp_option_lst = xf86parseOption(ptr->inp_option_lst);
diff-tree 7c4167f0d6b33c9c602b04fcfd246fd3aeddd709 (from parents)
Merge: 393f8347edcccfc24d8902a86ea9def7ada2537b cd2da4e41eae233b50f8830d9a8f5d1d916a5a1b
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Aug 25 11:15:33 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree 393f8347edcccfc24d8902a86ea9def7ada2537b (from 3a36b0a24aa9e9e238faa7f00100f59800f5142b)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Aug 25 10:46:32 2006 +0300

    xorgconf.cpp: kbd, not keyboard

diff --git a/hw/xfree86/xorgconf.cpp b/hw/xfree86/xorgconf.cpp
index 9de7e2b..df6704f 100644
--- a/hw/xfree86/xorgconf.cpp
+++ b/hw/xfree86/xorgconf.cpp
@@ -179,7 +179,7 @@ XCOMM **********************************
 Section "InputDevice"
 
     Identifier	"Keyboard1"
-    Driver	"keyboard"
+    Driver	"kbd"
 
 XCOMM Set the keyboard auto repeat parameters.  Not all platforms implement
 XCOMM this.
diff-tree 3a36b0a24aa9e9e238faa7f00100f59800f5142b (from parents)
Merge: db1ab1bdb2f79eca593fe247056309a16ebd29c6 b879356ce96929d02bcb75b9aa24b17ac7e28125
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 24 23:35:28 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree db1ab1bdb2f79eca593fe247056309a16ebd29c6 (from 5fb8d947bb88d715b9b236342885c445cb5a9387)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 24 23:33:59 2006 +0300

    XkbCopyKeymap: fix various range issues
    Fix a bunch of range issues caused by incorrect assumptions (e.g. that the
    design was at least halfway sensible), and copy types by hand, instead of
    just blindly memcpy()ing the lot, since it itself cleverly contains a ton
    of allocated pointers.

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 74799e8..5f1176b 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -28,6 +28,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include <dix-config.h>
 #endif
 
+#include "os.h"
 #include <stdio.h>
 #include <ctype.h>
 #include <math.h>
@@ -1009,16 +1010,17 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
         if (src->map->syms) {
             if (src->map->size_syms != dst->map->size_syms) {
                 if (dst->map->syms)
-                    tmp = xrealloc(dst->map->syms, src->map->size_syms);
+                    tmp = xrealloc(dst->map->syms,
+                                   src->map->size_syms * sizeof(KeySym));
                 else
-                    tmp = xalloc(src->map->size_syms);
+                    tmp = xalloc(src->map->size_syms * sizeof(KeySym));
                 if (!tmp)
                     return FALSE;
                 dst->map->syms = tmp;
+
             }
-            memcpy(dst->map->syms, src->map->syms, src->map->size_syms);
-            memcpy(dst->map->key_sym_map, src->map->key_sym_map,
-                   src->map->size_syms);
+            memcpy(dst->map->syms, src->map->syms,
+                   src->map->size_syms * sizeof(KeySym));
         }
         else {
             if (dst->map->syms) {
@@ -1029,37 +1031,116 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
         dst->map->num_syms = src->map->num_syms;
         dst->map->size_syms = src->map->size_syms;
 
-        if (src->map->types) {
-            if (src->map->size_types != dst->map->size_types) {
-                XkbKeyTypePtr stype = src->map->types;
-
-                if (dst->map->types)
-                    tmp = xrealloc(dst->map->types, src->map->size_types);
+        if (src->map->key_sym_map) {
+            if (src->max_key_code != dst->max_key_code) {
+                if (dst->map->key_sym_map)
+                    tmp = xrealloc(dst->map->key_sym_map,
+                                   (src->max_key_code + 1) *
+                                     sizeof(XkbSymMapRec));
                 else
-                    tmp = xalloc(src->map->size_types);
+                    tmp = xalloc((src->max_key_code + 1) *
+                                 sizeof(XkbSymMapRec));
+                if (!tmp)
+                    return FALSE;
+                dst->map->key_sym_map = tmp;
+            }
+            memcpy(dst->map->key_sym_map, src->map->key_sym_map,
+                   (src->max_key_code + 1) * sizeof(XkbSymMapRec));
+        }
+        else {
+            if (dst->map->key_sym_map) {
+                xfree(dst->map->key_sym_map);
+                dst->map->key_sym_map = NULL;
+            }
+        }
+
+        if (src->map->types) {
+            if (src->map->size_types > dst->map->size_types) {
+                if (dst->map->types) {
+                    tmp = xrealloc(dst->map->types,
+                                   src->map->size_types * sizeof(XkbKeyTypeRec));
+                    bzero(dst->map->types +
+                            (dst->map->size_types * sizeof(XkbKeyTypeRec)),
+                          (src->map->size_types - dst->map->size_types) *
+                            sizeof(XkbKeyTypeRec));
+                }
+                else {
+                    tmp = xcalloc(src->map->size_types, sizeof(XkbKeyTypeRec));
+                }
                 if (!tmp)
                     return FALSE;
                 dst->map->types = tmp;
             }
-            memcpy(dst->map->types, src->map->types, src->map->size_types);
+            else if (src->map->size_types < dst->map->size_types) {
+                if (dst->map->types) {
+                    for (i = src->map->num_types, dtype = (dst->map->types + i);
+                         i < dst->map->size_types; i++, dtype++) {
+                        if (dtype->level_names)
+                            xfree(dtype->level_names);
+                        dtype->level_names = NULL;
+                        dtype->num_levels = 0;
+                    }
+                }
+            }
 
             stype = src->map->types;
             dtype = dst->map->types;
             for (i = 0; i < dst->map->num_types; i++, dtype++, stype++) {
-                dtype->level_names = xalloc(dtype->num_levels * sizeof(Atom));
-                if (!dtype->level_names)
-                    continue; /* don't return FALSE here, try to whack all the
-                                 pointers we can, so we don't double-free when
-                                 going down. */
+                if (stype->num_levels != dtype->num_levels) {
+                    if (dtype->level_names)
+                        tmp = xrealloc(dtype->level_names,
+                                       stype->num_levels * sizeof(Atom));
+                    else
+                        tmp = xalloc(stype->num_levels * sizeof(Atom));
+                    if (!tmp)
+                        continue; /* don't return FALSE here, try to whack
+                                     all the pointers we can, so we don't
+                                     double-free when going down. */
+                    dtype->level_names = tmp;
+                    dtype->num_levels = stype->num_levels;
+                }
                 memcpy(dtype->level_names, stype->level_names,
-                       dtype->num_levels * sizeof(Atom));
+                       stype->num_levels * sizeof(Atom));
+
+                dtype->name = stype->name;
+                memcpy(&dtype->mods, &stype->mods, sizeof(XkbModsRec));
+
+                if (stype->map_count != dtype->map_count) {
+                    if (dtype->map)
+                        tmp = xrealloc(dtype->map,
+                                       stype->map_count *
+                                         sizeof(XkbKTMapEntryRec));
+                    else
+                        tmp = xalloc(stype->map_count *
+                                     sizeof(XkbKTMapEntryRec));
+                    if (!tmp)
+                        return FALSE;
+                    dtype->map = tmp;
+
+                    if (dtype->preserve)
+                        tmp = xrealloc(dtype->preserve,
+                                       stype->map_count * sizeof(XkbModsRec));
+                    else
+                        tmp = xalloc(stype->map_count * sizeof(XkbModsRec));
+                    if (!tmp)
+                        return FALSE;
+                    dtype->preserve = tmp;
+                }
+                dtype->map_count = stype->map_count;
+                memcpy(dtype->map, stype->map, stype->map_count *
+                                               sizeof(XkbKTMapEntryRec));
+                memcpy(dtype->preserve, stype->preserve, stype->map_count *
+                                                         sizeof(XkbModsRec));
             }
         }
         else {
             if (dst->map->types) {
                 for (i = 0, dtype = dst->map->types; i < dst->map->num_types;
-                     i++, dtype++)
+                     i++, dtype++) {
                     xfree(dtype->level_names);
+                    xfree(dtype->map);
+                    xfree(dtype->preserve);
+                }
                 xfree(dst->map->types);
                 dst->map->types = NULL;
             }
@@ -1123,15 +1204,16 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
         if (src->server->acts) {
             if (src->server->size_acts != dst->server->size_acts) {
                 if (dst->server->acts)
-                    tmp = xrealloc(dst->server->acts, src->server->size_acts);
+                    tmp = xrealloc(dst->server->acts,
+                                   src->server->size_acts * sizeof(XkbAction));
                 else
-                    tmp = xalloc(src->server->size_acts);
+                    tmp = xalloc(src->server->size_acts * sizeof(XkbAction));
                 if (!tmp)
                     return FALSE;
                 dst->server->acts = tmp;
             }
             memcpy(dst->server->acts, src->server->acts,
-                   src->server->size_acts);
+                   src->server->size_acts * sizeof(XkbAction));
         }
         else {
             if (dst->server->acts) {
@@ -1140,19 +1222,23 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
             }
         }
        dst->server->size_acts = src->server->size_acts;
+       dst->server->num_acts = src->server->num_acts;
 
         if (src->server->key_acts) {
             if (src->max_key_code != dst->max_key_code) {
                 if (dst->server->key_acts)
-                    tmp = xrealloc(dst->server->key_acts, src->max_key_code + 1);
+                    tmp = xrealloc(dst->server->key_acts,
+                                   (src->max_key_code + 1) *
+                                     sizeof(unsigned short));
                 else
-                    tmp = xalloc(src->max_key_code + 1);
+                    tmp = xalloc((src->max_key_code + 1) *
+                                 sizeof(unsigned short));
                 if (!tmp)
                     return FALSE;
                 dst->server->key_acts = tmp;
             }
             memcpy(dst->server->key_acts, src->server->key_acts,
-                   src->max_key_code + 1);
+                   (src->max_key_code + 1) * sizeof(unsigned short));
         }
         else {
             if (dst->server->key_acts) {
@@ -1188,15 +1274,17 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
             if (src->max_key_code != dst->max_key_code) {
                 if (dst->server->vmodmap)
                     tmp = xrealloc(dst->server->vmodmap,
-                                   src->max_key_code + 1);
+                                   (src->max_key_code + 1) *
+                                   sizeof(unsigned short));
                 else
-                    tmp = xalloc(src->max_key_code + 1);
+                    tmp = xalloc((src->max_key_code + 1) *
+                                 sizeof(unsigned short));
                 if (!tmp)
                     return FALSE;
                 dst->server->vmodmap = tmp;
             }
             memcpy(dst->server->vmodmap, src->server->vmodmap,
-                   src->max_key_code + 1);
+                   (src->max_key_code + 1) * sizeof(unsigned short));
         }
         else {
             if (dst->server->vmodmap) {
@@ -1324,20 +1412,20 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
     /* compat */
     if (src->compat) {
         if (src->compat->sym_interpret) {
-            if (src->compat->num_si != dst->compat->num_si) {
+            if (src->compat->size_si != dst->compat->size_si) {
                 if (dst->compat->sym_interpret)
                     tmp = xrealloc(dst->compat->sym_interpret,
-                                   src->compat->num_si *
+                                   src->compat->size_si *
                                      sizeof(XkbSymInterpretRec));
                 else
-                    tmp = xalloc(src->compat->num_si *
+                    tmp = xalloc(src->compat->size_si *
                                  sizeof(XkbSymInterpretRec));
                 if (!tmp)
                     return FALSE;
                 dst->compat->sym_interpret = tmp;
             }
             memcpy(dst->compat->sym_interpret, src->compat->sym_interpret,
-                   src->compat->num_si * sizeof(XkbSymInterpretRec));
+                   src->compat->size_si * sizeof(XkbSymInterpretRec));
         }
         else {
             if (dst->compat->sym_interpret) {
@@ -1346,6 +1434,7 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
             }
         }
         dst->compat->num_si = src->compat->num_si;
+        dst->compat->size_si = src->compat->size_si;
 
         memcpy(dst->compat->groups, src->compat->groups,
                XkbNumKbdGroups * sizeof(XkbModsRec));
diff-tree 5fb8d947bb88d715b9b236342885c445cb5a9387 (from 4e37c07ba6e5d299d4f8922dc6cf054c814f7baf)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 24 23:16:43 2006 +0300

    configure.ac: more thinkos
    Fix auto tests for vidmode and xf86dga.  I win at life.

diff --git a/configure.ac b/configure.ac
index 1c30a22..360f61c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1066,7 +1066,7 @@ if test "x$XORG" = xyes -o "x$XGL" = xye
 	XORG_LIBS="$COMPOSITE_LIB $MI_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB $OS_LIB"
 
 	if test "x$DGA" = xauto; then
-		PKG_CHECK_MODULES(DGA, dgaproto, [DGA=yes], [DGA=no])
+		PKG_CHECK_MODULES(DGA, xf86dgaproto, [DGA=yes], [DGA=no])
 	fi
 	if test "x$DGA" = xyes; then
 		XORG_MODULES="$XORG_MODULES xf86dgaproto"
@@ -1083,7 +1083,7 @@ if test "x$XORG" = xyes -o "x$XGL" = xye
 	fi
 
 	if test "x$XF86VIDMODE" = xauto; then
-		PKG_CHECK_MODULES(XF86VIDMODE, xf86vidmode, [XF86VIDMODE=yes], [XF86VIDMODE=no])
+		PKG_CHECK_MODULES(XF86VIDMODE, xf86vidmodeproto, [XF86VIDMODE=yes], [XF86VIDMODE=no])
 	fi
 	if test "x$XF86VIDMODE" = xyes; then
 		XORG_MODULES="$XORG_MODULES xf86vidmodeproto"
diff-tree 4e37c07ba6e5d299d4f8922dc6cf054c814f7baf (from 866ca1f929c95689bac9f0a0b3478f7b4d77214b)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 24 23:16:17 2006 +0300

    config: clean up debugging messages, make failure to acquire name fatal
    Bomb with FatalError when we can't acquire the bus and name.
    Clean up a bunch of debugging ErrorFs to be hidden behind #ifdef DEBUG.

diff --git a/config/config.c b/config/config.c
index d4cf233..d980f76 100644
--- a/config/config.c
+++ b/config/config.c
@@ -60,6 +60,7 @@ configMessage(DBusConnection *connection
     int deviceid = -1;
     DeviceIntPtr pDev = NULL;
 
+#ifdef DEBUG
     ErrorF("[dbus] new message!\n");
     ErrorF("       source: %s\n", dbus_message_get_sender(message));
     ErrorF("       destination: %s\n", dbus_message_get_destination(message));
@@ -70,6 +71,7 @@ configMessage(DBusConnection *connection
     ErrorF("       method call? %s\n", (dbus_message_get_type(message) ==
                                          DBUS_MESSAGE_TYPE_METHOD_CALL) ?
                                         "yes" : "no");
+#endif
 
     dbus_error_init(&error);
 
@@ -81,7 +83,9 @@ configMessage(DBusConnection *connection
             return DBUS_HANDLER_RESULT_NEED_MEMORY; /* ?? */
         }
         if (strcmp(dbus_message_get_member(message), "add") == 0) {
+#ifdef DEBUG
             ErrorF("       we want to add a device!\n");
+#endif
             /* signature should be [ss][ss]... */
             while (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_ARRAY) {
                 option = (InputOption *)xcalloc(sizeof(InputOption), 1);
@@ -160,7 +164,9 @@ configMessage(DBusConnection *connection
             return DBUS_HANDLER_RESULT_HANDLED;
         }
         else if (strcmp(dbus_message_get_member(message), "remove") == 0) {
+#ifdef DEBUG
             ErrorF("        we want to remove a device!\n");
+#endif
             if (!dbus_message_get_args(message, &error, DBUS_TYPE_INT32,
                                        &deviceid, DBUS_TYPE_INVALID)) {
                 ErrorF("couldn't get args: %s %s\n", error.name, error.message);
@@ -172,7 +178,6 @@ configMessage(DBusConnection *connection
                 dbus_error_free(&error);
                 return DBUS_HANDLER_RESULT_HANDLED;
             }
-            ErrorF("pDev is %p\n", pDev);
             /* Call PIE here so we don't try to dereference a device that's
              * already been removed.  Technically there's still a small race
              * here, so we should ensure that SIGIO is blocked. */
@@ -200,56 +205,56 @@ configInitialise()
     dbus_error_init(&error);
     bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
     if (!bus || dbus_error_is_set(&error)) {
-        ErrorF("[dbus] some kind of error occurred: %s (%s)\n", error.name,
-                error.message);
         dbus_error_free(&error);
+        FatalError("[dbus] some kind of error occurred: %s (%s)\n", error.name,
+                   error.message);
         return;
     }
 
     if (!dbus_connection_get_unix_fd(bus, &configfd)) {
-        ErrorF("[dbus] couldn't get fd for bus\n");
         dbus_connection_close(bus);
         configfd = -1;
+        FatalError("[dbus] couldn't get fd for bus\n");
         return;
     }
 
     snprintf(busname, sizeof(busname), "org.x.config.display%d", atoi(display));
     if (!dbus_bus_request_name(bus, busname, 0, &error) ||
         dbus_error_is_set(&error)) {
-        ErrorF("[dbus] couldn't take over org.x.config: %s (%s)\n",
-               error.name, error.message);
         dbus_error_free(&error);
         dbus_connection_close(bus);
         configfd = -1;
+        FatalError("[dbus] couldn't take over org.x.config: %s (%s)\n",
+                   error.name, error.message);
         return;
     }
 
     /* blocks until we get a reply. */
     dbus_bus_add_match(bus, MATCH_RULE, &error);
     if (dbus_error_is_set(&error)) {
-        ErrorF("[dbus] couldn't match X.Org rule: %s (%s)\n", error.name,
-               error.message);
         dbus_error_free(&error);
         dbus_bus_release_name(bus, busname, &error);
         dbus_connection_close(bus);
         configfd = -1;
+        FatalError("[dbus] couldn't match X.Org rule: %s (%s)\n", error.name,
+                   error.message);
         return;
     }
 
     vtable.message_function = configMessage;
     snprintf(busobject, sizeof(busobject), "/org/x/config/%d", atoi(display));
     if (!dbus_connection_register_object_path(bus, busobject, &vtable, NULL)) {
-        ErrorF("[dbus] couldn't register object path\n");
         configfd = -1;
         dbus_bus_release_name(bus, busname, &error);
         dbus_bus_remove_match(bus, MATCH_RULE, &error);
         dbus_connection_close(bus);
-        configfd = -1;
+        FatalError("[dbus] couldn't register object path\n");
         return;
     }
+#ifdef DEBUG
     ErrorF("[dbus] registered object path %s\n", busobject);
-
     ErrorF("[dbus] registered and listening\n");
+#endif
 
     dbus_error_free(&error);
 
@@ -265,7 +270,6 @@ configFini()
 
     if (configConnection) {
         dbus_error_init(&error);
-        ErrorF("configFini being called\n");
         dbus_bus_remove_match(configConnection, MATCH_RULE, &error);
         dbus_bus_release_name(configConnection, busname, &error);
         dbus_connection_close(configConnection);
diff-tree 866ca1f929c95689bac9f0a0b3478f7b4d77214b (from 2b06c69c8feaf3bdc065635ee711efa45b3033b3)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 24 15:46:44 2006 +0300

    configure.ac: fix XF86VidMode test

diff --git a/configure.ac b/configure.ac
index 19ef8d1..1c30a22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1082,8 +1082,8 @@ if test "x$XORG" = xyes -o "x$XGL" = xye
 		AC_DEFINE(XF86MISC, 1, [Support XFree86 miscellaneous extensions])
 	fi
 
-	if test "x$XF86VIDMOE" = xauto; then
-		PKG_CHECK_MODULES(XF86VIDMODE, xf86vidmode, [DGA=yes], [DGA=no])
+	if test "x$XF86VIDMODE" = xauto; then
+		PKG_CHECK_MODULES(XF86VIDMODE, xf86vidmode, [XF86VIDMODE=yes], [XF86VIDMODE=no])
 	fi
 	if test "x$XF86VIDMODE" = xyes; then
 		XORG_MODULES="$XORG_MODULES xf86vidmodeproto"
diff-tree 2b06c69c8feaf3bdc065635ee711efa45b3033b3 (from 4adf9af313c9f63b6ad734e174efe1d36ddb5813)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 24 14:51:26 2006 +0300

    GKVE: pass correct arguments to XkbCopyKeymap
    Fix horrendous thinko.  Indicators now work perfectly.

diff --git a/dix/events.c b/dix/events.c
index 6372a20..581fa08 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4651,7 +4651,8 @@ int GetKeyboardValuatorEvents(xEvent *ev
                               int key_code, int num_valuators,
                               int *valuators) {
     int numEvents = 0, ms = 0, first_valuator = 0;
-    KeySym sym = pDev->key->curKeySyms.map[key_code * pDev->key->curKeySyms.mapWidth];
+    KeySym sym = pDev->key->curKeySyms.map[key_code *
+                                           pDev->key->curKeySyms.mapWidth];
     deviceKeyButtonPointer *kbp = NULL;
     deviceValuator *xv = NULL;
     KeyClassPtr ckeyc;
@@ -4778,7 +4779,8 @@ int GetKeyboardValuatorEvents(xEvent *ev
 #ifdef XKB
             if (!noXkbExtension && pDev->key->xkbInfo &&
                 pDev->key->xkbInfo->desc) {
-                if (!XkbCopyKeymap(pDev->key->xkbInfo, ckeyc->xkbInfo, True))
+                if (!XkbCopyKeymap(pDev->key->xkbInfo->desc,
+                                   ckeyc->xkbInfo->desc, True))
                     FatalError("Couldn't pivot keymap from device to core!\n");
             }
 #endif
diff-tree 4adf9af313c9f63b6ad734e174efe1d36ddb5813 (from parents)
Merge: 33af05d58f1f4f021036e9ce4b60fd76dbaebe73 67bd672c880869ef625ae0c0163c3ec1eba46abf
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 24 10:59:33 2006 +0300

    Merge branch 'master' into input-hotplug

diff-tree 33af05d58f1f4f021036e9ce4b60fd76dbaebe73 (from 6323a11d0db4d3cf0317af83f0362730142f5325)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Aug 23 19:05:50 2006 +0300

    XkbCopyKeymap: use correct range for MapNotify
    We haven't copied {min,max}_key_code by the time the notifies run, so use
    src instead of dst to determine number of keys, et al.

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index da790f9..74799e8 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1418,20 +1418,20 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
                 mn.minKeyCode = src->min_key_code;
                 mn.maxKeyCode = src->max_key_code;
                 mn.firstType = 0;
-                mn.nTypes = dst->map->num_types;
-                mn.firstKeySym = dst->min_key_code;
-                mn.nKeySyms = XkbNumKeys(dst);
-                mn.firstKeyAct = dst->min_key_code;
-                mn.nKeyActs = XkbNumKeys(dst);
+                mn.nTypes = src->map->num_types;
+                mn.firstKeySym = src->min_key_code;
+                mn.nKeySyms = XkbNumKeys(src);
+                mn.firstKeyAct = src->min_key_code;
+                mn.nKeyActs = XkbNumKeys(src);
                 /* Cargo-culted from ProcXkbGetMap. */
-                mn.firstKeyBehavior = dst->min_key_code;
-                mn.nKeyBehaviors = XkbNumKeys(dst);
-                mn.firstKeyExplicit = dst->min_key_code;
-                mn.nKeyExplicit = XkbNumKeys(dst);
-                mn.firstModMapKey = dst->min_key_code;
-                mn.nModMapKeys = XkbNumKeys(dst);
-                mn.firstVModMapKey = dst->min_key_code;
-                mn.nVModMapKeys = XkbNumKeys(dst);
+                mn.firstKeyBehavior = src->min_key_code;
+                mn.nKeyBehaviors = XkbNumKeys(src);
+                mn.firstKeyExplicit = src->min_key_code;
+                mn.nKeyExplicit = XkbNumKeys(src);
+                mn.firstModMapKey = src->min_key_code;
+                mn.nModMapKeys = XkbNumKeys(src);
+                mn.firstVModMapKey = src->min_key_code;
+                mn.nVModMapKeys = XkbNumKeys(src);
                 mn.virtualMods = ~0; /* ??? */
                 mn.changed = XkbAllMapComponentsMask;                
                 XkbSendMapNotify(pDev, &mn);
diff-tree 6323a11d0db4d3cf0317af83f0362730142f5325 (from 728fbadd16a748b45c80bc2c65c46f82cf803578)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Aug 23 18:53:04 2006 +0300

    XkbCopyKeymap: optionally send NewKeyboardNotify/MapNotify events
    Optionally send a NewKeyboardNotify or MapNotify event when copying the
    keymap; modify GetKeyboardValuatorEvents to make use of this.

diff --git a/dix/events.c b/dix/events.c
index 808694d..6372a20 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4655,9 +4655,6 @@ int GetKeyboardValuatorEvents(xEvent *ev
     deviceKeyButtonPointer *kbp = NULL;
     deviceValuator *xv = NULL;
     KeyClassPtr ckeyc;
-#ifdef XKB
-    xkbMapNotify mn;
-#endif
 
     if (!events)
         return 0;
@@ -4781,28 +4778,7 @@ int GetKeyboardValuatorEvents(xEvent *ev
 #ifdef XKB
             if (!noXkbExtension && pDev->key->xkbInfo &&
                 pDev->key->xkbInfo->desc) {
-                mn.deviceID = inputInfo.keyboard->id;
-                mn.minKeyCode = pDev->key->xkbInfo->desc->min_key_code;
-                mn.maxKeyCode = pDev->key->xkbInfo->desc->max_key_code;
-                mn.firstType = 0;
-                mn.nTypes = pDev->key->xkbInfo->desc->map->num_types;
-                mn.firstKeySym = pDev->key->xkbInfo->desc->min_key_code;
-                mn.nKeySyms = XkbNumKeys(pDev->key->xkbInfo->desc);
-                mn.firstKeyAct = pDev->key->xkbInfo->desc->min_key_code;
-                mn.nKeyActs = XkbNumKeys(pDev->key->xkbInfo->desc);
-                /* Cargo-culted from ProcXkbGetMap. */
-                mn.firstKeyBehavior = pDev->key->xkbInfo->desc->min_key_code;
-                mn.nKeyBehaviors = XkbNumKeys(pDev->key->xkbInfo->desc);
-                mn.firstKeyExplicit = pDev->key->xkbInfo->desc->min_key_code;
-                mn.nKeyExplicit = XkbNumKeys(pDev->key->xkbInfo->desc);
-                mn.firstModMapKey = pDev->key->xkbInfo->desc->min_key_code;
-                mn.nModMapKeys = XkbNumKeys(pDev->key->xkbInfo->desc);
-                mn.firstVModMapKey = pDev->key->xkbInfo->desc->min_key_code;
-                mn.nVModMapKeys = XkbNumKeys(pDev->key->xkbInfo->desc);
-                mn.virtualMods = ~0; /* ??? */
-                mn.changed = XkbAllMapComponentsMask;
-                
-                if (!XkbCopyKeymap(pDev->key->xkbInfo, ckeyc->xkbInfo))
+                if (!XkbCopyKeymap(pDev->key->xkbInfo, ckeyc->xkbInfo, True))
                     FatalError("Couldn't pivot keymap from device to core!\n");
             }
 #endif
diff --git a/xkb/xkb.h b/xkb/xkb.h
index a85df8e..2be4258 100644
--- a/xkb/xkb.h
+++ b/xkb/xkb.h
@@ -75,4 +75,5 @@ extern Bool XkbDDXCompileKeymapByNames(
 
 extern Bool XkbCopyKeymap(
     XkbDescPtr              src,
-    XkbDescPtr              dst);
+    XkbDescPtr              dst,
+    Bool                    sendNotifies);
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 4fa5369..da790f9 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -985,13 +985,16 @@ XkbConvertCase(register KeySym sym, KeyS
  * to remain valid, but part of the map may be from src and part from dst.
  */
 Bool
-XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst)
+XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst, Bool sendNotifies)
 {
     int i = 0, j = 0;
     void *tmp = NULL;
     XkbKeyTypePtr stype = NULL, dtype = NULL;
+    DeviceIntPtr pDev = NULL, tmpDev = NULL;
+    xkbMapNotify mn;
+    xkbNewKeyboardNotify nkn;
 
-    if (!src || !dst)
+    if (!src || !dst || src == dst)
         return FALSE;
 
     /* client map */
@@ -1368,6 +1371,74 @@ XkbCopyKeymap(XkbDescPtr src, XkbDescPtr
         }
     }
 
+    if (inputInfo.keyboard->key->xkbInfo &&
+        inputInfo.keyboard->key->xkbInfo->desc == dst) {
+        pDev = inputInfo.keyboard;
+    }
+    else {
+        for (tmpDev = inputInfo.devices; tmpDev && !pDev;
+             tmpDev = tmpDev->next) {
+            if (tmpDev->key && tmpDev->key->xkbInfo &&
+                tmpDev->key->xkbInfo->desc == dst) {
+                pDev = tmpDev;
+                break;
+            }
+        }
+        for (tmpDev = inputInfo.off_devices; tmpDev && !pDev;
+             tmpDev = tmpDev->next) {
+            if (tmpDev->key && tmpDev->key->xkbInfo &&
+                tmpDev->key->xkbInfo->desc == dst) {
+                pDev = tmpDev;
+                break;
+            }
+        }
+    }
+
+    if (sendNotifies) {
+        if (!pDev) {
+            ErrorF("XkbCopyKeymap: asked for notifies, but can't find device!\n");
+        }
+        else {
+            /* send NewKeyboardNotify if the keycode range changed, else
+             * just MapNotify. */
+            if (src->min_key_code != dst->min_key_code ||
+                src->max_key_code != dst->max_key_code && sendNotifies) {
+                nkn.oldMinKeyCode = dst->min_key_code;
+                nkn.oldMaxKeyCode = dst->max_key_code;
+                nkn.deviceID = nkn.oldDeviceID = pDev->id;
+                nkn.minKeyCode = src->min_key_code;
+                nkn.maxKeyCode = src->max_key_code;
+                nkn.requestMajor = XkbReqCode;
+                nkn.requestMinor = X_kbSetMap; /* XXX bare-faced lie */
+                nkn.changed = XkbAllNewKeyboardEventsMask;
+                XkbSendNewKeyboardNotify(pDev, &nkn);
+            }
+            else if (sendNotifies) {
+                mn.deviceID = pDev->id;
+                mn.minKeyCode = src->min_key_code;
+                mn.maxKeyCode = src->max_key_code;
+                mn.firstType = 0;
+                mn.nTypes = dst->map->num_types;
+                mn.firstKeySym = dst->min_key_code;
+                mn.nKeySyms = XkbNumKeys(dst);
+                mn.firstKeyAct = dst->min_key_code;
+                mn.nKeyActs = XkbNumKeys(dst);
+                /* Cargo-culted from ProcXkbGetMap. */
+                mn.firstKeyBehavior = dst->min_key_code;
+                mn.nKeyBehaviors = XkbNumKeys(dst);
+                mn.firstKeyExplicit = dst->min_key_code;
+                mn.nKeyExplicit = XkbNumKeys(dst);
+                mn.firstModMapKey = dst->min_key_code;
+                mn.nModMapKeys = XkbNumKeys(dst);
+                mn.firstVModMapKey = dst->min_key_code;
+                mn.nVModMapKeys = XkbNumKeys(dst);
+                mn.virtualMods = ~0; /* ??? */
+                mn.changed = XkbAllMapComponentsMask;                
+                XkbSendMapNotify(pDev, &mn);
+            }
+        }
+    }
+
     dst->min_key_code = src->min_key_code;
     dst->max_key_code = src->max_key_code;
 
diff-tree 728fbadd16a748b45c80bc2c65c46f82cf803578 (from 8f8487ff997670a4af0293fed77ff920cfc39fb1)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Aug 23 14:33:59 2006 +0300

    gitignore: ignore vi swap files

diff --git a/.gitignore b/.gitignore
index 4118cd0..62b5fd6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -267,3 +267,4 @@ mfb/mfbteblack.c
 mfb/mfbtewhite.c
 mfb/mfbtileC.c
 mfb/mfbtileG.c
+.*.swp
diff-tree 8f8487ff997670a4af0293fed77ff920cfc39fb1 (from a56b98bb047003a05e26ca9365c212a2da7ac200)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Aug 23 14:33:41 2006 +0300

    xkb/gkve: copy XKB map, not pointer-assign
    Write a new function to copy an XKB map (does everything but geometry at
    the moment), and use that instead of nasty pointer assignments.

diff --git a/dix/devices.c b/dix/devices.c
index 773b301..60c2d29 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -260,16 +260,6 @@ CoreKeyboardProc(DeviceIntPtr pDev, int 
         break;
 
     case DEVICE_CLOSE:
-        /* This, uh, probably requires some explanation.
-         * Press a key on another keyboard.
-         * Watch its xkbInfo get pivoted into core's.
-         * Kill the server.
-         * Watch the first device's xkbInfo get freed.
-         * Try to free ours, which points to same.
-         *
-         * ... yeah.
-         */
-        pDev->key->xkbInfo = NULL;
         pDev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
         break;
 
diff --git a/dix/events.c b/dix/events.c
index 47c52d1..808694d 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4802,14 +4802,8 @@ int GetKeyboardValuatorEvents(xEvent *ev
                 mn.virtualMods = ~0; /* ??? */
                 mn.changed = XkbAllMapComponentsMask;
                 
-                /* If this is still the map we set at DEVICE_INIT, free it so
-                 * it doesn't just get lost.  (Shameful hack, sorry.) */
-                if (!inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr &&
-                    ckeyc->xkbInfo)
-                    XkbFreeInfo(ckeyc->xkbInfo);
-                /* FIXME we really need a map copy here. */
-                ckeyc->xkbInfo = pDev->key->xkbInfo;
-                XkbSendMapNotify(inputInfo.keyboard, &mn);
+                if (!XkbCopyKeymap(pDev->key->xkbInfo, ckeyc->xkbInfo))
+                    FatalError("Couldn't pivot keymap from device to core!\n");
             }
 #endif
             SendMappingNotify(MappingKeyboard, ckeyc->curKeySyms.minKeyCode,
diff --git a/xkb/xkb.h b/xkb/xkb.h
index 156608e..a85df8e 100644
--- a/xkb/xkb.h
+++ b/xkb/xkb.h
@@ -72,3 +72,7 @@ extern Bool XkbDDXCompileKeymapByNames(
     unsigned                need,
     char *                  nameRtrn,
     int                     nameRtrnLen);
+
+extern Bool XkbCopyKeymap(
+    XkbDescPtr              src,
+    XkbDescPtr              dst);
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index ee0abbe..4fa5369 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -969,3 +969,407 @@ XkbConvertCase(register KeySym sym, KeyS
         break;
     }
 }
+
+
+/**
+ * Copy an XKB map from src to dst, reallocating when necessary: if some
+ * map components are present in one, but not in the other, the destination
+ * components will be allocated or freed as necessary.
+ *
+ * Basic map consistency is assumed on both sides, so maps with random
+ * uninitialised data (e.g. names->radio_grous == NULL, names->num_rg == 19)
+ * _will_ cause failures.  You've been warned.
+ *
+ * Returns TRUE on success, or FALSE on failure.  If this function fails,
+ * dst may be in an inconsistent state: all its pointers are guaranteed
+ * to remain valid, but part of the map may be from src and part from dst.
+ */
+Bool
+XkbCopyKeymap(XkbDescPtr src, XkbDescPtr dst)
+{
+    int i = 0, j = 0;
+    void *tmp = NULL;
+    XkbKeyTypePtr stype = NULL, dtype = NULL;
+
+    if (!src || !dst)
+        return FALSE;
+
+    /* client map */
+    if (src->map) {
+        if (!dst->map) {
+            tmp = xcalloc(1, sizeof(XkbClientMapRec));
+            if (!tmp)
+                return FALSE;
+            dst->map = tmp;
+        }
+
+        if (src->map->syms) {
+            if (src->map->size_syms != dst->map->size_syms) {
+                if (dst->map->syms)
+                    tmp = xrealloc(dst->map->syms, src->map->size_syms);
+                else
+                    tmp = xalloc(src->map->size_syms);
+                if (!tmp)
+                    return FALSE;
+                dst->map->syms = tmp;
+            }
+            memcpy(dst->map->syms, src->map->syms, src->map->size_syms);
+            memcpy(dst->map->key_sym_map, src->map->key_sym_map,
+                   src->map->size_syms);
+        }
+        else {
+            if (dst->map->syms) {
+                xfree(dst->map->syms);
+                dst->map->syms = NULL;
+            }
+        }
+        dst->map->num_syms = src->map->num_syms;
+        dst->map->size_syms = src->map->size_syms;
+
+        if (src->map->types) {
+            if (src->map->size_types != dst->map->size_types) {
+                XkbKeyTypePtr stype = src->map->types;
+
+                if (dst->map->types)
+                    tmp = xrealloc(dst->map->types, src->map->size_types);
+                else
+                    tmp = xalloc(src->map->size_types);
+                if (!tmp)
+                    return FALSE;
+                dst->map->types = tmp;
+            }
+            memcpy(dst->map->types, src->map->types, src->map->size_types);
+
+            stype = src->map->types;
+            dtype = dst->map->types;
+            for (i = 0; i < dst->map->num_types; i++, dtype++, stype++) {
+                dtype->level_names = xalloc(dtype->num_levels * sizeof(Atom));
+                if (!dtype->level_names)
+                    continue; /* don't return FALSE here, try to whack all the
+                                 pointers we can, so we don't double-free when
+                                 going down. */
+                memcpy(dtype->level_names, stype->level_names,
+                       dtype->num_levels * sizeof(Atom));
+            }
+        }
+        else {
+            if (dst->map->types) {
+                for (i = 0, dtype = dst->map->types; i < dst->map->num_types;
+                     i++, dtype++)
+                    xfree(dtype->level_names);
+                xfree(dst->map->types);
+                dst->map->types = NULL;
+            }
+        }
+        dst->map->size_types = src->map->size_types;
+        dst->map->num_types = src->map->num_types;
+
+        if (src->map->modmap) {
+            if (src->max_key_code != dst->max_key_code) {
+                if (dst->map->modmap)
+                    tmp = xrealloc(dst->map->modmap, src->max_key_code + 1);
+                else
+                    tmp = xalloc(src->max_key_code + 1);
+                if (!tmp)
+                    return FALSE;
+                dst->map->syms = tmp;
+            }
+            memcpy(dst->map->modmap, src->map->modmap, src->max_key_code + 1);
+        }
+        else {
+            if (dst->map->modmap) {
+                xfree(dst->map->modmap);
+                dst->map->modmap = NULL;
+            }
+        }
+    }
+    else {
+        if (dst->map)
+            XkbFreeClientMap(dst, XkbAllClientInfoMask, True);
+    }
+
+    /* server map */
+    if (src->server) {
+        if (!dst->server) {
+            tmp = xcalloc(1, sizeof(XkbServerMapRec));
+            if (!tmp)
+                return FALSE;
+            dst->server = tmp;
+        }
+
+        if (src->server->explicit) {
+            if (src->max_key_code != dst->max_key_code) {
+                if (dst->server->explicit)
+                    tmp = xrealloc(dst->server->explicit, src->max_key_code + 1);
+                else
+                    tmp = xalloc(src->max_key_code + 1);
+                if (!tmp)
+                    return FALSE;
+                dst->server->explicit = tmp;
+            }
+            memcpy(dst->server->explicit, src->server->explicit,
+                   src->max_key_code + 1);
+        }
+        else {
+            if (dst->server->explicit) {
+                xfree(dst->server->explicit);
+                dst->server->explicit = NULL;
+            }
+        }
+
+        if (src->server->acts) {
+            if (src->server->size_acts != dst->server->size_acts) {
+                if (dst->server->acts)
+                    tmp = xrealloc(dst->server->acts, src->server->size_acts);
+                else
+                    tmp = xalloc(src->server->size_acts);
+                if (!tmp)
+                    return FALSE;
+                dst->server->acts = tmp;
+            }
+            memcpy(dst->server->acts, src->server->acts,
+                   src->server->size_acts);
+        }
+        else {
+            if (dst->server->acts) {
+                xfree(dst->server->acts);
+                dst->server->acts = NULL;
+            }
+        }
+       dst->server->size_acts = src->server->size_acts;
+
+        if (src->server->key_acts) {
+            if (src->max_key_code != dst->max_key_code) {
+                if (dst->server->key_acts)
+                    tmp = xrealloc(dst->server->key_acts, src->max_key_code + 1);
+                else
+                    tmp = xalloc(src->max_key_code + 1);
+                if (!tmp)
+                    return FALSE;
+                dst->server->key_acts = tmp;
+            }
+            memcpy(dst->server->key_acts, src->server->key_acts,
+                   src->max_key_code + 1);
+        }
+        else {
+            if (dst->server->key_acts) {
+                xfree(dst->server->key_acts);
+                dst->server->key_acts = NULL;
+            }
+        }
+
+        if (src->server->behaviors) {
+            if (src->max_key_code != dst->max_key_code) {
+                if (dst->server->behaviors)
+                    tmp = xrealloc(dst->server->behaviors,
+                                   (src->max_key_code + 1) *
+                                   sizeof(XkbBehavior));
+                else
+                    tmp = xalloc((src->max_key_code + 1) *
+                                 sizeof(XkbBehavior));
+                if (!tmp)
+                    return FALSE;
+                dst->server->behaviors = tmp;
+            }
+            memcpy(dst->server->behaviors, src->server->behaviors,
+                   (src->max_key_code + 1) * sizeof(XkbBehavior));
+        }
+        else {
+            if (dst->server->behaviors) {
+                xfree(dst->server->behaviors);
+                dst->server->behaviors = NULL;
+            }
+        }
+
+        if (src->server->vmodmap) {
+            if (src->max_key_code != dst->max_key_code) {
+                if (dst->server->vmodmap)
+                    tmp = xrealloc(dst->server->vmodmap,
+                                   src->max_key_code + 1);
+                else
+                    tmp = xalloc(src->max_key_code + 1);
+                if (!tmp)
+                    return FALSE;
+                dst->server->vmodmap = tmp;
+            }
+            memcpy(dst->server->vmodmap, src->server->vmodmap,
+                   src->max_key_code + 1);
+        }
+        else {
+            if (dst->server->vmodmap) {
+                xfree(dst->server->vmodmap);
+                dst->server->vmodmap = NULL;
+            }
+        }
+    }
+    else {
+        if (dst->server)
+            XkbFreeServerMap(dst, XkbAllServerInfoMask, True);
+    }
+
+    /* indicators */
+    if (src->indicators) {
+        if (!dst->indicators) {
+            dst->indicators = xalloc(sizeof(XkbIndicatorRec));
+            if (!dst->indicators)
+                return FALSE;
+        }
+        memcpy(dst->indicators, src->indicators, sizeof(XkbIndicatorRec));
+    }
+    else {
+        if (dst->indicators) {
+            xfree(dst->indicators);
+            dst->indicators = NULL;
+        }
+    }
+
+    /* controls */
+    if (src->ctrls) {
+        if (!dst->ctrls) {
+            dst->ctrls = xalloc(sizeof(XkbControlsRec));
+            if (!dst->ctrls)
+                return FALSE;
+        }
+        memcpy(dst->ctrls, src->ctrls, sizeof(XkbControlsRec));
+    }
+    else {
+        if (dst->ctrls) {
+            xfree(dst->ctrls);
+            dst->ctrls = NULL;
+        }
+    }
+
+    /* names */
+    if (src->names) {
+        if (!dst->names) {
+            dst->names = xcalloc(1, sizeof(XkbNamesRec));
+            if (!dst->names)
+                return FALSE;
+        }
+
+        if (src->names->keys) {
+            if (src->max_key_code != dst->max_key_code) {
+                if (dst->names->keys)
+                    tmp = xrealloc(dst->names->keys, (src->max_key_code + 1) *
+                                   sizeof(XkbKeyNameRec));
+                else
+                    tmp = xalloc((src->max_key_code + 1) *
+                                 sizeof(XkbKeyNameRec));
+                if (!tmp)
+                    return FALSE;
+                dst->names->keys = tmp;
+            }
+            memcpy(dst->names->keys, src->names->keys,
+                   (src->max_key_code + 1) * sizeof(XkbKeyNameRec));
+        }
+        else {
+            if (dst->names->keys) {
+                xfree(dst->names->keys);
+                dst->names->keys = NULL;
+            }
+        }
+
+        if (src->names->num_key_aliases) {
+            if (src->names->num_key_aliases != dst->names->num_key_aliases) {
+                if (dst->names->key_aliases)
+                    tmp = xrealloc(dst->names->key_aliases,
+                                   src->names->num_key_aliases *
+                                     sizeof(XkbKeyAliasRec));
+                else
+                    tmp = xalloc(src->names->num_key_aliases *
+                                 sizeof(XkbKeyAliasRec));
+                if (!tmp)
+                    return FALSE;
+                dst->names->key_aliases = tmp;
+            }
+            memcpy(dst->names->key_aliases, src->names->key_aliases,
+                   src->names->num_key_aliases * sizeof(XkbKeyAliasRec));
+        }
+        else {
+            if (dst->names->key_aliases) {
+                xfree(dst->names->key_aliases);
+                dst->names->key_aliases = NULL;
+            }
+        }
+        dst->names->num_key_aliases = src->names->num_key_aliases;
+
+        if (src->names->num_rg) {
+            if (src->names->num_rg != dst->names->num_rg) {
+                if (dst->names->radio_groups)
+                    tmp = xrealloc(dst->names->radio_groups,
+                                   src->names->num_rg * sizeof(Atom));
+                else
+                    tmp = xalloc(src->names->num_rg * sizeof(Atom));
+                if (!tmp)
+                    return FALSE;
+                dst->names->radio_groups = tmp;
+            }
+            memcpy(dst->names->radio_groups, src->names->radio_groups,
+                   src->names->num_rg * sizeof(Atom));
+        }
+        else {
+            if (dst->names->radio_groups)
+                xfree(dst->names->radio_groups);
+        }
+        dst->names->num_rg = src->names->num_rg;
+    }
+    else {
+        if (dst->names)
+            XkbFreeNames(dst, XkbAllNamesMask, True);
+    }
+
+    /* compat */
+    if (src->compat) {
+        if (src->compat->sym_interpret) {
+            if (src->compat->num_si != dst->compat->num_si) {
+                if (dst->compat->sym_interpret)
+                    tmp = xrealloc(dst->compat->sym_interpret,
+                                   src->compat->num_si *
+                                     sizeof(XkbSymInterpretRec));
+                else
+                    tmp = xalloc(src->compat->num_si *
+                                 sizeof(XkbSymInterpretRec));
+                if (!tmp)
+                    return FALSE;
+                dst->compat->sym_interpret = tmp;
+            }
+            memcpy(dst->compat->sym_interpret, src->compat->sym_interpret,
+                   src->compat->num_si * sizeof(XkbSymInterpretRec));
+        }
+        else {
+            if (dst->compat->sym_interpret) {
+                xfree(dst->compat->sym_interpret);
+                dst->compat->sym_interpret = NULL;
+            }
+        }
+        dst->compat->num_si = src->compat->num_si;
+
+        memcpy(dst->compat->groups, src->compat->groups,
+               XkbNumKbdGroups * sizeof(XkbModsRec));
+    }
+    else {
+        if (dst->compat)
+            XkbFreeCompatMap(dst, XkbAllCompatMask, True);
+    }
+
+    /* geometry */
+    if (src->geom) {
+        /* properties */
+        /* colors */
+        /* shapes */
+        /* sections */
+        /* doodads */
+        /* key aliases */
+        /* font?!? */
+    }
+    else {
+        if (dst->geom) {
+            XkbFreeGeometry(dst->geom, XkbGeomAllMask, True);
+        }
+    }
+
+    dst->min_key_code = src->min_key_code;
+    dst->max_key_code = src->max_key_code;
+
+    return TRUE;
+}
diff-tree a56b98bb047003a05e26ca9365c212a2da7ac200 (from 0704bb298cc826cd117815898c6bc015a693c2c9)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Fri Aug 18 18:03:41 2006 +0300

    dix: enable null root cursor
    
    Enable a blank root cursor, selectable with --enable-null-root-cursor at
    configure time.

diff --git a/configure.ac b/configure.ac
index e68021d..19ef8d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -396,6 +396,9 @@ AC_ARG_ENABLE(install-libxf86config,
 AC_ARG_ENABLE(builtin-fonts,  AS_HELP_STRING([--enable-builtin-fonts], [Use only built-in fonts (default: use external)]),
                                 [BUILTIN_FONTS=$enableval],
                                 [BUILTIN_FONTS=no])
+AC_ARG_ENABLE(null-root-cursor, AS_HELP_STRING([--enable-null-root-cursor], [Use an empty root cursor (default: use core cursor)]),
+                                 [NULL_ROOT_CURSOR=$enableval],
+                                 [NULL_ROOT_CURSOR=no])
 
 dnl Extensions.
 AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
@@ -745,6 +748,10 @@ XKB_STUB_LIB='$(top_builddir)/xkb/libxkb
 AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1,
                                         [Do not have `strcasecmp'.]))
 
+if test "x$NULL_ROOT_CURSOR" = xyes; then
+        AC_DEFINE(NULL_ROOT_CURSOR, 1, [Use an empty root cursor])
+fi
+
 PKG_CHECK_MODULES([XDMCP], [xdmcp], [have_libxdmcp="yes"], [have_libxdmcp="no"])
 if test "x$have_libxdmcp" = xyes; then
 	AC_CHECK_LIB(Xdmcp, XdmcpWrap, [have_xdmcpwrap="yes"], [have_xdmcpwrap="no"], [$XDMCP_LIBS])
diff --git a/dix/main.c b/dix/main.c
index 7449c5a..f2e494e 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -249,6 +249,7 @@ main(int argc, char *argv[], char *envp[
     int		i, j, k, error;
     char	*xauthfile;
     HWEventQueueType	alwaysCheckForInput[2];
+    CursorMetricRec cm;
 
     display = "0";
 
@@ -415,9 +416,20 @@ main(int argc, char *argv[], char *envp[
 	}
 	if (!SetDefaultFont(defaultTextFont))
 	    FatalError("could not open default font '%s'", defaultTextFont);
+#ifdef NULL_ROOT_CURSOR
+        cm.width = 0;
+        cm.height = 0;
+        cm.xhot = 0;
+        cm.yhot = 0;
+
+        if (!(rootCursor = AllocCursor(NULL, NULL, &cm, 0, 0, 0, 0, 0, 0)))
+            FatalError("could not create empty root cursor");
+        AddResource(FakeClientID(0), RT_CURSOR, (pointer)rootCursor);
+#else
 	if (!(rootCursor = CreateRootCursor(defaultCursorFont, 0)))
 	    FatalError("could not open default cursor font '%s'",
 		       defaultCursorFont);
+#endif
 #ifdef DPMSExtension
  	/* check all screens, looking for DPMS Capabilities */
  	DPMSCapableFlag = DPMSSupported();
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 2cf9eaf..2e05e04 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -445,4 +445,7 @@
 /* Avoid using font servers */
 #undef NOFONTSERVERACCESS
 
+/* Use an empty root cursor */
+#undef NULL_ROOT_CURSOR
+
 #endif /* _DIX_CONFIG_H_ */
diff-tree 0704bb298cc826cd117815898c6bc015a693c2c9 (from parents)
Merge: c14036977fef7b8787c0b68f5262fa0b6a2834f5 a1ac0440bba690368aa4226468ce571be1a09d95
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Aug 18 17:30:14 2006 +0300

    Merge branch 'master' into input-hotplug

diff-tree c14036977fef7b8787c0b68f5262fa0b6a2834f5 (from 1c2cb30cd88ba4453f9da339025f8ff39f7f5412)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Aug 18 17:24:34 2006 +0300

    input.h: add InitCoreDevices prototype

diff --git a/include/input.h b/include/input.h
index 6572db5..6573a1f 100644
--- a/include/input.h
+++ b/include/input.h
@@ -167,6 +167,8 @@ typedef struct _InputOption {
     struct _InputOption *next;
 } InputOption;
 
+extern void InitCoreDevices(void);
+
 extern DeviceIntPtr AddInputDevice(
     DeviceProc /*deviceProc*/,
     Bool /*autoStart*/);
diff-tree 1c2cb30cd88ba4453f9da339025f8ff39f7f5412 (from parents)
Merge: 633b6a69f560c0a77dcff78fdef5fcf0041e2e04 70ddd0f39d5118db72a1a4e473cbfb502f1ed9ec
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Aug 18 17:05:50 2006 +0300

    Merge branch 'origin' into input-hotplug

diff-tree 633b6a69f560c0a77dcff78fdef5fcf0041e2e04 (from parents)
Merge: 95dbfcf8828c041c218145afc87d21a6c9c7bc02 7da51447eaab34292e14077fb5a48e6b2e587781
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 17 21:25:14 2006 +0300

    Merge branch 'master' into input-hotplug

diff-tree 95dbfcf8828c041c218145afc87d21a6c9c7bc02 (from c6c39afde3e5f43b623ca6b52162b83c98a28d45)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 17 21:18:18 2006 +0300

    events.c: make XEvIE a little less verbose
    Change a lot of:
     #ifdef XEVIE
     xeviehot.x =
     #endif
     sprite.hot.x = ...
     #ifdef XEVIE
     xeviehot.y =
     #endif
     sprite.hot.y = ...
    to one single
     #ifdef XEVIE
     xeviehot.x = sprite.hot.x;
     xeviehot.y = sprite.hot.y;
     #endif
    at the end of the functions.

diff --git a/dix/events.c b/dix/events.c
index 781e467..f7eacf6 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -462,13 +462,7 @@ XineramaCheckVirtualMotion(
     if (qe)
     {
 	sprite.hot.pScreen = qe->pScreen;  /* should always be Screen 0 */
-#ifdef XEVIE
-	xeviehot.x =
-#endif
 	sprite.hot.x = qe->event->u.keyButtonPointer.rootX;
-#ifdef XEVIE
-	xeviehot.y =
-#endif
 	sprite.hot.y = qe->event->u.keyButtonPointer.rootY;
 	pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo :
 					 NullWindow;
@@ -505,24 +499,12 @@ XineramaCheckVirtualMotion(
 	lims = *REGION_EXTENTS(sprite.screen, &sprite.Reg2);
 
         if (sprite.hot.x < lims.x1)
-#ifdef XEVIE
-	    xeviehot.x =
-#endif
             sprite.hot.x = lims.x1;
         else if (sprite.hot.x >= lims.x2)
-#ifdef XEVIE
-	    xeviehot.x =
-#endif
             sprite.hot.x = lims.x2 - 1;
         if (sprite.hot.y < lims.y1)
-#ifdef XEVIE
-	    xeviehot.y =
-#endif
             sprite.hot.y = lims.y1;
         else if (sprite.hot.y >= lims.y2)
-#ifdef XEVIE
-	    xeviehot.y =
-#endif
             sprite.hot.y = lims.y2 - 1;
 
 	if (REGION_NUM_RECTS(&sprite.Reg2) > 1) 
@@ -535,6 +517,10 @@ XineramaCheckVirtualMotion(
 	    qe->event->u.keyButtonPointer.rootY = sprite.hot.y;
 	}
     }
+#ifdef XEVIE
+    xeviehot.x = sprite.hot.x;
+    xeviehot.y = sprite.hot.y;
+#endif
 }
 
 
@@ -552,33 +538,15 @@ XineramaCheckMotion(xEvent *xE)
 			  panoramiXdataPtr[0].x;
 	XE_KBPTR.rootY += panoramiXdataPtr[sprite.screen->myNum].y -
 			  panoramiXdataPtr[0].y;
-#ifdef XEVIE
-	xeviehot.x =
-#endif
 	sprite.hot.x = XE_KBPTR.rootX;
-#ifdef XEVIE
-	xeviehot.y =
-#endif
 	sprite.hot.y = XE_KBPTR.rootY;
 	if (sprite.hot.x < sprite.physLimits.x1)
-#ifdef XEVIE
-	    xeviehot.x =
-#endif
 	    sprite.hot.x = sprite.physLimits.x1;
 	else if (sprite.hot.x >= sprite.physLimits.x2)
-#ifdef XEVIE
-	    xeviehot.x =
-#endif
 	    sprite.hot.x = sprite.physLimits.x2 - 1;
 	if (sprite.hot.y < sprite.physLimits.y1)
-#ifdef XEVIE
-	    xeviehot.y =
-#endif
 	    sprite.hot.y = sprite.physLimits.y1;
 	else if (sprite.hot.y >= sprite.physLimits.y2)
-#ifdef XEVIE
-	    xeviehot.y =
-#endif
 	    sprite.hot.y = sprite.physLimits.y2 - 1;
 
 	if (sprite.hotShape) 
@@ -596,6 +564,8 @@ XineramaCheckMotion(xEvent *xE)
     }
 
 #ifdef XEVIE
+    xeviehot.x = sprite.hot.x;
+    xeviehot.y = sprite.hot.y;
     xeviewin =
 #endif
     sprite.win = XYToWindow(sprite.hot.x, sprite.hot.y);
@@ -821,13 +791,7 @@ CheckVirtualMotion(
     if (qe)
     {
 	sprite.hot.pScreen = qe->pScreen;
-#ifdef XEVIE
-	xeviehot.x =
-#endif
 	sprite.hot.x = qe->event->u.keyButtonPointer.rootX;
-#ifdef XEVIE
-	xeviehot.y =
-#endif
 	sprite.hot.y = qe->event->u.keyButtonPointer.rootY;
 	pWin = inputInfo.pointer->grab ? inputInfo.pointer->grab->confineTo :
 					 NullWindow;
@@ -839,31 +803,16 @@ CheckVirtualMotion(
 	if (sprite.hot.pScreen != pWin->drawable.pScreen)
 	{
 	    sprite.hot.pScreen = pWin->drawable.pScreen;
-#ifdef XEVIE
-	    xeviehot.x = xeviehot.y = 0;
-#endif
 	    sprite.hot.x = sprite.hot.y = 0;
 	}
 	lims = *REGION_EXTENTS(pWin->drawable.pScreen, &pWin->borderSize);
 	if (sprite.hot.x < lims.x1)
-#ifdef XEVIE
-	    xeviehot.x =
-#endif
 	    sprite.hot.x = lims.x1;
 	else if (sprite.hot.x >= lims.x2)
-#ifdef XEVIE
-	    xeviehot.x =
-#endif
 	    sprite.hot.x = lims.x2 - 1;
 	if (sprite.hot.y < lims.y1)
-#ifdef XEVIE
-	    xeviehot.y =
-#endif
 	    sprite.hot.y = lims.y1;
 	else if (sprite.hot.y >= lims.y2)
-#ifdef XEVIE
-	    xeviehot.y =
-#endif
 	    sprite.hot.y = lims.y2 - 1;
 #ifdef SHAPE
 	if (wBoundingShape(pWin))
@@ -876,6 +825,10 @@ CheckVirtualMotion(
 	    qe->event->u.keyButtonPointer.rootY = sprite.hot.y;
 	}
     }
+#ifdef XEVIE
+    xeviehot.x = sprite.hot.x;
+    xeviehot.y = sprite.hot.y;
+#endif
     ROOT = WindowTable[sprite.hot.pScreen->myNum];
 }
 
@@ -2057,34 +2010,20 @@ CheckMotion(xEvent *xE)
 	    sprite.hot.pScreen = sprite.hotPhys.pScreen;
 	    ROOT = WindowTable[sprite.hot.pScreen->myNum];
 	}
-#ifdef XEVIE
-	xeviehot.x =
-#endif
 	sprite.hot.x = XE_KBPTR.rootX;
-#ifdef XEVIE
-	xeviehot.y =
-#endif
 	sprite.hot.y = XE_KBPTR.rootY;
 	if (sprite.hot.x < sprite.physLimits.x1)
-#ifdef XEVIE
-	    xeviehot.x =
-#endif
 	    sprite.hot.x = sprite.physLimits.x1;
 	else if (sprite.hot.x >= sprite.physLimits.x2)
-#ifdef XEVIE
-	    xeviehot.x =
-#endif
 	    sprite.hot.x = sprite.physLimits.x2 - 1;
 	if (sprite.hot.y < sprite.physLimits.y1)
-#ifdef XEVIE
-	    xeviehot.y =
-#endif
 	    sprite.hot.y = sprite.physLimits.y1;
 	else if (sprite.hot.y >= sprite.physLimits.y2)
+	    sprite.hot.y = sprite.physLimits.y2 - 1;
 #ifdef XEVIE
-	    xeviehot.y =
+        xeviehot.x = sprite.hot.x;
+        xeviehot.y = sprite.hot.y;
 #endif
-	    sprite.hot.y = sprite.physLimits.y2 - 1;
 #ifdef SHAPE
 	if (sprite.hotShape)
 	    ConfineToShape(sprite.hotShape, &sprite.hot.x, &sprite.hot.y);
diff-tree c6c39afde3e5f43b623ca6b52162b83c98a28d45 (from f9624e0109cf12b6af43fb4235aaa0b54340a4bb)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 17 21:13:09 2006 +0300

    dix/events.c: add YAFIXME
    Add another FIXME to the cacaphony of XXX and FIXMEs in this file.

diff --git a/dix/events.c b/dix/events.c
index 571a576..781e467 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4868,6 +4868,7 @@ int GetKeyboardValuatorEvents(xEvent *ev
                 if (!inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr &&
                     ckeyc->xkbInfo)
                     XkbFreeInfo(ckeyc->xkbInfo);
+                /* FIXME we really need a map copy here. */
                 ckeyc->xkbInfo = pDev->key->xkbInfo;
                 XkbSendMapNotify(inputInfo.keyboard, &mn);
             }
diff-tree f9624e0109cf12b6af43fb4235aaa0b54340a4bb (from cd3f744b1f983f71476db99c050045d981c5f5b2)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 17 16:09:51 2006 +0300

    kdrive/input: verify SIGIO with --enable-debug

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 68afd28..a41fddb 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -131,8 +131,7 @@ KdUnblockSigio (void)
     sigprocmask (SIG_UNBLOCK, &set, 0);
 }
 
-#undef VERIFY_SIGIO
-#ifdef VERIFY_SIGIO
+#ifdef DEBUG
 
 void
 KdAssertSigioBlocked (char *where)
diff-tree cd3f744b1f983f71476db99c050045d981c5f5b2 (from 5d073697adb3864133fa3221b82ab8d2f4a59758)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Aug 15 15:54:13 2006 +0300

    fix missing brace, trim unused variables

diff --git a/dix/events.c b/dix/events.c
index 6eb1257..571a576 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4711,11 +4711,10 @@ GetKeyboardEvents(xEvent *events, Device
 int GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
                               int key_code, int num_valuators,
                               int *valuators) {
-    int numEvents = 0, numRepeatEvents = 0, ms = 0, first_valuator = 0, i = 0;
+    int numEvents = 0, ms = 0, first_valuator = 0;
     KeySym sym = pDev->key->curKeySyms.map[key_code * pDev->key->curKeySyms.mapWidth];
     deviceKeyButtonPointer *kbp = NULL;
     deviceValuator *xv = NULL;
-    xEvent *repeatEvents = NULL;
     KeyClassPtr ckeyc;
 #ifdef XKB
     xkbMapNotify mn;
@@ -4779,6 +4778,7 @@ int GetKeyboardValuatorEvents(xEvent *ev
                                                    num_valuators, valuators);
             events += numEvents;
         }
+    }
     
 
     ms = GetTimeInMillis();
@@ -4960,7 +4960,6 @@ GetPointerEvents(xEvent *events, DeviceI
     deviceKeyButtonPointer *kbp = NULL;
     deviceValuator *xv = NULL;
     AxisInfoPtr axes = NULL;
-    xEvent *ev = NULL;
     Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
     DeviceIntPtr cp = inputInfo.pointer;
 
diff-tree 5d073697adb3864133fa3221b82ab8d2f4a59758 (from 47c1c948e69cfba950ad37a3133fa2db0bd0ff2c)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Aug 15 15:37:10 2006 +0300

    kdrive/input: minor warning cleanups
    And also a compiler error fix when VERIFY_SIGIO is defined.

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 278bbf7..68afd28 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -143,7 +143,7 @@ KdAssertSigioBlocked (char *where)
     sigprocmask (SIG_BLOCK, &set, &old);
     if (!sigismember (&old, SIGIO)) {
 	ErrorF ("SIGIO not blocked at %s\n", where);
-        KdBacktrace();
+        KdBacktrace(0);
     }
 }
 
@@ -387,7 +387,6 @@ static int
 KdPointerProc(DeviceIntPtr pDevice, int onoff)
 {
     DevicePtr       pDev = (DevicePtr)pDevice;
-    int             i;
     KdPointerInfo   *pi;
 #ifdef XINPUT
     Atom            xiclass;
@@ -716,9 +715,6 @@ KdKeyboardProc(DeviceIntPtr pDevice, int
     Bool        ret;
     DevicePtr   pDev = (DevicePtr)pDevice;
     KdKeyboardInfo *ki;
-#ifdef XKB
-    XkbComponentNamesRec names;
-#endif
 #ifdef XINPUT
     Atom xiclass;
 #endif
@@ -1254,7 +1250,6 @@ KdInitInput (void)
     KdPointerInfo *pi;
     KdKeyboardInfo *ki;
     struct KdConfigDevice *dev;
-    int i = 0;
 
     kdInputEnabled = TRUE;
 
diff-tree 47c1c948e69cfba950ad37a3133fa2db0bd0ff2c (from 34228d8b280ef105a0c60b8de5dacf70a5ce24b5)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Aug 15 15:25:16 2006 +0300

    kdrive/input: only run special key behaviours on non-XKB
    Only attempt to manually deal with special key behaviours (e.g. terminating
    the server) when not using XKB, and leave locking behaviour up to GKVE.

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index fc4592a..278bbf7 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1927,23 +1927,14 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo   
 	else
 	    type = KeyPress;
 	
-        /* HRNGH */
-	switch (KEYCOL1(ki, key_code)) 
-	{
-	case XK_Num_Lock:
-	case XK_Scroll_Lock:
-	case XK_Shift_Lock:
-	case XK_Caps_Lock:
-	    if (type == KeyRelease)
-		return;
-	    if (IsKeyDown (ki, key_code))
-		type = KeyRelease;
-	    else
-		type = KeyPress;
+#ifdef XKB
+        if (noXkbExtension)
+#endif
+        {
+            KdCheckSpecialKeys(ki, type, key_code);
+            KdHandleKeyboardEvent(ki, type, key_code);
 	}
 	
-        KdCheckSpecialKeys(ki, type, key_code);
-        KdHandleKeyboardEvent(ki, type, key_code);
         nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, type, key_code);
 #ifdef DEBUG
         ErrorF("KdEnqueueKeyboardEvent: got %d events from GKE\n", nEvents);
diff-tree 34228d8b280ef105a0c60b8de5dacf70a5ce24b5 (from d003bada3352ec7d734498c4c732904876a9d1e2)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Aug 15 15:23:53 2006 +0300

    GPE: fix absolute button events / GKVE: (non-XKB) don't repeat lock keys
    Fix absolute button events in GPE, where we would previously send valuator
    events without bumping numEvents accordingly, causing the core event to
    go missing.
    In the non-XKB path in GKVE, implement proper lock behaviour (one press to
    enable, one press to disable, discard releases).
    Fix debug_events prototype.

diff --git a/dix/events.c b/dix/events.c
index f1e2fd8..6eb1257 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -113,6 +113,7 @@ of the copyright holder.
 #endif
 
 #include <X11/X.h>
+#include <X11/keysym.h>
 #include "misc.h"
 #include "resource.h"
 #define NEED_EVENTS
@@ -210,7 +211,7 @@ Mask DontPropagateMasks[DNPMCOUNT];
 static int DontPropagateRefCnts[DNPMCOUNT];
 
 #ifdef DEBUG
-static debug_events = 0;
+static int debug_events = 0;
 #endif
 _X_EXPORT InputInfo inputInfo;
 
@@ -4711,6 +4712,7 @@ int GetKeyboardValuatorEvents(xEvent *ev
                               int key_code, int num_valuators,
                               int *valuators) {
     int numEvents = 0, numRepeatEvents = 0, ms = 0, first_valuator = 0, i = 0;
+    KeySym sym = pDev->key->curKeySyms.map[key_code * pDev->key->curKeySyms.mapWidth];
     deviceKeyButtonPointer *kbp = NULL;
     deviceValuator *xv = NULL;
     xEvent *repeatEvents = NULL;
@@ -4740,11 +4742,28 @@ int GetKeyboardValuatorEvents(xEvent *ev
         numEvents += (num_valuators / 6) + 1;
     }
 
+#ifdef XKB
+    if (noXkbExtension)
+#endif
+    {
+        switch (sym) {
+            case XK_Num_Lock:
+            case XK_Caps_Lock:
+            case XK_Scroll_Lock:
+            case XK_Shift_Lock:
+                if (type == KeyRelease)
+                    return 0;
+                else if (type == KeyPress &&
+                         (pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
+                        type = KeyRelease;
+        }
+    }
+
     /* Handle core repeating, via press/release/press/release.
      * FIXME: In theory, if you're repeating with two keyboards,
      *        you could get unbalanced events here. */
     if (type == KeyPress &&
-        ((pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)) {
+        (((pDev->key->down[key_code >> 3] & (key_code & 7))) & 1)) {
         if (!pDev->kbdfeed->ctrl.autoRepeat ||
             pDev->key->modifierMap[key_code] ||
             !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
@@ -4760,7 +4779,7 @@ int GetKeyboardValuatorEvents(xEvent *ev
                                                    num_valuators, valuators);
             events += numEvents;
         }
-    }
+    
 
     ms = GetTimeInMillis();
 
@@ -4942,6 +4961,7 @@ GetPointerEvents(xEvent *events, DeviceI
     deviceValuator *xv = NULL;
     AxisInfoPtr axes = NULL;
     xEvent *ev = NULL;
+    Bool sendValuators = (type == MotionNotify || flags & POINTER_ABSOLUTE);
     DeviceIntPtr cp = inputInfo.pointer;
 
     if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
@@ -4961,14 +4981,13 @@ GetPointerEvents(xEvent *events, DeviceI
     else
         numEvents = 1;
 
-    if (type == MotionNotify) {
-        if (num_valuators > 2) {
-            if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS)
-                num_valuators = MAX_VALUATOR_EVENTS;
-            numEvents += (num_valuators / 6) + 1;
-        }
-        else if (num_valuators < 2)
-            return 0;
+    if (num_valuators > 2 && sendValuators) {
+        if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS)
+            num_valuators = MAX_VALUATOR_EVENTS;
+        numEvents += (num_valuators / 6) + 1;
+    }
+    else if (type == MotionNotify && num_valuators < 2) {
+        return 0;
     }
 
     ms = GetTimeInMillis();
@@ -5067,8 +5086,7 @@ GetPointerEvents(xEvent *events, DeviceI
         kbp->detail = pDev->button->map[buttons];
     }
 
-    if (num_valuators > 2 && (type == MotionNotify ||
-                              flags & POINTER_ABSOLUTE)) {
+    if (num_valuators > 2 && sendValuators) {
         kbp->deviceid |= MORE_EVENTS;
         while (first_valuator < num_valuators) {
             xv = (deviceValuator *) ++events;
@@ -5106,6 +5124,9 @@ GetPointerEvents(xEvent *events, DeviceI
     if (pDev->coreEvents) {
         events++;
         events->u.u.type = type;
+#ifdef DEBUG
+        ErrorF("GPE: core type is %d\n", type);
+#endif
         events->u.keyButtonPointer.time = ms;
         events->u.keyButtonPointer.rootX = kbp->root_x;
         events->u.keyButtonPointer.rootY = kbp->root_y;
diff-tree d003bada3352ec7d734498c4c732904876a9d1e2 (from parents)
Merge: d6433be3cca807dd78fbb1f45d9ba0212283083d a815b9b990e068f02d9cbba2b17f2cc3a30a9310
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Aug 12 22:48:55 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree d6433be3cca807dd78fbb1f45d9ba0212283083d (from parents)
Merge: 2bf9e3dc1ec5fd7bf84a4a96899e5663a721d4a4 984babe86bf82002b4d6589b2750c7b5a5489bd5
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Aug 12 21:50:52 2006 +0300

    Merge branch 'master' into input-hotplug

diff --cc hw/xfree86/os-support/Makefile.am
index a886de8,e64703a..131c495
@@@ -3,10 -3,10 +3,10 @@@
  endif
  
  SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
- DIST_SUBDIRS = bsd bus drm misc linux lynxos solaris sysv sco usl
+ DIST_SUBDIRS = bsd bus drm misc linux lynxos solaris sysv sco usl hurd
  
  sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h xf86_ansic.h xf86_libc.h \
 -              assyntax.h xf86OSKbd.h xf86OSmouse.h
 +              assyntax.h xf86OSmouse.h
  
  EXTRA_DIST = int10Defines.h xf86OSpriv.h README.OS-lib xf86drm.h
  
diff-tree 2bf9e3dc1ec5fd7bf84a4a96899e5663a721d4a4 (from 59dcc62906d8ee597cd43aa307f414cb47995cea)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Aug 12 21:50:39 2006 +0300

    make DIX more tolerant of devices without a CtrlProc (Debian #269860)
    Return BadDevice on client requests for devices without a CtrlProc, instead
    of tanking horribly.

diff --git a/dix/devices.c b/dix/devices.c
index 63b206a..9b72fa4 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -1454,6 +1454,10 @@ ProcChangeKeyboardControl (ClientPtr cli
     REQUEST(xChangeKeyboardControlReq);
 
     REQUEST_AT_LEAST_SIZE(xChangeKeyboardControlReq);
+
+    if (!keybd->kbdfeed->CtrlProc)
+        return BadDevice;
+    
     vmask = stuff->mask;
     if (client->req_len != (sizeof(xChangeKeyboardControlReq)>>2)+Ones(vmask))
 	return BadLength;
@@ -1660,6 +1664,10 @@ ProcBell(ClientPtr client)
     int newpercent;
     REQUEST(xBellReq);
     REQUEST_SIZE_MATCH(xBellReq);
+
+    if (!keybd->kbdfeed->BellProc)
+        return BadDevice;
+    
     if (stuff->percent < -100 || stuff->percent > 100)
     {
 	client->errorValue = stuff->percent;
@@ -1677,7 +1685,7 @@ ProcBell(ClientPtr client)
 	else
 #endif
     (*keybd->kbdfeed->BellProc)(newpercent, keybd,
-				(pointer) &keybd->kbdfeed->ctrl, 0);
+                                (pointer) &keybd->kbdfeed->ctrl, 0);
     return Success;
 } 
 
@@ -1689,6 +1697,10 @@ ProcChangePointerControl(ClientPtr clien
     REQUEST(xChangePointerControlReq);
 
     REQUEST_SIZE_MATCH(xChangePointerControlReq);
+    
+    if (!mouse->ptrfeed->CtrlProc)
+        return BadDevice;
+    
     ctrl = mouse->ptrfeed->ctrl;
     if ((stuff->doAccel != xTrue) && (stuff->doAccel != xFalse))
     {
diff-tree 59dcc62906d8ee597cd43aa307f414cb47995cea (from 26c3cd1c9e3f52548389817a6d89a377e20c4269)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Aug 12 20:39:08 2006 +0300

    xfree86: remove Xqueue support completely

diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 3729679..ca81969 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -76,7 +76,7 @@ Bool foundMouse = FALSE;
 #elif defined(__SCO__)
 static char *DFLT_MOUSE_PROTO = "OSMouse";
 #elif defined(__UNIXWARE__)
-static char *DFLT_MOUSE_PROTO = "Xqueue";
+static char *DFLT_MOUSE_PROTO = "OSMouse";
 static char *DFLT_MOUSE_DEV = "/dev/mouse";
 #elif defined(QNX4)
 static char *DFLT_MOUSE_PROTO = "OSMouse";
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 21389f2..45a50d8 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -142,9 +142,6 @@ Bool VTSwitchEnabled = TRUE;		/* Allows 
 
 extern fd_set EnabledDevices;
 
-#if defined(XQUEUE)
-extern void xf86XqueRequest(void);
-#endif
 #ifdef XF86PM
 extern void (*xf86OSPMClose)(void);
 #endif
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 64841ad..d7fc437 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -2576,7 +2576,7 @@ xf86SetSilkenMouse (ScreenPtr pScreen)
     /*
      * XXX quick hack to report correctly for OSs that can't do SilkenMouse
      * yet.  Should handle this differently so that alternate async methods
-     * like Xqueue work correctly with this too.
+     * work correctly with this too.
      */
     pScrn->silkenMouse = useSM && xf86SIGIOSupported();
     if (serverGeneration == 1)
diff --git a/hw/xfree86/common/xf86MiscExt.c b/hw/xfree86/common/xf86MiscExt.c
index b6f3874..375226a 100644
--- a/hw/xfree86/common/xf86MiscExt.c
+++ b/hw/xfree86/common/xf86MiscExt.c
@@ -433,15 +433,13 @@ MiscExtApply(pointer structure, MiscExtS
 	if (!xf86MouseProtocolIDToName)
 	    return MISC_RET_NOMODULE;
 	if (mse->type < MTYPE_MICROSOFT
-		|| ( mse->type > MTYPE_EXPPS2
-		    && (mse->type!=MTYPE_OSMOUSE && mse->type!=MTYPE_XQUEUE)))
+		|| (mse->type > MTYPE_EXPPS2
+		    && (mse->type != MTYPE_OSMOUSE)))
 	    return MISC_RET_BADMSEPROTO;
 #ifdef OSMOUSE_ONLY
 	if (mse->type != MTYPE_OSMOUSE)
 	    return MISC_RET_BADMSEPROTO;
 #else
-	if (mse->type == MTYPE_XQUEUE)
-	    return MISC_RET_BADMSEPROTO;
 	if (mse->type == MTYPE_OSMOUSE)
 	    return MISC_RET_BADMSEPROTO;
 #endif /* OSMOUSE_ONLY */
@@ -462,7 +460,6 @@ MiscExtApply(pointer structure, MiscExtS
 	    mse->flags &= ~MF_REOPEN;
 	}
 	if (mse->type != MTYPE_OSMOUSE
-		&& mse->type != MTYPE_XQUEUE
 		&& mse->type != MTYPE_PS_2
 		&& mse->type != MTYPE_BUSMOUSE
 		&& mse->type != MTYPE_IMPS2
@@ -483,7 +480,6 @@ MiscExtApply(pointer structure, MiscExtS
 	    return MISC_RET_BADFLAGS;
 
 	if (mse->type != MTYPE_OSMOUSE
-		&& mse->type != MTYPE_XQUEUE
 		&& mse->type != MTYPE_BUSMOUSE)
 	{
 	    if (mse->samplerate < 0)
diff --git a/hw/xfree86/os-support/bsd/Makefile.am b/hw/xfree86/os-support/bsd/Makefile.am
index edef4d4..0a0bcab 100644
--- a/hw/xfree86/os-support/bsd/Makefile.am
+++ b/hw/xfree86/os-support/bsd/Makefile.am
@@ -62,7 +62,6 @@ libbsd_la_SOURCES = \
 	$(srcdir)/../shared/vidmem.c \
 	bsd_VTsw.c \
 	bsd_init.c \
-	bsd_io.c \
 	bsd_mouse.c \
 	$(ARCH_SOURCES) \
 	$(AGP_SOURCES) \
diff --git a/hw/xfree86/os-support/bsd/bsd_io.c b/hw/xfree86/os-support/bsd/bsd_io.c
deleted file mode 100644
index b433d7b..0000000
--- a/hw/xfree86/os-support/bsd/bsd_io.c
+++ /dev/null
@@ -1,293 +0,0 @@
-/*
- * Copyright 1992 by Rich Murphey <Rich at Rice.edu>
- * 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 Rich Murphey and David Dawes 
- * not be used in advertising or publicity pertaining to distribution of 
- * the software without specific, written prior permission.  Rich Murphey 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.
- *
- * RICH MURPHEY AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO 
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL RICH MURPHEY 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.
- *
- */
-/* $XConsortium: bsd_io.c /main/11 1996/10/19 18:06:07 kaleb $ */
-
-#define NEED_EVENTS
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <termios.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#ifdef WSCONS_SUPPORT
-#define KBD_FD(i) ((i).kbdFd != -1 ? (i).kbdFd : (i).consoleFd)
-#endif
-
-_X_EXPORT void
-xf86SoundKbdBell(int loudness, int pitch, int duration)
-{
-#ifdef WSCONS_SUPPORT
-	struct wskbd_bell_data wsb;
-#endif
-
-    	if (loudness && pitch)
-	{
-#ifdef PCCONS_SUPPORT
-		int data[2];
-#endif
-
-	    	switch (xf86Info.consType) {
-
-#ifdef PCCONS_SUPPORT
-	    	case PCCONS:
-		    	data[0] = pitch;
-		    	data[1] = (duration * loudness) / 50;
-		    	ioctl(xf86Info.consoleFd, CONSOLE_X_BELL, data);
-			break;
-#endif
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	    	case SYSCONS:
-		case PCVT:
-			ioctl(xf86Info.consoleFd, KDMKTONE,
-			      ((1193190 / pitch) & 0xffff) |
-			      (((unsigned long)duration*loudness/50)<<16));
-			break;
-#endif
-#if defined (WSCONS_SUPPORT)
-		case WSCONS:
-			wsb.which = WSKBD_BELL_DOALL;
-			wsb.pitch = pitch;
-			wsb.period = duration;
-			wsb.volume = loudness;
-			ioctl(KBD_FD(xf86Info), WSKBDIO_COMPLEXBELL, 
-				      &wsb);
-			break;
-#endif
-	    	}
-	}
-}
-
-void
-xf86SetKbdLeds(int leds)
-{
-	switch (xf86Info.consType) {
-
-	case PCCONS:
-		break;
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	case SYSCONS:
-	case PCVT:
-		ioctl(xf86Info.consoleFd, KDSETLED, leds);
-		break;
-#endif
-#if defined(WSCONS_SUPPORT)
-	case WSCONS:
-		ioctl(KBD_FD(xf86Info), WSKBDIO_SETLEDS, &leds);
-		break;
-#endif
-	}
-}
-
-int
-xf86GetKbdLeds()
-{
-	int leds = 0;
-
-	switch (xf86Info.consType) {
-
-	case PCCONS:
-		break;
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	case SYSCONS:
-	case PCVT:
-		ioctl(xf86Info.consoleFd, KDGETLED, &leds);
-		break;
-#endif
-#if defined(WSCONS_SUPPORT)
-	  case WSCONS:
-		  ioctl(KBD_FD(xf86Info), WSKBDIO_GETLEDS, &leds);
-		  break;
-#endif
-	}
-	return(leds);
-}
-
-void
-xf86SetKbdRepeat(char rad)
-{
-	switch (xf86Info.consType) {
-
-	case PCCONS:
-		break;
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	case SYSCONS:
-	case PCVT:
-		ioctl(xf86Info.consoleFd, KDSETRAD, rad);
-		break;
-#endif
-	}
-}
-
-#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
-static struct termios kbdtty;
-#endif
-
-void
-xf86KbdInit()
-{
-	switch (xf86Info.consType) {
-
-#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	case PCCONS:
-	case SYSCONS:
-	case PCVT:
-		tcgetattr(xf86Info.consoleFd, &kbdtty);
-		break;
-#endif
-#if defined WSCONS_SUPPORT
-	case WSCONS:
-		if (xf86Info.kbdFd != -1) 
-			xf86FlushInput(xf86Info.kbdFd);
-		else
-			tcgetattr(xf86Info.consoleFd, &kbdtty);
-		break;
-#endif
-	}
-}
-
-int
-xf86KbdOn()
-{
-	struct termios nTty;
-#ifdef WSCONS_SUPPORT
-	int option;
-#endif
-
-
-	switch (xf86Info.consType) {
-
-#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT)
-	case SYSCONS:
-	case PCCONS:
-	case PCVT:
-		nTty = kbdtty;
-		nTty.c_iflag = IGNPAR | IGNBRK;
-		nTty.c_oflag = 0;
-		nTty.c_cflag = CREAD | CS8;
-		nTty.c_lflag = 0;
-		nTty.c_cc[VTIME] = 0;
-		nTty.c_cc[VMIN] = 1;
-		cfsetispeed(&nTty, 9600);
-		cfsetospeed(&nTty, 9600);
-		tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
-
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-		ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
-#endif
-		break;
-#endif
-#ifdef WSCONS_SUPPORT
-	case WSCONS:
-		if (xf86Info.kbdFd == -1) {
-			nTty = kbdtty;
-			nTty.c_iflag = IGNPAR | IGNBRK;
-			nTty.c_oflag = 0;
-			nTty.c_cflag = CREAD | CS8;
-			nTty.c_lflag = 0;
-			nTty.c_cc[VTIME] = 0;
-			nTty.c_cc[VMIN] = 1;
-			cfsetispeed(&nTty, 9600);
-			cfsetospeed(&nTty, 9600);
-			tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
-			option = WSKBD_RAW;
-			if (ioctl(xf86Info.consoleFd, WSKBDIO_SETMODE,
-					&option) == -1)
-				FatalError("can't switch keyboard to raw mode. "
-					"Enable support for it in the kernel\n"
-					"or use for example:\n\n"
-					"Option \"Protocol\" \"wskbd\"\n"
-					"Option \"Device\" \"/dev/wskbd0\"\n"
-					"\nin your XF86Config(5) file\n");
-		} else {
-			return xf86Info.kbdFd;
-		}
-#endif
-	}
-	return(xf86Info.consoleFd);
-}
-
-int
-xf86KbdOff()
-{
-#ifdef WSCONS_SUPPORT
-	int option;
-#endif
-
-	switch (xf86Info.consType) {
-
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	case SYSCONS:
-	case PCVT:
-		ioctl(xf86Info.consoleFd, KDSKBMODE, K_XLATE);
-		/* FALL THROUGH */
-#endif
-#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT)
-	case PCCONS:
-		tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
-		break;
-#endif
-#ifdef WSCONS_SUPPORT
-	case WSCONS:
-		if (xf86Info.kbdFd != -1) {
-			return xf86Info.kbdFd;
-		} else {
-			option = WSKBD_TRANSLATED;
-			ioctl(xf86Info.consoleFd, WSKBDIO_SETMODE, &option);
-			tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
-		}
-		break;
-#endif
-	}	
-	return(xf86Info.consoleFd);
-}
-
-#ifdef WSCONS_SUPPORT
-
-#define NUMEVENTS 64
-
-void
-xf86WSKbdEvents(void)
-{
-    static struct wscons_event events[NUMEVENTS];
-    int n, i;
-
-    n = read(xf86Info.kbdFd, events, sizeof events);
-    if (n <= 0)
-	return;
-    n /= sizeof(struct wscons_event);
-    for (i = 0; i < n; i++)
-	xf86PostWSKbdEvent(&events[i]);
-}
-
-#endif /* WSCONS_SUPPORT */
-
-
diff --git a/hw/xfree86/os-support/linux/lnx_kbd.h b/hw/xfree86/os-support/linux/lnx_kbd.h
deleted file mode 100644
index b2ae179..0000000
--- a/hw/xfree86/os-support/linux/lnx_kbd.h
+++ /dev/null
@@ -1,4 +0,0 @@
-
-extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms,
-				CARD8 *pModMap);
-
diff --git a/hw/xfree86/os-support/sco/Makefile.am b/hw/xfree86/os-support/sco/Makefile.am
index 820d183..9cb5011 100644
--- a/hw/xfree86/os-support/sco/Makefile.am
+++ b/hw/xfree86/os-support/sco/Makefile.am
@@ -1,8 +1,6 @@
 EXTRA_DIST = \
 	VTsw_sco.c \
-	sco_KbdMap.c \
 	sco_init.c \
-	sco_io.c \
 	sco_iop.c \
 	sco_mouse.c \
 	sco_video.c
diff --git a/hw/xfree86/os-support/sco/sco_io.c b/hw/xfree86/os-support/sco/sco_io.c
deleted file mode 100644
index eafc14c..0000000
--- a/hw/xfree86/os-support/sco/sco_io.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright 2001 by J. Kean Johnston <jkj at sco.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name J. Kean Johnston not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  J. Kean Johnston makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
- * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-/* $XConsortium$ */
-
-/* Re-written May 2001 to represent the current state of reality */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "compiler.h"
-
-#define _NEED_SYSI86
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86OSpriv.h"
-#include "xf86_OSlib.h"
-
-#include <sys/param.h>
-#include <sys/emap.h>
-#include <sys/nmap.h>
-
-_X_EXPORT void
-xf86SoundKbdBell(int loudness, int pitch, int duration)
-{
-  if (loudness && pitch) {
-    ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch);
-    usleep(duration * loudness * 20);
-    ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
-  }
-}
-
-void
-xf86SetKbdLeds(int leds)
-{
-  /*
-   * sleep the first time through under SCO.  There appears to be a
-   * timing problem in the driver which causes the keyboard to be lost.
-   * This usleep stops it from occurring. NOTE: this was in the old code.
-   * I am not convinced it is true any longer, but it doesn't hurt to
-   * leave this in here.
-   */
-  static int once = 1;
-
-  if (once) {
-    usleep(100);
-    once = 0;
-  }
-
-  ioctl(xf86Info.consoleFd, KDSETLED, leds );
-}
-
-int
-xf86GetKbdLeds(void)
-{
-  int leds;
-
-  ioctl (xf86Info.consoleFd, KDGETLED, &leds);
-  return leds;
-}
-
-/*
- * Much of the code in this function is duplicated from the Linux code
- * by Orest Zborowski <obz at Kodak.com> and David Dawes <dawes at xfree86.org>.
- * Please see the file ../linux/lnx_io.c for full copyright information.
- *
- * NOTE: Only OpenServer Release 5.0.6 with Release Supplement 5.0.6A
- * and later have the required ioctl. 5.0.6A or higher is HIGHLY
- * recommended. The console driver is quite a different beast on that OS.
- */
-void
-xf86SetKbdRepeat(char rad)
-{
-#if defined(KBIO_SETRATE)
-  int i;
-  int value = 0x7f;     /* Maximum delay with slowest rate */
-  int delay = 250;      /* Default delay */
-  int rate = 300;       /* Default repeat rate */
-
-  static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
-                               133, 120, 109, 100, 92, 86, 80, 75, 67,
-                               60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
-                               25, 23, 21, 20 };
-#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
-
-  static int valid_delays[] = { 250, 500, 750, 1000 };
-#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
-
-  if (xf86Info.kbdRate >= 0) 
-    rate = xf86Info.kbdRate * 10;
-  if (xf86Info.kbdDelay >= 0)
-    delay = xf86Info.kbdDelay;
-
-  for (i = 0; i < RATE_COUNT; i++)
-    if (rate >= valid_rates[i]) {
-      value &= 0x60;
-      value |= i;
-      break;
-    }
-
-  for (i = 0; i < DELAY_COUNT; i++)
-    if (delay <= valid_delays[i]) {
-      value &= 0x1f;
-      value |= i << 5;
-      break;
-    }
-
-  ioctl (xf86Info.consoleFd, KBIO_SETRATE, value);
-#endif /* defined(KBIO_SETRATE) */
-}
-
-static Bool use_tcs = TRUE, use_kd = TRUE;
-static Bool no_nmap = TRUE, no_emap = TRUE;
-static int orig_getsc, orig_kbm;
-static struct termios orig_termios;
-static keymap_t keymap, noledmap;
-static uchar_t *sc_mapbuf;
-static uchar_t *sc_mapbuf2;
-
-void
-xf86KbdInit(void)
-{
-  orig_getsc = 0;
-  if (ioctl (xf86Info.consoleFd, TCGETSC, &orig_getsc) < 0)
-    use_tcs = FALSE;
-  if (ioctl (xf86Info.consoleFd, KDGKBMODE, &orig_kbm) < 0)
-    use_kd = FALSE;
-
-  if (!use_tcs && !use_kd)
-    FatalError ("xf86KbdInit: Could not determine keyboard mode\n");
-
-  /*
-   * One day this should be fixed to translate normal ASCII characters
-   * back into scancodes or into events that XFree86 wants, but not
-   * now. For the time being, we only support scancode mode screens.
-  */
-  if (use_tcs && !(orig_getsc & KB_ISSCANCODE))
-    FatalError ("xf86KbdInit: Keyboard can not send scancodes\n");
-
-  /*
-   * We need to get the original keyboard map and NUL out the lock
-   * modifiers. This prevents the scancode API from messing with
-   * the keyboard LED's. We restore the original map when we exit.
-   */
-  if (ioctl (xf86Info.consoleFd, GIO_KEYMAP, &keymap) < 0) {
-    FatalError ("xf86KbdInit: Failed to get keyboard map (%s)\n",
-        strerror(errno));
-  }
-  if (ioctl (xf86Info.consoleFd, GIO_KEYMAP, &noledmap) < 0) {
-    FatalError ("xf86KbdInit: Failed to get keyboard map (%s)\n",
-        strerror(errno));
-  } else {
-    int i, j;
-
-    for (i = 0; i < noledmap.n_keys; i++) {
-      for (j = 0; j < NUM_STATES; j++) {
-        if (IS_SPECIAL(noledmap, i, j) &&
-            ((noledmap.key[i].map[j] == K_CLK) ||
-             (noledmap.key[i].map[j] == K_NLK) ||
-             (noledmap.key[i].map[j] == K_SLK))) {
-          noledmap.key[i].map[j] = K_NOP;
-        }
-      }
-    }
-  }
-
-  if (ioctl (xf86Info.consoleFd, XCGETA, &orig_termios) < 0) {
-    FatalError ("xf86KbdInit: Failed to get terminal modes (%s)\n",
-        strerror(errno));
-  }
-
-  sc_mapbuf = xalloc (10*BSIZE);
-  sc_mapbuf2 = xalloc(10*BSIZE);
-
-  /* Get the emap */
-  if (ioctl (xf86Info.consoleFd, LDGMAP, sc_mapbuf) < 0) {
-    if (errno != ENAVAIL) {
-      FatalError ("xf86KbdInit: Failed to retrieve e-map (%s)\n",
-          strerror (errno));
-    }
-    no_emap = FALSE;
-  }
-
-  /* Get the nmap */
-  if (ioctl (xf86Info.consoleFd, NMGMAP, sc_mapbuf2) < 0) {
-    if (errno != ENAVAIL) {
-      FatalError ("xf86KbdInit: Failed to retrieve n-map (%s)\n",
-          strerror (errno));
-    }
-    no_nmap = FALSE;
-  }
-}
-
-int
-xf86KbdOn(void)
-{
-  struct termios newtio;
-
-  ioctl (xf86Info.consoleFd, LDNMAP); /* Turn e-mapping off */
-  ioctl (xf86Info.consoleFd, NMNMAP); /* Turn n-mapping off */
-
-  newtio = orig_termios;        /* structure copy */
-  newtio.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
-  newtio.c_oflag = 0;
-  newtio.c_cflag = CREAD | CS8 | B9600;
-  newtio.c_lflag = 0;
-  newtio.c_cc[VTIME]=0;
-  newtio.c_cc[VMIN]=1;
-  cfsetispeed(&newtio, 9600);
-  cfsetospeed(&newtio, 9600);
-  ioctl(xf86Info.consoleFd, XCSETA, &newtio);
-
-  /* Now tell the keyboard driver to send us raw scancodes */
-  if (use_tcs) {
-    int nm = orig_getsc;
-    nm &= ~KB_XSCANCODE;
-    ioctl (xf86Info.consoleFd, TCSETSC, &nm);
-  }
-
-  if (use_kd)
-    ioctl (xf86Info.consoleFd, KDSKBMODE, K_RAW);
-
-  ioctl (xf86Info.consoleFd, PIO_KEYMAP, &noledmap);
-
-  return(xf86Info.consoleFd);
-}
-
-int
-xf86KbdOff(void)
-{
-  /* Revert back to original translate scancode mode */
-  if (use_tcs)
-    ioctl (xf86Info.consoleFd, TCSETSC, &orig_getsc);
-  if (use_kd)
-    ioctl (xf86Info.consoleFd, KDSKBMODE, orig_kbm);
-
-  ioctl (xf86Info.consoleFd, PIO_KEYMAP, &keymap);
-
-  if (no_emap)
-    ioctl (xf86Info.consoleFd, LDSMAP, sc_mapbuf);
-  if (no_nmap)
-    ioctl (xf86Info.consoleFd, NMSMAP, sc_mapbuf2);
-
-  ioctl(xf86Info.consoleFd, XCSETA, &orig_termios);
-
-  return(xf86Info.consoleFd);
-}
diff --git a/hw/xfree86/os-support/solaris/Makefile.am b/hw/xfree86/os-support/solaris/Makefile.am
index 504e1a1..9c86079 100644
--- a/hw/xfree86/os-support/solaris/Makefile.am
+++ b/hw/xfree86/os-support/solaris/Makefile.am
@@ -1,8 +1,6 @@
 if SOLARIS_USL_CONSOLE
-IO_SRC   = $(srcdir)/../sysv/sysv_io.c
 VTSW_SRC = $(srcdir)/../shared/VTsw_usl.c
 else
-IO_SRC   = sun_io.c
 VTSW_SRC = $(srcdir)/../shared/VTsw_noop.c
 endif
 
@@ -20,7 +18,7 @@ solaris-$(SOLARIS_INOUT_ARCH).il: solari
 	$(CPP) -P -DINLINE_ASM solaris-${SOLARIS_INOUT_ARCH}.S > $@
 
 noinst_LTLIBRARIES = libsolaris.la
-libsolaris_la_SOURCES = sun_bios.c sun_init.c $(IO_SRC) \
+libsolaris_la_SOURCES = sun_bios.c sun_init.c \
 	sun_mouse.c sun_vid.c $(AGP_SRC) \
 	$(srcdir)/../shared/libc_wrapper.c \
 	$(srcdir)/../shared/kmod_noop.c $(srcdir)/../shared/pm_noop.c \
diff --git a/hw/xfree86/os-support/solaris/sun_io.c b/hw/xfree86/os-support/solaris/sun_io.c
deleted file mode 100644
index 3d8292e..0000000
--- a/hw/xfree86/os-support/solaris/sun_io.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* $XdotOrg: $ */
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * 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 Thomas Roell and David Dawes
- * not be used in advertising or publicity pertaining to distribution of
- * the software without specific, written prior permission.  Thomas Roell and
- * David Dawes makes no representations about the suitability of this
- * software for any purpose.  It is provided "as is" without express or
- * implied warranty.
- *
- * THOMAS ROELL AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
- * IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-/* Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, and/or sell copies of the Software, and to permit persons
- * to whom the Software is furnished to do so, provided that the above
- * copyright notice(s) and this permission notice appear in all copies of
- * the Software and that both the above copyright notice(s) and this
- * permission notice appear in supporting documentation.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
- * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
- * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
- * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- * 
- * Except as contained in this notice, the name of a copyright holder
- * shall not be used in advertising or otherwise to promote the sale, use
- * or other dealings in this Software without prior written authorization
- * of the copyright holder.
- */
-
-/* Solaris support routines for builtin "keyboard" driver */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "sun_kbd.h"
-
-static sunKbdPrivRec sunKeyboardPriv;
-
-_X_HIDDEN void
-xf86KbdInit(void)
-{
-    const char *kbdName = "keyboard";
-    pointer *kbdOptions = NULL;
-    IDevPtr pDev;
-
-    /* There should be a better way to find the keyboard device name, but
-       this seems to work for now. */
-    for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) {
-	if (!xf86NameCmp(pDev->driver, "keyboard")) {
-	    kbdName = pDev->identifier;
-	    kbdOptions = pDev->commonOptions;
-	    break;
-	}
-    }
-
-    if (xf86Info.kbdFd < 0) {
-	xf86Info.kbdFd = sunKbdOpen(kbdName, kbdOptions);
-	if (xf86Info.kbdFd < 0) {
-	    FatalError("Unable to open keyboard: /dev/kbd\n");
-	}
-    }
-
-    memset(&sunKeyboardPriv, 0, sizeof(sunKbdPrivRec));    
-    if (sunKbdInit(&sunKeyboardPriv, xf86Info.kbdFd,
-		   kbdName, kbdOptions)	!= Success) {
-    	FatalError("Unable to initialize keyboard driver\n");
-    }
-}
-
-_X_HIDDEN int
-xf86KbdOn(void)
-{
-    if (sunKbdOn(&sunKeyboardPriv) != Success) {
-	FatalError("Enabling keyboard");
-    }
-
-    return xf86Info.kbdFd;
-}
-
-_X_HIDDEN int
-xf86KbdOff(void)
-{
-    if (sunKbdOff(&sunKeyboardPriv) != Success) {
-	FatalError("Disabling keyboard");
-    }
-
-    return xf86Info.kbdFd;
-}
-
-_X_EXPORT void
-xf86SoundKbdBell(int loudness, int pitch, int duration)
-{
-    sunKbdSoundBell(&sunKeyboardPriv, loudness, pitch, duration);
-}
-
-_X_HIDDEN void
-xf86SetKbdLeds(int leds)
-{
-    sunKbdSetLeds(&sunKeyboardPriv, leds);
-}
-
-_X_HIDDEN int
-xf86GetKbdLeds(void)
-{
-    return sunKbdGetLeds(&sunKeyboardPriv);
-}
-
-_X_HIDDEN void
-xf86SetKbdRepeat(char rad)
-{
-    sunKbdSetRepeat(&sunKeyboardPriv, rad);
-}
-
-/*
- * Lets try reading more than one keyboard event at a time in the hopes that
- * this will be slightly more efficient.  Or we could just try the MicroSoft
- * method, and forget about efficiency. :-)
- */
-_X_HIDDEN void
-xf86KbdEvents(void)
-{
-    Firm_event event[64];
-    int        nBytes, i;
-
-    /* I certainly hope its not possible to read partial events */
-
-    if ((nBytes = read(xf86Info.kbdFd, (char *)event, sizeof(event))) > 0)
-    {
-	for (i = 0; i < (nBytes / sizeof(Firm_event)); i++)
-	    sunPostKbdEvent(sunKeyboardPriv.ktype, &event[i]);
-    }
-}
diff --git a/hw/xfree86/os-support/sysv/Makefile.am b/hw/xfree86/os-support/sysv/Makefile.am
index b67cf99..85aa764 100644
--- a/hw/xfree86/os-support/sysv/Makefile.am
+++ b/hw/xfree86/os-support/sysv/Makefile.am
@@ -1 +1 @@
-EXTRA_DIST = sysv_init.c sysv_io.c sysv_mouse.c sysv_video.c xqueue.c xqueue.h
+EXTRA_DIST = sysv_init.c sysv_io.c sysv_mouse.c sysv_video.c
diff --git a/hw/xfree86/os-support/sysv/sysv_mouse.c b/hw/xfree86/os-support/sysv/sysv_mouse.c
index 581ed58..e620105 100644
--- a/hw/xfree86/os-support/sysv/sysv_mouse.c
+++ b/hw/xfree86/os-support/sysv/sysv_mouse.c
@@ -11,7 +11,6 @@
 #include "xf86.h"
 #include "xf86Xinput.h"
 #include "xf86OSmouse.h"
-#include "xqueue.h"
 
 static int
 SupportedInterfaces(void)
@@ -22,7 +21,6 @@ SupportedInterfaces(void)
 
 #ifndef ISC
 static const char *internalNames[] = {
-	"Xqueue",
 	NULL
 };
 
@@ -56,7 +54,6 @@ xf86OSMouseInit(int flags)
 #ifndef ISC
     p->BuiltinNames = BuiltinNames;
     p->CheckProtocol = CheckProtocol;
-    p->PreInit = XqueueMousePreInit;
 #endif
     return p;
 }
diff --git a/hw/xfree86/os-support/sysv/xqueue.c b/hw/xfree86/os-support/sysv/xqueue.c
deleted file mode 100644
index f003211..0000000
--- a/hw/xfree86/os-support/sysv/xqueue.c
+++ /dev/null
@@ -1,536 +0,0 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * Copyright 1993-1999 by The XFree86 Project, Inc.
- *
- * 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 the copyright holders not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holders make no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-/* $XConsortium: xqueue.c /main/8 1996/10/19 18:08:11 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86Xinput.h"
-#include "xf86OSmouse.h"
-#include "xqueue.h"
-
-#ifdef XQUEUE
-
-static xqEventQueue      *XqueQaddr;
-static int xqueFd = -1;
-#ifndef XQUEUE_ASYNC
-static int xquePipe[2];
-#endif
-
-#ifdef XKB
-#include "inputstr.h"
-#include <X11/extensions/XKB.h>
-#include <X11/extensions/XKBstr.h>
-#include <X11/extensions/XKBsrv.h>
-extern Bool noXkbExtension;
-#endif
-
-#include "xf86Xinput.h"
-#include "mipointer.h"
-
-typedef struct {
-	int		xquePending;
-	int		xqueSema;
-} XqInfoRec, *XqInfoPtr;
-
-InputInfoPtr XqMouse = NULL;
-InputInfoPtr XqKeyboard = NULL;
-
-#ifndef XQUEUE_ASYNC
-/*
- * xf86XqueSignal --
- *	Trap the signal from xqueue and let it be known that events are
- *	ready for collection
- */
-
-static void
-xf86XqueSignal(int signum)
-{
-  ((XqInfoPtr)(((MouseDevPtr)(XqMouse->private))->mousePriv))->xquePending = 1;
-  /*
-   * This is a hack, but it is the only reliable way I can find of letting
-   * the main select() loop know that there is more input waiting.  Receiving
-   * a signal will interrupt select(), but there is no way I can find of
-   * dealing with events that come in between the end of processing the
-   * last set and when select() gets called.
-   *
-   * Suggestions for better ways of dealing with this without going back to
-   * asynchronous event processing are welcome.
-   */
-#ifdef DEBUG
-  ErrorF("xf86XqueSignal\n");
-#endif
-  write(xquePipe[1], "X", 1);
-  signal(SIGUSR2, xf86XqueSignal);
-}
-#endif
-  
-
-/*
- * xf86XqueKbdProc --
- *	Handle the initialization, etc. of a keyboard.
- */
-
-int
-xf86XqueKbdProc(DeviceIntPtr pKeyboard, int what)
-{
-  KeySymsRec  keySyms;
-  CARD8       modMap[MAP_LENGTH];
-
-  switch (what) {
-      
-  case DEVICE_INIT:
-    
-    xf86KbdGetMapping(&keySyms, modMap);
-    
-    /*
-     * Get also the initial led settings
-     */
-    ioctl(xf86Info.consoleFd, KDGETLED, &xf86Info.leds);
-
-    /*
-     * Perform final initialization of the system private keyboard
-     * structure and fill in various slots in the device record
-     * itself which couldn't be filled in before.
-     */
-    pKeyboard->public.on = FALSE;
-
-#ifdef XKB
-    if (noXkbExtension) {
-#endif
-    InitKeyboardDeviceStruct((DevicePtr)xf86Info.pKeyboard,
-			     &keySyms,
-			     modMap,
-			     xf86KbdBell,
-			     (KbdCtrlProcPtr)xf86KbdCtrl);
-#ifdef XKB
-    } else {
-	XkbComponentNamesRec names;
-	if (xf86Info.xkbkeymap) {
-	    names.keymap = xf86Info.xkbkeymap;
-	    names.keycodes = NULL;
-	    names.types = NULL;
-	    names.compat = NULL;
-	    names.symbols = NULL;
-	    names.geometry = NULL;
-	} else {
-	    names.keymap = NULL;
-	    names.keycodes = xf86Info.xkbkeycodes;
-	    names.types = xf86Info.xkbtypes;
-	    names.compat = xf86Info.xkbcompat;
-	    names.symbols = xf86Info.xkbsymbols;
-	    names.geometry = xf86Info.xkbgeometry;
-	}
-	if ((xf86Info.xkbkeymap || xf86Info.xkbcomponents_specified)
-	   && (xf86Info.xkbmodel == NULL || xf86Info.xkblayout == NULL)) {
-		xf86Info.xkbrules = NULL;
-	}
-	XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel,
-			 xf86Info.xkblayout, xf86Info.xkbvariant,
-			 xf86Info.xkboptions);
-	XkbInitKeyboardDeviceStruct(pKeyboard, 
-				    &names,
-				    &keySyms, 
-				    modMap, 
-				    xf86KbdBell,
-				    (KbdCtrlProcPtr)xf86KbdCtrl);
-    }
-#endif
-
-    xf86InitKBD(TRUE);
-    break;
-    
-  case DEVICE_ON:
-    pKeyboard->public.on = TRUE;
-    xf86InitKBD(FALSE);
-    break;
-    
-  case DEVICE_CLOSE:
-  case DEVICE_OFF:
-    pKeyboard->public.on = FALSE;
-    break;
-  }
-  
-  return (Success);
-}
-
-
-/*
- * xf86XqueEvents --
- *      Get some events from our queue. Nothing to do here ...
- */
-
-void
-xf86XqueEvents()
-{
-}
-
-
-#ifdef XQUEUE_ASYNC
-static void XqDoInput(int signum);
-#endif
-
-void
-XqReadInput(InputInfoPtr pInfo)
-{
-    MouseDevPtr pMse;
-    XqInfoPtr pXq;
-    xqEvent *XqueEvents;
-    int XqueHead;
-    char buf[100];
-    signed char dx, dy;
-
-    if (xqueFd < 0)
-	return;
-
-    pMse = pInfo->private;
-    pXq = pMse->mousePriv;
-
-    XqueEvents = XqueQaddr->xq_events;
-    XqueHead = XqueQaddr->xq_head;
-
-    while (XqueHead != XqueQaddr->xq_tail) {
-	switch (XqueEvents[XqueHead].xq_type) {
-	case XQ_BUTTON:
-	    pMse->PostEvent(pInfo, ~(XqueEvents[XqueHead].xq_code) & 0x07,
-			    0, 0, 0, 0);
-#ifdef DEBUG
-	    ErrorF("xqueue: buttons: %d\n", ~(XqueEvents[XqueHead].xq_code) & 0x07);
-#endif
-	    break;
-
-	case XQ_MOTION:
-	    dx = (signed char)XqueEvents[XqueHead].xq_x;
-	    dy = (signed char)XqueEvents[XqueHead].xq_y;
-	    pMse->PostEvent(pInfo, ~(XqueEvents[XqueHead].xq_code) & 0x07,
-			    (int)dx, (int)dy, 0, 0);
-#ifdef DEBUG
-	    ErrorF("xqueue: Motion: (%d, %d) (buttons: %d)\n", dx, dy, ~(XqueEvents[XqueHead].xq_code) & 0x07);
-#endif
-	    break;
-
-	case XQ_KEY:
-	    /* XXX Need to deal with the keyboard part nicely. */
-#ifdef DEBUG
-	    ErrorF("xqueue: key: %d\n", XqueEvents[XqueHead].xq_code);
-#endif
-	    xf86PostKbdEvent(XqueEvents[XqueHead].xq_code);
-	    break;
-	default:
-	    xf86Msg(X_WARNING, "Unknown Xque Event: 0x%02x\n",
-		    XqueEvents[XqueHead].xq_type);
-	}
-      
-	if ((++XqueHead) == XqueQaddr->xq_size) XqueHead = 0;
-	xf86Info.inputPending = TRUE;
-    }
-
-    /* reenable the signal-processing */
-#ifdef XQUEUE_ASYNC
-    signal(SIGUSR2, XqDoInput);
-#endif
-
-#ifndef XQUEUE_ASYNC
-    {
-	int rval;
-
-	while ((rval = read(xquePipe[0], buf, sizeof(buf))) > 0)
-#ifdef DEBUG
-	    ErrorF("Read %d bytes from xquePipe[0]\n", rval);
-#else
-	    ;
-#endif
-    }
-#endif
-
-#ifdef DEBUG
-    ErrorF("Leaving XqReadInput()\n");
-#endif
-    pXq->xquePending = 0;
-    XqueQaddr->xq_head = XqueQaddr->xq_tail;
-    XqueQaddr->xq_sigenable = 1; /* UNLOCK */
-}
-
-#ifdef XQUEUE_ASYNC
-static void
-XqDoInput(int signum)
-{
-    if (XqMouse)
-	XqReadInput(XqMouse);
-}
-#endif
-
-static void
-XqBlock(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
-{
-    InputInfoPtr pInfo;
-    MouseDevPtr pMse;
-    XqInfoPtr pXq;
-    /*
-     * On MP SVR4 boxes, a race condition exists because the XQUEUE does
-     * not have anyway to lock it for exclusive access. This results in one
-     * processor putting something on the queue at the same time the other
-     * processor is taking it something off. The count of items in the queue
-     * can get off by 1. This just goes and checks to see if an extra event
-     * was put in the queue a during this period. The signal for this event
-     * was ignored while processing the previous event.
-     */
-
-    pInfo = blockData;
-    pMse = pInfo->private;
-    pXq = pMse-> mousePriv;
-    if (!pXq->xquePending) {
-#ifdef DEBUG
-	ErrorF("XqBlock: calling XqReadInput()\n");
-#endif
-	XqReadInput((InputInfoPtr)blockData);
-    } else {
-#ifdef DEBUG
-	ErrorF("XqBlock: not calling XqReadInput()\n");
-#endif
-	;
-    }
-    /*
-     * Make sure that any events that come in here are passed on without.
-     * waiting for the next wakeup.
-     */
-    if (xf86Info.inputPending) {
-#ifdef DEBUG
-	ErrorF("XqBlock: calling ProcessInputEvents()\n");
-#endif
-	ProcessInputEvents();
-    } else {
-#ifdef DEBUG
-	ErrorF("XqBlock: not calling ProcessInputEvents()\n");
-#endif
-	;
-    }
-}
-
-/*
- * XqEnable --
- *      Enable the handling of the Xque
- */
-
-static int
-XqEnable(InputInfoPtr pInfo)
-{
-    MouseDevPtr pMse;
-    XqInfoPtr pXq;
-    static struct kd_quemode xqueMode;
-    static Bool was_here = FALSE;
-
-    pMse = pInfo->private;
-    pXq = pMse->mousePriv;
-
-    if (xqueFd < 0) {
-	if ((xqueFd = open("/dev/mouse", O_RDONLY | O_NDELAY)) < 0) {
-	    if (xf86GetAllowMouseOpenFail()) {
-		xf86Msg(X_WARNING,
-		    "%s: Cannot open /dev/mouse (%s) - Continuing...\n",
-		    pInfo->name, strerror(errno));
-		return Success;
-	    } else {
-		xf86Msg(X_ERROR, "%s: Cannot open /dev/mouse (%s)\n",
-			pInfo->name, strerror(errno));
-		return !Success;
-	    }
-	}
-    }
-#ifndef XQUEUE_ASYNC
-    if (!was_here) {
-	pipe(xquePipe);
-	fcntl(xquePipe[0], F_SETFL, fcntl(xquePipe[0], F_GETFL, 0) | O_NDELAY);
-	fcntl(xquePipe[1], F_SETFL, fcntl(xquePipe[1], F_GETFL, 0) | O_NDELAY);
-	was_here = TRUE;
-    }
-#endif
-
-    if (pXq->xqueSema++ == 0) {
-#ifdef XQUEUE_ASYNC
-	(void) signal(SIGUSR2, XqDoInput);
-#else
-	(void) signal(SIGUSR2, xf86XqueSignal);
-#endif
-	xqueMode.qsize = 64;    /* max events */
-	xqueMode.signo = SIGUSR2;
-	ioctl(xf86Info.consoleFd, KDQUEMODE, NULL);
-
-	if (ioctl(xf86Info.consoleFd, KDQUEMODE, &xqueMode) < 0) {
-	    xf86Msg(X_ERROR, "%s: Cannot set KDQUEMODE", pInfo->name);
-	    return !Success;
-	}
-	XqueQaddr = (xqEventQueue *)xqueMode.qaddr;
-	XqueQaddr->xq_sigenable = 1; /* UNLOCK */
-    }
-
-    return Success;
-}
-
-
-
-/*
- * xf86XqueDisable --
- *      disable the handling of the Xque
- */
-
-static int
-XqDisable(InputInfoPtr pInfo)
-{
-    MouseDevPtr pMse;
-    XqInfoPtr pXq;
-
-    pMse = pInfo->private;
-    pXq = pMse->mousePriv;
-
-    if (pXq->xqueSema-- == 1)
-    {
-	XqueQaddr->xq_sigenable = 0; /* LOCK */
-      
-	if (ioctl(xf86Info.consoleFd, KDQUEMODE, NULL) < 0) {
-	    xf86Msg(X_ERROR, "%s: Cannot unset KDQUEMODE", pInfo->name);
-	    return !Success;
-	}
-    }
-
-    if (xqueFd >= 0) {
-	close(xqueFd);
-	xqueFd = -1;
-    }
-
-    return Success;
-}
-
-/*
- * XqMouseProc --
- *      Handle the initialization, etc. of a mouse
- */
-
-static int
-XqMouseProc(DeviceIntPtr pPointer, int what)
-{
-    InputInfoPtr pInfo;
-    MouseDevPtr pMse;
-    unchar        map[4];
-    int ret;
- 
-    pInfo = pPointer->public.devicePrivate;
-    pMse = pInfo->private;
-    pMse->device = pPointer;
-
-    switch (what) {
-    case DEVICE_INIT: 
-	pPointer->public.on = FALSE;
-
-	map[1] = 1;
-	map[2] = 2;
-	map[3] = 3;
-
-	InitPointerDeviceStruct((DevicePtr)pPointer, 
-				map, 
-				3, 
-				miPointerGetMotionEvents, 
-				pMse->Ctrl,
-				miPointerGetMotionBufferSize());
-	/* X valuator */
-	xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
-	xf86InitValuatorDefaults(pPointer, 0);
-	/* Y valuator */
-	xf86InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
-	xf86InitValuatorDefaults(pPointer, 1);
-	xf86MotionHistoryAllocate(pInfo);
-	RegisterBlockAndWakeupHandlers(XqBlock, (WakeupHandlerProcPtr)NoopDDA,
-					pInfo);
-	break;
-      
-    case DEVICE_ON:
-	pMse->lastButtons = 0;
-	pMse->lastMappedButtons = 0;
-	pMse->emulateState = 0;
-	pPointer->public.on = TRUE;
-	ret = XqEnable(pInfo);
-#ifndef XQUEUE_ASYNC
-	if (xquePipe[0] != -1) {
-	    pInfo->fd = xquePipe[0];
-	    AddEnabledDevice(xquePipe[0]);
-	}
-#endif
-	return ret;
-      
-    case DEVICE_CLOSE:
-    case DEVICE_OFF:
-	pPointer->public.on = FALSE;
-	ret = XqDisable(pInfo);
-#ifndef XQUEUE_ASYNC
-	if (xquePipe[0] != -1) {
-	    RemoveEnabledDevice(xquePipe[0]);
-	    pInfo->fd = -1;
-	}
-#endif
-	return ret;
-    }
-    return Success;
-}
-
-Bool
-XqueueMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
-{
-    MouseDevPtr pMse;
-    XqInfoPtr pXq;
-
-    pMse = pInfo->private;
-    pMse->protocol = protocol;
-    xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, protocol);
-    pXq = pMse->mousePriv = xnfcalloc(sizeof(XqInfoRec), 1);
-
-    /* Collect the options, and process the common options. */
-    xf86CollectInputOptions(pInfo, NULL, NULL);
-    xf86ProcessCommonOptions(pInfo, pInfo->options);
-
-    /* Process common mouse options (like Emulate3Buttons, etc). */
-    pMse->CommonOptions(pInfo);
-
-    /* Setup the local procs. */
-    pInfo->device_control = XqMouseProc;
-#ifdef XQUEUE_ASYNC
-    pInfo->read_input = NULL;
-#else
-    pInfo->read_input = XqReadInput;
-#endif
-    pInfo->fd = -1;
-
-    XqMouse = pInfo;
-
-    pInfo->flags |= XI86_CONFIGURED;
-    return TRUE;
-}
-
-#endif /* XQUEUE */
diff --git a/hw/xfree86/os-support/sysv/xqueue.h b/hw/xfree86/os-support/sysv/xqueue.h
deleted file mode 100644
index d693d2b..0000000
--- a/hw/xfree86/os-support/sysv/xqueue.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* $XFree86$ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifndef _XF86_XQUEUE_H_
-#define _XF86_XQUEUE_H_
-
-Bool XqueueMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags);
-
-#endif
diff --git a/hw/xfree86/os-support/usl/Makefile.am b/hw/xfree86/os-support/usl/Makefile.am
index 58f9760..db08f5d 100644
--- a/hw/xfree86/os-support/usl/Makefile.am
+++ b/hw/xfree86/os-support/usl/Makefile.am
@@ -1,9 +1,6 @@
 EXTRA_DIST = \
 	usl_init.c \
-	usl_io.c \
 	usl_iop.c \
 	usl_mouse.c \
 	usl_video.c \
-	usl_vtsw.c \
-	usl_xqueue.c \
-	usl_xqueue.h
+	usl_vtsw.c
diff --git a/hw/xfree86/os-support/usl/usl_io.c b/hw/xfree86/os-support/usl/usl_io.c
deleted file mode 100644
index 4cb23d4..0000000
--- a/hw/xfree86/os-support/usl/usl_io.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright 2001-2005 by Kean Johnston <jkj at sco.com>
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * 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 Thomas Roell, David Dawes 
- * and Kean Johnston not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * Thomas Roell, David Dawes and Kean Johnston make no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL, DAVID DAWES AND KEAN JOHNSTON DISCLAIM ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL THOMAS ROELLm DAVID WEXELBLAT
- * OR KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
- * THIS SOFTWARE.
- *
- */
-/* $XConsortium$ */
-
-#include "X.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-_X_EXPORT void
-xf86SoundKbdBell(int loudness, int pitch, int duration)
-{
-  if (loudness && pitch) {
-    ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch);
-    usleep(xf86Info.bell_duration * loudness * 20);
-    ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
-  }
-}
-
-void
-xf86SetKbdLeds(int leds)
-{
-  ioctl(xf86Info.consoleFd, KDSETLED, leds);
-}
-
-int
-xf86GetKbdLeds(void)
-{
-  int leds;
-
-  ioctl(xf86Info.consoleFd, KDGETLED, &leds);
-  return(leds);
-}
-
-/*
- * Much of the code in this function is duplicated from the Linux code
- * by Orest Zborowski <obz at Kodak.com> and David Dawes <dawes at xfree86.org>.
- * Please see the file ../linux/lnx_io.c for full copyright information.
- */
-void
-xf86SetKbdRepeat(char rad)
-{
-  int i;
-  int value = 0x7f;     /* Maximum delay with slowest rate */
-  int delay = 250;      /* Default delay */
-  int rate = 300;       /* Default repeat rate */
-
-  static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
-                               133, 120, 109, 100, 92, 86, 80, 75, 67,
-                               60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
-                               25, 23, 21, 20 };
-#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
-
-  static int valid_delays[] = { 250, 500, 750, 1000 };
-#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
-
-  if (xf86Info.kbdRate >= 0) 
-    rate = xf86Info.kbdRate * 10;
-  if (xf86Info.kbdDelay >= 0)
-    delay = xf86Info.kbdDelay;
-
-  for (i = 0; i < RATE_COUNT; i++)
-    if (rate >= valid_rates[i]) {
-      value &= 0x60;
-      value |= i;
-      break;
-    }
-
-  for (i = 0; i < DELAY_COUNT; i++)
-    if (delay <= valid_delays[i]) {
-      value &= 0x1f;
-      value |= i << 5;
-      break;
-    }
-
-  ioctl (xf86Info.consoleFd, KDSETTYPEMATICS, value);
-}
-
-static int orig_kbm;
-static struct termio orig_termio;
-static keymap_t keymap, noledmap;
-
-void
-xf86KbdInit(void)
-{
-  ioctl (xf86Info.consoleFd, KDGKBMODE, &orig_kbm);
-  ioctl (xf86Info.consoleFd, TCGETA, &orig_termio);
-  /*
-   * We need to get the original keyboard map and NUL out the lock
-   * modifiers. This prevents the scancode API from messing with
-   * the keyboard LED's. We restore the original map when we exit.
-   */
-  if (ioctl (xf86Info.consoleFd, GIO_KEYMAP, &keymap) < 0) {
-    FatalError ("xf86KbdInit: Failed to get keyboard map (%s)\n",
-        strerror(errno));
-  }
-  if (ioctl (xf86Info.consoleFd, GIO_KEYMAP, &noledmap) < 0) {
-    FatalError ("xf86KbdInit: Failed to get keyboard map (%s)\n",
-        strerror(errno));
-  } else {
-    int i, j;
-
-    for (i = 0; i < noledmap.n_keys; i++) {
-      for (j = 0; j < NUM_STATES; j++) {
-        if (IS_SPECKEY(&noledmap, i, j) &&
-            ((noledmap.key[i].map[j] == K_CLK) ||
-             (noledmap.key[i].map[j] == K_NLK) ||
-             (noledmap.key[i].map[j] == K_SLK))) {
-          noledmap.key[i].map[j] = K_NOP;
-        }
-      }
-    }
-  }
-}
-
-int
-xf86KbdOn(void)
-{
-  struct termio newtio;
-
-  newtio = orig_termio;        /* structure copy */
-  newtio.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
-  newtio.c_oflag = 0;
-  newtio.c_cflag = CREAD | CS8 | B9600;
-  newtio.c_lflag = 0;
-  newtio.c_cc[VTIME]=0;
-  newtio.c_cc[VMIN]=1;
-  ioctl(xf86Info.consoleFd, TCSETA, &newtio);
-
-  ioctl (xf86Info.consoleFd, KDSKBMODE, K_RAW);
-  ioctl (xf86Info.consoleFd, PIO_KEYMAP, &noledmap);
-
-  return(xf86Info.consoleFd);
-}
-
-int
-xf86KbdOff(void)
-{
-  ioctl (xf86Info.consoleFd, KDSKBMODE, orig_kbm);
-  ioctl (xf86Info.consoleFd, PIO_KEYMAP, &keymap);
-  ioctl(xf86Info.consoleFd, TCSETA, &orig_termio);
-
-  return(xf86Info.consoleFd);
-}
diff --git a/hw/xfree86/os-support/usl/usl_mouse.c b/hw/xfree86/os-support/usl/usl_mouse.c
index 15a0ac5..aa4600f 100644
--- a/hw/xfree86/os-support/usl/usl_mouse.c
+++ b/hw/xfree86/os-support/usl/usl_mouse.c
@@ -33,7 +33,6 @@
 #include "xf86Priv.h"
 #include "xf86_OSlib.h"
 #include "mipointer.h"
-#include "usl_xqueue.h"
 
 static int
 SupportedInterfaces(void)
@@ -42,7 +41,6 @@ SupportedInterfaces(void)
 }
 
 static const char *internalNames[] = {
-  "Xqueue",
   NULL
 };
 
@@ -55,7 +53,7 @@ BuiltinNames(void)
 static const char *
 DefaultProtocol (void)
 {
-  return "Xqueue";
+  return "OSMouse";
 }
 
 static Bool
@@ -121,7 +119,6 @@ OsMouseProc(DeviceIntPtr pPointer, int w
 static Bool
 OsMousePreInit(InputInfoPtr pInfo, const char *protocol, int flags)
 {
-  /* This is called when the protocol is "Xqueue" */
   MouseDevPtr pMse;
 
   pMse = pInfo->private;
@@ -155,7 +152,7 @@ OsMousePreInit(InputInfoPtr pInfo, const
 
   /* Setup the local procs. */
   pInfo->device_control = OsMouseProc;
-  pInfo->read_input     = NULL;	/* Handled by the XQUEUE signal handler */
+  pInfo->read_input     = NULL;
 
   pInfo->flags |= XI86_CONFIGURED;
   return TRUE;
diff --git a/hw/xfree86/os-support/usl/usl_xqueue.c b/hw/xfree86/os-support/usl/usl_xqueue.c
deleted file mode 100644
index 1615353..0000000
--- a/hw/xfree86/os-support/usl/usl_xqueue.c
+++ /dev/null
@@ -1,359 +0,0 @@
-/* $XdotOrg$ */
-/*
- * Copyright 2005 by Kean Johnston <jkj at sco.com>
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * Copyright 1993-1999 by The XFree86 Project, Inc.
- *
- * 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 the copyright holders not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  The copyright holders make no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-/* $XConsortium$ */
-
-#include "X.h"
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86Xinput.h"
-#include "xf86OSmouse.h"
-#include "usl_xqueue.h"
-
-#ifdef XKB
-#include "inputstr.h"
-#include <X11/extensions/XKB.h>
-#include <X11/extensions/XKBstr.h>
-#include <X11/extensions/XKBsrv.h>
-extern Bool noXkbExtension;
-#endif
-
-#include "xf86Xinput.h"
-#include "mipointer.h"
-
-#if !defined(XQ_WHEEL)
-# define XQ_WHEEL	4
-#endif
-
-/*
- * Implementation notes
- *
- * This code is based on a mixture of the original XFree86 sysv/xqueue.c
- * and information gathered from the SCO X server code (no actual code
- * was used, just the principles).
- *
- * The XFree86 XQUEUE code went to some considerable lengths to implement
- * what it calls "asynchronous XQUEUE". This involved creating a pipe,
- * and writing to that pipe each time an XQUEUE signal is received. The
- * one end of that pipe was then added to the list of selectable file
- * descriptors with AddEnabledDevice(). I completely fail to see the need
- * for this, and this code does not implement that mechanism. The server
- * will be interrupted anyway by the XQUEUE driver, so whether we pull the
- * events off the queue at the time we receive the signal or whether we
- * write to a pipe and then have the main select() loop stop and call us,
- * it makes no difference I can fathom.
- *
- * The code also differs from the original XFree86 code in that it maintains
- * local variables for the number of devices initialized. The original code
- * stored that information in the private data pointer of the mouse structure,
- * but this same code is used for both the keyboard and the mouse, so that
- * was changed.
- *
- * Part of the difficulty in dealing with XQUEUE is that it is a single
- * interface to two devices. The recent changes in XFree86/Xorg try to
- * treat the mouse and keyboard as discrete devices, and the code is
- * structured in such a way that they should be able to be independently
- * opened and closed. But we can't do that with XQUEUE, so we have to
- * centralize XQUEUE access here in this module.
- */
-
-static xqEventQueue *xqQaddr = NULL;
-static int xqSigEnable = 1;
-static int xqEnableCount = 0;
-static struct kd_quemode xqMode;
-
-/*
- * These two pointers are set when the keyboard/mouse handler procs
- * are called to turn them on or off. This is so that we can call the
- * correct PostEvent for the device.
- */
-static InputInfoPtr xqMouse = NULL;
-static InputInfoPtr xqKeyboard = NULL;
-
-static void XqSignalHandler (int signo);
-
-/*
- * Private functions
- */
-static void
-XqReset (void)
-{
-  if (xqEnableCount > 0) {
-    xqQaddr->xq_head = xqQaddr->xq_tail;
-    xqQaddr->xq_sigenable = xqSigEnable;
-  }
-}
-
-#ifdef NOTNEEDED
-static void
-XqLock (void)
-{
-  xqSigEnable = 0;
-  if (xqEnableCount > 0) {
-    xqQaddr->xq_sigenable = xqSigEnable;
-  }
-}
-
-static void
-XqUnlock (void)
-{
-  xqSigEnable = 1;
-  if (xqEnableCount > 0) {
-    xqQaddr->xq_sigenable = xqSigEnable;
-  }
-}
-#endif /* NOTNEEDED */
-
-/*
- * Since this code is shared between two devices, we need to keep track
- * of how many times we've been enabled or disabled. For example, if the
- * keyboard has been turned off, but the mouse hasn't, then we do not
- * want the whole queue off. Only when both devices are turned off do we
- * actually disable Xqueue mode. When either device is turned on, we
- * enable it.
- */
-static int
-XqEnable (InputInfoPtr pInfo)
-{
-  struct sigaction xqsig;
-  static int msefd = -1;
-
-  if (msefd == -1) {
-    msefd = open ("/dev/mouse", O_RDONLY | O_NONBLOCK);
-#if 0
-    msefd = open ("/dev/mouse", O_RDONLY | O_NONBLOCK | O_NOCTTY);
-    if (msefd < 0) {
-      /*
-       * Try giving it a controlling tty 
-       */
-      msefd = open (ttyname(xf86Info.consoleFd), O_RDWR | O_NONBLOCK);
-      if (msefd >= 0)
-	close (msefd);
-      msefd = open ("/dev/mouse", O_RDONLY | O_NONBLOCK | O_NOCTTY);
-      if (msefd < 0)
-	sleep(2);
-    }
-#endif
-  }
-
-  if (msefd < 0) {
-    if (xf86GetAllowMouseOpenFail()) {
-      ErrorF("%s: cannot open /dev/mouse (%s)\n",
-	ttyname(xf86Info.consoleFd), strerror(errno));
-    } else {
-      sleep(5);
-      FatalError ("%s: cannot open /dev/mouse (%s)\n",
-	ttyname(xf86Info.consoleFd), strerror(errno));
-    }
-  }
- 
-  if (xqEnableCount++ == 0) {
-    xqMode.qaddr = 0;
-    ioctl (xf86Info.consoleFd, KDQUEMODE, NULL);
-
-    /*
-     * Note: We need to make sure the signal is armed before we enable
-     * XQUEUE mode, so that if we get events immediately after the ioctl
-     * we dont have an unhandled signal coming to the Xserver.
-     * Also note that we use sigaction, so that we do not have to re-arm
-     * the signal every time it is delivered, which just slows things
-     * down (setting a signal is a fairly expensive operation).
-     */
-
-    xqsig.sa_handler = XqSignalHandler;
-    sigfillset (&xqsig.sa_mask);
-    xqsig.sa_flags = 0;
-    sigaction (SIGUSR2, &xqsig, NULL);
-
-    /*
-     * This is a fairly large queue size. Since we are reacting to events
-     * asynchronously, its best for performance if we deal with as many
-     * events as possible, and high resolution mice generate a lot of
-     * events.
-     */
-    xqMode.qsize = 64;
-    xqMode.signo = SIGUSR2;
-    xqMode.qaddr = 0;
-    if (ioctl (xf86Info.consoleFd, KDQUEMODE, &xqMode) < 0) {
-      xf86Msg (X_ERROR, "%s: could not set XQUEUE mode (%s)", pInfo->name,
-	strerror(errno));
-      xqEnableCount--;
-
-      xqsig.sa_handler = SIG_DFL;
-      sigfillset (&xqsig.sa_mask);
-      xqsig.sa_flags = 0;
-      sigaction (SIGUSR2, &xqsig, NULL);
-
-      return !Success;
-    }
-
-    /*
-     * We're in business. The workstation is now in XQUEUE mode.
-     */
-    xqQaddr = (xqEventQueue *)xqMode.qaddr;
-    xqQaddr->xq_sigenable = 0; /* LOCK */
-    nap(500);
-    XqReset();
-  }
-  return Success;
-}
-
-static int
-XqDisable (InputInfoPtr pInfo)
-{
-  struct sigaction xqsig;
-
-  if (xqEnableCount-- == 1) {
-    xqQaddr->xq_sigenable = 0; /* LOCK */
-
-    if (ioctl (xf86Info.consoleFd, KDQUEMODE, NULL) < 0) {
-      xf86Msg (X_ERROR, "%s: could not unset XQUEUE mode (%s)", pInfo->name,
-	strerror(errno));
-      xqEnableCount++;
-      return !Success;
-    }
-
-    xqsig.sa_handler = SIG_DFL;
-    sigfillset (&xqsig.sa_mask);
-    xqsig.sa_flags = 0;
-    sigaction (SIGUSR2, &xqsig, NULL);
-  }
-
-  return Success;
-}
-
-/*
- * XQUEUE signal handler. This is what goes through the list of events
- * we've already received and dispatches them to either the keyboard or
- * mouse event poster.
- */
-static void
-XqSignalHandler (int signo)
-{
-  xqEvent	*xqEvents = xqQaddr->xq_events;
-  int		xqHead = xqQaddr->xq_head;
-  xEvent	xE;
-  MouseDevPtr	pMse = NULL;
-  KbdDevPtr	pKbd = NULL;
-  signed char	dx, dy;
-
-  if (xqMouse)
-    pMse = (MouseDevPtr)xqMouse->private;
-  if (xqKeyboard)
-    pKbd = (KbdDevPtr)xqKeyboard->private;
-
-  while (xqHead != xqQaddr->xq_tail) {
-
-    switch (xqEvents[xqHead].xq_type) {
-      case XQ_MOTION:
-	dx = (signed char)xqEvents[xqHead].xq_x;
-	dy = (signed char)xqEvents[xqHead].xq_y;
-	if (pMse)
-	  pMse->PostEvent(xqMouse, ~(xqEvents[xqHead].xq_code) & 0x07,
-			  (int)dx, (int)dy, 0, 0);
-	break;
-
-      case XQ_BUTTON:
-	if (pMse)
-	  pMse->PostEvent(xqMouse, ~(xqEvents[xqHead].xq_code) & 0x07,
-			  0, 0, 0, 0);
-	break;
-
-      case XQ_WHEEL:
-	if (pMse) {
-	  int wbut = pMse->lastButtons, dz;
-	  if (xqEvents[xqHead].xq_code == 1)
-	    dz = 1;
-	  else
-	    dz = -1;
-	  pMse->PostEvent(xqMouse, wbut, 0, 0, dz, 0);
-	}
-	break;
-
-      case XQ_KEY:
-	if (pKbd)
-	  pKbd->PostEvent(xqKeyboard, xqEvents[xqHead].xq_code & 0x7f,
-	    xqEvents[xqHead].xq_code & 0x80 ? FALSE : TRUE);
-	break;
-
-      default:
-	xf86Msg(X_WARNING, "XQUEUE: unknown event type %d\n",
-	  xqEvents[xqHead].xq_type);
-	break;
-    }
-
-    xqHead++;
-    if (xqHead == xqQaddr->xq_size)
-      xqHead = 0;
-    xf86Info.inputPending = TRUE;
-  }
-
-  XqReset();
-}
-
-/*
- * Public functions
- */
-int
-XqMseOnOff (InputInfoPtr pInfo, int on)
-{
-  if (on) {
-    if (xqMouse) {
-      if (xqMouse != pInfo)
-	xf86Msg(X_WARNING, "XqMseOnOff: mouse pointer structure changed!\n");
-      xqMouse = pInfo;
-    } else {
-      xqMouse = pInfo;
-      return XqEnable(pInfo);
-    }
-  } else {
-    xqMouse = NULL;
-    return XqDisable(pInfo);
-  }
-  return Success;
-}
-
-int
-XqKbdOnOff (InputInfoPtr pInfo, int on)
-{
-  if (on) {
-    if (xqKeyboard) {
-      if (xqKeyboard != pInfo)
-	xf86Msg(X_WARNING, "XqKbdOnOff: keyboard pointer structure changed!\n");
-      xqKeyboard = pInfo;
-    } else {
-      xqKeyboard = pInfo;
-      return XqEnable(pInfo);
-    }
-  } else {
-    xqKeyboard = NULL;
-    return XqDisable(pInfo);
-  }
-  return Success;
-}
-
diff --git a/hw/xfree86/os-support/usl/usl_xqueue.h b/hw/xfree86/os-support/usl/usl_xqueue.h
deleted file mode 100644
index bad86a9..0000000
--- a/hw/xfree86/os-support/usl/usl_xqueue.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* $XdotOrg$ */
-
-#ifndef _XF86_USL_XQUEUE_H_
-#define _XF86_USL_XQUEUE_H_
-
-extern int XqMseOnOff (InputInfoPtr pInfo, int on);
-extern int XqKbdOnOff (InputInfoPtr pInfo, int on);
-
-#endif
diff --git a/hw/xfree86/os-support/xf86_OSlib.h b/hw/xfree86/os-support/xf86_OSlib.h
index e048547..97f8723 100644
--- a/hw/xfree86/os-support/xf86_OSlib.h
+++ b/hw/xfree86/os-support/xf86_OSlib.h
@@ -235,15 +235,6 @@ typedef signed long xf86ssize_t;
 #  define i386 /* not defined in ANSI C mode */
 # endif /* ATT && !i386 */
 
-# if (defined(ATT) || defined(SVR4)) && !defined(sun)
-#  ifndef __UNIXWARE__
-#   ifndef XQUEUE
-#    define XQUEUE
-#   endif
-#  endif
-#  include <sys/xque.h>
-# endif /* ATT || SVR4 */
-
 # ifdef SYSV
 #  if !defined(ISC) || defined(ISC202) || defined(ISC22)
 #   define NEED_STRERROR
diff --git a/hw/xfree86/os-support/xf86_OSproc.h b/hw/xfree86/os-support/xf86_OSproc.h
index 89a3301..c987d75 100644
--- a/hw/xfree86/os-support/xf86_OSproc.h
+++ b/hw/xfree86/os-support/xf86_OSproc.h
@@ -135,10 +135,6 @@ extern void xf86WrapperInit(void);
 #include <X11/Xfuncproto.h>
 #include "opaque.h"
 
-#if defined(XQUEUE)
-#include "input.h"	/* for DeviceIntPtr */
-#endif
-
 _XFUNCPROTOBEGIN
 
 /* public functions */
@@ -224,21 +220,7 @@ extern Bool xf86VTSwitchTo(void);
 extern void xf86VTRequest(int sig);
 extern int xf86ProcessArgument(int, char **, int);
 extern void xf86UseMsg(void);
-extern void xf86SetKbdLeds(int);
-extern int xf86GetKbdLeds(void);
-extern void xf86SetKbdRepeat(char);
-extern void xf86KbdInit(void);
-extern int xf86KbdOn(void);
-extern int xf86KbdOff(void);
-extern void xf86KbdEvents(void);
-#ifdef XQUEUE
-extern int  xf86XqueKbdProc(DeviceIntPtr, int);
-extern void xf86XqueEvents(void);
-#endif
 extern void xf86ReloadInputDevs(int sig);
-#ifdef WSCONS_SUPPORT
-extern void xf86WSKbdEvents(void);
-#endif
 extern PMClose xf86OSPMOpen(void);
 
 #ifdef NEED_OS_RAC_PROTOS
diff --git a/hw/xfree86/utils/xorgcfg/mouse-cfg.c b/hw/xfree86/utils/xorgcfg/mouse-cfg.c
index 6c29c1f..5bae6d3 100644
--- a/hw/xfree86/utils/xorgcfg/mouse-cfg.c
+++ b/hw/xfree86/utils/xorgcfg/mouse-cfg.c
@@ -60,9 +60,6 @@ static struct MouseProtocol {
 #ifdef __SCO__
     {"OsMouse",			MTYPE_AUTOMOUSE},
 #endif
-#if defined(__UNIXWARE__)
-    {"Xqueue",			MTYPE_XQUEUE},
-#endif
 #ifdef WSCONS_SUPPORT
     {"wsmouse",			MTYPE_AUTOMOUSE},
 #endif
diff --git a/hw/xfree86/utils/xorgcfg/text-mode.c b/hw/xfree86/utils/xorgcfg/text-mode.c
index 5bb5648..74647fd 100644
--- a/hw/xfree86/utils/xorgcfg/text-mode.c
+++ b/hw/xfree86/utils/xorgcfg/text-mode.c
@@ -361,9 +361,6 @@ static char *protocols[] = {
 #ifdef __SCO__
     "OsMouse",
 #endif
-#ifdef __UNIXWARE__
-    "Xqueue",
-#endif
 #ifdef WSCONS_SUPPORT
     "wsmouse",
 #endif
diff --git a/hw/xfree86/utils/xorgconfig/xorgconfig.c b/hw/xfree86/utils/xorgconfig/xorgconfig.c
index e00830a..f717483 100644
--- a/hw/xfree86/utils/xorgconfig/xorgconfig.c
+++ b/hw/xfree86/utils/xorgconfig/xorgconfig.c
@@ -2068,12 +2068,6 @@ static char *XF86Config_fontpathchunk_te
 "    Identifier	\"Keyboard1\"\n"
 "    Driver	\"kbd\"\n"
 "\n"
-"# For most OSs the protocol can be omitted (it defaults to \"Standard\").\n"
-"# When using XQUEUE (only for SVR3 and SVR4, but not Solaris),\n"
-"# uncomment the following line.\n"
-"\n"
-"#    Option     \"Protocol\"      \"Xqueue\"\n"
-"\n"
 "    Option \"AutoRepeat\" \"500 30\"\n"
 "\n"
 "# Specify which keyboard LEDs can be user-controlled (eg, with xset(1))\n"
@@ -2125,7 +2119,7 @@ static char *pointersection_text1 = 
 "\n"
 "# Identifier and driver\n"
 "\n"
-#if defined(__UNIXWARE__) || defined(XQUEUE)
+#if defined(__UNIXWARE__)
 "#    Identifier	\"Mouse1\"\n"
 "#    Driver	\"mouse\"\n"
 #else
@@ -2136,15 +2130,6 @@ static char *pointersection_text1 = 
 
 static char *pointersection_text2 =
 "\n"
-"# When using XQUEUE, comment out the above two lines, and uncomment\n"
-"# the following line.\n"
-"\n"
-#if defined(__UNIXWARE__) || defined(XQUEUE)
-"    Option \"Protocol\"	\"Xqueue\"\n"
-#else
-"#    Option \"Protocol\"	\"Xqueue\"\n"
-#endif
-"\n"
 "# Mouse-speed setting for PS/2 mouse.\n"
 "\n"
 "#    Option \"Resolution\"	\"256\"\n"
diff --git a/hw/xfree86/xorgconf.cpp b/hw/xfree86/xorgconf.cpp
index c94c1e5..9de7e2b 100644
--- a/hw/xfree86/xorgconf.cpp
+++ b/hw/xfree86/xorgconf.cpp
@@ -181,12 +181,6 @@ Section "InputDevice"
     Identifier	"Keyboard1"
     Driver	"keyboard"
 
-XCOMM For most OSs the protocol can be omitted (it defaults to "Standard").
-XCOMM When using XQUEUE (only for SVR3 and SVR4, but not Solaris), comment
-XCOMM out the above line, and uncomment the following line.
-
-XCOMM    Option	"Protocol"	"Xqueue"
-
 XCOMM Set the keyboard auto repeat parameters.  Not all platforms implement
 XCOMM this.
 
@@ -270,12 +264,6 @@ XCOMM be available.
 
 XCOMM    Option "Protocol"	"PS/2"
 
-XCOMM When using XQUEUE (only for SVR3 and SVR4, but not Solaris), use
-XCOMM the following instead of any of the lines above.  The Device line
-XCOMM is not required in this case.
-
-XCOMM    Option	"Protocol"	"Xqueue"
-
 XCOMM Baudrate and SampleRate are only for some older Logitech mice.  In
 XCOMM almost every case these lines should be omitted.
 
diff-tree 26c3cd1c9e3f52548389817a6d89a377e20c4269 (from parents)
Merge: 008aa7eb6ed090384e6c44f861410e317c78a1cd c4951e0a6b6cf3eeee710cc5cda1d9bc929ee3d7
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Aug 12 18:58:18 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree 008aa7eb6ed090384e6c44f861410e317c78a1cd (from 9525c2709ea3245c6518d4c3b5a0a4afff37181d)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Aug 12 18:56:05 2006 +0300

    completely remove OS keyboard layer
    Completely axe the keyboard layer from os-support.

diff --git a/hw/xfree86/common/xf86MiscExt.c b/hw/xfree86/common/xf86MiscExt.c
index 20ad182..b6f3874 100644
--- a/hw/xfree86/common/xf86MiscExt.c
+++ b/hw/xfree86/common/xf86MiscExt.c
@@ -61,7 +61,6 @@
 #endif
 
 #include "xf86OSmouse.h"
-#include "xf86OSKbd.h"
 
 #ifdef DEBUG
 # define DEBUG_P(x) ErrorF(x"\n");
@@ -259,59 +258,21 @@ MiscExtGetKbdSettings(pointer *kbd)
 {
     kbdParamsPtr kbdptr;
     InputInfoPtr pInfo;
-    KbdDevPtr pKbd;
 
     DEBUG_P("MiscExtGetKbdSettings");
 
-    kbdptr = MiscExtCreateStruct(MISC_KEYBOARD);
-    if (!kbdptr)
-	return FALSE;
-
-    pInfo = inputInfo.keyboard->public.devicePrivate;
-    pKbd = (KbdDevPtr) pInfo->private;
-
-    kbdptr->type  = pKbd->kbdType;
-    kbdptr->rate  = pKbd->rate;
-    kbdptr->delay = pKbd->delay;
-    *kbd = kbdptr;
-
-    return TRUE;
+    return FALSE;
 }
 
 _X_EXPORT int
 MiscExtGetKbdValue(pointer keyboard, MiscExtKbdValType valtype)
 {
-    kbdParamsPtr kbd = keyboard;
-
-    DEBUG_P("MiscExtGetKbdValue");
-    switch (valtype) {
-	case MISC_KBD_TYPE:		return kbd->type;
-	case MISC_KBD_RATE:		return kbd->rate;
-	case MISC_KBD_DELAY:		return kbd->delay;
-	case MISC_KBD_SERVNUMLOCK:	return 0;
-    }
     return 0;
 }
 
 _X_EXPORT Bool
 MiscExtSetKbdValue(pointer keyboard, MiscExtKbdValType valtype, int value)
 {
-    kbdParamsPtr kbd = keyboard;
-
-    DEBUG_P("MiscExtSetKbdValue");
-    switch (valtype) {
-	case MISC_KBD_TYPE:
-		kbd->type = value;
-		return TRUE;
-	case MISC_KBD_RATE:
-		kbd->rate = value;
-		return TRUE;
-	case MISC_KBD_DELAY:
-		kbd->delay = value;
-		return TRUE;
-	case MISC_KBD_SERVNUMLOCK:
-		return TRUE;
-    }
     return FALSE;
 }
 
@@ -595,39 +556,7 @@ MiscExtApply(pointer structure, MiscExtS
 	   xf86ReplaceBoolOption(pInfo->options, "ClearRTS",
 				 pMse->mouseFlags | MF_CLEAR_RTS);
     }
-    if (mse_or_kbd == MISC_KEYBOARD) {
-	kbdParamsPtr kbd = structure;
-        InputInfoPtr pInfo;
-        KbdDevPtr pKbd;
-
-        pInfo = inputInfo.keyboard->public.devicePrivate;
-        pKbd = (KbdDevPtr) pInfo->private;
-
-	if (kbd->rate < 0)
-	    return MISC_RET_BADVAL;
-	if (kbd->delay < 0)
-	    return MISC_RET_BADVAL;
-	if (kbd->type < KTYPE_UNKNOWN || kbd->type > KTYPE_XQUEUE)
-	    return MISC_RET_BADKBDTYPE;
-
-	if (pKbd->rate!=kbd->rate || pKbd->delay!=kbd->delay) {
-	    char rad;
-
-	    pKbd->rate = kbd->rate;
-	    pKbd->delay = kbd->delay;
-	    if      (pKbd->delay <= 375) rad = 0x00;
-	    else if (pKbd->delay <= 625) rad = 0x20;
-	    else if (pKbd->delay <= 875) rad = 0x40;
-	    else                         rad = 0x60;
-
-	    if      (pKbd->rate <=  2)   rad |= 0x1F;
-	    else if (pKbd->rate >= 30)   rad |= 0x00;
-	    else                         rad |= ((58/pKbd->rate)-2);
-
-	    pKbd->SetKbdRepeat(pInfo, rad);
-	}
-    }
-    return MISC_RET_SUCCESS;
+    return MISC_RET_BADVAL;
 }
 
 _X_EXPORT Bool
diff --git a/hw/xfree86/common/xf86Versions.c b/hw/xfree86/common/xf86Versions.c
index e984e80..97a3559 100644
--- a/hw/xfree86/common/xf86Versions.c
+++ b/hw/xfree86/common/xf86Versions.c
@@ -31,7 +31,6 @@
 
 #include "xf86.h"
 #include "xf86OSmouse.h"
-#include "xf86OSKbd.h"
 
 static CARD32 registeredVersions[NUM_BUILTIN_IFS];
 
@@ -51,8 +50,6 @@ xf86GetBuiltinInterfaceVersion(BuiltinIn
     switch (iface) {
     case BUILTIN_IF_OSMOUSE:
 	return OS_MOUSE_VERSION_CURRENT;
-    case BUILTIN_IF_OSKBD:
-	return OS_KBD_VERSION_CURRENT;
     default:
 	xf86Msg(X_ERROR, "xf86GetBuiltinInterfaceVersion: internal error: "
 		"interface %d not handled\n", iface);
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 041b203..586d5dc 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -70,7 +70,6 @@
 # include "xf86Xinput.h"
 #endif
 #include "xf86OSmouse.h"
-#include "xf86OSKbd.h"
 #include "xf86xv.h"
 #include "xf86xvmc.h"
 #include "xf86cmap.h"
@@ -280,7 +279,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86SerialModemClearBits)
     SYMFUNC(xf86LoadKernelModule)
     SYMFUNC(xf86OSMouseInit)
-    SYMFUNC(xf86OSKbdPreInit)
     SYMFUNC(xf86AgpGARTSupported)
     SYMFUNC(xf86GetAGPInfo)
     SYMFUNC(xf86AcquireGART)
diff --git a/hw/xfree86/os-support/Makefile.am b/hw/xfree86/os-support/Makefile.am
index 7897674..a886de8 100644
--- a/hw/xfree86/os-support/Makefile.am
+++ b/hw/xfree86/os-support/Makefile.am
@@ -6,7 +6,7 @@ SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DR
 DIST_SUBDIRS = bsd bus drm misc linux lynxos solaris sysv sco usl
 
 sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h xf86_ansic.h xf86_libc.h \
-              assyntax.h xf86OSKbd.h xf86OSmouse.h
+              assyntax.h xf86OSmouse.h
 
 EXTRA_DIST = int10Defines.h xf86OSpriv.h README.OS-lib xf86drm.h
 
diff --git a/hw/xfree86/os-support/bsd/Makefile.am b/hw/xfree86/os-support/bsd/Makefile.am
index 20885e8..edef4d4 100644
--- a/hw/xfree86/os-support/bsd/Makefile.am
+++ b/hw/xfree86/os-support/bsd/Makefile.am
@@ -55,18 +55,14 @@ AM_CFLAGS = -DUSESTDRES $(XORG_CFLAGS)
 INCLUDES = $(XORG_INCS)
 
 libbsd_la_SOURCES = \
-	$(srcdir)/../shared/at_scancode.c \
 	$(srcdir)/../shared/libc_wrapper.c \
 	$(srcdir)/../shared/posix_tty.c \
 	$(srcdir)/../shared/sigio.c \
-	$(srcdir)/../shared/std_kbdEv.c \
 	$(srcdir)/../shared/stdPci.c \
 	$(srcdir)/../shared/vidmem.c \
 	bsd_VTsw.c \
 	bsd_init.c \
 	bsd_io.c \
-	bsd_kbd.c \
-	bsd_KbdMap.c \
 	bsd_mouse.c \
 	$(ARCH_SOURCES) \
 	$(AGP_SOURCES) \
@@ -80,7 +76,6 @@ libbsd_la_SOURCES = \
 EXTRA_DIST = \
 	bsd_apm.c \
 	bsd_jstk.c \
-	bsd_kbd.h \
 	bsd_kqueue_apm.c \
 	bsdResource.c \
 	memrange.h \
diff --git a/hw/xfree86/os-support/bsd/bsd_KbdMap.c b/hw/xfree86/os-support/bsd/bsd_KbdMap.c
deleted file mode 100644
index d225c1f..0000000
--- a/hw/xfree86/os-support/bsd/bsd_KbdMap.c
+++ /dev/null
@@ -1,1087 +0,0 @@
-/* $XFree86$ */
-
-/*
- * Slightly modified xf86KbdBSD.c which is
- *
- * Derived from xf86Kbd.c by S_ren Schmidt (sos at login.dkuug.dk)
- * which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- * and from xf86KbdCODrv.c by Holger Veit
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h" 
-#include "xf86Xinput.h"
-#include "xf86OSKbd.h"
-#include "atKeynames.h"
-#include "xf86Keymap.h"
-#include "bsd_kbd.h"
-
-#if (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)) && defined(GIO_KEYMAP)
-#define KD_GET_ENTRY(i,n) \
-  eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
-
-static unsigned char remap[NUM_KEYCODES] = {
-     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
-  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
-  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
-  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
-  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
-  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
-  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
-  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
-  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
-     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
-  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
-     0,    0, 0x69, 0x65,    0,    0,    0,    0,   /* 0x70 - 0x77 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
-};
-
-/* This table assumes the ibm code page 437 coding for characters 
- * > 0x80. They are returned in this form by PCVT */
-static KeySym eascii_to_x[512] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	XK_Ccedilla,	XK_udiaeresis,	XK_eacute,	XK_acircumflex,
-	XK_adiaeresis,	XK_agrave,	XK_aring,	XK_ccedilla,
-	XK_ecircumflex,	XK_ediaeresis,	XK_egrave,	XK_idiaeresis,
-	XK_icircumflex,	XK_igrave,	XK_Adiaeresis,	XK_Aring,
-	XK_Eacute,	XK_ae,		XK_AE,		XK_ocircumflex,
-	XK_odiaeresis,	XK_ograve,	XK_ucircumflex,	XK_ugrave,
-	XK_ydiaeresis,	XK_Odiaeresis,	XK_Udiaeresis,	XK_cent,
-	XK_sterling,	XK_yen,		XK_paragraph,	XK_section,
-	XK_aacute,	XK_iacute,	XK_oacute,	XK_uacute,
-	XK_ntilde,	XK_Ntilde,	XK_ordfeminine,	XK_masculine,
-	XK_questiondown,XK_hyphen,	XK_notsign,	XK_onehalf,
-	XK_onequarter,	XK_exclamdown,	XK_guillemotleft,XK_guillemotright,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Greek_alpha,	XK_ssharp,	XK_Greek_GAMMA,	XK_Greek_pi,
-	XK_Greek_SIGMA,	XK_Greek_sigma,	XK_mu,	        XK_Greek_tau,
-	XK_Greek_PHI,	XK_Greek_THETA,	XK_Greek_OMEGA,	XK_Greek_delta,
-	XK_infinity,	XK_Ooblique,	XK_Greek_epsilon, XK_intersection,
-	XK_identical,	XK_plusminus,	XK_greaterthanequal, XK_lessthanequal,
-	XK_topintegral,	XK_botintegral,	XK_division,	XK_similarequal,
-	XK_degree,	NoSymbol,	NoSymbol,	XK_radical,
-	XK_Greek_eta,	XK_twosuperior,	XK_periodcentered, NoSymbol,
-
-	/* 
-	 * special marked entries (256 + x)
-	 */
-
-	/* This has been checked against what syscons actually does */
-	NoSymbol,	NoSymbol,	XK_Shift_L,	XK_Shift_R,
-	XK_Caps_Lock,	XK_Num_Lock,	XK_Scroll_Lock,	XK_Alt_L,
-	XK_ISO_Left_Tab,XK_Control_L,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_F1,
-	XK_F2,		XK_F3,		XK_F4,		XK_F5,
-	XK_F6,		XK_F7,		XK_F8,		XK_F9,
-	XK_F10,		XK_F11,		XK_F12,		NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Control_R,	XK_Alt_R,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol
-};
-
-#ifdef __OpenBSD__
-/* don't mark AltR and  CtrlR for remapping, since they 
- * cannot be remapped by pccons */
-static unsigned char pccons_remap[128] = {
-     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
-  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
-  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
-  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
-  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
-  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
-  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
-  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
-  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
-     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
-  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x70 - 0x77 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
-};
-
-/* This table assumes an iso8859_1 encoding for the characters 
- * > 80, as returned by pccons */
-static KeySym latin1_to_x[256] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_nobreakspace,XK_exclamdown,	XK_cent,	XK_sterling,
-	XK_currency,	XK_yen,		XK_brokenbar,	XK_section,
-	XK_diaeresis,	XK_copyright,	XK_ordfeminine,	XK_guillemotleft,
-	XK_notsign,	XK_hyphen,	XK_registered,	XK_macron,
-	XK_degree,	XK_plusminus,	XK_twosuperior,	XK_threesuperior,
-	XK_acute,	XK_mu,		XK_paragraph,	XK_periodcentered,
-	XK_cedilla,	XK_onesuperior,	XK_masculine,	XK_guillemotright,
-	XK_onequarter,	XK_onehalf,	XK_threequarters,XK_questiondown,
-	XK_Agrave,	XK_Aacute,	XK_Acircumflex,	XK_Atilde,
-	XK_Adiaeresis,	XK_Aring,	XK_AE,		XK_Ccedilla,
-	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
-	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
-	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
-	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_multiply,
-	XK_Ooblique,	XK_Ugrave,	XK_Uacute,	XK_Ucircumflex,
-	XK_Udiaeresis,	XK_Yacute,	XK_THORN,	XK_ssharp,
-	XK_agrave,	XK_aacute,	XK_acircumflex,	XK_atilde,
-	XK_adiaeresis,	XK_aring,	XK_ae,	        XK_ccedilla,
-	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
-	XK_igrave,	XK_iacute,	XK_icircumflex, XK_idiaeresis,
-	XK_eth,		XK_ntilde,	XK_ograve, 	XK_oacute,
-	XK_ocircumflex,	XK_otilde,	XK_odiaeresis,	XK_division,
-	XK_oslash,	XK_ugrave,	XK_uacute,	XK_ucircumflex,
-	XK_udiaeresis,	XK_yacute,	XK_thorn, 	XK_ydiaeresis
-      };
-#endif
-
-#ifdef SYSCONS_SUPPORT
-static
-unsigned char sysconsCODEMap[] = {
-	KEY_KP_Enter,	KEY_RCtrl,	KEY_KP_Divide,	KEY_Print,
-	KEY_AltLang,	KEY_KP_7,	KEY_KP_8,	KEY_KP_9,
-	KEY_KP_4,	KEY_KP_6,	KEY_KP_1,	KEY_KP_2,
-	KEY_KP_3,	KEY_KP_0,	KEY_KP_Decimal,	KEY_Pause,
-	KEY_LMeta,	KEY_RMeta,	KEY_Menu,	KEY_Break
-};
-static
-TransMapRec sysconsCODE = {
-    0x59,
-    0x6d,
-    sysconsCODEMap
-};
-#endif
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
-
-#ifdef WSCONS_SUPPORT
-
-static CARD8 wsUsbMap[] = {
-	/* 0 */ KEY_NOTUSED,
-	/* 1 */ KEY_NOTUSED,
-	/* 2 */ KEY_NOTUSED,
-	/* 3 */ KEY_NOTUSED,
-	/* 4 */ KEY_A,		
-	/* 5 */ KEY_B,
-	/* 6 */ KEY_C,
-	/* 7 */ KEY_D,
-	/* 8 */ KEY_E,
-	/* 9 */ KEY_F,
-	/* 10 */ KEY_G,
-	/* 11 */ KEY_H,
-	/* 12 */ KEY_I,
-	/* 13 */ KEY_J,
-	/* 14 */ KEY_K,
-	/* 15 */ KEY_L,
-	/* 16 */ KEY_M,
-	/* 17 */ KEY_N,
-	/* 18 */ KEY_O,
-	/* 19 */ KEY_P,
-	/* 20 */ KEY_Q,
-	/* 21 */ KEY_R,
-	/* 22 */ KEY_S,
-	/* 23 */ KEY_T,
-	/* 24 */ KEY_U,
-	/* 25 */ KEY_V,
-	/* 26 */ KEY_W,
-	/* 27 */ KEY_X,
-	/* 28 */ KEY_Y,
-	/* 29 */ KEY_Z,
-	/* 30 */ KEY_1,		/* 1 !*/
-	/* 31 */ KEY_2,		/* 2 @ */
-	/* 32 */ KEY_3,		/* 3 # */
-	/* 33 */ KEY_4,		/* 4 $ */
-	/* 34 */ KEY_5,		/* 5 % */
-	/* 35 */ KEY_6,		/* 6 ^ */
-	/* 36 */ KEY_7,		/* 7 & */
-	/* 37 */ KEY_8,		/* 8 * */
-	/* 38 */ KEY_9,		/* 9 ( */
-	/* 39 */ KEY_0,		/* 0 ) */
-	/* 40 */ KEY_Enter,	/* Return  */
-	/* 41 */ KEY_Escape,	/* Escape */
-	/* 42 */ KEY_BackSpace,	/* Backspace Delete */
-	/* 43 */ KEY_Tab,	/* Tab */
-	/* 44 */ KEY_Space,	/* Space */
-	/* 45 */ KEY_Minus,	/* - _ */
-	/* 46 */ KEY_Equal,	/* = + */
-	/* 47 */ KEY_LBrace,	/* [ { */
-	/* 48 */ KEY_RBrace,	/* ] } */
-	/* 49 */ KEY_BSlash,	/* \ | */
-	/* 50 */ KEY_BSlash2,	/* \ _ # ~ on some keyboards */
-	/* 51 */ KEY_SemiColon,	/* ; : */
-	/* 52 */ KEY_Quote,	/* ' " */
-	/* 53 */ KEY_Tilde,	/* ` ~ */
-	/* 54 */ KEY_Comma,	/* , <  */
-	/* 55 */ KEY_Period,	/* . > */
-	/* 56 */ KEY_Slash,	/* / ? */
-	/* 57 */ KEY_CapsLock,	/* Caps Lock */
-	/* 58 */ KEY_F1,		/* F1 */
-	/* 59 */ KEY_F2,		/* F2 */
-	/* 60 */ KEY_F3,		/* F3 */
-	/* 61 */ KEY_F4,		/* F4 */
-	/* 62 */ KEY_F5,		/* F5 */
-	/* 63 */ KEY_F6,		/* F6 */
-	/* 64 */ KEY_F7,		/* F7 */
-	/* 65 */ KEY_F8,		/* F8 */
-	/* 66 */ KEY_F9,		/* F9 */
-	/* 67 */ KEY_F10,	/* F10 */
-	/* 68 */ KEY_F11,	/* F11 */
-	/* 69 */ KEY_F12,	/* F12 */
-	/* 70 */ KEY_Print,	/* PrintScrn SysReq */
-	/* 71 */ KEY_ScrollLock,	/* Scroll Lock */
-	/* 72 */ KEY_Pause,	/* Pause Break */
-	/* 73 */ KEY_Insert,	/* Insert XXX  Help on some Mac Keyboards */
-	/* 74 */ KEY_Home,	/* Home */
-	/* 75 */ KEY_PgUp,	/* Page Up */
-	/* 76 */ KEY_Delete,	/* Delete */
-	/* 77 */ KEY_End,	/* End */
-	/* 78 */ KEY_PgDown,	/* Page Down */
-	/* 79 */ KEY_Right,	/* Right Arrow */
-	/* 80 */ KEY_Left,	/* Left Arrow */
-	/* 81 */ KEY_Down,	/* Down Arrow */
-	/* 82 */ KEY_Up,		/* Up Arrow */
-	/* 83 */ KEY_NumLock,	/* Num Lock */
-	/* 84 */ KEY_KP_Divide,	/* Keypad / */
-	/* 85 */ KEY_KP_Multiply, /* Keypad * */
-	/* 86 */ KEY_KP_Minus,	/* Keypad - */
-	/* 87 */ KEY_KP_Plus,	/* Keypad + */
-	/* 88 */ KEY_KP_Enter,	/* Keypad Enter */
-	/* 89 */ KEY_KP_1,	/* Keypad 1 End */
-	/* 90 */ KEY_KP_2,	/* Keypad 2 Down */
-	/* 91 */ KEY_KP_3,	/* Keypad 3 Pg Down */
-	/* 92 */ KEY_KP_4,	/* Keypad 4 Left  */
-	/* 93 */ KEY_KP_5,	/* Keypad 5 */
-	/* 94 */ KEY_KP_6,	/* Keypad 6 */
-	/* 95 */ KEY_KP_7,	/* Keypad 7 Home */
-	/* 96 */ KEY_KP_8,	/* Keypad 8 Up */
-	/* 97 */ KEY_KP_9,	/* KEypad 9 Pg Up */
-	/* 98 */ KEY_KP_0,	/* Keypad 0 Ins */
-	/* 99 */ KEY_KP_Decimal,	/* Keypad . Del */
-	/* 100 */ KEY_Less,	/* < > on some keyboards */
-	/* 101 */ KEY_Menu,	/* Menu */
-	/* 102 */ KEY_NOTUSED,
-	/* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */
-	/* 104 */ KEY_NOTUSED,
-	/* 105 */ KEY_NOTUSED,
-	/* 106 */ KEY_NOTUSED,
-	/* 107 */ KEY_NOTUSED,
-	/* 108 */ KEY_NOTUSED,
-	/* 109 */ KEY_NOTUSED,
-	/* 110 */ KEY_NOTUSED,
-	/* 111 */ KEY_NOTUSED,
-	/* 112 */ KEY_NOTUSED,
-	/* 113 */ KEY_NOTUSED,
-	/* 114 */ KEY_NOTUSED,
-	/* 115 */ KEY_NOTUSED,
-	/* 116 */ KEY_NOTUSED,
-	/* 117 */ KEY_NOTUSED,
-	/* 118 */ KEY_NOTUSED,
-	/* 119 */ KEY_NOTUSED,
-	/* 120 */ KEY_NOTUSED,
-	/* 121 */ KEY_NOTUSED,
-	/* 122 */ KEY_NOTUSED,
-	/* 123 */ KEY_NOTUSED,
-	/* 124 */ KEY_NOTUSED,
-	/* 125 */ KEY_NOTUSED,
-	/* 126 */ KEY_NOTUSED,
-	/* 127 */ KEY_NOTUSED,
-	/* 128 */ KEY_NOTUSED,
-	/* 129 */ KEY_NOTUSED,
-	/* 130 */ KEY_NOTUSED,
-	/* 131 */ KEY_NOTUSED,
-	/* 132 */ KEY_NOTUSED,
-	/* 133 */ KEY_NOTUSED,
-	/* 134 */ KEY_NOTUSED,
-	/* 135 */ KEY_NOTUSED,
-	/* 136 */ KEY_NOTUSED,
-	/* 137 */ KEY_NOTUSED,
-	/* 138 */ KEY_NOTUSED,
-	/* 139 */ KEY_NOTUSED,
-	/* 140 */ KEY_NOTUSED,
-	/* 141 */ KEY_NOTUSED,
-	/* 142 */ KEY_NOTUSED,
-	/* 143 */ KEY_NOTUSED,
-	/* 144 */ KEY_NOTUSED,
-	/* 145 */ KEY_NOTUSED,
-	/* 146 */ KEY_NOTUSED,
-	/* 147 */ KEY_NOTUSED,
-	/* 148 */ KEY_NOTUSED,
-	/* 149 */ KEY_NOTUSED,
-	/* 150 */ KEY_NOTUSED,
-	/* 151 */ KEY_NOTUSED,
-	/* 152 */ KEY_NOTUSED,
-	/* 153 */ KEY_NOTUSED,
-	/* 154 */ KEY_NOTUSED,
-	/* 155 */ KEY_NOTUSED,
-	/* 156 */ KEY_NOTUSED,
-	/* 157 */ KEY_NOTUSED,
-	/* 158 */ KEY_NOTUSED,
-	/* 159 */ KEY_NOTUSED,
-	/* 160 */ KEY_NOTUSED,
-	/* 161 */ KEY_NOTUSED,
-	/* 162 */ KEY_NOTUSED,
-	/* 163 */ KEY_NOTUSED,
-	/* 164 */ KEY_NOTUSED,
-	/* 165 */ KEY_NOTUSED,
-	/* 166 */ KEY_NOTUSED,
-	/* 167 */ KEY_NOTUSED,
-	/* 168 */ KEY_NOTUSED,
-	/* 169 */ KEY_NOTUSED,
-	/* 170 */ KEY_NOTUSED,
-	/* 171 */ KEY_NOTUSED,
-	/* 172 */ KEY_NOTUSED,
-	/* 173 */ KEY_NOTUSED,
-	/* 174 */ KEY_NOTUSED,
-	/* 175 */ KEY_NOTUSED,
-	/* 176 */ KEY_NOTUSED,
-	/* 177 */ KEY_NOTUSED,
-	/* 178 */ KEY_NOTUSED,
-	/* 179 */ KEY_NOTUSED,
-	/* 180 */ KEY_NOTUSED,
-	/* 181 */ KEY_NOTUSED,
-	/* 182 */ KEY_NOTUSED,
-	/* 183 */ KEY_NOTUSED,
-	/* 184 */ KEY_NOTUSED,
-	/* 185 */ KEY_NOTUSED,
-	/* 186 */ KEY_NOTUSED,
-	/* 187 */ KEY_NOTUSED,
-	/* 188 */ KEY_NOTUSED,
-	/* 189 */ KEY_NOTUSED,
-	/* 190 */ KEY_NOTUSED,
-	/* 191 */ KEY_NOTUSED,
-	/* 192 */ KEY_NOTUSED,
-	/* 193 */ KEY_NOTUSED,
-	/* 194 */ KEY_NOTUSED,
-	/* 195 */ KEY_NOTUSED,
-	/* 196 */ KEY_NOTUSED,
-	/* 197 */ KEY_NOTUSED,
-	/* 198 */ KEY_NOTUSED,
-	/* 199 */ KEY_NOTUSED,
-	/* 200 */ KEY_NOTUSED,
-	/* 201 */ KEY_NOTUSED,
-	/* 202 */ KEY_NOTUSED,
-	/* 203 */ KEY_NOTUSED,
-	/* 204 */ KEY_NOTUSED,
-	/* 205 */ KEY_NOTUSED,
-	/* 206 */ KEY_NOTUSED,
-	/* 207 */ KEY_NOTUSED,
-	/* 208 */ KEY_NOTUSED,
-	/* 209 */ KEY_NOTUSED,
-	/* 210 */ KEY_NOTUSED,
-	/* 211 */ KEY_NOTUSED,
-	/* 212 */ KEY_NOTUSED,
-	/* 213 */ KEY_NOTUSED,
-	/* 214 */ KEY_NOTUSED,
-	/* 215 */ KEY_NOTUSED,
-	/* 216 */ KEY_NOTUSED,
-	/* 217 */ KEY_NOTUSED,
-	/* 218 */ KEY_NOTUSED,
-	/* 219 */ KEY_NOTUSED,
-	/* 220 */ KEY_NOTUSED,
-	/* 221 */ KEY_NOTUSED,
-	/* 222 */ KEY_NOTUSED,
-	/* 223 */ KEY_NOTUSED,
-	/* 224 */ KEY_LCtrl,	/* Left Control */
-	/* 225 */ KEY_ShiftL,	/* Left Shift */
-	/* 226 */ KEY_Alt,	/* Left Alt */
-	/* 227 */ KEY_LMeta,	/* Left Meta */
-	/* 228 */ KEY_RCtrl,	/* Right Control */
-	/* 229 */ KEY_ShiftR,	/* Right Shift */
-	/* 230 */ KEY_AltLang,	/* Right Alt, AKA AltGr */
-	/* 231 */ KEY_LMeta,	/* Right Meta XXX */
-};
-#define WS_USB_MAP_SIZE (sizeof(wsUsbMap)/sizeof(unsigned char))
-
-static
-TransMapRec wsUsb = {
-    0,
-    WS_USB_MAP_SIZE,
-    wsUsbMap
-};
-
-/* Map for adb keyboards  */
-static CARD8 wsAdbMap[] = {
-	/* 0 */ KEY_A,
-	/* 1 */ KEY_S,
-	/* 2 */ KEY_D,
-	/* 3 */ KEY_F,
-	/* 4 */ KEY_H,
-	/* 5 */ KEY_G,
-	/* 6 */ KEY_Z,
-	/* 7 */ KEY_X,
-	/* 8 */ KEY_C,
-	/* 9 */ KEY_V,
-	/* 10 */ KEY_UNKNOWN,	/* @ # on french keyboards */
-	/* 11 */ KEY_B,
-	/* 12 */ KEY_Q,
-	/* 13 */ KEY_W,
-	/* 14 */ KEY_E,
-	/* 15 */ KEY_R,
-	/* 16 */ KEY_Y,
-	/* 17 */ KEY_T,
-	/* 18 */ KEY_1,
-	/* 19 */ KEY_2,
-	/* 20 */ KEY_3,
-	/* 21 */ KEY_4,
-	/* 22 */ KEY_6,
-	/* 23 */ KEY_5,
-	/* 24 */ KEY_Equal,
-	/* 25 */ KEY_9,
-	/* 26 */ KEY_7,
-	/* 27 */ KEY_Minus,
-	/* 28 */ KEY_8,
-	/* 29 */ KEY_0,
-	/* 30 */ KEY_RBrace,
-	/* 31 */ KEY_O,
-	/* 32 */ KEY_U,
-	/* 33 */ KEY_LBrace,
-	/* 34 */ KEY_I,
-	/* 35 */ KEY_P,
-	/* 36 */ KEY_Enter,
-	/* 37 */ KEY_L,
-	/* 38 */ KEY_J,
-	/* 39 */ KEY_Quote,
-	/* 40 */ KEY_K,
-	/* 41 */ KEY_SemiColon,
-	/* 42 */ KEY_BSlash,
-	/* 43 */ KEY_Comma,
-	/* 44 */ KEY_Slash,
-	/* 45 */ KEY_N,
-	/* 46 */ KEY_M,
-	/* 47 */ KEY_Period,
-	/* 48 */ KEY_Tab,
-	/* 49 */ KEY_Space,
-	/* 50 */ KEY_Tilde,
-	/* 51 */ KEY_Delete,
-	/* 52 */ KEY_AltLang,
-	/* 53 */ KEY_Escape,
-	/* 54 */ KEY_LCtrl,
-	/* 55 */ KEY_Alt,
-	/* 56 */ KEY_ShiftL,
-	/* 57 */ KEY_CapsLock,
-	/* 58 */ KEY_LMeta,
-	/* 59 */ KEY_Left,
-	/* 60 */ KEY_Right,
-	/* 61 */ KEY_Down,
-	/* 62 */ KEY_Up,
-	/* 63 */ KEY_UNKNOWN,	/* Fn */
-	/* 64 */ KEY_NOTUSED,
-	/* 65 */ KEY_KP_Decimal,
-	/* 66 */ KEY_NOTUSED,
-	/* 67 */ KEY_KP_Multiply,
-	/* 68 */ KEY_NOTUSED,
-	/* 69 */ KEY_KP_Plus,
-	/* 70 */ KEY_NOTUSED,
-	/* 71 */ KEY_UNKNOWN,	/* Clear */
-	/* 72 */ KEY_NOTUSED, 
-	/* 73 */ KEY_NOTUSED,
-	/* 74 */ KEY_NOTUSED,
-	/* 75 */ KEY_KP_Divide,
-	/* 76 */ KEY_KP_Enter,
-	/* 77 */ KEY_NOTUSED,
-	/* 78 */ KEY_KP_Minus,
-	/* 79 */ KEY_NOTUSED,
-	/* 80 */ KEY_NOTUSED,
-	/* 81 */ KEY_KP_Equal,	/* Keypad = */
-	/* 82 */ KEY_KP_0,
-	/* 83 */ KEY_KP_1,
-	/* 84 */ KEY_KP_2,
-	/* 85 */ KEY_KP_3,
-	/* 86 */ KEY_KP_4,
-	/* 87 */ KEY_KP_5,
-	/* 88 */ KEY_KP_6,
-	/* 89 */ KEY_KP_7,
-	/* 90 */ KEY_NOTUSED,
-	/* 91 */ KEY_KP_8,
-	/* 92 */ KEY_KP_9,
-	/* 93 */ KEY_NOTUSED,
-	/* 94 */ KEY_NOTUSED,
-	/* 95 */ KEY_UNKNOWN,	/* Keypad ,  */
-	/* 96 */ KEY_F5,
-	/* 97 */ KEY_F6,
-	/* 98 */ KEY_F7,
-	/* 99 */ KEY_F3,
-	/* 100 */ KEY_F8,
-	/* 101 */ KEY_F9,
-	/* 102 */ KEY_NOTUSED,
-	/* 103 */ KEY_F11,
-	/* 104 */ KEY_NOTUSED,
-	/* 105 */ KEY_NOTUSED,
-	/* 106 */ KEY_KP_Enter,
-	/* 107 */ KEY_NOTUSED,
-	/* 108 */ KEY_NOTUSED,
-	/* 109 */ KEY_F10,
-	/* 110 */ KEY_NOTUSED,
-	/* 111 */ KEY_F12,
-	/* 112 */ KEY_NOTUSED,
-	/* 113 */ KEY_NOTUSED,
-	/* 114 */ KEY_NOTUSED,
-	/* 115 */ KEY_Home,
-	/* 116 */ KEY_PgUp,
-	/* 117 */ KEY_NOTUSED,
-	/* 118 */ KEY_F4,
-	/* 119 */ KEY_End,
-	/* 120 */ KEY_F2,
-	/* 121 */ KEY_PgDown,
-	/* 122 */ KEY_F1
-};
-#define WS_ADB_MAP_SIZE (sizeof(wsAdbMap)/sizeof(unsigned char))
-
-static
-TransMapRec wsAdb = {
-    0,
-    WS_ADB_MAP_SIZE,
-    wsAdbMap
-};
-
-static CARD8 wsSunMap[] = {
-	/* 0x00 */ KEY_Help,
-	/* 0x01 */ KEY_L1,		/* stop */
-	/* 0x02 */ KEY_AudioLower,	/* BrightnessDown / S-VolumeDown */
-	/* 0x03 */ KEY_L2,		/* again */
-	/* 0x04 */ KEY_AudioRaise,	/* BridgtnessUp / S-VolumeUp */
-	/* 0x05 */ KEY_F1,
-	/* 0x06 */ KEY_F2,
-	/* 0x07 */ KEY_F10,
-	/* 0x08 */ KEY_F3,
-	/* 0x09 */ KEY_F11,
-	/* 0x0a */ KEY_F4,
-	/* 0x0b */ KEY_F12,
-	/* 0x0c */ KEY_F5,
-	/* 0x0d */ KEY_AltLang,
-	/* 0x0e */ KEY_F6,
-	/* 0x0f */ KEY_NOTUSED,
-	/* 0x10 */ KEY_F7,
-	/* 0x11 */ KEY_F8,
-	/* 0x12 */ KEY_F9,
-	/* 0x13 */ KEY_Alt,
-	/* 0x14 */ KEY_Up,
-	/* 0x15 */ KEY_Pause,
-	/* 0x16 */ KEY_Print,
-	/* 0x17 */ KEY_ScrollLock,
-	/* 0x18 */ KEY_Left,
-	/* 0x19 */ KEY_L3,		/* props */
-	/* 0x1a */ KEY_L4,		/* undo */
-	/* 0x1b */ KEY_Down,
-	/* 0x1c */ KEY_Right,
-	/* 0x1d */ KEY_Escape,
-	/* 0x1e */ KEY_1,
-	/* 0x1f */ KEY_2,
-	/* 0x20 */ KEY_3,
-	/* 0x21 */ KEY_4,
-	/* 0x22 */ KEY_5,
-	/* 0x23 */ KEY_6,
-	/* 0x24 */ KEY_7,
-	/* 0x25 */ KEY_8,
-	/* 0x26 */ KEY_9,
-	/* 0x27 */ KEY_0,
-	/* 0x28 */ KEY_Minus,
-	/* 0x29 */ KEY_Equal,
-	/* 0x2a */ KEY_Tilde,
-	/* 0x2b */ KEY_BackSpace,
-	/* 0x2c */ KEY_Insert,
-	/* 0x2d */ KEY_Mute,		/* Audio Mute */
-	/* 0x2e */ KEY_KP_Divide,
-	/* 0x2f */ KEY_KP_Multiply,
-	/* 0x30 */ KEY_NOTUSED,
-	/* 0x31 */ KEY_L5,		/* front */
-	/* 0x32 */ KEY_KP_Decimal,
-	/* 0x33 */ KEY_L6,		/* copy */
-	/* 0x34 */ KEY_Home,
-	/* 0x35 */ KEY_Tab,
-	/* 0x36 */ KEY_Q,
-	/* 0x37 */ KEY_W,
-	/* 0x38 */ KEY_E,
-	/* 0x39 */ KEY_R,
-	/* 0x3a */ KEY_T,
-	/* 0x3b */ KEY_Y,
-	/* 0x3c */ KEY_U,
-	/* 0x3d */ KEY_I,
-	/* 0x3e */ KEY_O,
-	/* 0x3f */ KEY_P,
-	/* 0x40 */ KEY_LBrace,
-	/* 0x41 */ KEY_RBrace,
-	/* 0x42 */ KEY_Delete,
-	/* 0x43 */ KEY_Menu,		/* compose */
-	/* 0x44 */ KEY_KP_7,
-	/* 0x45 */ KEY_KP_8,
-	/* 0x46 */ KEY_KP_9,
-	/* 0x47 */ KEY_KP_Minus,
-	/* 0x48 */ KEY_L7,		/* open */
-	/* 0x49 */ KEY_L8,		/* paste */
-	/* 0x4a */ KEY_End,
-	/* 0x4b */ KEY_NOTUSED,
-	/* 0x4c */ KEY_LCtrl,
-	/* 0x4d */ KEY_A,
-	/* 0x4e */ KEY_S,
-	/* 0x4f */ KEY_D,
-	/* 0x50 */ KEY_F,
-	/* 0x51 */ KEY_G,
-	/* 0x52 */ KEY_H,
-	/* 0x53 */ KEY_J,
-	/* 0x54 */ KEY_K,
-	/* 0x55 */ KEY_L,
-	/* 0x56 */ KEY_SemiColon,
-	/* 0x57 */ KEY_Quote,
-	/* 0x58 */ KEY_BSlash,
-	/* 0x59 */ KEY_Enter,
-	/* 0x5a */ KEY_KP_Enter,
-	/* 0x5b */ KEY_KP_4,
-	/* 0x5c */ KEY_KP_5,
-	/* 0x5d */ KEY_KP_6,
-	/* 0x5e */ KEY_KP_0,
-	/* 0x5f */ KEY_L9,		/* find */
-	/* 0x60 */ KEY_PgUp,
-	/* 0x61 */ KEY_L10,		/* cut */
-	/* 0x62 */ KEY_NumLock,
-	/* 0x63 */ KEY_ShiftL,
-	/* 0x64 */ KEY_Z,
-	/* 0x65 */ KEY_X,
-	/* 0x66 */ KEY_C,
-	/* 0x67 */ KEY_V,
-	/* 0x68 */ KEY_B,
-	/* 0x69 */ KEY_N,
-	/* 0x6a */ KEY_M,
-	/* 0x6b */ KEY_Comma,
-	/* 0x6c */ KEY_Period,
-	/* 0x6d */ KEY_Slash,
-	/* 0x6e */ KEY_ShiftR,
-	/* 0x6f */ KEY_NOTUSED,		/* linefeed */
-	/* 0x70 */ KEY_KP_1,
-	/* 0x71 */ KEY_KP_2,
-	/* 0x72 */ KEY_KP_3,
-	/* 0x73 */ KEY_NOTUSED,
-	/* 0x74 */ KEY_NOTUSED,
-	/* 0x75 */ KEY_NOTUSED,
-	/* 0x76 */ KEY_NOTUSED,		/* help */
-	/* 0x77 */ KEY_CapsLock,
-	/* 0x78 */ KEY_LMeta,
-	/* 0x79 */ KEY_Space,
-	/* 0x7a */ KEY_RMeta,
-	/* 0x7b */ KEY_PgDown,
-	/* 0x7c */ KEY_Less,		/* < > on some keyboards */
-	/* 0x7d */ KEY_KP_Plus,
-	/* 0x7e */ KEY_NOTUSED,
-	/* 0x7f */ KEY_NOTUSED
-};
-#define WS_SUN_MAP_SIZE (sizeof(wsSunMap)/sizeof(unsigned char))
-
-static
-TransMapRec wsSun = {
-    0,
-    WS_SUN_MAP_SIZE,
-    wsSunMap
-};
-
-#endif /* WSCONS_SUPPORT */
-
-/*ARGSUSED*/
-
-/*
- * KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-void
-KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  KeySym        *k;
-  int           i;
-
-#ifndef __bsdi__
-  switch (pKbd->consType) {
-
-#ifdef PCCONS_SUPPORT
-  case PCCONS:
-#if defined(__OpenBSD__)
-    /*
-     * on OpenBSD, the pccons keymap is programmable, too
-     */
-    {
-      pccons_keymap_t keymap[KB_NUM_KEYS];
-      if (ioctl(pInfo->fd, CONSOLE_GET_KEYMAP, &keymap) != -1) {
-	for (i = 0; i < KB_NUM_KEYS; i++) 
-	  if (pccons_remap[i]) {
-	    k = map + (pccons_remap[i] << 2);
-	    switch (keymap[i].type) {
-	    case KB_ASCII:
-	      /* For ASCII keys, there is only one char in the keymap */
-	      k[0] = latin1_to_x[(unsigned char)keymap[i].unshift[0]];
-	      k[1] = latin1_to_x[(unsigned char)keymap[i].shift[0]];
-	      k[2] = latin1_to_x[(unsigned char)keymap[i].altgr[0]];
-	      k[3] = latin1_to_x[(unsigned char)keymap[i].shift_altgr[0]];
-	      break;
-	    case KB_SCROLL:
-	      k[0] = XK_Scroll_Lock;
-	      goto special;
-	    case KB_NUM:
-	      k[0] = XK_Num_Lock;
-	      goto special;
-	    case KB_CAPS:
-	      k[0] = XK_Caps_Lock;
-	      goto special;
-	    case KB_SHIFT:
-	      switch (keymap[i].unshift[0]) {
-	      case 1:
-		/* left shift */
-		k[0] = XK_Shift_L;
-		break;
-	      case 2:
-		/* right shift */
-		k[0] = XK_Shift_R;
-		break;
-	      default:
-		k[0] = NoSymbol;
-	      }
-	      goto special;
-	    case KB_CTL:
-	      k[0] = XK_Control_L;
-	      goto special;
-	    case KB_ALT:
-	      k[0] = XK_Alt_L;
-	      goto special;
-	    case KB_FUNC:
-	      switch (keymap[i].unshift[2]) {
-	      case 'M':
-		k[0] = XK_F1;
-		break;
-	      case 'N':
-		k[0] = XK_F2;
-		break;
-	      case 'O':
-		k[0] = XK_F3;
-		break;
-	      case 'P':
-		k[0] = XK_F4;
-		break;
-	      case 'Q':
-		k[0] = XK_F5;
-		break;
-	      case 'R':
-		k[0] = XK_F6;
-		break;
-	      case 'S':
-		k[0] = XK_F7;
-		break;
-	      case 'T':
-		k[0] = XK_F8;
-		break;
-	      case 'U':
-		k[0] = XK_F9;
-		break;
-	      case 'V':
-		k[0] = XK_F10;
-		break;
-	      case 'W':
-		k[0] = XK_F11;
-		break;
-	      case 'X':
-		k[0] = XK_F12;
-		break;
-	      default:
-		k[0] = NoSymbol;
-		break;
-	      }
-	      goto special;
-	    default:
-	      k[0] = NoSymbol;
-	    special:
-	      k[1] = k[2] = k[3] = NoSymbol;
-	    }
-	  }
-      } else {
-	ErrorF("Can't read pccons keymap\n");
-      }
-    }
-#endif /* __OpenBSD__ */
-  break;
-#endif
-
-/*
- * XXX wscons has no GIO_KEYMAP
- */
-#if (defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)) && defined(GIO_KEYMAP)
-  case SYSCONS:
-  case PCVT:
-    {
-      keymap_t keymap;
-    
-      if (ioctl(pInfo->fd, GIO_KEYMAP, &keymap) != -1) {
-	for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++)
-	  if (remap[i]) {
-	    k = map + (remap[i] << 2);
-	    k[0] = KD_GET_ENTRY(i,0);           /* non-shifed */
-	    k[1] = KD_GET_ENTRY(i,1);	      /* shifted */
-	    k[2] = KD_GET_ENTRY(i,4);	      /* alt */
-	    k[3] = KD_GET_ENTRY(i,5);	      /* alt - shifted */
-	    if (k[3] == k[2]) k[3] = NoSymbol;
-	    if (k[2] == k[1]) k[2] = NoSymbol;
-	    if (k[1] == k[0]) k[1] = NoSymbol;
-	    if (k[0] == k[2] && k[1] == k[3])
-	      k[2] = k[3] = NoSymbol;
-	  }
-      }
-    }
-    break;
-#endif /* SYSCONS || PCVT */
-    
-  } 
-#endif /* !bsdi */
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = map, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4)
-    
-    switch(*k) {
-      
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-
-    }
-  
-  pKbd->kbdType = 0;
-
-  pKeySyms->map        = map;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  pKeySyms->maxKeyCode = MAX_KEYCODE; 
-
-  switch(pKbd->consType) {
-#ifdef SYSCONS_SUPPORT
-      case SYSCONS:
-           if (pKbd->CustomKeycodes)
-              pKbd->scancodeMap = &sysconsCODE;
-           else
-              pKbd->RemapScanCode = ATScancode;
-           break;
-#endif
-#if defined(PCCONS_SUPPORT) || defined (PCVT_SUPPORT)
-      case PCCONS:
-      case PCVT:
-           pKbd->RemapScanCode = ATScancode;
-	   break;
-#endif
-#ifdef WSCONS_SUPPORT
-      case WSCONS:
-	if (!pKbd->isConsole) {
-           switch (pKbd->wsKbdType) {
-	       case WSKBD_TYPE_PC_XT:
-	       case WSKBD_TYPE_PC_AT:
-                    pKbd->RemapScanCode = ATScancode;
-                    break;
-	       case WSKBD_TYPE_USB:
-                    pKbd->scancodeMap = &wsUsb;
-                    break;
-#ifdef WSKBD_TYPE_ADB	
-	       case WSKBD_TYPE_ADB:
-                    pKbd->scancodeMap = &wsAdb; 
-                    break;
-#endif
-#ifdef WSKBD_TYPE_SUN
-#ifdef WSKBD_TYPE_SUN5
-	       case WSKBD_TYPE_SUN5:
-#endif
-	       case WSKBD_TYPE_SUN:
-                    pKbd->scancodeMap = &wsSun;
-                    break;
-#endif
-	       default:
-		    ErrorF("Unknown wskbd type %d\n", pKbd->wsKbdType);
-           }
-	} else {
-           pKbd->RemapScanCode = ATScancode;
-	}
-      break;
-#endif
-  }
-  return;
-}
diff --git a/hw/xfree86/os-support/bsd/bsd_kbd.c b/hw/xfree86/os-support/bsd/bsd_kbd.c
deleted file mode 100644
index 65d577e..0000000
--- a/hw/xfree86/os-support/bsd/bsd_kbd.c
+++ /dev/null
@@ -1,572 +0,0 @@
-
-/*
- * Copyright (c) 2002 by The XFree86 Project, Inc.
- * Author: Ivan Pascal.
- *
- * Based on the code from bsd_io.c which is
- * Copyright 1992 by Rich Murphey <Rich at Rice.edu>
- * Copyright 1993 by David Dawes <dawes at xfree86.org>
- */
-
-#define NEED_EVENTS
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <termios.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#include "xf86Xinput.h"
-#include "xf86OSKbd.h"
-#include "atKeynames.h"
-#include "bsd_kbd.h"
-
-extern Bool VTSwitchEnabled;
-#ifdef USE_VT_SYSREQ
-extern Bool VTSysreqToggle;
-#endif
-
-static KbdProtocolRec protocols[] = {
-   {"standard", PROT_STD },
-#ifdef WSCONS_SUPPORT
-   {"wskbd", PROT_WSCONS },
-#endif
-   { NULL, PROT_UNKNOWN_KBD }
-};
-
-typedef struct {
-   struct termios kbdtty;
-} BsdKbdPrivRec, *BsdKbdPrivPtr;
-
-static
-int KbdInit(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    BsdKbdPrivPtr priv = (BsdKbdPrivPtr) pKbd->private;
-
-    if (pKbd->isConsole) {
-        switch (pKbd->consType) {
-#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)  || defined (WSCONS_SUPPORT)
-	    case PCCONS:
-	    case SYSCONS:
-	    case PCVT:
-#if defined WSCONS_SUPPORT
-            case WSCONS:
-#endif
- 	         tcgetattr(pInfo->fd, &(priv->kbdtty));
-#endif
-	         break;
-        }
-    }
-
-    return Success;
-}
-
-static void
-SetKbdLeds(InputInfoPtr pInfo, int leds)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    int real_leds = 0;
-
-#ifdef LED_CAP
-    if (leds & XLED1)  real_leds |= LED_CAP;
-#endif
-#ifdef LED_NUM
-    if (leds & XLED2)  real_leds |= LED_NUM;
-#endif
-#ifdef LED_SCR
-    if (leds & XLED3)  real_leds |= LED_SCR;
-    if (leds & XLED4)  real_leds |= LED_SCR;
-#endif
-
-    switch (pKbd->consType) {
-
-	case PCCONS:
-		break;
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	case SYSCONS:
-	case PCVT:
-	     ioctl(pInfo->fd, KDSETLED, real_leds);
-	     break;
-#endif
-#if defined(WSCONS_SUPPORT)
-        case WSCONS:
-             ioctl(pInfo->fd, WSKBDIO_SETLEDS, &real_leds);
-             break;
-#endif
-    }
-}
-
-static int
-GetKbdLeds(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    int leds = 0, real_leds = 0;
-
-    switch (pKbd->consType) {
-	case PCCONS:
-	     break;
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	case SYSCONS:
-	case PCVT:
-	     ioctl(pInfo->fd, KDGETLED, &real_leds);
-	     break;
-#endif
-#if defined(WSCONS_SUPPORT)
-        case WSCONS:
-             ioctl(pInfo->fd, WSKBDIO_GETLEDS, &real_leds);
-             break;
-#endif
-    }
-
-#ifdef LED_CAP
-    if (real_leds & LED_CAP) leds |= XLED1;
-#endif
-#ifdef LED_NUM
-    if (real_leds & LED_NUM) leds |= XLED2;
-#endif
-#ifdef LED_SCR
-    if (real_leds & LED_SCR) leds |= XLED3;
-#endif
-
-    return(leds);
-}
-
-static void
-SetKbdRepeat(InputInfoPtr pInfo, char rad)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    switch (pKbd->consType) {
-
-	case PCCONS:
-		break;
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	case SYSCONS:
-	case PCVT:
-		ioctl(pInfo->fd, KDSETRAD, rad);
-		break;
-#endif
-    }
-}
-
-static int
-KbdOn(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
-    BsdKbdPrivPtr priv = (BsdKbdPrivPtr) pKbd->private;
-    struct termios nTty;
-#endif
-#ifdef WSCONS_SUPPORT
-    int option;
-#endif
-
-    if (pKbd->isConsole) {
-        switch (pKbd->consType) {
-
-#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
-	    case SYSCONS:
-	    case PCCONS:
-	    case PCVT:
-#ifdef WSCONS_SUPPORT
-            case WSCONS:
-#endif
-		 nTty = priv->kbdtty;
-		 nTty.c_iflag = IGNPAR | IGNBRK;
-		 nTty.c_oflag = 0;
-		 nTty.c_cflag = CREAD | CS8;
-		 nTty.c_lflag = 0;
-		 nTty.c_cc[VTIME] = 0;
-		 nTty.c_cc[VMIN] = 1;
-		 cfsetispeed(&nTty, 9600);
-		 cfsetospeed(&nTty, 9600);
-		 if (tcsetattr(pInfo->fd, TCSANOW, &nTty) < 0) {
-			 xf86Msg(X_ERROR, "KbdOn: tcsetattr: %s\n",
-			     strerror(errno));
-		 }
-                 break; 
-#endif 
-        }
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT) || defined (WSCONS_SUPPORT)
-        switch (pKbd->consType) {
-	    case SYSCONS:
-	    case PCVT:
-#ifdef K_CODE
-                 if (pKbd->CustomKeycodes)
-		     ioctl(pInfo->fd, KDSKBMODE, K_CODE);
-	         else
-	             ioctl(pInfo->fd, KDSKBMODE, K_RAW);
-#else
-		 ioctl(pInfo->fd, KDSKBMODE, K_RAW);
-#endif
-	         break;
-#endif
-#ifdef WSCONS_SUPPORT
-            case WSCONS:
-                 option = WSKBD_RAW;
-                 if (ioctl(pInfo->fd, WSKBDIO_SETMODE, &option) == -1) {
-			 FatalError("can't switch keyboard to raw mode. "
-				    "Enable support for it in the kernel\n"
-				    "or use for example:\n\n"
-				    "Option \"Protocol\" \"wskbd\"\n"
-				    "Option \"Device\" \"/dev/wskbd0\"\n"
-				    "\nin your xorg.conf(5) file\n");
-		 }
-		 break;
-#endif
-        }
-    }
-    return Success;
-}
-
-static int
-KbdOff(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    BsdKbdPrivPtr priv = (BsdKbdPrivPtr) pKbd->private;
-#ifdef WSCONS_SUPPORT
-    int option;
-#endif
-
-    if (pKbd->isConsole) {
-        switch (pKbd->consType) {
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	    case SYSCONS:
-	    case PCVT:
-	         ioctl(pInfo->fd, KDSKBMODE, K_XLATE);
-	         /* FALL THROUGH */
-#endif
-#if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT) || defined(PCVT_SUPPORT)
-	    case PCCONS:
-	         tcsetattr(pInfo->fd, TCSANOW, &(priv->kbdtty));
-	         break;
-#endif
-#ifdef WSCONS_SUPPORT
-            case WSCONS:
-                 option = WSKBD_TRANSLATED;
-                 ioctl(xf86Info.consoleFd, WSKBDIO_SETMODE, &option);
-                 tcsetattr(pInfo->fd, TCSANOW, &(priv->kbdtty));
-	         break;
-#endif
-        }
-    }
-    return Success;
-}
-
-static void
-SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-#ifdef WSCONS_SUPPORT
-    struct wskbd_bell_data wsb;
-#endif
-
-    if (loudness && pitch) {
-    	switch (pKbd->consType) {
-#ifdef PCCONS_SUPPORT
-	    case PCCONS:
-	         { int data[2];
-		   data[0] = pitch;
-		   data[1] = (duration * loudness) / 50;
-		   ioctl(pInfo->fd, CONSOLE_X_BELL, data);
-		   break;
-		 }
-#endif
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-	    case SYSCONS:
-	    case PCVT:
-		 ioctl(pInfo->fd, KDMKTONE,
-		 ((1193190 / pitch) & 0xffff) |
-		 (((unsigned long)duration*loudness/50)<<16));
-		 break;
-#endif
-#if defined (WSCONS_SUPPORT)
-            case WSCONS:
-                 wsb.which = WSKBD_BELL_DOALL;
-                 wsb.pitch = pitch;
-                 wsb.period = duration;
-                 wsb.volume = loudness;
-                 ioctl(pInfo->fd, WSKBDIO_COMPLEXBELL, &wsb);
-                 break;
-#endif
-	}
-    }
-}
-
-#define ModifierSet(k) ((modifiers & (k)) == (k))
-
-static
-Bool SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-
-  if(!pKbd->vtSwitchSupported)
-      return FALSE;
-
-  if ((ModifierSet(ControlMask | AltMask)) ||
-      (ModifierSet(ControlMask | AltLangMask))) {
-      if (VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
-         switch (key) {
-             case KEY_F1:
-             case KEY_F2:
-             case KEY_F3:
-             case KEY_F4:
-             case KEY_F5:
-             case KEY_F6:
-             case KEY_F7:
-             case KEY_F8:
-             case KEY_F9:
-             case KEY_F10:
-#ifdef VT_ACTIVATE
-                  if (down) {
-                    ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
-                    return TRUE;
-                  }
-#endif
-             case KEY_F11:
-             case KEY_F12:
-#ifdef VT_ACTIVATE
-                  if (down) {
-                    ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
-                    return TRUE;
-                  }
-#endif
-         }
-      }
-    }
-#ifdef USE_VT_SYSREQ
-    if (VTSwitchEnabled && xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
-        switch (key) {
-            case KEY_F1:
-            case KEY_F2:
-            case KEY_F3:
-            case KEY_F4:
-            case KEY_F5:
-            case KEY_F6:
-            case KEY_F7:
-            case KEY_F8:
-            case KEY_F9:
-            case KEY_F10:
-                 if (VTSysreqToggle && down) {
-                     ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
-                     VTSysreqToggle = FALSE;
-                     return TRUE;
-                 }
-                 break;
-            case KEY_F11:
-            case KEY_F12:
-                 if (VTSysreqToggle && down) {
-                     ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
-                     VTSysreqToggle = FALSE;
-                     return TRUE;
-                 }
-                 break;
-            /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
-            case KEY_Alt:
-            case KEY_AltLang:
-                 break;
-            case KEY_SysReqest:
-                 if ((ModifierSet(AltMask) || ModifierSet(AltLangMask)) && down)
-                     VTSysreqToggle = TRUE;
-                 break;
-            default:
-                 /*
-                  * We only land here when Alt-SysReq is followed by a
-                  * non-switching key.
-                  */
-                 if (VTSysreqToggle)
-                     VTSysreqToggle = FALSE;
-        }
-    }
-#endif /* USE_VT_SYSREQ */
-
-    return FALSE;
-}
-
-static void
-stdReadInput(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    unsigned char rBuf[64];
-    int nBytes, i;
-    if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) {
-       for (i = 0; i < nBytes; i++)
-	   pKbd->PostEvent(pInfo, rBuf[i] & 0x7f,
-                           rBuf[i] & 0x80 ? FALSE : TRUE);
-       }
-}
-
-#ifdef WSCONS_SUPPORT
-
-static void
-WSReadInput(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    struct wscons_event events[64];
-    int type;
-    int blocked, n, i;
-
-    if ((n = read( pInfo->fd, events, sizeof(events))) > 0) {
-        n /=  sizeof(struct wscons_event);
-        for (i = 0; i < n; i++) {
-	    type = events[i].type;
-	    if (type == WSCONS_EVENT_KEY_UP || type == WSCONS_EVENT_KEY_DOWN) {
-		/* It seems better to block SIGIO there */
-		blocked = xf86BlockSIGIO();
-		pKbd->PostEvent(pInfo, (unsigned int)(events[i].value),
-				type == WSCONS_EVENT_KEY_DOWN ? TRUE : FALSE);
-		xf86UnblockSIGIO(blocked);
-	    }
-	} /* for */
-    }
-}
-
-static void
-printWsType(char *type, char *devname)
-{
-    xf86Msg(X_PROBED, "%s: Keyboard type: %s\n", type, devname); 
-}
-#endif
-
-static Bool
-OpenKeyboard(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    int i;
-    KbdProtocolId prot = PROT_UNKNOWN_KBD;
-    char *s;
-
-    s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
-    for (i = 0; protocols[i].name; i++) {
-        if (xf86NameCmp(s, protocols[i].name) == 0) {
-           prot = protocols[i].id;
-           break;
-        }
-    }
-
-    switch (prot) {
-    	case PROT_STD:
-           pInfo->read_input = stdReadInput;
-           break;
-#ifdef WSCONS_SUPPORT
-        case PROT_WSCONS:
-           pInfo->read_input = WSReadInput;
-           break;
-#endif
-        default:
-           xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
-           xfree(s);
-           return FALSE;
-    }
-    xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s);
-    xfree(s);
-
-    s = xf86SetStrOption(pInfo->options, "Device", NULL);
-    if (s == NULL) {
-       if (prot == PROT_WSCONS) {
-           xf86Msg(X_ERROR,"A \"device\" option is required with"
-                                  " the \"wskbd\" keyboard protocol\n");
-           return FALSE;
-       } else {
-           pInfo->fd = xf86Info.consoleFd;
-           pKbd->isConsole = TRUE;
-           pKbd->consType = xf86Info.consType;
-       }
-    } else {
-	pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
-       if (pInfo->fd == -1) {
-           xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
-           xfree(s);
-           return FALSE;
-       }
-       pKbd->isConsole = FALSE;
-       pKbd->consType = xf86Info.consType;
-       xfree(s);
-    }
-
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
-    if (pKbd->isConsole &&
-        ((pKbd->consType == SYSCONS) || (pKbd->consType == PCVT)))
-        pKbd->vtSwitchSupported = TRUE;
-#endif
-
-#ifdef WSCONS_SUPPORT
-    if( prot == PROT_WSCONS) {
-       pKbd->consType = WSCONS;
-       /* Find out keyboard type */
-       if (ioctl(pInfo->fd, WSKBDIO_GTYPE, &(pKbd->wsKbdType)) == -1) {
-           xf86Msg(X_ERROR, "%s: cannot get keyboard type", pInfo->name);
-           close(pInfo->fd);
-           return FALSE;
-       }
-       switch (pKbd->wsKbdType) {
-           case WSKBD_TYPE_PC_XT:
-               printWsType("XT", pInfo->name);
-               break;
-           case WSKBD_TYPE_PC_AT:
-               printWsType("AT", pInfo->name);
-               break;
-           case WSKBD_TYPE_USB:
-               printWsType("USB", pInfo->name);
-               break;
-#ifdef WSKBD_TYPE_ADB
-           case WSKBD_TYPE_ADB:
-               printWsType("ADB", pInfo->name);
-               break;
-#endif
-#ifdef WSKBD_TYPE_SUN
-           case WSKBD_TYPE_SUN:
-               printWsType("Sun", pInfo->name);
-               break;
-#endif
-#ifdef WSKBD_TYPE_SUN5
-     case WSKBD_TYPE_SUN5:
-	     xf86Msg(X_PROBED, "Keyboard type: Sun5\n");
-	     break;
-#endif
-           default:
-               xf86Msg(X_ERROR, "%s: Unsupported wskbd type \"%d\"",
-                                pInfo->name, pKbd->wsKbdType);
-               close(pInfo->fd);
-               return FALSE;
-       }
-    }
-#endif
-    return TRUE;
-}
-
-_X_EXPORT Bool
-xf86OSKbdPreInit(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = pInfo->private;
-
-    pKbd->KbdInit	= KbdInit;
-    pKbd->KbdOn		= KbdOn;
-    pKbd->KbdOff	= KbdOff;
-    pKbd->Bell		= SoundBell;
-    pKbd->SetLeds	= SetKbdLeds;
-    pKbd->GetLeds	= GetKbdLeds;
-    pKbd->SetKbdRepeat	= SetKbdRepeat;
-    pKbd->KbdGetMapping	= KbdGetMapping;
-    pKbd->SpecialKey	= SpecialKey;
-
-    pKbd->RemapScanCode = NULL;
-    pKbd->GetSpecialKey = NULL;
-
-    pKbd->OpenKeyboard = OpenKeyboard;
-    pKbd->vtSwitchSupported = FALSE;
-    pKbd->CustomKeycodes = FALSE;
-    
-    pKbd->private = xcalloc(sizeof(BsdKbdPrivRec), 1);
-    if (pKbd->private == NULL) {
-       xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
-       return FALSE;
-    }
-    return TRUE;
-}
diff --git a/hw/xfree86/os-support/bsd/bsd_kbd.h b/hw/xfree86/os-support/bsd/bsd_kbd.h
deleted file mode 100644
index b2ae179..0000000
--- a/hw/xfree86/os-support/bsd/bsd_kbd.h
+++ /dev/null
@@ -1,4 +0,0 @@
-
-extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms,
-				CARD8 *pModMap);
-
diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am
index d77e3a3..fc4243b 100644
--- a/hw/xfree86/os-support/linux/Makefile.am
+++ b/hw/xfree86/os-support/linux/Makefile.am
@@ -19,17 +19,15 @@ APM_SOURCES = lnx_apm.c
 XORG_CFLAGS += -DHAVE_APM
 endif
 
-liblinux_la_SOURCES = lnx_init.c lnx_video.c lnx_kbd.c lnx_mouse.c \
-                     lnx_pci.c lnx_agp.c lnx_kmod.c lnx_KbdMap.c \
+liblinux_la_SOURCES = lnx_init.c lnx_video.c lnx_mouse.c \
+                     lnx_pci.c lnx_agp.c lnx_kmod.c \
                      $(srcdir)/../shared/bios_mmap.c \
 		     $(srcdir)/../shared/VTsw_usl.c \
-                     $(srcdir)/../shared/std_kbdEv.c \
 		     $(srcdir)/../shared/posix_tty.c \
                      $(srcdir)/../shared/vidmem.c \
 		     $(srcdir)/../shared/sigio.c \
                      $(srcdir)/../shared/stdResource.c \
 		     $(srcdir)/../shared/libc_wrapper.c \
-                     $(srcdir)/../shared/at_scancode.c \
                      $(ACPI_SOURCES) \
                      $(APM_SOURCES) \
                      $(PLATFORM_PCI_SUPPORT)
diff --git a/hw/xfree86/os-support/linux/lnx_KbdMap.c b/hw/xfree86/os-support/linux/lnx_KbdMap.c
deleted file mode 100644
index a2a2e22..0000000
--- a/hw/xfree86/os-support/linux/lnx_KbdMap.c
+++ /dev/null
@@ -1,606 +0,0 @@
-/* $XFree86$ */
-
-/*
- * Slightly modified xf86KbdLnx.c which is
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86Xinput.h"
-#include "xf86OSKbd.h"
-#include "atKeynames.h"
-
-#include "xf86Keymap.h"
-
-#include "lnx_kbd.h"
-
-/*ARGSUSED*/
-
-/*
- * KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-static void readKernelMapping(InputInfoPtr pInfo,
-                              KeySymsPtr pKeySyms, CARD8 *pModMap);
-void
-KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  KeySym        *k;
-  char          type;
-  int           i;
-
-  readKernelMapping(pInfo, pKeySyms, pModMap);
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = map, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4)
-    
-    switch(*k) {
-      
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-
-    }
-  
-  pKbd->kbdType = ioctl(pInfo->fd, KDGKBTYPE, &type) != -1 ? type : KB_101;
-
-  pKeySyms->map        = map;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  pKeySyms->maxKeyCode = MAX_KEYCODE; 
-}
-
-#include <linux/keyboard.h>
-
-static KeySym linux_to_x[256] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_BackSpace,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_nobreakspace,XK_exclamdown,	XK_cent,	XK_sterling,
-	XK_currency,	XK_yen,		XK_brokenbar,	XK_section,
-	XK_diaeresis,	XK_copyright,	XK_ordfeminine,	XK_guillemotleft,
-	XK_notsign,	XK_hyphen,	XK_registered,	XK_macron,
-	XK_degree,	XK_plusminus,	XK_twosuperior,	XK_threesuperior,
-	XK_acute,	XK_mu,		XK_paragraph,	XK_periodcentered,
-	XK_cedilla,	XK_onesuperior,	XK_masculine,	XK_guillemotright,
-	XK_onequarter,	XK_onehalf,	XK_threequarters,XK_questiondown,
-	XK_Agrave,	XK_Aacute,	XK_Acircumflex,	XK_Atilde,
-	XK_Adiaeresis,	XK_Aring,	XK_AE,		XK_Ccedilla,
-	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
-	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
-	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
-	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_multiply,
-	XK_Ooblique,	XK_Ugrave,	XK_Uacute,	XK_Ucircumflex,
-	XK_Udiaeresis,	XK_Yacute,	XK_THORN,	XK_ssharp,
-	XK_agrave,	XK_aacute,	XK_acircumflex,	XK_atilde,
-	XK_adiaeresis,	XK_aring,	XK_ae,		XK_ccedilla,
-	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
-	XK_igrave,	XK_iacute,	XK_icircumflex,	XK_idiaeresis,
-	XK_eth,		XK_ntilde,	XK_ograve,	XK_oacute,
-	XK_ocircumflex,	XK_otilde,	XK_odiaeresis,	XK_division,
-	XK_oslash,	XK_ugrave,	XK_uacute,	XK_ucircumflex,
-	XK_udiaeresis,	XK_yacute,	XK_thorn,	XK_ydiaeresis
-};
-
-/*
- * Maps the AT keycodes to Linux keycodes
- */
-static unsigned char at2lnx[] =
-{
-	0x01,	/* KEY_Escape */	0x02,	/* KEY_1 */
-	0x03,	/* KEY_2 */		0x04,	/* KEY_3 */
-	0x05,	/* KEY_4 */		0x06,	/* KEY_5 */
-	0x07,	/* KEY_6 */		0x08,	/* KEY_7 */
-	0x09,	/* KEY_8 */		0x0a,	/* KEY_9 */
-	0x0b,	/* KEY_0 */		0x0c,	/* KEY_Minus */
-	0x0d,	/* KEY_Equal */		0x0e,	/* KEY_BackSpace */
-	0x0f,	/* KEY_Tab */		0x10,	/* KEY_Q */
-	0x11,	/* KEY_W */		0x12,	/* KEY_E */
-	0x13,	/* KEY_R */		0x14,	/* KEY_T */
-	0x15,	/* KEY_Y */		0x16,	/* KEY_U */
-	0x17,	/* KEY_I */		0x18,	/* KEY_O */
-	0x19,	/* KEY_P */		0x1a,	/* KEY_LBrace */
-	0x1b,	/* KEY_RBrace */	0x1c,	/* KEY_Enter */
-	0x1d,	/* KEY_LCtrl */		0x1e,	/* KEY_A */
-	0x1f,	/* KEY_S */		0x20,	/* KEY_D */
-	0x21,	/* KEY_F */		0x22,	/* KEY_G */
-	0x23,	/* KEY_H */		0x24,	/* KEY_J */
-	0x25,	/* KEY_K */		0x26,	/* KEY_L */
-	0x27,	/* KEY_SemiColon */	0x28,	/* KEY_Quote */
-	0x29,	/* KEY_Tilde */		0x2a,	/* KEY_ShiftL */
-	0x2b,	/* KEY_BSlash */	0x2c,	/* KEY_Z */
-	0x2d,	/* KEY_X */		0x2e,	/* KEY_C */
-	0x2f,	/* KEY_V */		0x30,	/* KEY_B */
-	0x31,	/* KEY_N */		0x32,	/* KEY_M */
-	0x33,	/* KEY_Comma */		0x34,	/* KEY_Period */
-	0x35,	/* KEY_Slash */		0x36,	/* KEY_ShiftR */
-	0x37,	/* KEY_KP_Multiply */	0x38,	/* KEY_Alt */
-	0x39,	/* KEY_Space */		0x3a,	/* KEY_CapsLock */
-	0x3b,	/* KEY_F1 */		0x3c,	/* KEY_F2 */
-	0x3d,	/* KEY_F3 */		0x3e,	/* KEY_F4 */
-	0x3f,	/* KEY_F5 */		0x40,	/* KEY_F6 */
-	0x41,	/* KEY_F7 */		0x42,	/* KEY_F8 */
-	0x43,	/* KEY_F9 */		0x44,	/* KEY_F10 */
-	0x45,	/* KEY_NumLock */	0x46,	/* KEY_ScrollLock */
-	0x47,	/* KEY_KP_7 */		0x48,	/* KEY_KP_8 */
-	0x49,	/* KEY_KP_9 */		0x4a,	/* KEY_KP_Minus */
-	0x4b,	/* KEY_KP_4 */		0x4c,	/* KEY_KP_5 */
-	0x4d,	/* KEY_KP_6 */		0x4e,	/* KEY_KP_Plus */
-	0x4f,	/* KEY_KP_1 */		0x50,	/* KEY_KP_2 */
-	0x51,	/* KEY_KP_3 */		0x52,	/* KEY_KP_0 */
-	0x53,	/* KEY_KP_Decimal */	0x54,	/* KEY_SysReqest */
-	0x00,	/* 0x55 */		0x56,	/* KEY_Less */
-	0x57,	/* KEY_F11 */		0x58,	/* KEY_F12 */
-	0x66,	/* KEY_Home */		0x67,	/* KEY_Up */
-	0x68,	/* KEY_PgUp */		0x69,	/* KEY_Left */
-	0x5d,	/* KEY_Begin */		0x6a,	/* KEY_Right */
-	0x6b,	/* KEY_End */		0x6c,	/* KEY_Down */
-	0x6d,	/* KEY_PgDown */	0x6e,	/* KEY_Insert */
-	0x6f,	/* KEY_Delete */	0x60,	/* KEY_KP_Enter */
-	0x61,	/* KEY_RCtrl */		0x77,	/* KEY_Pause */
-	0x63,	/* KEY_Print */		0x62,	/* KEY_KP_Divide */
-	0x64,	/* KEY_AltLang */	0x65,	/* KEY_Break */
-	0x00,	/* KEY_LMeta */		0x00,	/* KEY_RMeta */
-	0x7A,	/* KEY_Menu/FOCUS_PF11*/0x00,	/* 0x6e */
-	0x7B,	/* FOCUS_PF12 */	0x00,	/* 0x70 */
-	0x00,	/* 0x71 */		0x00,	/* 0x72 */
-	0x59,	/* FOCUS_PF2 */		0x78,	/* FOCUS_PF9 */
-	0x00,	/* 0x75 */		0x00,	/* 0x76 */
-	0x5A,	/* FOCUS_PF3 */		0x5B,	/* FOCUS_PF4 */
-	0x5C,	/* FOCUS_PF5 */		0x5D,	/* FOCUS_PF6 */
-	0x5E,	/* FOCUS_PF7 */		0x5F,	/* FOCUS_PF8 */
-	0x7C,	/* JAP_86 */		0x79,	/* FOCUS_PF10 */
-	0x00,	/* 0x7f */
-};
-#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
-
-#define NUM_CUSTOMKEYS	NR_KEYS
-
-static void
-readKernelMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  KeySym        *k;
-  int           i;
-  int           maxkey;
-  static unsigned char tbl[GLYPHS_PER_KEY] =
-  {
-	0,	/* unshifted */
-	1,	/* shifted */
-	0,	/* modeswitch unshifted */
-	0	/* modeswitch shifted */
-  };
-
-  /*
-   * Read the mapping from the kernel.
-   * Since we're still using the XFree86 scancode->AT keycode mapping
-   * routines, we need to convert the AT keycodes to Linux keycodes,
-   * then translate the Linux keysyms into X keysyms.
-   *
-   * First, figure out which tables to use for the modeswitch columns
-   * above, from the XF86Config fields.
-   */
-  tbl[2] = 8;	/* alt */
-  tbl[3] = tbl[2] | 1;
-
-  if (pKbd->CustomKeycodes) {
-    k = map;
-    maxkey = NUM_CUSTOMKEYS;
-  }
-  else {
-    k = map+GLYPHS_PER_KEY;
-    maxkey = NUM_AT2LNX;
-  }
-
-  for (i = 0; i < maxkey; ++i)
-  {
-    struct kbentry kbe;
-    int j;
-
-    if (pKbd->CustomKeycodes)
-      kbe.kb_index = i;
-    else
-      kbe.kb_index = at2lnx[i];
-
-    for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k)
-    {
-      unsigned short kval;
-
-      *k = NoSymbol;
-
-      kbe.kb_table = tbl[j];
-      if (
-	  (!pKbd->CustomKeycodes && kbe.kb_index == 0) ||
-	  ioctl(pInfo->fd, KDGKBENT, &kbe))
-	continue;
-
-      kval = KVAL(kbe.kb_value);
-      switch (KTYP(kbe.kb_value))
-      {
-      case KT_LATIN:
-      case KT_LETTER:
-	*k = linux_to_x[kval];
-	break;
-
-      case KT_FN:
-	if (kval <= 19)
-	  *k = XK_F1 + kval;
-	else switch (kbe.kb_value)
-	{
-	case K_FIND:
-	  *k = XK_Home; /* or XK_Find */
-	  break;
-	case K_INSERT:
-	  *k = XK_Insert;
-	  break;
-	case K_REMOVE:
-	  *k = XK_Delete;
-	  break;
-	case K_SELECT:
-	  *k = XK_End; /* or XK_Select */
-	  break;
-	case K_PGUP:
-	  *k = XK_Prior;
-	  break;
-	case K_PGDN:
-	  *k = XK_Next;
-	  break;
-	case K_HELP:
-	  *k = XK_Help;
-	  break;
-	case K_DO:
-	  *k = XK_Execute;
-	  break;
-	case K_PAUSE:
-	  *k = XK_Pause;
-	  break;
-	case K_MACRO:
-	  *k = XK_Menu;
-	  break;
-	default:
-	  break;
-	}
-	break;
-
-      case KT_SPEC:
-	switch (kbe.kb_value)
-	{
-	case K_ENTER:
-	  *k = XK_Return;
-	  break;
-	case K_BREAK:
-	  *k = XK_Break;
-	  break;
-	case K_CAPS:
-	  *k = XK_Caps_Lock;
-	  break;
-	case K_NUM:
-	  *k = XK_Num_Lock;
-	  break;
-	case K_HOLD:
-	  *k = XK_Scroll_Lock;
-	  break;
-	case K_COMPOSE:
-          *k = XK_Multi_key;
-	  break;
-	default:
-	  break;
-	}
-	break;
-
-      case KT_PAD:
-	switch (kbe.kb_value)
-	{
-	case K_PPLUS:
-	  *k = XK_KP_Add;
-	  break;
-	case K_PMINUS:
-	  *k = XK_KP_Subtract;
-	  break;
-	case K_PSTAR:
-	  *k = XK_KP_Multiply;
-	  break;
-	case K_PSLASH:
-	  *k = XK_KP_Divide;
-	  break;
-	case K_PENTER:
-	  *k = XK_KP_Enter;
-	  break;
-	case K_PCOMMA:
-	  *k = XK_KP_Separator;
-	  break;
-	case K_PDOT:
-	  *k = XK_KP_Decimal;
-	  break;
-	case K_PPLUSMINUS:
-	  *k = XK_KP_Subtract;
-	  break;
-	default:
-	  if (kval <= 9)
-	    *k = XK_KP_0 + kval;
-	  break;
-	}
-	break;
-
-      /*
-       * KT_DEAD keys are for accelerated diacritical creation.
-       */
-      case KT_DEAD:
-	switch (kbe.kb_value)
-	  {
-	  case K_DGRAVE:
-	    *k = XK_dead_grave;
-	    break;
-	  case K_DACUTE:
-	    *k = XK_dead_acute;
-	    break;
-	  case K_DCIRCM:
-	    *k = XK_dead_circumflex;
-	    break;
-	  case K_DTILDE:
-	    *k = XK_dead_tilde;
-	    break;
-	  case K_DDIERE:
-	    *k = XK_dead_diaeresis;
-	    break;
-	  }
-	break;
-
-      case KT_CUR:
-	switch (kbe.kb_value)
-	{
-	case K_DOWN:
-	  *k = XK_Down;
-	  break;
-	case K_LEFT:
-	  *k = XK_Left;
-	  break;
-	case K_RIGHT:
-	  *k = XK_Right;
-	  break;
-	case K_UP:
-	  *k = XK_Up;
-	  break;
-	}
-	break;
-
-      case KT_SHIFT:
-	switch (kbe.kb_value)
-	{
-	case K_ALTGR:
-	  *k = XK_Alt_R;
-	  break;
-	case K_ALT:
-	  *k = (kbe.kb_index == 0x64 ?
-		XK_Alt_R : XK_Alt_L);
-	  break;
-	case K_CTRL:
-	  *k = (kbe.kb_index == 0x61 ?
-		XK_Control_R : XK_Control_L);
-	  break;
-        case K_CTRLL:
-	  *k = XK_Control_L;
-	  break;
-        case K_CTRLR:
-	  *k = XK_Control_R;
-	  break;
-	case K_SHIFT:
-	  *k = (kbe.kb_index == 0x36 ?
-		XK_Shift_R : XK_Shift_L);
-	  break;
-        case K_SHIFTL:
-	  *k = XK_Shift_L;
-	  break;
-        case K_SHIFTR:
-	  *k = XK_Shift_R;
-	  break;
-	default:
-	  break;
-	}
-	break;
-
-      /*
-       * KT_ASCII keys accumulate a 3 digit decimal number that gets
-       * emitted when the shift state changes. We can't emulate that.
-       */
-      case KT_ASCII:
-	break;
-
-      case KT_LOCK:
-	if (kbe.kb_value == K_SHIFTLOCK)
-	  *k = XK_Shift_Lock;
-	break;
-
-      default:
-	break;
-      }
-    }
-
-    if (k[-1] == k[-2]) k[-1] = NoSymbol;
-    if (k[-2] == k[-3]) k[-2] = NoSymbol;
-    if (k[-3] == k[-4]) k[-3] = NoSymbol;
-    if (k[-4] == k[-2] && k[-3] == k[-1]) k[-2] = k[-1] = NoSymbol;
-    if (k[-1] == k[-4] && k[-2] == k[-3] && k[-2] == NoSymbol) k[-1] =NoSymbol;
-  }
-
-  if (!pKbd->CustomKeycodes)
-    return;
-
-  /*
-   * Find the Mapping for the special server functions
-   */
-  pKbd->specialMap = (TransMapPtr) xcalloc(NUM_CUSTOMKEYS, 1);
-  if (pKbd->specialMap != NULL) {
-      pKbd->specialMap->end = NUM_CUSTOMKEYS;
-      pKbd->specialMap->map = (unsigned char*) xcalloc(NUM_CUSTOMKEYS, 1);
-      if (pKbd->specialMap == NULL) {
-      	  xfree(pKbd->specialMap);
-      	  pKbd->specialMap = NULL;
-      }
-  }
-  if (pKbd->specialMap == NULL) {
-      xf86Msg(X_ERROR, "%s can't allocate \"special map\"\n", pInfo->name);
-      return;
-  }
-
-  for (i = 0; i < NUM_CUSTOMKEYS; ++i) {
-    struct kbentry kbe;
-    int special = 0;
-
-    kbe.kb_index = i;
-    kbe.kb_table = 0; /* Plain map */
-    if (!ioctl(pInfo->fd, KDGKBENT, &kbe))
-      switch (kbe.kb_value) {
-	case K(KT_LATIN,0x7f):	/* This catches DEL too... But who cares? */
-	  special = KEY_BackSpace;
-	  break;
-	case K_PMINUS:
-	  special = KEY_KP_Minus;
-	  break;
-	case K_PPLUS:
-	  special = KEY_KP_Plus;
-	  break;
-	case K_F1:
-	  special = KEY_F1;
-	  break;
-	case K_F2:
-	  special = KEY_F2;
-	  break;
-	case K_F3:
-	  special = KEY_F3;
-	  break;
-	case K_F4:
-	  special = KEY_F4;
-	  break;
-	case K_F5:
-	  special = KEY_F5;
-	  break;
-	case K_F6:
-	  special = KEY_F6;
-	  break;
-	case K_F7:
-	  special = KEY_F7;
-	  break;
-	case K_F8:
-	  special = KEY_F8;
-	  break;
-	case K_F9:
-	  special = KEY_F9;
-	  break;
-	case K_F10:
-	  special = KEY_F10;
-	  break;
-	case K_F11:
-	  special = KEY_F11;
-	  break;
-	case K_F12:
-	  special = KEY_F12;
-	  break;
-	case K_ALT:
-	  special = KEY_Alt;
-	  break;
-	case K_ALTGR:
-	  special = KEY_AltLang;
-	  break;
-	case K_CONS:
-	  special = KEY_SysReqest;
-	  break;
-      }
-    pKbd->specialMap->map[i] = special;
-  }
-}
diff --git a/hw/xfree86/os-support/linux/lnx_kbd.c b/hw/xfree86/os-support/linux/lnx_kbd.c
deleted file mode 100644
index a4890d2..0000000
--- a/hw/xfree86/os-support/linux/lnx_kbd.c
+++ /dev/null
@@ -1,530 +0,0 @@
-
-/*
- * Copyright (c) 2002 by The XFree86 Project, Inc.
- * Author: Ivan Pascal.
- *
- * Based on the code from lnx_io.c which is
- * Copyright 1992 by Orest Zborowski <obz at Kodak.com>
- * Copyright 1993 by David Dawes <dawes at xfree86.org>
- */
-
-#define NEED_EVENTS
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#include "xf86Xinput.h"
-#include "xf86OSKbd.h"
-#include "atKeynames.h"
-#if defined(DO_OS_FONTRESTORE)
-#include "lnx.h"
-#endif
-#include "lnx_kbd.h"
-
-#define KBC_TIMEOUT 250        /* Timeout in ms for sending to keyboard controller */
-
-static KbdProtocolRec protocols[] = {
-   {"standard", PROT_STD },
-   { NULL, PROT_UNKNOWN_KBD }
-};
-
-extern Bool VTSwitchEnabled;
-#ifdef USE_VT_SYSREQ
-extern Bool VTSysreqToggle;
-#endif
-
-static void
-SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
-{
-	if (loudness && pitch)
-	{
-		ioctl(pInfo->fd, KDMKTONE,
-		      ((1193190 / pitch) & 0xffff) |
-		      (((unsigned long)duration *
-			loudness / 50) << 16));
-	}
-}
-
-static void
-SetKbdLeds(InputInfoPtr pInfo, int leds)
-{
-    int real_leds = 0;
-
-#if defined (__sparc__)
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    if (pKbd->sunKbd) {
-  	if (leds & 0x08) real_leds |= XLED1;
-  	if (leds & 0x04) real_leds |= XLED3;
-  	if (leds & 0x02) real_leds |= XLED4;
-  	if (leds & 0x01) real_leds |= XLED2;
-        leds = real_leds;
-        real_leds = 0;
-    }
-#endif /* defined (__sparc__) */
-#ifdef LED_CAP
-    if (leds & XLED1)  real_leds |= LED_CAP;
-    if (leds & XLED2)  real_leds |= LED_NUM;
-    if (leds & XLED3)  real_leds |= LED_SCR;
-#ifdef LED_COMP
-    if (leds & XLED4)  real_leds |= LED_COMP;
-#else
-    if (leds & XLED4)  real_leds |= LED_SCR;
-#endif
-#endif
-    ioctl(pInfo->fd, KDSETLED, real_leds);
-}
-
-static int
-GetKbdLeds(InputInfoPtr pInfo)
-{
-    int real_leds, leds = 0;
-
-    ioctl(pInfo->fd, KDGETLED, &real_leds);
-
-    if (real_leds & LED_CAP) leds |= XLED1;
-    if (real_leds & LED_NUM) leds |= XLED2;
-    if (real_leds & LED_SCR) leds |= XLED3;
-
-    return(leds);
-}
-
-static int
-KDKBDREP_ioctl_ok(int rate, int delay) {
-#if defined(KDKBDREP) && !defined(__sparc__)
-     /* This ioctl is defined in <linux/kd.h> but is not
-	implemented anywhere - must be in some m68k patches. */
-   struct kbd_repeat kbdrep_s;
-
-   /* don't change, just test */
-   kbdrep_s.LNX_KBD_PERIOD_NAME = -1;
-   kbdrep_s.delay = -1;
-   if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
-       return 0;
-   }
-
-   /* do the change */
-   if (rate == 0)				/* switch repeat off */
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 0;
-   else
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 10000 / rate; /* convert cps to msec */
-   if (kbdrep_s.LNX_KBD_PERIOD_NAME < 1)
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 1;
-   kbdrep_s.delay = delay;
-   if (kbdrep_s.delay < 1)
-     kbdrep_s.delay = 1;
-   
-   if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
-       return 0;
-   }
-
-   return 1;			/* success! */
-#else /* no KDKBDREP */
-   return 0;
-#endif /* KDKBDREP */
-}
-
-static int
-KIOCSRATE_ioctl_ok(int rate, int delay) {
-#ifdef KIOCSRATE
-   struct kbd_rate kbdrate_s;
-   int fd;
-
-   fd = open("/dev/kbd", O_RDONLY);
-   if (fd == -1) 
-     return 0;   
-
-   kbdrate_s.rate = (rate + 5) / 10;  /* must be integer, so round up */
-   kbdrate_s.delay = delay * HZ / 1000;  /* convert ms to Hz */
-   if (kbdrate_s.rate > 50)
-     kbdrate_s.rate = 50;
-
-   if (ioctl( fd, KIOCSRATE, &kbdrate_s )) {
-       return 0;
-   }
-
-   close( fd );
-
-   return 1;
-#else /* no KIOCSRATE */
-   return 0;
-#endif /* KIOCSRATE */
-}
-
-#undef rate
-
-static void
-SetKbdRepeat(InputInfoPtr pInfo, char rad)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  int i;
-  int timeout;
-  int         value = 0x7f;    /* Maximum delay with slowest rate */
-
-#ifdef __sparc__
-  int         rate  = 500;     /* Default rate */
-  int         delay = 200;     /* Default delay */
-#else
-  int         rate  = 300;     /* Default rate */
-  int         delay = 250;     /* Default delay */
-#endif
-
-  static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
-			       133, 120, 109, 100, 92, 86, 80, 75, 67,
-			       60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
-			       25, 23, 21, 20 };
-#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
-
-  static int valid_delays[] = { 250, 500, 750, 1000 };
-#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
-
-  if (pKbd->rate >= 0) 
-    rate = pKbd->rate * 10;
-  if (pKbd->delay >= 0)
-    delay = pKbd->delay;
-
-  if(KDKBDREP_ioctl_ok(rate, delay)) 	/* m68k? */
-    return;
-
-  if(KIOCSRATE_ioctl_ok(rate, delay))	/* sparc? */
-    return;
-
-  if (xf86IsPc98())
-    return;
-
-#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
-
-  if (!xorgHWAccess) {
-      if (xf86EnableIO())
-	  xorgHWAccess = TRUE;
-      else 
-	  return;
-  }
-      
-  /* The ioport way */
-
-  for (i = 0; i < RATE_COUNT; i++)
-    if (rate >= valid_rates[i]) {
-      value &= 0x60;
-      value |= i;
-      break;
-    }
-
-  for (i = 0; i < DELAY_COUNT; i++)
-    if (delay <= valid_delays[i]) {
-      value &= 0x1f;
-      value |= i << 5;
-      break;
-    }
-
-  timeout = KBC_TIMEOUT;
-  while (((inb(0x64) & 2) == 2) && --timeout)
-       usleep(1000); /* wait */
-
-  if (timeout == 0)
-      return;
-
-  outb(0x60, 0xf3);             /* set typematic rate */
-  while (((inb(0x64) & 2) == 2) && --timeout)
-       usleep(1000); /* wait */
-
-  usleep(10000);
-  outb(0x60, value);
-
-#endif /* __alpha__ || __i386__ || __ia64__ */
-}
-
-typedef struct {
-   int kbdtrans;
-   struct termios kbdtty;
-} LnxKbdPrivRec, *LnxKbdPrivPtr;
-
-static int
-KbdInit(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
-
-    if (pKbd->isConsole) {
-        ioctl (pInfo->fd, KDGKBMODE, &(priv->kbdtrans));
-        tcgetattr (pInfo->fd, &(priv->kbdtty));
-    }
-    if (!pKbd->CustomKeycodes) {
-        pKbd->RemapScanCode = ATScancode;
-    }
-
-    return Success;
-}
-
-static int
-KbdOn(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
-    struct termios nTty;
-
-    if (pKbd->isConsole) {
-	if (pKbd->CustomKeycodes)
-	    ioctl(pInfo->fd, KDSKBMODE, K_MEDIUMRAW);
-	else
-	    ioctl(pInfo->fd, KDSKBMODE, K_RAW);
-
-	nTty = priv->kbdtty;
-	nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
-	nTty.c_oflag = 0;
-	nTty.c_cflag = CREAD | CS8;
-	nTty.c_lflag = 0;
-	nTty.c_cc[VTIME]=0;
-	nTty.c_cc[VMIN]=1;
-	cfsetispeed(&nTty, 9600);
-	cfsetospeed(&nTty, 9600);
-	tcsetattr(pInfo->fd, TCSANOW, &nTty);
-    }
-    return Success;
-}
-
-static int
-KbdOff(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
-
-    if (pKbd->isConsole) {
-	ioctl(pInfo->fd, KDSKBMODE, priv->kbdtrans);
-	tcsetattr(pInfo->fd, TCSANOW, &(priv->kbdtty));
-    }
-    return Success;
-}
-
-static int
-GetSpecialKey(InputInfoPtr pInfo, int scanCode)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  int specialkey = scanCode;
-
-#if defined (__sparc__)
-  if (pKbd->sunKbd) {
-      switch (scanCode) {
-          case 0x2b: specialkey = KEY_BackSpace; break;
-          case 0x47: specialkey = KEY_KP_Minus; break;
-          case 0x7d: specialkey = KEY_KP_Plus; break;
-          /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */
-          case 0x05: specialkey = KEY_F1; break;
-          case 0x06: specialkey = KEY_F2; break;
-          case 0x08: specialkey = KEY_F3; break;
-          case 0x0a: specialkey = KEY_F4; break;
-          case 0x0c: specialkey = KEY_F5; break;
-          case 0x0e: specialkey = KEY_F6; break;
-          case 0x10: specialkey = KEY_F7; break;
-          case 0x11: specialkey = KEY_F8; break;
-          case 0x12: specialkey = KEY_F9; break;
-          case 0x07: specialkey = KEY_F10; break;
-          case 0x09: specialkey = KEY_F11; break;
-          case 0x0b: specialkey = KEY_F12; break;
-          default: specialkey = 0; break;
-      }
-      return specialkey;
-  }
-#endif
-
-  if (pKbd->CustomKeycodes) {
-      specialkey = pKbd->specialMap->map[scanCode];
-  }
-  return specialkey;
-}
-
-#define ModifierSet(k) ((modifiers & (k)) == (k))
-
-static
-Bool SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-
-  if(!pKbd->vtSwitchSupported)
-      return FALSE;
-
-  if ((ModifierSet(ControlMask | AltMask)) ||
-      (ModifierSet(ControlMask | AltLangMask))) {
-      if (VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
-          switch (key) {
-             case KEY_F1:
-             case KEY_F2:
-             case KEY_F3:
-             case KEY_F4:
-             case KEY_F5:
-             case KEY_F6:
-             case KEY_F7:
-             case KEY_F8:
-             case KEY_F9:
-             case KEY_F10:
-                  if (down) {
-                    ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
-                    return TRUE;
-                  }
-             case KEY_F11:
-             case KEY_F12:
-                  if (down) {
-                    ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
-                    return TRUE;
-                  }
-         }
-      }
-  }
-#ifdef USE_VT_SYSREQ
-    if (VTSwitchEnabled && xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
-        switch (key) {
-            case KEY_F1:
-            case KEY_F2:
-            case KEY_F3:
-            case KEY_F4:
-            case KEY_F5:
-            case KEY_F6:
-            case KEY_F7:
-            case KEY_F8:
-            case KEY_F9:
-            case KEY_F10:
-                 if (VTSysreqToggle && down) {
-                     ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
-                     VTSysreqToggle = FALSE;
-                     return TRUE;
-                 }
-                 break;
-            case KEY_F11:
-            case KEY_F12:
-                 if (VTSysreqToggle && down) {
-                     ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
-                     VTSysreqToggle = FALSE;
-                     return TRUE;
-                 }
-                 break;
-            /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
-            case KEY_Alt:
-            case KEY_AltLang:
-                 break;
-            case KEY_SysReqest:
-                 if ((ModifierSet(AltMask) || ModifierSet(AltLangMask)) && down)
-                     VTSysreqToggle = TRUE;
-                 break;
-             default:
-                 /*
-                  * We only land here when Alt-SysReq is followed by a
-                  * non-switching key.
-                  */
-                 if (VTSysreqToggle)
-                     VTSysreqToggle = FALSE;
-        }
-    }
-#endif /* USE_VT_SYSREQ */
-    return FALSE;
-} 
-
-static void
-stdReadInput(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    unsigned char rBuf[64];
-    int nBytes, i;
-    if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) {
-       for (i = 0; i < nBytes; i++)
-           pKbd->PostEvent(pInfo, rBuf[i] & 0x7f,
-                           rBuf[i] & 0x80 ? FALSE : TRUE);
-       }
-}
-
-static Bool
-OpenKeyboard(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    int i;
-    KbdProtocolId prot = PROT_UNKNOWN_KBD;
-    char *s;
-
-    s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
-    for (i = 0; protocols[i].name; i++) {
-        if (xf86NameCmp(s, protocols[i].name) == 0) {
-           prot = protocols[i].id;
-           break;
-        }
-    }
-
-    switch (prot) {
-        case PROT_STD:
-           pInfo->read_input = stdReadInput;
-           break;
-        default:
-           xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
-           xfree(s);
-           return FALSE;
-    }
-
-    xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s);
-    xfree(s);
-
-    s = xf86SetStrOption(pInfo->options, "Device", NULL);
-    if (s == NULL) {
-       pInfo->fd = xf86Info.consoleFd;
-       pKbd->isConsole = TRUE;
-    } else {
-       pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
-       if (pInfo->fd == -1) {
-           xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
-           xfree(s);
-           return FALSE;
-       }
-       pKbd->isConsole = FALSE;
-       xfree(s);
-    }
-
-    if (pKbd->isConsole)
-         pKbd->vtSwitchSupported = TRUE;
-
-    return TRUE;
-}
-
-_X_EXPORT Bool
-xf86OSKbdPreInit(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = pInfo->private;
-
-    pKbd->KbdInit       = KbdInit;
-    pKbd->KbdOn         = KbdOn;
-    pKbd->KbdOff        = KbdOff;
-    pKbd->Bell          = SoundBell;
-    pKbd->SetLeds       = SetKbdLeds;
-    pKbd->GetLeds       = GetKbdLeds;
-    pKbd->SetKbdRepeat  = SetKbdRepeat;
-    pKbd->KbdGetMapping = KbdGetMapping;
-    pKbd->SpecialKey    = SpecialKey;
-
-    pKbd->RemapScanCode = NULL;
-    pKbd->GetSpecialKey = GetSpecialKey;
-
-    pKbd->OpenKeyboard = OpenKeyboard;
-    pKbd->vtSwitchSupported = FALSE;
-
-    pKbd->private = xcalloc(sizeof(LnxKbdPrivRec), 1);
-    if (pKbd->private == NULL) {
-       xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
-       return FALSE;
-    }
-
-#if defined(__powerpc__)
-  {
-    FILE *f;
-    f = fopen("/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes","r");
-    if (f) {
-        if (fgetc(f) == '0')
-            pKbd->CustomKeycodes = TRUE;
-        fclose(f);
-    }
-  }
-#endif
-    return TRUE;
-}
diff --git a/hw/xfree86/os-support/lynxos/lynx_io.c b/hw/xfree86/os-support/lynxos/lynx_io.c
deleted file mode 100644
index 8181046..0000000
--- a/hw/xfree86/os-support/lynxos/lynx_io.c
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright 1993 by Thomas Mueller
- *
- * 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 Mueller not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Thomas Mueller makes no representations
- * about the suitability of this software for any purpose.  It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS MUELLER 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_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#if defined(KDMKTONE) || defined(KIOCSOUND)
-/* Lynx 2.2.1 has sophisticated atc stuff.... */
-_X_EXPORT void
-xf86SoundKbdBell(int loudness, int pitch, int duration)
-{
-	if (loudness && pitch)
-	{
-#ifdef KDMKTONE
-		/*
-		 * If we have KDMKTONE use it to avoid putting the server
-		 * to sleep
-		 */
-		ioctl(xf86Info.consoleFd, KDMKTONE,
-		      (pitch & 0xffff) |
-		      (((unsigned long)duration *
-			loudness / 50) << 16));
-#else
-		ioctl(xf86Info.consoleFd, KIOCSOUND, pitch);
-		usleep(xf86Info.bell_duration * loudness * 20);
-		ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
-#endif
-	}
-}
-
-#else
-
-/* this is pulled from /sys/drivers/vt100/atbeep.c */
-
-#define	SPEAKER_CONTROL	0x61
-#define	TIMER_CONTROL	0x43
-#define	TIMER_DATA	0x42
-#define	TIMER_LOAD_CMD	0xb6
-
-#define	TIMER_CONSTANT	1193280
-#define	FREQ_LO(f)	((TIMER_CONSTANT / (f)) % 256)
-#define	FREQ_HI(f)	((TIMER_CONSTANT / (f)) / 256)
-
-void
-xf86SoundKbdBell(int loudness, int pitch, int duration)
-{
-	int	flo = FREQ_LO(pitch);
-	int	fhi = FREQ_HI(pitch);
-
-	outb(TIMER_CONTROL, TIMER_LOAD_CMD);
-	outb(TIMER_DATA, flo);
-	outb(TIMER_DATA, fhi);
-
-	/* speaker on */
-	outb(SPEAKER_CONTROL, inb(SPEAKER_CONTROL) | 3);
-	usleep(xf86Info.bell_duration * loudness * 20);
-	/* speaker off */
-	outb(SPEAKER_CONTROL, inb(SPEAKER_CONTROL) & ~3);
-}
-#endif
-
-void
-xf86SetKbdLeds(int leds)
-{
-#ifdef KBD_SET_LEDS
-	ioctl(xf86Info.consoleFd, KBD_SET_LEDS, &leds);
-#endif
-}
-
-int
-xf86GetKbdLeds()
-{
-#ifdef KBD_SET_LEDS
-	int leds;
-
-	if (ioctl(xf86Info.consoleFd, KBD_SET_LEDS, &leds) < 0)
-		return 0;
-
-	return leds;
-#endif
-	return 0;
-}
-
-void
-xf86SetKbdRepeat(char rad)
-{
-}
-
-static struct termio kbdtty;
-
-void
-xf86KbdInit()
-{
-	ioctl(xf86Info.consoleFd, TCGETA, &kbdtty);
-}
-
-int
-xf86KbdOn()
-{
-	struct termio nTty;
-
-	/* set CAPS_LOCK to behave as CAPS_LOCK not as CTRL */
-	write(xf86Info.consoleFd, "\033<", 2);
-
-	/* enable scan mode */
-	ioctl(xf86Info.consoleFd, TIO_ENSCANMODE, NULL);
-
-	nTty = kbdtty;
-	nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
-	nTty.c_oflag = 0;
-	nTty.c_cflag = CREAD | CS8;
-	nTty.c_lflag = 0;
-	nTty.c_cc[VTIME]=0;
-	nTty.c_cc[VMIN]=1;
-	ioctl(xf86Info.consoleFd, TCSETA, &nTty);
-
-	return(xf86Info.consoleFd);
-}
-
-int
-xf86KbdOff()
-{
-	/* disable scan mode */
-	ioctl(xf86Info.consoleFd, TIO_DISSCANMODE, NULL);
-	ioctl(xf86Info.consoleFd, TCSETA, &kbdtty);
-	return(xf86Info.consoleFd);
-}
-
-#include "xf86OSKbd.h"
-
-_X_EXPORT Bool
-xf86OSKbdPreInit(InputInfoPtr pInfo)
-{
-    return FALSE;
-}
diff --git a/hw/xfree86/os-support/sco/Makefile.am b/hw/xfree86/os-support/sco/Makefile.am
index 1271c9d..820d183 100644
--- a/hw/xfree86/os-support/sco/Makefile.am
+++ b/hw/xfree86/os-support/sco/Makefile.am
@@ -4,7 +4,5 @@ EXTRA_DIST = \
 	sco_init.c \
 	sco_io.c \
 	sco_iop.c \
-	sco_kbd.c \
-	sco_kbd.h \
 	sco_mouse.c \
 	sco_video.c
diff --git a/hw/xfree86/os-support/sco/sco_KbdMap.c b/hw/xfree86/os-support/sco/sco_KbdMap.c
deleted file mode 100644
index 6a0e9de..0000000
--- a/hw/xfree86/os-support/sco/sco_KbdMap.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/* $XFree86$ */
-/*
- * Copyright 2005 by J. Kean Johnston <jkj at sco.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name J. Kean Johnston not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  J. Kean Johnston makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
- * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Based on xf86KbdMap.c, which is
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
- */
-
-#include "X.h"
-#include "Xmd.h"
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86Xinput.h"
-#include "xf86OSKbd.h"
-#include "atKeynames.h"
-#include "xf86Keymap.h"
-
-#include "sco_kbd.h"
-
-#define KD_GET_ENTRY(i,n) \
-  eascii_to_x[((priv->keymap.key[i].spcl << (n+1)) & 0x100) + priv->keymap.key[i].map[n]]
-
-/*
- * NOTE: Not all possible remappable symbols are remapped. There are two main
- *       reasons:
- *                 a) The mapping between scancode and SYSV/386 - symboltable
- *                    is inconsistent between different versions and has some
- *                    BIG mistakes.
- *                 b) In X-Windows there is a difference between numpad-keys
- *                    and normal keys. SYSV/386 uses for both kinds of keys
- *                    the same symbol.
- *
- *       Thus only the alpha keypad and the function keys are translated.
- *       Also CapsLock, NumLock, ScrollLock, Shift, Control & Alt.
- */
-
-static unsigned char remap[128] = {
-     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
-  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
-  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
-  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
-  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
-  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
-  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
-  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
-  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
-     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
-  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
-     0,    0, 0x69, 0x65,    0,    0,    0,    0,   /* 0x70 - 0x77 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
-};
-
-static KeySym eascii_to_x[512] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	XK_Ccedilla,	XK_udiaeresis,	XK_eacute,	XK_acircumflex,
-	XK_adiaeresis,	XK_agrave,	XK_aring,	XK_ccedilla,
-	XK_ecircumflex,	XK_ediaeresis,	XK_egrave,	XK_idiaeresis,
-	XK_icircumflex,	XK_igrave,	XK_Adiaeresis,	XK_Aring,
-	XK_Eacute,	XK_ae,		XK_AE,		XK_ocircumflex,
-	XK_odiaeresis,	XK_ograve,	XK_ucircumflex,	XK_ugrave,
-	XK_ydiaeresis,	XK_Odiaeresis,	XK_Udiaeresis,	XK_cent,
-	XK_sterling,	XK_yen,		XK_paragraph,	XK_section,
-	XK_aacute,	XK_iacute,	XK_oacute,	XK_uacute,
-	XK_ntilde,	XK_Ntilde,	XK_ordfeminine,	XK_masculine,
-	XK_questiondown,XK_hyphen,	XK_notsign,	XK_onehalf,
-	XK_onequarter,	XK_exclamdown,	XK_guillemotleft,XK_guillemotright,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Greek_alpha,	XK_ssharp,	XK_Greek_GAMMA,	XK_Greek_pi,
-	XK_Greek_SIGMA,	XK_Greek_sigma,	XK_mu,	        XK_Greek_tau,
-	XK_Greek_PHI,	XK_Greek_THETA,	XK_Greek_OMEGA,	XK_Greek_delta,
-	XK_infinity,	XK_Ooblique,	XK_Greek_epsilon, XK_intersection,
-	XK_identical,	XK_plusminus,	XK_greaterthanequal, XK_lessthanequal,
-	XK_topintegral,	XK_botintegral,	XK_division,	XK_similarequal,
-	XK_degree,	NoSymbol,	NoSymbol,	XK_radical,
-	XK_Greek_eta,	XK_twosuperior,	XK_periodcentered, NoSymbol,
-
-	/* 
-	 * special marked entries (256 + x)
-	 */
-
-	NoSymbol,	NoSymbol,	XK_Shift_L,	XK_Shift_R,
-	XK_Caps_Lock,	XK_Num_Lock,	XK_Scroll_Lock,	XK_Alt_L,
-	NoSymbol,	XK_Control_L,	XK_Alt_L,	XK_Alt_R,
-	XK_Control_L,	XK_Control_R,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_F1,
-	XK_F2,		XK_F3,		XK_F4,		XK_F5,
-	XK_F6,		XK_F7,		XK_F8,		XK_F9,
-	XK_F10,		XK_F11,		XK_F12,		NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-      };
-
-/*
- * KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-void
-KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private;
-  KeySym *k;
-  int i;
-  KeySym *pMap = map;
-
-  for (i = 0; i < priv->keymap.n_keys && i < NUM_KEYCODES; i++) {
-    if (remap[i]) {
-      k = pMap + (remap[i] << 2);
-	
-      k[0] = KD_GET_ENTRY(i,0);       /* non-shifed */
-      k[1] = KD_GET_ENTRY(i,1);	      /* shifted */
-      k[2] = KD_GET_ENTRY(i,4);	      /* alt */
-      k[3] = KD_GET_ENTRY(i,5);	      /* alt - shifted */
-
-      if (k[3] == k[2]) k[3] = NoSymbol;
-      if (k[2] == k[1]) k[2] = NoSymbol;
-      if (k[1] == k[0]) k[1] = NoSymbol;
-      if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
-    }
-  }
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = pMap, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += GLYPHS_PER_KEY) {
-    
-    switch(*k) {
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-    }
-  }
-
-  pKeySyms->map        = pMap;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  pKeySyms->maxKeyCode = MAX_KEYCODE;
-}
diff --git a/hw/xfree86/os-support/sco/sco_kbd.c b/hw/xfree86/os-support/sco/sco_kbd.c
deleted file mode 100644
index 8b1d5b7..0000000
--- a/hw/xfree86/os-support/sco/sco_kbd.c
+++ /dev/null
@@ -1,530 +0,0 @@
-/* $XFree86$ */
-/*
- * Copyright 2005 by J. Kean Johnston <jkj at sco.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name J. Kean Johnston not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  J. Kean Johnston makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
- * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-/* $XConsortium$ */
-
-/*
- * Based on sco_io.c which is
- * (C) Copyright 2003 J. Kean Johnston <jkj at sco.com>
- *
- * Based on lnx_kbd.c which is 
- * Copyright (c) 2002 by The XFree86 Project, Inc.
- *
- * Based on the code from lnx_io.c which is
- * Copyright 1992 by Orest Zborowski <obz at Kodak.com>
- * Copyright 1993 by David Dawes <dawes at xfree86.org>
- */
-
-#define NEED_EVENTS
-#include "X.h"
-
-#include "compiler.h"
-
-#define _NEED_SYSI86
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86OSpriv.h"
-#include "xf86_OSlib.h"
-
-#include "xf86Xinput.h"
-#include "xf86OSKbd.h"
-#include "atKeynames.h"
-#include "sco_kbd.h"
-
-#include <sys/param.h>
-#include <sys/emap.h>
-#include <sys/nmap.h>
-
-static KbdProtocolRec protocols[] = {
-  { "standard", PROT_STD },
-  { NULL, PROT_UNKNOWN_KBD }
-};
-
-extern Bool VTSwitchEnabled;
-#ifdef USE_VT_SYSREQ
-extern Bool VTSysreqToggle;
-#endif
-
-static void
-SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
-{
-  if (loudness && pitch) {
-    ioctl(pInfo->fd, KIOCSOUND, 1193180 / pitch);
-    usleep(duration * loudness * 20);
-    ioctl(pInfo->fd, KIOCSOUND, 0);
-  }
-}
-
-static void
-SetKbdLeds(InputInfoPtr pInfo, int leds)
-{
-  int real_leds = 0;
-  static int once = 1;
-
-  /*
-   * sleep the first time through under SCO.  There appears to be a
-   * timing problem in the driver which causes the keyboard to be lost.
-   * This usleep stops it from occurring. NOTE: this was in the old code.
-   * I am not convinced it is true any longer, but it doesn't hurt to
-   * leave this in here.
-   */
-  if (once) {
-    usleep(100);
-    once = 0;
-  }
-
-#ifdef LED_CAP
-  if (leds & XLED1)
-    real_leds |= LED_CAP;
-  if (leds & XLED2)
-    real_leds |= LED_NUM;
-  if (leds & XLED3)
-    real_leds |= LED_SCR;
-#ifdef LED_COMP
-  if (leds & XLED4)
-    real_leds |= LED_COMP;
-#else
-  if (leds & XLED4)
-    real_leds |= LED_SCR;
-#endif
-#endif
-  ioctl(pInfo->fd, KDSETLED, real_leds);
-}
-
-static int
-GetKbdLeds(InputInfoPtr pInfo)
-{
-    int real_leds, leds = 0;
-
-    ioctl(pInfo->fd, KDGETLED, &real_leds);
-
-    if (real_leds & LED_CAP) leds |= XLED1;
-    if (real_leds & LED_NUM) leds |= XLED2;
-    if (real_leds & LED_SCR) leds |= XLED3;
-
-    return(leds);
-}
-
-/*
- * NOTE: Only OpenServer Release 5.0.6 with Release Supplement 5.0.6A
- * and later have the required ioctl. 5.0.6A or higher is HIGHLY
- * recommended. The console driver is quite a different beast on that OS.
- */
-#undef rate
-
-static void
-SetKbdRepeat(InputInfoPtr pInfo, char rad)
-{
-#if defined(KBIO_SETRATE)
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  int i;
-  int value = 0x7f;     /* Maximum delay with slowest rate */
-  int delay = 250;      /* Default delay */
-  int rate = 300;       /* Default repeat rate */
-
-  static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
-                               133, 120, 109, 100, 92, 86, 80, 75, 67,
-                               60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
-                               25, 23, 21, 20 };
-#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
-
-  static int valid_delays[] = { 250, 500, 750, 1000 };
-#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
-
-  if (pKbd->rate >= 0) 
-    rate = pKbd->rate * 10;
-  if (pKbd->delay >= 0)
-    delay = pKbd->delay;
-
-  for (i = 0; i < RATE_COUNT; i++)
-    if (rate >= valid_rates[i]) {
-      value &= 0x60;
-      value |= i;
-      break;
-    }
-
-  for (i = 0; i < DELAY_COUNT; i++)
-    if (delay <= valid_delays[i]) {
-      value &= 0x1f;
-      value |= i << 5;
-      break;
-    }
-
-  ioctl (pInfo->fd, KBIO_SETRATE, value);
-#endif /* defined(KBIO_SETRATE) */
-}
-
-static int
-KbdInit(InputInfoPtr pInfo, int what)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private;
-
-  if (pKbd->isConsole) {
-    priv->use_tcs = 1;
-    priv->use_kd = 1;
-    priv->no_nmap = 1;
-    priv->no_emap = 1;
-    priv->orig_getsc = 0;
-
-    if (ioctl (pInfo->fd, TCGETSC, &priv->orig_getsc) < 0)
-      priv->use_tcs = 0;
-    if (ioctl (pInfo->fd, KDGKBMODE, &priv->orig_kbm) < 0)
-      priv->use_kd = 0;
-
-    if (!priv->use_tcs && !priv->use_kd) {
-      xf86Msg (X_ERROR, "KbdInit: Could not determine keyboard mode\n");
-      return !Success;
-    }
-
-    /*
-     * One day this should be fixed to translate normal ASCII characters
-     * back into scancodes or into events that XFree86 wants, but not
-     * now. For the time being, we only support scancode mode screens.
-     */
-    if (priv->use_tcs && !(priv->orig_getsc & KB_ISSCANCODE)) {
-      xf86Msg (X_ERROR, "KbdInit: Keyboard can not send scancodes\n");
-      return !Success;
-    }
-
-    /*
-     * We need to get the original keyboard map and NUL out the lock
-     * modifiers. This prevents the scancode API from messing with
-     * the keyboard LED's. We restore the original map when we exit.
-     */
-    if (ioctl (pInfo->fd, GIO_KEYMAP, &priv->keymap) < 0) {
-      xf86Msg (X_ERROR, "KbdInit: Failed to get keyboard map (%s)\n",
-        strerror(errno));
-      return !Success;
-    }
-    if (ioctl (pInfo->fd, GIO_KEYMAP, &priv->noledmap) < 0) {
-      xf86Msg (X_ERROR, "KbdInit: Failed to get keyboard map (%s)\n",
-        strerror(errno));
-      return !Success;
-    } else {
-      int i, j;
-
-      for (i = 0; i < priv->noledmap.n_keys; i++) {
-        for (j = 0; j < NUM_STATES; j++) {
-          if (IS_SPECIAL(priv->noledmap, i, j) &&
-            ((priv->noledmap.key[i].map[j] == K_CLK) ||
-             (priv->noledmap.key[i].map[j] == K_NLK) ||
-             (priv->noledmap.key[i].map[j] == K_SLK))) {
-            priv->noledmap.key[i].map[j] = K_NOP;
-          }
-        }
-      }
-    }
-
-    if (ioctl (pInfo->fd, XCGETA, &priv->kbdtty) < 0) {
-      xf86Msg (X_ERROR, "KbdInit: Failed to get terminal modes (%s)\n",
-        strerror(errno));
-      return !Success;
-    }
-
-    priv->sc_mapbuf = xalloc (10*BSIZE);
-    priv->sc_mapbuf2 = xalloc(10*BSIZE);
-
-    /* Get the emap */
-    if (ioctl (pInfo->fd, LDGMAP, priv->sc_mapbuf) < 0) {
-      if (errno != ENAVAIL) {
-        xf86Msg (X_ERROR, "KbdInit: Failed to retrieve e-map (%s)\n",
-          strerror (errno));
-        return !Success;
-      }
-      priv->no_emap = 0;
-    }
-
-    /* Get the nmap */
-    if (ioctl (pInfo->fd, NMGMAP, priv->sc_mapbuf2) < 0) {
-      if (errno != ENAVAIL) {
-        xf86Msg (X_ERROR, "KbdInit: Failed to retrieve n-map (%s)\n",
-          strerror (errno));
-        return !Success;
-      }
-      priv->no_nmap = 0;
-    }
-  } /* End of if we are on a console */
-
-  return Success;
-}
-
-static int
-KbdOn(InputInfoPtr pInfo, int what)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private;
-  struct termios newtio;
-
-  if (pKbd->isConsole) {
-    ioctl (pInfo->fd, LDNMAP); /* Turn e-mapping off */
-    ioctl (pInfo->fd, NMNMAP); /* Turn n-mapping off */
-
-    newtio = priv->kbdtty;     /* structure copy */
-    newtio.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
-    newtio.c_oflag = 0;
-    newtio.c_cflag = CREAD | CS8 | B9600;
-    newtio.c_lflag = 0;
-    newtio.c_cc[VTIME]=0;
-    newtio.c_cc[VMIN]=1;
-    cfsetispeed(&newtio, 9600);
-    cfsetospeed(&newtio, 9600);
-    ioctl(pInfo->fd, XCSETA, &newtio);
-
-    /* Now tell the keyboard driver to send us raw scancodes */
-    if (priv->use_tcs) {
-      int nm = priv->orig_getsc;
-      nm &= ~KB_XSCANCODE;
-      ioctl (pInfo->fd, TCSETSC, &nm);
-    }
-
-    if (priv->use_kd)
-      ioctl (pInfo->fd, KDSKBMODE, K_RAW);
-
-    ioctl (pInfo->fd, PIO_KEYMAP, &priv->noledmap);
-  }
-
-  return Success;
-}
-
-static int
-KbdOff(InputInfoPtr pInfo, int what)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  ScoKbdPrivPtr priv = (ScoKbdPrivPtr) pKbd->private;
-
-  if (pKbd->isConsole) {
-    /* Revert back to original translate scancode mode */
-    if (priv->use_tcs)
-      ioctl (pInfo->fd, TCSETSC, &priv->orig_getsc);
-    if (priv->use_kd)
-      ioctl (pInfo->fd, KDSKBMODE, priv->orig_kbm);
-
-    ioctl (pInfo->fd, PIO_KEYMAP, &priv->keymap);
-
-    if (priv->no_emap)
-      ioctl (pInfo->fd, LDSMAP, priv->sc_mapbuf);
-    if (priv->no_nmap)
-      ioctl (pInfo->fd, NMSMAP, priv->sc_mapbuf2);
-
-    ioctl(pInfo->fd, XCSETA, &priv->kbdtty);
-  }
-
-  return Success;
-}
-
-static int
-GetSpecialKey(InputInfoPtr pInfo, int scanCode)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  int specialkey = scanCode;
-
-  if (pKbd->CustomKeycodes) {
-      specialkey = pKbd->specialMap->map[scanCode];
-  }
-  return specialkey;
-}
-
-#define ModifierSet(k) ((modifiers & (k)) == (k))
-
-static Bool
-SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-
-  if(!pKbd->vtSwitchSupported)
-    return FALSE;
-
-  if ((!ModifierSet(ShiftMask)) && ((ModifierSet(ControlMask | AltMask)) ||
-      (ModifierSet(ControlMask | AltLangMask)))) {
-    if (VTSwitchEnabled && !xf86Info.vtSysreq) {
-      switch (key) {
-        case KEY_F1:
-        case KEY_F2:
-        case KEY_F3:
-        case KEY_F4:
-        case KEY_F5:
-        case KEY_F6:
-        case KEY_F7:
-        case KEY_F8:
-        case KEY_F9:
-        case KEY_F10:
-          if (down) {
-	    int sts = key - KEY_F1;
-	    if (sts != xf86Info.vtno) {
-	      ioctl(pInfo->fd, VT_ACTIVATE, sts);
-	    }
-            return TRUE;
-          }
-        case KEY_F11:
-        case KEY_F12:
-          if (down) {
-	    int sts = key - KEY_F11 + 10;
-	    if (sts != xf86Info.vtno) {
-	      ioctl(pInfo->fd, VT_ACTIVATE, sts);
-	    }
-            return TRUE;
-          }
-      }
-    }
-  }
-#ifdef USE_VT_SYSREQ
-  if (VTSwitchEnabled && xf86Info.vtSysreq) {
-    switch (key) {
-      case KEY_F1:
-      case KEY_F2:
-      case KEY_F3:
-      case KEY_F4:
-      case KEY_F5:
-      case KEY_F6:
-      case KEY_F7:
-      case KEY_F8:
-      case KEY_F9:
-      case KEY_F10:
-        if (VTSysreqToggle && down) {
-          ioctl(pInfo->fd, VT_ACTIVATE, key - KEY_F1);
-          VTSysreqToggle = FALSE;
-          return TRUE;
-        }
-        break;
-      case KEY_F11:
-      case KEY_F12:
-        if (VTSysreqToggle && down) {
-          ioctl(pInfo->fd, VT_ACTIVATE, key - KEY_F11 + 10);
-          VTSysreqToggle = FALSE;
-          return TRUE;
-        }
-        break;
-        /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
-      case KEY_Alt:
-      case KEY_AltLang:
-        break;
-      case KEY_SysReqest:
-        if (!(ModifierSet(ShiftMask) || ModifierSet(ControlMask))) {
-          if ((ModifierSet(AltMask) || ModifierSet(AltLangMask)) && down)
-            VTSysreqToggle = TRUE;
-        }
-        break;
-      default:
-        /*
-         * We only land here when Alt-SysReq is followed by a
-         * non-switching key.
-         */
-        if (VTSysreqToggle)
-          VTSysreqToggle = FALSE;
-    }
-  }
-#endif /* USE_VT_SYSREQ */
-  return FALSE;
-} 
-
-static void
-stdReadInput(InputInfoPtr pInfo)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  unsigned char rBuf[64];
-  int nBytes, i;
-
-  if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) {
-    for (i = 0; i < nBytes; i++) {
-      pKbd->PostEvent(pInfo, rBuf[i] & 0x7f, rBuf[i] & 0x80 ? FALSE : TRUE);
-    }
-  }
-}
-
-static Bool
-OpenKeyboard(InputInfoPtr pInfo)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  int i;
-  KbdProtocolId prot = PROT_UNKNOWN_KBD;
-  char *s;
-
-  s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
-  for (i = 0; protocols[i].name; i++) {
-    if (xf86NameCmp(s, protocols[i].name) == 0) {
-      prot = protocols[i].id;
-      break;
-    }
-  }
-
-  switch (prot) {
-    case PROT_STD:
-      pInfo->read_input = stdReadInput;
-      break;
-    default:
-      xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
-      xfree(s);
-      return FALSE;
-  }
-
-  xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s);
-  xfree(s);
-
-  s = xf86SetStrOption(pInfo->options, "Device", NULL);
-  if (s == NULL) {
-    pInfo->fd = xf86Info.consoleFd;
-    pKbd->isConsole = TRUE;
-  } else {
-    pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
-    if (pInfo->fd == -1) {
-      xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
-      xfree(s);
-      return FALSE;
-    }
-    pKbd->isConsole = FALSE;
-    xfree(s);
-  }
-
-  if (pKbd->isConsole)
-    pKbd->vtSwitchSupported = TRUE;
-
-  return TRUE;
-}
-
-_X_EXPORT Bool
-xf86OSKbdPreInit(InputInfoPtr pInfo)
-{
-  KbdDevPtr pKbd = pInfo->private;
-
-  pKbd->KbdInit           = KbdInit;
-  pKbd->KbdOn             = KbdOn;
-  pKbd->KbdOff            = KbdOff;
-  pKbd->Bell              = SoundBell;
-  pKbd->SetLeds           = SetKbdLeds;
-  pKbd->GetLeds           = GetKbdLeds;
-  pKbd->SetKbdRepeat      = SetKbdRepeat;
-  pKbd->KbdGetMapping     = KbdGetMapping;
-  pKbd->SpecialKey        = SpecialKey;
-  pKbd->GetSpecialKey     = GetSpecialKey;
-  pKbd->OpenKeyboard      = OpenKeyboard;
-  pKbd->RemapScanCode     = ATScancode;
-  pKbd->vtSwitchSupported = FALSE;
-
-  pKbd->private = xcalloc(sizeof(ScoKbdPrivRec), 1);
-  if (pKbd->private == NULL) {
-    xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
-    return FALSE;
-  }
-
-  return TRUE;
-}
diff --git a/hw/xfree86/os-support/sco/sco_kbd.h b/hw/xfree86/os-support/sco/sco_kbd.h
deleted file mode 100644
index a79cd7b..0000000
--- a/hw/xfree86/os-support/sco/sco_kbd.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* $XFree86$ */
-#ifndef SCO_KBD_HDR
-#define SCO_KBD_HDR
-
-typedef struct {
-  int use_tcs;
-  int use_kd;
-  int no_nmap;
-  int no_emap;
-  int orig_getsc;
-  int orig_kbm;
-  struct termios kbdtty;
-  keymap_t keymap, noledmap;
-  uchar_t *sc_mapbuf;
-  uchar_t *sc_mapbuf2;
-} ScoKbdPrivRec, *ScoKbdPrivPtr;
-
-extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms,
-  CARD8 *pModMap);
-#endif /* SCO_KBD_HDR */
diff --git a/hw/xfree86/os-support/shared/at_scancode.c b/hw/xfree86/os-support/shared/at_scancode.c
deleted file mode 100644
index 10d3da2..0000000
--- a/hw/xfree86/os-support/shared/at_scancode.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (c) 2002-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86Xinput.h"
-#include "xf86OSKbd.h"
-#include "atKeynames.h"
-
-Bool
-ATScancode(InputInfoPtr pInfo, int *scanCode)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-
-    switch (pKbd->scanPrefix) {
-       case 0:
-          switch (*scanCode) {
-             case KEY_Prefix0:
-             case KEY_Prefix1:
-                  pKbd->scanPrefix = *scanCode;  /* special prefixes */
-                  return TRUE;
-          }
-          if (!xf86IsPc98()) {
-            switch (*scanCode) {
-             case 0x59: *scanCode = KEY_0x59; break;
-             case 0x5a: *scanCode = KEY_0x5A; break;
-             case 0x5b: *scanCode = KEY_0x5B; break;
-             case 0x5c: *scanCode = KEY_KP_Equal; break; /* Keypad Equal */
-             case 0x5d: *scanCode = KEY_0x5D; break;
-             case 0x5e: *scanCode = KEY_0x5E; break;
-             case 0x5f: *scanCode = KEY_0x5F; break;
-             case 0x62: *scanCode = KEY_0x62; break;
-             case 0x63: *scanCode = KEY_0x63; break;
-             case 0x64: *scanCode = KEY_0x64; break;
-             case 0x65: *scanCode = KEY_0x65; break;
-             case 0x66: *scanCode = KEY_0x66; break;
-             case 0x67: *scanCode = KEY_0x67; break;
-             case 0x68: *scanCode = KEY_0x68; break;
-             case 0x69: *scanCode = KEY_0x69; break;
-             case 0x6a: *scanCode = KEY_0x6A; break;
-             case 0x6b: *scanCode = KEY_0x6B; break;
-             case 0x6c: *scanCode = KEY_0x6C; break;
-             case 0x6d: *scanCode = KEY_0x6D; break;
-             case 0x6e: *scanCode = KEY_0x6E; break;
-             case 0x6f: *scanCode = KEY_0x6F; break;
-             case 0x70: *scanCode = KEY_0x70; break;
-             case 0x71: *scanCode = KEY_0x71; break;
-             case 0x72: *scanCode = KEY_0x72; break;
-             case 0x73: *scanCode = KEY_0x73; break;
-             case 0x74: *scanCode = KEY_0x74; break;
-             case 0x75: *scanCode = KEY_0x75; break;
-             case 0x76: *scanCode = KEY_0x76; break;
-            }
-          }
-          break;
-       case KEY_Prefix0:
-          pKbd->scanPrefix = 0;
-          switch (*scanCode) {
-            case KEY_KP_7:        *scanCode = KEY_Home;      break;  /* curs home */
-            case KEY_KP_8:        *scanCode = KEY_Up;        break;  /* curs up */
-            case KEY_KP_9:        *scanCode = KEY_PgUp;      break;  /* curs pgup */
-            case KEY_KP_4:        *scanCode = KEY_Left;      break;  /* curs left */
-            case KEY_KP_5:        *scanCode = KEY_Begin;     break;  /* curs begin */
-            case KEY_KP_6:        *scanCode = KEY_Right;     break;  /* curs right */
-            case KEY_KP_1:        *scanCode = KEY_End;       break;  /* curs end */
-            case KEY_KP_2:        *scanCode = KEY_Down;      break;  /* curs down */
-            case KEY_KP_3:        *scanCode = KEY_PgDown;    break;  /* curs pgdown */
-            case KEY_KP_0:        *scanCode = KEY_Insert;    break;  /* curs insert */
-            case KEY_KP_Decimal:  *scanCode = KEY_Delete;    break;  /* curs delete */
-            case KEY_Enter:       *scanCode = KEY_KP_Enter;  break;  /* keypad enter */
-            case KEY_LCtrl:       *scanCode = KEY_RCtrl;     break;  /* right ctrl */
-            case KEY_KP_Multiply: *scanCode = KEY_Print;     break;  /* print */
-            case KEY_Slash:       *scanCode = KEY_KP_Divide; break;  /* keyp divide */
-            case KEY_Alt:         *scanCode = KEY_AltLang;   break;  /* right alt */
-            case KEY_ScrollLock:  *scanCode = KEY_Break;     break;  /* curs break */
-            case 0x5b:            *scanCode = KEY_LMeta;     break;
-            case 0x5c:            *scanCode = KEY_RMeta;     break;
-            case 0x5d:            *scanCode = KEY_Menu;      break;
-            case KEY_F3:          *scanCode = KEY_F13;       break;
-            case KEY_F4:          *scanCode = KEY_F14;       break;
-            case KEY_F5:          *scanCode = KEY_F15;       break;
-            case KEY_F6:          *scanCode = KEY_F16;       break;
-            case KEY_F7:          *scanCode = KEY_F17;       break;
-            case KEY_KP_Plus:     *scanCode = KEY_KP_DEC;    break;
-            case 0x2A:
-            case 0x36:
-	         return TRUE;
-            default:
-                 xf86MsgVerb(X_INFO, 4, "Unreported Prefix0 scancode: 0x%02x\n",
-		             *scanCode);
-                 *scanCode += 0x78;
-          }
-       break;
-       case KEY_Prefix1: 
-            pKbd->scanPrefix = (*scanCode == KEY_LCtrl) ? KEY_LCtrl : 0;
-            return TRUE;
-       case KEY_LCtrl:
-            pKbd->scanPrefix = 0;
-            if (*scanCode != KEY_NumLock)
-                return TRUE;
-            *scanCode = KEY_Pause;       /* pause */
-    }
-    return FALSE;
-}
diff --git a/hw/xfree86/os-support/shared/kbd.c b/hw/xfree86/os-support/shared/kbd.c
deleted file mode 100644
index dd6d77d..0000000
--- a/hw/xfree86/os-support/shared/kbd.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2001-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86OSKbd.h"
-
-_X_EXPORT Bool
-xf86OSKbdPreInit(InputInfoPtr pInfo)
-{
-    return FALSE;
-}
diff --git a/hw/xfree86/os-support/shared/std_kbdEv.c b/hw/xfree86/os-support/shared/std_kbdEv.c
deleted file mode 100644
index f56a5fd..0000000
--- a/hw/xfree86/os-support/shared/std_kbdEv.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * 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 Thomas Roell and David Dawes 
- * not be used in advertising or publicity pertaining to distribution of 
- * the software without specific, written prior permission.  Thomas Roell and
- * David Dawes makes no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
- * implied warranty.
- *
- * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO 
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR 
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-/* $XConsortium: std_kbdEv.c /main/4 1996/03/11 10:47:33 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-void
-xf86KbdEvents()
-{
-	unsigned char rBuf[64];
-	int nBytes, i;
-
-	if ((nBytes = read( xf86Info.consoleFd, (char *)rBuf, sizeof(rBuf)))
-	    > 0)
-	{
-		for (i = 0; i < nBytes; i++)
-			xf86PostKbdEvent(rBuf[i]);
-	}
-}
-
diff --git a/hw/xfree86/os-support/shared/sysv_kbd.c b/hw/xfree86/os-support/shared/sysv_kbd.c
deleted file mode 100644
index d7d7519..0000000
--- a/hw/xfree86/os-support/shared/sysv_kbd.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * 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 Thomas Roell and David Dawes 
- * not be used in advertising or publicity pertaining to distribution of 
- * the software without specific, written prior permission.  Thomas Roell and
- * David Dawes makes no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
- * implied warranty.
- *
- * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO 
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR 
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-/* $XConsortium: sysv_kbd.c /main/3 1996/02/21 17:53:59 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-int
-xf86GetKbdLeds()
-{
-	int leds;
-
-	ioctl(xf86Info.consoleFd, KDGETLED, &leds);
-	return(leds);
-}
-
-void
-xf86SetKbdRepeat(char rad)
-{
-#ifdef KDSETRAD
-	ioctl(xf86Info.consoleFd, KDSETRAD, rad);
-#endif
-}
-
-static int kbdtrans;
-static struct termio kbdtty;
-static char *kbdemap = NULL;
-
-void
-xf86KbdInit()
-{
-#ifdef KDGKBMODE
-	ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
-#endif
-	ioctl (xf86Info.consoleFd, TCGETA, &kbdtty);
-#if defined(E_TABSZ)
-	kbdemap = xalloc(E_TABSZ);
-	if (ioctl(xf86Info.consoleFd, LDGMAP, kbdemap) < 0)
-	{
-		xfree(kbdemap);
-		kbdemap = NULL;
-	}
-#endif
-}
-
-int
-xf86KbdOn()
-{
-	struct termio nTty;
-
-	ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
-	ioctl(xf86Info.consoleFd, LDNMAP, 0); /* disable mapping completely */
-	nTty = kbdtty;
-	nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
-	nTty.c_oflag = 0;
-	nTty.c_cflag = CREAD | CS8 | B9600;
-	nTty.c_lflag = 0;
-	nTty.c_cc[VTIME]=0;
-	nTty.c_cc[VMIN]=1;
-	ioctl(xf86Info.consoleFd, TCSETA, &nTty);
-	return(xf86Info.consoleFd);
-}
-
-int
-xf86KbdOff()
-{
-	if (kbdemap)
-	{
-		ioctl(xf86Info.consoleFd, LDSMAP, kbdemap);
-	}
-	ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans);
-	ioctl(xf86Info.consoleFd, TCSETA, &kbdtty);
-	return(xf86Info.consoleFd);
-}
diff --git a/hw/xfree86/os-support/solaris/Makefile.am b/hw/xfree86/os-support/solaris/Makefile.am
index 6b29b30..504e1a1 100644
--- a/hw/xfree86/os-support/solaris/Makefile.am
+++ b/hw/xfree86/os-support/solaris/Makefile.am
@@ -1,10 +1,8 @@
 if SOLARIS_USL_CONSOLE
 IO_SRC   = $(srcdir)/../sysv/sysv_io.c
-KBD_SRCS = $(srcdir)/../shared/sysv_kbd.c $(srcdir)/../shared/std_kbdEv.c
 VTSW_SRC = $(srcdir)/../shared/VTsw_usl.c
 else
-IO_SRC   = sun_io.c sun_kbd.h
-KBD_SRCS = sun_kbd.c sun_kbdEv.c sun_kbd.h
+IO_SRC   = sun_io.c
 VTSW_SRC = $(srcdir)/../shared/VTsw_noop.c
 endif
 
@@ -22,7 +20,7 @@ solaris-$(SOLARIS_INOUT_ARCH).il: solari
 	$(CPP) -P -DINLINE_ASM solaris-${SOLARIS_INOUT_ARCH}.S > $@
 
 noinst_LTLIBRARIES = libsolaris.la
-libsolaris_la_SOURCES = sun_bios.c sun_init.c $(IO_SRC) $(KBD_SRCS) \
+libsolaris_la_SOURCES = sun_bios.c sun_init.c $(IO_SRC) \
 	sun_mouse.c sun_vid.c $(AGP_SRC) \
 	$(srcdir)/../shared/libc_wrapper.c \
 	$(srcdir)/../shared/kmod_noop.c $(srcdir)/../shared/pm_noop.c \
diff --git a/hw/xfree86/os-support/solaris/sun_kbd.c b/hw/xfree86/os-support/solaris/sun_kbd.c
deleted file mode 100644
index 2cb1d13..0000000
--- a/hw/xfree86/os-support/solaris/sun_kbd.c
+++ /dev/null
@@ -1,660 +0,0 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * Copyright 1993 by David Dawes <dawes at XFree86.org>
- * Copyright 1999 by David Holland <davidh at iquest.net)
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the names of Thomas Roell, David Dawes, and David Holland not be used
- * in advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission.  Thomas Roell, David Dawes, and
- * David Holland make no representations about the suitability of this software
- * for any purpose.  It is provided "as is" without express or implied
- * warranty.
- *
- * THOMAS ROELL, DAVID DAWES, AND DAVID HOLLAND DISCLAIM ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS.  IN NO EVENT SHALL THOMAS ROELL, DAVID DAWES, OR DAVID HOLLAND
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-/* Copyright 2004-2005 Sun Microsystems, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, and/or sell copies of the Software, and to permit persons
- * to whom the Software is furnished to do so, provided that the above
- * copyright notice(s) and this permission notice appear in all copies of
- * the Software and that both the above copyright notice(s) and this
- * permission notice appear in supporting documentation.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
- * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
- * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
- * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- * 
- * Except as contained in this notice, the name of a copyright holder
- * shall not be used in advertising or otherwise to promote the sale, use
- * or other dealings in this Software without prior written authorization
- * of the copyright holder.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86OSKbd.h"
-#include "sun_kbd.h"
-
-/* Define to provide support for using /dev/audio to ring the bell instead of
-   the keyboard beeper */
-#define AUDIO_BELL
-
-#ifdef AUDIO_BELL
-#include <sys/audio.h>
-#include <sys/uio.h>
-#include <limits.h>
-#include <math.h>
-#include <poll.h>
-#endif
-
-/***************************************************************************
- * Common implementation of routines shared by "keyboard" driver in sun_io.c
- * and "kbd" driver (later on in this file)
- */
-
-#include <sys/stropts.h>
-#include <sys/vuid_event.h>
-#include <sys/kbd.h>
-
-_X_HIDDEN int
-sunKbdOpen(const char *devName, pointer options)
-{
-    int kbdFD;
-    const char *kbdPath = NULL;
-    const char *defaultKbd = "/dev/kbd";
-
-    if (options != NULL) {
-	kbdPath = xf86SetStrOption(options, "Device", NULL);
-    }
-    if (kbdPath == NULL) {
-        kbdPath = defaultKbd;
-    }
-
-    kbdFD = open(kbdPath, O_RDONLY | O_NONBLOCK);
-    
-    if (kbdFD == -1) {
-        xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", devName, kbdPath);
-    } else {
-	xf86MsgVerb(X_INFO, 3, "%s: Opened device \"%s\"\n", devName, kbdPath);
-    }
-    
-    if ((kbdPath != NULL) && (kbdPath != defaultKbd)) {
-	xfree(kbdPath);
-    }
-    return kbdFD;
-}
-
-
-/*
- * Save initial keyboard state.  This is called at the start of each server
- * generation.
- */
-
-_X_HIDDEN int
-sunKbdInit(sunKbdPrivPtr priv, int kbdFD, const char *devName, pointer options)
-{
-    int	ktype, klayout, i;
-    const char *ktype_name;
-
-    priv->kbdFD 	= kbdFD;
-    priv->devName 	= devName;
-    priv->otranslation 	= -1;
-    priv->odirect 	= -1;
-
-    if (options != NULL) {
-	priv->strmod = xf86SetStrOption(options, "StreamsModule", NULL);
-	priv->audioDevName = xf86SetStrOption(options, "BellDevice", NULL);
-
-	if (priv->audioDevName && (priv->audioDevName[0] == '\0')) {
-	    xfree(priv->audioDevName);
-	    priv->audioDevName = NULL;
-	}	
-    } else {
-	priv->strmod 		= NULL;
-	priv->audioDevName	= NULL;
-    }
-
-    if (priv->strmod) {
-	SYSCALL(i = ioctl(priv->kbdFD, I_PUSH, priv->strmod));
-	if (i < 0) {
-	    xf86Msg(X_ERROR,
-		    "%s: cannot push module '%s' onto keyboard device: %s\n",
-		    priv->devName, priv->strmod, strerror(errno));
-	}
-    }
-    
-    SYSCALL(i = ioctl(kbdFD, KIOCTYPE, &ktype));
-    if (i < 0) {
-	xf86Msg(X_ERROR, "%s: Unable to determine keyboard type: %s\n", 
-		devName, strerror(errno));
-	return BadImplementation;
-    }
-    
-    SYSCALL(i = ioctl(kbdFD, KIOCLAYOUT, &klayout));
-    if (i < 0) {	
-	xf86Msg(X_ERROR, "%s: Unable to determine keyboard layout: %s\n", 
-		devName, strerror(errno));
-	return BadImplementation;
-    }
-    
-    switch (ktype) {
-    case KB_SUN3:
-	ktype_name = "Sun Type 3"; break;
-    case KB_SUN4:
-	ktype_name = "Sun Type 4/5/6"; break;
-    case KB_USB:
-	ktype_name = "USB"; break;
-    case KB_PC:
-	ktype_name = "PC"; break;
-    default:
-	ktype_name = "Unknown"; break;
-    }
-
-    xf86Msg(X_PROBED, "%s: Keyboard type: %s (%d)\n",
-	    devName, ktype_name, ktype);
-    xf86Msg(X_PROBED, "%s: Keyboard layout: %d\n", devName, klayout);
-
-    priv->ktype 	= ktype;
-    priv->keyMap	= sunGetKbdMapping(ktype);
-    priv->audioState	= AB_INITIALIZING;
-    priv->oleds 	= sunKbdGetLeds(priv);
-
-    return Success;
-}
-
-_X_HIDDEN int
-sunKbdOn(sunKbdPrivPtr priv)
-{
-    int	ktrans, kdirect, i;
-
-    SYSCALL(i = ioctl(priv->kbdFD, KIOCGDIRECT, &kdirect));
-    if (i < 0) {
-	xf86Msg(X_ERROR, 
-		"%s: Unable to determine keyboard direct setting: %s\n", 
-		priv->devName, strerror(errno));
-	return BadImplementation;
-    }
-
-    priv->odirect = kdirect;
-    kdirect = 1;
-
-    SYSCALL(i = ioctl(priv->kbdFD, KIOCSDIRECT, &kdirect));
-    if (i < 0) {
-	xf86Msg(X_ERROR, "%s: Failed turning keyboard direct mode on: %s\n",
-			priv->devName, strerror(errno));
-	return BadImplementation;
-    }
-
-    /* Setup translation */
-
-    SYSCALL(i = ioctl(priv->kbdFD, KIOCGTRANS, &ktrans));
-    if (i < 0) {
-	xf86Msg(X_ERROR, 
-		"%s: Unable to determine keyboard translation mode: %s\n", 
-		priv->devName, strerror(errno));
-	return BadImplementation;
-    }
-
-    priv->otranslation = ktrans;
-    ktrans = TR_UNTRANS_EVENT;
-
-    SYSCALL(i = ioctl(priv->kbdFD, KIOCTRANS, &ktrans));
-    if (i < 0) {	
-	xf86Msg(X_ERROR, "%s: Failed setting keyboard translation mode: %s\n",
-			priv->devName, strerror(errno));
-	return BadImplementation;
-    }
-
-    return Success;
-}
-
-_X_HIDDEN int
-sunKbdOff(sunKbdPrivPtr priv)
-{
-    int i;
-
-    /* restore original state */
-    
-    sunKbdSetLeds(priv, priv->oleds);
-    
-    if (priv->otranslation != -1) {
-        SYSCALL(i = ioctl(priv->kbdFD, KIOCTRANS, &priv->otranslation));
-	if (i < 0) {
-	    xf86Msg(X_ERROR,
-		    "%s: Unable to restore keyboard translation mode: %s\n",
-		    priv->devName, strerror(errno));
-	    return BadImplementation;
-	}
-	priv->otranslation = -1;
-    }
-
-    if (priv->odirect != -1) {
-        SYSCALL(i = ioctl(priv->kbdFD, KIOCSDIRECT, &priv->odirect));
-	if (i < 0) {
-	    xf86Msg(X_ERROR,
-		    "%s: Unable to restore keyboard direct setting: %s\n",
-		    priv->devName, strerror(errno));
-	    return BadImplementation;
-	}
-	priv->odirect = -1;
-    }
-
-    if (priv->strmod) {
-	SYSCALL(i = ioctl(priv->kbdFD, I_POP, priv->strmod));
-	if (i < 0) {
-            xf86Msg(X_WARNING,
-		    "%s: cannot pop module '%s' off keyboard device: %s\n",
-		    priv->devName, priv->strmod, strerror(errno));
-	}
-    }
-
-    return Success;
-}
-
-#ifdef AUDIO_BELL
-
-/* Helper function to ring bell via audio device instead of keyboard beeper */
-
-#define BELL_RATE       48000   /* Samples per second */
-#define BELL_HZ         50      /* Fraction of a second i.e. 1/x */
-#define BELL_MS         (1000/BELL_HZ)  /* MS */
-#define BELL_SAMPLES    (BELL_RATE / BELL_HZ)
-#define BELL_MIN        3       /* Min # of repeats */
-
-static int
-sunKbdAudioBell(sunKbdPrivPtr priv, int loudness, int pitch, int duration)
-{
-    static short    samples[BELL_SAMPLES];
-    static short    silence[BELL_SAMPLES]; /* "The Sound of Silence" */
-    static int      lastFreq;
-    int             cnt;
-    int             i;
-    int		    written;
-    int             repeats;
-    int             freq;
-    audio_info_t    audioInfo;
-    struct iovec    iov[IOV_MAX];
-    int		    iovcnt;
-    double	    ampl, cyclen, phase;
-    int		    audioFD;
-
-    if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) {
-	return 0;
-    }
-
-    if ((priv == NULL) || (priv->audioDevName == NULL)) {
-	return -1;
-    }
-
-    if (priv->audioState == AB_INITIALIZING) {
-	priv->audioState = AB_NORMAL;
-	lastFreq = 0;
-	bzero(silence, sizeof(silence));
-    }
-    
-    audioFD = open(priv->audioDevName, O_WRONLY | O_NONBLOCK);
-    if (audioFD == -1) {
-	xf86Msg(X_ERROR, "%s: cannot open audio device \"%s\": %s\n",
-		priv->devName, priv->audioDevName, strerror(errno));
-	return -1;
-    } 
-
-    freq = pitch;
-    freq = min(freq, (BELL_RATE / 2) - 1);
-    freq = max(freq, 2 * BELL_HZ);
-
-    /*
-     * Ensure full waves per buffer
-     */
-    freq -= freq % BELL_HZ;
-
-    if (freq != lastFreq) {
-	lastFreq = freq;
-	ampl =  16384.0;
-
-	cyclen = (double) freq / (double) BELL_RATE;
-	phase = 0.0;
-
-	for (i = 0; i < BELL_SAMPLES; i++) {
-	    samples[i] = (short) (ampl * sin(2.0 * M_PI * phase));
-	    phase += cyclen;
-	    if (phase >= 1.0)
-		phase -= 1.0;
-	}
-    }
-    
-    repeats = (duration + (BELL_MS / 2)) / BELL_MS;
-    repeats = max(repeats, BELL_MIN);
-
-    loudness = max(0, loudness);
-    loudness = min(loudness, 100);
-
-#ifdef DEBUG
-    ErrorF("BELL : freq %d volume %d duration %d repeats %d\n",
-	   freq, loudness, duration, repeats);
-#endif
-
-    AUDIO_INITINFO(&audioInfo);
-    audioInfo.play.encoding = AUDIO_ENCODING_LINEAR;
-    audioInfo.play.sample_rate = BELL_RATE;
-    audioInfo.play.channels = 2;
-    audioInfo.play.precision = 16;
-    audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100);
-
-    if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){
-	xf86Msg(X_ERROR,
-		"%s: AUDIO_SETINFO failed on audio device \"%s\": %s\n",
-		priv->devName, priv->audioDevName, strerror(errno));
-	close(audioFD);
-	return -1;
-    }
-    
-    iovcnt = 0;
-    
-    for (cnt = 0; cnt <= repeats; cnt++) {
-	iov[iovcnt].iov_base = (char *) samples;
-	iov[iovcnt++].iov_len = sizeof(samples);
-	if (cnt == repeats) {
-	    /* Insert a bit of silence so that multiple beeps are distinct and
-	     * not compressed into a single tone.
-	     */
-	    iov[iovcnt].iov_base = (char *) silence;
-	    iov[iovcnt++].iov_len = sizeof(silence);
-	}	    
-	if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
-	    written = writev(audioFD, iov, iovcnt);
-
-	    if ((written < ((int)(sizeof(samples) * iovcnt)))) {
-		/* audio buffer was full! */
-
-		int naptime;
-
-		if (written == -1) {
-		    if (errno != EAGAIN) {
-			xf86Msg(X_ERROR,
-			       "%s: writev failed on audio device \"%s\": %s\n",
-				priv->devName, priv->audioDevName,
-				strerror(errno));
-			close(audioFD);
-			return -1;
-		    }
-		    i = iovcnt;
-		} else {
-		    i = ((sizeof(samples) * iovcnt) - written)
-			/ sizeof(samples);
-		}
-		cnt -= i;
-		
-		/* sleep a little to allow audio buffer to drain */
-		naptime = BELL_MS * i;
-		poll(NULL, 0, naptime);
-
-		i = ((sizeof(samples) * iovcnt) - written) % sizeof(samples);
-		iovcnt = 0;
-		if ((written != -1) && (i > 0)) {
-		    iov[iovcnt].iov_base = ((char *) samples) + i;
-		    iov[iovcnt++].iov_len = sizeof(samples) - i;
-		}
-	    } else {
-		iovcnt = 0;
-	    }
-	}
-    }
-    
-    close(audioFD);
-    return 0;
-}
-
-#endif /* AUDIO_BELL */
-
-_X_HIDDEN void
-sunKbdSoundBell(sunKbdPrivPtr priv, int loudness, int pitch, int duration)
-{
-    int	kbdCmd, i;
-
-    if (loudness && pitch)
-    {
-#ifdef AUDIO_BELL
-	if (priv->audioDevName != NULL) {
-	    if (sunKbdAudioBell(priv, loudness, pitch, duration) == 0) {
-		return;
-	    }
-	}
-#endif
-	
- 	kbdCmd = KBD_CMD_BELL;
-		
-	SYSCALL(i = ioctl (priv->kbdFD, KIOCCMD, &kbdCmd));
-	if (i < 0) {
-	    xf86Msg(X_ERROR, "%s: Failed to activate bell: %s\n",
-                priv->devName, strerror(errno));
-	}
-	
-	usleep(duration * loudness * 20);
-	
-	kbdCmd = KBD_CMD_NOBELL;
-	SYSCALL(i = ioctl (priv->kbdFD, KIOCCMD, &kbdCmd));
-	if (i < 0) {
-	     xf86Msg(X_ERROR, "%s: Failed to deactivate bell: %s\n",
-                priv->devName, strerror(errno));
-	}
-    }
-}
-
-_X_HIDDEN void
-sunKbdSetLeds(sunKbdPrivPtr priv, int leds)
-{
-    int i;
-	
-    SYSCALL(i = ioctl(priv->kbdFD, KIOCSLED, &leds));
-    if (i < 0) {
-	xf86Msg(X_ERROR, "%s: Failed to set keyboard LED's: %s\n",
-                priv->devName, strerror(errno));
-    }
-}
-
-_X_HIDDEN int
-sunKbdGetLeds(sunKbdPrivPtr priv)
-{
-    int i, leds = 0;
-
-    SYSCALL(i = ioctl(priv->kbdFD, KIOCGLED, &leds));
-    if (i < 0) {
-        xf86Msg(X_ERROR, "%s: Failed to get keyboard LED's: %s\n",
-                priv->devName, strerror(errno));
-    }
-    return leds;
-}
-
-/* ARGSUSED0 */
-_X_HIDDEN void
-sunKbdSetRepeat(sunKbdPrivPtr priv, char rad)
-{
-    /* Nothing to do */
-}
-
-/***************************************************************************
- * Routines called from "kbd" driver via proc vectors filled in by
- * xf86OSKbdPreInit().
- */
-
-
-static int
-KbdInit(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
-
-    return sunKbdInit(priv, pInfo->fd, pInfo->name, pInfo->options);
-}
-
-
-static int
-KbdOn(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
-
-    return sunKbdOn(priv);
-}
-
-static int
-KbdOff(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
-
-    return sunKbdOff(priv);
-}
-
-
-static void
-SoundKbdBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
-
-    sunKbdSoundBell(priv, loudness, pitch, duration);
-}
-
-static void
-SetKbdLeds(InputInfoPtr pInfo, int leds)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
-    int real_leds = sunKbdGetLeds(priv);
-
-    real_leds &= ~(LED_CAPS_LOCK | LED_NUM_LOCK | LED_SCROLL_LOCK | LED_COMPOSE);
-
-    if (leds & XLED1)  real_leds |= LED_CAPS_LOCK;
-    if (leds & XLED2)  real_leds |= LED_NUM_LOCK;
-    if (leds & XLED3)  real_leds |= LED_SCROLL_LOCK;
-    if (leds & XLED4)  real_leds |= LED_COMPOSE;
-    
-    sunKbdSetLeds(priv, real_leds);
-}
-
-static int
-GetKbdLeds(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
-    int leds = 0;
-    int real_leds = sunKbdGetLeds(priv);
-
-    if (real_leds & LED_CAPS_LOCK)	leds |= XLED1;
-    if (real_leds & LED_NUM_LOCK)	leds |= XLED2;
-    if (real_leds & LED_SCROLL_LOCK)	leds |= XLED3;
-    if (real_leds & LED_COMPOSE)	leds |= XLED4;
-	
-    return leds;
-}
-
-static void
-SetKbdRepeat(InputInfoPtr pInfo, char rad)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
-    
-    sunKbdSetRepeat(priv, rad);
-}
-
-static void
-KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
-    /* Should probably do something better here */
-    xf86KbdGetMapping(pKeySyms, pModMap);
-}
-
-static void
-ReadInput(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
-    Firm_event event[64];
-    int        nBytes, i;
-
-    /* I certainly hope its not possible to read partial events */
-
-    if ((nBytes = read(pInfo->fd, (char *)event, sizeof(event))) > 0)
-    {
-        for (i = 0; i < (nBytes / sizeof(Firm_event)); i++) {
-	    pKbd->PostEvent(pInfo, priv->keyMap[event[i].id],
-			    event[i].value == VKEY_DOWN ? TRUE : FALSE);
-	}
-    }
-}
-
-static Bool
-OpenKeyboard(InputInfoPtr pInfo)
-{
-    pInfo->fd = sunKbdOpen(pInfo->name, pInfo->options);
-
-    if (pInfo->fd >= 0) {
-	pInfo->read_input = ReadInput;
-	return TRUE;
-    } else {
-	return FALSE;
-    }
-}
-
-_X_EXPORT Bool
-xf86OSKbdPreInit(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = pInfo->private;
-
-    pKbd->KbdInit       = KbdInit;
-    pKbd->KbdOn         = KbdOn;
-    pKbd->KbdOff        = KbdOff;
-    pKbd->Bell          = SoundKbdBell;
-    pKbd->SetLeds       = SetKbdLeds;
-    pKbd->GetLeds       = GetKbdLeds;
-    pKbd->SetKbdRepeat  = SetKbdRepeat;
-    pKbd->KbdGetMapping = KbdGetMapping;
-
-    pKbd->RemapScanCode = NULL;
-    pKbd->GetSpecialKey = NULL;
-    pKbd->SpecialKey    = NULL;
-
-    pKbd->OpenKeyboard = OpenKeyboard;
-
-    pKbd->vtSwitchSupported = FALSE;
-    pKbd->CustomKeycodes = FALSE;
-
-    pKbd->private = xcalloc(sizeof(sunKbdPrivRec), 1);
-    if (pKbd->private == NULL) {
-       xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
-       return FALSE;
-    } else {
-	sunKbdPrivPtr priv = (sunKbdPrivPtr) pKbd->private;
-	priv->otranslation = -1;
-	priv->odirect = -1;
-    }
-
-    return TRUE;
-}
diff --git a/hw/xfree86/os-support/solaris/sun_kbd.h b/hw/xfree86/os-support/solaris/sun_kbd.h
deleted file mode 100644
index ed2824b..0000000
--- a/hw/xfree86/os-support/solaris/sun_kbd.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, and/or sell copies of the Software, and to permit persons
- * to whom the Software is furnished to do so, provided that the above
- * copyright notice(s) and this permission notice appear in all copies of
- * the Software and that both the above copyright notice(s) and this
- * permission notice appear in supporting documentation.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
- * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
- * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
- * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- * 
- * Except as contained in this notice, the name of a copyright holder
- * shall not be used in advertising or otherwise to promote the sale, use
- * or other dealings in this Software without prior written authorization
- * of the copyright holder.
- */
-
-#ifndef _XORG_SUN_KBD_H_
-#define _XORG_SUN_KBD_H_
-
-/*
- * Keyboard common implementation routines shared by "keyboard" driver
- * in sun_io.c and "kbd" driver in sun_kbd.c
- */
-
-typedef struct {
-    int			kbdFD;
-    const char *	devName;
-    int 		ktype;		/* Keyboard type from KIOCTYPE */
-    Bool		kbdActive;	/* Have we set kbd modes for X? */
-    int 		otranslation;	/* Original translation mode */
-    int 		odirect;	/* Original "direct" mode setting */
-    unsigned char	oleds;		/* Original LED state */
-    const char *	strmod;		/* Streams module pushed on kbd device */
-    const char *	audioDevName;	/* Audio device path to use for bell
-					   or NULL to use keyboard beeper */
-    enum {AB_INITIALIZING, AB_NORMAL} audioState;
-    const unsigned char *keyMap;
-} sunKbdPrivRec, *sunKbdPrivPtr;
-
-/* sun_kbd.c */
-extern int  sunKbdOpen	(const char *devName, pointer options);
-extern int  sunKbdInit	(sunKbdPrivPtr priv, int kbdFD,
-			 const char *devName, pointer options);
-extern int  sunKbdOn	(sunKbdPrivPtr priv);
-extern int  sunKbdOff	(sunKbdPrivPtr priv);
-    
-extern void sunKbdSoundBell 	(sunKbdPrivPtr priv,
-				 int loudness, int pitch, int duration);
-
-extern void sunKbdSetLeds 	(sunKbdPrivPtr priv, int leds);
-extern int  sunKbdGetLeds 	(sunKbdPrivPtr priv);
-extern void sunKbdSetRepeat 	(sunKbdPrivPtr priv, char rad);
-
-/* sun_kbdEv.c */
-#include <sys/vuid_event.h>
-extern void sunPostKbdEvent	(int ktype, Firm_event *event);
-
-extern const unsigned char *sunGetKbdMapping(int ktype);
-
-#endif
diff --git a/hw/xfree86/os-support/solaris/sun_kbdEv.c b/hw/xfree86/os-support/solaris/sun_kbdEv.c
deleted file mode 100644
index df8b6fa..0000000
--- a/hw/xfree86/os-support/solaris/sun_kbdEv.c
+++ /dev/null
@@ -1,854 +0,0 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- * 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 Thomas Roell and David Dawes not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission.  Thomas Roell and David Dawes make no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * THOMAS ROELL AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
- * IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR ANY SPECIAL,
- * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* [JCH-96/01/21] Extended std reverse map to four buttons. */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "sun_kbd.h"
-
-#ifdef XINPUT
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include "xf86Xinput.h"
-#else
-#include "inputstr.h"
-#endif
-
-#include <sys/kbd.h>
-#include "atKeynames.h"
-
-#ifdef XKB
-extern Bool noXkbExtension;
-#endif
-
-#define XE_POINTER  1
-#define XE_KEYBOARD 2
-
-#ifdef XINPUT
-#define ENQUEUE(ev, code, direction, dev_type) \
-  (ev)->u.u.detail = (code); \
-  (ev)->u.u.type   = (direction); \
-  xf86eqEnqueue((ev))
-#else
-#define ENQUEUE(ev, code, direction, dev_type) \
-  (ev)->u.u.detail = (code); \
-  (ev)->u.u.type   = (direction); \
-  mieqEnqueue((ev))
-#endif
-
-static void startautorepeat(long keycode);
-static CARD32 processautorepeat(OsTimerPtr timer, CARD32 now, pointer arg);
-
-static OsTimerPtr sunTimer = NULL;
-
-/* Map the Solaris keycodes to the "XFree86" keycodes. */
-/*
- * This doesn't seem right.  It probably needs to be dependent on a keyboard
- * type.
- */
-
-/* Additional Sun Japanese Keyboard Keys not defined in common/atKeynames.h */
-#define KEY_Kanji	0x82
-#define KEY_Execute	0x83
-
-static unsigned char map[256] = {
-#if defined(i386) || defined(__i386) || defined(__i386__) || defined(__x86)
-	KEY_NOTUSED,		/*   0 */
-	KEY_Tilde,		/*   1 */
-	KEY_1,			/*   2 */
-	KEY_2,			/*   3 */
-	KEY_3,			/*   4 */
-	KEY_4,			/*   5 */
-	KEY_5,			/*   6 */
-	KEY_6,			/*   7 */
-	KEY_7,			/*   8 */
-	KEY_8,			/*   9 */
-	KEY_9,			/*  10 */
-	KEY_0,			/*  11 */
-	KEY_Minus,		/*  12 */
-	KEY_Equal,		/*  13 */
-	0x7D, /*KEY_P_YEN*/	/*  14 */
-	KEY_BackSpace,		/*  15 */
-	KEY_Tab,		/*  16 */
-	KEY_Q,			/*  17 */
-	KEY_W,			/*  18 */
-	KEY_E,			/*  19 */
-	KEY_R,			/*  20 */
-	KEY_T,			/*  21 */
-	KEY_Y,			/*  22 */
-	KEY_U,			/*  23 */
-	KEY_I,			/*  24 */
-	KEY_O,			/*  25 */
-	KEY_P,			/*  26 */
-	KEY_LBrace,		/*  27 */
-	KEY_RBrace,		/*  28 */
-	KEY_BSlash,		/*  29 */
-	KEY_CapsLock,		/*  30 */
-	KEY_A,			/*  31 */
-	KEY_S,			/*  32 */
-	KEY_D,			/*  33 */
-	KEY_F,			/*  34 */
-	KEY_G,			/*  35 */
-	KEY_H,			/*  36 */
-	KEY_J,			/*  37 */
-	KEY_K,			/*  38 */
-	KEY_L,			/*  39 */
-	KEY_SemiColon,		/*  40 */
-	KEY_Quote,		/*  41 */
-	KEY_UNKNOWN,		/*  42 */
-	KEY_Enter,		/*  43 */
-	KEY_ShiftL,		/*  44 */
-	KEY_Less,		/*  45 */
-	KEY_Z,			/*  46 */
-	KEY_X,			/*  47 */
-	KEY_C,			/*  48 */
-	KEY_V,			/*  49 */
-	KEY_B,			/*  50 */
-	KEY_N,			/*  51 */
-	KEY_M,			/*  52 */
-	KEY_Comma,		/*  53 */
-	KEY_Period,		/*  54 */
-	KEY_Slash,		/*  55 */
-	KEY_BSlash2,		/*  56 */
-	KEY_ShiftR,		/*  57 */
-	KEY_LCtrl,		/*  58 */
-	KEY_LMeta,		/*  59 */
-	KEY_Alt,		/*  60 */
-	KEY_Space,		/*  61 */
-	KEY_AltLang,		/*  62 */
-	KEY_RMeta,		/*  63 */
-	KEY_RCtrl,		/*  64 */
-	KEY_Menu,		/*  65 */
-	KEY_UNKNOWN,		/*  66 */
-	KEY_UNKNOWN,		/*  67 */
-	KEY_UNKNOWN,		/*  68 */
-	KEY_UNKNOWN,		/*  69 */
-	KEY_UNKNOWN,		/*  70 */
-	KEY_UNKNOWN,		/*  71 */
-	KEY_UNKNOWN,		/*  72 */
-	KEY_UNKNOWN,		/*  73 */
-	KEY_UNKNOWN,		/*  74 */
-	KEY_Insert,		/*  75 */
-	KEY_Delete,		/*  76 */
-	KEY_UNKNOWN,		/*  77 */
-	KEY_UNKNOWN,		/*  78 */
-	KEY_Left,		/*  79 */
-	KEY_Home,		/*  80 */
-	KEY_End,		/*  81 */
-	KEY_UNKNOWN,		/*  82 */
-	KEY_Up,			/*  83 */
-	KEY_Down,		/*  84 */
-	KEY_PgUp,		/*  85 */
-	KEY_PgDown,		/*  86 */
-	KEY_UNKNOWN,		/*  87 */
-	KEY_UNKNOWN,		/*  88 */
-	KEY_Right,		/*  89 */
-	KEY_NumLock,		/*  90 */
-	KEY_KP_7,		/*  91 */
-	KEY_KP_4,		/*  92 */
-	KEY_KP_1,		/*  93 */
-	KEY_UNKNOWN,		/*  94 */
-	KEY_KP_Divide,		/*  95 */
-	KEY_KP_8,		/*  96 */
-	KEY_KP_5,		/*  97 */
-	KEY_KP_2,		/*  98 */
-	KEY_KP_0,		/*  99 */
-	KEY_KP_Multiply,	/* 100 */
-	KEY_KP_9,		/* 101 */
-	KEY_KP_6,		/* 102 */
-	KEY_KP_3,		/* 103 */
-	KEY_KP_Decimal,		/* 104 */
-	KEY_KP_Minus,		/* 105 */
-	KEY_KP_Plus,		/* 106 */
-	KEY_UNKNOWN,		/* 107 */
-	KEY_KP_Enter,		/* 108 */
-	KEY_UNKNOWN,		/* 109 */
-	KEY_Escape,		/* 110 */
-	KEY_UNKNOWN,		/* 111 */
-	KEY_F1,			/* 112 */
-	KEY_F2,			/* 113 */
-	KEY_F3,			/* 114 */
-	KEY_F4,			/* 115 */
-	KEY_F5,			/* 116 */
-	KEY_F6,			/* 117 */
-	KEY_F7,			/* 118 */
-	KEY_F8,			/* 119 */
-	KEY_F9,			/* 120 */
-	KEY_F10,		/* 121 */
-	KEY_F11,		/* 122 */
-	KEY_F12,		/* 123 */
-	KEY_Print,		/* 124 */
-	KEY_ScrollLock,		/* 125 */
-	KEY_Pause,		/* 126 */
-	KEY_UNKNOWN,		/* 127 */
-	KEY_UNKNOWN,		/* 128 */
-	KEY_UNKNOWN,		/* 129 */
-	KEY_UNKNOWN,		/* 130 */
-	KEY_NFER,		/* 131 */
-	KEY_XFER,		/* 132 */
-	KEY_HKTG,		/* 133 */
-	KEY_UNKNOWN,		/* 134 */
-#elif defined(sparc) || defined(__sparc__)
-	KEY_UNKNOWN,		/* 0x00 */
-	KEY_UNKNOWN,		/* 0x01 */
-	KEY_UNKNOWN,		/* 0x02 */
-	KEY_UNKNOWN,		/* 0x03 */
-	KEY_UNKNOWN,		/* 0x04 */
-	KEY_F1,			/* 0x05 */
-	KEY_F2,			/* 0x06 */
-	KEY_F10,		/* 0x07 */
-	KEY_F3,			/* 0x08 */
-	KEY_F11,		/* 0x09 */
-	KEY_F4,			/* 0x0A */
-	KEY_F12,		/* 0x0B */
-	KEY_F5,			/* 0x0C */
-	KEY_UNKNOWN,		/* 0x0D */
-	KEY_F6,			/* 0x0E */
-	KEY_UNKNOWN,		/* 0x0F */
-	KEY_F7,			/* 0x10 */
-	KEY_F8,			/* 0x11 */
-	KEY_F9,			/* 0x12 */
-	KEY_Alt,		/* 0x13 */
-	KEY_Up,			/* 0x14 */
-	KEY_Pause,		/* 0x15 */
-	KEY_SysReqest,		/* 0x16 */
-	KEY_ScrollLock,		/* 0x17 */
-	KEY_Left,		/* 0x18 */
-	KEY_UNKNOWN,		/* 0x19 */
-	KEY_UNKNOWN,		/* 0x1A */
-	KEY_Down,		/* 0x1B */
-	KEY_Right,		/* 0x1C */
-	KEY_Escape,		/* 0x1D */
-	KEY_1,			/* 0x1E */
-	KEY_2,			/* 0x1F */
-	KEY_3,			/* 0x20 */
-	KEY_4,			/* 0x21 */
-	KEY_5,			/* 0x22 */
-	KEY_6,			/* 0x23 */
-	KEY_7,			/* 0x24 */
-	KEY_8,			/* 0x25 */
-	KEY_9,			/* 0x26 */
-	KEY_0,			/* 0x27 */
-	KEY_Minus,		/* 0x28 */
-	KEY_Equal,		/* 0x29 */
-	KEY_Tilde,		/* 0x2A */
-	KEY_BackSpace,		/* 0x2B */
-	KEY_Insert,		/* 0x2C */
-	KEY_UNKNOWN,		/* 0x2D */
-	KEY_KP_Divide,		/* 0x2E */
-	KEY_KP_Multiply,	/* 0x2F */
-	KEY_UNKNOWN,		/* 0x30 */
-	KEY_UNKNOWN,		/* 0x31 */
-	KEY_KP_Decimal,		/* 0x32 */
-	KEY_UNKNOWN,		/* 0x33 */
-	KEY_Home,		/* 0x34 */
-	KEY_Tab,		/* 0x35 */
-	KEY_Q,			/* 0x36 */
-	KEY_W,			/* 0x37 */
-	KEY_E,			/* 0x38 */
-	KEY_R,			/* 0x39 */
-	KEY_T,			/* 0x3A */
-	KEY_Y,			/* 0x3B */
-	KEY_U,			/* 0x3C */
-	KEY_I,			/* 0x3D */
-	KEY_O,			/* 0x3E */
-	KEY_P,			/* 0x3F */
-	KEY_LBrace,		/* 0x40 */
-	KEY_RBrace,		/* 0x41 */
-	KEY_Delete,		/* 0x42 */
-	KEY_UNKNOWN,		/* 0x43 */
-	KEY_KP_7,		/* 0x44 */
-	KEY_KP_8,		/* 0x45 */
-	KEY_KP_9,		/* 0x46 */
-	KEY_KP_Minus,		/* 0x47 */
-	KEY_UNKNOWN,		/* 0x48 */
-	KEY_UNKNOWN,		/* 0x49 */
-	KEY_End,		/* 0x4A */
-	KEY_UNKNOWN,		/* 0x4B */
-	KEY_LCtrl,		/* 0x4C */
-	KEY_A,			/* 0x4D */
-	KEY_S,			/* 0x4E */
-	KEY_D,			/* 0x4F */
-	KEY_F,			/* 0x50 */
-	KEY_G,			/* 0x51 */
-	KEY_H,			/* 0x52 */
-	KEY_J,			/* 0x53 */
-	KEY_K,			/* 0x54 */
-	KEY_L,			/* 0x55 */
-	KEY_SemiColon,		/* 0x56 */
-	KEY_Quote,		/* 0x57 */
-	KEY_BSlash,		/* 0x58 */
-	KEY_Enter,		/* 0x59 */
-	KEY_KP_Enter,		/* 0x5A */
-	KEY_KP_4,		/* 0x5B */
-	KEY_KP_5,		/* 0x5C */
-	KEY_KP_6,		/* 0x5D */
-	KEY_KP_0,		/* 0x5E */
-	KEY_UNKNOWN,		/* 0x5F */
-	KEY_PgUp,		/* 0x60 */
-	KEY_UNKNOWN,		/* 0x61 */
-	KEY_NumLock,		/* 0x62 */
-	KEY_ShiftL,		/* 0x63 */
-	KEY_Z,			/* 0x64 */
-	KEY_X,			/* 0x65 */
-	KEY_C,			/* 0x66 */
-	KEY_V,			/* 0x67 */
-	KEY_B,			/* 0x68 */
-	KEY_N,			/* 0x69 */
-	KEY_M,			/* 0x6A */
-	KEY_Comma,		/* 0x6B */
-	KEY_Period,		/* 0x6C */
-	KEY_Slash,		/* 0x6D */
-	KEY_ShiftR,		/* 0x6E */
-	KEY_UNKNOWN,		/* 0x6F */
-	KEY_KP_1,		/* 0x70 */
-	KEY_KP_2,		/* 0x71 */
-	KEY_KP_3,		/* 0x72 */
-	KEY_UNKNOWN,		/* 0x73 */
-	KEY_UNKNOWN,		/* 0x74 */
-	KEY_UNKNOWN,		/* 0x75 */
-	KEY_UNKNOWN,		/* 0x76 */
-	KEY_CapsLock,		/* 0x77 */
-	KEY_LMeta,		/* 0x78 */
-	KEY_Space,		/* 0x79 */
-	KEY_RMeta,		/* 0x7A */
-	KEY_PgDown,		/* 0x7B */
-	KEY_UNKNOWN,		/* 0x7C */
-	KEY_KP_Plus,		/* 0x7D */
-	KEY_UNKNOWN,		/* 0x7E */
-	KEY_UNKNOWN,		/* 0x7F */
-#endif
-	/* The rest default to KEY_UNKNOWN */
-};
-
-#if defined(KB_USB)
-static unsigned char usbmap[256] = {
-/*
- * partially taken from ../bsd/bsd_KbdMap.c
- *
- * added keycodes for Sun special keys (left function keys, audio control)
- */
-	/* 0 */ KEY_NOTUSED,
-	/* 1 */ KEY_NOTUSED,
-	/* 2 */ KEY_NOTUSED,
-	/* 3 */ KEY_NOTUSED,
-	/* 4 */ KEY_A,		
-	/* 5 */ KEY_B,
-	/* 6 */ KEY_C,
-	/* 7 */ KEY_D,
-	/* 8 */ KEY_E,
-	/* 9 */ KEY_F,
-	/* 10 */ KEY_G,
-	/* 11 */ KEY_H,
-	/* 12 */ KEY_I,
-	/* 13 */ KEY_J,
-	/* 14 */ KEY_K,
-	/* 15 */ KEY_L,
-	/* 16 */ KEY_M,
-	/* 17 */ KEY_N,
-	/* 18 */ KEY_O,
-	/* 19 */ KEY_P,
-	/* 20 */ KEY_Q,
-	/* 21 */ KEY_R,
-	/* 22 */ KEY_S,
-	/* 23 */ KEY_T,
-	/* 24 */ KEY_U,
-	/* 25 */ KEY_V,
-	/* 26 */ KEY_W,
-	/* 27 */ KEY_X,
-	/* 28 */ KEY_Y,
-	/* 29 */ KEY_Z,
-	/* 30 */ KEY_1,		/* 1 !*/
-	/* 31 */ KEY_2,		/* 2 @ */
-	/* 32 */ KEY_3,		/* 3 # */
-	/* 33 */ KEY_4,		/* 4 $ */
-	/* 34 */ KEY_5,		/* 5 % */
-	/* 35 */ KEY_6,		/* 6 ^ */
-	/* 36 */ KEY_7,		/* 7 & */
-	/* 37 */ KEY_8,		/* 8 * */
-	/* 38 */ KEY_9,		/* 9 ( */
-	/* 39 */ KEY_0,		/* 0 ) */
-	/* 40 */ KEY_Enter,	/* Return  */
-	/* 41 */ KEY_Escape,	/* Escape */
-	/* 42 */ KEY_BackSpace,	/* Backspace Delete */
-	/* 43 */ KEY_Tab,	/* Tab */
-	/* 44 */ KEY_Space,	/* Space */
-	/* 45 */ KEY_Minus,	/* - _ */
-	/* 46 */ KEY_Equal,	/* = + */
-	/* 47 */ KEY_LBrace,	/* [ { */
-	/* 48 */ KEY_RBrace,	/* ] } */
-	/* 49 */ KEY_BSlash,	/* \ | */
-	/* 50 */ KEY_BSlash,	/* \ _ # ~ on some keyboards */
-	/* 51 */ KEY_SemiColon,	/* ; : */
-	/* 52 */ KEY_Quote,	/* ' " */
-	/* 53 */ KEY_Tilde,	/* ` ~ */
-	/* 54 */ KEY_Comma,	/* , <  */
-	/* 55 */ KEY_Period,	/* . > */
-	/* 56 */ KEY_Slash,	/* / ? */
-	/* 57 */ KEY_CapsLock,	/* Caps Lock */
-	/* 58 */ KEY_F1,		/* F1 */
-	/* 59 */ KEY_F2,		/* F2 */
-	/* 60 */ KEY_F3,		/* F3 */
-	/* 61 */ KEY_F4,		/* F4 */
-	/* 62 */ KEY_F5,		/* F5 */
-	/* 63 */ KEY_F6,		/* F6 */
-	/* 64 */ KEY_F7,		/* F7 */
-	/* 65 */ KEY_F8,		/* F8 */
-	/* 66 */ KEY_F9,		/* F9 */
-	/* 67 */ KEY_F10,	/* F10 */
-	/* 68 */ KEY_F11,	/* F11 */
-	/* 69 */ KEY_F12,	/* F12 */
-	/* 70 */ KEY_Print,	/* PrintScrn SysReq */
-	/* 71 */ KEY_ScrollLock,	/* Scroll Lock */
-	/* 72 */ KEY_Pause,	/* Pause Break */
-	/* 73 */ KEY_Insert,	/* Insert XXX  Help on some Mac Keyboards */
-	/* 74 */ KEY_Home,	/* Home */
-	/* 75 */ KEY_PgUp,	/* Page Up */
-	/* 76 */ KEY_Delete,	/* Delete */
-	/* 77 */ KEY_End,	/* End */
-	/* 78 */ KEY_PgDown,	/* Page Down */
-	/* 79 */ KEY_Right,	/* Right Arrow */
-	/* 80 */ KEY_Left,	/* Left Arrow */
-	/* 81 */ KEY_Down,	/* Down Arrow */
-	/* 82 */ KEY_Up,		/* Up Arrow */
-	/* 83 */ KEY_NumLock,	/* Num Lock */
-	/* 84 */ KEY_KP_Divide,	/* Keypad / */
-	/* 85 */ KEY_KP_Multiply, /* Keypad * */
-	/* 86 */ KEY_KP_Minus,	/* Keypad - */
-	/* 87 */ KEY_KP_Plus,	/* Keypad + */
-	/* 88 */ KEY_KP_Enter,	/* Keypad Enter */
-	/* 89 */ KEY_KP_1,	/* Keypad 1 End */
-	/* 90 */ KEY_KP_2,	/* Keypad 2 Down */
-	/* 91 */ KEY_KP_3,	/* Keypad 3 Pg Down */
-	/* 92 */ KEY_KP_4,	/* Keypad 4 Left  */
-	/* 93 */ KEY_KP_5,	/* Keypad 5 */
-	/* 94 */ KEY_KP_6,	/* Keypad 6 */
-	/* 95 */ KEY_KP_7,	/* Keypad 7 Home */
-	/* 96 */ KEY_KP_8,	/* Keypad 8 Up */
-	/* 97 */ KEY_KP_9,	/* KEypad 9 Pg Up */
-	/* 98 */ KEY_KP_0,	/* Keypad 0 Ins */
-	/* 99 */ KEY_KP_Decimal,	/* Keypad . Del */
-	/* 100 */ KEY_Less,	/* < > on some keyboards */
-	/* 101 */ KEY_Menu,	/* Menu */
-	/* 102 */ KEY_Power,	/* Sun: Power */
-	/* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */
-	/* 104 */ KEY_NOTUSED,
-	/* 105 */ KEY_NOTUSED,
-	/* 106 */ KEY_NOTUSED,
-	/* 107 */ KEY_NOTUSED,
-	/* 108 */ KEY_NOTUSED,
-	/* 109 */ KEY_NOTUSED,
-	/* 110 */ KEY_NOTUSED,
-	/* 111 */ KEY_NOTUSED,
-	/* 112 */ KEY_NOTUSED,
-	/* 113 */ KEY_NOTUSED,
-	/* 114 */ KEY_NOTUSED,
-	/* 115 */ KEY_NOTUSED,
-	/* 116 */ KEY_L7,	/* Sun: Open */
-	/* 117 */ KEY_Help,	/* Sun: Help */
-	/* 118 */ KEY_L3,	/* Sun: Props */
-	/* 119 */ KEY_L5,	/* Sun: Front */
-	/* 120 */ KEY_L1,	/* Sun: Stop */
-	/* 121 */ KEY_L2,	/* Sun: Again */
-	/* 122 */ KEY_L4,	/* Sun: Undo */
-	/* 123 */ KEY_L10,	/* Sun: Cut */
-	/* 124 */ KEY_L6,	/* Sun: Copy */
-	/* 125 */ KEY_L8,	/* Sun: Paste */
-	/* 126 */ KEY_L9,	/* Sun: Find */
-	/* 127 */ KEY_Mute,	/* Sun: AudioMute */
-	/* 128 */ KEY_AudioRaise,	/* Sun: AudioRaise */
-	/* 129 */ KEY_AudioLower,	/* Sun: AudioLower */
-	/* 130 */ KEY_NOTUSED,
-	/* 131 */ KEY_NOTUSED,
-	/* 132 */ KEY_NOTUSED,
-	/* 133 */ KEY_NOTUSED,
-	/* 134 */ KEY_NOTUSED,
-	/* 135 */ KEY_BSlash2,	/* Sun Japanese Kbd: Backslash / Underscore */
-	/* 136 */ KEY_XFER,	/* Sun Japanese Kbd: Henkan Mode */
-	/* 137 */ KEY_Yen,	/* Sun Japanese Kbd: Yen / Brokenbar */
-	/* 138 */ KEY_Kanji,	/* Sun Japanese Kbd: Kanji */
-	/* 139 */ KEY_Execute,	/* Sun Japanese Kbd: Execute */
-	/* 140 */ KEY_NOTUSED,
-	/* 141 */ KEY_NOTUSED,
-	/* 142 */ KEY_NOTUSED,
-	/* 143 */ KEY_NOTUSED,
-	/* 144 */ KEY_NOTUSED,
-	/* 145 */ KEY_NOTUSED,
-	/* 146 */ KEY_NOTUSED,
-	/* 147 */ KEY_NOTUSED,
-	/* 148 */ KEY_NOTUSED,
-	/* 149 */ KEY_NOTUSED,
-	/* 150 */ KEY_NOTUSED,
-	/* 151 */ KEY_NOTUSED,
-	/* 152 */ KEY_NOTUSED,
-	/* 153 */ KEY_NOTUSED,
-	/* 154 */ KEY_NOTUSED,
-	/* 155 */ KEY_NOTUSED,
-	/* 156 */ KEY_NOTUSED,
-	/* 157 */ KEY_NOTUSED,
-	/* 158 */ KEY_NOTUSED,
-	/* 159 */ KEY_NOTUSED,
-	/* 160 */ KEY_NOTUSED,
-	/* 161 */ KEY_NOTUSED,
-	/* 162 */ KEY_NOTUSED,
-	/* 163 */ KEY_NOTUSED,
-	/* 164 */ KEY_NOTUSED,
-	/* 165 */ KEY_NOTUSED,
-	/* 166 */ KEY_NOTUSED,
-	/* 167 */ KEY_NOTUSED,
-	/* 168 */ KEY_NOTUSED,
-	/* 169 */ KEY_NOTUSED,
-	/* 170 */ KEY_NOTUSED,
-	/* 171 */ KEY_NOTUSED,
-	/* 172 */ KEY_NOTUSED,
-	/* 173 */ KEY_NOTUSED,
-	/* 174 */ KEY_NOTUSED,
-	/* 175 */ KEY_NOTUSED,
-	/* 176 */ KEY_NOTUSED,
-	/* 177 */ KEY_NOTUSED,
-	/* 178 */ KEY_NOTUSED,
-	/* 179 */ KEY_NOTUSED,
-	/* 180 */ KEY_NOTUSED,
-	/* 181 */ KEY_NOTUSED,
-	/* 182 */ KEY_NOTUSED,
-	/* 183 */ KEY_NOTUSED,
-	/* 184 */ KEY_NOTUSED,
-	/* 185 */ KEY_NOTUSED,
-	/* 186 */ KEY_NOTUSED,
-	/* 187 */ KEY_NOTUSED,
-	/* 188 */ KEY_NOTUSED,
-	/* 189 */ KEY_NOTUSED,
-	/* 190 */ KEY_NOTUSED,
-	/* 191 */ KEY_NOTUSED,
-	/* 192 */ KEY_NOTUSED,
-	/* 193 */ KEY_NOTUSED,
-	/* 194 */ KEY_NOTUSED,
-	/* 195 */ KEY_NOTUSED,
-	/* 196 */ KEY_NOTUSED,
-	/* 197 */ KEY_NOTUSED,
-	/* 198 */ KEY_NOTUSED,
-	/* 199 */ KEY_NOTUSED,
-	/* 200 */ KEY_NOTUSED,
-	/* 201 */ KEY_NOTUSED,
-	/* 202 */ KEY_NOTUSED,
-	/* 203 */ KEY_NOTUSED,
-	/* 204 */ KEY_NOTUSED,
-	/* 205 */ KEY_NOTUSED,
-	/* 206 */ KEY_NOTUSED,
-	/* 207 */ KEY_NOTUSED,
-	/* 208 */ KEY_NOTUSED,
-	/* 209 */ KEY_NOTUSED,
-	/* 210 */ KEY_NOTUSED,
-	/* 211 */ KEY_NOTUSED,
-	/* 212 */ KEY_NOTUSED,
-	/* 213 */ KEY_NOTUSED,
-	/* 214 */ KEY_NOTUSED,
-	/* 215 */ KEY_NOTUSED,
-	/* 216 */ KEY_NOTUSED,
-	/* 217 */ KEY_NOTUSED,
-	/* 218 */ KEY_NOTUSED,
-	/* 219 */ KEY_NOTUSED,
-	/* 220 */ KEY_NOTUSED,
-	/* 221 */ KEY_NOTUSED,
-	/* 222 */ KEY_NOTUSED,
-	/* 223 */ KEY_NOTUSED,
-	/* 224 */ KEY_LCtrl,	/* Left Control */
-	/* 225 */ KEY_ShiftL,	/* Left Shift */
-	/* 226 */ KEY_Alt,	/* Left Alt */
-	/* 227 */ KEY_LMeta,	/* Left Meta */
-	/* 228 */ KEY_RCtrl,	/* Right Control */
-	/* 229 */ KEY_ShiftR,	/* Right Shift */
-	/* 230 */ KEY_AltLang,	/* Right Alt, AKA AltGr */
-	/* 231 */ KEY_RMeta,	/* Right Meta */
-};
-
-#endif /* KB_USB */
-
-_X_HIDDEN const unsigned char *
-sunGetKbdMapping(int ktype) {
-#if defined(KB_USB)
-    if (ktype == KB_USB)
-        return usbmap;
-    else
-#endif
-        return map;
-}
-
-
-/*
- * sunPostKbdEvent --
- *	Translate the raw hardware Firm_event into an XEvent, and tell DIX
- *	about it. KeyCode preprocessing and so on is done ...
- *
- * Most of the Solaris stuff has whacked Panix/PC98 support in the
- * interests of simplicity - DWH 8/30/99
- */
-
-_X_HIDDEN void
-sunPostKbdEvent(int sun_ktype, Firm_event *event)
-{
-    Bool        down;
-    KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key;
-    Bool        updateLeds = FALSE;
-    xEvent      kevent;
-    KeySym      *keysym;
-    int         keycode;
-    static int  lockkeys = 0;
-
-    /* Give down a value */
-    if (event->value == VKEY_DOWN)
-	down = TRUE;
-    else
-	down = FALSE;
-
-
-#if defined(KB_USB)
-    if(sun_ktype == KB_USB)
-	keycode = usbmap[event->id];
-    else
-#endif
-	keycode = map[event->id];
-
-    /*
-     * and now get some special keysequences
-     */
-    
-#ifdef XKB
-    if (((xf86Info.ddxSpecialKeys == SKWhenNeeded) &&
-	 (!xf86Info.ActionKeyBindingsSet)) ||
-	noXkbExtension || (xf86Info.ddxSpecialKeys == SKAlways))
-#endif
-    {
-	if (!(ModifierDown(ShiftMask)) &&
-	    ((ModifierDown(ControlMask | AltMask)) ||
-	     (ModifierDown(ControlMask | AltLangMask))))
-	{
-	    switch (keycode) {
-	    /*
-	     * The idea here is to pass the scancode down to a list of 
-	     * registered routines.  There should be some standard conventions
-	     * for processing certain keys.
-	     */
-	    case KEY_BackSpace:
-		xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
-		break;
-		
-	    /*
-	     * Check grabs
-	     */
-	    case KEY_KP_Divide:
-		xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL);
-		break;
-	    case KEY_KP_Multiply:
-		xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL);
-		break;
-		
-	    /*
-	     * Video mode switches
-	     */
-	    case KEY_KP_Minus:   /* Keypad - */
-		if (down) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL);
-		if (!xf86Info.dontZoom) return;
-		break;
-		
-	    case KEY_KP_Plus:   /* Keypad + */
-		if (down) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL);
-		if (!xf86Info.dontZoom) return;
-		break;
-	    }
-	}
-    }
-
-    /*
-     * Now map the scancodes to real X-keycodes ...
-     */
-    if (keycode == KEY_NOTUSED) {
-	xf86MsgVerb(X_INFO, 0,
-	    "raw code %d mapped to KEY_NOTUSED -- please report\n", event->id);
-	return;
-    }
-    if (keycode == KEY_UNKNOWN) {
-	xf86MsgVerb(X_INFO, 0,
-	    "raw code %d mapped to KEY_UNKNOWN -- please report\n", event->id);
-	return;
-    }
-    keycode += MIN_KEYCODE;
-    keysym = keyc->curKeySyms.map +
-	     (keyc->curKeySyms.mapWidth *
-	      (keycode - keyc->curKeySyms.minKeyCode));
-
-#ifdef XKB
-    if (noXkbExtension)
-#endif
-    {
-	/*
-	 * Toggle lock keys.
-	 */
-#define CAPSFLAG 0x01
-#define NUMFLAG 0x02
-#define SCROLLFLAG 0x04
-#define MODEFLAG 0x08
-
-	if (down) {
-	    /*
-	     * Handle the KeyPresses of the lock keys.
-	     */
-
-	    switch (keysym[0]) {
-
-	    case XK_Caps_Lock:
-		if (lockkeys & CAPSFLAG) {
-		    lockkeys &= ~CAPSFLAG;
-		    return;
-		}
-		lockkeys |= CAPSFLAG;
-		updateLeds = TRUE;
-		xf86Info.capsLock = down;
-		break;
-
-	    case XK_Num_Lock:
-		if (lockkeys & NUMFLAG) {
-		    lockkeys &= ~NUMFLAG;
-		    return;
-		}
-		lockkeys |= NUMFLAG;
-		updateLeds = TRUE;
-		xf86Info.numLock = down;
-		break;
-
-	    case XK_Scroll_Lock:
-		if (lockkeys & SCROLLFLAG) {
-		    lockkeys &= ~SCROLLFLAG;
-		    return;
-		}
-		lockkeys |= SCROLLFLAG;
-		updateLeds = TRUE;
-		xf86Info.scrollLock = down;
-		break;
-	    }
-	} else {
-	    /*
-	     * Handle the releases of the lock keys.
-	     */
-
-	    switch (keysym[0]) {
-
-	    case XK_Caps_Lock:
-		if (lockkeys & CAPSFLAG)
-		    return;
-		updateLeds = TRUE;
-		xf86Info.capsLock = down;
-		break;
-
-	    case XK_Num_Lock:
-		if (lockkeys & NUMFLAG)
-		    return;
-		updateLeds = TRUE;
-		xf86Info.numLock = down;
-		break;
-
-	    case XK_Scroll_Lock:
-		if (lockkeys & SCROLLFLAG)
-		    return;
-		updateLeds = TRUE;
-		xf86Info.scrollLock = down;
-		break;
-	    }
-	}
-
-  	if (updateLeds)
-	    xf86KbdLeds();
-
-	/*
-	 * If this keycode is not a modifier key, and its down initiate the
-	 * autorepeate sequence.  (Only necessary if not using XKB).
-	 *
-	 * If its not down, then reset the timer.
-	 */
-	if (!keyc->modifierMap[keycode]) {
-	    if (down) {
-		startautorepeat(keycode);
-	    } else {
-		TimerFree(sunTimer);
-		sunTimer = NULL;
-	    }
-  	}
-    }
-
-    xf86Info.lastEventTime =
-	kevent.u.keyButtonPointer.time =
-	    GetTimeInMillis();
-
-    /*
-     * And now send these prefixes ...
-     * NOTE: There cannot be multiple Mode_Switch keys !!!!
-     */
-
-    ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
-}
-
-
-
-/*
- * Autorepeat stuff
- */
-
-void
-startautorepeat(long keycode)
-{
-    sunTimer = TimerSet(sunTimer, 		/* Timer */
-			0, 			/* Flags */
-			xf86Info.kbdDelay,	/* millis */
-			processautorepeat,	/* callback */
-			(pointer) keycode);	/* arg for timer */
-}
-
-CARD32
-processautorepeat(OsTimerPtr timer, CARD32 now, pointer arg)
-{
-    xEvent kevent;
-    int    keycode;
-
-    keycode = (long)arg;
-
-    xf86Info.lastEventTime =
-	kevent.u.keyButtonPointer.time =
-	    GetTimeInMillis();
-
-    /*
-     * Repeat a key by faking a KeyRelease, and a KeyPress event in rapid
-     * succession
-     */
-
-    ENQUEUE(&kevent, keycode,  KeyRelease, XE_KEYBOARD);
-    ENQUEUE(&kevent, keycode,  KeyPress, XE_KEYBOARD);
-
-    /* And return the appropriate value so we get rescheduled */
-    return xf86Info.kbdRate;
-}
diff --git a/hw/xfree86/os-support/sysv/sysv_io.c b/hw/xfree86/os-support/sysv/sysv_io.c
deleted file mode 100644
index d6c8ca0..0000000
--- a/hw/xfree86/os-support/sysv/sysv_io.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
- * 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 Thomas Roell and David Dawes 
- * not be used in advertising or publicity pertaining to distribution of 
- * the software without specific, written prior permission.  Thomas Roell and
- * David Dawes makes no representations about the suitability of this 
- * software for any purpose.  It is provided "as is" without express or 
- * implied warranty.
- *
- * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO 
- * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
- * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE FOR 
- * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER 
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF 
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-/* $XConsortium: sysv_io.c /main/8 1996/10/19 18:08:06 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-_X_EXPORT void
-xf86SoundKbdBell(int loudness, int pitch, int duration)
-{
-	if (loudness && pitch)
-	{
-#ifdef KDMKTONE
-		/*
-		 * If we have KDMKTONE use it to avoid putting the server
-		 * to sleep
-		 */
-		ioctl(xf86Info.consoleFd, KDMKTONE,
-		      ((1193190 / pitch) & 0xffff) |
-		      (((unsigned long)duration *
-			loudness / 50) << 16));
-#else
-		ioctl(xf86Info.consoleFd, KIOCSOUND, 1193180 / pitch);
-		usleep(xf86Info.bell_duration * loudness * 20);
-		ioctl(xf86Info.consoleFd, KIOCSOUND, 0);
-#endif
-	}
-}
-
-void
-xf86SetKbdLeds(int leds)
-{
-#ifdef KBIO_SETMODE
-	ioctl(xf86Info.consoleFd, KBIO_SETMODE, KBM_AT);
-	ioctl(xf86Info.consoleFd, KDSETLED, leds);
-	ioctl(xf86Info.consoleFd, KBIO_SETMODE, KBM_XT);
-#endif
-}
-
-#include "xf86OSKbd.h"
-
-_X_EXPORT Bool
-xf86OSKbdPreInit(InputInfoPtr pInfo)
-{
-    return FALSE;
-}
diff --git a/hw/xfree86/os-support/usl/Makefile.am b/hw/xfree86/os-support/usl/Makefile.am
index 5143b24..58f9760 100644
--- a/hw/xfree86/os-support/usl/Makefile.am
+++ b/hw/xfree86/os-support/usl/Makefile.am
@@ -2,9 +2,6 @@ EXTRA_DIST = \
 	usl_init.c \
 	usl_io.c \
 	usl_iop.c \
-	usl_kbd.c \
-	usl_kbd.h \
-	usl_KbdMap.c \
 	usl_mouse.c \
 	usl_video.c \
 	usl_vtsw.c \
diff --git a/hw/xfree86/os-support/usl/usl_KbdMap.c b/hw/xfree86/os-support/usl/usl_KbdMap.c
deleted file mode 100644
index 76032e6..0000000
--- a/hw/xfree86/os-support/usl/usl_KbdMap.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/* $XdotOrg$ */
-/*
- * Copyright 2005 by J. Kean Johnston <jkj at sco.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name J. Kean Johnston not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  J. Kean Johnston makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
- * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-
-/*
- * Based on xf86KbdMap.c, which is
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
- */
-
-#include "X.h"
-#include "Xmd.h"
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "xf86Xinput.h"
-#include "xf86OSKbd.h"
-#include "atKeynames.h"
-#include "xf86Keymap.h"
-
-#include "usl_kbd.h"
-
-#define KD_GET_ENTRY(i,n) \
-  eascii_to_x[((priv->keymap.key[i].spcl << (n+1)) & 0x100) + priv->keymap.key[i].map[n]]
-
-/*
- * NOTE: Not all possible remappable symbols are remapped. There are two main
- *       reasons:
- *                 a) The mapping between scancode and SYSV/386 - symboltable
- *                    is inconsistent between different versions and has some
- *                    BIG mistakes.
- *                 b) In X-Windows there is a difference between numpad-keys
- *                    and normal keys. SYSV/386 uses for both kinds of keys
- *                    the same symbol.
- *
- *       Thus only the alpha keypad and the function keys are translated.
- *       Also CapsLock, NumLock, ScrollLock, Shift, Control & Alt.
- */
-
-static unsigned char remap[128] = {
-     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
-  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
-  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
-  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
-  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
-  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
-  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
-  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
-  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
-     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
-  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
-     0,    0, 0x69, 0x65,    0,    0,    0,    0,   /* 0x70 - 0x77 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
-};
-
-static KeySym eascii_to_x[512] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	XK_Ccedilla,	XK_udiaeresis,	XK_eacute,	XK_acircumflex,
-	XK_adiaeresis,	XK_agrave,	XK_aring,	XK_ccedilla,
-	XK_ecircumflex,	XK_ediaeresis,	XK_egrave,	XK_idiaeresis,
-	XK_icircumflex,	XK_igrave,	XK_Adiaeresis,	XK_Aring,
-	XK_Eacute,	XK_ae,		XK_AE,		XK_ocircumflex,
-	XK_odiaeresis,	XK_ograve,	XK_ucircumflex,	XK_ugrave,
-	XK_ydiaeresis,	XK_Odiaeresis,	XK_Udiaeresis,	XK_cent,
-	XK_sterling,	XK_yen,		XK_paragraph,	XK_section,
-	XK_aacute,	XK_iacute,	XK_oacute,	XK_uacute,
-	XK_ntilde,	XK_Ntilde,	XK_ordfeminine,	XK_masculine,
-	XK_questiondown,XK_hyphen,	XK_notsign,	XK_onehalf,
-	XK_onequarter,	XK_exclamdown,	XK_guillemotleft,XK_guillemotright,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Greek_alpha,	XK_ssharp,	XK_Greek_GAMMA,	XK_Greek_pi,
-	XK_Greek_SIGMA,	XK_Greek_sigma,	XK_mu,	        XK_Greek_tau,
-	XK_Greek_PHI,	XK_Greek_THETA,	XK_Greek_OMEGA,	XK_Greek_delta,
-	XK_infinity,	XK_Ooblique,	XK_Greek_epsilon, XK_intersection,
-	XK_identical,	XK_plusminus,	XK_greaterthanequal, XK_lessthanequal,
-	XK_topintegral,	XK_botintegral,	XK_division,	XK_similarequal,
-	XK_degree,	NoSymbol,	NoSymbol,	XK_radical,
-	XK_Greek_eta,	XK_twosuperior,	XK_periodcentered, NoSymbol,
-
-	/* 
-	 * special marked entries (256 + x)
-	 */
-
-	NoSymbol,	NoSymbol,	XK_Shift_L,	XK_Shift_R,
-	XK_Caps_Lock,	XK_Num_Lock,	XK_Scroll_Lock,	XK_Alt_L,
-	NoSymbol,	XK_Control_L,	XK_Alt_L,	XK_Alt_R,
-	XK_Control_L,	XK_Control_R,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_F1,
-	XK_F2,		XK_F3,		XK_F4,		XK_F5,
-	XK_F6,		XK_F7,		XK_F8,		XK_F9,
-	XK_F10,		XK_F11,		XK_F12,		NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-      };
-
-/*
- * KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-void
-KbdGetMapping (InputInfoPtr pInfo, KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  USLKbdPrivPtr priv = (USLKbdPrivPtr) pKbd->private;
-  KeySym *k;
-  int i;
-  KeySym *pMap = map;
-
-  for (i = 0; i < priv->keymap.n_keys && i < NUM_KEYCODES; i++) {
-    if (remap[i]) {
-      k = pMap + (remap[i] << 2);
-	
-      k[0] = KD_GET_ENTRY(i,0);             /* non-shifed */
-      k[1] = KD_GET_ENTRY(i,1);	      /* shifted */
-      k[2] = KD_GET_ENTRY(i,4);	      /* alt */
-      k[3] = KD_GET_ENTRY(i,5);	      /* alt - shifted */
-
-      if (k[3] == k[2]) k[3] = NoSymbol;
-      if (k[2] == k[1]) k[2] = NoSymbol;
-      if (k[1] == k[0]) k[1] = NoSymbol;
-      if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
-    }
-  }
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = pMap, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4) {
-    
-    switch(*k) {
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-    }
-  }
-
-  pKeySyms->map        = pMap;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  pKeySyms->maxKeyCode = MAX_KEYCODE;
-}
diff --git a/hw/xfree86/os-support/usl/usl_kbd.c b/hw/xfree86/os-support/usl/usl_kbd.c
deleted file mode 100644
index d6e6af2..0000000
--- a/hw/xfree86/os-support/usl/usl_kbd.c
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * Copyright 2005 by Kean Johnston <jkj at sco.com>
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name Kean Johnston not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Kean Johnston makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
- * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
- * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- */
-/* $XConsortium$ */
-
-/*
- * Based on sco_io.c which is
- * (C) Copyright 2003 Kean Johnston <jkj at sco.com>
- *
- * Based on lnx_kbd.c which is 
- * Copyright (c) 2002 by The XFree86 Project, Inc.
- *
- * Based on the code from lnx_io.c which is
- * Copyright 1992 by Orest Zborowski <obz at Kodak.com>
- * Copyright 1993 by David Dawes <dawes at xfree86.org>
- */
-
-#define NEED_EVENTS
-#include "X.h"
-
-#include "compiler.h"
-
-#define _NEED_SYSI86
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86OSpriv.h"
-#include "xf86_OSlib.h"
-
-#include "xf86Xinput.h"
-#include "xf86OSKbd.h"
-#include "atKeynames.h"
-#include "usl_kbd.h"
-#include "usl_xqueue.h"
-
-#include <sys/param.h>
-
-static KbdProtocolRec protocols[] = {
-  { "standard", PROT_STD },
-  { "Xqueue", PROT_XQUEUE },
-  { NULL, PROT_UNKNOWN_KBD }
-};
-
-extern Bool VTSwitchEnabled;
-#ifdef USE_VT_SYSREQ
-extern Bool VTSysreqToggle;
-#endif
-
-static void
-SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
-{
-  if (loudness && pitch) {
-    ioctl(pInfo->fd, KIOCSOUND, 1193180 / pitch);
-    usleep(duration * loudness * 20);
-    ioctl(pInfo->fd, KIOCSOUND, 0);
-  }
-}
-
-static void
-SetKbdLeds(InputInfoPtr pInfo, int leds)
-{
-  int real_leds = 0;
-
-  if (leds & XLED1)
-    real_leds |= LED_CAP;
-  if (leds & XLED2)
-    real_leds |= LED_NUM;
-  if (leds & XLED3)
-    real_leds |= LED_SCR;
-  ioctl(pInfo->fd, KDSETLED, real_leds);
-}
-
-static int
-GetKbdLeds(InputInfoPtr pInfo)
-{
-    int real_leds, leds = 0;
-
-    ioctl(pInfo->fd, KDGETLED, &real_leds);
-
-    if (real_leds & LED_CAP) leds |= XLED1;
-    if (real_leds & LED_NUM) leds |= XLED2;
-    if (real_leds & LED_SCR) leds |= XLED3;
-
-    return(leds);
-}
-
-static void
-SetKbdRepeat(InputInfoPtr pInfo, char rad)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  int i;
-  int value = 0x7f;     /* Maximum delay with slowest rate */
-  int delay = 250;      /* Default delay */
-  int rate = 300;       /* Default repeat rate */
-
-  static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
-                               133, 120, 109, 100, 92, 86, 80, 75, 67,
-                               60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
-                               25, 23, 21, 20 };
-#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
-
-  static int valid_delays[] = { 250, 500, 750, 1000 };
-#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
-
-  if (pKbd->rate >= 0) 
-    rate = pKbd->rate * 10;
-  if (pKbd->delay >= 0)
-    delay = pKbd->delay;
-
-  for (i = 0; i < RATE_COUNT; i++)
-    if (rate >= valid_rates[i]) {
-      value &= 0x60;
-      value |= i;
-      break;
-    }
-
-  for (i = 0; i < DELAY_COUNT; i++)
-    if (delay <= valid_delays[i]) {
-      value &= 0x1f;
-      value |= i << 5;
-      break;
-    }
-
-  ioctl (pInfo->fd, KDSETTYPEMATICS, value);
-}
-
-static int
-KbdInit(InputInfoPtr pInfo, int what)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  USLKbdPrivPtr priv = (USLKbdPrivPtr) pKbd->private;
-
-  if (pKbd->isConsole) {
-    if (ioctl (pInfo->fd, KDGKBMODE, &priv->orig_kbm) < 0) {
-      xf86Msg (X_ERROR, "KbdInit: Could not determine keyboard mode\n");
-      return !Success;
-    }
-
-    /*
-     * We need to get the original keyboard map and NUL out the lock
-     * modifiers. This prevents the kernel from messing with
-     * the keyboard LED's. We restore the original map when we exit.
-     * Note that we also have to eliminate screen switch sequences
-     * else the VT manager will switch for us, which we don't want.
-     * For example, lets say you had changed the VT manager to switch
-     * on Alt-Fx instead of Ctrl-Alt-Fx. This means that while inside
-     * X, you cant use, for example, Alt-F4, which is a pain in the
-     * fundamental when you're using CDE-like thingies.
-     */
-    if (ioctl (pInfo->fd, GIO_KEYMAP, &priv->keymap) < 0) {
-      xf86Msg (X_ERROR, "KbdInit: Failed to get keyboard map (%s)\n",
-        strerror(errno));
-      return !Success;
-    }
-    if (ioctl (pInfo->fd, GIO_KEYMAP, &priv->noledmap) < 0) {
-      xf86Msg (X_ERROR, "KbdInit: Failed to get keyboard map (%s)\n",
-        strerror(errno));
-      return !Success;
-    } else {
-      int i, j;
-
-      for (i = 0; i < priv->noledmap.n_keys; i++) {
-        for (j = 0; j < NUM_STATES; j++) {
-          if (IS_SPECKEY(&priv->noledmap, i, j) &&
-            ((priv->noledmap.key[i].map[j] == K_CLK) ||
-             (priv->noledmap.key[i].map[j] == K_NLK) ||
-             (priv->noledmap.key[i].map[j] == K_SLK) ||
-             (priv->noledmap.key[i].map[j] == K_FRCNEXT) ||
-             (priv->noledmap.key[i].map[j] == K_FRCPREV) ||
-             ((priv->noledmap.key[i].map[j] >=  K_VTF) &&
-	      (priv->noledmap.key[i].map[j] <= K_VTL)) )) {
-            priv->noledmap.key[i].map[j] = K_NOP;
-          }
-        }
-      }
-    }
-
-    if (ioctl (pInfo->fd, TCGETA, &priv->kbdtty) < 0) {
-      xf86Msg (X_ERROR, "KbdInit: Failed to get terminal modes (%s)\n",
-        strerror(errno));
-      return !Success;
-    }
-  } /* End of if we are on a console */
-
-  return Success;
-}
-
-static int
-KbdOn(InputInfoPtr pInfo, int what)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  USLKbdPrivPtr priv = (USLKbdPrivPtr) pKbd->private;
-  struct termio newtio;
-
-  if (pKbd->isConsole) {
-    /*
-     * Use the calculated keyboard map that does not have active
-     * LED lock handling (we track LEDs ourselves).
-     */
-    ioctl (pInfo->fd, PIO_KEYMAP, &priv->noledmap);
-
-#ifdef NOTYET
-    newtio = priv->kbdtty;     /* structure copy */
-    newtio.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
-    newtio.c_oflag = 0;
-    newtio.c_cflag = CREAD | CS8 | B9600;
-    newtio.c_lflag = 0;
-    newtio.c_cc[VTIME]=0;
-    newtio.c_cc[VMIN]=1;
-    ioctl(pInfo->fd, TCSETA, &newtio);
-
-    if (priv->xq == 0)
-      ioctl (pInfo->fd, KDSKBMODE, K_RAW);
-    else
-#endif
-      XqKbdOnOff (pInfo, 1);
-  }
-
-  return Success;
-}
-
-static int
-KbdOff(InputInfoPtr pInfo, int what)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  USLKbdPrivPtr priv = (USLKbdPrivPtr) pKbd->private;
-
-  if (pKbd->isConsole) {
-    /* Revert back to original translate scancode mode */
-#ifdef NOTYET
-    if (priv->xq == 0)
-      ioctl (pInfo->fd, KDSKBMODE, priv->orig_kbm);
-    else
-#endif
-      XqKbdOnOff (pInfo, 0);
-
-    ioctl (pInfo->fd, PIO_KEYMAP, &priv->keymap);
-    ioctl(pInfo->fd, TCSETA, &priv->kbdtty);
-  }
-
-  return Success;
-}
-
-#define ModifierSet(k) ((modifiers & (k)) == (k))
-
-static Bool
-SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-
-  if(!pKbd->vtSwitchSupported)
-    return FALSE;
-
-  if ((!ModifierSet(ShiftMask)) && ((ModifierSet(ControlMask | AltMask)) ||
-      (ModifierSet(ControlMask | AltLangMask)))) {
-    if (VTSwitchEnabled && !xf86Info.vtSysreq) {
-      switch (key) {
-        case KEY_F1:
-        case KEY_F2:
-        case KEY_F3:
-        case KEY_F4:
-        case KEY_F5:
-        case KEY_F6:
-        case KEY_F7:
-        case KEY_F8:
-        case KEY_F9:
-        case KEY_F10:
-          if (down) {
-	    int sts = key - KEY_F1;
-	    if (sts != xf86Info.vtno) {
-	      ioctl(pInfo->fd, VT_SWITCH, sts);
-	    }
-            return TRUE;
-          }
-        case KEY_F11:
-        case KEY_F12:
-          if (down) {
-	    int sts = key - KEY_F11 + 10;
-	    if (sts != xf86Info.vtno) {
-	      ioctl(pInfo->fd, VT_SWITCH, sts);
-	    }
-            return TRUE;
-          }
-      }
-    }
-  }
-#ifdef USE_VT_SYSREQ
-  if (VTSwitchEnabled && xf86Info.vtSysreq) {
-    switch (key) {
-      case KEY_F1:
-      case KEY_F2:
-      case KEY_F3:
-      case KEY_F4:
-      case KEY_F5:
-      case KEY_F6:
-      case KEY_F7:
-      case KEY_F8:
-      case KEY_F9:
-      case KEY_F10:
-        if (VTSysreqToggle && down) {
-          ioctl(pInfo->fd, VT_ACTIVATE, key - KEY_F1);
-          VTSysreqToggle = FALSE;
-          return TRUE;
-        }
-        break;
-      case KEY_F11:
-      case KEY_F12:
-        if (VTSysreqToggle && down) {
-          ioctl(pInfo->fd, VT_ACTIVATE, key - KEY_F11 + 10);
-          VTSysreqToggle = FALSE;
-          return TRUE;
-        }
-        break;
-        /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
-      case KEY_Alt:
-      case KEY_AltLang:
-        break;
-      case KEY_SysReqest:
-        if (!(ModifierSet(ShiftMask) || ModifierSet(ControlMask))) {
-          if ((ModifierSet(AltMask) || ModifierSet(AltLangMask)) && down)
-            VTSysreqToggle = TRUE;
-        }
-        break;
-      default:
-        /*
-         * We only land here when Alt-SysReq is followed by a
-         * non-switching key.
-         */
-        if (VTSysreqToggle)
-          VTSysreqToggle = FALSE;
-    }
-  }
-#endif /* USE_VT_SYSREQ */
-  return FALSE;
-} 
-
-#ifdef NOTYET
-static void
-stdReadInput(InputInfoPtr pInfo)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  unsigned char rBuf[64];
-  int nBytes, i;
-
-  if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) {
-    for (i = 0; i < nBytes; i++) {
-      pKbd->PostEvent(pInfo, rBuf[i] & 0x7f, rBuf[i] & 0x80 ? FALSE : TRUE);
-    }
-  }
-}
-#endif
-
-static Bool
-OpenKeyboard(InputInfoPtr pInfo)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  USLKbdPrivPtr priv = (USLKbdPrivPtr) pKbd->private;
-  int i;
-  KbdProtocolId prot = PROT_UNKNOWN_KBD;
-  char *s;
-
-  s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
-  for (i = 0; protocols[i].name; i++) {
-    if (xf86NameCmp(s, protocols[i].name) == 0) {
-      prot = protocols[i].id;
-      break;
-    }
-  }
-
-  switch (prot) {
-    case PROT_STD:
-#ifdef NOTYET
-      pInfo->read_input = stdReadInput;
-      priv->xq = 0;
-      break;
-#endif
-    case PROT_XQUEUE:
-      pInfo->read_input = NULL;	/* Handled by the XQUEUE signal handler */
-      priv->xq = 1;
-      break;
-    default:
-      xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
-      xfree(s);
-      return FALSE;
-  }
-
-  xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s);
-  xfree(s);
-
-  s = xf86SetStrOption(pInfo->options, "Device", NULL);
-  if (s == NULL) {
-    pInfo->fd = xf86Info.consoleFd;
-    pKbd->isConsole = TRUE;
-  } else {
-    pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
-    if (pInfo->fd == -1) {
-      xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
-      xfree(s);
-      return FALSE;
-    }
-    pKbd->isConsole = FALSE;
-    xfree(s);
-  }
-
-  if (pKbd->isConsole)
-    pKbd->vtSwitchSupported = TRUE;
-
-  return TRUE;
-}
-
-_X_EXPORT Bool
-xf86OSKbdPreInit(InputInfoPtr pInfo)
-{
-  KbdDevPtr pKbd = pInfo->private;
-
-  pKbd->KbdInit       = KbdInit;
-  pKbd->KbdOn         = KbdOn;
-  pKbd->KbdOff        = KbdOff;
-  pKbd->Bell          = SoundBell;
-  pKbd->SetLeds       = SetKbdLeds;
-  pKbd->GetLeds       = GetKbdLeds;
-  pKbd->SetKbdRepeat  = SetKbdRepeat;
-  pKbd->KbdGetMapping = KbdGetMapping;
-  pKbd->SpecialKey    = SpecialKey;
-  pKbd->OpenKeyboard  = OpenKeyboard;
-
-  pKbd->GetSpecialKey = NULL;
-  pKbd->RemapScanCode = ATScancode;
-  pKbd->vtSwitchSupported = FALSE;
-
-  pKbd->private = xcalloc(sizeof(USLKbdPrivRec), 1);
-  if (pKbd->private == NULL) {
-    xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
-    return FALSE;
-  }
-
-  return TRUE;
-}
diff --git a/hw/xfree86/os-support/usl/usl_kbd.h b/hw/xfree86/os-support/usl/usl_kbd.h
deleted file mode 100644
index 990c13c..0000000
--- a/hw/xfree86/os-support/usl/usl_kbd.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* $XdotOrg$ */
-#ifndef SCO_KBD_HDR
-#define SCO_KBD_HDR
-
-typedef struct {
-  int orig_kbm;
-  struct termio kbdtty;
-  keymap_t keymap, noledmap;
-  int xq;
-} USLKbdPrivRec, *USLKbdPrivPtr;
-
-extern void KbdGetMapping(InputInfoPtr pInfo, KeySymsPtr pKeySyms,
-  CARD8 *pModMap);
-#endif /* SCO_KBD_HDR */
diff --git a/hw/xfree86/os-support/usl/usl_xqueue.c b/hw/xfree86/os-support/usl/usl_xqueue.c
index c00d374..1615353 100644
--- a/hw/xfree86/os-support/usl/usl_xqueue.c
+++ b/hw/xfree86/os-support/usl/usl_xqueue.c
@@ -33,7 +33,6 @@
 #include "xf86_OSlib.h"
 #include "xf86Xinput.h"
 #include "xf86OSmouse.h"
-#include "xf86OSKbd.h"
 #include "usl_xqueue.h"
 
 #ifdef XKB
diff --git a/hw/xfree86/os-support/xf86OSKbd.h b/hw/xfree86/os-support/xf86OSKbd.h
deleted file mode 100644
index 4ab722c..0000000
--- a/hw/xfree86/os-support/xf86OSKbd.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (c) 2002-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- *
- * Author: Ivan Pascal.
- */
-
-#include "xf86Xinput.h"
-
-Bool ATScancode(InputInfoPtr pInfo, int *scanCode);
-
-/* Public interface to OS-specific keyboard support. */
-
-typedef	int	(*KbdInitProc)(InputInfoPtr pInfo, int what);
-typedef	int	(*KbdOnProc)(InputInfoPtr pInfo, int what);
-typedef	int	(*KbdOffProc)(InputInfoPtr pInfo, int what);
-typedef	void	(*BellProc)(InputInfoPtr pInfo,
-                            int loudness, int pitch, int duration);
-typedef	void	(*SetLedsProc)(InputInfoPtr pInfo, int leds);
-typedef	int	(*GetLedsProc)(InputInfoPtr pInfo);
-typedef	void	(*SetKbdRepeatProc)(InputInfoPtr pInfo, char rad);
-typedef	void	(*KbdGetMappingProc)(InputInfoPtr pInfo,
-                                     KeySymsPtr pKeySyms, CARD8* pModMap);
-typedef	int	(*GetSpecialKeyProc)(InputInfoPtr pInfo, int scanCode);
-typedef	Bool	(*SpecialKeyProc)(InputInfoPtr pInfo,
-                                     int key, Bool down, int modifiers);
-typedef	int	(*RemapScanCodeProc)(InputInfoPtr pInfo, int *scanCode);
-typedef	Bool	(*OpenKeyboardProc)(InputInfoPtr pInfo);
-typedef	void	(*PostEventProc)(InputInfoPtr pInfo,
-                                 unsigned int key, Bool down);
-typedef struct {
-    int                 begin;
-    int                 end;
-    unsigned char       *map;
-} TransMapRec, *TransMapPtr;
-
-typedef struct {
-    KbdInitProc		KbdInit;
-    KbdOnProc		KbdOn;
-    KbdOffProc		KbdOff;
-    BellProc		Bell;
-    SetLedsProc		SetLeds;
-    GetLedsProc		GetLeds;
-    SetKbdRepeatProc	SetKbdRepeat;
-    KbdGetMappingProc	KbdGetMapping;
-    RemapScanCodeProc	RemapScanCode;
-    GetSpecialKeyProc	GetSpecialKey;
-    SpecialKeyProc	SpecialKey;
-
-    OpenKeyboardProc	OpenKeyboard;
-    PostEventProc	PostEvent;
-
-    int			rate;
-    int			delay;
-    int			bell_pitch;
-    int			bell_duration;
-    Bool		autoRepeat;
-    unsigned long	leds;
-    unsigned long	xledsMask;
-    unsigned long	keyLeds;
-    int			scanPrefix;
-    Bool		vtSwitchSupported;
-    Bool		CustomKeycodes;
-    Bool		noXkb;
-    Bool		isConsole;
-    TransMapPtr         scancodeMap;
-    TransMapPtr         specialMap;
-
-    /* os specific */
-    pointer		private;
-    int			kbdType;
-    int			consType;
-    int			wsKbdType;
-    Bool		sunKbd;
-    Bool		Panix106;
-
-} KbdDevRec, *KbdDevPtr;
-
-typedef enum {
-    PROT_STD,
-    PROT_XQUEUE,
-    PROT_WSCONS,
-    PROT_USB,
-    PROT_UNKNOWN_KBD
-} KbdProtocolId;
-
-typedef struct {
-    const char		*name;
-    KbdProtocolId	id;
-} KbdProtocolRec;
-
-Bool xf86OSKbdPreInit(InputInfoPtr pInfo);
-
-/* Adjust this when the kbd interface changes. */
-
-/*
- * History:
- *
- *  1.0.0 - Initial version.
- */
-
-#define OS_KBD_VERSION_MAJOR 1
-#define OS_KBD_VERSION_MINOR 0
-#define OS_KBD_VERSION_PATCH 0
-
-#define OS_KBD_VERSION_CURRENT						\
-	BUILTIN_INTERFACE_VERSION_NUMERIC(OS_KBD_VERSION_MAJOR,		\
-					  OS_KBD_VERSION_MINOR,		\
-					  OS_KBD_VERSION_PATCH)
-
diff-tree 9525c2709ea3245c6518d4c3b5a0a4afff37181d (from 6d8d4abaaacf08140b673472d985117d448a62e7)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 10 20:29:57 2006 +0300

    configure.ac: fix xephyr conditionals
    Fix Xephyr build conditions, allowing it to actually be disabled.

diff --git a/configure.ac b/configure.ac
index 62a3848..c5c96f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1509,8 +1509,9 @@ if test "$KDRIVE" = yes; then
 
     PKG_CHECK_MODULES(XEPHYR, x11 xext xfont xau xdmcp, [xephyr="yes"], [xephyr="no"])
     if test "x$XEPHYR" = xauto; then
-       XEPHYR=xephyr
+        XEPHYR=$xephyr
     fi
+
     # Xephyr needs nanosleep() which is in librt on Solaris
     AC_CHECK_FUNC([nanosleep], [],
         AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
@@ -1556,7 +1557,7 @@ AM_CONDITIONAL(H3600_TS, false)
 AM_CONDITIONAL(KDRIVEVESA, [test "x$KDRIVEVESA" = xyes])
 AM_CONDITIONAL(KDRIVEFBDEV, [test "x$XFBDEV" = xyes])
 AM_CONDITIONAL(XSDLSERVER, [test x"$XSDL" = xyes])
-AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$xephyr" = xyes])
+AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes])
 AM_CONDITIONAL(BUILD_KDRIVEFBDEVLIB, [test "x$KDRIVE" = xyes && test "x$KDRIVEFBDEVLIB" = xyes])
 AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
 
diff-tree 6d8d4abaaacf08140b673472d985117d448a62e7 (from cec284f2b3e948deb9e56a1a8519fddf693ab952)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 10 20:28:06 2006 +0300

    configure.ac: allow conditional building of XF86{DGA,Misc,VidMode}
    Allow conditional building of the above three extensions, defaulting to
    auto.

diff --git a/configure.ac b/configure.ac
index dffa472..62a3848 100644
--- a/configure.ac
+++ b/configure.ac
@@ -404,7 +404,7 @@ AC_ARG_ENABLE(xtrap,          AS_HELP_ST
 AC_ARG_ENABLE(record,         AS_HELP_STRING([--disable-record], [Build Record extension (default: enabled)]), [RECORD=$enableval], [RECORD=yes])
 AC_ARG_ENABLE(xv,             AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
 AC_ARG_ENABLE(xvmc,           AS_HELP_STRING([--disable-xvmc], [Build XvMC extension (default: enabled)]), [XVMC=$enableval], [XVMC=yes])
-AC_ARG_ENABLE(dga,            AS_HELP_STRING([--disable-dga], [Build DGA extension (default: enabled)]), [DGA=$enableval], [DGA=yes])
+AC_ARG_ENABLE(dga,            AS_HELP_STRING([--disable-dga], [Build DGA extension (default: auto)]), [DGA=$enableval], [DGA=auto])
 AC_ARG_ENABLE(screensaver,    AS_HELP_STRING([--disable-screensaver], [Build ScreenSaver extension (default: enabled)]), [SCREENSAVER=$enableval], [SCREENSAVER=yes])
 AC_ARG_ENABLE(xdmcp,          AS_HELP_STRING([--disable-xdmcp], [Build XDMCP extension (default: auto)]), [XDMCP=$enableval], [XDMCP=auto])
 AC_ARG_ENABLE(xdm-auth-1,     AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto])
@@ -413,8 +413,8 @@ AC_ARG_ENABLE(aiglx,          AS_HELP_ST
 AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]), [GLX_USE_TLS=$enableval], [GLX_USE_TLS=no])
 AC_ARG_ENABLE(dri,            AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
 AC_ARG_ENABLE(xinerama,	      AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
-AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: enabled)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=yes])
-AC_ARG_ENABLE(xf86misc,       AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: enabled)]), [XF86MISC=$enableval], [XF86MISC=yes])
+AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
+AC_ARG_ENABLE(xf86misc,       AS_HELP_STRING([--disable-xf86misc], [Build XF86Misc extension (default: auto)]), [XF86MISC=$enableval], [XF86MISC=auto])
 AC_ARG_ENABLE(xcsecurity,     AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: enabled)]), [XCSECURITY=$enableval], [XCSECURITY=yes])
 AC_ARG_ENABLE(xevie,          AS_HELP_STRING([--disable-xevie], [Build XEvIE extension (default: enabled)]), [XEVIE=$enableval], [XEVIE=yes])
 AC_ARG_ENABLE(appgroup,       AS_HELP_STRING([--disable-appgroup], [Build XC-APPGROUP extension (default: enabled)]), [APPGROUP=$enableval], [APPGROUP=yes])
@@ -544,10 +544,6 @@ if test "x$XVMC" = xyes; then
 	AC_DEFINE(XvMCExtension, 1, [Build XvMC extension])
 fi
 
-AM_CONDITIONAL(DGA, [test "x$DGA" = xyes])
-if test "x$DGA" = xyes; then
-	AC_DEFINE(DGA, 1, [Support DGA extension])
-fi
 
 AM_CONDITIONAL(COMPOSITE, [test "x$COMPOSITE" = xyes])
 if test "x$COMPOSITE" = xyes; then
@@ -696,14 +692,6 @@ if test "x$DPMSExtension" = xyes; then
 	AC_DEFINE(DPMSExtension, 1, [Support DPMS extension])
 fi
 
-if test "x$XF86VIDMODE" = xyes; then
-	AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension])
-fi
-
-if test "x$XF86MISC" = xyes; then
-	AC_DEFINE(XF86MISC, 1, [Support XFree86 miscellaneous extensions])
-fi
-
 if test "x$XPRINT" = xauto; then
 	PKG_CHECK_MODULES([XPRINTPROTO], [printproto], [XPRINT=yes], [XPRINT=no])
 fi
@@ -1069,13 +1057,36 @@ if test "x$XORG" = xyes -o "x$XGL" = xye
 	XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
 	XORG_LIBS="$COMPOSITE_LIB $MI_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB $OS_LIB"
 
-        AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension])
-        AC_DEFINE(XF86MISC, 1, [Support XFree86 miscellaneous extensions])
+	if test "x$DGA" = xauto; then
+		PKG_CHECK_MODULES(DGA, dgaproto, [DGA=yes], [DGA=no])
+	fi
+	if test "x$DGA" = xyes; then
+		XORG_MODULES="$XORG_MODULES xf86dgaproto"
+		AC_DEFINE(DGA, 1, [Support DGA extension])
+		AC_DEFINE(XFreeXDGA, 1, [Build XDGA support])
+	fi
+
+	if test "x$XF86MISC" = xauto; then
+		PKG_CHECK_MODULES(XF86MISC, xf86miscproto, [XF86MISC=yes], [XF86MISC=no])
+	fi
+	if test "x$XF86MISC" = xyes; then
+		XORG_MODULES="$XORG_MODULES xf86miscproto"
+		AC_DEFINE(XF86MISC, 1, [Support XFree86 miscellaneous extensions])
+	fi
 
-        XORG_MODULES="xf86miscproto xf86vidmodeproto xf86dgaproto"
-        PKG_CHECK_MODULES(XORG_MODULES, [$XORG_MODULES])
-        XORG_CFLAGS="$XORG_CFLAGS $XORG_MODULES_CFLAGS"
-        XORG_LIBS="$XORG_LIBS $XORG_MODULES_LIBS"
+	if test "x$XF86VIDMOE" = xauto; then
+		PKG_CHECK_MODULES(XF86VIDMODE, xf86vidmode, [DGA=yes], [DGA=no])
+	fi
+	if test "x$XF86VIDMODE" = xyes; then
+		XORG_MODULES="$XORG_MODULES xf86vidmodeproto"
+		AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension])
+	fi
+
+	if test -n "$XORG_MODULES"; then
+	        PKG_CHECK_MODULES(XORG_MODULES, [$XORG_MODULES])
+	        XORG_CFLAGS="$XORG_CFLAGS $XORG_MODULES_CFLAGS"
+	        XORG_LIBS="$XORG_LIBS $XORG_MODULES_LIBS"
+	fi
 
 dnl Check to see if dlopen is in default libraries (like Solaris, which
 dnl has it in libc), or if libdl is needed to get it.
@@ -1312,6 +1323,7 @@ AM_CONDITIONAL([SOLARIS_ASM_INLINE], [te
 AM_CONDITIONAL(MFB, [test "x$XORG" = xyes])
 AM_CONDITIONAL(CFB, [test "x$XORG" = xyes])
 AM_CONDITIONAL(AFB, [test "x$XORG" = xyes])
+AM_CONDITIONAL(DGA, [test "x$DGA" = xyes])
 
 dnl Xprint DDX
 
@@ -1572,7 +1584,6 @@ AC_DEFINE_DIR(XKM_OUTPUT_DIR, XKBOUTPUT,
 AC_SUBST(XKB_COMPILED_DIR)
 
 dnl and the rest of these are generic, so they're in config.h
-AC_DEFINE(XFreeXDGA, 1, [Build XDGA support])
 AC_DEFINE(XResExtension, 1, [Build XRes extension])
 
 dnl CYGWIN does not define fd_set if _POSIX_SOURCE is defined
diff-tree cec284f2b3e948deb9e56a1a8519fddf693ab952 (from 45bce556e8665412b9f6e89f88ed5bedb41de1ba)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 10 18:03:58 2006 +0300

    kdrive: properly ifdef composite enabling

diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 05102ab..1cc2932 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -1396,9 +1396,11 @@ KdInitOutput (ScreenInfo    *pScreenInfo
     KdCardInfo	    *card;
     KdScreenInfo    *screen;
 
+#ifdef COMPOSITE
     /* kind of a hack: we want Composite enabled, but it's disabled per
      * default. */
     noCompositeExtension = FALSE;
+#endif
     
     if (!kdCardInfo)
     {
diff-tree 45bce556e8665412b9f6e89f88ed5bedb41de1ba (from 172d45b9b75f95c997d1e9358040eead496e2a06)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 10 18:02:47 2006 +0300

    GetMaximumEventsNum: be more conservative
    Be slightly more conservative in our maximum event count if we're using
    XKB (and thus don't need to count the extra repeat events).

diff --git a/dix/events.c b/dix/events.c
index 171e277..f1e2fd8 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4672,7 +4672,14 @@ int
 GetMaximumEventsNum() {
     /* Two base events -- core and device, plus valuator events.  Multiply
      * by two if we're doing key repeats. */
-    return 2 * (2 + MAX_VALUATOR_EVENTS);
+    int ret = 2 + MAX_VALUATOR_EVENTS;
+
+#ifdef XKB
+    if (noXkbExtension)
+#endif
+        ret *= 2;
+
+    return ret;
 }
 
 /**
diff-tree 172d45b9b75f95c997d1e9358040eead496e2a06 (from parents)
Merge: 3832a3d7db0f3b5d7167e3b3b5ea6d6b3d96351a db82e12fac5eaa16a39fc1bd0bc31ad95089dc95
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 10 14:14:54 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree 3832a3d7db0f3b5d7167e3b3b5ea6d6b3d96351a (from 9f188416bb6b4837d4c3f8773053d5eee0ff0ee1)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 10 14:13:51 2006 +0300

    GKVE: don't repeat modifiers when using XKB
    Make sure we don't ever repeat modifiers (previously was repeating when
    using XKB); only do explicit KP/KR repeats in the non-XKB case.  XKB will
    take care of repeating when we're using it.

diff --git a/dix/events.c b/dix/events.c
index 5706aac..171e277 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4737,20 +4737,22 @@ int GetKeyboardValuatorEvents(xEvent *ev
      * FIXME: In theory, if you're repeating with two keyboards,
      *        you could get unbalanced events here. */
     if (type == KeyPress &&
-        ((pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
-#ifdef XKB
-       && noXkbExtension
-#endif
-       ) {
+        ((pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)) {
         if (!pDev->kbdfeed->ctrl.autoRepeat ||
             pDev->key->modifierMap[key_code] ||
             !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
                 & (1 << (key_code & 7))))
             return 0;
-        numEvents += GetKeyboardValuatorEvents(events, pDev,
-                                               KeyRelease, key_code,
-                                               num_valuators, valuators);
-        events += numEvents;
+
+#ifdef XKB
+        if (noXkbExtension)
+#endif
+        {
+            numEvents += GetKeyboardValuatorEvents(events, pDev,
+                                                   KeyRelease, key_code,
+                                                   num_valuators, valuators);
+            events += numEvents;
+        }
     }
 
     ms = GetTimeInMillis();
diff-tree 9f188416bb6b4837d4c3f8773053d5eee0ff0ee1 (from 539d1f33475484d35fb5a377efc76dba2d868e3f)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 10 14:00:34 2006 +0300

    core devices: clear devicePrivates on close

diff --git a/dix/devices.c b/dix/devices.c
index 69f1e7b..63b206a 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -270,6 +270,7 @@ CoreKeyboardProc(DeviceIntPtr pDev, int 
          * ... yeah.
          */
         pDev->key->xkbInfo = NULL;
+        pDev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
         break;
 
     default:
@@ -298,6 +299,10 @@ CorePointerProc(DeviceIntPtr pDev, int w
         pDev->valuator->lasty = pDev->valuator->axisVal[1];
         break;
 
+    case DEVICE_CLOSE:
+        pDev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
+        break;
+
     default:
         break;
     }
diff-tree 539d1f33475484d35fb5a377efc76dba2d868e3f (from 5506b4ad200745236f997c121e8200179c47b749)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Aug 10 14:00:14 2006 +0300

    GKVE/GPE: have DDX allocate events
    Don't allocate events on every GKE/GKVE/GPE call, just have the DDX manage
    it instead.  Introduce GetMaximumEventsNum(), which is the maximum number
    of events these functions will ever produce.

diff --git a/dix/events.c b/dix/events.c
index f0b9e16..5706aac 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4658,22 +4658,39 @@ WriteEventsToClient(ClientPtr pClient, i
     }
 }
 
+/* Maximum number of valuators, divided by six, rounded up. */
+#define MAX_VALUATOR_EVENTS 6
+
+/**
+ * Returns the maximum number of events GetKeyboardEvents,
+ * GetKeyboardValuatorEvents, and GetPointerEvents will ever return.
+ *
+ * Should be used in DIX as:
+ * xEvent *events = xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+ */
+int
+GetMaximumEventsNum() {
+    /* Two base events -- core and device, plus valuator events.  Multiply
+     * by two if we're doing key repeats. */
+    return 2 * (2 + MAX_VALUATOR_EVENTS);
+}
+
 /**
  * Convenience wrapper around GetKeyboardValuatorEvents, that takes no
  * valuators.
  */
 int
-GetKeyboardEvents(xEvent **xE, DeviceIntPtr pDev, int type, int key_code) {
-    return GetKeyboardValuatorEvents(xE, pDev, type, key_code, 0, NULL);
+GetKeyboardEvents(xEvent *events, DeviceIntPtr pDev, int type, int key_code) {
+    return GetKeyboardValuatorEvents(events, pDev, type, key_code, 0, NULL);
 }
 
 /**
  * Returns a set of keyboard events for KeyPress/KeyRelease, optionally
  * also with valuator events.  Handles Xi and XKB.
  *
- * xE will be set to an array of events, which must be freed by the user;
- * the return value is the number of events in xE, which is not
- * NULL-terminated.
+ * events is not NULL-terminated; the return value is the number of events.
+ * The DDX is responsible for allocating the event structure in the first
+ * place via GetMaximumEventsNum(), and for freeing it.
  *
  * If pDev is set to send core events, then the keymap on the core
  * keyboard will be pivoted to that of the new keyboard and the appropriate
@@ -4683,18 +4700,21 @@ GetKeyboardEvents(xEvent **xE, DeviceInt
  * key press will trigger a matching KeyRelease, as well as the
  * KeyPresses.
  */
-int GetKeyboardValuatorEvents(xEvent **xE, DeviceIntPtr pDev, int type,
+int GetKeyboardValuatorEvents(xEvent *events, DeviceIntPtr pDev, int type,
                               int key_code, int num_valuators,
                               int *valuators) {
     int numEvents = 0, numRepeatEvents = 0, ms = 0, first_valuator = 0, i = 0;
     deviceKeyButtonPointer *kbp = NULL;
     deviceValuator *xv = NULL;
-    xEvent *ev = NULL, *repeatEvents = NULL;
+    xEvent *repeatEvents = NULL;
     KeyClassPtr ckeyc;
 #ifdef XKB
     xkbMapNotify mn;
 #endif
 
+    if (!events)
+        return 0;
+    
     if (type != KeyPress && type != KeyRelease)
         return 0;
 
@@ -4707,8 +4727,11 @@ int GetKeyboardValuatorEvents(xEvent **x
     else
         numEvents = 1;
 
-    if (num_valuators)
-        numEvents += (num_valuators % 6) + 1;
+    if (num_valuators) {
+        if ((num_valuators / 6) + 1 > MAX_VALUATOR_EVENTS)
+            num_valuators = MAX_VALUATOR_EVENTS;
+        numEvents += (num_valuators / 6) + 1;
+    }
 
     /* Handle core repeating, via press/release/press/release.
      * FIXME: In theory, if you're repeating with two keyboards,
@@ -4724,26 +4747,15 @@ int GetKeyboardValuatorEvents(xEvent **x
             !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
                 & (1 << (key_code & 7))))
             return 0;
-        numEvents += GetKeyboardValuatorEvents(&repeatEvents, pDev,
+        numEvents += GetKeyboardValuatorEvents(events, pDev,
                                                KeyRelease, key_code,
                                                num_valuators, valuators);
+        events += numEvents;
     }
 
-    ev = (xEvent *)xcalloc(sizeof(xEvent), numEvents);
-    if (!ev)
-        return 0;
-
-    if (repeatEvents) {
-        for (i = 0; i < numRepeatEvents; i++) {
-            ev = repeatEvents++;
-            ev++;
-        }
-    }
-
-    *xE = ev;
     ms = GetTimeInMillis();
 
-    kbp = (deviceKeyButtonPointer *) ev;
+    kbp = (deviceKeyButtonPointer *) events;
     kbp->time = ms;
     kbp->deviceid = pDev->id;
     if (type == KeyPress)
@@ -4754,7 +4766,7 @@ int GetKeyboardValuatorEvents(xEvent **x
     if (num_valuators) {
         kbp->deviceid |= MORE_EVENTS;
         while (first_valuator < num_valuators) {
-            xv = (deviceValuator *) ++ev;
+            xv = (deviceValuator *) ++events;
             xv->type = DeviceValuator;
             xv->first_valuator = first_valuator;
             xv->num_valuators = num_valuators;
@@ -4781,10 +4793,10 @@ int GetKeyboardValuatorEvents(xEvent **x
     }
 
     if (pDev->coreEvents) {
-        ev++;
-        ev->u.keyButtonPointer.time = ms;
-        ev->u.u.type = type;
-        ev->u.u.detail = key_code;
+        events++;
+        events->u.keyButtonPointer.time = ms;
+        events->u.u.type = type;
+        events->u.u.detail = key_code;
 
         if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr !=
             pDev) {
@@ -4796,8 +4808,6 @@ int GetKeyboardValuatorEvents(xEvent **x
             memcpy(ckeyc->modifierKeyMap, pDev->key->modifierKeyMap,
                     (8 * pDev->key->maxKeysPerModifier));
             ckeyc->maxKeysPerModifier = pDev->key->maxKeysPerModifier;
-            ckeyc->curKeySyms.map = NULL;
-            ckeyc->curKeySyms.mapWidth = 0;
             ckeyc->curKeySyms.minKeyCode = pDev->key->curKeySyms.minKeyCode;
             ckeyc->curKeySyms.maxKeyCode = pDev->key->curKeySyms.maxKeyCode;
             SetKeySymsMap(&ckeyc->curKeySyms, &pDev->key->curKeySyms);
@@ -4911,13 +4921,14 @@ acceleratePointer(DeviceIntPtr pDev, int
  * Generate a series of xEvents (returned in xE) representing pointer
  * motion, or button presses.  Xi and XKB-aware.
  *
- * xE is not NULL-terminated; the return value is the number of events.
- * The user is responsible for freeing these events.
+ * events is not NULL-terminated; the return value is the number of events.
+ * The DDX is responsible for allocating the event structure in the first
+ * place via GetMaximumEventsNum(), and for freeing it.
  */
 int
-GetPointerEvents(xEvent **xE, DeviceIntPtr pDev, int type, int buttons,
+GetPointerEvents(xEvent *events, DeviceIntPtr pDev, int type, int buttons,
                  int flags, int num_valuators, int *valuators) {
-    int numEvents, ms, first_valuator = 0;
+    int numEvents = 0, ms = 0, first_valuator = 0;
     deviceKeyButtonPointer *kbp = NULL;
     deviceValuator *xv = NULL;
     AxisInfoPtr axes = NULL;
@@ -4942,20 +4953,18 @@ GetPointerEvents(xEvent **xE, DeviceIntP
         numEvents = 1;
 
     if (type == MotionNotify) {
-        if (num_valuators > 2)
+        if (num_valuators > 2) {
+            if (((num_valuators / 6) + 1) > MAX_VALUATOR_EVENTS)
+                num_valuators = MAX_VALUATOR_EVENTS;
             numEvents += (num_valuators / 6) + 1;
+        }
         else if (num_valuators < 2)
             return 0;
     }
 
-    ev = (xEvent *)xcalloc(sizeof(xEvent), numEvents);
-    if (!ev)
-        return 0;
-
-    *xE = ev;
     ms = GetTimeInMillis();
 
-    kbp = (deviceKeyButtonPointer *) ev;
+    kbp = (deviceKeyButtonPointer *) events;
     kbp->time = ms;
     kbp->deviceid = pDev->id;
 
@@ -5053,7 +5062,7 @@ GetPointerEvents(xEvent **xE, DeviceIntP
                               flags & POINTER_ABSOLUTE)) {
         kbp->deviceid |= MORE_EVENTS;
         while (first_valuator < num_valuators) {
-            xv = (deviceValuator *) ++ev;
+            xv = (deviceValuator *) ++events;
             xv->type = DeviceValuator;
             xv->first_valuator = first_valuator;
             xv->num_valuators = num_valuators;
@@ -5086,11 +5095,11 @@ GetPointerEvents(xEvent **xE, DeviceIntP
     }
 
     if (pDev->coreEvents) {
-        ev++;
-        ev->u.u.type = type;
-        ev->u.keyButtonPointer.time = ms;
-        ev->u.keyButtonPointer.rootX = kbp->root_x;
-        ev->u.keyButtonPointer.rootY = kbp->root_y;
+        events++;
+        events->u.u.type = type;
+        events->u.keyButtonPointer.time = ms;
+        events->u.keyButtonPointer.rootX = kbp->root_x;
+        events->u.keyButtonPointer.rootY = kbp->root_y;
         cp->valuator->lastx = kbp->root_x;
         cp->valuator->lasty = kbp->root_y;
 #ifdef DEBUG
@@ -5101,10 +5110,10 @@ GetPointerEvents(xEvent **xE, DeviceIntP
             ErrorF("GPE: core detail is %d\n", buttons);
 #endif
             /* Core buttons remapping shouldn't be transitive. */
-            ev->u.u.detail = pDev->button->map[buttons];
+            events->u.u.detail = pDev->button->map[buttons];
         }
         else {
-            ev->u.u.detail = 0;
+            events->u.u.detail = 0;
         }
 
         if (inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr !=
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 1718fda..fc4592a 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -69,6 +69,8 @@ static struct KdConfigDevice *kdConfigPo
 static KdKeyboardDriver *kdKeyboardDrivers = NULL;
 static KdPointerDriver  *kdPointerDrivers  = NULL;
 
+static xEvent           *kdEvents = NULL;
+
 static Bool		kdInputEnabled;
 static Bool		kdOffScreen;
 static unsigned long	kdOffScreenTime;
@@ -1271,6 +1273,11 @@ KdInitInput (void)
             ErrorF("Failed to add keyboard!\n");
     }
 
+    if (!kdEvents)
+        kdEvents = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+    if (!kdEvents)
+        FatalError("Couldn't allocate event buffer\n");
+
     mieqInit();
 }
 
@@ -1849,7 +1856,6 @@ KdHandleKeyboardEvent (KdKeyboardInfo *k
 void
 KdReleaseAllKeys (void)
 {
-    xEvent *xE;
     int	key, nEvents, i;
     KdKeyboardInfo *ki;
 
@@ -1860,9 +1866,9 @@ KdReleaseAllKeys (void)
              key++) {
             if (IsKeyDown(ki, key)) {
                 KdHandleKeyboardEvent(ki, KeyRelease, key);
-                nEvents = GetKeyboardEvents(&xE, ki->dixdev, KeyRelease, key);
+                nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, KeyRelease, key);
                 for (i = 0; i < nEvents; i++)
-                    KdQueueEvent (xE++);
+                    KdQueueEvent (kdEvents + i);
             }
         }
     }
@@ -1897,7 +1903,6 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo   
     KeyClassPtr	keyc = NULL;
     KeybdCtrl *ctrl = NULL;
     int type, nEvents, i;
-    xEvent *xE = NULL;
 
 #ifdef DEBUG
     ErrorF("enqueuing kb event (scancode %d, %s)\n", scan_code, is_up ? "up" : "down");
@@ -1939,12 +1944,12 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo   
 	
         KdCheckSpecialKeys(ki, type, key_code);
         KdHandleKeyboardEvent(ki, type, key_code);
-        nEvents = GetKeyboardEvents(&xE, ki->dixdev, type, key_code);
+        nEvents = GetKeyboardEvents(kdEvents, ki->dixdev, type, key_code);
 #ifdef DEBUG
         ErrorF("KdEnqueueKeyboardEvent: got %d events from GKE\n", nEvents);
 #endif
         for (i = 0; i < nEvents; i++)
-            KdQueueEvent(xE++);
+            KdQueueEvent(kdEvents + i);
     }
     else {
         ErrorF("driver %s wanted to post scancode %d outside of [%d, %d]!\n",
@@ -2047,8 +2052,7 @@ void
 _KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
                         int b, int absrel, Bool force)
 {
-    xEvent *xE = NULL;
-    int n = 0, i = 0;
+    int nEvents = 0, i = 0;
     int valuators[3] = { x, y, z };
 
 #ifdef DEBUG
@@ -2060,9 +2064,10 @@ _KdEnqueuePointerEvent (KdPointerInfo *p
     if (!force && KdHandlePointerEvent(pi, type, x, y, z, b, absrel))
         return;
 
-    n = GetPointerEvents(&xE, pi->dixdev, type, b, absrel, 3, valuators);
-    for (i = 0; i < n; i++)
-        KdQueueEvent(xE++);
+    nEvents = GetPointerEvents(kdEvents, pi->dixdev, type, b, absrel, 3,
+                               valuators);
+    for (i = 0; i < nEvents; i++)
+        KdQueueEvent(kdEvents + i);
 }
 
 void
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 91db82e..070645d 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -108,6 +108,8 @@ static int      debug_level = 0;
 #define DBG(lvl, f)
 #endif
 
+static xEvent *xf86Events = NULL;
+
 static Bool
 xf86SendDragEvents(DeviceIntPtr	device)
 {
@@ -639,7 +641,6 @@ xf86PostMotionEvent(DeviceIntPtr	device,
     int i = 0, nevents = 0;
     Bool drag = xf86SendDragEvents(device);
     LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
-    xEvent *events = NULL;
     int *valuators = NULL;
     int flags = 0;
 
@@ -662,15 +663,16 @@ xf86PostMotionEvent(DeviceIntPtr	device,
 #endif
     }
 
-    nevents = GetPointerEvents(&events, device, MotionNotify, 0,
+    if (!xf86Events)
+        xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+    if (!xf86Events)
+        FatalError("Couldn't allocate event store\n");
+
+    nevents = GetPointerEvents(xf86Events, device, MotionNotify, 0,
                                flags, num_valuators, valuators);
 
-    for (i = 0; i < nevents; i++) {
-        if (events->u.keyButtonPointer.time > xf86Info.lastEventTime)
-            xf86Info.lastEventTime = events->u.keyButtonPointer.time;
-        mieqEnqueue(events + i);
-    }
-    xfree(events);
+    for (i = 0; i < nevents; i++)
+        mieqEnqueue(xf86Events + i);
     
 #if 0
     if (HAS_MOTION_HISTORY(local)) {
@@ -791,7 +793,6 @@ xf86PostButtonEvent(DeviceIntPtr	device,
     va_list var;
     int *valuators = NULL;
     int i = 0, nevents = 0;
-    xEvent *events = NULL;
     
 #ifdef DEBUG
     ErrorF("xf86PostButtonEvent BEGIN 0x%x(%s) button=%d down=%s is_absolute=%s\n",
@@ -810,18 +811,19 @@ xf86PostButtonEvent(DeviceIntPtr	device,
         valuators[i] = va_arg(var, int);
     }
 
-    nevents = GetPointerEvents(&events, device,
+    if (!xf86Events)
+        xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+    if (!xf86Events)
+        FatalError("Couldn't allocate event store\n");
+
+    nevents = GetPointerEvents(xf86Events, device,
                                is_down ? ButtonPress : ButtonRelease, button,
                                is_absolute ? POINTER_ABSOLUTE :
                                              POINTER_RELATIVE,
                                num_valuators, valuators);
 
-    for (i = 0; i < nevents; i++) {
-        if (events->u.keyButtonPointer.time > xf86Info.lastEventTime)
-            xf86Info.lastEventTime = events->u.keyButtonPointer.time;
-        mieqEnqueue(events + i);
-    }
-    xfree(events);
+    for (i = 0; i < nevents; i++)
+        mieqEnqueue(xf86Events + i);
 }
 
 _X_EXPORT void
@@ -835,38 +837,39 @@ xf86PostKeyEvent(DeviceIntPtr	device,
 {
     va_list var;
     int i = 0, nevents = 0, *valuators = NULL;
-    xEvent *events = NULL;
 
     /* instil confidence in the user */
     ErrorF("this function has never been tested properly.  if things go quite "
            "badly south after this message, then xf86PostKeyEvent is "
            "broken.\n");
 
+    if (!xf86Events)
+        xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+    if (!xf86Events)
+        FatalError("Couldn't allocate event store\n");
+
     /* the spec says that dkp/dkr events should only get valuators in
      * absolute mode.  the spec knows all.  BOW BEFORE etc. */
     if (is_absolute) {
-        nevents = GetKeyboardValuatorEvents(&events, device,
-                                            is_down ? KeyPress : KeyRelease,
-                                            key_code, num_valuators,
-                                            valuators);
         valuators = xcalloc(sizeof(int), num_valuators);
         va_start(var, num_valuators);
         for (i = 0; i < num_valuators; i++)
             valuators[i] = va_arg(var, int);
         va_end(var);
+
+        nevents = GetKeyboardValuatorEvents(xf86Events, device,
+                                            is_down ? KeyPress : KeyRelease,
+                                            key_code, num_valuators,
+                                            valuators);
     }
     else {
-        nevents = GetKeyboardEvents(&events, device,
+        nevents = GetKeyboardEvents(xf86Events, device,
                                     is_down ? KeyPress : KeyRelease,
                                     key_code);
     }
 
-    for (i = 0; i < nevents; i++) {
-        if (events->u.keyButtonPointer.time > xf86Info.lastEventTime)
-            xf86Info.lastEventTime = events->u.keyButtonPointer.time;
-        mieqEnqueue(events + i);
-    }
-    xfree(events);
+    for (i = 0; i < nevents; i++)
+        mieqEnqueue(xf86Events + i);
 }
 
 _X_EXPORT void
@@ -874,7 +877,6 @@ xf86PostKeyboardEvent(DeviceIntPtr      
                       unsigned int      key_code,
                       int               is_down)
 {
-    xEvent *events = NULL;
     int nevents = 0, i = 0;
 
 #ifdef DEBUG
@@ -882,15 +884,16 @@ xf86PostKeyboardEvent(DeviceIntPtr      
            is_down ? "down" : "up", device->id);
 #endif
 
-    nevents = GetKeyboardEvents(&events, device,
+    if (!xf86Events)
+        xf86Events = (xEvent *)xcalloc(sizeof(xEvent), GetMaximumEventsNum());
+    if (!xf86Events)
+        FatalError("Couldn't allocate event store\n");
+
+    nevents = GetKeyboardEvents(xf86Events, device,
                                 is_down ? KeyPress : KeyRelease, key_code);
 
-    for (i = 0; i < nevents; i++) {
-        if (events->u.keyButtonPointer.time > xf86Info.lastEventTime)
-            xf86Info.lastEventTime = events->u.keyButtonPointer.time;
-        mieqEnqueue(events + i);
-    }
-    xfree(events);
+    for (i = 0; i < nevents; i++)
+        mieqEnqueue(xf86Events + i);
 }
 
 /* 
diff --git a/include/input.h b/include/input.h
index d1791e7..6572db5 100644
--- a/include/input.h
+++ b/include/input.h
@@ -377,8 +377,10 @@ extern void InitInput(
     int  /*argc*/,
     char ** /*argv*/);
 
+extern int GetMaximumEventsNum(void);
+
 extern int GetPointerEvents(
-    xEvent **xE,
+    xEvent *events,
     DeviceIntPtr pDev,
     int type,
     int buttons,
@@ -387,13 +389,13 @@ extern int GetPointerEvents(
     int *valuators);
 
 extern int GetKeyboardEvents(
-    xEvent **xE,
+    xEvent *events,
     DeviceIntPtr pDev,
     int type,
     int key_code);
 
 extern int GetKeyboardValuatorEvents(
-    xEvent **xE,
+    xEvent *events,
     DeviceIntPtr pDev,
     int type,
     int key_code,
diff-tree 5506b4ad200745236f997c121e8200179c47b749 (from parents)
Merge: 4be9abb8504b3761b5f3a01851e4eb3da86c76e2 462bb61b0fe968fae1b99cf98ec6f7de09105dcd
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Aug 9 07:21:01 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree 4be9abb8504b3761b5f3a01851e4eb3da86c76e2 (from fe351a711ef55c3ae1e784d4551147c080eda109)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Aug 9 07:20:16 2006 +0300

    kdrive: remove ddx_DEPENDENCIES
    Remove foo_DEPENDENCIES as they weren't guaranteed to just be libs,
    and loader arguments (-lfoo, -Lfoo) might've crept in.

diff --git a/hw/kdrive/ati/Makefile.am b/hw/kdrive/ati/Makefile.am
index b234181..94d525e 100644
--- a/hw/kdrive/ati/Makefile.am
+++ b/hw/kdrive/ati/Makefile.am
@@ -67,6 +67,3 @@ Xati_LDADD = \
 	@KDRIVE_LIBS@			\
 	@XSERVER_LIBS@			\
 	$(TSLIB_FLAG)
-
-
-Xati_DEPENDENCIES = $(ATI_LIBS)
diff --git a/hw/kdrive/chips/Makefile.am b/hw/kdrive/chips/Makefile.am
index e308077..146c1df 100644
--- a/hw/kdrive/chips/Makefile.am
+++ b/hw/kdrive/chips/Makefile.am
@@ -29,5 +29,3 @@ Xchips_LDADD = \
 	@KDRIVE_LIBS@                          \
 	@XSERVER_LIBS@				\
 	$(TSLIB_FLAG)
-
-Xchips_DEPENDENCIES = $(CHIPS_LIBS) @KDRIVE_LIBS@
diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am
index 6982d80..b8f12c5 100644
--- a/hw/kdrive/ephyr/Makefile.am
+++ b/hw/kdrive/ephyr/Makefile.am
@@ -35,9 +35,3 @@ Xephyr_LDADD = 						\
 	@KDRIVE_LIBS@					\
         $(TSLIB_LIBS)                                   \
         @XEPHYR_LIBS@
-
-Xephyr_DEPENDENCIES =					\
-	libxephyr.a					\
-	libxephyr-hostx.a                               \
-	@KDRIVE_LIBS@					\
-	../../../exa/libexa.la					
diff --git a/hw/kdrive/epson/Makefile.am b/hw/kdrive/epson/Makefile.am
index 0538f4c..1a24d43 100644
--- a/hw/kdrive/epson/Makefile.am
+++ b/hw/kdrive/epson/Makefile.am
@@ -29,5 +29,3 @@ Xepson_LDADD = \
 	@KDRIVE_LIBS@                          \
 	@XSERVER_LIBS@				\
 	$(TSLIB_FLAG)
-
-Xepson_DEPENDENCIES = $(EPSON_LIBS) @KDRIVE_LIBS@
diff --git a/hw/kdrive/fake/Makefile.am b/hw/kdrive/fake/Makefile.am
index f3a6a34..a9c9aff 100644
--- a/hw/kdrive/fake/Makefile.am
+++ b/hw/kdrive/fake/Makefile.am
@@ -26,8 +26,3 @@ Xfake_LDADD = 						\
 	@KDRIVE_LIBS@					\
 	$(TSLIB_FLAG)                                   \
         @XSERVER_LIBS@
-
-Xfake_DEPENDENCIES =					\
-	libfake.a					\
-	@KDRIVE_LIBS@					
-
diff --git a/hw/kdrive/fbdev/Makefile.am b/hw/kdrive/fbdev/Makefile.am
index 39e9ba4..deed3c9 100644
--- a/hw/kdrive/fbdev/Makefile.am
+++ b/hw/kdrive/fbdev/Makefile.am
@@ -23,8 +23,4 @@ Xfbdev_LDADD = 						\
 	@KDRIVE_LIBS@					\
 	@XSERVER_LIBS@					\
 	$(TSLIB_FLAG)
-
-Xfbdev_DEPENDENCIES =					\
-	libfbdev.a					\
-	@KDRIVE_LIBS@					
 endif
diff --git a/hw/kdrive/i810/Makefile.am b/hw/kdrive/i810/Makefile.am
index d676a69..5f7b2ac 100644
--- a/hw/kdrive/i810/Makefile.am
+++ b/hw/kdrive/i810/Makefile.am
@@ -31,5 +31,3 @@ Xi810_LDADD = \
 	@KDRIVE_LIBS@                                  \
 	@XSERVER_LIBS@					\
 	$(TSLIB_FLAG)
-
-Xi810_DEPENDENCIES = $(I810_LIBS) @KDRIVE_LIBS@
diff --git a/hw/kdrive/linux/Makefile.am b/hw/kdrive/linux/Makefile.am
index 29959df..e13d083 100644
--- a/hw/kdrive/linux/Makefile.am
+++ b/hw/kdrive/linux/Makefile.am
@@ -32,16 +32,3 @@ liblinux_a_SOURCES = 	\
 	$(KDRIVE_HW_SOURCES) \
 	$(TSLIB_C)	\
 	$(TS_C)
-
-liblinux_a_DEPENDENCIES = \
-	agp.c		\
-	bus.c		\
-	keyboard.c	\
-	linux.c		\
-	mouse.c		\
-	evdev.c		\
-	ms.c		\
-	ps2.c		\
-	$(TSLIB_C)	\
-	$(TS_C)
-
diff --git a/hw/kdrive/mach64/Makefile.am b/hw/kdrive/mach64/Makefile.am
index 299565f..3040a89 100644
--- a/hw/kdrive/mach64/Makefile.am
+++ b/hw/kdrive/mach64/Makefile.am
@@ -32,6 +32,3 @@ Xmach64_LDADD = 					\
 	@KDRIVE_LIBS@					\
 	@XSERVER_LIBS@					\
 	$(TSLIB_FLAG)
-
-
-Xmach64_DEPENDENCIES = $(MACH64_LIBS) @KDRIVE_LIBS@
diff --git a/hw/kdrive/mga/Makefile.am b/hw/kdrive/mga/Makefile.am
index 64d260e..7853cba 100644
--- a/hw/kdrive/mga/Makefile.am
+++ b/hw/kdrive/mga/Makefile.am
@@ -31,5 +31,3 @@ Xmga_LDADD = \
 	@KDRIVE_LIBS@                                  \
 	@XSERVER_LIBS@					\
 	$(TSLIB_FLAG)
-
-Xmga_DEPENDENCIES = $(MGA_LIBS) @KDRIVE_LIBS@
diff --git a/hw/kdrive/neomagic/Makefile.am b/hw/kdrive/neomagic/Makefile.am
index b37bfc3..8b8db6a 100644
--- a/hw/kdrive/neomagic/Makefile.am
+++ b/hw/kdrive/neomagic/Makefile.am
@@ -43,5 +43,3 @@ Xneomagic_LDADD = \
 	@KDRIVE_LIBS@               \
 	@XSERVER_LIBS@					\
 	$(TSLIB_FLAG)
-
-Xneomagic_DEPENDENCIES = $(NEOMAGIC_LIBS) @KDRIVE_LIBS@
diff --git a/hw/kdrive/nvidia/Makefile.am b/hw/kdrive/nvidia/Makefile.am
index 48551a3..848b4cc 100644
--- a/hw/kdrive/nvidia/Makefile.am
+++ b/hw/kdrive/nvidia/Makefile.am
@@ -32,5 +32,3 @@ Xnvidia_LDADD = \
 	@KDRIVE_LIBS@				\
 	@XSERVER_LIBS@					\
 	$(TSLIB_FLAG)
-
-Xnvidia_DEPENDENCIES = $(NVIDIA_LIBS) @KDRIVE_LIBS@
diff --git a/hw/kdrive/pm2/Makefile.am b/hw/kdrive/pm2/Makefile.am
index 1a71207..7ca2936 100644
--- a/hw/kdrive/pm2/Makefile.am
+++ b/hw/kdrive/pm2/Makefile.am
@@ -30,5 +30,3 @@ Xpm2_LDADD = \
 	@KDRIVE_LIBS@                          \
 	@XSERVER_LIBS@					\
 	$(TSLIB_FLAG)
-
-Xpm2_DEPENDENCIES = $(PM2_LIBS) @KDRIVE_LIBS@
diff --git a/hw/kdrive/r128/Makefile.am b/hw/kdrive/r128/Makefile.am
index b33e138..5d783ee 100644
--- a/hw/kdrive/r128/Makefile.am
+++ b/hw/kdrive/r128/Makefile.am
@@ -29,5 +29,3 @@ Xr128_LDADD = \
 	@KDRIVE_LIBS@                          \
 	@XSERVER_LIBS@					\
 	$(TSLIB_FLAG)
-
-Xr128_DEPENDENCIES = $(R128_LIBS) @KDRIVE_LIBS@
diff --git a/hw/kdrive/sdl/Makefile.am b/hw/kdrive/sdl/Makefile.am
index ba6ed4d..cc3873c 100644
--- a/hw/kdrive/sdl/Makefile.am
+++ b/hw/kdrive/sdl/Makefile.am
@@ -16,5 +16,3 @@ Xsdl_LDADD = @KDRIVE_PURE_LIBS@				\
 	@XSERVER_LIBS@					\
 	$(TSLIB_FLAG)					\
 	@XSDL_LIBS@
-
-Xsdl_DEPENDENCIES = @KDRIVE_LIBS@
diff --git a/hw/kdrive/sis300/Makefile.am b/hw/kdrive/sis300/Makefile.am
index efd1e9a..e7200a2 100644
--- a/hw/kdrive/sis300/Makefile.am
+++ b/hw/kdrive/sis300/Makefile.am
@@ -42,5 +42,3 @@ Xsis_LDADD = \
 	$(SIS_LIBS)				\
 	@KDRIVE_LIBS@                          \
 	$(TSLIB_FLAG)
-
-Xsis_DEPENDENCIES = $(SIS_LIBS) @KDRIVE_LIBS@
diff --git a/hw/kdrive/smi/Makefile.am b/hw/kdrive/smi/Makefile.am
index a214e76..8ce3eba 100644
--- a/hw/kdrive/smi/Makefile.am
+++ b/hw/kdrive/smi/Makefile.am
@@ -34,5 +34,3 @@ Xsmi_LDADD = \
 	@KDRIVE_LIBS@                          \
 	@XSERVER_LIBS@					\
 	$(TSLIB_FLAG)
-
-Xsmi_DEPENDENCIES = $(SMI_LIBS) @KDRIVE_LIBS@
diff --git a/hw/kdrive/vesa/Makefile.am b/hw/kdrive/vesa/Makefile.am
index 01bc0a3..8f36ddf 100644
--- a/hw/kdrive/vesa/Makefile.am
+++ b/hw/kdrive/vesa/Makefile.am
@@ -30,7 +30,3 @@ Xvesa_LDADD = \
 	@KDRIVE_LIBS@                          \
 	$(TSLIB_FLAG)				\
 	@XSERVER_LIBS@
-
-Xvesa_DEPENDENCIES = \
-	libvesa.a    \
-	@KDRIVE_LIBS@
diff --git a/hw/kdrive/via/Makefile.am b/hw/kdrive/via/Makefile.am
index 4d52df9..6e2045a 100644
--- a/hw/kdrive/via/Makefile.am
+++ b/hw/kdrive/via/Makefile.am
@@ -30,5 +30,3 @@ Xvia_LDADD =						\
 	@KDRIVE_LIBS@					\
 	@XSERVER_LIBS@					\
 	$(TSLIB_FLAG)					
-
-Xvia_DEPENDENCIES = $(VIA_LIBS) @KDRIVE_LIBS@
diff-tree fe351a711ef55c3ae1e784d4551147c080eda109 (from 31089816317f27c668b12a15c74fdd226a8df9f7)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Aug 8 14:54:10 2006 +0300

    GKVE: send XkbMapNotify, not XkbNewKeyboardNotify
    Sending MapNotify is more correct in this case than NKN, so do that.

diff --git a/dix/events.c b/dix/events.c
index f6524a3..f0b9e16 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4675,6 +4675,10 @@ GetKeyboardEvents(xEvent **xE, DeviceInt
  * the return value is the number of events in xE, which is not
  * NULL-terminated.
  *
+ * If pDev is set to send core events, then the keymap on the core
+ * keyboard will be pivoted to that of the new keyboard and the appropriate
+ * MapNotify events (both core and XKB) will be sent.
+ *
  * Note that this function recurses!  If called for non-XKB, a repeating
  * key press will trigger a matching KeyRelease, as well as the
  * KeyPresses.
@@ -4688,7 +4692,7 @@ int GetKeyboardValuatorEvents(xEvent **x
     xEvent *ev = NULL, *repeatEvents = NULL;
     KeyClassPtr ckeyc;
 #ifdef XKB
-    xkbNewKeyboardNotify nkn;
+    xkbMapNotify mn;
 #endif
 
     if (type != KeyPress && type != KeyRelease)
@@ -4798,27 +4802,36 @@ int GetKeyboardValuatorEvents(xEvent **x
             ckeyc->curKeySyms.maxKeyCode = pDev->key->curKeySyms.maxKeyCode;
             SetKeySymsMap(&ckeyc->curKeySyms, &pDev->key->curKeySyms);
 #ifdef XKB
-            if (!noXkbExtension) {
-                nkn.oldMinKeyCode = ckeyc->xkbInfo->desc->min_key_code;
-                nkn.oldMaxKeyCode = ckeyc->xkbInfo->desc->max_key_code;
-                nkn.deviceID = nkn.oldDeviceID = inputInfo.keyboard->id;
-                nkn.minKeyCode = pDev->key->xkbInfo->desc->min_key_code;
-                nkn.maxKeyCode = pDev->key->xkbInfo->desc->max_key_code;
-                nkn.requestMajor = XkbReqCode;
-                nkn.requestMinor = X_kbSetMap; /* XXX bare-faced lie */
-                nkn.changed = XkbAllNewKeyboardEventsMask;
-                /* Free the map we set up at DEVICE_INIT time, since it's
-                 * going to just quietly disappear.  Shameful hack. */
-                if (!inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr
-                    && ckeyc->xkbInfo)
+            if (!noXkbExtension && pDev->key->xkbInfo &&
+                pDev->key->xkbInfo->desc) {
+                mn.deviceID = inputInfo.keyboard->id;
+                mn.minKeyCode = pDev->key->xkbInfo->desc->min_key_code;
+                mn.maxKeyCode = pDev->key->xkbInfo->desc->max_key_code;
+                mn.firstType = 0;
+                mn.nTypes = pDev->key->xkbInfo->desc->map->num_types;
+                mn.firstKeySym = pDev->key->xkbInfo->desc->min_key_code;
+                mn.nKeySyms = XkbNumKeys(pDev->key->xkbInfo->desc);
+                mn.firstKeyAct = pDev->key->xkbInfo->desc->min_key_code;
+                mn.nKeyActs = XkbNumKeys(pDev->key->xkbInfo->desc);
+                /* Cargo-culted from ProcXkbGetMap. */
+                mn.firstKeyBehavior = pDev->key->xkbInfo->desc->min_key_code;
+                mn.nKeyBehaviors = XkbNumKeys(pDev->key->xkbInfo->desc);
+                mn.firstKeyExplicit = pDev->key->xkbInfo->desc->min_key_code;
+                mn.nKeyExplicit = XkbNumKeys(pDev->key->xkbInfo->desc);
+                mn.firstModMapKey = pDev->key->xkbInfo->desc->min_key_code;
+                mn.nModMapKeys = XkbNumKeys(pDev->key->xkbInfo->desc);
+                mn.firstVModMapKey = pDev->key->xkbInfo->desc->min_key_code;
+                mn.nVModMapKeys = XkbNumKeys(pDev->key->xkbInfo->desc);
+                mn.virtualMods = ~0; /* ??? */
+                mn.changed = XkbAllMapComponentsMask;
+                
+                /* If this is still the map we set at DEVICE_INIT, free it so
+                 * it doesn't just get lost.  (Shameful hack, sorry.) */
+                if (!inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr &&
+                    ckeyc->xkbInfo)
                     XkbFreeInfo(ckeyc->xkbInfo);
                 ckeyc->xkbInfo = pDev->key->xkbInfo;
-                /* FIXME OH MY GOD SO AWFUL let's hope nobody notices */
-                if (nkn.oldMinKeyCode == nkn.minKeyCode)
-                    nkn.oldMinKeyCode--;
-                if (nkn.oldMaxKeyCode == nkn.maxKeyCode)
-                    nkn.oldMaxKeyCode++;
-                XkbSendNewKeyboardNotify(inputInfo.keyboard, &nkn);
+                XkbSendMapNotify(inputInfo.keyboard, &mn);
             }
 #endif
             SendMappingNotify(MappingKeyboard, ckeyc->curKeySyms.minKeyCode,
diff-tree 31089816317f27c668b12a15c74fdd226a8df9f7 (from parents)
Merge: ab3ebfefdb7d21aba72a5030f6f93bf4fafed709 12dbd8a02f797ad57a1be683a02a1fcb1ca35438
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Aug 8 12:01:12 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree ab3ebfefdb7d21aba72a5030f6f93bf4fafed709 (from 7721ee308fbbb6fc9c969f15fe04b3346c04f843)
Author: Tiago Vignatti <tv02 at c3sl.ufpr.br>
Date:   Tue Aug 8 12:00:34 2006 +0300

    xorgcfg: fix compilation error
    Add missing parentheses to IS_KBDDRIV macros.

diff --git a/hw/xfree86/utils/xorgcfg/interface.c b/hw/xfree86/utils/xorgcfg/interface.c
index 3670597..9b22dc7 100644
--- a/hw/xfree86/utils/xorgcfg/interface.c
+++ b/hw/xfree86/utils/xorgcfg/interface.c
@@ -66,7 +66,7 @@
 #define DefaultXFree86Dir	"/usr"
 #endif
 
-#define IS_KBDDRIV(S) ((strcasecmp((S),"kbd") == 0)
+#define IS_KBDDRIV(S) ((strcasecmp((S),"kbd") == 0))
 
 /*
  * Prototypes
diff --git a/hw/xfree86/utils/xorgcfg/keyboard-cfg.c b/hw/xfree86/utils/xorgcfg/keyboard-cfg.c
index 95102b5..545a670 100644
--- a/hw/xfree86/utils/xorgcfg/keyboard-cfg.c
+++ b/hw/xfree86/utils/xorgcfg/keyboard-cfg.c
@@ -37,7 +37,7 @@
 #include <X11/Xaw/SimpleMenu.h>
 #include <X11/Xaw/SmeBSB.h>
 
-#define IS_KBDDRIV(X) ((strcasecmp((X),"kbd") == 0)
+#define IS_KBDDRIV(X) ((strcasecmp((X),"kbd") == 0))
 
 /*
  * Types
diff --git a/hw/xfree86/utils/xorgcfg/text-mode.c b/hw/xfree86/utils/xorgcfg/text-mode.c
index 91616ad..5bb5648 100644
--- a/hw/xfree86/utils/xorgcfg/text-mode.c
+++ b/hw/xfree86/utils/xorgcfg/text-mode.c
@@ -46,7 +46,7 @@
 #include "xf86config.h"
 #include "loader.h"
 
-#define IS_KBDDRIV(X) ((strcmp((X),"kbd") == 0)
+#define IS_KBDDRIV(X) ((strcmp((X),"kbd") == 0))
 
 #ifndef PROJECT_ROOT
 #define PROJECT_ROOT "/usr"
diff-tree 7721ee308fbbb6fc9c969f15fe04b3346c04f843 (from 458c63a84110f64c7fce397a531a3a779c2239a2)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 23:03:02 2006 +0300

    config client: fix minor race with event queue
    Fix a small race whereby you could remove a device while events from it
    were still in the queue, by calling ProcessInputEvents immediately before
    RemoveDevice, to (hopefully) flush the event queue.

diff --git a/config/config.c b/config/config.c
index b85b120..d4cf233 100644
--- a/config/config.c
+++ b/config/config.c
@@ -173,6 +173,10 @@ configMessage(DBusConnection *connection
                 return DBUS_HANDLER_RESULT_HANDLED;
             }
             ErrorF("pDev is %p\n", pDev);
+            /* Call PIE here so we don't try to dereference a device that's
+             * already been removed.  Technically there's still a small race
+             * here, so we should ensure that SIGIO is blocked. */
+            ProcessInputEvents();
             RemoveDevice(pDev);
             dbus_error_free(&error);
             return DBUS_HANDLER_RESULT_HANDLED;
diff-tree 458c63a84110f64c7fce397a531a3a779c2239a2 (from a31d11a7a8485cdc799f76c4d407d3b7f7c9b350)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 23:02:17 2006 +0300

    enable adding devices after removal of a middle device
    Allow new devices to be added after a device that _wasn't_ the last on the
    list was removed, by ensuring inputInfo.numDevices always increases, and
    never decreases.

diff --git a/Xi/listdev.c b/Xi/listdev.c
index 91e8f22..02d55ad 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -96,7 +96,7 @@ int
 ProcXListInputDevices(register ClientPtr client)
 {
     xListInputDevicesReply rep;
-    int numdevs;
+    int numdevs = 0;
     int namesize = 1;	/* need 1 extra byte for strcpy */
     int size = 0;
     int total_length;
@@ -115,12 +115,15 @@ ProcXListInputDevices(register ClientPtr
     rep.sequenceNumber = client->sequence;
 
     AddOtherInputDevices();
-    numdevs = inputInfo.numDevices;
 
-    for (d = inputInfo.devices; d; d = d->next)
+    for (d = inputInfo.devices; d; d = d->next) {
 	SizeDeviceInfo(d, &namesize, &size);
-    for (d = inputInfo.off_devices; d; d = d->next)
+        numdevs++;
+    }
+    for (d = inputInfo.off_devices; d; d = d->next) {
 	SizeDeviceInfo(d, &namesize, &size);
+        numdevs++;
+    }
 
     total_length = numdevs * sizeof(xDeviceInfo) + size + namesize;
     devbuf = (char *)xalloc(total_length);
diff --git a/dix/devices.c b/dix/devices.c
index 1d423e2..69f1e7b 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -536,7 +536,7 @@ RemoveDevice(DeviceIntPtr dev)
     ErrorF("want to remove device %p, kb is %p, pointer is %p\n", dev, inputInfo.keyboard, inputInfo.pointer);
 #endif
 
-    if (!dev)
+    if (!dev || dev == inputInfo.keyboard || dev == inputInfo.pointer)
         return BadImplementation;
 
     prev = NULL;
@@ -550,13 +550,6 @@ RemoveDevice(DeviceIntPtr dev)
 	    else
 		prev->next = next;
 
-	    inputInfo.numDevices--;
-
-	    if (inputInfo.keyboard == tmp)
-	        inputInfo.keyboard = NULL;
-	    else if (inputInfo.pointer == tmp)
-	        inputInfo.pointer = NULL;
-
 	    ret = Success;
 	}
     }
@@ -572,13 +565,6 @@ RemoveDevice(DeviceIntPtr dev)
 	    else
 		prev->next = next;
 
-	    inputInfo.numDevices--;
-
-	    if (inputInfo.keyboard == tmp)
-	        inputInfo.keyboard = NULL;
-	    else if (inputInfo.pointer == tmp)
-	        inputInfo.pointer = NULL;
-
             ret = Success;
 	}
     }
diff-tree a31d11a7a8485cdc799f76c4d407d3b7f7c9b350 (from bedc4ecf23c7150e3156e0d24602ed3bc3977225)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 23:01:23 2006 +0300

    GKVE: get rid of bogus double-release check
    Get rid of a bogus double-release check which broke non-XKB servers.

diff --git a/dix/events.c b/dix/events.c
index 002b47d..e5ae3e6 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4727,14 +4727,6 @@ int GetKeyboardValuatorEvents(xEvent **x
                                                KeyRelease, key_code,
                                                num_valuators, valuators);
     }
-    else if (type == KeyRelease &&
-             !((pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
-#ifdef XKB
-             && noXkbExtension
-#endif
-             ) {
-        return;
-    }
 
     ev = (xEvent *)xcalloc(sizeof(xEvent), numEvents);
     if (!ev)
diff-tree bedc4ecf23c7150e3156e0d24602ed3bc3977225 (from baf93b3abe1e88d82ee6a3d6939f50f96ded271a)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 23:00:45 2006 +0300

    xephyr: aid input debugging
    Add the 'ephyr' mouse and keyboard drivers to the driver list so we can
    re-add devices.
    Set the names properly in Ephyr{Keyboard,Mouse}Init, not in InitInput.

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index d3c9bf9..7db8675 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -865,6 +865,7 @@ MouseInit (KdPointerInfo *pi)
     ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
     pi->nAxes = 3;
     pi->nButtons = 32;
+    pi->name = KdSaveString("Xephyr virtual mouse");
     ephyrMouse = pi;
     return Success;
 }
@@ -917,6 +918,7 @@ EphyrKeyboardInit (KdKeyboardInfo *ki)
   ki->maxScanCode = ki->keySyms.maxKeyCode;
   ki->keySyms.mapWidth = ephyrKeySyms.mapWidth;
   ki->keySyms.map = ephyrKeySyms.map;
+  ki->name = KdSaveString("Xephyr virtual keyboard");
   ephyrKbd = ki;
   return Success;
 }
diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index 021abd6..a77b87e 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -58,14 +58,14 @@ InitInput (int argc, char **argv)
   if (!ki)
     FatalError("Couldn't create Xephyr keyboard\n");
   ki->driver = &EphyrKeyboardDriver;
-  ki->name = KdSaveString("Xephyr virtual keyboard");
+  KdAddKeyboardDriver(&EphyrKeyboardDriver);
   KdAddKeyboard(ki);
 
   pi = KdNewPointer();
   if (!pi)
     FatalError("Couldn't create Xephyr pointer\n");
   pi->driver = &EphyrMouseDriver;
-  pi->name = KdSaveString("Xephyr virtual mouse");
+  KdAddPointerDriver(&EphyrMouseDriver);
   KdAddPointer(pi);
 
   KdInitInput();
diff-tree baf93b3abe1e88d82ee6a3d6939f50f96ded271a (from ccb53340b66a778abf10182fd88a7d699207fb84)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 21:12:45 2006 +0300

    kdrive: move map initialisation to KdNewPointer
    Do a linear n -> n initialisation on the map up until KD_MAX_BUTTON in
    KdNewPointer, moving it out of both KdParsePointer, and KdPointerProc.
    Also remove dead pointer acceleration code.

diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c
index 1d81ed3..1e03ac8 100644
--- a/hw/kdrive/src/kinfo.c
+++ b/hw/kdrive/src/kinfo.c
@@ -117,6 +117,7 @@ KdPointerInfo *
 KdNewPointer (void)
 {
     KdPointerInfo *pi;
+    int i;
 
     pi = (KdPointerInfo *)xcalloc(1, sizeof(KdPointerInfo));
     if (!pi)
@@ -130,6 +131,9 @@ KdNewPointer (void)
     pi->next = NULL;
     pi->options = NULL;
     pi->nAxes = 3;
+    pi->nButtons = KD_MAX_BUTTON;
+    for (i = 1; i < KD_MAX_BUTTON; i++)
+        pi->map[i] = i;
 
     return pi;
 }
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index e8a00dc..1718fda 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -433,9 +433,6 @@ KdPointerProc(DeviceIntPtr pDevice, int 
             return BadImplementation;
         }
 
-	for (i = 1; i <= pi->nButtons; i++)
-	    pi->map[i] = i; 
-
         if ((*pi->driver->Init) (pi) != Success) {
             return !Success;
         }
@@ -1156,9 +1153,6 @@ KdParsePointer (char *arg)
     pi->nButtons = 3;
     pi->inputClass = KD_MOUSE;
 
-    for (i = 0; i < KD_MAX_BUTTON; i++)
-        pi->map[i] = i + 1;
-
     if (!arg)
     {
         ErrorF("mouse: no arg\n");
@@ -1967,39 +1961,6 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo   
  * passed off to MI for enqueueing.
  */
 
-static void
-KdMouseAccelerate (KdPointerInfo *pi, int *dx, int *dy)
-{
-    DeviceIntPtr device = pi->dixdev;
-    PtrCtrl *pCtrl = &device->ptrfeed->ctrl;
-    double  speed = sqrt (*dx * *dx + *dy * *dy);
-    double  accel;
-#ifdef QUADRATIC_ACCELERATION
-    double  m;
-
-    /*
-     * Ok, so we want it moving num/den times faster at threshold*2
-     *
-     * accel = m *threshold + b
-     * 1 = m * 0 + b	-> b = 1
-     *
-     * num/den = m * (threshold * 2) + 1
-     *
-     * num / den - 1 = m * threshold * 2
-     * (num / den - 1) / threshold * 2 = m
-     */
-    m = (((double) pCtrl->num / (double) pCtrl->den - 1.0) / 
-	 ((double) pCtrl->threshold * 2.0));
-    accel = m * speed + 1;
-#else
-    accel = 1.0;
-    if (speed > pCtrl->threshold)
-	accel = (double) pCtrl->num / pCtrl->den;
-#endif
-    *dx = accel * *dx;
-    *dy = accel * *dy;
-}
-
 /* FIXME do something a little more clever to deal with multiple axes here */
 void
 KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
@@ -2028,9 +1989,6 @@ KdEnqueuePointerEvent(KdPointerInfo *pi,
 	    x = rx;
 	    y = ry;
 	}
-        /* screw this, use the DIX's acceleration (stolen from XFree86)
-         * instead.
-         * KdMouseAccelerate (pi, &x, &y); */
     }
     else {
 	if (pi->transformCoordinates) {
diff-tree ccb53340b66a778abf10182fd88a7d699207fb84 (from d1c18af27e0aed73104743afb4bf4b8d3d1186cf)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 21:12:00 2006 +0300

    ephyr: cleanup
    Remove extraneous KdAddPointerDriver call.

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 86a072d..d3c9bf9 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -866,7 +866,6 @@ MouseInit (KdPointerInfo *pi)
     pi->nAxes = 3;
     pi->nButtons = 32;
     ephyrMouse = pi;
-    KdAddPointerDriver(&EphyrMouseDriver);
     return Success;
 }
 
diff-tree d1c18af27e0aed73104743afb4bf4b8d3d1186cf (from 9b7ecbd1dd8d092221897e29c85f3306c7367716)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 21:11:38 2006 +0300

    GPE: use button map for DBP/DBR, not just BP/BR
    Make sure we use the button map for extended events, not just core.

diff --git a/dix/events.c b/dix/events.c
index f87e850..002b47d 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -5044,7 +5044,7 @@ GetPointerEvents(xEvent **xE, DeviceIntP
 #ifdef DEBUG
         ErrorF("GPE: detail is %d\n", buttons);
 #endif
-        kbp->detail = buttons;
+        kbp->detail = pDev->button->map[buttons];
     }
 
     if (num_valuators > 2 && (type == MotionNotify ||
diff-tree 9b7ecbd1dd8d092221897e29c85f3306c7367716 (from eb6e8d4042252b13328dbb122e0e6186796a80ac)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 21:09:32 2006 +0300

    kdrive: prevent overrun in map
    We actually need n + 1 elements for the mouse button map, not n.

diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index c9405b1..7e8712c 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -258,7 +258,7 @@ struct _KdPointerInfo {
     InputOption           *options;
     int                   inputClass;
 
-    CARD8                 map[KD_MAX_BUTTON];
+    CARD8                 map[KD_MAX_BUTTON + 1];
     int                   nButtons;
     int                   nAxes;
 
diff-tree eb6e8d4042252b13328dbb122e0e6186796a80ac (from afcad4ad99bbfc8bdcd0f4fdd70e072108410d30)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 21:05:37 2006 +0300

    kdrive: increase maximum number of buttons
    Increase KD_MAX_BUTTONS to 32.

diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 843f921..c9405b1 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -234,7 +234,7 @@ typedef enum _kdPointerState {
     num_input_states
 } KdPointerState;
 
-#define KD_MAX_BUTTON  16
+#define KD_MAX_BUTTON  32
 
 #define KD_KEYBOARD 1
 #define KD_MOUSE 2
diff-tree afcad4ad99bbfc8bdcd0f4fdd70e072108410d30 (from 98fdf874eeadd5b37413922d8afba8415d0c56bb)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 18:11:05 2006 +0300

    xfree86 ddx: always free GKE/GPE events
    free() events we get passed back from GKE and GPE so we don't just, er,
    leak them all.  *cough*.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index bcae3f0..91db82e 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -639,7 +639,7 @@ xf86PostMotionEvent(DeviceIntPtr	device,
     int i = 0, nevents = 0;
     Bool drag = xf86SendDragEvents(device);
     LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
-    xEvent *xE = NULL;
+    xEvent *events = NULL;
     int *valuators = NULL;
     int flags = 0;
 
@@ -662,14 +662,15 @@ xf86PostMotionEvent(DeviceIntPtr	device,
 #endif
     }
 
-    nevents = GetPointerEvents(&xE, device, MotionNotify, 0,
+    nevents = GetPointerEvents(&events, device, MotionNotify, 0,
                                flags, num_valuators, valuators);
 
     for (i = 0; i < nevents; i++) {
-        if (xE->u.keyButtonPointer.time > xf86Info.lastEventTime)
-            xf86Info.lastEventTime = xE->u.keyButtonPointer.time;
-        mieqEnqueue(xE++);
+        if (events->u.keyButtonPointer.time > xf86Info.lastEventTime)
+            xf86Info.lastEventTime = events->u.keyButtonPointer.time;
+        mieqEnqueue(events + i);
     }
+    xfree(events);
     
 #if 0
     if (HAS_MOTION_HISTORY(local)) {
@@ -818,8 +819,9 @@ xf86PostButtonEvent(DeviceIntPtr	device,
     for (i = 0; i < nevents; i++) {
         if (events->u.keyButtonPointer.time > xf86Info.lastEventTime)
             xf86Info.lastEventTime = events->u.keyButtonPointer.time;
-        mieqEnqueue(events++);
+        mieqEnqueue(events + i);
     }
+    xfree(events);
 }
 
 _X_EXPORT void
@@ -862,8 +864,9 @@ xf86PostKeyEvent(DeviceIntPtr	device,
     for (i = 0; i < nevents; i++) {
         if (events->u.keyButtonPointer.time > xf86Info.lastEventTime)
             xf86Info.lastEventTime = events->u.keyButtonPointer.time;
-        mieqEnqueue(events++);
+        mieqEnqueue(events + i);
     }
+    xfree(events);
 }
 
 _X_EXPORT void
@@ -885,8 +888,9 @@ xf86PostKeyboardEvent(DeviceIntPtr      
     for (i = 0; i < nevents; i++) {
         if (events->u.keyButtonPointer.time > xf86Info.lastEventTime)
             xf86Info.lastEventTime = events->u.keyButtonPointer.time;
-        mieqEnqueue(events++);
+        mieqEnqueue(events + i);
     }
+    xfree(events);
 }
 
 /* 
diff-tree 98fdf874eeadd5b37413922d8afba8415d0c56bb (from 5c7001fef8ffc6e3d8585a37d3f79a9495be8ed0)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 16:51:39 2006 +0300

    move all autorepeat logic to DIX
    Move core autorepeat logic for keyboards down to the DIX, remove it from
    KDrive.

diff --git a/dix/events.c b/dix/events.c
index 5d6b28b..f87e850 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4661,18 +4661,34 @@ WriteEventsToClient(ClientPtr pClient, i
     }
 }
 
+/**
+ * Convenience wrapper around GetKeyboardValuatorEvents, that takes no
+ * valuators.
+ */
 int
 GetKeyboardEvents(xEvent **xE, DeviceIntPtr pDev, int type, int key_code) {
     return GetKeyboardValuatorEvents(xE, pDev, type, key_code, 0, NULL);
 }
 
+/**
+ * Returns a set of keyboard events for KeyPress/KeyRelease, optionally
+ * also with valuator events.  Handles Xi and XKB.
+ *
+ * xE will be set to an array of events, which must be freed by the user;
+ * the return value is the number of events in xE, which is not
+ * NULL-terminated.
+ *
+ * Note that this function recurses!  If called for non-XKB, a repeating
+ * key press will trigger a matching KeyRelease, as well as the
+ * KeyPresses.
+ */
 int GetKeyboardValuatorEvents(xEvent **xE, DeviceIntPtr pDev, int type,
                               int key_code, int num_valuators,
                               int *valuators) {
-    int numEvents = 0, ms = 0, first_valuator = 0;
+    int numEvents = 0, numRepeatEvents = 0, ms = 0, first_valuator = 0, i = 0;
     deviceKeyButtonPointer *kbp = NULL;
     deviceValuator *xv = NULL;
-    xEvent *ev = NULL;
+    xEvent *ev = NULL, *repeatEvents = NULL;
     KeyClassPtr ckeyc;
 #ifdef XKB
     xkbNewKeyboardNotify nkn;
@@ -4693,10 +4709,44 @@ int GetKeyboardValuatorEvents(xEvent **x
     if (num_valuators)
         numEvents += (num_valuators % 6) + 1;
 
+    /* Handle core repeating, via press/release/press/release.
+     * FIXME: In theory, if you're repeating with two keyboards,
+     *        you could get unbalanced events here. */
+    if (type == KeyPress &&
+        ((pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
+#ifdef XKB
+       && noXkbExtension
+#endif
+       ) {
+        if (!pDev->kbdfeed->ctrl.autoRepeat ||
+            pDev->key->modifierMap[key_code] ||
+            !(pDev->kbdfeed->ctrl.autoRepeats[key_code >> 3]
+                & (1 << (key_code & 7))))
+            return 0;
+        numEvents += GetKeyboardValuatorEvents(&repeatEvents, pDev,
+                                               KeyRelease, key_code,
+                                               num_valuators, valuators);
+    }
+    else if (type == KeyRelease &&
+             !((pDev->key->down[key_code >> 3] & (key_code & 7)) & 1)
+#ifdef XKB
+             && noXkbExtension
+#endif
+             ) {
+        return;
+    }
+
     ev = (xEvent *)xcalloc(sizeof(xEvent), numEvents);
     if (!ev)
         return 0;
 
+    if (repeatEvents) {
+        for (i = 0; i < numRepeatEvents; i++) {
+            ev = repeatEvents++;
+            ev++;
+        }
+    }
+
     *xE = ev;
     ms = GetTimeInMillis();
 
@@ -4791,7 +4841,7 @@ int GetKeyboardValuatorEvents(xEvent **x
     }
 
 #ifdef DEBUG
-    ErrorF("GKE: putting out %d events with detail %d\n", numEvents, key_code);
+    ErrorF("GKVE: putting out %d events with detail %d\n", numEvents, key_code);
 #endif
 
     return numEvents;
@@ -4855,6 +4905,13 @@ acceleratePointer(DeviceIntPtr pDev, int
     }
 }
 
+/**
+ * Generate a series of xEvents (returned in xE) representing pointer
+ * motion, or button presses.  Xi and XKB-aware.
+ *
+ * xE is not NULL-terminated; the return value is the number of events.
+ * The user is responsible for freeing these events.
+ */
 int
 GetPointerEvents(xEvent **xE, DeviceIntPtr pDev, int type, int buttons,
                  int flags, int num_valuators, int *valuators) {
@@ -4990,9 +5047,6 @@ GetPointerEvents(xEvent **xE, DeviceIntP
         kbp->detail = buttons;
     }
 
-    /* XXX: the spec says that Device{Key,Button}{Press,Release} events
-     * for relative devices shouldn't contain valuators since only the
-     * state field will have meaning, but I don't see why. */
     if (num_valuators > 2 && (type == MotionNotify ||
                               flags & POINTER_ABSOLUTE)) {
         kbp->deviceid |= MORE_EVENTS;
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 6d33c31..e8a00dc 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -1943,34 +1943,6 @@ KdEnqueueKeyboardEvent(KdKeyboardInfo   
 		type = KeyPress;
 	}
 	
-	/*
-	 * Check pressed keys which are already down
-	 */
-	if (IsKeyDown (ki, key_code) && type == KeyPress) {
-	    /*
-	     * Check auto repeat
-	     */
-	    if (!ctrl->autoRepeat || keyc->modifierMap[key_code] ||
-		!(ctrl->autoRepeats[key_code >> 3] & (1 << (key_code & 7))))
-		return;
-
-	    /*
-	     * X delivers press/release even for autorepeat
-	     */
-            nEvents = GetKeyboardEvents(&xE, ki->dixdev, KeyRelease, key_code);
-            for (i = 0; i < nEvents; i++)
-                KdQueueEvent(xE++);
-            nEvents = GetKeyboardEvents(&xE, ki->dixdev, KeyPress, key_code);
-            for (i = 0; i < nEvents; i++)
-                KdQueueEvent(xE++);
-	}
-	/*
-	 * Check released keys which are already up
-	 */
-	else if (!IsKeyDown (ki, key_code) && type == KeyRelease) {
-	    return;
-        }
-
         KdCheckSpecialKeys(ki, type, key_code);
         KdHandleKeyboardEvent(ki, type, key_code);
         nEvents = GetKeyboardEvents(&xE, ki->dixdev, type, key_code);
diff-tree 5c7001fef8ffc6e3d8585a37d3f79a9495be8ed0 (from c85e64cba1d2d88f676ca7cf23b52a6f8219e90e)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 16:51:09 2006 +0300

    memcpy() events in
    memcpy events into our event structure instead of doing pointer assignment.

diff --git a/mi/mieq.c b/mi/mieq.c
index 0d9dcb8..3d44ee7 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -51,7 +51,7 @@ in this Software without prior written a
 #define QUEUE_SIZE  256
 
 typedef struct _Event {
-    xEvent          event[2];
+    xEvent          event[7];
     int             nevents;
     ScreenPtr	    pScreen;
     DeviceIntPtr    pDev;
@@ -101,6 +101,7 @@ mieqEnqueue (xEvent *e)
 
 #ifdef DEBUG
     ErrorF("mieqEnqueue: slamming an event on to the queue from %d\n", kbp->deviceid & DEVICE_BITS);
+    ErrorF("    type %d, detail %d\n", e->u.u.type, e->u.u.detail);
 #endif
 
     if (e->u.u.type == MotionNotify) {
@@ -122,9 +123,8 @@ mieqEnqueue (xEvent *e)
         /* We silently steal valuator events: just tack them on to the last
          * motion event they need to be attached to.  Sigh. */
         if (e->u.u.type == DeviceValuator) {
-            if (laste->nevents >= 6) {
+            if (laste->nevents > 6) {
                 ErrorF("mieqEnqueue: more than six valuator events; dropping.\n");
-                free(e);
                 return;
             }
             if (oldtail == miEventQueue.head || 
@@ -134,10 +134,9 @@ mieqEnqueue (xEvent *e)
                 ((lastkbp->deviceid & DEVICE_BITS) !=
                  (v->deviceid & DEVICE_BITS))) {
                 ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n");
-                free(e);
                 return;
             }
-            laste->event[laste->nevents++] = *e;
+            memcpy(&(laste->event[laste->nevents++]), e, sizeof(xEvent));
             return;
         }
         else if (e->u.u.type == DeviceMotionNotify) {
@@ -161,13 +160,12 @@ mieqEnqueue (xEvent *e)
     	/* Toss events which come in late */
     	if (newtail == miEventQueue.head) {
             ErrorF("tossed event which came in late\n");
-            free(e);
 	    return;
         }
 	miEventQueue.tail = newtail;
     }
 
-    miEventQueue.events[oldtail].event[0] = *e;
+    memcpy(&(miEventQueue.events[oldtail].event[0]), e, sizeof(xEvent));
     miEventQueue.events[oldtail].nevents = 1;
 
     /*
@@ -238,7 +236,5 @@ void mieqProcessInputEvents ()
 	    	++miEventQueue.head;
             (*e->pDev->public.processInputProc)(e->event, e->pDev, e->nevents);
 	}
-
-        free(e->event);
     }
 }
diff-tree c85e64cba1d2d88f676ca7cf23b52a6f8219e90e (from parents)
Merge: a406f6bfeaa46e3236f7ab46813fe6c30b936a35 f54b71b772a1f587394ae3968782b611e52f0e2d
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Mon Aug 7 15:54:55 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree a406f6bfeaa46e3236f7ab46813fe6c30b936a35 (from 997ba45b192f21810099ed888792a45f1677a9ce)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Aug 4 12:40:19 2006 +0300

    mieq: don't leak events
    free all events posted through mieqEnqueue.

diff --git a/mi/mieq.c b/mi/mieq.c
index 8dbf166..0d9dcb8 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -124,6 +124,7 @@ mieqEnqueue (xEvent *e)
         if (e->u.u.type == DeviceValuator) {
             if (laste->nevents >= 6) {
                 ErrorF("mieqEnqueue: more than six valuator events; dropping.\n");
+                free(e);
                 return;
             }
             if (oldtail == miEventQueue.head || 
@@ -133,6 +134,7 @@ mieqEnqueue (xEvent *e)
                 ((lastkbp->deviceid & DEVICE_BITS) !=
                  (v->deviceid & DEVICE_BITS))) {
                 ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n");
+                free(e);
                 return;
             }
             laste->event[laste->nevents++] = *e;
@@ -159,6 +161,7 @@ mieqEnqueue (xEvent *e)
     	/* Toss events which come in late */
     	if (newtail == miEventQueue.head) {
             ErrorF("tossed event which came in late\n");
+            free(e);
 	    return;
         }
 	miEventQueue.tail = newtail;
@@ -235,5 +238,7 @@ void mieqProcessInputEvents ()
 	    	++miEventQueue.head;
             (*e->pDev->public.processInputProc)(e->event, e->pDev, e->nevents);
 	}
+
+        free(e->event);
     }
 }
diff-tree 997ba45b192f21810099ed888792a45f1677a9ce (from 87fe85f38b6f781bf0e2eb555526e3d77779f9fa)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Aug 4 11:18:16 2006 +0300

    fix incorrect button test
    Test for n (1..nButtons) being under nButtons, not button (1..(1<<nButtons)).

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index f072ef1..6d33c31 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2087,7 +2087,7 @@ KdEnqueuePointerEvent(KdPointerInfo *pi,
 
     buttons = flags;
 
-    for (button = KD_BUTTON_1, n = 1; button <= pi->nButtons;
+    for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons;
          button <<= 1, n++) {
         if (((pi->buttonState & button) ^ (buttons & button)) &&
            !(buttons & button)) {
@@ -2098,7 +2098,7 @@ KdEnqueuePointerEvent(KdPointerInfo *pi,
                                    dixflags, FALSE);
 	}
     }
-    for (button = KD_BUTTON_1, n = 1; button <= pi->nButtons;
+    for (button = KD_BUTTON_1, n = 1; n <= pi->nButtons;
          button <<= 1, n++) {
 	if (((pi->buttonState & button) ^ (buttons & button)) &&
 	    (buttons & button)) {
diff-tree 87fe85f38b6f781bf0e2eb555526e3d77779f9fa (from parents)
Merge: 3518e2d0debc97e2bacdefe604b280e7fdfdd216 654619d76c779606f2315782fc01d1410399fa3b
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Jul 30 10:51:34 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff --cc hw/xfree86/common/Makefile.am
index 090112c,d983ee9..57493f3
@@@ -30,9 -32,9 +30,9 @@@
  
  AM_LDFLAGS = -r
  libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \
-                       xf86Cursor.c xf86DGA.c xf86DPMS.c \
+                       xf86Cursor.c xf86cvt.c xf86DGA.c xf86DPMS.c \
                        xf86DoProbe.c xf86DoScanPci.c xf86Events.c \
 -                      xf86Globals.c xf86Io.c xf86AutoConfig.c \
 +                      xf86Globals.c xf86AutoConfig.c \
                        xf86MiscExt.c xf86Option.c \
                        xf86VidMode.c xf86fbman.c xf86cmap.c \
                        xf86Helper.c xf86PM.c \
diff-tree 3518e2d0debc97e2bacdefe604b280e7fdfdd216 (from parents)
Merge: eb7733a48a92405660d5d2ab60913b62c30daaed 3821f6aeaa714582ee0a631de96c6e7cfd96303e
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Jul 26 11:29:21 2006 +0300

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree eb7733a48a92405660d5d2ab60913b62c30daaed (from 4ea475924c557ad0819b796f5369e5e669465709)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Jul 26 11:28:45 2006 +0300

    kdrive: drop excessive NewInputDeviceRequest debugging

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index d46694f..f072ef1 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2420,8 +2420,6 @@ NewInputDeviceRequest(InputOption *optio
     KdPointerInfo *pi = NULL;
     KdKeyboardInfo *ki = NULL;
 
-    ErrorF("handling NIDR\n");
-
     for (option = options; option; option = option->next) {
         if (strcmp(option->key, "type") == 0) {
             if (strcmp(option->value, "pointer") == 0) {
@@ -2481,6 +2479,4 @@ NewInputDeviceRequest(InputOption *optio
             return BadImplementation;
         }
     }
-
-    ErrorF("done handling NIDR\n");
 }
diff-tree 4ea475924c557ad0819b796f5369e5e669465709 (from ca3f4fc1b0c21a0620ab1eb35c199cd55d795095)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Tue Jul 25 20:00:48 2006 +0300

    re-add OpenedHand copyright
    Ae-add OpenedHand copyright, accidentally dropped in KDrive new world
    order patch.  Sorry guys.

diff --git a/hw/kdrive/linux/tslib.c b/hw/kdrive/linux/tslib.c
index aa57e87..bf2a3db 100644
--- a/hw/kdrive/linux/tslib.c
+++ b/hw/kdrive/linux/tslib.c
@@ -7,6 +7,7 @@
  * Copyright © 1999 Keith Packard
  * Copyright © 2000 Compaq Computer Corporation
  * Copyright © 2002 MontaVista Software Inc.
+ * Copyright © 2005 OpenedHand Ltd.
  * Copyright © 2006 Nokia Corporation
  * 
  * Permission to use, copy, modify, distribute, and sell this software and its
diff-tree ca3f4fc1b0c21a0620ab1eb35c199cd55d795095 (from e73e5e2a4d8f22889d840a7719479f9af686cb9c)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sun Jul 23 19:02:12 2006 -0400

    add fallback ChangeDeviceControl, allow XOpenDevice on closed device
    Add a fallback ChangeDeviceControl, which allows the attributes we know about
    so far.
    Allow XOpenDevice on closed devices.

diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 3082e39..bcae3f0 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -288,18 +288,21 @@ OpenInputDevice(DeviceIntPtr	dev,
                 ClientPtr	client,
                 int		*status)
 {
-    if (!dev->inited) {
-        *status = BadDevice;
-    } else {
-        if (!dev->public.on) {
-            if (EnableDevice(dev)) {
-                /* to prevent ProcXOpenDevice to call EnableDevice again */
-                dev->startup = FALSE;
-            } else {
-                *status = BadDevice;
-            }
+    if (!dev->inited)
+        ActivateDevice(dev);
+
+    if (!dev->public.on) {
+        if (EnableDevice(dev)) {
+            dev->startup = FALSE;
+        }
+        else {
+            ErrorF("couldn't enable device %s\n", dev->name);
+            *status = BadDevice;
+            return;
         }
     }
+
+    *status = Success;
 }
 
 
@@ -530,7 +533,14 @@ ChangeDeviceControl (ClientPtr client, D
   LocalDevicePtr        local = (LocalDevicePtr)dev->public.devicePrivate;
 
   if (!local->control_proc) {
-      return (BadMatch);
+      switch (control->control) {
+      case DEVICE_CORE:
+      case DEVICE_RESOLUTION:
+      case DEVICE_TOUCHSCREEN:
+        return Success;
+      default:
+        return BadMatch;
+      }
   }
   else {
       return (*local->control_proc)(local, control);
diff-tree e73e5e2a4d8f22889d840a7719479f9af686cb9c (from parents)
Merge: a73cef1f005ca66db18e952e676ee5a21b829700 8977b07434d75ca396d236dc1324f0c862b633c7
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Jul 22 13:56:30 2006 -0400

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree a73cef1f005ca66db18e952e676ee5a21b829700 (from parents)
Merge: 672ca156bfb11440e6e234650bfba9d38e1edb52 70869fc6777f87cd05794446caa739e3d9a91ffe
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Sat Jul 22 12:07:22 2006 -0400

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree 672ca156bfb11440e6e234650bfba9d38e1edb52 (from parents)
Merge: d14d91f094c3897c889f6aafb66d738820dae0aa 6cf844ab69926b6d23619a12c97734af3881ba67
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Jul 21 19:58:42 2006 -0400

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree d14d91f094c3897c889f6aafb66d738820dae0aa (from 87a6346bf7f086b5f98b2b2ecd52f27efe864e56)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Jul 21 19:57:28 2006 -0400

    loader: walk directory paths with readdir(), don't stat() everything
    Walk the directories with readdir, and don't stat everything we can
    find.  Thanks to davej for the public humiliation reminding me to go back
    and re-fix this one.

diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index fd84a92..53dcffe 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -389,23 +389,65 @@ FreeSubdirs(const char **subdirs)
 }
 
 static char *
-FindModule(const char *module, const char *dir, const char **subdirlist,
+FindModuleInSubdir(const char *dirpath, const char *module)
+{
+    struct dirent *direntry = NULL;
+    DIR *dir = NULL;
+    char *ret = NULL, tmpBuf[PATH_MAX];
+    struct stat stat_buf;
+
+    dir = opendir(dirpath);
+    if (!dir)
+        return NULL;
+
+    while ((direntry = readdir(dir))) {
+        if (direntry->d_name[0] == '.')
+            continue;
+        if ((stat(direntry->d_name, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) {
+            snprintf(tmpBuf, PATH_MAX, "%s/%s", dirpath, direntry->d_name);
+            if ((ret = FindModuleInSubdir(tmpBuf, module)))
+                break;
+            continue;
+        }
+ 
+        snprintf(tmpBuf, PATH_MAX, "lib%s.so", module);
+        if (strcmp(direntry->d_name, tmpBuf) == 0) {
+            ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2);
+            sprintf(ret, "%s/%s", dirpath, tmpBuf);
+            break;
+        }
+
+        snprintf(tmpBuf, PATH_MAX, "%s_drv.so", module);
+        if (strcmp(direntry->d_name, tmpBuf) == 0) {
+            ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2);
+            sprintf(ret, "%s/%s", dirpath, tmpBuf);
+            break;
+        }
+
+        snprintf(tmpBuf, PATH_MAX, "%s.so", module);
+        if (strcmp(direntry->d_name, tmpBuf) == 0) {
+            ret = malloc(strlen(tmpBuf) + strlen(dirpath) + 2);
+            sprintf(ret, "%s/%s", dirpath, tmpBuf);
+            break;
+        }
+    }
+    
+    closedir(dir);
+    return ret;
+}
+
+static char *
+FindModule(const char *module, const char *dirname, const char **subdirlist,
 	   PatternPtr patterns)
 {
-    char buf[PATH_MAX + 1], tmpBuf[PATH_MAX + 1];
+    char buf[PATH_MAX + 1];
     char *dirpath = NULL;
     char *name = NULL;
-    struct stat stat_buf;
     int dirlen;
     const char **subdirs = NULL;
     const char **s;
 
-#ifndef __EMX__
-    dirpath = (char *)dir;
-#else
-    dirpath = xalloc(strlen(dir) + 10);
-    strcpy(dirpath, (char *)__XOS2RedirRoot(dir));
-#endif
+    dirpath = (char *)dirname;
     if (strlen(dirpath) > PATH_MAX)
 	return NULL;
     
@@ -418,38 +460,15 @@ FindModule(const char *module, const cha
 	    continue;
 	strcpy(buf, dirpath);
 	strcat(buf, *s);
-        if ((stat(buf, &stat_buf) == 0) && S_ISDIR(stat_buf.st_mode)) {
-            if (buf[dirlen - 1] != '/') {
-                buf[dirlen++] = '/';
-            }
-	    
-            snprintf(tmpBuf, PATH_MAX, "%slib%s.so", buf, module);
-            if (stat(tmpBuf, &stat_buf) == 0) {
-                name = tmpBuf;
-                break;
-            }
-
-            snprintf(tmpBuf, PATH_MAX, "%s%s_drv.so", buf, module);
-            if (stat(tmpBuf, &stat_buf) == 0) {
-                name = tmpBuf;
-                break;
-            }
-
-            snprintf(tmpBuf, PATH_MAX, "%s%s.so", buf, module);
-            if (stat(tmpBuf, &stat_buf) == 0) {
-                name = tmpBuf;
-                break;
-            }
-        }
+        if ((name = FindModuleInSubdir(buf, module)))
+            break;
     }
+
     FreeSubdirs(subdirs);
-    if (dirpath != dir)
+    if (dirpath != dirname)
 	xfree(dirpath);
 
-    if (name) {
-	return xstrdup(name);
-    }
-    return NULL;
+    return name;
 }
 
 _X_EXPORT char **
diff-tree 87a6346bf7f086b5f98b2b2ecd52f27efe864e56 (from parents)
Merge: b73fb2ae35a82e0bdd48f01132e971fb84946ff1 0486d3966d2888ef86d36c19f31bdbc2a3e8c652
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Jul 21 19:36:25 2006 -0400

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff --cc configure.ac
index 456b8b5,f8aa32a..a20237c
@@@ -515,21 -509,9 +515,21 @@@
  XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
  
  dnl Core modules for most extensions, et al.
- REQUIRED_MODULES="randrproto renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto xproto xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4]"
 -REQUIRED_MODULES="randrproto renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto xproto xtrans xf86miscproto xf86vidmodeproto xf86bigfontproto [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto inputproto xf86dgaproto [kbproto >= 1.0.3]"
++REQUIRED_MODULES="randrproto renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto xproto xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4] [kbproto >= 1.0.3]"
  REQUIRED_LIBS="xfont xau fontenc"
  
 +if test "x$DBUS" = xauto; then
 +       PKG_CHECK_MODULES(DBUS, dbus-1, [DBUS=yes], [DBUS=no])
 +fi
 +if test "x$DBUS" = xyes; then
 +       PKG_CHECK_MODULES(DBUS, dbus-1)
 +       AC_DEFINE(HAVE_DBUS, 1, [Have D-BUS support])
 +       REQUIRED_MODULES="$REQUIRED_MODULES dbus-1"
 +       REQUIRED_LIBS="$REQUIRED_LIBS dbus-1"
 +fi
 +CONFIG_LIB='$(top_builddir)/config/libconfig.a'
 +AM_CONDITIONAL(DBUS, [test "x$DBUS" = xyes])
 +
  AM_CONDITIONAL(XV, [test "x$XV" = xyes])
  if test "x$XV" = xyes; then
  	AC_DEFINE(XV, 1, [Support Xv extension])
diff-tree b73fb2ae35a82e0bdd48f01132e971fb84946ff1 (from parents)
Merge: e7ac27ad81efbea6128b3cec443ca98e228d14ad aff404f293ed86a44a093a51a9f11e79e6c3f4f6
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Jul 21 19:30:26 2006 -0400

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree e7ac27ad81efbea6128b3cec443ca98e228d14ad (from 81913a12910e39d7ea6af8657c1c66cc6791cd65)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Jul 21 19:29:28 2006 -0400

    revert accidental deletion of lnx_io.c; re-delete lnx_kbd.c
    Thinko'd which file to remove after merging from master.

diff --git a/hw/xfree86/os-support/linux/lnx_io.c b/hw/xfree86/os-support/linux/lnx_io.c
deleted file mode 100644
index 836aaa1..0000000
--- a/hw/xfree86/os-support/linux/lnx_io.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * 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.
- *
- */
-/* $XConsortium: lnx_io.c /main/8 1996/10/19 18:06:28 kaleb $ */
-
-#define NEED_EVENTS
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#define KBC_TIMEOUT 250        /* Timeout in ms for sending to keyboard controller */
-
-_X_EXPORT void
-xf86SoundKbdBell(int loudness, int pitch, int duration)
-{
-	if (loudness && pitch)
-	{
-		ioctl(xf86Info.consoleFd, KDMKTONE,
-		      ((1193190 / pitch) & 0xffff) |
-		      (((unsigned long)duration *
-			loudness / 50) << 16));
-	}
-}
-
-void
-xf86SetKbdLeds(int leds)
-{
- 	ioctl(xf86Info.consoleFd, KDSETLED, leds);
-}
-
-int
-xf86GetKbdLeds()
-{
-	int leds = 0;
-
- 	ioctl(xf86Info.consoleFd, KDGETLED, &leds);
-	return(leds);
-}
-
-static int
-KDKBDREP_ioctl_ok(int rate, int delay) {
-#if defined(KDKBDREP) && !defined(__sparc__)
-     /* This ioctl is defined in <linux/kd.h> but is not
-	implemented anywhere - must be in some m68k patches. */
-   struct kbd_repeat kbdrep_s;
-
-   /* don't change, just test */
-   kbdrep_s.LNX_KBD_PERIOD_NAME = -1;
-   kbdrep_s.delay = -1;
-   if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
-       return 0;
-   }
-   /* do the change */
-   if (rate == 0)				/* switch repeat off */
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 0;
-   else
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 10000 / rate; /* convert cps to msec */
-   if (kbdrep_s.LNX_KBD_PERIOD_NAME < 1)
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 1;
-   kbdrep_s.delay = delay;
-   if (kbdrep_s.delay < 1)
-     kbdrep_s.delay = 1;
-   
-   if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
-     return 0;
-   }
-
-   return 1;			/* success! */
-#else /* no KDKBDREP */
-   return 0;
-#endif /* KDKBDREP */
-}
-
-static int
-KIOCSRATE_ioctl_ok(int rate, int delay) {
-#ifdef KIOCSRATE
-   struct kbd_rate kbdrate_s;
-   int fd;
-
-   fd = open("/dev/kbd", O_RDONLY);
-   if (fd == -1) 
-     return 0;   
-
-   kbdrate_s.rate = (rate + 5) / 10;  /* must be integer, so round up */
-   kbdrate_s.delay = delay * HZ / 1000;  /* convert ms to Hz */
-   if (kbdrate_s.rate > 50)
-     kbdrate_s.rate = 50;
-
-   if (ioctl( fd, KIOCSRATE, &kbdrate_s )) {
-       return 0;
-   }
-
-   close( fd );
-
-   return 1;
-#else /* no KIOCSRATE */
-   return 0;
-#endif /* KIOCSRATE */
-}
-
-void xf86SetKbdRepeat(char rad)
-{
-#ifdef __sparc__
-  int         rate  = 500;     /* Default rate */
-  int         delay = 200;     /* Default delay */
-#else
-  int         rate  = 300;     /* Default rate */
-  int         delay = 250;     /* Default delay */
-#endif
-
-#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
-  int i;
-  int timeout;
-  int         value = 0x7f;    /* Maximum delay with slowest rate */
-
-  static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
-			       133, 120, 109, 100, 92, 86, 80, 75, 67,
-			       60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
-			       25, 23, 21, 20 };
-#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
-
-  static int valid_delays[] = { 250, 500, 750, 1000 };
-#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
-#endif
-
-  if (xf86Info.kbdRate >= 0) 
-    rate = xf86Info.kbdRate * 10;
-  if (xf86Info.kbdDelay >= 0)
-    delay = xf86Info.kbdDelay;
-
-  if(KDKBDREP_ioctl_ok(rate, delay)) 	/* m68k? */
-    return;
-
-  if(KIOCSRATE_ioctl_ok(rate, delay))	/* sparc? */
-    return;
-
-  if (xf86IsPc98())
-    return;
-
-#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
-
-  /* The ioport way */
-
-  for (i = 0; i < RATE_COUNT; i++)
-    if (rate >= valid_rates[i]) {
-      value &= 0x60;
-      value |= i;
-      break;
-    }
-
-  for (i = 0; i < DELAY_COUNT; i++)
-    if (delay <= valid_delays[i]) {
-      value &= 0x1f;
-      value |= i << 5;
-      break;
-    }
-
-  timeout = KBC_TIMEOUT;
-  while (((inb(0x64) & 2) == 2) && --timeout)
-       usleep(1000); /* wait */
-
-  if (timeout == 0)
-      return;
-
-  outb(0x60, 0xf3);             /* set typematic rate */
-  while (((inb(0x64) & 2) == 2) && --timeout)
-       usleep(1000); /* wait */
-
-  usleep(10000);
-  outb(0x60, value);
-
-#endif /* __alpha__ || __i386__ || __ia64__ */
-}
-
-static int kbdtrans;
-static struct termios kbdtty;
-
-void
-xf86KbdInit()
-{
-	ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
-	tcgetattr (xf86Info.consoleFd, &kbdtty);
-}
-
-int
-xf86KbdOn()
-{
-	struct termios nTty;
-
-#ifdef __powerpc__
-	if (xf86Info.kbdCustomKeycodes)
-		ioctl(xf86Info.consoleFd, KDSKBMODE, K_MEDIUMRAW);
-	else
-#endif
-	ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
-
-	nTty = kbdtty;
-	nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
-	nTty.c_oflag = 0;
-	nTty.c_cflag = CREAD | CS8;
-	nTty.c_lflag = 0;
-	nTty.c_cc[VTIME]=0;
-	nTty.c_cc[VMIN]=1;
-	cfsetispeed(&nTty, 9600);
-	cfsetospeed(&nTty, 9600);
-	tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
-	return(xf86Info.consoleFd);
-}
-
-int
-xf86KbdOff()
-{
-	ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans);
-	tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
-	return(xf86Info.consoleFd);
-}
-
diff --git a/hw/xfree86/os-support/linux/lnx_kbd.c b/hw/xfree86/os-support/linux/lnx_kbd.c
new file mode 100644
index 0000000..a4890d2
--- /dev/null
+++ b/hw/xfree86/os-support/linux/lnx_kbd.c
@@ -0,0 +1,530 @@
+
+/*
+ * Copyright (c) 2002 by The XFree86 Project, Inc.
+ * Author: Ivan Pascal.
+ *
+ * Based on the code from lnx_io.c which is
+ * Copyright 1992 by Orest Zborowski <obz at Kodak.com>
+ * Copyright 1993 by David Dawes <dawes at xfree86.org>
+ */
+
+#define NEED_EVENTS
+#ifdef HAVE_XORG_CONFIG_H
+#include <xorg-config.h>
+#endif
+
+#include <X11/X.h>
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include "xf86Xinput.h"
+#include "xf86OSKbd.h"
+#include "atKeynames.h"
+#if defined(DO_OS_FONTRESTORE)
+#include "lnx.h"
+#endif
+#include "lnx_kbd.h"
+
+#define KBC_TIMEOUT 250        /* Timeout in ms for sending to keyboard controller */
+
+static KbdProtocolRec protocols[] = {
+   {"standard", PROT_STD },
+   { NULL, PROT_UNKNOWN_KBD }
+};
+
+extern Bool VTSwitchEnabled;
+#ifdef USE_VT_SYSREQ
+extern Bool VTSysreqToggle;
+#endif
+
+static void
+SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
+{
+	if (loudness && pitch)
+	{
+		ioctl(pInfo->fd, KDMKTONE,
+		      ((1193190 / pitch) & 0xffff) |
+		      (((unsigned long)duration *
+			loudness / 50) << 16));
+	}
+}
+
+static void
+SetKbdLeds(InputInfoPtr pInfo, int leds)
+{
+    int real_leds = 0;
+
+#if defined (__sparc__)
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    if (pKbd->sunKbd) {
+  	if (leds & 0x08) real_leds |= XLED1;
+  	if (leds & 0x04) real_leds |= XLED3;
+  	if (leds & 0x02) real_leds |= XLED4;
+  	if (leds & 0x01) real_leds |= XLED2;
+        leds = real_leds;
+        real_leds = 0;
+    }
+#endif /* defined (__sparc__) */
+#ifdef LED_CAP
+    if (leds & XLED1)  real_leds |= LED_CAP;
+    if (leds & XLED2)  real_leds |= LED_NUM;
+    if (leds & XLED3)  real_leds |= LED_SCR;
+#ifdef LED_COMP
+    if (leds & XLED4)  real_leds |= LED_COMP;
+#else
+    if (leds & XLED4)  real_leds |= LED_SCR;
+#endif
+#endif
+    ioctl(pInfo->fd, KDSETLED, real_leds);
+}
+
+static int
+GetKbdLeds(InputInfoPtr pInfo)
+{
+    int real_leds, leds = 0;
+
+    ioctl(pInfo->fd, KDGETLED, &real_leds);
+
+    if (real_leds & LED_CAP) leds |= XLED1;
+    if (real_leds & LED_NUM) leds |= XLED2;
+    if (real_leds & LED_SCR) leds |= XLED3;
+
+    return(leds);
+}
+
+static int
+KDKBDREP_ioctl_ok(int rate, int delay) {
+#if defined(KDKBDREP) && !defined(__sparc__)
+     /* This ioctl is defined in <linux/kd.h> but is not
+	implemented anywhere - must be in some m68k patches. */
+   struct kbd_repeat kbdrep_s;
+
+   /* don't change, just test */
+   kbdrep_s.LNX_KBD_PERIOD_NAME = -1;
+   kbdrep_s.delay = -1;
+   if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
+       return 0;
+   }
+
+   /* do the change */
+   if (rate == 0)				/* switch repeat off */
+     kbdrep_s.LNX_KBD_PERIOD_NAME = 0;
+   else
+     kbdrep_s.LNX_KBD_PERIOD_NAME = 10000 / rate; /* convert cps to msec */
+   if (kbdrep_s.LNX_KBD_PERIOD_NAME < 1)
+     kbdrep_s.LNX_KBD_PERIOD_NAME = 1;
+   kbdrep_s.delay = delay;
+   if (kbdrep_s.delay < 1)
+     kbdrep_s.delay = 1;
+   
+   if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
+       return 0;
+   }
+
+   return 1;			/* success! */
+#else /* no KDKBDREP */
+   return 0;
+#endif /* KDKBDREP */
+}
+
+static int
+KIOCSRATE_ioctl_ok(int rate, int delay) {
+#ifdef KIOCSRATE
+   struct kbd_rate kbdrate_s;
+   int fd;
+
+   fd = open("/dev/kbd", O_RDONLY);
+   if (fd == -1) 
+     return 0;   
+
+   kbdrate_s.rate = (rate + 5) / 10;  /* must be integer, so round up */
+   kbdrate_s.delay = delay * HZ / 1000;  /* convert ms to Hz */
+   if (kbdrate_s.rate > 50)
+     kbdrate_s.rate = 50;
+
+   if (ioctl( fd, KIOCSRATE, &kbdrate_s )) {
+       return 0;
+   }
+
+   close( fd );
+
+   return 1;
+#else /* no KIOCSRATE */
+   return 0;
+#endif /* KIOCSRATE */
+}
+
+#undef rate
+
+static void
+SetKbdRepeat(InputInfoPtr pInfo, char rad)
+{
+  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+  int i;
+  int timeout;
+  int         value = 0x7f;    /* Maximum delay with slowest rate */
+
+#ifdef __sparc__
+  int         rate  = 500;     /* Default rate */
+  int         delay = 200;     /* Default delay */
+#else
+  int         rate  = 300;     /* Default rate */
+  int         delay = 250;     /* Default delay */
+#endif
+
+  static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
+			       133, 120, 109, 100, 92, 86, 80, 75, 67,
+			       60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
+			       25, 23, 21, 20 };
+#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
+
+  static int valid_delays[] = { 250, 500, 750, 1000 };
+#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
+
+  if (pKbd->rate >= 0) 
+    rate = pKbd->rate * 10;
+  if (pKbd->delay >= 0)
+    delay = pKbd->delay;
+
+  if(KDKBDREP_ioctl_ok(rate, delay)) 	/* m68k? */
+    return;
+
+  if(KIOCSRATE_ioctl_ok(rate, delay))	/* sparc? */
+    return;
+
+  if (xf86IsPc98())
+    return;
+
+#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
+
+  if (!xorgHWAccess) {
+      if (xf86EnableIO())
+	  xorgHWAccess = TRUE;
+      else 
+	  return;
+  }
+      
+  /* The ioport way */
+
+  for (i = 0; i < RATE_COUNT; i++)
+    if (rate >= valid_rates[i]) {
+      value &= 0x60;
+      value |= i;
+      break;
+    }
+
+  for (i = 0; i < DELAY_COUNT; i++)
+    if (delay <= valid_delays[i]) {
+      value &= 0x1f;
+      value |= i << 5;
+      break;
+    }
+
+  timeout = KBC_TIMEOUT;
+  while (((inb(0x64) & 2) == 2) && --timeout)
+       usleep(1000); /* wait */
+
+  if (timeout == 0)
+      return;
+
+  outb(0x60, 0xf3);             /* set typematic rate */
+  while (((inb(0x64) & 2) == 2) && --timeout)
+       usleep(1000); /* wait */
+
+  usleep(10000);
+  outb(0x60, value);
+
+#endif /* __alpha__ || __i386__ || __ia64__ */
+}
+
+typedef struct {
+   int kbdtrans;
+   struct termios kbdtty;
+} LnxKbdPrivRec, *LnxKbdPrivPtr;
+
+static int
+KbdInit(InputInfoPtr pInfo, int what)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
+
+    if (pKbd->isConsole) {
+        ioctl (pInfo->fd, KDGKBMODE, &(priv->kbdtrans));
+        tcgetattr (pInfo->fd, &(priv->kbdtty));
+    }
+    if (!pKbd->CustomKeycodes) {
+        pKbd->RemapScanCode = ATScancode;
+    }
+
+    return Success;
+}
+
+static int
+KbdOn(InputInfoPtr pInfo, int what)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
+    struct termios nTty;
+
+    if (pKbd->isConsole) {
+	if (pKbd->CustomKeycodes)
+	    ioctl(pInfo->fd, KDSKBMODE, K_MEDIUMRAW);
+	else
+	    ioctl(pInfo->fd, KDSKBMODE, K_RAW);
+
+	nTty = priv->kbdtty;
+	nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+	nTty.c_oflag = 0;
+	nTty.c_cflag = CREAD | CS8;
+	nTty.c_lflag = 0;
+	nTty.c_cc[VTIME]=0;
+	nTty.c_cc[VMIN]=1;
+	cfsetispeed(&nTty, 9600);
+	cfsetospeed(&nTty, 9600);
+	tcsetattr(pInfo->fd, TCSANOW, &nTty);
+    }
+    return Success;
+}
+
+static int
+KbdOff(InputInfoPtr pInfo, int what)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
+
+    if (pKbd->isConsole) {
+	ioctl(pInfo->fd, KDSKBMODE, priv->kbdtrans);
+	tcsetattr(pInfo->fd, TCSANOW, &(priv->kbdtty));
+    }
+    return Success;
+}
+
+static int
+GetSpecialKey(InputInfoPtr pInfo, int scanCode)
+{
+  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+  int specialkey = scanCode;
+
+#if defined (__sparc__)
+  if (pKbd->sunKbd) {
+      switch (scanCode) {
+          case 0x2b: specialkey = KEY_BackSpace; break;
+          case 0x47: specialkey = KEY_KP_Minus; break;
+          case 0x7d: specialkey = KEY_KP_Plus; break;
+          /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */
+          case 0x05: specialkey = KEY_F1; break;
+          case 0x06: specialkey = KEY_F2; break;
+          case 0x08: specialkey = KEY_F3; break;
+          case 0x0a: specialkey = KEY_F4; break;
+          case 0x0c: specialkey = KEY_F5; break;
+          case 0x0e: specialkey = KEY_F6; break;
+          case 0x10: specialkey = KEY_F7; break;
+          case 0x11: specialkey = KEY_F8; break;
+          case 0x12: specialkey = KEY_F9; break;
+          case 0x07: specialkey = KEY_F10; break;
+          case 0x09: specialkey = KEY_F11; break;
+          case 0x0b: specialkey = KEY_F12; break;
+          default: specialkey = 0; break;
+      }
+      return specialkey;
+  }
+#endif
+
+  if (pKbd->CustomKeycodes) {
+      specialkey = pKbd->specialMap->map[scanCode];
+  }
+  return specialkey;
+}
+
+#define ModifierSet(k) ((modifiers & (k)) == (k))
+
+static
+Bool SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers)
+{
+  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+
+  if(!pKbd->vtSwitchSupported)
+      return FALSE;
+
+  if ((ModifierSet(ControlMask | AltMask)) ||
+      (ModifierSet(ControlMask | AltLangMask))) {
+      if (VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
+          switch (key) {
+             case KEY_F1:
+             case KEY_F2:
+             case KEY_F3:
+             case KEY_F4:
+             case KEY_F5:
+             case KEY_F6:
+             case KEY_F7:
+             case KEY_F8:
+             case KEY_F9:
+             case KEY_F10:
+                  if (down) {
+                    ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
+                    return TRUE;
+                  }
+             case KEY_F11:
+             case KEY_F12:
+                  if (down) {
+                    ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
+                    return TRUE;
+                  }
+         }
+      }
+  }
+#ifdef USE_VT_SYSREQ
+    if (VTSwitchEnabled && xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
+        switch (key) {
+            case KEY_F1:
+            case KEY_F2:
+            case KEY_F3:
+            case KEY_F4:
+            case KEY_F5:
+            case KEY_F6:
+            case KEY_F7:
+            case KEY_F8:
+            case KEY_F9:
+            case KEY_F10:
+                 if (VTSysreqToggle && down) {
+                     ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
+                     VTSysreqToggle = FALSE;
+                     return TRUE;
+                 }
+                 break;
+            case KEY_F11:
+            case KEY_F12:
+                 if (VTSysreqToggle && down) {
+                     ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
+                     VTSysreqToggle = FALSE;
+                     return TRUE;
+                 }
+                 break;
+            /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
+            case KEY_Alt:
+            case KEY_AltLang:
+                 break;
+            case KEY_SysReqest:
+                 if ((ModifierSet(AltMask) || ModifierSet(AltLangMask)) && down)
+                     VTSysreqToggle = TRUE;
+                 break;
+             default:
+                 /*
+                  * We only land here when Alt-SysReq is followed by a
+                  * non-switching key.
+                  */
+                 if (VTSysreqToggle)
+                     VTSysreqToggle = FALSE;
+        }
+    }
+#endif /* USE_VT_SYSREQ */
+    return FALSE;
+} 
+
+static void
+stdReadInput(InputInfoPtr pInfo)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    unsigned char rBuf[64];
+    int nBytes, i;
+    if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) {
+       for (i = 0; i < nBytes; i++)
+           pKbd->PostEvent(pInfo, rBuf[i] & 0x7f,
+                           rBuf[i] & 0x80 ? FALSE : TRUE);
+       }
+}
+
+static Bool
+OpenKeyboard(InputInfoPtr pInfo)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+    int i;
+    KbdProtocolId prot = PROT_UNKNOWN_KBD;
+    char *s;
+
+    s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
+    for (i = 0; protocols[i].name; i++) {
+        if (xf86NameCmp(s, protocols[i].name) == 0) {
+           prot = protocols[i].id;
+           break;
+        }
+    }
+
+    switch (prot) {
+        case PROT_STD:
+           pInfo->read_input = stdReadInput;
+           break;
+        default:
+           xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
+           xfree(s);
+           return FALSE;
+    }
+
+    xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s);
+    xfree(s);
+
+    s = xf86SetStrOption(pInfo->options, "Device", NULL);
+    if (s == NULL) {
+       pInfo->fd = xf86Info.consoleFd;
+       pKbd->isConsole = TRUE;
+    } else {
+       pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
+       if (pInfo->fd == -1) {
+           xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
+           xfree(s);
+           return FALSE;
+       }
+       pKbd->isConsole = FALSE;
+       xfree(s);
+    }
+
+    if (pKbd->isConsole)
+         pKbd->vtSwitchSupported = TRUE;
+
+    return TRUE;
+}
+
+_X_EXPORT Bool
+xf86OSKbdPreInit(InputInfoPtr pInfo)
+{
+    KbdDevPtr pKbd = pInfo->private;
+
+    pKbd->KbdInit       = KbdInit;
+    pKbd->KbdOn         = KbdOn;
+    pKbd->KbdOff        = KbdOff;
+    pKbd->Bell          = SoundBell;
+    pKbd->SetLeds       = SetKbdLeds;
+    pKbd->GetLeds       = GetKbdLeds;
+    pKbd->SetKbdRepeat  = SetKbdRepeat;
+    pKbd->KbdGetMapping = KbdGetMapping;
+    pKbd->SpecialKey    = SpecialKey;
+
+    pKbd->RemapScanCode = NULL;
+    pKbd->GetSpecialKey = GetSpecialKey;
+
+    pKbd->OpenKeyboard = OpenKeyboard;
+    pKbd->vtSwitchSupported = FALSE;
+
+    pKbd->private = xcalloc(sizeof(LnxKbdPrivRec), 1);
+    if (pKbd->private == NULL) {
+       xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
+       return FALSE;
+    }
+
+#if defined(__powerpc__)
+  {
+    FILE *f;
+    f = fopen("/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes","r");
+    if (f) {
+        if (fgetc(f) == '0')
+            pKbd->CustomKeycodes = TRUE;
+        fclose(f);
+    }
+  }
+#endif
+    return TRUE;
+}
diff-tree 81913a12910e39d7ea6af8657c1c66cc6791cd65 (from 7465010d59ec435bd00b738f0cef766b352dc7eb)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Jul 21 19:10:26 2006 -0400

    remove undead files from master
    Remove dead files which worked their way back in when merging from master.
    Ugh.

diff --git a/hw/xfree86/common/xf86Io.c b/hw/xfree86/common/xf86Io.c
deleted file mode 100644
index 86ac745..0000000
--- a/hw/xfree86/common/xf86Io.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- * 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.
- *
- */
-/*
- * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/* $XConsortium: xf86Io.c /main/27 1996/10/19 17:58:55 kaleb $ */
-
-#define NEED_EVENTS
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "inputstr.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#define XF86_OS_PRIVS
-#include "xf86_OSlib.h"
-#include "mipointer.h"
-
-#ifdef XINPUT
-#include "xf86Xinput.h"
-#include <X11/extensions/XIproto.h>
-#include "exevents.h"
-#endif
-
-#ifdef XKB
-#include <X11/extensions/XKB.h>
-#include <X11/extensions/XKBstr.h>
-#include <X11/extensions/XKBsrv.h>
-#endif
-
-unsigned int xf86InitialCaps = 0;
-unsigned int xf86InitialNum = 0;
-unsigned int xf86InitialScroll = 0;
-
-#include "atKeynames.h"
-
-/*
- * xf86KbdBell --
- *	Ring the terminal/keyboard bell for an amount of time proportional to
- *      "loudness".
- */
-
-void
-xf86KbdBell(percent, pKeyboard, ctrl, unused)
-     int           percent;          /* Percentage of full volume */
-     DeviceIntPtr  pKeyboard;        /* Keyboard to ring */
-     pointer	   ctrl;	
-     int	   unused;	
-{
-  xf86SoundKbdBell(percent, xf86Info.bell_pitch, xf86Info.bell_duration);
-}
-
-void
-xf86UpdateKbdLeds()
-{
-  int leds = 0;
-  if (xf86Info.capsLock) leds |= XLED1;
-  if (xf86Info.numLock)  leds |= XLED2;
-  if (xf86Info.scrollLock || xf86Info.modeSwitchLock) leds |= XLED3;
-  if (xf86Info.composeLock) leds |= XLED4;
-  xf86Info.leds = (xf86Info.leds & xf86Info.xleds) | (leds & ~xf86Info.xleds);
-  xf86KbdLeds();
-}
-
-void
-xf86KbdLeds ()
-{
-  int leds, real_leds = 0;
-
-#if defined (__sparc__) && defined(__linux__)
-  static int kbdSun = -1;
-  if (kbdSun == -1) {
-  if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun")) ||
-      (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun")))
-      kbdSun = 1;
-  else
-      kbdSun = 0;
-  }
-  if (kbdSun) {
-     if (xf86Info.leds & 0x08) real_leds |= XLED1;
-     if (xf86Info.leds & 0x04) real_leds |= XLED3;
-     if (xf86Info.leds & 0x02) real_leds |= XLED4;
-     if (xf86Info.leds & 0x01) real_leds |= XLED2;
-     leds = real_leds;
-     real_leds = 0;
-  } else {
-     leds = xf86Info.leds;
-  }
-#else
-  leds = xf86Info.leds;
-#endif /* defined (__sparc__) */
-
-#ifdef LED_CAP
-  if (leds & XLED1)  real_leds |= LED_CAP;
-  if (leds & XLED2)  real_leds |= LED_NUM;
-  if (leds & XLED3)  real_leds |= LED_SCR;
-#ifdef LED_COMP
-  if (leds & XLED4)  real_leds |= LED_COMP;
-#else
-  if (leds & XLED4)  real_leds |= LED_SCR;
-#endif
-#endif
-#ifdef sun
-  /* Pass through any additional LEDs, such as Kana LED on Sun Japanese kbd */
-  real_leds |= (leds & 0xFFFFFFF0);
-#endif
-  xf86SetKbdLeds(real_leds);
-  (void)leds;
-}
-
-/*
- * xf86KbdCtrl --
- *      Alter some of the keyboard control parameters. All special protocol
- *      values are handled by dix (ProgChangeKeyboardControl)
- */
-
-void
-xf86KbdCtrl (pKeyboard, ctrl)
-     DevicePtr     pKeyboard;        /* Keyboard to alter */
-     KeybdCtrl     *ctrl;
-{
-  int leds;
-  xf86Info.bell_pitch    = ctrl->bell_pitch;
-  xf86Info.bell_duration = ctrl->bell_duration;
-  xf86Info.autoRepeat    = ctrl->autoRepeat;
-
-  xf86Info.composeLock   = (ctrl->leds & XCOMP) ? TRUE : FALSE;
-
-  leds = (ctrl->leds & ~(XCAPS | XNUM | XSCR));
-#ifdef XKB
-  if (noXkbExtension) {
-#endif
-      xf86Info.leds = (leds & xf86Info.xleds)|(xf86Info.leds & ~xf86Info.xleds);
-#ifdef XKB
-  } else {
-      xf86Info.leds = leds;
-  }
-#endif
-
-  xf86KbdLeds();
-}
-
-/*
- * xf86InitKBD --
- *      Reinitialize the keyboard. Only set Lockkeys according to ours leds.
- *      Depress all other keys.
- */
-
-void
-xf86InitKBD(init)
-Bool init;
-{
-  char            leds = 0, rad;
-  unsigned int    i;
-  xEvent          kevent;
-  DeviceIntPtr    pKeyboard = xf86Info.pKeyboard;
-  KeyClassRec     *keyc = xf86Info.pKeyboard->key;
-  KeySym          *map = keyc->curKeySyms.map;
-
-  kevent.u.keyButtonPointer.time = GetTimeInMillis();
-  kevent.u.keyButtonPointer.rootX = 0;
-  kevent.u.keyButtonPointer.rootY = 0;
-
-  /*
-   * Hmm... here is the biggest hack of every time !
-   * It may be possible that a switch-vt procedure has finished BEFORE
-   * you released all keys neccessary to do this. That peculiar behavior
-   * can fool the X-server pretty much, cause it assumes that some keys
-   * were not released. TWM may stuck alsmost completly....
-   * OK, what we are doing here is after returning from the vt-switch
-   * exeplicitely unrelease all keyboard keys before the input-devices
-   * are reenabled.
-   */
-  for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
-       i < keyc->curKeySyms.maxKeyCode;
-       i++, map += keyc->curKeySyms.mapWidth)
-    if (KeyPressed(i))
-      {
-        switch (*map) {
-	/* Don't release the lock keys */
-        case XK_Caps_Lock:
-        case XK_Shift_Lock:
-        case XK_Num_Lock:
-        case XK_Scroll_Lock:
-        case XK_Kana_Lock:
-	  break;
-        default:
-	  kevent.u.u.detail = i;
-	  kevent.u.u.type = KeyRelease;
-	  (* pKeyboard->public.processInputProc)(&kevent, pKeyboard, 1);
-        }
-      }
-  
-  xf86Info.scanPrefix      = 0;
-
-  if (init)
-    {
-      /*
-       * we must deal here with the fact, that on some cases the numlock or
-       * capslock key are enabled BEFORE the server is started up. So look
-       * here at the state on the according LEDS to determine whether a
-       * lock-key is already set.
-       */
-
-      xf86Info.capsLock        = FALSE;
-      xf86Info.numLock         = FALSE;
-      xf86Info.scrollLock      = FALSE;
-      xf86Info.modeSwitchLock  = FALSE;
-      xf86Info.composeLock     = FALSE;
-    
-#ifdef LED_CAP
-#ifdef INHERIT_LOCK_STATE
-      leds = xf86Info.leds;
-
-      for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
-           i < keyc->curKeySyms.maxKeyCode;
-           i++, map += keyc->curKeySyms.mapWidth)
-
-        switch(*map) {
-
-        case XK_Caps_Lock:
-        case XK_Shift_Lock:
-          if (leds & LED_CAP) 
-	    {
-	      xf86InitialCaps = i;
-	      xf86Info.capsLock = TRUE;
-	    }
-          break;
-
-        case XK_Num_Lock:
-          if (leds & LED_NUM)
-	    {
-	      xf86InitialNum = i;
-	      xf86Info.numLock = TRUE;
-	    }
-          break;
-
-        case XK_Scroll_Lock:
-        case XK_Kana_Lock:
-          if (leds & LED_SCR)
-	    {
-	      xf86InitialScroll = i;
-	      xf86Info.scrollLock = TRUE;
-	    }
-          break;
-        }
-#endif /* INHERIT_LOCK_STATE */
-      xf86SetKbdLeds(leds);
-#endif /* LED_CAP */
-      (void)leds;
-
-      if      (xf86Info.kbdDelay <= 375) rad = 0x00;
-      else if (xf86Info.kbdDelay <= 625) rad = 0x20;
-      else if (xf86Info.kbdDelay <= 875) rad = 0x40;
-      else                               rad = 0x60;
-    
-      if      (xf86Info.kbdRate <=  2)   rad |= 0x1F;
-      else if (xf86Info.kbdRate >= 30)   rad |= 0x00;
-      else                               rad |= ((58 / xf86Info.kbdRate) - 2);
-    
-      xf86SetKbdRepeat(rad);
-    }
-}
-
-/*
- * xf86KbdProc --
- *	Handle the initialization, etc. of a keyboard.
- */
-
-int
-xf86KbdProc (pKeyboard, what)
-     DeviceIntPtr pKeyboard;	/* Keyboard to manipulate */
-     int       what;	    	/* What to do to it */
-{
-  KeySymsRec           keySyms;
-  CARD8                modMap[MAP_LENGTH];
-  int                  kbdFd;
-
-  switch (what) {
-
-  case DEVICE_INIT:
-    /*
-     * First open and find the current state of the keyboard.
-     */
-
-    xf86KbdInit();
-
-    xf86KbdGetMapping(&keySyms, modMap);
-    
-
-#ifndef XKB
-    defaultKeyboardControl.leds = xf86GetKbdLeds();
-#else
-    defaultKeyboardControl.leds = 0;
-#endif
-
-    /*
-     * Perform final initialization of the system private keyboard
-     * structure and fill in various slots in the device record
-     * itself which couldn't be filled in before.
-     */
-
-    pKeyboard->public.on = FALSE;
-
-#ifdef XKB
-    if (noXkbExtension) {
-#endif
-    InitKeyboardDeviceStruct((DevicePtr)xf86Info.pKeyboard,
-			     &keySyms,
-			     modMap,
-			     xf86KbdBell,
-			     (KbdCtrlProcPtr)xf86KbdCtrl);
-#ifdef XKB
-    } else {
- 	XkbComponentNamesRec	names;
-	XkbDescPtr		desc;
-	Bool			foundTerminate = FALSE;
-	int			keyc;
-	if (xf86Info.xkbkeymap) {
-	    names.keymap = xf86Info.xkbkeymap;
-	    names.keycodes = NULL;
-	    names.types = NULL;
-	    names.compat = NULL;
-	    names.symbols = NULL;
-	    names.geometry = NULL;
-	} else {
-	    names.keymap = NULL;
-	    names.keycodes = xf86Info.xkbkeycodes;
-	    names.types = xf86Info.xkbtypes;
-	    names.compat = xf86Info.xkbcompat;
-	    names.symbols = xf86Info.xkbsymbols;
-	    names.geometry = xf86Info.xkbgeometry;
-	}
-	if ((xf86Info.xkbkeymap || xf86Info.xkbcomponents_specified)
-	   && (xf86Info.xkbmodel == NULL || xf86Info.xkblayout == NULL)) {
-		xf86Info.xkbrules = NULL;
-	}
-	XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel,
-			 xf86Info.xkblayout, xf86Info.xkbvariant,
-			 xf86Info.xkboptions);
-	
-	XkbInitKeyboardDeviceStruct(pKeyboard, 
-				    &names,
-				    &keySyms, 
-				    modMap, 
-				    xf86KbdBell,
-				    (KbdCtrlProcPtr)xf86KbdCtrl);
-
-	/* Search keymap for Terminate action */
-	desc  = pKeyboard->key->xkbInfo->desc;
-	for (keyc = desc->min_key_code; keyc <= desc->max_key_code; keyc++) {
-	    int i;
-	    for (i = 1; i <= XkbKeyNumActions(desc, keyc); i++) {
-		if (XkbKeyAction(desc, keyc, i)
-		  && XkbKeyAction(desc, keyc, i)->type == XkbSA_Terminate) {
-		    foundTerminate = TRUE;
-		    goto searchdone;
-		}
-	    }
-  	}
-searchdone:
-	xf86Info.ActionKeyBindingsSet = foundTerminate;
-	if (!foundTerminate)
-	    xf86Msg(X_INFO, "Server_Terminate keybinding not found\n");
-    }
-#endif
-    
-    xf86InitKBD(TRUE);
-    break;
-    
-  case DEVICE_ON:
-    /*
-     * Set the keyboard into "direct" mode and turn on
-     * event translation.
-     */
-
-    kbdFd = xf86KbdOn();
-    /*
-     * Discard any pending input after a VT switch to prevent the server
-     * passing on parts of the VT switch sequence.
-     */
-    sleep(1);
-#if defined(WSCONS_SUPPORT)
-    if (xf86Info.consType != WSCONS) {
-#endif
-	if (kbdFd != -1) {
-		char buf[16];
-		read(kbdFd, buf, 16);
-    	}
-#if defined(WSCONS_SUPPORT)
-    }
-#endif
-
-#if !defined(__UNIXOS2__) /* Under EMX, keyboard cannot be select()'ed */
-    if (kbdFd != -1)
-      AddEnabledDevice(kbdFd);
-#endif  /* __UNIXOS2__ */
-
-    pKeyboard->public.on = TRUE;
-    xf86InitKBD(FALSE);
-    break;
-    
-  case DEVICE_CLOSE:
-  case DEVICE_OFF:
-    /*
-     * Restore original keyboard directness and translation.
-     */
-
-    kbdFd = xf86KbdOff();
-
-    if (kbdFd != -1)
-      RemoveEnabledDevice(kbdFd);
-
-    pKeyboard->public.on = FALSE;
-    break;
-
-  }
-  return (Success);
-}
diff --git a/hw/xfree86/common/xf86Kbd.c b/hw/xfree86/common/xf86Kbd.c
deleted file mode 100644
index a86581c..0000000
--- a/hw/xfree86/common/xf86Kbd.c
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * 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.
- *
- */
-/*
- * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/* $XConsortium: xf86Kbd.c /main/10 1996/02/21 17:38:32 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifdef __UNIXOS2__
-#define I_NEED_OS2_H
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "atKeynames.h"
-#include "xf86Config.h"
-
-#include "xf86Keymap.h"
-
-#if defined(KDGKBTYPE) && \
-	!defined(Lynx) && \
-	!defined(__UNIXOS2__) && !defined(__mips__) && \
-	!defined(__arm32__) && !defined(__GNU__) && !defined(__QNX__)
-#define HAS_GETKBTYPE
-#endif
-#if defined(GIO_KEYMAP) && \
-	!defined(Lynx) && \
-	!defined(__UNIXOS2__) && !defined(__mips__) && \
-	!defined(__arm32__) && !defined(__GNU__) && !defined(DGUX) && \
-	!defined(__QNX__)
-#define HAS_GETKEYMAP
-
-#define KD_GET_ENTRY(i,n) \
-  eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
-
-/*
- * NOTE: Not all possible remappable symbols are remapped. There are two main
- *       reasons:
- *                 a) The mapping between scancode and SYSV/386 - symboltable
- *                    is inconsistent between different versions and has some
- *                    BIG mistakes.
- *                 b) In X-Windows there is a difference between numpad-keys
- *                    and normal keys. SYSV/386 uses for both kinds of keys
- *                    the same symbol.
- *
- *       Thus only the alpha keypad and the function keys are translated.
- *       Also CapsLock, NumLock, ScrollLock, Shift, Control & Alt.
- */
-
-static unsigned char remap[128] = {
-     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
-  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
-  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
-  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
-  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
-  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
-  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
-  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
-  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
-     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
-  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
-     0,    0, 0x69, 0x65,    0,    0,    0,    0,   /* 0x70 - 0x77 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
-};
-
-static KeySym eascii_to_x[512] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	XK_Ccedilla,	XK_udiaeresis,	XK_eacute,	XK_acircumflex,
-	XK_adiaeresis,	XK_agrave,	XK_aring,	XK_ccedilla,
-	XK_ecircumflex,	XK_ediaeresis,	XK_egrave,	XK_idiaeresis,
-	XK_icircumflex,	XK_igrave,	XK_Adiaeresis,	XK_Aring,
-	XK_Eacute,	XK_ae,		XK_AE,		XK_ocircumflex,
-	XK_odiaeresis,	XK_ograve,	XK_ucircumflex,	XK_ugrave,
-	XK_ydiaeresis,	XK_Odiaeresis,	XK_Udiaeresis,	XK_cent,
-	XK_sterling,	XK_yen,		XK_paragraph,	XK_section,
-	XK_aacute,	XK_iacute,	XK_oacute,	XK_uacute,
-	XK_ntilde,	XK_Ntilde,	XK_ordfeminine,	XK_masculine,
-	XK_questiondown,XK_hyphen,	XK_notsign,	XK_onehalf,
-	XK_onequarter,	XK_exclamdown,	XK_guillemotleft,XK_guillemotright,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Greek_alpha,	XK_ssharp,	XK_Greek_GAMMA,	XK_Greek_pi,
-	XK_Greek_SIGMA,	XK_Greek_sigma,	XK_mu,	        XK_Greek_tau,
-	XK_Greek_PHI,	XK_Greek_THETA,	XK_Greek_OMEGA,	XK_Greek_delta,
-	XK_infinity,	XK_Ooblique,	XK_Greek_epsilon, XK_intersection,
-	XK_identical,	XK_plusminus,	XK_greaterthanequal, XK_lessthanequal,
-	XK_topintegral,	XK_botintegral,	XK_division,	XK_similarequal,
-	XK_degree,	NoSymbol,	NoSymbol,	XK_radical,
-	XK_Greek_eta,	XK_twosuperior,	XK_periodcentered, NoSymbol,
-
-	/* 
-	 * special marked entries (256 + x)
-	 */
-
-	NoSymbol,	NoSymbol,	XK_Shift_L,	XK_Shift_R,
-	XK_Caps_Lock,	XK_Num_Lock,	XK_Scroll_Lock,	XK_Alt_L,
-	NoSymbol,	XK_Control_L,	XK_Alt_L,	XK_Alt_R,
-	XK_Control_L,	XK_Control_R,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_F1,
-	XK_F2,		XK_F3,		XK_F4,		XK_F5,
-	XK_F6,		XK_F7,		XK_F8,		XK_F9,
-	XK_F10,		XK_F11,		XK_F12,		NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-      };
-
-#endif /* HAS_GETKEYMAP */
-
-/*
- * LegalModifier --
- *      determine whether a key is a legal modifier key, i.e send a
- *      press/release sequence.
- */
-
-/*ARGSUSED*/
-Bool
-LegalModifier(key, pDev)
-     unsigned int  key;
-     DevicePtr	pDev;
-{
-  return (TRUE);
-}
-
-
-      
-/*
- * xf86KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-void
-xf86KbdGetMapping (pKeySyms, pModMap)
-     KeySymsPtr pKeySyms;
-     CARD8      *pModMap;
-{
-  KeySym        *k;
-#ifdef HAS_GETKEYMAP
-  keymap_t      keymap;
-#endif
-  int           i;
-  KeySym        *pMap;
-
-#ifdef HAS_GETKBTYPE
-  char          type;
-  
-  xf86Info.kbdType =
-    ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101;
-  if (xf86Info.kbdType == KB_84)
-    pMap = map84;
-  else
-    pMap = map;
-#else
-/* OS/2 sets the keyboard type during xf86OpenKbd */
-#ifndef __UNIXOS2__
-  xf86Info.kbdType = 0;
-#endif
-  pMap = map;
-#endif
-
-#ifdef HAS_GETKEYMAP
-  /*
-   * use the keymap, which can be gotten from our oringinal vt??.
-   * ( ttymap(1) !!!! )
-   */
-  if (ioctl(xf86Info.consoleFd, GIO_KEYMAP, &keymap) != -1) {
-    for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++)
-      
-      if (remap[i]) {
-	
-	k = pMap + (remap[i] << 2);
-	
-	k[0] = KD_GET_ENTRY(i,0);             /* non-shifed */
-	k[1] = KD_GET_ENTRY(i,1);	      /* shifted */
-	k[2] = KD_GET_ENTRY(i,4);	      /* alt */
-	k[3] = KD_GET_ENTRY(i,5);	      /* alt - shifted */
-
-	if (k[3] == k[2]) k[3] = NoSymbol;
-	if (k[2] == k[1]) k[2] = NoSymbol;
-	if (k[1] == k[0]) k[1] = NoSymbol;
-	if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
-      }
-  }
-#endif
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = pMap, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4)
-    
-    switch(*k) {
-      
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-
-    }
-  
-  pKeySyms->map        = pMap;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  pKeySyms->maxKeyCode = MAX_KEYCODE;
-}
diff --git a/hw/xfree86/common/xf86KbdBSD.c b/hw/xfree86/common/xf86KbdBSD.c
deleted file mode 100644
index 97a737d..0000000
--- a/hw/xfree86/common/xf86KbdBSD.c
+++ /dev/null
@@ -1,1265 +0,0 @@
-/*
- * Derived from xf86Kbd.c by S_ren Schmidt (sos at login.dkuug.dk)
- * which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- * and from xf86KbdCODrv.c by Holger Veit
- *
- * 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.
- */
-/*
- * Copyright (c) 1994-2002 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/* $XConsortium: xf86KbdBSD.c /main/6 1996/10/23 13:12:27 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "atKeynames.h"
-#include "xf86Keymap.h"
-
-#if (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)) && defined(GIO_KEYMAP)
-#define KD_GET_ENTRY(i,n) \
-  eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
-
-static unsigned char remap[NUM_KEYCODES] = {
-     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
-  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
-  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
-  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
-  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
-  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
-  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
-  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
-  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
-     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
-  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
-     0,    0, 0x69, 0x65,    0,    0,    0,    0,   /* 0x70 - 0x77 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
-};
-
-/* This table assumes the ibm code page 437 coding for characters 
- * > 0x80. They are returned in this form by PCVT */
-static KeySym eascii_to_x[512] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	XK_Ccedilla,	XK_udiaeresis,	XK_eacute,	XK_acircumflex,
-	XK_adiaeresis,	XK_agrave,	XK_aring,	XK_ccedilla,
-	XK_ecircumflex,	XK_ediaeresis,	XK_egrave,	XK_idiaeresis,
-	XK_icircumflex,	XK_igrave,	XK_Adiaeresis,	XK_Aring,
-	XK_Eacute,	XK_ae,		XK_AE,		XK_ocircumflex,
-	XK_odiaeresis,	XK_ograve,	XK_ucircumflex,	XK_ugrave,
-	XK_ydiaeresis,	XK_Odiaeresis,	XK_Udiaeresis,	XK_cent,
-	XK_sterling,	XK_yen,		XK_paragraph,	XK_section,
-	XK_aacute,	XK_iacute,	XK_oacute,	XK_uacute,
-	XK_ntilde,	XK_Ntilde,	XK_ordfeminine,	XK_masculine,
-	XK_questiondown,XK_hyphen,	XK_notsign,	XK_onehalf,
-	XK_onequarter,	XK_exclamdown,	XK_guillemotleft,XK_guillemotright,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Greek_alpha,	XK_ssharp,	XK_Greek_GAMMA,	XK_Greek_pi,
-	XK_Greek_SIGMA,	XK_Greek_sigma,	XK_mu,	        XK_Greek_tau,
-	XK_Greek_PHI,	XK_Greek_THETA,	XK_Greek_OMEGA,	XK_Greek_delta,
-	XK_infinity,	XK_Ooblique,	XK_Greek_epsilon, XK_intersection,
-	XK_identical,	XK_plusminus,	XK_greaterthanequal, XK_lessthanequal,
-	XK_topintegral,	XK_botintegral,	XK_division,	XK_similarequal,
-	XK_degree,	NoSymbol,	NoSymbol,	XK_radical,
-	XK_Greek_eta,	XK_twosuperior,	XK_periodcentered, NoSymbol,
-
-	/* 
-	 * special marked entries (256 + x)
-	 */
-
-#if 1
-	/* This has been checked against what syscons actually does */
-	NoSymbol,	NoSymbol,	XK_Shift_L,	XK_Shift_R,
-	XK_Caps_Lock,	XK_Num_Lock,	XK_Scroll_Lock,	XK_Alt_L,
-	XK_ISO_Left_Tab,XK_Control_L,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_F1,
-	XK_F2,		XK_F3,		XK_F4,		XK_F5,
-	XK_F6,		XK_F7,		XK_F8,		XK_F9,
-	XK_F10,		XK_F11,		XK_F12,		NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Control_R,	XK_Alt_R,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol
-#else
-	/* The old table, supposedly for pcvt. */
-	NoSymbol,	NoSymbol,	XK_Shift_L,	XK_Shift_R,
-	XK_Caps_Lock,	XK_Num_Lock,	XK_Scroll_Lock,	XK_Alt_L,
-	NoSymbol,	XK_Control_L,	XK_Alt_L,	XK_Alt_R,
-	XK_Control_L,	XK_Control_R,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_F1,
-	XK_F2,		XK_F3,		XK_F4,		XK_F5,
-	XK_F6,		XK_F7,		XK_F8,		XK_F9,
-	XK_F10,		XK_F11,		XK_F12,		NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol
-#endif
-      };
-
-#ifdef __OpenBSD__
-/* don't mark AltR and  CtrlR for remapping, since they 
- * cannot be remapped by pccons */
-static unsigned char pccons_remap[128] = {
-     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
-  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
-  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
-  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
-  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
-  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
-  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
-  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
-  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
-     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
-  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x70 - 0x77 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
-};
-
-/* This table assumes an iso8859_1 encoding for the characters 
- * > 80, as returned by pccons */
-static KeySym latin1_to_x[256] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_nobreakspace,XK_exclamdown,	XK_cent,	XK_sterling,
-	XK_currency,	XK_yen,		XK_brokenbar,	XK_section,
-	XK_diaeresis,	XK_copyright,	XK_ordfeminine,	XK_guillemotleft,
-	XK_notsign,	XK_hyphen,	XK_registered,	XK_macron,
-	XK_degree,	XK_plusminus,	XK_twosuperior,	XK_threesuperior,
-	XK_acute,	XK_mu,		XK_paragraph,	XK_periodcentered,
-	XK_cedilla,	XK_onesuperior,	XK_masculine,	XK_guillemotright,
-	XK_onequarter,	XK_onehalf,	XK_threequarters,XK_questiondown,
-	XK_Agrave,	XK_Aacute,	XK_Acircumflex,	XK_Atilde,
-	XK_Adiaeresis,	XK_Aring,	XK_AE,		XK_Ccedilla,
-	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
-	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
-	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
-	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_multiply,
-	XK_Ooblique,	XK_Ugrave,	XK_Uacute,	XK_Ucircumflex,
-	XK_Udiaeresis,	XK_Yacute,	XK_THORN,	XK_ssharp,
-	XK_agrave,	XK_aacute,	XK_acircumflex,	XK_atilde,
-	XK_adiaeresis,	XK_aring,	XK_ae,	        XK_ccedilla,
-	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
-	XK_igrave,	XK_iacute,	XK_icircumflex, XK_idiaeresis,
-	XK_eth,		XK_ntilde,	XK_ograve, 	XK_oacute,
-	XK_ocircumflex,	XK_otilde,	XK_odiaeresis,	XK_division,
-	XK_oslash,	XK_ugrave,	XK_uacute,	XK_ucircumflex,
-	XK_udiaeresis,	XK_yacute,	XK_thorn, 	XK_ydiaeresis
-      };
-#endif
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
-/*
- * LegalModifier --
- *      determine whether a key is a legal modifier key, i.e send a
- *      press/release sequence.
- */
-
-/*ARGSUSED*/
-Bool
-LegalModifier(key, pDev)
-     unsigned int  key;
-     DevicePtr pDev;
-{
-  return (TRUE);
-}
-
-/*
- * xf86KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-void
-xf86KbdGetMapping (pKeySyms, pModMap)
-     KeySymsPtr pKeySyms;
-     CARD8      *pModMap;
-{
-  KeySym        *k;
-  int           i;
-
-#ifndef __bsdi__
-  switch (xf86Info.consType) {
-
-#ifdef PCCONS_SUPPORT
-  case PCCONS:
-#if defined(__OpenBSD__)
-    /*
-     * on OpenBSD, the pccons keymap is programmable, too
-     */
-    {
-      pccons_keymap_t keymap[KB_NUM_KEYS];
-      if (ioctl(xf86Info.consoleFd, CONSOLE_GET_KEYMAP, &keymap) != -1) {
-	for (i = 0; i < KB_NUM_KEYS; i++) 
-	  if (pccons_remap[i]) {
-	    k = map + (pccons_remap[i] << 2);
-	    switch (keymap[i].type) {
-	    case KB_ASCII:
-	      /* For ASCII keys, there is only one char in the keymap */
-	      k[0] = latin1_to_x[(unsigned char)keymap[i].unshift[0]];
-	      k[1] = latin1_to_x[(unsigned char)keymap[i].shift[0]];
-	      k[2] = latin1_to_x[(unsigned char)keymap[i].altgr[0]];
-	      k[3] = latin1_to_x[(unsigned char)keymap[i].shift_altgr[0]];
-	      break;
-	    case KB_SCROLL:
-	      k[0] = XK_Scroll_Lock;
-	      goto special;
-	    case KB_NUM:
-	      k[0] = XK_Num_Lock;
-	      goto special;
-	    case KB_CAPS:
-	      k[0] = XK_Caps_Lock;
-	      goto special;
-	    case KB_SHIFT:
-	      switch (keymap[i].unshift[0]) {
-	      case 1:
-		/* left shift */
-		k[0] = XK_Shift_L;
-		break;
-	      case 2:
-		/* right shift */
-		k[0] = XK_Shift_R;
-		break;
-	      default:
-		k[0] = NoSymbol;
-	      }
-	      goto special;
-	    case KB_CTL:
-	      k[0] = XK_Control_L;
-	      goto special;
-	    case KB_ALT:
-	      k[0] = XK_Alt_L;
-	      goto special;
-	    case KB_FUNC:
-	      switch (keymap[i].unshift[2]) {
-	      case 'M':
-		k[0] = XK_F1;
-		break;
-	      case 'N':
-		k[0] = XK_F2;
-		break;
-	      case 'O':
-		k[0] = XK_F3;
-		break;
-	      case 'P':
-		k[0] = XK_F4;
-		break;
-	      case 'Q':
-		k[0] = XK_F5;
-		break;
-	      case 'R':
-		k[0] = XK_F6;
-		break;
-	      case 'S':
-		k[0] = XK_F7;
-		break;
-	      case 'T':
-		k[0] = XK_F8;
-		break;
-	      case 'U':
-		k[0] = XK_F9;
-		break;
-	      case 'V':
-		k[0] = XK_F10;
-		break;
-	      case 'W':
-		k[0] = XK_F11;
-		break;
-	      case 'X':
-		k[0] = XK_F12;
-		break;
-	      default:
-		k[0] = NoSymbol;
-		break;
-	      }
-	      goto special;
-	    default:
-	      k[0] = NoSymbol;
-	    special:
-	      k[1] = k[2] = k[3] = NoSymbol;
-	    }
-	  }
-      } else {
-	ErrorF("Can't read pccons keymap\n");
-      }
-    }
-#endif /* __OpenBSD__ */
-  break;
-#endif
-
-/*
- * XXX wscons has no GIO_KEYMAP
- */
-#if (defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)) && defined(GIO_KEYMAP)
-  case SYSCONS:
-  case PCVT:
-    {
-      keymap_t keymap;
-    
-      if (ioctl(xf86Info.consoleFd, GIO_KEYMAP, &keymap) != -1) {
-	for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++)
-	  if (remap[i]) {
-	    k = map + (remap[i] << 2);
-	    k[0] = KD_GET_ENTRY(i,0);           /* non-shifed */
-	    k[1] = KD_GET_ENTRY(i,1);	      /* shifted */
-	    k[2] = KD_GET_ENTRY(i,4);	      /* alt */
-	    k[3] = KD_GET_ENTRY(i,5);	      /* alt - shifted */
-	    if (k[3] == k[2]) k[3] = NoSymbol;
-	    if (k[2] == k[1]) k[2] = NoSymbol;
-	    if (k[1] == k[0]) k[1] = NoSymbol;
-	    if (k[0] == k[2] && k[1] == k[3])
-	      k[2] = k[3] = NoSymbol;
-	  }
-      }
-    }
-    break;
-#endif /* SYSCONS || PCVT */
-    
-  } 
-#endif /* !bsdi */
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = map, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4)
-    
-    switch(*k) {
-      
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-
-    }
-  
-  xf86Info.kbdType = 0;
-
-  pKeySyms->map        = map;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  pKeySyms->maxKeyCode = MAX_KEYCODE; 
-
-}
-
-#ifdef WSCONS_SUPPORT
-#include "atKeynames.h"
-
-static CARD8 wsUsbMap[] = {
-	/* 0 */ KEY_NOTUSED,
-	/* 1 */ KEY_NOTUSED,
-	/* 2 */ KEY_NOTUSED,
-	/* 3 */ KEY_NOTUSED,
-	/* 4 */ KEY_A,		
-	/* 5 */ KEY_B,
-	/* 6 */ KEY_C,
-	/* 7 */ KEY_D,
-	/* 8 */ KEY_E,
-	/* 9 */ KEY_F,
-	/* 10 */ KEY_G,
-	/* 11 */ KEY_H,
-	/* 12 */ KEY_I,
-	/* 13 */ KEY_J,
-	/* 14 */ KEY_K,
-	/* 15 */ KEY_L,
-	/* 16 */ KEY_M,
-	/* 17 */ KEY_N,
-	/* 18 */ KEY_O,
-	/* 19 */ KEY_P,
-	/* 20 */ KEY_Q,
-	/* 21 */ KEY_R,
-	/* 22 */ KEY_S,
-	/* 23 */ KEY_T,
-	/* 24 */ KEY_U,
-	/* 25 */ KEY_V,
-	/* 26 */ KEY_W,
-	/* 27 */ KEY_X,
-	/* 28 */ KEY_Y,
-	/* 29 */ KEY_Z,
-	/* 30 */ KEY_1,		/* 1 !*/
-	/* 31 */ KEY_2,		/* 2 @ */
-	/* 32 */ KEY_3,		/* 3 # */
-	/* 33 */ KEY_4,		/* 4 $ */
-	/* 34 */ KEY_5,		/* 5 % */
-	/* 35 */ KEY_6,		/* 6 ^ */
-	/* 36 */ KEY_7,		/* 7 & */
-	/* 37 */ KEY_8,		/* 8 * */
-	/* 38 */ KEY_9,		/* 9 ( */
-	/* 39 */ KEY_0,		/* 0 ) */
-	/* 40 */ KEY_Enter,	/* Return  */
-	/* 41 */ KEY_Escape,	/* Escape */
-	/* 42 */ KEY_BackSpace,	/* Backspace Delete */
-	/* 43 */ KEY_Tab,	/* Tab */
-	/* 44 */ KEY_Space,	/* Space */
-	/* 45 */ KEY_Minus,	/* - _ */
-	/* 46 */ KEY_Equal,	/* = + */
-	/* 47 */ KEY_LBrace,	/* [ { */
-	/* 48 */ KEY_RBrace,	/* ] } */
-	/* 49 */ KEY_BSlash,	/* \ | */
-	/* 50 */ KEY_BSlash2,	/* \ _ # ~ on some keyboards */
-	/* 51 */ KEY_SemiColon,	/* ; : */
-	/* 52 */ KEY_Quote,	/* ' " */
-	/* 53 */ KEY_Tilde,	/* ` ~ */
-	/* 54 */ KEY_Comma,	/* , <  */
-	/* 55 */ KEY_Period,	/* . > */
-	/* 56 */ KEY_Slash,	/* / ? */
-	/* 57 */ KEY_CapsLock,	/* Caps Lock */
-	/* 58 */ KEY_F1,		/* F1 */
-	/* 59 */ KEY_F2,		/* F2 */
-	/* 60 */ KEY_F3,		/* F3 */
-	/* 61 */ KEY_F4,		/* F4 */
-	/* 62 */ KEY_F5,		/* F5 */
-	/* 63 */ KEY_F6,		/* F6 */
-	/* 64 */ KEY_F7,		/* F7 */
-	/* 65 */ KEY_F8,		/* F8 */
-	/* 66 */ KEY_F9,		/* F9 */
-	/* 67 */ KEY_F10,	/* F10 */
-	/* 68 */ KEY_F11,	/* F11 */
-	/* 69 */ KEY_F12,	/* F12 */
-	/* 70 */ KEY_Print,	/* PrintScrn SysReq */
-	/* 71 */ KEY_ScrollLock,	/* Scroll Lock */
-	/* 72 */ KEY_Pause,	/* Pause Break */
-	/* 73 */ KEY_Insert,	/* Insert XXX  Help on some Mac Keyboards */
-	/* 74 */ KEY_Home,	/* Home */
-	/* 75 */ KEY_PgUp,	/* Page Up */
-	/* 76 */ KEY_Delete,	/* Delete */
-	/* 77 */ KEY_End,	/* End */
-	/* 78 */ KEY_PgDown,	/* Page Down */
-	/* 79 */ KEY_Right,	/* Right Arrow */
-	/* 80 */ KEY_Left,	/* Left Arrow */
-	/* 81 */ KEY_Down,	/* Down Arrow */
-	/* 82 */ KEY_Up,		/* Up Arrow */
-	/* 83 */ KEY_NumLock,	/* Num Lock */
-	/* 84 */ KEY_KP_Divide,	/* Keypad / */
-	/* 85 */ KEY_KP_Multiply, /* Keypad * */
-	/* 86 */ KEY_KP_Minus,	/* Keypad - */
-	/* 87 */ KEY_KP_Plus,	/* Keypad + */
-	/* 88 */ KEY_KP_Enter,	/* Keypad Enter */
-	/* 89 */ KEY_KP_1,	/* Keypad 1 End */
-	/* 90 */ KEY_KP_2,	/* Keypad 2 Down */
-	/* 91 */ KEY_KP_3,	/* Keypad 3 Pg Down */
-	/* 92 */ KEY_KP_4,	/* Keypad 4 Left  */
-	/* 93 */ KEY_KP_5,	/* Keypad 5 */
-	/* 94 */ KEY_KP_6,	/* Keypad 6 */
-	/* 95 */ KEY_KP_7,	/* Keypad 7 Home */
-	/* 96 */ KEY_KP_8,	/* Keypad 8 Up */
-	/* 97 */ KEY_KP_9,	/* KEypad 9 Pg Up */
-	/* 98 */ KEY_KP_0,	/* Keypad 0 Ins */
-	/* 99 */ KEY_KP_Decimal,	/* Keypad . Del */
-	/* 100 */ KEY_Less,	/* < > on some keyboards */
-	/* 101 */ KEY_Menu,	/* Menu */
-	/* 102 */ KEY_NOTUSED,
-	/* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */
-	/* 104 */ KEY_NOTUSED,
-	/* 105 */ KEY_NOTUSED,
-	/* 106 */ KEY_NOTUSED,
-	/* 107 */ KEY_NOTUSED,
-	/* 108 */ KEY_NOTUSED,
-	/* 109 */ KEY_NOTUSED,
-	/* 110 */ KEY_NOTUSED,
-	/* 111 */ KEY_NOTUSED,
-	/* 112 */ KEY_NOTUSED,
-	/* 113 */ KEY_NOTUSED,
-	/* 114 */ KEY_NOTUSED,
-	/* 115 */ KEY_NOTUSED,
-	/* 116 */ KEY_NOTUSED,
-	/* 117 */ KEY_NOTUSED,
-	/* 118 */ KEY_NOTUSED,
-	/* 119 */ KEY_NOTUSED,
-	/* 120 */ KEY_NOTUSED,
-	/* 121 */ KEY_NOTUSED,
-	/* 122 */ KEY_NOTUSED,
-	/* 123 */ KEY_NOTUSED,
-	/* 124 */ KEY_NOTUSED,
-	/* 125 */ KEY_NOTUSED,
-	/* 126 */ KEY_NOTUSED,
-	/* 127 */ KEY_NOTUSED,
-	/* 128 */ KEY_NOTUSED,
-	/* 129 */ KEY_NOTUSED,
-	/* 130 */ KEY_NOTUSED,
-	/* 131 */ KEY_NOTUSED,
-	/* 132 */ KEY_NOTUSED,
-	/* 133 */ KEY_NOTUSED,
-	/* 134 */ KEY_NOTUSED,
-	/* 135 */ KEY_NOTUSED,
-	/* 136 */ KEY_NOTUSED,
-	/* 137 */ KEY_NOTUSED,
-	/* 138 */ KEY_NOTUSED,
-	/* 139 */ KEY_NOTUSED,
-	/* 140 */ KEY_NOTUSED,
-	/* 141 */ KEY_NOTUSED,
-	/* 142 */ KEY_NOTUSED,
-	/* 143 */ KEY_NOTUSED,
-	/* 144 */ KEY_NOTUSED,
-	/* 145 */ KEY_NOTUSED,
-	/* 146 */ KEY_NOTUSED,
-	/* 147 */ KEY_NOTUSED,
-	/* 148 */ KEY_NOTUSED,
-	/* 149 */ KEY_NOTUSED,
-	/* 150 */ KEY_NOTUSED,
-	/* 151 */ KEY_NOTUSED,
-	/* 152 */ KEY_NOTUSED,
-	/* 153 */ KEY_NOTUSED,
-	/* 154 */ KEY_NOTUSED,
-	/* 155 */ KEY_NOTUSED,
-	/* 156 */ KEY_NOTUSED,
-	/* 157 */ KEY_NOTUSED,
-	/* 158 */ KEY_NOTUSED,
-	/* 159 */ KEY_NOTUSED,
-	/* 160 */ KEY_NOTUSED,
-	/* 161 */ KEY_NOTUSED,
-	/* 162 */ KEY_NOTUSED,
-	/* 163 */ KEY_NOTUSED,
-	/* 164 */ KEY_NOTUSED,
-	/* 165 */ KEY_NOTUSED,
-	/* 166 */ KEY_NOTUSED,
-	/* 167 */ KEY_NOTUSED,
-	/* 168 */ KEY_NOTUSED,
-	/* 169 */ KEY_NOTUSED,
-	/* 170 */ KEY_NOTUSED,
-	/* 171 */ KEY_NOTUSED,
-	/* 172 */ KEY_NOTUSED,
-	/* 173 */ KEY_NOTUSED,
-	/* 174 */ KEY_NOTUSED,
-	/* 175 */ KEY_NOTUSED,
-	/* 176 */ KEY_NOTUSED,
-	/* 177 */ KEY_NOTUSED,
-	/* 178 */ KEY_NOTUSED,
-	/* 179 */ KEY_NOTUSED,
-	/* 180 */ KEY_NOTUSED,
-	/* 181 */ KEY_NOTUSED,
-	/* 182 */ KEY_NOTUSED,
-	/* 183 */ KEY_NOTUSED,
-	/* 184 */ KEY_NOTUSED,
-	/* 185 */ KEY_NOTUSED,
-	/* 186 */ KEY_NOTUSED,
-	/* 187 */ KEY_NOTUSED,
-	/* 188 */ KEY_NOTUSED,
-	/* 189 */ KEY_NOTUSED,
-	/* 190 */ KEY_NOTUSED,
-	/* 191 */ KEY_NOTUSED,
-	/* 192 */ KEY_NOTUSED,
-	/* 193 */ KEY_NOTUSED,
-	/* 194 */ KEY_NOTUSED,
-	/* 195 */ KEY_NOTUSED,
-	/* 196 */ KEY_NOTUSED,
-	/* 197 */ KEY_NOTUSED,
-	/* 198 */ KEY_NOTUSED,
-	/* 199 */ KEY_NOTUSED,
-	/* 200 */ KEY_NOTUSED,
-	/* 201 */ KEY_NOTUSED,
-	/* 202 */ KEY_NOTUSED,
-	/* 203 */ KEY_NOTUSED,
-	/* 204 */ KEY_NOTUSED,
-	/* 205 */ KEY_NOTUSED,
-	/* 206 */ KEY_NOTUSED,
-	/* 207 */ KEY_NOTUSED,
-	/* 208 */ KEY_NOTUSED,
-	/* 209 */ KEY_NOTUSED,
-	/* 210 */ KEY_NOTUSED,
-	/* 211 */ KEY_NOTUSED,
-	/* 212 */ KEY_NOTUSED,
-	/* 213 */ KEY_NOTUSED,
-	/* 214 */ KEY_NOTUSED,
-	/* 215 */ KEY_NOTUSED,
-	/* 216 */ KEY_NOTUSED,
-	/* 217 */ KEY_NOTUSED,
-	/* 218 */ KEY_NOTUSED,
-	/* 219 */ KEY_NOTUSED,
-	/* 220 */ KEY_NOTUSED,
-	/* 221 */ KEY_NOTUSED,
-	/* 222 */ KEY_NOTUSED,
-	/* 223 */ KEY_NOTUSED,
-	/* 224 */ KEY_LCtrl,	/* Left Control */
-	/* 225 */ KEY_ShiftL,	/* Left Shift */
-	/* 226 */ KEY_Alt,	/* Left Alt */
-	/* 227 */ KEY_LMeta,	/* Left Meta */
-	/* 228 */ KEY_RCtrl,	/* Right Control */
-	/* 229 */ KEY_ShiftR,	/* Right Shift */
-	/* 230 */ KEY_AltLang,	/* Right Alt, AKA AltGr */
-	/* 231 */ KEY_LMeta,	/* Right Meta XXX */
-};
-
-#define WS_USB_MAP_SIZE (sizeof(wsUsbMap)/sizeof(unsigned char))
-
-/* Map for adb keyboards  */
-static CARD8 wsAdbMap[] = {
-	/* 0 */ KEY_A,
-	/* 1 */ KEY_S,
-	/* 2 */ KEY_D,
-	/* 3 */ KEY_F,
-	/* 4 */ KEY_H,
-	/* 5 */ KEY_G,
-	/* 6 */ KEY_Z,
-	/* 7 */ KEY_X,
-	/* 8 */ KEY_C,
-	/* 9 */ KEY_V,
-	/* 10 */ KEY_UNKNOWN,	/* @ # on french keyboards */
-	/* 11 */ KEY_B,
-	/* 12 */ KEY_Q,
-	/* 13 */ KEY_W,
-	/* 14 */ KEY_E,
-	/* 15 */ KEY_R,
-	/* 16 */ KEY_Y,
-	/* 17 */ KEY_T,
-	/* 18 */ KEY_1,
-	/* 19 */ KEY_2,
-	/* 20 */ KEY_3,
-	/* 21 */ KEY_4,
-	/* 22 */ KEY_6,
-	/* 23 */ KEY_5,
-	/* 24 */ KEY_Equal,
-	/* 25 */ KEY_9,
-	/* 26 */ KEY_7,
-	/* 27 */ KEY_Minus,
-	/* 28 */ KEY_8,
-	/* 29 */ KEY_0,
-	/* 30 */ KEY_RBrace,
-	/* 31 */ KEY_O,
-	/* 32 */ KEY_U,
-	/* 33 */ KEY_LBrace,
-	/* 34 */ KEY_I,
-	/* 35 */ KEY_P,
-	/* 36 */ KEY_Enter,
-	/* 37 */ KEY_L,
-	/* 38 */ KEY_J,
-	/* 39 */ KEY_Quote,
-	/* 40 */ KEY_K,
-	/* 41 */ KEY_SemiColon,
-	/* 42 */ KEY_BSlash,
-	/* 43 */ KEY_Comma,
-	/* 44 */ KEY_Slash,
-	/* 45 */ KEY_N,
-	/* 46 */ KEY_M,
-	/* 47 */ KEY_Period,
-	/* 48 */ KEY_Tab,
-	/* 49 */ KEY_Space,
-	/* 50 */ KEY_Tilde,
-	/* 51 */ KEY_Delete,
-	/* 52 */ KEY_AltLang,
-	/* 53 */ KEY_Escape,
-	/* 54 */ KEY_LCtrl,
-	/* 55 */ KEY_Alt,
-	/* 56 */ KEY_ShiftL,
-	/* 57 */ KEY_CapsLock,
-	/* 58 */ KEY_LMeta,
-	/* 59 */ KEY_Left,
-	/* 60 */ KEY_Right,
-	/* 61 */ KEY_Down,
-	/* 62 */ KEY_Up,
-	/* 63 */ KEY_UNKNOWN,	/* Fn */
-	/* 64 */ KEY_NOTUSED,
-	/* 65 */ KEY_KP_Decimal,
-	/* 66 */ KEY_NOTUSED,
-	/* 67 */ KEY_KP_Multiply,
-	/* 68 */ KEY_NOTUSED,
-	/* 69 */ KEY_KP_Plus,
-	/* 70 */ KEY_NOTUSED,
-	/* 71 */ KEY_UNKNOWN,	/* Clear */
-	/* 72 */ KEY_NOTUSED, 
-	/* 73 */ KEY_NOTUSED,
-	/* 74 */ KEY_NOTUSED,
-	/* 75 */ KEY_KP_Divide,
-	/* 76 */ KEY_KP_Enter,
-	/* 77 */ KEY_NOTUSED,
-	/* 78 */ KEY_KP_Minus,
-	/* 79 */ KEY_NOTUSED,
-	/* 80 */ KEY_NOTUSED,
-	/* 81 */ KEY_KP_Equal,	/* Keypad = */
-	/* 82 */ KEY_KP_0,
-	/* 83 */ KEY_KP_1,
-	/* 84 */ KEY_KP_2,
-	/* 85 */ KEY_KP_3,
-	/* 86 */ KEY_KP_4,
-	/* 87 */ KEY_KP_5,
-	/* 88 */ KEY_KP_6,
-	/* 89 */ KEY_KP_7,
-	/* 90 */ KEY_NOTUSED,
-	/* 91 */ KEY_KP_8,
-	/* 92 */ KEY_KP_9,
-	/* 93 */ KEY_NOTUSED,
-	/* 94 */ KEY_NOTUSED,
-	/* 95 */ KEY_UNKNOWN,	/* Keypad ,  */
-	/* 96 */ KEY_F5,
-	/* 97 */ KEY_F6,
-	/* 98 */ KEY_F7,
-	/* 99 */ KEY_F3,
-	/* 100 */ KEY_F8,
-	/* 101 */ KEY_F9,
-	/* 102 */ KEY_NOTUSED,
-	/* 103 */ KEY_F11,
-	/* 104 */ KEY_NOTUSED,
-	/* 105 */ KEY_NOTUSED,
-	/* 106 */ KEY_KP_Enter,
-	/* 107 */ KEY_NOTUSED,
-	/* 108 */ KEY_NOTUSED,
-	/* 109 */ KEY_F10,
-	/* 110 */ KEY_NOTUSED,
-	/* 111 */ KEY_F12,
-	/* 112 */ KEY_NOTUSED,
-	/* 113 */ KEY_NOTUSED,
-	/* 114 */ KEY_NOTUSED,
-	/* 115 */ KEY_Home,
-	/* 116 */ KEY_PgUp,
-	/* 117 */ KEY_NOTUSED,
-	/* 118 */ KEY_F4,
-	/* 119 */ KEY_End,
-	/* 120 */ KEY_F2,
-	/* 121 */ KEY_PgDown,
-	/* 122 */ KEY_F1,
-	/* 123 */ KEY_NOTUSED,
-	/* 124 */ KEY_NOTUSED,
-	/* 125 */ KEY_NOTUSED,
-	/* 126 */ KEY_NOTUSED,
-	/* 127 */ KEY_NOTUSED,
-	/* 128 */ KEY_NOTUSED,
-	/* 129 */ KEY_NOTUSED,
-	/* 130 */ KEY_NOTUSED,
-	/* 131 */ KEY_NOTUSED,
-	/* 132 */ KEY_NOTUSED,
-	/* 133 */ KEY_NOTUSED,
-	/* 134 */ KEY_NOTUSED,
-	/* 135 */ KEY_NOTUSED,
-	/* 136 */ KEY_NOTUSED,
-	/* 137 */ KEY_NOTUSED,
-	/* 138 */ KEY_NOTUSED,
-	/* 139 */ KEY_NOTUSED,
-	/* 140 */ KEY_NOTUSED,
-	/* 141 */ KEY_NOTUSED,
-	/* 142 */ KEY_NOTUSED,
-	/* 143 */ KEY_NOTUSED,
-	/* 144 */ KEY_NOTUSED,
-	/* 145 */ KEY_NOTUSED,
-	/* 146 */ KEY_NOTUSED,
-	/* 147 */ KEY_NOTUSED,
-	/* 148 */ KEY_NOTUSED,
-	/* 149 */ KEY_NOTUSED,
-	/* 150 */ KEY_NOTUSED,
-	/* 151 */ KEY_NOTUSED,
-	/* 152 */ KEY_NOTUSED,
-	/* 153 */ KEY_NOTUSED,
-	/* 154 */ KEY_NOTUSED,
-	/* 155 */ KEY_NOTUSED,
-	/* 156 */ KEY_NOTUSED,
-	/* 157 */ KEY_NOTUSED,
-	/* 158 */ KEY_NOTUSED,
-	/* 159 */ KEY_NOTUSED,
-	/* 160 */ KEY_NOTUSED,
-	/* 161 */ KEY_NOTUSED,
-	/* 162 */ KEY_NOTUSED,
-	/* 163 */ KEY_NOTUSED,
-	/* 164 */ KEY_NOTUSED,
-	/* 165 */ KEY_NOTUSED,
-	/* 166 */ KEY_NOTUSED,
-	/* 167 */ KEY_NOTUSED,
-	/* 168 */ KEY_NOTUSED,
-	/* 169 */ KEY_NOTUSED,
-	/* 170 */ KEY_NOTUSED,
-	/* 171 */ KEY_NOTUSED,
-	/* 172 */ KEY_NOTUSED,
-	/* 173 */ KEY_NOTUSED,
-	/* 174 */ KEY_NOTUSED,
-	/* 175 */ KEY_NOTUSED,
-	/* 176 */ KEY_NOTUSED,
-	/* 177 */ KEY_NOTUSED,
-	/* 178 */ KEY_NOTUSED,
-	/* 179 */ KEY_NOTUSED,
-	/* 180 */ KEY_NOTUSED,
-	/* 181 */ KEY_NOTUSED,
-	/* 182 */ KEY_NOTUSED,
-	/* 183 */ KEY_NOTUSED,
-	/* 184 */ KEY_NOTUSED,
-	/* 185 */ KEY_NOTUSED,
-	/* 186 */ KEY_NOTUSED,
-	/* 187 */ KEY_NOTUSED,
-	/* 188 */ KEY_NOTUSED,
-	/* 189 */ KEY_NOTUSED,
-	/* 190 */ KEY_NOTUSED,
-	/* 191 */ KEY_NOTUSED,
-	/* 192 */ KEY_NOTUSED,
-	/* 193 */ KEY_NOTUSED,
-	/* 194 */ KEY_NOTUSED,
-	/* 195 */ KEY_NOTUSED,
-	/* 196 */ KEY_NOTUSED,
-	/* 197 */ KEY_NOTUSED,
-	/* 198 */ KEY_NOTUSED,
-	/* 199 */ KEY_NOTUSED,
-	/* 200 */ KEY_NOTUSED,
-	/* 201 */ KEY_NOTUSED,
-	/* 202 */ KEY_NOTUSED,
-	/* 203 */ KEY_NOTUSED,
-	/* 204 */ KEY_NOTUSED,
-	/* 205 */ KEY_NOTUSED,
-	/* 206 */ KEY_NOTUSED,
-	/* 207 */ KEY_NOTUSED,
-	/* 208 */ KEY_NOTUSED,
-	/* 209 */ KEY_NOTUSED,
-	/* 210 */ KEY_NOTUSED,
-	/* 211 */ KEY_NOTUSED,
-	/* 212 */ KEY_NOTUSED,
-	/* 213 */ KEY_NOTUSED,
-	/* 214 */ KEY_NOTUSED,
-	/* 215 */ KEY_NOTUSED,
-	/* 216 */ KEY_NOTUSED,
-	/* 217 */ KEY_NOTUSED,
-	/* 218 */ KEY_NOTUSED,
-	/* 219 */ KEY_NOTUSED,
-	/* 220 */ KEY_NOTUSED,
-	/* 221 */ KEY_NOTUSED,
-	/* 222 */ KEY_NOTUSED,
-	/* 223 */ KEY_NOTUSED,
-};
-
-#define WS_ADB_MAP_SIZE (sizeof(wsAdbMap)/sizeof(unsigned char))
-
-static CARD8 wsSunMap[] = {
-	/* 0x00 */ KEY_NOTUSED,
-	/* 0x01 */ KEY_NOTUSED,		/* stop */
-	/* 0x02 */ KEY_NOTUSED,		/* BrightnessDown / S-VolumeDown */
-	/* 0x03 */ KEY_NOTUSED,		/* again */
-	/* 0x04 */ KEY_NOTUSED,		/* BridgtnessUp / S-VolumeUp */
-	/* 0x05 */ KEY_F1,
-	/* 0x06 */ KEY_F2,
-	/* 0x07 */ KEY_F10,
-	/* 0x08 */ KEY_F3,
-	/* 0x09 */ KEY_F11,
-	/* 0x0a */ KEY_F4,
-	/* 0x0b */ KEY_F12,
-	/* 0x0c */ KEY_F5,
-	/* 0x0d */ KEY_AltLang,
-	/* 0x0e */ KEY_F6,
-	/* 0x0f */ KEY_NOTUSED,
-	/* 0x10 */ KEY_F7,
-	/* 0x11 */ KEY_F8,
-	/* 0x12 */ KEY_F9,
-	/* 0x13 */ KEY_Alt,
-	/* 0x14 */ KEY_Up,
-	/* 0x15 */ KEY_Pause,
-	/* 0x16 */ KEY_Print,
-	/* 0x17 */ KEY_NOTUSED,		/* props */
-	/* 0x18 */ KEY_Left,
-	/* 0x19 */ KEY_ScrollLock,
-	/* 0x1a */ KEY_NOTUSED,		/* undo */
-	/* 0x1b */ KEY_Down,
-	/* 0x1c */ KEY_Right,
-	/* 0x1d */ KEY_Escape,
-	/* 0x1e */ KEY_1,
-	/* 0x1f */ KEY_2,
-	/* 0x20 */ KEY_3,
-	/* 0x21 */ KEY_4,
-	/* 0x22 */ KEY_5,
-	/* 0x23 */ KEY_6,
-	/* 0x24 */ KEY_7,
-	/* 0x25 */ KEY_8,
-	/* 0x26 */ KEY_9,
-	/* 0x27 */ KEY_0,
-	/* 0x28 */ KEY_Minus,
-	/* 0x29 */ KEY_Equal,
-	/* 0x2a */ KEY_Tilde,
-	/* 0x2b */ KEY_BackSpace,
-	/* 0x2c */ KEY_Insert,
-	/* 0x2d */ KEY_KP_Equal,
-	/* 0x2e */ KEY_KP_Divide,
-	/* 0x2f */ KEY_KP_Multiply,
-	/* 0x30 */ KEY_NOTUSED,
-	/* 0x31 */ KEY_NOTUSED,		/* front */
-	/* 0x32 */ KEY_KP_Decimal,
-	/* 0x33 */ KEY_NOTUSED,		/* copy */
-	/* 0x34 */ KEY_Home,
-	/* 0x35 */ KEY_Tab,
-	/* 0x36 */ KEY_Q,
-	/* 0x37 */ KEY_W,
-	/* 0x38 */ KEY_E,
-	/* 0x39 */ KEY_R,
-	/* 0x3a */ KEY_T,
-	/* 0x3b */ KEY_Y,
-	/* 0x3c */ KEY_U,
-	/* 0x3d */ KEY_I,
-	/* 0x3e */ KEY_O,
-	/* 0x3f */ KEY_P,
-	/* 0x40 */ KEY_LBrace,
-	/* 0x41 */ KEY_RBrace,
-	/* 0x42 */ KEY_Delete,
-	/* 0x43 */ KEY_NOTUSED,		/* compose */
-	/* 0x44 */ KEY_KP_7,
-	/* 0x45 */ KEY_KP_8,
-	/* 0x46 */ KEY_KP_9,
-	/* 0x47 */ KEY_KP_Minus,
-	/* 0x48 */ KEY_NOTUSED,		/* open */
-	/* 0x49 */ KEY_NOTUSED,		/* paste */
-	/* 0x4a */ KEY_End,
-	/* 0x4b */ KEY_NOTUSED,
-	/* 0x4c */ KEY_LCtrl,
-	/* 0x4d */ KEY_A,
-	/* 0x4e */ KEY_S,
-	/* 0x4f */ KEY_D,
-	/* 0x50 */ KEY_F,
-	/* 0x51 */ KEY_G,
-	/* 0x52 */ KEY_H,
-	/* 0x53 */ KEY_J,
-	/* 0x54 */ KEY_K,
-	/* 0x55 */ KEY_L,
-	/* 0x56 */ KEY_SemiColon,
-	/* 0x57 */ KEY_Quote,
-	/* 0x58 */ KEY_BSlash,
-	/* 0x59 */ KEY_Enter,
-	/* 0x5a */ KEY_KP_Enter,
-	/* 0x5b */ KEY_KP_4,
-	/* 0x5c */ KEY_KP_5,
-	/* 0x5d */ KEY_KP_6,
-	/* 0x5e */ KEY_KP_0,
-	/* 0x5f */ KEY_NOTUSED,		/* find */
-	/* 0x60 */ KEY_PgUp,
-	/* 0x61 */ KEY_NOTUSED,		/* cut */
-	/* 0x62 */ KEY_NumLock,
-	/* 0x63 */ KEY_ShiftL,
-	/* 0x64 */ KEY_Z,
-	/* 0x65 */ KEY_X,
-	/* 0x66 */ KEY_C,
-	/* 0x67 */ KEY_V,
-	/* 0x68 */ KEY_B,
-	/* 0x69 */ KEY_N,
-	/* 0x6a */ KEY_M,
-	/* 0x6b */ KEY_Comma,
-	/* 0x6c */ KEY_Period,
-	/* 0x6d */ KEY_Slash,
-	/* 0x6e */ KEY_ShiftR,
-	/* 0x6f */ KEY_NOTUSED,		/* linefeed */
-	/* 0x70 */ KEY_KP_1,
-	/* 0x71 */ KEY_KP_2,
-	/* 0x72 */ KEY_KP_3,
-	/* 0x73 */ KEY_NOTUSED,
-	/* 0x74 */ KEY_NOTUSED,
-	/* 0x75 */ KEY_NOTUSED,
-	/* 0x76 */ KEY_NOTUSED,		/* help */
-	/* 0x77 */ KEY_CapsLock,
-	/* 0x78 */ KEY_LMeta,
-	/* 0x79 */ KEY_Space,
-	/* 0x7a */ KEY_RMeta,
-	/* 0x7b */ KEY_PgDown,
-	/* 0x7c */ KEY_NOTUSED,
-	/* 0x7d */ KEY_KP_Plus,
-	/* 0x7e */ KEY_NOTUSED,
-	/* 0x7f */ KEY_NOTUSED
-};
-
-#define WS_SUN_MAP_SIZE (sizeof(wsSunMap)/sizeof(unsigned char))
-
-/*
- * Translate raw wskbd keyboard event values to XFree86 standard keycodes
- * (based on the AT keyboard scan codes using the tables above
- */
-int 
-WSKbdToKeycode(int keycode)
-{
-	switch (xf86Info.wsKbdType) {
-	case WSKBD_TYPE_PC_XT:
-	case WSKBD_TYPE_PC_AT:
-		/* No translation needed */
-		return keycode;
-	case WSKBD_TYPE_USB:
-		if (keycode < 0 || keycode >= WS_USB_MAP_SIZE) 
-			return KEY_UNKNOWN;
-		else 
-			return wsUsbMap[keycode];
-#ifdef WSKBD_TYPE_ADB
-	case WSKBD_TYPE_ADB:
-		if (keycode < 0 || keycode >= WS_ADB_MAP_SIZE) 
-			return KEY_UNKNOWN;
-		else 
-			return wsAdbMap[keycode];
-#endif
-#ifdef WSKBD_TYPE_SUN
-	case WSKBD_TYPE_SUN:
-#ifdef WSKBD_TYPE_SUN5
-	case WSKBD_TYPE_SUN5:
-#endif
-		if (keycode < 0 || keycode >= WS_SUN_MAP_SIZE)
-			return KEY_UNKNOWN;
-		else
-			return wsSunMap[keycode];
-#endif
-	default:
-		ErrorF("Unknown wskbd type %d\n", xf86Info.wsKbdType);
-		return KEY_UNKNOWN;
-	}
-}
-
-#endif /* WSCONS_SUPPORT */
diff --git a/hw/xfree86/common/xf86KbdLnx.c b/hw/xfree86/common/xf86KbdLnx.c
deleted file mode 100644
index 74cb42d..0000000
--- a/hw/xfree86/common/xf86KbdLnx.c
+++ /dev/null
@@ -1,650 +0,0 @@
-/*
- * 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.
- *
- */
-/*
- * Copyright (c) 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).
- */
-
-/* $XConsortium: xf86KbdLnx.c /main/7 1996/10/19 17:59:00 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "atKeynames.h"
-
-#include "xf86Keymap.h"
-
-/*
- * LegalModifier --
- *      determine whether a key is a legal modifier key, i.e send a
- *      press/release sequence.
- */
-
-/*ARGSUSED*/
-Bool
-LegalModifier(unsigned int key, DevicePtr pDev)
-{
-  return (TRUE);
-}
-
-/*
- * xf86KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-static void readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap);
-
-void
-xf86KbdGetMapping (KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
-  KeySym        *k;
-  char          type;
-  int           i;
-
-  readKernelMapping(pKeySyms, pModMap);
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = map, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4)
-    
-    switch(*k) {
-      
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-
-    }
-  
-  xf86Info.kbdType =
-    ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101;
-
-  pKeySyms->map        = map;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  pKeySyms->maxKeyCode = MAX_KEYCODE; 
-}
-
-#include <linux/keyboard.h>
-
-static KeySym linux_to_x[256] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_BackSpace,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_nobreakspace,XK_exclamdown,	XK_cent,	XK_sterling,
-	XK_currency,	XK_yen,		XK_brokenbar,	XK_section,
-	XK_diaeresis,	XK_copyright,	XK_ordfeminine,	XK_guillemotleft,
-	XK_notsign,	XK_hyphen,	XK_registered,	XK_macron,
-	XK_degree,	XK_plusminus,	XK_twosuperior,	XK_threesuperior,
-	XK_acute,	XK_mu,		XK_paragraph,	XK_periodcentered,
-	XK_cedilla,	XK_onesuperior,	XK_masculine,	XK_guillemotright,
-	XK_onequarter,	XK_onehalf,	XK_threequarters,XK_questiondown,
-	XK_Agrave,	XK_Aacute,	XK_Acircumflex,	XK_Atilde,
-	XK_Adiaeresis,	XK_Aring,	XK_AE,		XK_Ccedilla,
-	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
-	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
-	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
-	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_multiply,
-	XK_Ooblique,	XK_Ugrave,	XK_Uacute,	XK_Ucircumflex,
-	XK_Udiaeresis,	XK_Yacute,	XK_THORN,	XK_ssharp,
-	XK_agrave,	XK_aacute,	XK_acircumflex,	XK_atilde,
-	XK_adiaeresis,	XK_aring,	XK_ae,		XK_ccedilla,
-	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
-	XK_igrave,	XK_iacute,	XK_icircumflex,	XK_idiaeresis,
-	XK_eth,		XK_ntilde,	XK_ograve,	XK_oacute,
-	XK_ocircumflex,	XK_otilde,	XK_odiaeresis,	XK_division,
-	XK_oslash,	XK_ugrave,	XK_uacute,	XK_ucircumflex,
-	XK_udiaeresis,	XK_yacute,	XK_thorn,	XK_ydiaeresis
-};
-
-/*
- * Maps the AT keycodes to Linux keycodes
- */
-static unsigned char at2lnx[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 */
-};
-#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
-
-#define NUM_CUSTOMKEYS	NR_KEYS
-
-u_char SpecialServerMap[NUM_CUSTOMKEYS];
-
-static void
-readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
-  KeySym        *k;
-  int           i;
-  int           maxkey;
-  static unsigned char tbl[GLYPHS_PER_KEY] =
-  {
-	0,	/* unshifted */
-	1,	/* shifted */
-	0,	/* modeswitch unshifted */
-	0	/* modeswitch shifted */
-  };
-
-  /*
-   * Read the mapping from the kernel.
-   * Since we're still using the XFree86 scancode->AT keycode mapping
-   * routines, we need to convert the AT keycodes to Linux keycodes,
-   * then translate the Linux keysyms into X keysyms.
-   *
-   * First, figure out which tables to use for the modeswitch columns
-   * above, from the XF86Config fields.
-   */
-  tbl[2] = 8;	/* alt */
-  tbl[3] = tbl[2] | 1;
-
-  if (xf86Info.kbdCustomKeycodes) {
-    k = map;
-    maxkey = NUM_CUSTOMKEYS;
-  }
-  else {
-    k = map+GLYPHS_PER_KEY;
-    maxkey = NUM_AT2LNX;
-  }
-
-  for (i = 0; i < maxkey; ++i)
-  {
-    struct kbentry kbe;
-    int j;
-
-    if (xf86Info.kbdCustomKeycodes)
-      kbe.kb_index = i;
-    else
-      kbe.kb_index = at2lnx[i];
-
-    for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k)
-    {
-      unsigned short kval;
-
-      *k = NoSymbol;
-
-      kbe.kb_table = tbl[j];
-      if (
-	  (!xf86Info.kbdCustomKeycodes && kbe.kb_index == 0) ||
-	  ioctl(xf86Info.consoleFd, KDGKBENT, &kbe))
-	continue;
-
-      kval = KVAL(kbe.kb_value);
-      switch (KTYP(kbe.kb_value))
-      {
-      case KT_LATIN:
-      case KT_LETTER:
-	*k = linux_to_x[kval];
-	break;
-
-      case KT_FN:
-	if (kval <= 19)
-	  *k = XK_F1 + kval;
-	else switch (kbe.kb_value)
-	{
-	case K_FIND:
-	  *k = XK_Home; /* or XK_Find */
-	  break;
-	case K_INSERT:
-	  *k = XK_Insert;
-	  break;
-	case K_REMOVE:
-	  *k = XK_Delete;
-	  break;
-	case K_SELECT:
-	  *k = XK_End; /* or XK_Select */
-	  break;
-	case K_PGUP:
-	  *k = XK_Prior;
-	  break;
-	case K_PGDN:
-	  *k = XK_Next;
-	  break;
-	case K_HELP:
-	  *k = XK_Help;
-	  break;
-	case K_DO:
-	  *k = XK_Execute;
-	  break;
-	case K_PAUSE:
-	  *k = XK_Pause;
-	  break;
-	case K_MACRO:
-	  *k = XK_Menu;
-	  break;
-	default:
-	  break;
-	}
-	break;
-
-      case KT_SPEC:
-	switch (kbe.kb_value)
-	{
-	case K_ENTER:
-	  *k = XK_Return;
-	  break;
-	case K_BREAK:
-	  *k = XK_Break;
-	  break;
-	case K_CAPS:
-	  *k = XK_Caps_Lock;
-	  break;
-	case K_NUM:
-	  *k = XK_Num_Lock;
-	  break;
-	case K_HOLD:
-	  *k = XK_Scroll_Lock;
-	  break;
-	case K_COMPOSE:
-          *k = XK_Multi_key;
-	  break;
-	default:
-	  break;
-	}
-	break;
-
-      case KT_PAD:
-	switch (kbe.kb_value)
-	{
-	case K_PPLUS:
-	  *k = XK_KP_Add;
-	  break;
-	case K_PMINUS:
-	  *k = XK_KP_Subtract;
-	  break;
-	case K_PSTAR:
-	  *k = XK_KP_Multiply;
-	  break;
-	case K_PSLASH:
-	  *k = XK_KP_Divide;
-	  break;
-	case K_PENTER:
-	  *k = XK_KP_Enter;
-	  break;
-	case K_PCOMMA:
-	  *k = XK_KP_Separator;
-	  break;
-	case K_PDOT:
-	  *k = XK_KP_Decimal;
-	  break;
-	case K_PPLUSMINUS:
-	  *k = XK_KP_Subtract;
-	  break;
-	default:
-	  if (kval <= 9)
-	    *k = XK_KP_0 + kval;
-	  break;
-	}
-	break;
-
-      /*
-       * KT_DEAD keys are for accelerated diacritical creation.
-       */
-      case KT_DEAD:
-	switch (kbe.kb_value)
-	  {
-	  case K_DGRAVE:
-	    *k = XK_dead_grave;
-	    break;
-	  case K_DACUTE:
-	    *k = XK_dead_acute;
-	    break;
-	  case K_DCIRCM:
-	    *k = XK_dead_circumflex;
-	    break;
-	  case K_DTILDE:
-	    *k = XK_dead_tilde;
-	    break;
-	  case K_DDIERE:
-	    *k = XK_dead_diaeresis;
-	    break;
-	  }
-	break;
-
-      case KT_CUR:
-	switch (kbe.kb_value)
-	{
-	case K_DOWN:
-	  *k = XK_Down;
-	  break;
-	case K_LEFT:
-	  *k = XK_Left;
-	  break;
-	case K_RIGHT:
-	  *k = XK_Right;
-	  break;
-	case K_UP:
-	  *k = XK_Up;
-	  break;
-	}
-	break;
-
-      case KT_SHIFT:
-	switch (kbe.kb_value)
-	{
-	case K_ALTGR:
-	  *k = XK_Alt_R;
-	  break;
-	case K_ALT:
-	  *k = (kbe.kb_index == 0x64 ?
-		XK_Alt_R : XK_Alt_L);
-	  break;
-	case K_CTRL:
-	  *k = (kbe.kb_index == 0x61 ?
-		XK_Control_R : XK_Control_L);
-	  break;
-        case K_CTRLL:
-	  *k = XK_Control_L;
-	  break;
-        case K_CTRLR:
-	  *k = XK_Control_R;
-	  break;
-	case K_SHIFT:
-	  *k = (kbe.kb_index == 0x36 ?
-		XK_Shift_R : XK_Shift_L);
-	  break;
-        case K_SHIFTL:
-	  *k = XK_Shift_L;
-	  break;
-        case K_SHIFTR:
-	  *k = XK_Shift_R;
-	  break;
-	default:
-	  break;
-	}
-	break;
-
-      /*
-       * KT_ASCII keys accumulate a 3 digit decimal number that gets
-       * emitted when the shift state changes. We can't emulate that.
-       */
-      case KT_ASCII:
-	break;
-
-      case KT_LOCK:
-	if (kbe.kb_value == K_SHIFTLOCK)
-	  *k = XK_Shift_Lock;
-	break;
-
-      default:
-	break;
-      }
-    }
-
-    if (k[-1] == k[-2]) k[-1] = NoSymbol;
-    if (k[-2] == k[-3]) k[-2] = NoSymbol;
-    if (k[-3] == k[-4]) k[-3] = NoSymbol;
-    if (k[-4] == k[-2] && k[-3] == k[-1]) k[-2] = k[-1] = NoSymbol;
-    if (k[-1] == k[-4] && k[-2] == k[-3] && k[-2] == NoSymbol) k[-1] =NoSymbol;
-  }
-
-  if (!xf86Info.kbdCustomKeycodes)
-    return;
-
-  /*
-   * Find the Mapping for the special server functions
-   */
-  for (i = 0; i < NUM_CUSTOMKEYS; ++i) {
-    struct kbentry kbe;
-    int special = 0;
-
-    kbe.kb_index = i;
-    kbe.kb_table = 0; /* Plain map */
-    if (!ioctl(xf86Info.consoleFd, KDGKBENT, &kbe))
-      switch (kbe.kb_value) {
-	case K(KT_LATIN,0x7f):	/* This catches DEL too... But who cares? */
-	  special = KEY_BackSpace;
-	  break;
-	case K_PMINUS:
-	  special = KEY_KP_Minus;
-	  break;
-	case K_PPLUS:
-	  special = KEY_KP_Plus;
-	  break;
-	case K_F1:
-	  special = KEY_F1;
-	  break;
-	case K_F2:
-	  special = KEY_F2;
-	  break;
-	case K_F3:
-	  special = KEY_F3;
-	  break;
-	case K_F4:
-	  special = KEY_F4;
-	  break;
-	case K_F5:
-	  special = KEY_F5;
-	  break;
-	case K_F6:
-	  special = KEY_F6;
-	  break;
-	case K_F7:
-	  special = KEY_F7;
-	  break;
-	case K_F8:
-	  special = KEY_F8;
-	  break;
-	case K_F9:
-	  special = KEY_F9;
-	  break;
-	case K_F10:
-	  special = KEY_F10;
-	  break;
-	case K_F11:
-	  special = KEY_F11;
-	  break;
-	case K_F12:
-	  special = KEY_F12;
-	  break;
-	case K_ALT:
-	  special = KEY_Alt;
-	  break;
-	case K_ALTGR:
-	  special = KEY_AltLang;
-	  break;
-	case K_CONS:
-	  special = KEY_SysReqest;
-	  break;
-      }
-    SpecialServerMap[i] = special;
-  }
-}
diff --git a/hw/xfree86/common/xf86KbdMach.c b/hw/xfree86/common/xf86KbdMach.c
deleted file mode 100644
index 82e3c72..0000000
--- a/hw/xfree86/common/xf86KbdMach.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- *****************************************************************************
- * HISTORY
- * Log:	xf86KbdMach.c,v
- * Revision 2.1.2.1  92/06/25  10:32:08  moore
- * 	Incorporate the Elliot Dresselhaus's, Ernest Hua's and local changes
- * 	to run Thomas Roell's I386 color X11R5.  Original code only worked
- * 	with SCO Unix.  New code works with 2.5 and 3.0 Mach
- * 	[92/06/24            rvb]
- * 
- * 	EndLog
- * 
- *****************************************************************************
- */
-/*
- * 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.
- *
- */
-/* $XConsortium: xf86KbdMach.c /main/9 1996/02/21 17:38:43 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "atKeynames.h"
-#include "xf86Config.h"
-
-#include "xf86Keymap.h"
-
-static KeySym ascii_to_x[256] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	XK_Ccedilla,	XK_udiaeresis,	XK_eacute,	XK_acircumflex,
-	XK_adiaeresis,	XK_agrave,	XK_aring,	XK_ccedilla,
-	XK_ecircumflex,	XK_ediaeresis,	XK_egrave,	XK_idiaeresis,
-	XK_icircumflex,	XK_igrave,	XK_Adiaeresis,	XK_Aring,
-	XK_Eacute,	XK_ae,		XK_AE,		XK_ocircumflex,
-	XK_odiaeresis,	XK_ograve,	XK_ucircumflex,	XK_ugrave,
-	XK_ydiaeresis,	XK_Odiaeresis,	XK_Udiaeresis,	XK_cent,
-	XK_sterling,	XK_yen,		XK_paragraph,	XK_section,
-	XK_aacute,	XK_iacute,	XK_oacute,	XK_uacute,
-	XK_ntilde,	XK_Ntilde,	XK_ordfeminine,	XK_masculine,
-	XK_questiondown,XK_hyphen,	XK_notsign,	XK_onehalf,
-	XK_onequarter,	XK_exclamdown,	XK_guillemotleft,XK_guillemotright,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Greek_alpha,	XK_ssharp,	XK_Greek_GAMMA,	XK_Greek_pi,
-	XK_Greek_SIGMA,	XK_Greek_sigma,	XK_mu,	        XK_Greek_tau,
-	XK_Greek_PHI,	XK_Greek_THETA,	XK_Greek_OMEGA,	XK_Greek_delta,
-	XK_infinity,	XK_Ooblique,	XK_Greek_epsilon, XK_intersection,
-	XK_identical,	XK_plusminus,	XK_greaterthanequal, XK_lessthanequal,
-	XK_topintegral,	XK_botintegral,	XK_division,	XK_similarequal,
-	XK_degree,	NoSymbol,	NoSymbol,	XK_radical,
-	XK_Greek_eta,	XK_twosuperior,	XK_periodcentered, NoSymbol,
-      };
-
-/*
- * LegalModifier --
- *      determine whether a key is a legal modifier key, i.e send a
- *      press/release sequence.
- */
-
-/*ARGSUSED*/
-Bool
-LegalModifier(key, pDev)
-     unsigned int  key;
-     DevicePtr  pDev;
-{
-  return (TRUE);
-}
-
-
-      
-/*
- * xf86KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-void
-xf86KbdGetMapping (pKeySyms, pModMap)
-     KeySymsPtr pKeySyms;
-     CARD8      *pModMap;
-{
-  KeySym        *k;
-  struct	kbentry kbe;
-  char          type;
-  int           i, j;
-  
-  for (i = 0; i < NUMKEYS; i++)
-    {
-      static int states[] = { NORM_STATE, SHIFT_STATE, ALT_STATE, SHIFT_ALT };
-      int j;
-
-      k = &map[i*4];
-      kbe.kb_index = i;
-	
-      for (j = 0; j < 4; j++)
-	{
-	  kbe.kb_state = states[j];
-
-	  if (ioctl (xf86Info.consoleFd, KDGKBENT, &kbe) != -1)
-	    continue;
-      
-	  if (kbe.kb_value [0] == K_SCAN)
-	    {
-	      int keycode = -1;
-	      switch (kbe.kb_value [1])
-		{
-		case K_CTLSC: keycode = XK_Control_L; break;
-		case K_LSHSC: keycode = XK_Shift_L; break;
-		case K_RSHSC: keycode = XK_Shift_R; break;
-		case K_ALTSC: keycode = XK_Alt_L; break;
-		case K_CLCKSC: keycode = XK_Caps_Lock; break;
-		case K_NLCKSC: keycode = XK_Num_Lock; break;
-		default: break;
-		}
-	      if (keycode > 0)
-		k[j] = keycode;
-	    }
-	  else if (kbe.kb_value[1] != NC)
-	    {
-	      /* How to handle multiple characters?
-	         Ignore them for now. */
-	    }
-	  else
-	    {
-	      k[j] = ascii_to_x[kbe.kb_value[0]];
-	    }
-	}
-    }
-
-  /*
-   * Apply the special key mapping specified in XF86Config 
-   */
-  for (k = map, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4) {
-    switch (k[0]) {
-      case XK_Alt_L:
-        j = K_INDEX_LEFTALT;
-        break;
-      case XK_Alt_R:
-        j = K_INDEX_RIGHTALT;
-        break;
-      case XK_Scroll_Lock:
-        j = K_INDEX_SCROLLLOCK;
-        break;
-      case XK_Control_R:
-        j = K_INDEX_RIGHTCTL;
-        break;
-      default:
-        j = -1;
-    }
-    if (j >= 0)
-      switch (xf86Info.specialKeyMap[j]) {
-        case KM_META:
-          if (k[0] == XK_Alt_R)
-            k[1] = XK_Meta_R;
-          else {
-            k[0] = XK_Alt_L;
-            k[1] = XK_Meta_L;
-          }
-          break;
-        case KM_COMPOSE:
-          k[0] = XK_Multi_key;
-          break;
-        case KM_MODESHIFT:
-          k[0] = XK_Mode_switch;
-          k[1] = NoSymbol;
-          break;
-        case KM_MODELOCK:
-          k[0] = XK_Mode_switch;
-          k[1] = XF86XK_ModeLock;
-          break;
-        case KM_SCROLLLOCK:
-          k[0] = XK_Scroll_Lock;
-          break;
-        case KM_CONTROL:
-          k[0] = XK_Control_R;
-          break;
-      }
-  }
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = map, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4)
-    
-    switch(*k) {
-      
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-
-    }
-  
-  xf86Info.kbdType =
-    ioctl(xf86Info.kbdFd, KDGKBDTYPE, &type) != -1 ? type : KB_VANILLAKB;
-
-  pKeySyms->map        = map;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  if (xf86Info.serverNumLock)
-    pKeySyms->maxKeyCode = MAX_KEYCODE; 
-  else
-    pKeySyms->maxKeyCode = MAX_STD_KEYCODE;
-
-}
diff --git a/hw/xfree86/os-support/linux/lnx_kbd.c b/hw/xfree86/os-support/linux/lnx_kbd.c
deleted file mode 100644
index a4890d2..0000000
--- a/hw/xfree86/os-support/linux/lnx_kbd.c
+++ /dev/null
@@ -1,530 +0,0 @@
-
-/*
- * Copyright (c) 2002 by The XFree86 Project, Inc.
- * Author: Ivan Pascal.
- *
- * Based on the code from lnx_io.c which is
- * Copyright 1992 by Orest Zborowski <obz at Kodak.com>
- * Copyright 1993 by David Dawes <dawes at xfree86.org>
- */
-
-#define NEED_EVENTS
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#include "xf86Xinput.h"
-#include "xf86OSKbd.h"
-#include "atKeynames.h"
-#if defined(DO_OS_FONTRESTORE)
-#include "lnx.h"
-#endif
-#include "lnx_kbd.h"
-
-#define KBC_TIMEOUT 250        /* Timeout in ms for sending to keyboard controller */
-
-static KbdProtocolRec protocols[] = {
-   {"standard", PROT_STD },
-   { NULL, PROT_UNKNOWN_KBD }
-};
-
-extern Bool VTSwitchEnabled;
-#ifdef USE_VT_SYSREQ
-extern Bool VTSysreqToggle;
-#endif
-
-static void
-SoundBell(InputInfoPtr pInfo, int loudness, int pitch, int duration)
-{
-	if (loudness && pitch)
-	{
-		ioctl(pInfo->fd, KDMKTONE,
-		      ((1193190 / pitch) & 0xffff) |
-		      (((unsigned long)duration *
-			loudness / 50) << 16));
-	}
-}
-
-static void
-SetKbdLeds(InputInfoPtr pInfo, int leds)
-{
-    int real_leds = 0;
-
-#if defined (__sparc__)
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    if (pKbd->sunKbd) {
-  	if (leds & 0x08) real_leds |= XLED1;
-  	if (leds & 0x04) real_leds |= XLED3;
-  	if (leds & 0x02) real_leds |= XLED4;
-  	if (leds & 0x01) real_leds |= XLED2;
-        leds = real_leds;
-        real_leds = 0;
-    }
-#endif /* defined (__sparc__) */
-#ifdef LED_CAP
-    if (leds & XLED1)  real_leds |= LED_CAP;
-    if (leds & XLED2)  real_leds |= LED_NUM;
-    if (leds & XLED3)  real_leds |= LED_SCR;
-#ifdef LED_COMP
-    if (leds & XLED4)  real_leds |= LED_COMP;
-#else
-    if (leds & XLED4)  real_leds |= LED_SCR;
-#endif
-#endif
-    ioctl(pInfo->fd, KDSETLED, real_leds);
-}
-
-static int
-GetKbdLeds(InputInfoPtr pInfo)
-{
-    int real_leds, leds = 0;
-
-    ioctl(pInfo->fd, KDGETLED, &real_leds);
-
-    if (real_leds & LED_CAP) leds |= XLED1;
-    if (real_leds & LED_NUM) leds |= XLED2;
-    if (real_leds & LED_SCR) leds |= XLED3;
-
-    return(leds);
-}
-
-static int
-KDKBDREP_ioctl_ok(int rate, int delay) {
-#if defined(KDKBDREP) && !defined(__sparc__)
-     /* This ioctl is defined in <linux/kd.h> but is not
-	implemented anywhere - must be in some m68k patches. */
-   struct kbd_repeat kbdrep_s;
-
-   /* don't change, just test */
-   kbdrep_s.LNX_KBD_PERIOD_NAME = -1;
-   kbdrep_s.delay = -1;
-   if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
-       return 0;
-   }
-
-   /* do the change */
-   if (rate == 0)				/* switch repeat off */
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 0;
-   else
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 10000 / rate; /* convert cps to msec */
-   if (kbdrep_s.LNX_KBD_PERIOD_NAME < 1)
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 1;
-   kbdrep_s.delay = delay;
-   if (kbdrep_s.delay < 1)
-     kbdrep_s.delay = 1;
-   
-   if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
-       return 0;
-   }
-
-   return 1;			/* success! */
-#else /* no KDKBDREP */
-   return 0;
-#endif /* KDKBDREP */
-}
-
-static int
-KIOCSRATE_ioctl_ok(int rate, int delay) {
-#ifdef KIOCSRATE
-   struct kbd_rate kbdrate_s;
-   int fd;
-
-   fd = open("/dev/kbd", O_RDONLY);
-   if (fd == -1) 
-     return 0;   
-
-   kbdrate_s.rate = (rate + 5) / 10;  /* must be integer, so round up */
-   kbdrate_s.delay = delay * HZ / 1000;  /* convert ms to Hz */
-   if (kbdrate_s.rate > 50)
-     kbdrate_s.rate = 50;
-
-   if (ioctl( fd, KIOCSRATE, &kbdrate_s )) {
-       return 0;
-   }
-
-   close( fd );
-
-   return 1;
-#else /* no KIOCSRATE */
-   return 0;
-#endif /* KIOCSRATE */
-}
-
-#undef rate
-
-static void
-SetKbdRepeat(InputInfoPtr pInfo, char rad)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  int i;
-  int timeout;
-  int         value = 0x7f;    /* Maximum delay with slowest rate */
-
-#ifdef __sparc__
-  int         rate  = 500;     /* Default rate */
-  int         delay = 200;     /* Default delay */
-#else
-  int         rate  = 300;     /* Default rate */
-  int         delay = 250;     /* Default delay */
-#endif
-
-  static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
-			       133, 120, 109, 100, 92, 86, 80, 75, 67,
-			       60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
-			       25, 23, 21, 20 };
-#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
-
-  static int valid_delays[] = { 250, 500, 750, 1000 };
-#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
-
-  if (pKbd->rate >= 0) 
-    rate = pKbd->rate * 10;
-  if (pKbd->delay >= 0)
-    delay = pKbd->delay;
-
-  if(KDKBDREP_ioctl_ok(rate, delay)) 	/* m68k? */
-    return;
-
-  if(KIOCSRATE_ioctl_ok(rate, delay))	/* sparc? */
-    return;
-
-  if (xf86IsPc98())
-    return;
-
-#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
-
-  if (!xorgHWAccess) {
-      if (xf86EnableIO())
-	  xorgHWAccess = TRUE;
-      else 
-	  return;
-  }
-      
-  /* The ioport way */
-
-  for (i = 0; i < RATE_COUNT; i++)
-    if (rate >= valid_rates[i]) {
-      value &= 0x60;
-      value |= i;
-      break;
-    }
-
-  for (i = 0; i < DELAY_COUNT; i++)
-    if (delay <= valid_delays[i]) {
-      value &= 0x1f;
-      value |= i << 5;
-      break;
-    }
-
-  timeout = KBC_TIMEOUT;
-  while (((inb(0x64) & 2) == 2) && --timeout)
-       usleep(1000); /* wait */
-
-  if (timeout == 0)
-      return;
-
-  outb(0x60, 0xf3);             /* set typematic rate */
-  while (((inb(0x64) & 2) == 2) && --timeout)
-       usleep(1000); /* wait */
-
-  usleep(10000);
-  outb(0x60, value);
-
-#endif /* __alpha__ || __i386__ || __ia64__ */
-}
-
-typedef struct {
-   int kbdtrans;
-   struct termios kbdtty;
-} LnxKbdPrivRec, *LnxKbdPrivPtr;
-
-static int
-KbdInit(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
-
-    if (pKbd->isConsole) {
-        ioctl (pInfo->fd, KDGKBMODE, &(priv->kbdtrans));
-        tcgetattr (pInfo->fd, &(priv->kbdtty));
-    }
-    if (!pKbd->CustomKeycodes) {
-        pKbd->RemapScanCode = ATScancode;
-    }
-
-    return Success;
-}
-
-static int
-KbdOn(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
-    struct termios nTty;
-
-    if (pKbd->isConsole) {
-	if (pKbd->CustomKeycodes)
-	    ioctl(pInfo->fd, KDSKBMODE, K_MEDIUMRAW);
-	else
-	    ioctl(pInfo->fd, KDSKBMODE, K_RAW);
-
-	nTty = priv->kbdtty;
-	nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
-	nTty.c_oflag = 0;
-	nTty.c_cflag = CREAD | CS8;
-	nTty.c_lflag = 0;
-	nTty.c_cc[VTIME]=0;
-	nTty.c_cc[VMIN]=1;
-	cfsetispeed(&nTty, 9600);
-	cfsetospeed(&nTty, 9600);
-	tcsetattr(pInfo->fd, TCSANOW, &nTty);
-    }
-    return Success;
-}
-
-static int
-KbdOff(InputInfoPtr pInfo, int what)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    LnxKbdPrivPtr priv = (LnxKbdPrivPtr) pKbd->private;
-
-    if (pKbd->isConsole) {
-	ioctl(pInfo->fd, KDSKBMODE, priv->kbdtrans);
-	tcsetattr(pInfo->fd, TCSANOW, &(priv->kbdtty));
-    }
-    return Success;
-}
-
-static int
-GetSpecialKey(InputInfoPtr pInfo, int scanCode)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-  int specialkey = scanCode;
-
-#if defined (__sparc__)
-  if (pKbd->sunKbd) {
-      switch (scanCode) {
-          case 0x2b: specialkey = KEY_BackSpace; break;
-          case 0x47: specialkey = KEY_KP_Minus; break;
-          case 0x7d: specialkey = KEY_KP_Plus; break;
-          /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */
-          case 0x05: specialkey = KEY_F1; break;
-          case 0x06: specialkey = KEY_F2; break;
-          case 0x08: specialkey = KEY_F3; break;
-          case 0x0a: specialkey = KEY_F4; break;
-          case 0x0c: specialkey = KEY_F5; break;
-          case 0x0e: specialkey = KEY_F6; break;
-          case 0x10: specialkey = KEY_F7; break;
-          case 0x11: specialkey = KEY_F8; break;
-          case 0x12: specialkey = KEY_F9; break;
-          case 0x07: specialkey = KEY_F10; break;
-          case 0x09: specialkey = KEY_F11; break;
-          case 0x0b: specialkey = KEY_F12; break;
-          default: specialkey = 0; break;
-      }
-      return specialkey;
-  }
-#endif
-
-  if (pKbd->CustomKeycodes) {
-      specialkey = pKbd->specialMap->map[scanCode];
-  }
-  return specialkey;
-}
-
-#define ModifierSet(k) ((modifiers & (k)) == (k))
-
-static
-Bool SpecialKey(InputInfoPtr pInfo, int key, Bool down, int modifiers)
-{
-  KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-
-  if(!pKbd->vtSwitchSupported)
-      return FALSE;
-
-  if ((ModifierSet(ControlMask | AltMask)) ||
-      (ModifierSet(ControlMask | AltLangMask))) {
-      if (VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
-          switch (key) {
-             case KEY_F1:
-             case KEY_F2:
-             case KEY_F3:
-             case KEY_F4:
-             case KEY_F5:
-             case KEY_F6:
-             case KEY_F7:
-             case KEY_F8:
-             case KEY_F9:
-             case KEY_F10:
-                  if (down) {
-                    ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
-                    return TRUE;
-                  }
-             case KEY_F11:
-             case KEY_F12:
-                  if (down) {
-                    ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
-                    return TRUE;
-                  }
-         }
-      }
-  }
-#ifdef USE_VT_SYSREQ
-    if (VTSwitchEnabled && xf86Info.vtSysreq && !xf86Info.dontVTSwitch) {
-        switch (key) {
-            case KEY_F1:
-            case KEY_F2:
-            case KEY_F3:
-            case KEY_F4:
-            case KEY_F5:
-            case KEY_F6:
-            case KEY_F7:
-            case KEY_F8:
-            case KEY_F9:
-            case KEY_F10:
-                 if (VTSysreqToggle && down) {
-                     ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F1 + 1);
-                     VTSysreqToggle = FALSE;
-                     return TRUE;
-                 }
-                 break;
-            case KEY_F11:
-            case KEY_F12:
-                 if (VTSysreqToggle && down) {
-                     ioctl(xf86Info.consoleFd, VT_ACTIVATE, key - KEY_F11 + 11);
-                     VTSysreqToggle = FALSE;
-                     return TRUE;
-                 }
-                 break;
-            /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
-            case KEY_Alt:
-            case KEY_AltLang:
-                 break;
-            case KEY_SysReqest:
-                 if ((ModifierSet(AltMask) || ModifierSet(AltLangMask)) && down)
-                     VTSysreqToggle = TRUE;
-                 break;
-             default:
-                 /*
-                  * We only land here when Alt-SysReq is followed by a
-                  * non-switching key.
-                  */
-                 if (VTSysreqToggle)
-                     VTSysreqToggle = FALSE;
-        }
-    }
-#endif /* USE_VT_SYSREQ */
-    return FALSE;
-} 
-
-static void
-stdReadInput(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    unsigned char rBuf[64];
-    int nBytes, i;
-    if ((nBytes = read( pInfo->fd, (char *)rBuf, sizeof(rBuf))) > 0) {
-       for (i = 0; i < nBytes; i++)
-           pKbd->PostEvent(pInfo, rBuf[i] & 0x7f,
-                           rBuf[i] & 0x80 ? FALSE : TRUE);
-       }
-}
-
-static Bool
-OpenKeyboard(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
-    int i;
-    KbdProtocolId prot = PROT_UNKNOWN_KBD;
-    char *s;
-
-    s = xf86SetStrOption(pInfo->options, "Protocol", NULL);
-    for (i = 0; protocols[i].name; i++) {
-        if (xf86NameCmp(s, protocols[i].name) == 0) {
-           prot = protocols[i].id;
-           break;
-        }
-    }
-
-    switch (prot) {
-        case PROT_STD:
-           pInfo->read_input = stdReadInput;
-           break;
-        default:
-           xf86Msg(X_ERROR,"\"%s\" is not a valid keyboard protocol name\n", s);
-           xfree(s);
-           return FALSE;
-    }
-
-    xf86Msg(X_CONFIG, "%s: Protocol: %s\n", pInfo->name, s);
-    xfree(s);
-
-    s = xf86SetStrOption(pInfo->options, "Device", NULL);
-    if (s == NULL) {
-       pInfo->fd = xf86Info.consoleFd;
-       pKbd->isConsole = TRUE;
-    } else {
-       pInfo->fd = open(s, O_RDONLY | O_NONBLOCK | O_EXCL);
-       if (pInfo->fd == -1) {
-           xf86Msg(X_ERROR, "%s: cannot open \"%s\"\n", pInfo->name, s);
-           xfree(s);
-           return FALSE;
-       }
-       pKbd->isConsole = FALSE;
-       xfree(s);
-    }
-
-    if (pKbd->isConsole)
-         pKbd->vtSwitchSupported = TRUE;
-
-    return TRUE;
-}
-
-_X_EXPORT Bool
-xf86OSKbdPreInit(InputInfoPtr pInfo)
-{
-    KbdDevPtr pKbd = pInfo->private;
-
-    pKbd->KbdInit       = KbdInit;
-    pKbd->KbdOn         = KbdOn;
-    pKbd->KbdOff        = KbdOff;
-    pKbd->Bell          = SoundBell;
-    pKbd->SetLeds       = SetKbdLeds;
-    pKbd->GetLeds       = GetKbdLeds;
-    pKbd->SetKbdRepeat  = SetKbdRepeat;
-    pKbd->KbdGetMapping = KbdGetMapping;
-    pKbd->SpecialKey    = SpecialKey;
-
-    pKbd->RemapScanCode = NULL;
-    pKbd->GetSpecialKey = GetSpecialKey;
-
-    pKbd->OpenKeyboard = OpenKeyboard;
-    pKbd->vtSwitchSupported = FALSE;
-
-    pKbd->private = xcalloc(sizeof(LnxKbdPrivRec), 1);
-    if (pKbd->private == NULL) {
-       xf86Msg(X_ERROR,"can't allocate keyboard OS private data\n");
-       return FALSE;
-    }
-
-#if defined(__powerpc__)
-  {
-    FILE *f;
-    f = fopen("/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes","r");
-    if (f) {
-        if (fgetc(f) == '0')
-            pKbd->CustomKeycodes = TRUE;
-        fclose(f);
-    }
-  }
-#endif
-    return TRUE;
-}
diff --git a/hw/xfree86/parser/Keyboard.c b/hw/xfree86/parser/Keyboard.c
deleted file mode 100644
index 9749a1a..0000000
--- a/hw/xfree86/parser/Keyboard.c
+++ /dev/null
@@ -1,308 +0,0 @@
-/* 
- * 
- * Copyright (c) 1997  Metro Link Incorporated
- * 
- * 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 X CONSORTIUM 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 Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- * 
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-#include "ctype.h"
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec KeyboardTab[] =
-{
-	{ENDSECTION, "endsection"},
-	{KPROTOCOL, "protocol"},
-	{AUTOREPEAT, "autorepeat"},
-	{XLEDS, "xleds"},
-	{PANIX106, "panix106"},
-	{XKBKEYMAP, "xkbkeymap"},
-	{XKBCOMPAT, "xkbcompat"},
-	{XKBTYPES, "xkbtypes"},
-	{XKBKEYCODES, "xkbkeycodes"},
-	{XKBGEOMETRY, "xkbgeometry"},
-	{XKBSYMBOLS, "xkbsymbols"},
-	{XKBDISABLE, "xkbdisable"},
-	{XKBRULES, "xkbrules"},
-	{XKBMODEL, "xkbmodel"},
-	{XKBLAYOUT, "xkblayout"},
-	{XKBVARIANT, "xkbvariant"},
-	{XKBOPTIONS, "xkboptions"},
-	/* The next two have become ServerFlags options */
-	{VTINIT, "vtinit"},
-	{VTSYSREQ, "vtsysreq"},
-	/* Obsolete keywords */
-	{SERVERNUM, "servernumlock"},
-	{LEFTALT, "leftalt"},
-	{RIGHTALT, "rightalt"},
-	{RIGHTALT, "altgr"},
-	{SCROLLLOCK_TOK, "scrolllock"},
-	{RIGHTCTL, "rightctl"},
-	{-1, ""},
-};
-
-/* Obsolete */
-static xf86ConfigSymTabRec KeyMapTab[] =
-{
-	{CONF_KM_META, "meta"},
-	{CONF_KM_COMPOSE, "compose"},
-	{CONF_KM_MODESHIFT, "modeshift"},
-	{CONF_KM_MODELOCK, "modelock"},
-	{CONF_KM_SCROLLLOCK, "scrolllock"},
-	{CONF_KM_CONTROL, "control"},
-	{-1, ""},
-};
-
-#define CLEANUP xf86freeInputList
-
-XF86ConfInputPtr
-xf86parseKeyboardSection (void)
-{
-	char *s, *s1, *s2;
-	int l;
-	int token, ntoken;
-	parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
-
-	while ((token = xf86getToken (KeyboardTab)) != ENDSECTION)
-	{
-		switch (token)
-		{
-		case COMMENT:
-			ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
-			break;
-		case KPROTOCOL:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "Protocol");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-							       xf86configStrdup("Protocol"),
-							       val.str);
-			break;
-		case AUTOREPEAT:
-			if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER)
-				Error (AUTOREPEAT_MSG, NULL);
-			s1 = xf86uLongToString(val.num);
-			if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER) {
-				xf86conffree(s1);
-				Error (AUTOREPEAT_MSG, NULL);
-			}
-			s2 = xf86uLongToString(val.num);
-			l = strlen(s1) + 1 + strlen(s2) + 1;
-			s = xf86confmalloc(l);
-			sprintf(s, "%s %s", s1, s2);
-			xf86conffree(s1);
-			xf86conffree(s2);
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-							       xf86configStrdup("AutoRepeat"), s);
-			break;
-		case XLEDS:
-			if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER)
-				Error (XLEDS_MSG, NULL);
-			s = xf86uLongToString(val.num);
-			l = strlen(s) + 1;
-			while ((token = xf86getSubToken (&(ptr->inp_comment))) == NUMBER)
-			{
-				s1 = xf86uLongToString(val.num);
-				l += (1 + strlen(s1));
-				s = xf86confrealloc(s, l);
-				strcat(s, " ");
-				strcat(s, s1);
-				xf86conffree(s1);
-			}
-			xf86unGetToken (token);
-			xf86conffree(s);
-			break;
-		case SERVERNUM:
-			xf86parseWarning(OBSOLETE_MSG, xf86tokenString());
-			break;
-		case LEFTALT:
-		case RIGHTALT:
-		case SCROLLLOCK_TOK:
-		case RIGHTCTL:
-			xf86parseWarning(OBSOLETE_MSG, xf86tokenString());
-				break;
-			ntoken = xf86getToken (KeyMapTab);
-			switch (ntoken)
-			{
-			case EOF_TOKEN:
-				xf86parseError (UNEXPECTED_EOF_MSG);
-				CLEANUP (ptr);
-				return (NULL);
-				break;
-
-			default:
-				Error (INVALID_KEYWORD_MSG, xf86tokenString ());
-				break;
-			}
-			break;
-		case VTINIT:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "VTInit");
-			xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTInit");
-			break;
-		case VTSYSREQ:
-			xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTSysReq");
-			break;
-		case XKBDISABLE:
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbDisable"),
-												NULL);
-			break;
-		case XKBKEYMAP:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBKeymap");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbKeymap"),
-												val.str);
-			break;
-		case XKBCOMPAT:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBCompat");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbCompat"),
-												val.str);
-			break;
-		case XKBTYPES:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBTypes");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbTypes"),
-												val.str);
-			break;
-		case XKBKEYCODES:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBKeycodes");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbKeycodes"),
-												val.str);
-			break;
-		case XKBGEOMETRY:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBGeometry");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbGeometry"),
-												val.str);
-			break;
-		case XKBSYMBOLS:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBSymbols");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbSymbols"),
-												val.str);
-			break;
-		case XKBRULES:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBRules");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbRules"),
-												val.str);
-			break;
-		case XKBMODEL:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBModel");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbModel"),
-												val.str);
-			break;
-		case XKBLAYOUT:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBLayout");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbLayout"),
-												val.str);
-			break;
-		case XKBVARIANT:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBVariant");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbVariant"),
-												val.str);
-			break;
-		case XKBOPTIONS:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBOptions");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbOptions"),
-												val.str);
-			break;
-		case PANIX106:
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("Panix106"), NULL);
-			break;
-		case EOF_TOKEN:
-			Error (UNEXPECTED_EOF_MSG, NULL);
-			break;
-		default:
-			Error (INVALID_KEYWORD_MSG, xf86tokenString ());
-			break;
-		}
-	}
-
-	ptr->inp_identifier = xf86configStrdup(CONF_IMPLICIT_KEYBOARD);
-	ptr->inp_driver = xf86configStrdup("keyboard");
-	ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-										xf86configStrdup("CoreKeyboard"), NULL);
-
-#ifdef DEBUG
-	printf ("Keyboard section parsed\n");
-#endif
-
-	return ptr;
-}
-
diff-tree 7465010d59ec435bd00b738f0cef766b352dc7eb (from parents)
Merge: 1d31ed778284082e1060bff63317c94581d9eb9b 0aaac95b0d12089b256c97f6ff955c8c229ae095
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Jul 21 19:05:41 2006 -0400

    Merge branch 'master' of git+ssh://git.freedesktop.org/git/xorg/xserver into input-hotplug

diff-tree 1d31ed778284082e1060bff63317c94581d9eb9b (from 3eeb62e8f587732e6b433c2b9c6879eb26a3f1b4)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Jul 21 19:02:52 2006 -0400

    xephyr: load keysyms at init, not enable
    Load keysyms at init time, not enable, so we don't get the wrong map width.

diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 6a337bc..86a072d 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -907,9 +907,17 @@ EphyrKeyboardInit (KdKeyboardInfo *ki)
 {
   ki->driverPrivate = (EphyrKbdPrivate *)
                        xcalloc(sizeof(EphyrKbdPrivate), 1);
-  /* FIXME blah blah overrunning memory blah blah */
-  ki->minScanCode = ki->keySyms.minKeyCode = 0;
-  ki->maxScanCode = ki->keySyms.maxKeyCode = 255;
+  hostx_load_keymap();
+  if (!ephyrKeySyms.map) {
+      ErrorF("Couldn't load keymap from host\n");
+      return BadAlloc;
+  }
+  ki->keySyms.minKeyCode = ephyrKeySyms.minKeyCode;
+  ki->keySyms.maxKeyCode = ephyrKeySyms.maxKeyCode;
+  ki->minScanCode = ki->keySyms.minKeyCode;
+  ki->maxScanCode = ki->keySyms.maxKeyCode;
+  ki->keySyms.mapWidth = ephyrKeySyms.mapWidth;
+  ki->keySyms.map = ephyrKeySyms.map;
   ephyrKbd = ki;
   return Success;
 }
@@ -917,17 +925,6 @@ EphyrKeyboardInit (KdKeyboardInfo *ki)
 static Status
 EphyrKeyboardEnable (KdKeyboardInfo *ki)
 {
-    hostx_load_keymap();
-    if (!ephyrKeySyms.map) {
-        ErrorF("Couldn't load keymap from host\n");
-        return BadAlloc;
-    }
-    ki->keySyms.minKeyCode = ephyrKeySyms.minKeyCode;
-    ki->keySyms.maxKeyCode = ephyrKeySyms.maxKeyCode;
-    ki->minScanCode = ki->keySyms.minKeyCode;
-    ki->maxScanCode = ki->keySyms.maxKeyCode;
-    ki->keySyms.mapWidth = ephyrKeySyms.mapWidth;
-    ki->keySyms.map = ephyrKeySyms.map;
     ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = TRUE;
 
     return Success;
diff-tree 3eeb62e8f587732e6b433c2b9c6879eb26a3f1b4 (from 60ea7b51fe2b8a19a08b63db48504971a7a50ee6)
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Fri Jul 21 16:33:28 2006 -0400

    bug #890: completely remove deprecated keyboard driver
    Remove all remnants of the old built-in keyboard driver.

diff --git a/configure.ac b/configure.ac
index 815f1f4..456b8b5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1089,7 +1089,6 @@ dnl has it in libc), or if libdl is need
 		fi
 	  	XORG_OS="linux"
 		XORG_OS_SUBDIR="linux"
-		XORG_OS_KBD="Lnx"
 		xorg_bus_linuxpci="yes"
 		linux_acpi="no"
 		case $host_cpu in
@@ -1131,7 +1130,6 @@ int main () { 
 	  freebsd* | kfreebsd*-gnu)
 	  	XORG_OS="freebsd"
 		XORG_OS_SUBDIR="bsd"
-		XORG_OS_KBD="BSD"
 		case $host_cpu in
 		  i*86)
 			;;
@@ -1143,7 +1141,6 @@ int main () { 
 	  netbsd*)
 	  	XORG_OS="netbsd"
 		XORG_OS_SUBDIR="bsd"
-		XORG_OS_KBD="BSD"
 		case $host_cpu in
 		  i*86|amd64*|x86_64*|ia64*)
 			;;
@@ -1155,7 +1152,6 @@ int main () { 
 	  openbsd*)
 	  	XORG_OS="openbsd"
 		XORG_OS_SUBDIR="bsd"
-		XORG_OS_KBD="BSD"
 		case $host_cpu in
 		  i*86|amd64*|x86_64*|ia64*)
 			;;
@@ -1258,7 +1254,6 @@ int main () { 
 	AC_SUBST([XORG_INCS])
 	AC_SUBST([XORG_OS])
 	AC_SUBST([XORG_OS_SUBDIR])
-	AC_SUBST([XORG_OS_KBD])
 
 	dnl only used in hw/xfree86/scanpci, TTBOMK
 	AC_PATH_PROG(PERL, perl, no)
diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
index 84818ff..090112c 100644
--- a/hw/xfree86/common/Makefile.am
+++ b/hw/xfree86/common/Makefile.am
@@ -21,8 +21,6 @@ RANDRSOURCES = xf86RandR.c
 
 BUSSOURCES = xf86isaBus.c xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES)
 
-KBDSOURCES = xf86Kbd at XORG_OS_KBD@.c
-
 MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
 
 xf86DefModeSet.c: $(srcdir)/modeline2c.pl $(MODEDEFSOURCES)
@@ -34,14 +32,13 @@ AM_LDFLAGS = -r
 libcommon_la_SOURCES = xf86Configure.c xf86Bus.c xf86Config.c \
                       xf86Cursor.c xf86DGA.c xf86DPMS.c \
                       xf86DoProbe.c xf86DoScanPci.c xf86Events.c \
-                      xf86Globals.c xf86Io.c xf86AutoConfig.c \
+                      xf86Globals.c xf86AutoConfig.c \
                       xf86MiscExt.c xf86Option.c \
                       xf86VidMode.c xf86fbman.c xf86cmap.c \
                       xf86Helper.c xf86PM.c \
                       xf86Mode.c xf86Build.h xorgHelper.c xf86Versions.c \
                       $(XVSOURCES) $(BUSSOURCES) $(XKBSOURCES) \
-                      $(DEBUGSOURCES) $(XISOURCES) $(RANDRSOURCES) \
-                      $(KBDSOURCES)
+                      $(DEBUGSOURCES) $(XISOURCES) $(RANDRSOURCES)
 nodist_libcommon_la_SOURCES = xf86DefModeSet.c
 libinit_a_SOURCES = xf86Build.h xf86Init.c
 
@@ -59,11 +56,6 @@ sdk_HEADERS = compiler.h fourcc.h xf86.h
 DISTCLEANFILES = xf86Build.h
 CLEANFILES = $(BUILT_SOURCES)
 
-# this is a hack for now.  as above we don't have rules to build all of these
-# yet, but we want to make sure they all get into the distball.  this should
-# eventually go away.
-DISTKBDSOURCES = xf86Kbd.c xf86KbdBSD.c xf86KbdLnx.c xf86KbdMach.c
-
 EXTRA_DIST = \
 	atKeynames.h \
 	compiler.h \
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 16591be..16df621 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -385,18 +385,6 @@ xf86DriverlistFromConfig()
     return modulearray;
 }
 
-
-Bool
-xf86BuiltinInputDriver(const char *name)
-{
-#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
-    if (xf86NameCmp(name, "keyboard") == 0)
-	return TRUE;
-    else
-#endif
-	return FALSE;
-}
-
 char **
 xf86InputDriverlistFromConfig()
 {
@@ -421,8 +409,7 @@ xf86InputDriverlistFromConfig()
     if (xf86ConfigLayout.inputs) {
         idp = xf86ConfigLayout.inputs;
         while (idp->identifier) {
-	    if (!xf86BuiltinInputDriver(idp->driver))
-	        count++;
+	    count++;
 	    idp++;
         }
     }
@@ -437,10 +424,8 @@ xf86InputDriverlistFromConfig()
     count = 0;
     idp = xf86ConfigLayout.inputs;
     while (idp->identifier) {
-	if (!xf86BuiltinInputDriver(idp->driver)) {
-	    modulearray[count] = idp->driver;
-	    count++;
-	}
+        modulearray[count] = idp->driver;
+	count++;
 	idp++;
     }
     modulearray[count] = NULL;
@@ -1115,295 +1100,6 @@ configServerFlags(XF86ConfFlagsPtr flags
 }
 
 /*
- * XXX This function is temporary, and will be removed when the keyboard
- * driver is converted into a regular input driver.
- */
-static Bool
-configInputKbd(IDevPtr inputp)
-{
-  char *s;
-  MessageType from = X_DEFAULT;
-  Bool customKeycodesDefault = FALSE;
-  int verb = 0;
-#if defined(XQUEUE)
-  char *kbdproto = "Xqueue";
-#else
-  char *kbdproto = "standard";
-#endif
-
-  /* Initialize defaults */
-  xf86Info.xleds         = 0L;
-  xf86Info.kbdDelay      = 500;
-  xf86Info.kbdRate       = 30;
-  
-  xf86Info.vtinit        = NULL;
-  xf86Info.vtSysreq      = VT_SYSREQ_DEFAULT;
-#if defined(SVR4) && defined(i386)
-  xf86Info.panix106      = FALSE;
-#endif
-  xf86Info.kbdCustomKeycodes = FALSE;
-#ifdef WSCONS_SUPPORT
-  xf86Info.kbdFd 	   = -1;
-#endif
-#ifdef XKB
-  if (!xf86IsPc98()) {
-    xf86Info.xkbrules      = __XKBDEFRULES__;
-    xf86Info.xkbmodel      = "pc105";
-    xf86Info.xkblayout     = "us";
-    xf86Info.xkbvariant    = NULL;
-    xf86Info.xkboptions    = NULL;
-  } else {
-    xf86Info.xkbrules      = "xfree98";
-    xf86Info.xkbmodel      = "pc98";
-    xf86Info.xkblayout     = "nec/jp";
-    xf86Info.xkbvariant    = NULL;
-    xf86Info.xkboptions    = NULL;
-  }
-  xf86Info.xkbcomponents_specified = FALSE;
-  /* Should discourage the use of these. */
-  xf86Info.xkbkeymap     = NULL;
-  xf86Info.xkbtypes      = NULL;
-  xf86Info.xkbcompat     = NULL;
-  xf86Info.xkbkeycodes   = NULL;
-  xf86Info.xkbsymbols    = NULL;
-  xf86Info.xkbgeometry   = NULL;
-#endif
-
-  s = xf86SetStrOption(inputp->commonOptions, "Protocol", kbdproto);
-  if (xf86NameCmp(s, "standard") == 0) {
-     xfree(s);
-  } else if (xf86NameCmp(s, "xqueue") == 0) {
-#ifdef __UNIXWARE__
-    /*
-     * To retain compatibility with older config files, on UnixWare, we
-     * accept the xqueue protocol but use the normal keyboard procs.
-     */
-#else
-#ifdef XQUEUE
-    xf86Msg(X_CONFIG, "Xqueue selected for keyboard input\n");
-#endif
-#endif
-    xfree(s);
-#ifdef WSCONS_SUPPORT
-  } else if (xf86NameCmp(s, "wskbd") == 0) {
-     xfree(s);
-     s = xf86SetStrOption(inputp->commonOptions, "Device", NULL);
-     xf86Msg(X_CONFIG, "Keyboard: Protocol: wskbd\n");
-     if (s == NULL) {
-	 xf86ConfigError("A \"device\" option is required with"
-			 " the \"wskbd\" keyboard protocol");
-	 return FALSE;
-     }
-     xf86Info.kbdFd = open(s, O_RDWR | O_NONBLOCK | O_EXCL);
-     if (xf86Info.kbdFd == -1) {
-       xf86ConfigError("cannot open \"%s\"", s);
-       xfree(s);
-       return FALSE;
-     }
-     xfree(s);
-     /* Find out keyboard type */
-     if (ioctl(xf86Info.kbdFd, WSKBDIO_GTYPE, &xf86Info.wsKbdType) == -1) {
-	     xf86ConfigError("cannot get keyboard type");
-	     close(xf86Info.kbdFd);
-	     return FALSE;
-     }
-     switch (xf86Info.wsKbdType) {
-     case WSKBD_TYPE_PC_XT:
-	     xf86Msg(X_PROBED, "Keyboard type: XT\n");
-	     break;
-     case WSKBD_TYPE_PC_AT:
-	     xf86Msg(X_PROBED, "Keyboard type: AT\n");
-	     break;
-     case WSKBD_TYPE_USB:
-	     xf86Msg(X_PROBED, "Keyboard type: USB\n");
-	     break;
-#ifdef WSKBD_TYPE_ADB
-     case WSKBD_TYPE_ADB:
-	     xf86Msg(X_PROBED, "Keyboard type: ADB\n");
-	     break;
-#endif
-#ifdef WSKBD_TYPE_SUN
-     case WSKBD_TYPE_SUN:
-	     xf86Msg(X_PROBED, "Keyboard type: Sun\n");
-	     break;
-#endif
-#ifdef WSKBD_TYPE_SUN5
-     case WSKBD_TYPE_SUN5:
-	     xf86Msg(X_PROBED, "Keyboard type: Sun5\n");
-	     break;
-#endif
-     default:
-	     xf86ConfigError("Unsupported wskbd type \"%d\"", 
-			     xf86Info.wsKbdType);
-	     close(xf86Info.kbdFd);
-	     return FALSE;
-     }
-#endif
-  } else {
-    xf86ConfigError("\"%s\" is not a valid keyboard protocol name", s);
-    xfree(s);
-    return FALSE;
-  }
-
-  s = xf86SetStrOption(inputp->commonOptions, "AutoRepeat", NULL);
-  if (s) {
-    if (sscanf(s, "%d %d", &xf86Info.kbdDelay, &xf86Info.kbdRate) != 2) {
-      xf86ConfigError("\"%s\" is not a valid AutoRepeat value", s);
-      xfree(s);
-      return FALSE;
-    }
-  xfree(s);
-  }
-
-  s = xf86SetStrOption(inputp->commonOptions, "XLeds", NULL);
-  if (s) {
-    char *l, *end;
-    unsigned int i;
-    l = strtok(s, " \t\n");
-    while (l) {
-      i = strtoul(l, &end, 0);
-      if (*end == '\0')
-	xf86Info.xleds |= 1L << (i - 1);
-      else {
-	xf86ConfigError("\"%s\" is not a valid XLeds value", l);
-	xfree(s);
-	return FALSE;
-      }
-      l = strtok(NULL, " \t\n");
-    }
-    xfree(s);
-  }
-
-#ifdef XKB
-  from = X_DEFAULT;
-  if (noXkbExtension)
-    from = X_CMDLINE;
-  else if (xf86FindOption(inputp->commonOptions, "XkbDisable")) {
-    xf86Msg(X_WARNING, "KEYBOARD: XKB should be disabled in the "
-	    "ServerFlags section instead\n"
-	    "\tof in the \"keyboard\" InputDevice section.\n");
-    noXkbExtension =
-	xf86SetBoolOption(inputp->commonOptions, "XkbDisable", FALSE);
-    from = X_CONFIG;
-  }
-  if (noXkbExtension)
-    xf86Msg(from, "XKB: disabled\n");
-
-#define NULL_IF_EMPTY(s) (s[0] ? s : (xfree(s), (char *)NULL))
-
-  if (!noXkbExtension) {
-    if ((s = xf86SetStrOption(inputp->commonOptions, "XkbKeymap", NULL))) {
-      xf86Info.xkbkeymap = NULL_IF_EMPTY(s);
-      xf86Msg(X_CONFIG, "XKB: keymap: \"%s\" "
-		"(overrides other XKB settings)\n", xf86Info.xkbkeymap);
-    } else {
-      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbCompat", NULL))) {
-	xf86Info.xkbcompat = NULL_IF_EMPTY(s);
-	xf86Info.xkbcomponents_specified = TRUE;
-	xf86Msg(X_CONFIG, "XKB: compat: \"%s\"\n", s);
-      }
-
-      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbTypes", NULL))) {
-	xf86Info.xkbtypes = NULL_IF_EMPTY(s);
-	xf86Info.xkbcomponents_specified = TRUE;
-	xf86Msg(X_CONFIG, "XKB: types: \"%s\"\n", s);
-      }
-
-      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbKeycodes", NULL))) {
-	xf86Info.xkbkeycodes = NULL_IF_EMPTY(s);
-	xf86Info.xkbcomponents_specified = TRUE;
-	xf86Msg(X_CONFIG, "XKB: keycodes: \"%s\"\n", s);
-      }
-
-      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbGeometry", NULL))) {
-	xf86Info.xkbgeometry = NULL_IF_EMPTY(s);
-	xf86Info.xkbcomponents_specified = TRUE;
-	xf86Msg(X_CONFIG, "XKB: geometry: \"%s\"\n", s);
-      }
-
-      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbSymbols", NULL))) {
-	xf86Info.xkbsymbols = NULL_IF_EMPTY(s);
-	xf86Info.xkbcomponents_specified = TRUE;
-	xf86Msg(X_CONFIG, "XKB: symbols: \"%s\"\n", s);
-      }
-
-      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbRules", NULL))) {
-	xf86Info.xkbrules = NULL_IF_EMPTY(s);
-	xf86Info.xkbcomponents_specified = TRUE;
-	xf86Msg(X_CONFIG, "XKB: rules: \"%s\"\n", s);
-      }
-
-      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbModel", NULL))) {
-	xf86Info.xkbmodel = NULL_IF_EMPTY(s);
-	xf86Info.xkbcomponents_specified = TRUE;
-	xf86Msg(X_CONFIG, "XKB: model: \"%s\"\n", s);
-      }
-
-      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbLayout", NULL))) {
-	xf86Info.xkblayout = NULL_IF_EMPTY(s);
-	xf86Info.xkbcomponents_specified = TRUE;
-	xf86Msg(X_CONFIG, "XKB: layout: \"%s\"\n", s);
-      }
-
-      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbVariant", NULL))) {
-	xf86Info.xkbvariant = NULL_IF_EMPTY(s);
-	xf86Info.xkbcomponents_specified = TRUE;
-	xf86Msg(X_CONFIG, "XKB: variant: \"%s\"\n", s);
-      }
-
-      if ((s = xf86SetStrOption(inputp->commonOptions, "XkbOptions", NULL))) {
-	xf86Info.xkboptions = NULL_IF_EMPTY(s);
-	xf86Info.xkbcomponents_specified = TRUE;
-	xf86Msg(X_CONFIG, "XKB: options: \"%s\"\n", s);
-      }
-    }
-  }
-#undef NULL_IF_EMPTY
-#endif
-#if defined(SVR4) && defined(i386)
-  if ((xf86Info.panix106 =
-	xf86SetBoolOption(inputp->commonOptions, "Panix106", FALSE))) {
-    xf86Msg(X_CONFIG, "PANIX106: enabled\n");
-  }
-#endif
-
-  /*
-   * This was once a compile time option (ASSUME_CUSTOM_KEYCODES)
-   * defaulting to 1 on Linux/PPC. It is no longer necessary, but for
-   * backwards compatibility we provide 'Option "CustomKeycodes"'
-   * and try to autoprobe on Linux/PPC.
-   */
-  from = X_DEFAULT;
-  verb = 2;
-#if defined(__linux__) && defined(__powerpc__)
-  {
-    FILE *f;
-
-    f = fopen("/proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes","r");
-    if (f) {
-      if (fgetc(f) == '0') {
-	customKeycodesDefault = TRUE;
-	from = X_PROBED;
-	verb = 1;
-      }
-      fclose(f);
-    }
-  }
-#endif
-  if (xf86FindOption(inputp->commonOptions, "CustomKeycodes")) {
-    from = X_CONFIG;
-    verb = 1;
-  }
-  xf86Info.kbdCustomKeycodes =
-	xf86SetBoolOption(inputp->commonOptions, "CustomKeycodes",
-			  customKeycodesDefault);
-  xf86MsgVerb(from, verb, "Keyboard: CustomKeycode %s\n",
-		xf86Info.kbdCustomKeycodes ? "enabled" : "disabled");
-
-  return TRUE;
-}
-
-/*
  * Locate the core input devices.  These can be specified/located in
  * the following ways, in order of priority:
  *
@@ -1639,10 +1335,6 @@ checkCoreInputDevices(serverLayoutPtr se
 	    confInput = xf86findInputByDriver("kbd",
 					      xf86configptr->conf_input_lst);
 	}
-	if (!confInput) {
-	    confInput = xf86findInputByDriver("keyboard",
-					      xf86configptr->conf_input_lst);
-	}
 	if (confInput) {
 	    foundKeyboard = TRUE;
 	    from = X_DEFAULT;
@@ -2549,10 +2241,6 @@ configInput(IDevPtr inputp, XF86ConfInpu
     inputp->commonOptions = conf_input->inp_option_lst;
     inputp->extraOptions = NULL;
 
-    /* XXX This is required until the keyboard driver is converted */
-    if (!xf86NameCmp(inputp->driver, "keyboard"))
-	return configInputKbd(inputp);
-
     return TRUE;
 }
 
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index a0d622a..d6efb9a 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -263,11 +263,7 @@ configureInputSection (void)
     parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
 
     ptr->inp_identifier = "Keyboard0";
-#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
-    ptr->inp_driver = "keyboard";
-#else
     ptr->inp_driver = "kbd";
-#endif
     ptr->list.next = NULL;
 
     /* Crude mechanism to auto-detect mouse (os dependent) */
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index cc2ce9b..21389f2 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -166,6 +166,12 @@ typedef struct x_IHRec {
 static IHPtr InputHandlers = NULL;
 
 
+Bool
+LegalModifier(unsigned int key, DevicePtr pDev)
+{
+    return TRUE;
+}
+
 /*
  * TimeSinceLastInputEvent --
  *      Function used for screensaver purposes by the os module. Returns the
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index ab73c6c..aad479d 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -95,32 +95,10 @@ InputInfoPtr xf86InputDevs = NULL;
 
 xf86InfoRec xf86Info = {
 	-1,		/* consoleFd */
-	-1,		/* kbdFd */
 	-1,		/* vtno */
-	-1,		/* kbdType */
-	-1,		/* kbdRate */
-	-1, 		/* kbdDelay */
-	-1,		/* bell_pitch */
-	-1,		/* bell_duration */
-	TRUE,		/* autoRepeat */
-	0,		/* leds */
-	0,		/* xleds */
 	NULL,		/* vtinit */
-	0,		/* scanPrefix */
-	FALSE,		/* capsLock */
-	FALSE,		/* numLock */
-	FALSE,		/* scrollLock */
-	FALSE,		/* modeSwitchLock */
-	FALSE,		/* composeLock */
 	FALSE,		/* vtSysreq */
 	SKWhenNeeded,	/* ddxSpecialKeys */
-	FALSE,		/* ActionKeyBindingsSet */
-#if defined(SVR4) && defined(i386)
-	FALSE,		/* panix106 */
-#endif
-#if defined(__OpenBSD__) || defined(__NetBSD__)
-	0,		/* wskbdType */
-#endif
 	NULL,		/* pMouse */
 #ifdef XINPUT
 	NULL,		/* mouseLocal */
@@ -139,20 +117,6 @@ xf86InfoRec xf86Info = {
 	-1,		/* screenFd */
 	-1,		/* consType */
 #endif
-#ifdef XKB
-	NULL,		/* xkbkeymap */
-	NULL,		/* xkbkeycodes */
-	NULL,		/* xkbtypes */
-	NULL,		/* xkbcompat */
-	NULL,		/* xkbsymbols */
-	NULL,		/* xkbgeometry */
-	FALSE,		/* xkbcomponents_specified */
-	NULL,		/* xkbrules */
-	NULL,		/* xkbmodel */
-	NULL,		/* xkblayout */
-	NULL,		/* xkbvariant */
-	NULL,		/* xkboptions */
-#endif
 	FALSE,		/* allowMouseOpenFail */
 	TRUE,		/* vidModeEnabled */
 	FALSE,		/* vidModeAllowNonLocal */
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index e2622e3..a975e37 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -137,16 +137,6 @@ static int numFormats = 6;
 #endif
 static Bool formatsDone = FALSE;
 
-InputDriverRec XF86KEYBOARD = {
-	1,
-	"keyboard",
-	NULL,
-	NULL,
-	NULL,
-	NULL,
-	0
-};
-
 static Bool
 xf86CreateRootWindow(WindowPtr pWin)
 {
@@ -405,10 +395,6 @@ InitOutput(ScreenInfo *pScreenInfo, int 
       xfree(modulelist);
     }
 
-#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
-    /* Setup the builtin input drivers */
-    xf86AddInputDriver(&XF86KEYBOARD, NULL, 0);
-#endif
     /* Load all input driver modules specified in the config file. */
     if ((modulelist = xf86InputDriverlistFromConfig())) {
       xf86LoadModules(modulelist, NULL);
diff --git a/hw/xfree86/common/xf86Io.c b/hw/xfree86/common/xf86Io.c
deleted file mode 100644
index d10ad43..0000000
--- a/hw/xfree86/common/xf86Io.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.56 2003/11/03 05:11:02 tsi Exp $ */
-/*
- * 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.
- *
- */
-/*
- * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/* $XConsortium: xf86Io.c /main/27 1996/10/19 17:58:55 kaleb $ */
-/* $XdotOrg: xserver/xorg/hw/xfree86/common/xf86Io.c,v 1.6 2006/03/25 19:52:03 ajax Exp $ */
-
-#define NEED_EVENTS
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "inputstr.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#define XF86_OS_PRIVS
-#include "xf86_OSlib.h"
-#include "mipointer.h"
-
-#ifdef XINPUT
-#include "xf86Xinput.h"
-#include <X11/extensions/XIproto.h>
-#include "exevents.h"
-#endif
-
-#ifdef XKB
-#include <X11/extensions/XKB.h>
-#include <X11/extensions/XKBstr.h>
-#include <X11/extensions/XKBsrv.h>
-#endif
-
-unsigned int xf86InitialCaps = 0;
-unsigned int xf86InitialNum = 0;
-unsigned int xf86InitialScroll = 0;
-
-#include "atKeynames.h"
-
-/*
- * xf86KbdBell --
- *	Ring the terminal/keyboard bell for an amount of time proportional to
- *      "loudness".
- */
-
-void
-xf86KbdBell(percent, pKeyboard, ctrl, unused)
-     int           percent;          /* Percentage of full volume */
-     DeviceIntPtr  pKeyboard;        /* Keyboard to ring */
-     pointer	   ctrl;	
-     int	   unused;	
-{
-  xf86SoundKbdBell(percent, xf86Info.bell_pitch, xf86Info.bell_duration);
-}
-
-void
-xf86UpdateKbdLeds()
-{
-  int leds = 0;
-  if (xf86Info.capsLock) leds |= XLED1;
-  if (xf86Info.numLock)  leds |= XLED2;
-  if (xf86Info.scrollLock || xf86Info.modeSwitchLock) leds |= XLED3;
-  if (xf86Info.composeLock) leds |= XLED4;
-  xf86Info.leds = (xf86Info.leds & xf86Info.xleds) | (leds & ~xf86Info.xleds);
-  xf86KbdLeds();
-}
-
-void
-xf86KbdLeds ()
-{
-  int leds, real_leds = 0;
-
-#if defined (__sparc__) && defined(__linux__)
-  static int kbdSun = -1;
-  if (kbdSun == -1) {
-  if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun")) ||
-      (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun")))
-      kbdSun = 1;
-  else
-      kbdSun = 0;
-  }
-  if (kbdSun) {
-     if (xf86Info.leds & 0x08) real_leds |= XLED1;
-     if (xf86Info.leds & 0x04) real_leds |= XLED3;
-     if (xf86Info.leds & 0x02) real_leds |= XLED4;
-     if (xf86Info.leds & 0x01) real_leds |= XLED2;
-     leds = real_leds;
-     real_leds = 0;
-  } else {
-     leds = xf86Info.leds;
-  }
-#else
-  leds = xf86Info.leds;
-#endif /* defined (__sparc__) */
-
-#ifdef LED_CAP
-  if (leds & XLED1)  real_leds |= LED_CAP;
-  if (leds & XLED2)  real_leds |= LED_NUM;
-  if (leds & XLED3)  real_leds |= LED_SCR;
-#ifdef LED_COMP
-  if (leds & XLED4)  real_leds |= LED_COMP;
-#else
-  if (leds & XLED4)  real_leds |= LED_SCR;
-#endif
-#endif
-#ifdef sun
-  /* Pass through any additional LEDs, such as Kana LED on Sun Japanese kbd */
-  real_leds |= (leds & 0xFFFFFFF0);
-#endif
-  xf86SetKbdLeds(real_leds);
-  (void)leds;
-}
diff --git a/hw/xfree86/common/xf86Kbd.c b/hw/xfree86/common/xf86Kbd.c
deleted file mode 100644
index 85f9e34..0000000
--- a/hw/xfree86/common/xf86Kbd.c
+++ /dev/null
@@ -1,395 +0,0 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Kbd.c,v 3.26 2003/08/24 17:36:53 dawes Exp $ */
-/*
- * 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.
- *
- */
-/*
- * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/* $XConsortium: xf86Kbd.c /main/10 1996/02/21 17:38:32 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#ifdef __UNIXOS2__
-#define I_NEED_OS2_H
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "atKeynames.h"
-#include "xf86Config.h"
-
-#include "xf86Keymap.h"
-
-#if defined(KDGKBTYPE) && \
-	!defined(Lynx) && \
-	!defined(__UNIXOS2__) && !defined(__mips__) && \
-	!defined(__arm32__) && !defined(__GNU__) && !defined(__QNX__)
-#define HAS_GETKBTYPE
-#endif
-#if defined(GIO_KEYMAP) && \
-	!defined(Lynx) && \
-	!defined(__UNIXOS2__) && !defined(__mips__) && \
-	!defined(__arm32__) && !defined(__GNU__) && !defined(DGUX) && \
-	!defined(__QNX__)
-#define HAS_GETKEYMAP
-
-#define KD_GET_ENTRY(i,n) \
-  eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
-
-/*
- * NOTE: Not all possible remappable symbols are remapped. There are two main
- *       reasons:
- *                 a) The mapping between scancode and SYSV/386 - symboltable
- *                    is inconsistent between different versions and has some
- *                    BIG mistakes.
- *                 b) In X-Windows there is a difference between numpad-keys
- *                    and normal keys. SYSV/386 uses for both kinds of keys
- *                    the same symbol.
- *
- *       Thus only the alpha keypad and the function keys are translated.
- *       Also CapsLock, NumLock, ScrollLock, Shift, Control & Alt.
- */
-
-static unsigned char remap[128] = {
-     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
-  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
-  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
-  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
-  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
-  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
-  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
-  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
-  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
-     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
-  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
-     0,    0, 0x69, 0x65,    0,    0,    0,    0,   /* 0x70 - 0x77 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
-};
-
-static KeySym eascii_to_x[512] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	XK_Ccedilla,	XK_udiaeresis,	XK_eacute,	XK_acircumflex,
-	XK_adiaeresis,	XK_agrave,	XK_aring,	XK_ccedilla,
-	XK_ecircumflex,	XK_ediaeresis,	XK_egrave,	XK_idiaeresis,
-	XK_icircumflex,	XK_igrave,	XK_Adiaeresis,	XK_Aring,
-	XK_Eacute,	XK_ae,		XK_AE,		XK_ocircumflex,
-	XK_odiaeresis,	XK_ograve,	XK_ucircumflex,	XK_ugrave,
-	XK_ydiaeresis,	XK_Odiaeresis,	XK_Udiaeresis,	XK_cent,
-	XK_sterling,	XK_yen,		XK_paragraph,	XK_section,
-	XK_aacute,	XK_iacute,	XK_oacute,	XK_uacute,
-	XK_ntilde,	XK_Ntilde,	XK_ordfeminine,	XK_masculine,
-	XK_questiondown,XK_hyphen,	XK_notsign,	XK_onehalf,
-	XK_onequarter,	XK_exclamdown,	XK_guillemotleft,XK_guillemotright,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Greek_alpha,	XK_ssharp,	XK_Greek_GAMMA,	XK_Greek_pi,
-	XK_Greek_SIGMA,	XK_Greek_sigma,	XK_mu,	        XK_Greek_tau,
-	XK_Greek_PHI,	XK_Greek_THETA,	XK_Greek_OMEGA,	XK_Greek_delta,
-	XK_infinity,	XK_Ooblique,	XK_Greek_epsilon, XK_intersection,
-	XK_identical,	XK_plusminus,	XK_greaterthanequal, XK_lessthanequal,
-	XK_topintegral,	XK_botintegral,	XK_division,	XK_similarequal,
-	XK_degree,	NoSymbol,	NoSymbol,	XK_radical,
-	XK_Greek_eta,	XK_twosuperior,	XK_periodcentered, NoSymbol,
-
-	/* 
-	 * special marked entries (256 + x)
-	 */
-
-	NoSymbol,	NoSymbol,	XK_Shift_L,	XK_Shift_R,
-	XK_Caps_Lock,	XK_Num_Lock,	XK_Scroll_Lock,	XK_Alt_L,
-	NoSymbol,	XK_Control_L,	XK_Alt_L,	XK_Alt_R,
-	XK_Control_L,	XK_Control_R,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_F1,
-	XK_F2,		XK_F3,		XK_F4,		XK_F5,
-	XK_F6,		XK_F7,		XK_F8,		XK_F9,
-	XK_F10,		XK_F11,		XK_F12,		NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-      };
-
-#endif /* HAS_GETKEYMAP */
-
-/*
- * LegalModifier --
- *      determine whether a key is a legal modifier key, i.e send a
- *      press/release sequence.
- */
-
-/*ARGSUSED*/
-Bool
-LegalModifier(key, pDev)
-     unsigned int  key;
-     DevicePtr	pDev;
-{
-  return (TRUE);
-}
-
-
-      
-/*
- * xf86KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-void
-xf86KbdGetMapping (pKeySyms, pModMap)
-     KeySymsPtr pKeySyms;
-     CARD8      *pModMap;
-{
-  KeySym        *k;
-#ifdef HAS_GETKEYMAP
-  keymap_t      keymap;
-#endif
-  int           i;
-  KeySym        *pMap;
-
-#ifdef HAS_GETKBTYPE
-  char          type;
-  
-  xf86Info.kbdType =
-    ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101;
-  if (xf86Info.kbdType == KB_84)
-    pMap = map84;
-  else
-    pMap = map;
-#else
-/* OS/2 sets the keyboard type during xf86OpenKbd */
-#ifndef __UNIXOS2__
-  xf86Info.kbdType = 0;
-#endif
-  pMap = map;
-#endif
-
-#ifdef HAS_GETKEYMAP
-  /*
-   * use the keymap, which can be gotten from our oringinal vt??.
-   * ( ttymap(1) !!!! )
-   */
-  if (ioctl(xf86Info.consoleFd, GIO_KEYMAP, &keymap) != -1) {
-    for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++)
-      
-      if (remap[i]) {
-	
-	k = pMap + (remap[i] << 2);
-	
-	k[0] = KD_GET_ENTRY(i,0);             /* non-shifed */
-	k[1] = KD_GET_ENTRY(i,1);	      /* shifted */
-	k[2] = KD_GET_ENTRY(i,4);	      /* alt */
-	k[3] = KD_GET_ENTRY(i,5);	      /* alt - shifted */
-
-	if (k[3] == k[2]) k[3] = NoSymbol;
-	if (k[2] == k[1]) k[2] = NoSymbol;
-	if (k[1] == k[0]) k[1] = NoSymbol;
-	if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
-      }
-  }
-#endif
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = pMap, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4)
-    
-    switch(*k) {
-      
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-
-    }
-  
-  pKeySyms->map        = pMap;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  pKeySyms->maxKeyCode = MAX_KEYCODE;
-}
diff --git a/hw/xfree86/common/xf86KbdBSD.c b/hw/xfree86/common/xf86KbdBSD.c
deleted file mode 100644
index c1f6156..0000000
--- a/hw/xfree86/common/xf86KbdBSD.c
+++ /dev/null
@@ -1,1266 +0,0 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c,v 3.22 2003/10/07 22:00:52 herrb Exp $ */
-/*
- * Derived from xf86Kbd.c by S_ren Schmidt (sos at login.dkuug.dk)
- * which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- * and from xf86KbdCODrv.c by Holger Veit
- *
- * 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.
- */
-/*
- * Copyright (c) 1994-2002 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/* $XConsortium: xf86KbdBSD.c /main/6 1996/10/23 13:12:27 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "atKeynames.h"
-#include "xf86Keymap.h"
-
-#if (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)) && defined(GIO_KEYMAP)
-#define KD_GET_ENTRY(i,n) \
-  eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
-
-static unsigned char remap[NUM_KEYCODES] = {
-     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
-  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
-  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
-  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
-  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
-  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
-  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
-  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
-  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
-     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
-  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
-     0,    0, 0x69, 0x65,    0,    0,    0,    0,   /* 0x70 - 0x77 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
-};
-
-/* This table assumes the ibm code page 437 coding for characters 
- * > 0x80. They are returned in this form by PCVT */
-static KeySym eascii_to_x[512] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	XK_Ccedilla,	XK_udiaeresis,	XK_eacute,	XK_acircumflex,
-	XK_adiaeresis,	XK_agrave,	XK_aring,	XK_ccedilla,
-	XK_ecircumflex,	XK_ediaeresis,	XK_egrave,	XK_idiaeresis,
-	XK_icircumflex,	XK_igrave,	XK_Adiaeresis,	XK_Aring,
-	XK_Eacute,	XK_ae,		XK_AE,		XK_ocircumflex,
-	XK_odiaeresis,	XK_ograve,	XK_ucircumflex,	XK_ugrave,
-	XK_ydiaeresis,	XK_Odiaeresis,	XK_Udiaeresis,	XK_cent,
-	XK_sterling,	XK_yen,		XK_paragraph,	XK_section,
-	XK_aacute,	XK_iacute,	XK_oacute,	XK_uacute,
-	XK_ntilde,	XK_Ntilde,	XK_ordfeminine,	XK_masculine,
-	XK_questiondown,XK_hyphen,	XK_notsign,	XK_onehalf,
-	XK_onequarter,	XK_exclamdown,	XK_guillemotleft,XK_guillemotright,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Greek_alpha,	XK_ssharp,	XK_Greek_GAMMA,	XK_Greek_pi,
-	XK_Greek_SIGMA,	XK_Greek_sigma,	XK_mu,	        XK_Greek_tau,
-	XK_Greek_PHI,	XK_Greek_THETA,	XK_Greek_OMEGA,	XK_Greek_delta,
-	XK_infinity,	XK_Ooblique,	XK_Greek_epsilon, XK_intersection,
-	XK_identical,	XK_plusminus,	XK_greaterthanequal, XK_lessthanequal,
-	XK_topintegral,	XK_botintegral,	XK_division,	XK_similarequal,
-	XK_degree,	NoSymbol,	NoSymbol,	XK_radical,
-	XK_Greek_eta,	XK_twosuperior,	XK_periodcentered, NoSymbol,
-
-	/* 
-	 * special marked entries (256 + x)
-	 */
-
-#if 1
-	/* This has been checked against what syscons actually does */
-	NoSymbol,	NoSymbol,	XK_Shift_L,	XK_Shift_R,
-	XK_Caps_Lock,	XK_Num_Lock,	XK_Scroll_Lock,	XK_Alt_L,
-	XK_ISO_Left_Tab,XK_Control_L,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_F1,
-	XK_F2,		XK_F3,		XK_F4,		XK_F5,
-	XK_F6,		XK_F7,		XK_F8,		XK_F9,
-	XK_F10,		XK_F11,		XK_F12,		NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Control_R,	XK_Alt_R,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol
-#else
-	/* The old table, supposedly for pcvt. */
-	NoSymbol,	NoSymbol,	XK_Shift_L,	XK_Shift_R,
-	XK_Caps_Lock,	XK_Num_Lock,	XK_Scroll_Lock,	XK_Alt_L,
-	NoSymbol,	XK_Control_L,	XK_Alt_L,	XK_Alt_R,
-	XK_Control_L,	XK_Control_R,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_F1,
-	XK_F2,		XK_F3,		XK_F4,		XK_F5,
-	XK_F6,		XK_F7,		XK_F8,		XK_F9,
-	XK_F10,		XK_F11,		XK_F12,		NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol
-#endif
-      };
-
-#ifdef __OpenBSD__
-/* don't mark AltR and  CtrlR for remapping, since they 
- * cannot be remapped by pccons */
-static unsigned char pccons_remap[128] = {
-     0, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,   /* 0x00 - 0x07 */
-  0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,   /* 0x08 - 0x0f */
-  0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,   /* 0x10 - 0x17 */
-  0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,   /* 0x18 - 0x1f */
-  0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,   /* 0x20 - 0x27 */
-  0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,   /* 0x28 - 0x2f */
-  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,    0,   /* 0x30 - 0x37 */
-  0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,   /* 0x38 - 0x3f */
-  0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,    0,   /* 0x40 - 0x47 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x48 - 0x4f */
-     0,    0,    0,    0,    0,    0, 0x56, 0x57,   /* 0x50 - 0x57 */
-  0x58,    0,    0,    0,    0,    0,    0,    0,   /* 0x58 - 0x5f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x60 - 0x67 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x68 - 0x6f */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x70 - 0x77 */
-     0,    0,    0,    0,    0,    0,    0,    0,   /* 0x78 - 0x7f */
-};
-
-/* This table assumes an iso8859_1 encoding for the characters 
- * > 80, as returned by pccons */
-static KeySym latin1_to_x[256] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_nobreakspace,XK_exclamdown,	XK_cent,	XK_sterling,
-	XK_currency,	XK_yen,		XK_brokenbar,	XK_section,
-	XK_diaeresis,	XK_copyright,	XK_ordfeminine,	XK_guillemotleft,
-	XK_notsign,	XK_hyphen,	XK_registered,	XK_macron,
-	XK_degree,	XK_plusminus,	XK_twosuperior,	XK_threesuperior,
-	XK_acute,	XK_mu,		XK_paragraph,	XK_periodcentered,
-	XK_cedilla,	XK_onesuperior,	XK_masculine,	XK_guillemotright,
-	XK_onequarter,	XK_onehalf,	XK_threequarters,XK_questiondown,
-	XK_Agrave,	XK_Aacute,	XK_Acircumflex,	XK_Atilde,
-	XK_Adiaeresis,	XK_Aring,	XK_AE,		XK_Ccedilla,
-	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
-	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
-	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
-	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_multiply,
-	XK_Ooblique,	XK_Ugrave,	XK_Uacute,	XK_Ucircumflex,
-	XK_Udiaeresis,	XK_Yacute,	XK_THORN,	XK_ssharp,
-	XK_agrave,	XK_aacute,	XK_acircumflex,	XK_atilde,
-	XK_adiaeresis,	XK_aring,	XK_ae,	        XK_ccedilla,
-	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
-	XK_igrave,	XK_iacute,	XK_icircumflex, XK_idiaeresis,
-	XK_eth,		XK_ntilde,	XK_ograve, 	XK_oacute,
-	XK_ocircumflex,	XK_otilde,	XK_odiaeresis,	XK_division,
-	XK_oslash,	XK_ugrave,	XK_uacute,	XK_ucircumflex,
-	XK_udiaeresis,	XK_yacute,	XK_thorn, 	XK_ydiaeresis
-      };
-#endif
-#endif /* SYSCONS_SUPPORT || PCVT_SUPPORT */
-/*
- * LegalModifier --
- *      determine whether a key is a legal modifier key, i.e send a
- *      press/release sequence.
- */
-
-/*ARGSUSED*/
-Bool
-LegalModifier(key, pDev)
-     unsigned int  key;
-     DevicePtr pDev;
-{
-  return (TRUE);
-}
-
-/*
- * xf86KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-void
-xf86KbdGetMapping (pKeySyms, pModMap)
-     KeySymsPtr pKeySyms;
-     CARD8      *pModMap;
-{
-  KeySym        *k;
-  int           i;
-
-#ifndef __bsdi__
-  switch (xf86Info.consType) {
-
-#ifdef PCCONS_SUPPORT
-  case PCCONS:
-#if defined(__OpenBSD__)
-    /*
-     * on OpenBSD, the pccons keymap is programmable, too
-     */
-    {
-      pccons_keymap_t keymap[KB_NUM_KEYS];
-      if (ioctl(xf86Info.consoleFd, CONSOLE_GET_KEYMAP, &keymap) != -1) {
-	for (i = 0; i < KB_NUM_KEYS; i++) 
-	  if (pccons_remap[i]) {
-	    k = map + (pccons_remap[i] << 2);
-	    switch (keymap[i].type) {
-	    case KB_ASCII:
-	      /* For ASCII keys, there is only one char in the keymap */
-	      k[0] = latin1_to_x[(unsigned char)keymap[i].unshift[0]];
-	      k[1] = latin1_to_x[(unsigned char)keymap[i].shift[0]];
-	      k[2] = latin1_to_x[(unsigned char)keymap[i].altgr[0]];
-	      k[3] = latin1_to_x[(unsigned char)keymap[i].shift_altgr[0]];
-	      break;
-	    case KB_SCROLL:
-	      k[0] = XK_Scroll_Lock;
-	      goto special;
-	    case KB_NUM:
-	      k[0] = XK_Num_Lock;
-	      goto special;
-	    case KB_CAPS:
-	      k[0] = XK_Caps_Lock;
-	      goto special;
-	    case KB_SHIFT:
-	      switch (keymap[i].unshift[0]) {
-	      case 1:
-		/* left shift */
-		k[0] = XK_Shift_L;
-		break;
-	      case 2:
-		/* right shift */
-		k[0] = XK_Shift_R;
-		break;
-	      default:
-		k[0] = NoSymbol;
-	      }
-	      goto special;
-	    case KB_CTL:
-	      k[0] = XK_Control_L;
-	      goto special;
-	    case KB_ALT:
-	      k[0] = XK_Alt_L;
-	      goto special;
-	    case KB_FUNC:
-	      switch (keymap[i].unshift[2]) {
-	      case 'M':
-		k[0] = XK_F1;
-		break;
-	      case 'N':
-		k[0] = XK_F2;
-		break;
-	      case 'O':
-		k[0] = XK_F3;
-		break;
-	      case 'P':
-		k[0] = XK_F4;
-		break;
-	      case 'Q':
-		k[0] = XK_F5;
-		break;
-	      case 'R':
-		k[0] = XK_F6;
-		break;
-	      case 'S':
-		k[0] = XK_F7;
-		break;
-	      case 'T':
-		k[0] = XK_F8;
-		break;
-	      case 'U':
-		k[0] = XK_F9;
-		break;
-	      case 'V':
-		k[0] = XK_F10;
-		break;
-	      case 'W':
-		k[0] = XK_F11;
-		break;
-	      case 'X':
-		k[0] = XK_F12;
-		break;
-	      default:
-		k[0] = NoSymbol;
-		break;
-	      }
-	      goto special;
-	    default:
-	      k[0] = NoSymbol;
-	    special:
-	      k[1] = k[2] = k[3] = NoSymbol;
-	    }
-	  }
-      } else {
-	ErrorF("Can't read pccons keymap\n");
-      }
-    }
-#endif /* __OpenBSD__ */
-  break;
-#endif
-
-/*
- * XXX wscons has no GIO_KEYMAP
- */
-#if (defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)) && defined(GIO_KEYMAP)
-  case SYSCONS:
-  case PCVT:
-    {
-      keymap_t keymap;
-    
-      if (ioctl(xf86Info.consoleFd, GIO_KEYMAP, &keymap) != -1) {
-	for (i = 0; i < keymap.n_keys && i < NUM_KEYCODES; i++)
-	  if (remap[i]) {
-	    k = map + (remap[i] << 2);
-	    k[0] = KD_GET_ENTRY(i,0);           /* non-shifed */
-	    k[1] = KD_GET_ENTRY(i,1);	      /* shifted */
-	    k[2] = KD_GET_ENTRY(i,4);	      /* alt */
-	    k[3] = KD_GET_ENTRY(i,5);	      /* alt - shifted */
-	    if (k[3] == k[2]) k[3] = NoSymbol;
-	    if (k[2] == k[1]) k[2] = NoSymbol;
-	    if (k[1] == k[0]) k[1] = NoSymbol;
-	    if (k[0] == k[2] && k[1] == k[3])
-	      k[2] = k[3] = NoSymbol;
-	  }
-      }
-    }
-    break;
-#endif /* SYSCONS || PCVT */
-    
-  } 
-#endif /* !bsdi */
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = map, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4)
-    
-    switch(*k) {
-      
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-
-    }
-  
-  xf86Info.kbdType = 0;
-
-  pKeySyms->map        = map;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  pKeySyms->maxKeyCode = MAX_KEYCODE; 
-
-}
-
-#ifdef WSCONS_SUPPORT
-#include "atKeynames.h"
-
-static CARD8 wsUsbMap[] = {
-	/* 0 */ KEY_NOTUSED,
-	/* 1 */ KEY_NOTUSED,
-	/* 2 */ KEY_NOTUSED,
-	/* 3 */ KEY_NOTUSED,
-	/* 4 */ KEY_A,		
-	/* 5 */ KEY_B,
-	/* 6 */ KEY_C,
-	/* 7 */ KEY_D,
-	/* 8 */ KEY_E,
-	/* 9 */ KEY_F,
-	/* 10 */ KEY_G,
-	/* 11 */ KEY_H,
-	/* 12 */ KEY_I,
-	/* 13 */ KEY_J,
-	/* 14 */ KEY_K,
-	/* 15 */ KEY_L,
-	/* 16 */ KEY_M,
-	/* 17 */ KEY_N,
-	/* 18 */ KEY_O,
-	/* 19 */ KEY_P,
-	/* 20 */ KEY_Q,
-	/* 21 */ KEY_R,
-	/* 22 */ KEY_S,
-	/* 23 */ KEY_T,
-	/* 24 */ KEY_U,
-	/* 25 */ KEY_V,
-	/* 26 */ KEY_W,
-	/* 27 */ KEY_X,
-	/* 28 */ KEY_Y,
-	/* 29 */ KEY_Z,
-	/* 30 */ KEY_1,		/* 1 !*/
-	/* 31 */ KEY_2,		/* 2 @ */
-	/* 32 */ KEY_3,		/* 3 # */
-	/* 33 */ KEY_4,		/* 4 $ */
-	/* 34 */ KEY_5,		/* 5 % */
-	/* 35 */ KEY_6,		/* 6 ^ */
-	/* 36 */ KEY_7,		/* 7 & */
-	/* 37 */ KEY_8,		/* 8 * */
-	/* 38 */ KEY_9,		/* 9 ( */
-	/* 39 */ KEY_0,		/* 0 ) */
-	/* 40 */ KEY_Enter,	/* Return  */
-	/* 41 */ KEY_Escape,	/* Escape */
-	/* 42 */ KEY_BackSpace,	/* Backspace Delete */
-	/* 43 */ KEY_Tab,	/* Tab */
-	/* 44 */ KEY_Space,	/* Space */
-	/* 45 */ KEY_Minus,	/* - _ */
-	/* 46 */ KEY_Equal,	/* = + */
-	/* 47 */ KEY_LBrace,	/* [ { */
-	/* 48 */ KEY_RBrace,	/* ] } */
-	/* 49 */ KEY_BSlash,	/* \ | */
-	/* 50 */ KEY_BSlash2,	/* \ _ # ~ on some keyboards */
-	/* 51 */ KEY_SemiColon,	/* ; : */
-	/* 52 */ KEY_Quote,	/* ' " */
-	/* 53 */ KEY_Tilde,	/* ` ~ */
-	/* 54 */ KEY_Comma,	/* , <  */
-	/* 55 */ KEY_Period,	/* . > */
-	/* 56 */ KEY_Slash,	/* / ? */
-	/* 57 */ KEY_CapsLock,	/* Caps Lock */
-	/* 58 */ KEY_F1,		/* F1 */
-	/* 59 */ KEY_F2,		/* F2 */
-	/* 60 */ KEY_F3,		/* F3 */
-	/* 61 */ KEY_F4,		/* F4 */
-	/* 62 */ KEY_F5,		/* F5 */
-	/* 63 */ KEY_F6,		/* F6 */
-	/* 64 */ KEY_F7,		/* F7 */
-	/* 65 */ KEY_F8,		/* F8 */
-	/* 66 */ KEY_F9,		/* F9 */
-	/* 67 */ KEY_F10,	/* F10 */
-	/* 68 */ KEY_F11,	/* F11 */
-	/* 69 */ KEY_F12,	/* F12 */
-	/* 70 */ KEY_Print,	/* PrintScrn SysReq */
-	/* 71 */ KEY_ScrollLock,	/* Scroll Lock */
-	/* 72 */ KEY_Pause,	/* Pause Break */
-	/* 73 */ KEY_Insert,	/* Insert XXX  Help on some Mac Keyboards */
-	/* 74 */ KEY_Home,	/* Home */
-	/* 75 */ KEY_PgUp,	/* Page Up */
-	/* 76 */ KEY_Delete,	/* Delete */
-	/* 77 */ KEY_End,	/* End */
-	/* 78 */ KEY_PgDown,	/* Page Down */
-	/* 79 */ KEY_Right,	/* Right Arrow */
-	/* 80 */ KEY_Left,	/* Left Arrow */
-	/* 81 */ KEY_Down,	/* Down Arrow */
-	/* 82 */ KEY_Up,		/* Up Arrow */
-	/* 83 */ KEY_NumLock,	/* Num Lock */
-	/* 84 */ KEY_KP_Divide,	/* Keypad / */
-	/* 85 */ KEY_KP_Multiply, /* Keypad * */
-	/* 86 */ KEY_KP_Minus,	/* Keypad - */
-	/* 87 */ KEY_KP_Plus,	/* Keypad + */
-	/* 88 */ KEY_KP_Enter,	/* Keypad Enter */
-	/* 89 */ KEY_KP_1,	/* Keypad 1 End */
-	/* 90 */ KEY_KP_2,	/* Keypad 2 Down */
-	/* 91 */ KEY_KP_3,	/* Keypad 3 Pg Down */
-	/* 92 */ KEY_KP_4,	/* Keypad 4 Left  */
-	/* 93 */ KEY_KP_5,	/* Keypad 5 */
-	/* 94 */ KEY_KP_6,	/* Keypad 6 */
-	/* 95 */ KEY_KP_7,	/* Keypad 7 Home */
-	/* 96 */ KEY_KP_8,	/* Keypad 8 Up */
-	/* 97 */ KEY_KP_9,	/* KEypad 9 Pg Up */
-	/* 98 */ KEY_KP_0,	/* Keypad 0 Ins */
-	/* 99 */ KEY_KP_Decimal,	/* Keypad . Del */
-	/* 100 */ KEY_Less,	/* < > on some keyboards */
-	/* 101 */ KEY_Menu,	/* Menu */
-	/* 102 */ KEY_NOTUSED,
-	/* 103 */ KEY_KP_Equal, /* Keypad = on Mac keyboards */
-	/* 104 */ KEY_NOTUSED,
-	/* 105 */ KEY_NOTUSED,
-	/* 106 */ KEY_NOTUSED,
-	/* 107 */ KEY_NOTUSED,
-	/* 108 */ KEY_NOTUSED,
-	/* 109 */ KEY_NOTUSED,
-	/* 110 */ KEY_NOTUSED,
-	/* 111 */ KEY_NOTUSED,
-	/* 112 */ KEY_NOTUSED,
-	/* 113 */ KEY_NOTUSED,
-	/* 114 */ KEY_NOTUSED,
-	/* 115 */ KEY_NOTUSED,
-	/* 116 */ KEY_NOTUSED,
-	/* 117 */ KEY_NOTUSED,
-	/* 118 */ KEY_NOTUSED,
-	/* 119 */ KEY_NOTUSED,
-	/* 120 */ KEY_NOTUSED,
-	/* 121 */ KEY_NOTUSED,
-	/* 122 */ KEY_NOTUSED,
-	/* 123 */ KEY_NOTUSED,
-	/* 124 */ KEY_NOTUSED,
-	/* 125 */ KEY_NOTUSED,
-	/* 126 */ KEY_NOTUSED,
-	/* 127 */ KEY_NOTUSED,
-	/* 128 */ KEY_NOTUSED,
-	/* 129 */ KEY_NOTUSED,
-	/* 130 */ KEY_NOTUSED,
-	/* 131 */ KEY_NOTUSED,
-	/* 132 */ KEY_NOTUSED,
-	/* 133 */ KEY_NOTUSED,
-	/* 134 */ KEY_NOTUSED,
-	/* 135 */ KEY_NOTUSED,
-	/* 136 */ KEY_NOTUSED,
-	/* 137 */ KEY_NOTUSED,
-	/* 138 */ KEY_NOTUSED,
-	/* 139 */ KEY_NOTUSED,
-	/* 140 */ KEY_NOTUSED,
-	/* 141 */ KEY_NOTUSED,
-	/* 142 */ KEY_NOTUSED,
-	/* 143 */ KEY_NOTUSED,
-	/* 144 */ KEY_NOTUSED,
-	/* 145 */ KEY_NOTUSED,
-	/* 146 */ KEY_NOTUSED,
-	/* 147 */ KEY_NOTUSED,
-	/* 148 */ KEY_NOTUSED,
-	/* 149 */ KEY_NOTUSED,
-	/* 150 */ KEY_NOTUSED,
-	/* 151 */ KEY_NOTUSED,
-	/* 152 */ KEY_NOTUSED,
-	/* 153 */ KEY_NOTUSED,
-	/* 154 */ KEY_NOTUSED,
-	/* 155 */ KEY_NOTUSED,
-	/* 156 */ KEY_NOTUSED,
-	/* 157 */ KEY_NOTUSED,
-	/* 158 */ KEY_NOTUSED,
-	/* 159 */ KEY_NOTUSED,
-	/* 160 */ KEY_NOTUSED,
-	/* 161 */ KEY_NOTUSED,
-	/* 162 */ KEY_NOTUSED,
-	/* 163 */ KEY_NOTUSED,
-	/* 164 */ KEY_NOTUSED,
-	/* 165 */ KEY_NOTUSED,
-	/* 166 */ KEY_NOTUSED,
-	/* 167 */ KEY_NOTUSED,
-	/* 168 */ KEY_NOTUSED,
-	/* 169 */ KEY_NOTUSED,
-	/* 170 */ KEY_NOTUSED,
-	/* 171 */ KEY_NOTUSED,
-	/* 172 */ KEY_NOTUSED,
-	/* 173 */ KEY_NOTUSED,
-	/* 174 */ KEY_NOTUSED,
-	/* 175 */ KEY_NOTUSED,
-	/* 176 */ KEY_NOTUSED,
-	/* 177 */ KEY_NOTUSED,
-	/* 178 */ KEY_NOTUSED,
-	/* 179 */ KEY_NOTUSED,
-	/* 180 */ KEY_NOTUSED,
-	/* 181 */ KEY_NOTUSED,
-	/* 182 */ KEY_NOTUSED,
-	/* 183 */ KEY_NOTUSED,
-	/* 184 */ KEY_NOTUSED,
-	/* 185 */ KEY_NOTUSED,
-	/* 186 */ KEY_NOTUSED,
-	/* 187 */ KEY_NOTUSED,
-	/* 188 */ KEY_NOTUSED,
-	/* 189 */ KEY_NOTUSED,
-	/* 190 */ KEY_NOTUSED,
-	/* 191 */ KEY_NOTUSED,
-	/* 192 */ KEY_NOTUSED,
-	/* 193 */ KEY_NOTUSED,
-	/* 194 */ KEY_NOTUSED,
-	/* 195 */ KEY_NOTUSED,
-	/* 196 */ KEY_NOTUSED,
-	/* 197 */ KEY_NOTUSED,
-	/* 198 */ KEY_NOTUSED,
-	/* 199 */ KEY_NOTUSED,
-	/* 200 */ KEY_NOTUSED,
-	/* 201 */ KEY_NOTUSED,
-	/* 202 */ KEY_NOTUSED,
-	/* 203 */ KEY_NOTUSED,
-	/* 204 */ KEY_NOTUSED,
-	/* 205 */ KEY_NOTUSED,
-	/* 206 */ KEY_NOTUSED,
-	/* 207 */ KEY_NOTUSED,
-	/* 208 */ KEY_NOTUSED,
-	/* 209 */ KEY_NOTUSED,
-	/* 210 */ KEY_NOTUSED,
-	/* 211 */ KEY_NOTUSED,
-	/* 212 */ KEY_NOTUSED,
-	/* 213 */ KEY_NOTUSED,
-	/* 214 */ KEY_NOTUSED,
-	/* 215 */ KEY_NOTUSED,
-	/* 216 */ KEY_NOTUSED,
-	/* 217 */ KEY_NOTUSED,
-	/* 218 */ KEY_NOTUSED,
-	/* 219 */ KEY_NOTUSED,
-	/* 220 */ KEY_NOTUSED,
-	/* 221 */ KEY_NOTUSED,
-	/* 222 */ KEY_NOTUSED,
-	/* 223 */ KEY_NOTUSED,
-	/* 224 */ KEY_LCtrl,	/* Left Control */
-	/* 225 */ KEY_ShiftL,	/* Left Shift */
-	/* 226 */ KEY_Alt,	/* Left Alt */
-	/* 227 */ KEY_LMeta,	/* Left Meta */
-	/* 228 */ KEY_RCtrl,	/* Right Control */
-	/* 229 */ KEY_ShiftR,	/* Right Shift */
-	/* 230 */ KEY_AltLang,	/* Right Alt, AKA AltGr */
-	/* 231 */ KEY_LMeta,	/* Right Meta XXX */
-};
-
-#define WS_USB_MAP_SIZE (sizeof(wsUsbMap)/sizeof(unsigned char))
-
-/* Map for adb keyboards  */
-static CARD8 wsAdbMap[] = {
-	/* 0 */ KEY_A,
-	/* 1 */ KEY_S,
-	/* 2 */ KEY_D,
-	/* 3 */ KEY_F,
-	/* 4 */ KEY_H,
-	/* 5 */ KEY_G,
-	/* 6 */ KEY_Z,
-	/* 7 */ KEY_X,
-	/* 8 */ KEY_C,
-	/* 9 */ KEY_V,
-	/* 10 */ KEY_UNKNOWN,	/* @ # on french keyboards */
-	/* 11 */ KEY_B,
-	/* 12 */ KEY_Q,
-	/* 13 */ KEY_W,
-	/* 14 */ KEY_E,
-	/* 15 */ KEY_R,
-	/* 16 */ KEY_Y,
-	/* 17 */ KEY_T,
-	/* 18 */ KEY_1,
-	/* 19 */ KEY_2,
-	/* 20 */ KEY_3,
-	/* 21 */ KEY_4,
-	/* 22 */ KEY_6,
-	/* 23 */ KEY_5,
-	/* 24 */ KEY_Equal,
-	/* 25 */ KEY_9,
-	/* 26 */ KEY_7,
-	/* 27 */ KEY_Minus,
-	/* 28 */ KEY_8,
-	/* 29 */ KEY_0,
-	/* 30 */ KEY_RBrace,
-	/* 31 */ KEY_O,
-	/* 32 */ KEY_U,
-	/* 33 */ KEY_LBrace,
-	/* 34 */ KEY_I,
-	/* 35 */ KEY_P,
-	/* 36 */ KEY_Enter,
-	/* 37 */ KEY_L,
-	/* 38 */ KEY_J,
-	/* 39 */ KEY_Quote,
-	/* 40 */ KEY_K,
-	/* 41 */ KEY_SemiColon,
-	/* 42 */ KEY_BSlash,
-	/* 43 */ KEY_Comma,
-	/* 44 */ KEY_Slash,
-	/* 45 */ KEY_N,
-	/* 46 */ KEY_M,
-	/* 47 */ KEY_Period,
-	/* 48 */ KEY_Tab,
-	/* 49 */ KEY_Space,
-	/* 50 */ KEY_Tilde,
-	/* 51 */ KEY_Delete,
-	/* 52 */ KEY_AltLang,
-	/* 53 */ KEY_Escape,
-	/* 54 */ KEY_LCtrl,
-	/* 55 */ KEY_Alt,
-	/* 56 */ KEY_ShiftL,
-	/* 57 */ KEY_CapsLock,
-	/* 58 */ KEY_LMeta,
-	/* 59 */ KEY_Left,
-	/* 60 */ KEY_Right,
-	/* 61 */ KEY_Down,
-	/* 62 */ KEY_Up,
-	/* 63 */ KEY_UNKNOWN,	/* Fn */
-	/* 64 */ KEY_NOTUSED,
-	/* 65 */ KEY_KP_Decimal,
-	/* 66 */ KEY_NOTUSED,
-	/* 67 */ KEY_KP_Multiply,
-	/* 68 */ KEY_NOTUSED,
-	/* 69 */ KEY_KP_Plus,
-	/* 70 */ KEY_NOTUSED,
-	/* 71 */ KEY_UNKNOWN,	/* Clear */
-	/* 72 */ KEY_NOTUSED, 
-	/* 73 */ KEY_NOTUSED,
-	/* 74 */ KEY_NOTUSED,
-	/* 75 */ KEY_KP_Divide,
-	/* 76 */ KEY_KP_Enter,
-	/* 77 */ KEY_NOTUSED,
-	/* 78 */ KEY_KP_Minus,
-	/* 79 */ KEY_NOTUSED,
-	/* 80 */ KEY_NOTUSED,
-	/* 81 */ KEY_KP_Equal,	/* Keypad = */
-	/* 82 */ KEY_KP_0,
-	/* 83 */ KEY_KP_1,
-	/* 84 */ KEY_KP_2,
-	/* 85 */ KEY_KP_3,
-	/* 86 */ KEY_KP_4,
-	/* 87 */ KEY_KP_5,
-	/* 88 */ KEY_KP_6,
-	/* 89 */ KEY_KP_7,
-	/* 90 */ KEY_NOTUSED,
-	/* 91 */ KEY_KP_8,
-	/* 92 */ KEY_KP_9,
-	/* 93 */ KEY_NOTUSED,
-	/* 94 */ KEY_NOTUSED,
-	/* 95 */ KEY_UNKNOWN,	/* Keypad ,  */
-	/* 96 */ KEY_F5,
-	/* 97 */ KEY_F6,
-	/* 98 */ KEY_F7,
-	/* 99 */ KEY_F3,
-	/* 100 */ KEY_F8,
-	/* 101 */ KEY_F9,
-	/* 102 */ KEY_NOTUSED,
-	/* 103 */ KEY_F11,
-	/* 104 */ KEY_NOTUSED,
-	/* 105 */ KEY_NOTUSED,
-	/* 106 */ KEY_KP_Enter,
-	/* 107 */ KEY_NOTUSED,
-	/* 108 */ KEY_NOTUSED,
-	/* 109 */ KEY_F10,
-	/* 110 */ KEY_NOTUSED,
-	/* 111 */ KEY_F12,
-	/* 112 */ KEY_NOTUSED,
-	/* 113 */ KEY_NOTUSED,
-	/* 114 */ KEY_NOTUSED,
-	/* 115 */ KEY_Home,
-	/* 116 */ KEY_PgUp,
-	/* 117 */ KEY_NOTUSED,
-	/* 118 */ KEY_F4,
-	/* 119 */ KEY_End,
-	/* 120 */ KEY_F2,
-	/* 121 */ KEY_PgDown,
-	/* 122 */ KEY_F1,
-	/* 123 */ KEY_NOTUSED,
-	/* 124 */ KEY_NOTUSED,
-	/* 125 */ KEY_NOTUSED,
-	/* 126 */ KEY_NOTUSED,
-	/* 127 */ KEY_NOTUSED,
-	/* 128 */ KEY_NOTUSED,
-	/* 129 */ KEY_NOTUSED,
-	/* 130 */ KEY_NOTUSED,
-	/* 131 */ KEY_NOTUSED,
-	/* 132 */ KEY_NOTUSED,
-	/* 133 */ KEY_NOTUSED,
-	/* 134 */ KEY_NOTUSED,
-	/* 135 */ KEY_NOTUSED,
-	/* 136 */ KEY_NOTUSED,
-	/* 137 */ KEY_NOTUSED,
-	/* 138 */ KEY_NOTUSED,
-	/* 139 */ KEY_NOTUSED,
-	/* 140 */ KEY_NOTUSED,
-	/* 141 */ KEY_NOTUSED,
-	/* 142 */ KEY_NOTUSED,
-	/* 143 */ KEY_NOTUSED,
-	/* 144 */ KEY_NOTUSED,
-	/* 145 */ KEY_NOTUSED,
-	/* 146 */ KEY_NOTUSED,
-	/* 147 */ KEY_NOTUSED,
-	/* 148 */ KEY_NOTUSED,
-	/* 149 */ KEY_NOTUSED,
-	/* 150 */ KEY_NOTUSED,
-	/* 151 */ KEY_NOTUSED,
-	/* 152 */ KEY_NOTUSED,
-	/* 153 */ KEY_NOTUSED,
-	/* 154 */ KEY_NOTUSED,
-	/* 155 */ KEY_NOTUSED,
-	/* 156 */ KEY_NOTUSED,
-	/* 157 */ KEY_NOTUSED,
-	/* 158 */ KEY_NOTUSED,
-	/* 159 */ KEY_NOTUSED,
-	/* 160 */ KEY_NOTUSED,
-	/* 161 */ KEY_NOTUSED,
-	/* 162 */ KEY_NOTUSED,
-	/* 163 */ KEY_NOTUSED,
-	/* 164 */ KEY_NOTUSED,
-	/* 165 */ KEY_NOTUSED,
-	/* 166 */ KEY_NOTUSED,
-	/* 167 */ KEY_NOTUSED,
-	/* 168 */ KEY_NOTUSED,
-	/* 169 */ KEY_NOTUSED,
-	/* 170 */ KEY_NOTUSED,
-	/* 171 */ KEY_NOTUSED,
-	/* 172 */ KEY_NOTUSED,
-	/* 173 */ KEY_NOTUSED,
-	/* 174 */ KEY_NOTUSED,
-	/* 175 */ KEY_NOTUSED,
-	/* 176 */ KEY_NOTUSED,
-	/* 177 */ KEY_NOTUSED,
-	/* 178 */ KEY_NOTUSED,
-	/* 179 */ KEY_NOTUSED,
-	/* 180 */ KEY_NOTUSED,
-	/* 181 */ KEY_NOTUSED,
-	/* 182 */ KEY_NOTUSED,
-	/* 183 */ KEY_NOTUSED,
-	/* 184 */ KEY_NOTUSED,
-	/* 185 */ KEY_NOTUSED,
-	/* 186 */ KEY_NOTUSED,
-	/* 187 */ KEY_NOTUSED,
-	/* 188 */ KEY_NOTUSED,
-	/* 189 */ KEY_NOTUSED,
-	/* 190 */ KEY_NOTUSED,
-	/* 191 */ KEY_NOTUSED,
-	/* 192 */ KEY_NOTUSED,
-	/* 193 */ KEY_NOTUSED,
-	/* 194 */ KEY_NOTUSED,
-	/* 195 */ KEY_NOTUSED,
-	/* 196 */ KEY_NOTUSED,
-	/* 197 */ KEY_NOTUSED,
-	/* 198 */ KEY_NOTUSED,
-	/* 199 */ KEY_NOTUSED,
-	/* 200 */ KEY_NOTUSED,
-	/* 201 */ KEY_NOTUSED,
-	/* 202 */ KEY_NOTUSED,
-	/* 203 */ KEY_NOTUSED,
-	/* 204 */ KEY_NOTUSED,
-	/* 205 */ KEY_NOTUSED,
-	/* 206 */ KEY_NOTUSED,
-	/* 207 */ KEY_NOTUSED,
-	/* 208 */ KEY_NOTUSED,
-	/* 209 */ KEY_NOTUSED,
-	/* 210 */ KEY_NOTUSED,
-	/* 211 */ KEY_NOTUSED,
-	/* 212 */ KEY_NOTUSED,
-	/* 213 */ KEY_NOTUSED,
-	/* 214 */ KEY_NOTUSED,
-	/* 215 */ KEY_NOTUSED,
-	/* 216 */ KEY_NOTUSED,
-	/* 217 */ KEY_NOTUSED,
-	/* 218 */ KEY_NOTUSED,
-	/* 219 */ KEY_NOTUSED,
-	/* 220 */ KEY_NOTUSED,
-	/* 221 */ KEY_NOTUSED,
-	/* 222 */ KEY_NOTUSED,
-	/* 223 */ KEY_NOTUSED,
-};
-
-#define WS_ADB_MAP_SIZE (sizeof(wsAdbMap)/sizeof(unsigned char))
-
-static CARD8 wsSunMap[] = {
-	/* 0x00 */ KEY_NOTUSED,
-	/* 0x01 */ KEY_NOTUSED,		/* stop */
-	/* 0x02 */ KEY_NOTUSED,		/* BrightnessDown / S-VolumeDown */
-	/* 0x03 */ KEY_NOTUSED,		/* again */
-	/* 0x04 */ KEY_NOTUSED,		/* BridgtnessUp / S-VolumeUp */
-	/* 0x05 */ KEY_F1,
-	/* 0x06 */ KEY_F2,
-	/* 0x07 */ KEY_F10,
-	/* 0x08 */ KEY_F3,
-	/* 0x09 */ KEY_F11,
-	/* 0x0a */ KEY_F4,
-	/* 0x0b */ KEY_F12,
-	/* 0x0c */ KEY_F5,
-	/* 0x0d */ KEY_AltLang,
-	/* 0x0e */ KEY_F6,
-	/* 0x0f */ KEY_NOTUSED,
-	/* 0x10 */ KEY_F7,
-	/* 0x11 */ KEY_F8,
-	/* 0x12 */ KEY_F9,
-	/* 0x13 */ KEY_Alt,
-	/* 0x14 */ KEY_Up,
-	/* 0x15 */ KEY_Pause,
-	/* 0x16 */ KEY_Print,
-	/* 0x17 */ KEY_NOTUSED,		/* props */
-	/* 0x18 */ KEY_Left,
-	/* 0x19 */ KEY_ScrollLock,
-	/* 0x1a */ KEY_NOTUSED,		/* undo */
-	/* 0x1b */ KEY_Down,
-	/* 0x1c */ KEY_Right,
-	/* 0x1d */ KEY_Escape,
-	/* 0x1e */ KEY_1,
-	/* 0x1f */ KEY_2,
-	/* 0x20 */ KEY_3,
-	/* 0x21 */ KEY_4,
-	/* 0x22 */ KEY_5,
-	/* 0x23 */ KEY_6,
-	/* 0x24 */ KEY_7,
-	/* 0x25 */ KEY_8,
-	/* 0x26 */ KEY_9,
-	/* 0x27 */ KEY_0,
-	/* 0x28 */ KEY_Minus,
-	/* 0x29 */ KEY_Equal,
-	/* 0x2a */ KEY_Tilde,
-	/* 0x2b */ KEY_BackSpace,
-	/* 0x2c */ KEY_Insert,
-	/* 0x2d */ KEY_KP_Equal,
-	/* 0x2e */ KEY_KP_Divide,
-	/* 0x2f */ KEY_KP_Multiply,
-	/* 0x30 */ KEY_NOTUSED,
-	/* 0x31 */ KEY_NOTUSED,		/* front */
-	/* 0x32 */ KEY_KP_Decimal,
-	/* 0x33 */ KEY_NOTUSED,		/* copy */
-	/* 0x34 */ KEY_Home,
-	/* 0x35 */ KEY_Tab,
-	/* 0x36 */ KEY_Q,
-	/* 0x37 */ KEY_W,
-	/* 0x38 */ KEY_E,
-	/* 0x39 */ KEY_R,
-	/* 0x3a */ KEY_T,
-	/* 0x3b */ KEY_Y,
-	/* 0x3c */ KEY_U,
-	/* 0x3d */ KEY_I,
-	/* 0x3e */ KEY_O,
-	/* 0x3f */ KEY_P,
-	/* 0x40 */ KEY_LBrace,
-	/* 0x41 */ KEY_RBrace,
-	/* 0x42 */ KEY_Delete,
-	/* 0x43 */ KEY_NOTUSED,		/* compose */
-	/* 0x44 */ KEY_KP_7,
-	/* 0x45 */ KEY_KP_8,
-	/* 0x46 */ KEY_KP_9,
-	/* 0x47 */ KEY_KP_Minus,
-	/* 0x48 */ KEY_NOTUSED,		/* open */
-	/* 0x49 */ KEY_NOTUSED,		/* paste */
-	/* 0x4a */ KEY_End,
-	/* 0x4b */ KEY_NOTUSED,
-	/* 0x4c */ KEY_LCtrl,
-	/* 0x4d */ KEY_A,
-	/* 0x4e */ KEY_S,
-	/* 0x4f */ KEY_D,
-	/* 0x50 */ KEY_F,
-	/* 0x51 */ KEY_G,
-	/* 0x52 */ KEY_H,
-	/* 0x53 */ KEY_J,
-	/* 0x54 */ KEY_K,
-	/* 0x55 */ KEY_L,
-	/* 0x56 */ KEY_SemiColon,
-	/* 0x57 */ KEY_Quote,
-	/* 0x58 */ KEY_BSlash,
-	/* 0x59 */ KEY_Enter,
-	/* 0x5a */ KEY_KP_Enter,
-	/* 0x5b */ KEY_KP_4,
-	/* 0x5c */ KEY_KP_5,
-	/* 0x5d */ KEY_KP_6,
-	/* 0x5e */ KEY_KP_0,
-	/* 0x5f */ KEY_NOTUSED,		/* find */
-	/* 0x60 */ KEY_PgUp,
-	/* 0x61 */ KEY_NOTUSED,		/* cut */
-	/* 0x62 */ KEY_NumLock,
-	/* 0x63 */ KEY_ShiftL,
-	/* 0x64 */ KEY_Z,
-	/* 0x65 */ KEY_X,
-	/* 0x66 */ KEY_C,
-	/* 0x67 */ KEY_V,
-	/* 0x68 */ KEY_B,
-	/* 0x69 */ KEY_N,
-	/* 0x6a */ KEY_M,
-	/* 0x6b */ KEY_Comma,
-	/* 0x6c */ KEY_Period,
-	/* 0x6d */ KEY_Slash,
-	/* 0x6e */ KEY_ShiftR,
-	/* 0x6f */ KEY_NOTUSED,		/* linefeed */
-	/* 0x70 */ KEY_KP_1,
-	/* 0x71 */ KEY_KP_2,
-	/* 0x72 */ KEY_KP_3,
-	/* 0x73 */ KEY_NOTUSED,
-	/* 0x74 */ KEY_NOTUSED,
-	/* 0x75 */ KEY_NOTUSED,
-	/* 0x76 */ KEY_NOTUSED,		/* help */
-	/* 0x77 */ KEY_CapsLock,
-	/* 0x78 */ KEY_LMeta,
-	/* 0x79 */ KEY_Space,
-	/* 0x7a */ KEY_RMeta,
-	/* 0x7b */ KEY_PgDown,
-	/* 0x7c */ KEY_NOTUSED,
-	/* 0x7d */ KEY_KP_Plus,
-	/* 0x7e */ KEY_NOTUSED,
-	/* 0x7f */ KEY_NOTUSED
-};
-
-#define WS_SUN_MAP_SIZE (sizeof(wsSunMap)/sizeof(unsigned char))
-
-/*
- * Translate raw wskbd keyboard event values to XFree86 standard keycodes
- * (based on the AT keyboard scan codes using the tables above
- */
-int 
-WSKbdToKeycode(int keycode)
-{
-	switch (xf86Info.wsKbdType) {
-	case WSKBD_TYPE_PC_XT:
-	case WSKBD_TYPE_PC_AT:
-		/* No translation needed */
-		return keycode;
-	case WSKBD_TYPE_USB:
-		if (keycode < 0 || keycode >= WS_USB_MAP_SIZE) 
-			return KEY_UNKNOWN;
-		else 
-			return wsUsbMap[keycode];
-#ifdef WSKBD_TYPE_ADB
-	case WSKBD_TYPE_ADB:
-		if (keycode < 0 || keycode >= WS_ADB_MAP_SIZE) 
-			return KEY_UNKNOWN;
-		else 
-			return wsAdbMap[keycode];
-#endif
-#ifdef WSKBD_TYPE_SUN
-	case WSKBD_TYPE_SUN:
-#ifdef WSKBD_TYPE_SUN5
-	case WSKBD_TYPE_SUN5:
-#endif
-		if (keycode < 0 || keycode >= WS_SUN_MAP_SIZE)
-			return KEY_UNKNOWN;
-		else
-			return wsSunMap[keycode];
-#endif
-	default:
-		ErrorF("Unknown wskbd type %d\n", xf86Info.wsKbdType);
-		return KEY_UNKNOWN;
-	}
-}
-
-#endif /* WSCONS_SUPPORT */
diff --git a/hw/xfree86/common/xf86KbdLnx.c b/hw/xfree86/common/xf86KbdLnx.c
deleted file mode 100644
index c5361f5..0000000
--- a/hw/xfree86/common/xf86KbdLnx.c
+++ /dev/null
@@ -1,651 +0,0 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c,v 3.17 2003/08/24 17:36:53 dawes Exp $ */
-/*
- * 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.
- *
- */
-/*
- * Copyright (c) 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).
- */
-
-/* $XConsortium: xf86KbdLnx.c /main/7 1996/10/19 17:59:00 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "atKeynames.h"
-
-#include "xf86Keymap.h"
-
-/*
- * LegalModifier --
- *      determine whether a key is a legal modifier key, i.e send a
- *      press/release sequence.
- */
-
-/*ARGSUSED*/
-Bool
-LegalModifier(unsigned int key, DevicePtr pDev)
-{
-  return (TRUE);
-}
-
-/*
- * xf86KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-static void readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap);
-
-void
-xf86KbdGetMapping (KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
-  KeySym        *k;
-  char          type;
-  int           i;
-
-  readKernelMapping(pKeySyms, pModMap);
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = map, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4)
-    
-    switch(*k) {
-      
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-
-    }
-  
-  xf86Info.kbdType =
-    ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101;
-
-  pKeySyms->map        = map;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  pKeySyms->maxKeyCode = MAX_KEYCODE; 
-}
-
-#include <linux/keyboard.h>
-
-static KeySym linux_to_x[256] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_BackSpace,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_nobreakspace,XK_exclamdown,	XK_cent,	XK_sterling,
-	XK_currency,	XK_yen,		XK_brokenbar,	XK_section,
-	XK_diaeresis,	XK_copyright,	XK_ordfeminine,	XK_guillemotleft,
-	XK_notsign,	XK_hyphen,	XK_registered,	XK_macron,
-	XK_degree,	XK_plusminus,	XK_twosuperior,	XK_threesuperior,
-	XK_acute,	XK_mu,		XK_paragraph,	XK_periodcentered,
-	XK_cedilla,	XK_onesuperior,	XK_masculine,	XK_guillemotright,
-	XK_onequarter,	XK_onehalf,	XK_threequarters,XK_questiondown,
-	XK_Agrave,	XK_Aacute,	XK_Acircumflex,	XK_Atilde,
-	XK_Adiaeresis,	XK_Aring,	XK_AE,		XK_Ccedilla,
-	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
-	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
-	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
-	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_multiply,
-	XK_Ooblique,	XK_Ugrave,	XK_Uacute,	XK_Ucircumflex,
-	XK_Udiaeresis,	XK_Yacute,	XK_THORN,	XK_ssharp,
-	XK_agrave,	XK_aacute,	XK_acircumflex,	XK_atilde,
-	XK_adiaeresis,	XK_aring,	XK_ae,		XK_ccedilla,
-	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
-	XK_igrave,	XK_iacute,	XK_icircumflex,	XK_idiaeresis,
-	XK_eth,		XK_ntilde,	XK_ograve,	XK_oacute,
-	XK_ocircumflex,	XK_otilde,	XK_odiaeresis,	XK_division,
-	XK_oslash,	XK_ugrave,	XK_uacute,	XK_ucircumflex,
-	XK_udiaeresis,	XK_yacute,	XK_thorn,	XK_ydiaeresis
-};
-
-/*
- * Maps the AT keycodes to Linux keycodes
- */
-static unsigned char at2lnx[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 */
-};
-#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
-
-#define NUM_CUSTOMKEYS	NR_KEYS
-
-u_char SpecialServerMap[NUM_CUSTOMKEYS];
-
-static void
-readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap)
-{
-  KeySym        *k;
-  int           i;
-  int           maxkey;
-  static unsigned char tbl[GLYPHS_PER_KEY] =
-  {
-	0,	/* unshifted */
-	1,	/* shifted */
-	0,	/* modeswitch unshifted */
-	0	/* modeswitch shifted */
-  };
-
-  /*
-   * Read the mapping from the kernel.
-   * Since we're still using the XFree86 scancode->AT keycode mapping
-   * routines, we need to convert the AT keycodes to Linux keycodes,
-   * then translate the Linux keysyms into X keysyms.
-   *
-   * First, figure out which tables to use for the modeswitch columns
-   * above, from the XF86Config fields.
-   */
-  tbl[2] = 8;	/* alt */
-  tbl[3] = tbl[2] | 1;
-
-  if (xf86Info.kbdCustomKeycodes) {
-    k = map;
-    maxkey = NUM_CUSTOMKEYS;
-  }
-  else {
-    k = map+GLYPHS_PER_KEY;
-    maxkey = NUM_AT2LNX;
-  }
-
-  for (i = 0; i < maxkey; ++i)
-  {
-    struct kbentry kbe;
-    int j;
-
-    if (xf86Info.kbdCustomKeycodes)
-      kbe.kb_index = i;
-    else
-      kbe.kb_index = at2lnx[i];
-
-    for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k)
-    {
-      unsigned short kval;
-
-      *k = NoSymbol;
-
-      kbe.kb_table = tbl[j];
-      if (
-	  (!xf86Info.kbdCustomKeycodes && kbe.kb_index == 0) ||
-	  ioctl(xf86Info.consoleFd, KDGKBENT, &kbe))
-	continue;
-
-      kval = KVAL(kbe.kb_value);
-      switch (KTYP(kbe.kb_value))
-      {
-      case KT_LATIN:
-      case KT_LETTER:
-	*k = linux_to_x[kval];
-	break;
-
-      case KT_FN:
-	if (kval <= 19)
-	  *k = XK_F1 + kval;
-	else switch (kbe.kb_value)
-	{
-	case K_FIND:
-	  *k = XK_Home; /* or XK_Find */
-	  break;
-	case K_INSERT:
-	  *k = XK_Insert;
-	  break;
-	case K_REMOVE:
-	  *k = XK_Delete;
-	  break;
-	case K_SELECT:
-	  *k = XK_End; /* or XK_Select */
-	  break;
-	case K_PGUP:
-	  *k = XK_Prior;
-	  break;
-	case K_PGDN:
-	  *k = XK_Next;
-	  break;
-	case K_HELP:
-	  *k = XK_Help;
-	  break;
-	case K_DO:
-	  *k = XK_Execute;
-	  break;
-	case K_PAUSE:
-	  *k = XK_Pause;
-	  break;
-	case K_MACRO:
-	  *k = XK_Menu;
-	  break;
-	default:
-	  break;
-	}
-	break;
-
-      case KT_SPEC:
-	switch (kbe.kb_value)
-	{
-	case K_ENTER:
-	  *k = XK_Return;
-	  break;
-	case K_BREAK:
-	  *k = XK_Break;
-	  break;
-	case K_CAPS:
-	  *k = XK_Caps_Lock;
-	  break;
-	case K_NUM:
-	  *k = XK_Num_Lock;
-	  break;
-	case K_HOLD:
-	  *k = XK_Scroll_Lock;
-	  break;
-	case K_COMPOSE:
-          *k = XK_Multi_key;
-	  break;
-	default:
-	  break;
-	}
-	break;
-
-      case KT_PAD:
-	switch (kbe.kb_value)
-	{
-	case K_PPLUS:
-	  *k = XK_KP_Add;
-	  break;
-	case K_PMINUS:
-	  *k = XK_KP_Subtract;
-	  break;
-	case K_PSTAR:
-	  *k = XK_KP_Multiply;
-	  break;
-	case K_PSLASH:
-	  *k = XK_KP_Divide;
-	  break;
-	case K_PENTER:
-	  *k = XK_KP_Enter;
-	  break;
-	case K_PCOMMA:
-	  *k = XK_KP_Separator;
-	  break;
-	case K_PDOT:
-	  *k = XK_KP_Decimal;
-	  break;
-	case K_PPLUSMINUS:
-	  *k = XK_KP_Subtract;
-	  break;
-	default:
-	  if (kval <= 9)
-	    *k = XK_KP_0 + kval;
-	  break;
-	}
-	break;
-
-      /*
-       * KT_DEAD keys are for accelerated diacritical creation.
-       */
-      case KT_DEAD:
-	switch (kbe.kb_value)
-	  {
-	  case K_DGRAVE:
-	    *k = XK_dead_grave;
-	    break;
-	  case K_DACUTE:
-	    *k = XK_dead_acute;
-	    break;
-	  case K_DCIRCM:
-	    *k = XK_dead_circumflex;
-	    break;
-	  case K_DTILDE:
-	    *k = XK_dead_tilde;
-	    break;
-	  case K_DDIERE:
-	    *k = XK_dead_diaeresis;
-	    break;
-	  }
-	break;
-
-      case KT_CUR:
-	switch (kbe.kb_value)
-	{
-	case K_DOWN:
-	  *k = XK_Down;
-	  break;
-	case K_LEFT:
-	  *k = XK_Left;
-	  break;
-	case K_RIGHT:
-	  *k = XK_Right;
-	  break;
-	case K_UP:
-	  *k = XK_Up;
-	  break;
-	}
-	break;
-
-      case KT_SHIFT:
-	switch (kbe.kb_value)
-	{
-	case K_ALTGR:
-	  *k = XK_Alt_R;
-	  break;
-	case K_ALT:
-	  *k = (kbe.kb_index == 0x64 ?
-		XK_Alt_R : XK_Alt_L);
-	  break;
-	case K_CTRL:
-	  *k = (kbe.kb_index == 0x61 ?
-		XK_Control_R : XK_Control_L);
-	  break;
-        case K_CTRLL:
-	  *k = XK_Control_L;
-	  break;
-        case K_CTRLR:
-	  *k = XK_Control_R;
-	  break;
-	case K_SHIFT:
-	  *k = (kbe.kb_index == 0x36 ?
-		XK_Shift_R : XK_Shift_L);
-	  break;
-        case K_SHIFTL:
-	  *k = XK_Shift_L;
-	  break;
-        case K_SHIFTR:
-	  *k = XK_Shift_R;
-	  break;
-	default:
-	  break;
-	}
-	break;
-
-      /*
-       * KT_ASCII keys accumulate a 3 digit decimal number that gets
-       * emitted when the shift state changes. We can't emulate that.
-       */
-      case KT_ASCII:
-	break;
-
-      case KT_LOCK:
-	if (kbe.kb_value == K_SHIFTLOCK)
-	  *k = XK_Shift_Lock;
-	break;
-
-      default:
-	break;
-      }
-    }
-
-    if (k[-1] == k[-2]) k[-1] = NoSymbol;
-    if (k[-2] == k[-3]) k[-2] = NoSymbol;
-    if (k[-3] == k[-4]) k[-3] = NoSymbol;
-    if (k[-4] == k[-2] && k[-3] == k[-1]) k[-2] = k[-1] = NoSymbol;
-    if (k[-1] == k[-4] && k[-2] == k[-3] && k[-2] == NoSymbol) k[-1] =NoSymbol;
-  }
-
-  if (!xf86Info.kbdCustomKeycodes)
-    return;
-
-  /*
-   * Find the Mapping for the special server functions
-   */
-  for (i = 0; i < NUM_CUSTOMKEYS; ++i) {
-    struct kbentry kbe;
-    int special = 0;
-
-    kbe.kb_index = i;
-    kbe.kb_table = 0; /* Plain map */
-    if (!ioctl(xf86Info.consoleFd, KDGKBENT, &kbe))
-      switch (kbe.kb_value) {
-	case K(KT_LATIN,0x7f):	/* This catches DEL too... But who cares? */
-	  special = KEY_BackSpace;
-	  break;
-	case K_PMINUS:
-	  special = KEY_KP_Minus;
-	  break;
-	case K_PPLUS:
-	  special = KEY_KP_Plus;
-	  break;
-	case K_F1:
-	  special = KEY_F1;
-	  break;
-	case K_F2:
-	  special = KEY_F2;
-	  break;
-	case K_F3:
-	  special = KEY_F3;
-	  break;
-	case K_F4:
-	  special = KEY_F4;
-	  break;
-	case K_F5:
-	  special = KEY_F5;
-	  break;
-	case K_F6:
-	  special = KEY_F6;
-	  break;
-	case K_F7:
-	  special = KEY_F7;
-	  break;
-	case K_F8:
-	  special = KEY_F8;
-	  break;
-	case K_F9:
-	  special = KEY_F9;
-	  break;
-	case K_F10:
-	  special = KEY_F10;
-	  break;
-	case K_F11:
-	  special = KEY_F11;
-	  break;
-	case K_F12:
-	  special = KEY_F12;
-	  break;
-	case K_ALT:
-	  special = KEY_Alt;
-	  break;
-	case K_ALTGR:
-	  special = KEY_AltLang;
-	  break;
-	case K_CONS:
-	  special = KEY_SysReqest;
-	  break;
-      }
-    SpecialServerMap[i] = special;
-  }
-}
diff --git a/hw/xfree86/common/xf86KbdMach.c b/hw/xfree86/common/xf86KbdMach.c
deleted file mode 100644
index 89c23c2..0000000
--- a/hw/xfree86/common/xf86KbdMach.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdMach.c,v 3.7.4.2 1998/06/04 17:35:20 dawes Exp $ */
-/*
- *****************************************************************************
- * HISTORY
- * Log:	xf86KbdMach.c,v
- * Revision 2.1.2.1  92/06/25  10:32:08  moore
- * 	Incorporate the Elliot Dresselhaus's, Ernest Hua's and local changes
- * 	to run Thomas Roell's I386 color X11R5.  Original code only worked
- * 	with SCO Unix.  New code works with 2.5 and 3.0 Mach
- * 	[92/06/24            rvb]
- * 
- * 	EndLog
- * 
- *****************************************************************************
- */
-/*
- * 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.
- *
- */
-/* $XConsortium: xf86KbdMach.c /main/9 1996/02/21 17:38:43 kaleb $ */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "input.h"
-#include "scrnintstr.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-#include "atKeynames.h"
-#include "xf86Config.h"
-
-#include "xf86Keymap.h"
-
-static KeySym ascii_to_x[256] = {
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
-	NoSymbol,	XK_Return,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
-	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
-	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
-	XK_comma,	XK_minus,	XK_period,	XK_slash,
-	XK_0,		XK_1,		XK_2,		XK_3,
-	XK_4,		XK_5,		XK_6,		XK_7,
-	XK_8,		XK_9,		XK_colon,	XK_semicolon,
-	XK_less,	XK_equal,	XK_greater,	XK_question,
-	XK_at,		XK_A,		XK_B,		XK_C,
-	XK_D,		XK_E,		XK_F,		XK_G,
-	XK_H,		XK_I,		XK_J,		XK_K,
-	XK_L,		XK_M,		XK_N,		XK_O,
-	XK_P,		XK_Q,		XK_R,		XK_S,
-	XK_T,		XK_U,		XK_V,		XK_W,
-	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
-	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
-	XK_grave,	XK_a,		XK_b,		XK_c,
-	XK_d,		XK_e,		XK_f,		XK_g,
-	XK_h,		XK_i,		XK_j,		XK_k,
-	XK_l,		XK_m,		XK_n,		XK_o,
-	XK_p,		XK_q,		XK_r,		XK_s,
-	XK_t,		XK_u,		XK_v,		XK_w,
-	XK_x,		XK_y,		XK_z,		XK_braceleft,
-	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
-	XK_Ccedilla,	XK_udiaeresis,	XK_eacute,	XK_acircumflex,
-	XK_adiaeresis,	XK_agrave,	XK_aring,	XK_ccedilla,
-	XK_ecircumflex,	XK_ediaeresis,	XK_egrave,	XK_idiaeresis,
-	XK_icircumflex,	XK_igrave,	XK_Adiaeresis,	XK_Aring,
-	XK_Eacute,	XK_ae,		XK_AE,		XK_ocircumflex,
-	XK_odiaeresis,	XK_ograve,	XK_ucircumflex,	XK_ugrave,
-	XK_ydiaeresis,	XK_Odiaeresis,	XK_Udiaeresis,	XK_cent,
-	XK_sterling,	XK_yen,		XK_paragraph,	XK_section,
-	XK_aacute,	XK_iacute,	XK_oacute,	XK_uacute,
-	XK_ntilde,	XK_Ntilde,	XK_ordfeminine,	XK_masculine,
-	XK_questiondown,XK_hyphen,	XK_notsign,	XK_onehalf,
-	XK_onequarter,	XK_exclamdown,	XK_guillemotleft,XK_guillemotright,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
-	XK_Greek_alpha,	XK_ssharp,	XK_Greek_GAMMA,	XK_Greek_pi,
-	XK_Greek_SIGMA,	XK_Greek_sigma,	XK_mu,	        XK_Greek_tau,
-	XK_Greek_PHI,	XK_Greek_THETA,	XK_Greek_OMEGA,	XK_Greek_delta,
-	XK_infinity,	XK_Ooblique,	XK_Greek_epsilon, XK_intersection,
-	XK_identical,	XK_plusminus,	XK_greaterthanequal, XK_lessthanequal,
-	XK_topintegral,	XK_botintegral,	XK_division,	XK_similarequal,
-	XK_degree,	NoSymbol,	NoSymbol,	XK_radical,
-	XK_Greek_eta,	XK_twosuperior,	XK_periodcentered, NoSymbol,
-      };
-
-/*
- * LegalModifier --
- *      determine whether a key is a legal modifier key, i.e send a
- *      press/release sequence.
- */
-
-/*ARGSUSED*/
-Bool
-LegalModifier(key, pDev)
-     unsigned int  key;
-     DevicePtr  pDev;
-{
-  return (TRUE);
-}
-
-
-      
-/*
- * xf86KbdGetMapping --
- *	Get the national keyboard mapping. The keyboard type is set, a new map
- *      and the modifiermap is computed.
- */
-
-void
-xf86KbdGetMapping (pKeySyms, pModMap)
-     KeySymsPtr pKeySyms;
-     CARD8      *pModMap;
-{
-  KeySym        *k;
-  struct	kbentry kbe;
-  char          type;
-  int           i, j;
-  
-  for (i = 0; i < NUMKEYS; i++)
-    {
-      static int states[] = { NORM_STATE, SHIFT_STATE, ALT_STATE, SHIFT_ALT };
-      int j;
-
-      k = &map[i*4];
-      kbe.kb_index = i;
-	
-      for (j = 0; j < 4; j++)
-	{
-	  kbe.kb_state = states[j];
-
-	  if (ioctl (xf86Info.consoleFd, KDGKBENT, &kbe) != -1)
-	    continue;
-      
-	  if (kbe.kb_value [0] == K_SCAN)
-	    {
-	      int keycode = -1;
-	      switch (kbe.kb_value [1])
-		{
-		case K_CTLSC: keycode = XK_Control_L; break;
-		case K_LSHSC: keycode = XK_Shift_L; break;
-		case K_RSHSC: keycode = XK_Shift_R; break;
-		case K_ALTSC: keycode = XK_Alt_L; break;
-		case K_CLCKSC: keycode = XK_Caps_Lock; break;
-		case K_NLCKSC: keycode = XK_Num_Lock; break;
-		default: break;
-		}
-	      if (keycode > 0)
-		k[j] = keycode;
-	    }
-	  else if (kbe.kb_value[1] != NC)
-	    {
-	      /* How to handle multiple characters?
-	         Ignore them for now. */
-	    }
-	  else
-	    {
-	      k[j] = ascii_to_x[kbe.kb_value[0]];
-	    }
-	}
-    }
-
-  /*
-   * Apply the special key mapping specified in XF86Config 
-   */
-  for (k = map, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4) {
-    switch (k[0]) {
-      case XK_Alt_L:
-        j = K_INDEX_LEFTALT;
-        break;
-      case XK_Alt_R:
-        j = K_INDEX_RIGHTALT;
-        break;
-      case XK_Scroll_Lock:
-        j = K_INDEX_SCROLLLOCK;
-        break;
-      case XK_Control_R:
-        j = K_INDEX_RIGHTCTL;
-        break;
-      default:
-        j = -1;
-    }
-    if (j >= 0)
-      switch (xf86Info.specialKeyMap[j]) {
-        case KM_META:
-          if (k[0] == XK_Alt_R)
-            k[1] = XK_Meta_R;
-          else {
-            k[0] = XK_Alt_L;
-            k[1] = XK_Meta_L;
-          }
-          break;
-        case KM_COMPOSE:
-          k[0] = XK_Multi_key;
-          break;
-        case KM_MODESHIFT:
-          k[0] = XK_Mode_switch;
-          k[1] = NoSymbol;
-          break;
-        case KM_MODELOCK:
-          k[0] = XK_Mode_switch;
-          k[1] = XF86XK_ModeLock;
-          break;
-        case KM_SCROLLLOCK:
-          k[0] = XK_Scroll_Lock;
-          break;
-        case KM_CONTROL:
-          k[0] = XK_Control_R;
-          break;
-      }
-  }
-
-  /*
-   * compute the modifier map
-   */
-  for (i = 0; i < MAP_LENGTH; i++)
-    pModMap[i] = NoSymbol;  /* make sure it is restored */
-  
-  for (k = map, i = MIN_KEYCODE;
-       i < (NUM_KEYCODES + MIN_KEYCODE);
-       i++, k += 4)
-    
-    switch(*k) {
-      
-    case XK_Shift_L:
-    case XK_Shift_R:
-      pModMap[i] = ShiftMask;
-      break;
-      
-    case XK_Control_L:
-    case XK_Control_R:
-      pModMap[i] = ControlMask;
-      break;
-      
-    case XK_Caps_Lock:
-      pModMap[i] = LockMask;
-      break;
-      
-    case XK_Alt_L:
-    case XK_Alt_R:
-      pModMap[i] = AltMask;
-      break;
-      
-    case XK_Num_Lock:
-      if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask;
-      break;
-
-    case XK_Scroll_Lock:
-      pModMap[i] = ScrollLockMask;
-      break;
-
-      /* kana support */
-    case XK_Kana_Lock:
-    case XK_Kana_Shift:
-      pModMap[i] = KanaMask;
-      break;
-
-      /* alternate toggle for multinational support */
-    case XK_Mode_switch:
-      pModMap[i] = AltLangMask;
-      break;
-
-    }
-  
-  xf86Info.kbdType =
-    ioctl(xf86Info.kbdFd, KDGKBDTYPE, &type) != -1 ? type : KB_VANILLAKB;
-
-  pKeySyms->map        = map;
-  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
-  pKeySyms->minKeyCode = MIN_KEYCODE;
-  if (xf86Info.serverNumLock)
-    pKeySyms->maxKeyCode = MAX_KEYCODE; 
-  else
-    pKeySyms->maxKeyCode = MAX_STD_KEYCODE;
-
-}
diff --git a/hw/xfree86/common/xf86MiscExt.c b/hw/xfree86/common/xf86MiscExt.c
index 3e741ba..3a698b0 100644
--- a/hw/xfree86/common/xf86MiscExt.c
+++ b/hw/xfree86/common/xf86MiscExt.c
@@ -62,6 +62,7 @@
 #endif
 
 #include "xf86OSmouse.h"
+#include "xf86OSKbd.h"
 
 #ifdef DEBUG
 # define DEBUG_P(x) ErrorF(x"\n");
@@ -90,6 +91,7 @@ typedef struct {
 	int	rate;
 	int	delay;
 	int	serverNumLock;	/* obsolete */
+        pointer private;
 } kbdParamsRec, *kbdParamsPtr;
 
 /*
@@ -257,16 +259,23 @@ _X_EXPORT Bool
 MiscExtGetKbdSettings(pointer *kbd)
 {
     kbdParamsPtr kbdptr;
+    InputInfoPtr pInfo;
+    KbdDevPtr pKbd;
 
     DEBUG_P("MiscExtGetKbdSettings");
 
     kbdptr = MiscExtCreateStruct(MISC_KEYBOARD);
     if (!kbdptr)
 	return FALSE;
-    kbdptr->type  = xf86Info.kbdType;
-    kbdptr->rate  = xf86Info.kbdRate;
-    kbdptr->delay = xf86Info.kbdDelay;
+
+    pInfo = inputInfo.keyboard->public.devicePrivate;
+    pKbd = (KbdDevPtr) pInfo->private;
+
+    kbdptr->type  = pKbd->kbdType;
+    kbdptr->rate  = pKbd->rate;
+    kbdptr->delay = pKbd->delay;
     *kbd = kbdptr;
+
     return TRUE;
 }
 
@@ -589,6 +598,11 @@ MiscExtApply(pointer structure, MiscExtS
     }
     if (mse_or_kbd == MISC_KEYBOARD) {
 	kbdParamsPtr kbd = structure;
+        InputInfoPtr pInfo;
+        KbdDevPtr pKbd;
+
+        pInfo = inputInfo.keyboard->public.devicePrivate;
+        pKbd = (KbdDevPtr) pInfo->private;
 
 	if (kbd->rate < 0)
 	    return MISC_RET_BADVAL;
@@ -597,25 +611,22 @@ MiscExtApply(pointer structure, MiscExtS
 	if (kbd->type < KTYPE_UNKNOWN || kbd->type > KTYPE_XQUEUE)
 	    return MISC_RET_BADKBDTYPE;
 
-	if (xf86Info.kbdRate!=kbd->rate || xf86Info.kbdDelay!=kbd->delay) {
+	if (pKbd->rate!=kbd->rate || pKbd->delay!=kbd->delay) {
 	    char rad;
 
-	    xf86Info.kbdRate = kbd->rate;
-	    xf86Info.kbdDelay = kbd->delay;
-	    if      (xf86Info.kbdDelay <= 375) rad = 0x00;
-	    else if (xf86Info.kbdDelay <= 625) rad = 0x20;
-	    else if (xf86Info.kbdDelay <= 875) rad = 0x40;
-	    else                               rad = 0x60;
-
-	    if      (xf86Info.kbdRate <=  2)   rad |= 0x1F;
-	    else if (xf86Info.kbdRate >= 30)   rad |= 0x00;
-	    else                               rad |= ((58/xf86Info.kbdRate)-2);
+	    pKbd->rate = kbd->rate;
+	    pKbd->delay = kbd->delay;
+	    if      (pKbd->delay <= 375) rad = 0x00;
+	    else if (pKbd->delay <= 625) rad = 0x20;
+	    else if (pKbd->delay <= 875) rad = 0x40;
+	    else                         rad = 0x60;
+
+	    if      (pKbd->rate <=  2)   rad |= 0x1F;
+	    else if (pKbd->rate >= 30)   rad |= 0x00;
+	    else                         rad |= ((58/pKbd->rate)-2);
 
-	    xf86SetKbdRepeat(rad);
+	    pKbd->SetKbdRepeat(pInfo, rad);
 	}
-#if 0   /* Not done yet */
-	xf86Info.kbdType = kbd->kbdtype;
-#endif
     }
     return MISC_RET_SUCCESS;
 }
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index b4e531c..7b435ac 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -194,17 +194,6 @@ Bool xf86LoadModules(char **list, pointe
 int xf86SetVerbosity(int verb);
 int xf86SetLogVerbosity(int verb);
 
-/* xf86Io.c */
-
-void xf86KbdBell(int percent, DeviceIntPtr pKeyboard, pointer ctrl,
-		 int unused);
-void xf86KbdLeds(void);
-void xf86UpdateKbdLeds(void);
-
-/* xf86Kbd.c */ 
-
-void xf86KbdGetMapping(KeySymsPtr pKeySyms, CARD8 *pModMap);
-
 /* xf86Lock.c */
 
 #ifdef USE_XF86_SERVERLOCK
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index c26e288..0ea6712 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -69,32 +69,10 @@ typedef enum {
 
 typedef struct {
     int			consoleFd;
-    int			kbdFd;
     int			vtno;
-    int			kbdType;		/* AT84 / AT101 */
-    int			kbdRate;
-    int			kbdDelay;
-    int			bell_pitch;
-    int			bell_duration;
-    Bool		autoRepeat;
-    unsigned long	leds;
-    unsigned long	xleds;
     char *		vtinit;
-    int			scanPrefix;		/* scancode-state */
-    Bool		capsLock;
-    Bool		numLock;
-    Bool		scrollLock;
-    Bool		modeSwitchLock;
-    Bool		composeLock;
     Bool		vtSysreq;
     SpecialKeysInDDX	ddxSpecialKeys;
-    Bool		ActionKeyBindingsSet;
-#if defined(SVR4) && defined(i386)
-    Bool		panix106;
-#endif  /* SVR4 && i386 */
-#if defined(__OpenBSD__) || defined(__NetBSD__)
-    int                 wsKbdType;
-#endif
 
     /* mouse part */
     DeviceIntPtr	pMouse;
@@ -121,25 +99,6 @@ typedef struct {
     int			consType;	/* Which console driver? */
 #endif
 
-#ifdef XKB
-    /* 
-     * would like to use an XkbComponentNamesRec here but can't without
-     * pulling in a bunch of header files. :-(
-     */
-    char *		xkbkeymap;
-    char *		xkbkeycodes;
-    char *		xkbtypes;
-    char *		xkbcompat;
-    char *		xkbsymbols;
-    char *		xkbgeometry;
-    Bool		xkbcomponents_specified;
-    char *		xkbrules;
-    char *		xkbmodel;
-    char *		xkblayout;
-    char *		xkbvariant;
-    char *		xkboptions;
-#endif
-
     /* Other things */
     Bool		allowMouseOpenFail;
     Bool		vidModeEnabled;		/* VidMode extension enabled */
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index f9d11e8..5fa52c4 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -290,7 +290,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86BindGARTMemory)
     SYMFUNC(xf86UnbindGARTMemory)
     SYMFUNC(xf86EnableAGP)
-    SYMFUNC(xf86SoundKbdBell)
     SYMFUNC(xf86GARTCloseScreen)
 #ifdef XINPUT
     SYMFUNC(XisbNew)
diff --git a/hw/xfree86/os-support/linux/Makefile.am b/hw/xfree86/os-support/linux/Makefile.am
index 6fdc1bc..d77e3a3 100644
--- a/hw/xfree86/os-support/linux/Makefile.am
+++ b/hw/xfree86/os-support/linux/Makefile.am
@@ -19,7 +19,7 @@ APM_SOURCES = lnx_apm.c
 XORG_CFLAGS += -DHAVE_APM
 endif
 
-liblinux_la_SOURCES = lnx_init.c lnx_video.c lnx_io.c lnx_kbd.c lnx_mouse.c \
+liblinux_la_SOURCES = lnx_init.c lnx_video.c lnx_kbd.c lnx_mouse.c \
                      lnx_pci.c lnx_agp.c lnx_kmod.c lnx_KbdMap.c \
                      $(srcdir)/../shared/bios_mmap.c \
 		     $(srcdir)/../shared/VTsw_usl.c \
diff --git a/hw/xfree86/os-support/linux/lnx_io.c b/hw/xfree86/os-support/linux/lnx_io.c
deleted file mode 100644
index eb8cd53..0000000
--- a/hw/xfree86/os-support/linux/lnx_io.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.25 2003/08/19 17:32:34 tsi Exp $ */
-/*
- * 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.
- *
- */
-/* $XConsortium: lnx_io.c /main/8 1996/10/19 18:06:28 kaleb $ */
-
-#define NEED_EVENTS
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-#define KBC_TIMEOUT 250        /* Timeout in ms for sending to keyboard controller */
-
-_X_EXPORT void
-xf86SoundKbdBell(int loudness, int pitch, int duration)
-{
-	if (loudness && pitch)
-	{
-		ioctl(xf86Info.consoleFd, KDMKTONE,
-		      ((1193190 / pitch) & 0xffff) |
-		      (((unsigned long)duration *
-			loudness / 50) << 16));
-	}
-}
-
-void
-xf86SetKbdLeds(int leds)
-{
- 	ioctl(xf86Info.consoleFd, KDSETLED, leds);
-}
-
-int
-xf86GetKbdLeds()
-{
-	int leds = 0;
-
- 	ioctl(xf86Info.consoleFd, KDGETLED, &leds);
-	return(leds);
-}
-
-static int
-KDKBDREP_ioctl_ok(int rate, int delay) {
-#if defined(KDKBDREP) && !defined(__sparc__)
-     /* This ioctl is defined in <linux/kd.h> but is not
-	implemented anywhere - must be in some m68k patches. */
-   struct kbd_repeat kbdrep_s;
-
-   /* don't change, just test */
-   kbdrep_s.LNX_KBD_PERIOD_NAME = -1;
-   kbdrep_s.delay = -1;
-   if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
-       return 0;
-   }
-   /* do the change */
-   if (rate == 0)				/* switch repeat off */
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 0;
-   else
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 10000 / rate; /* convert cps to msec */
-   if (kbdrep_s.LNX_KBD_PERIOD_NAME < 1)
-     kbdrep_s.LNX_KBD_PERIOD_NAME = 1;
-   kbdrep_s.delay = delay;
-   if (kbdrep_s.delay < 1)
-     kbdrep_s.delay = 1;
-   
-   if (ioctl( xf86Info.consoleFd, KDKBDREP, &kbdrep_s )) {
-     return 0;
-   }
-
-   return 1;			/* success! */
-#else /* no KDKBDREP */
-   return 0;
-#endif /* KDKBDREP */
-}
-
-static int
-KIOCSRATE_ioctl_ok(int rate, int delay) {
-#ifdef KIOCSRATE
-   struct kbd_rate kbdrate_s;
-   int fd;
-
-   fd = open("/dev/kbd", O_RDONLY);
-   if (fd == -1) 
-     return 0;   
-
-   kbdrate_s.rate = (rate + 5) / 10;  /* must be integer, so round up */
-   kbdrate_s.delay = delay * HZ / 1000;  /* convert ms to Hz */
-   if (kbdrate_s.rate > 50)
-     kbdrate_s.rate = 50;
-
-   if (ioctl( fd, KIOCSRATE, &kbdrate_s )) {
-       return 0;
-   }
-
-   close( fd );
-
-   return 1;
-#else /* no KIOCSRATE */
-   return 0;
-#endif /* KIOCSRATE */
-}
-
-void xf86SetKbdRepeat(char rad)
-{
-#ifdef __sparc__
-  int         rate  = 500;     /* Default rate */
-  int         delay = 200;     /* Default delay */
-#else
-  int         rate  = 300;     /* Default rate */
-  int         delay = 250;     /* Default delay */
-#endif
-
-#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
-  int i;
-  int timeout;
-  int         value = 0x7f;    /* Maximum delay with slowest rate */
-
-  static int valid_rates[] = { 300, 267, 240, 218, 200, 185, 171, 160, 150,
-			       133, 120, 109, 100, 92, 86, 80, 75, 67,
-			       60, 55, 50, 46, 43, 40, 37, 33, 30, 27,
-			       25, 23, 21, 20 };
-#define RATE_COUNT (sizeof( valid_rates ) / sizeof( int ))
-
-  static int valid_delays[] = { 250, 500, 750, 1000 };
-#define DELAY_COUNT (sizeof( valid_delays ) / sizeof( int ))
-#endif
-
-  if (xf86Info.kbdRate >= 0) 
-    rate = xf86Info.kbdRate * 10;
-  if (xf86Info.kbdDelay >= 0)
-    delay = xf86Info.kbdDelay;
-
-  if(KDKBDREP_ioctl_ok(rate, delay)) 	/* m68k? */
-    return;
-
-  if(KIOCSRATE_ioctl_ok(rate, delay))	/* sparc? */
-    return;
-
-  if (xf86IsPc98())
-    return;
-
-#if defined(__alpha__) || defined (__i386__) || defined(__ia64__)
-
-  /* The ioport way */
-
-  for (i = 0; i < RATE_COUNT; i++)
-    if (rate >= valid_rates[i]) {
-      value &= 0x60;
-      value |= i;
-      break;
-    }
-
-  for (i = 0; i < DELAY_COUNT; i++)
-    if (delay <= valid_delays[i]) {
-      value &= 0x1f;
-      value |= i << 5;
-      break;
-    }
-
-  timeout = KBC_TIMEOUT;
-  while (((inb(0x64) & 2) == 2) && --timeout)
-       usleep(1000); /* wait */
-
-  if (timeout == 0)
-      return;
-
-  outb(0x60, 0xf3);             /* set typematic rate */
-  while (((inb(0x64) & 2) == 2) && --timeout)
-       usleep(1000); /* wait */
-
-  usleep(10000);
-  outb(0x60, value);
-
-#endif /* __alpha__ || __i386__ || __ia64__ */
-}
-
-static int kbdtrans;
-static struct termios kbdtty;
-
-void
-xf86KbdInit()
-{
-	ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
-	tcgetattr (xf86Info.consoleFd, &kbdtty);
-}
-
-int
-xf86KbdOn()
-{
-	struct termios nTty;
-
-#ifdef __powerpc__
-	if (xf86Info.kbdCustomKeycodes)
-		ioctl(xf86Info.consoleFd, KDSKBMODE, K_MEDIUMRAW);
-	else
-#endif
-	ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
-
-	nTty = kbdtty;
-	nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
-	nTty.c_oflag = 0;
-	nTty.c_cflag = CREAD | CS8;
-	nTty.c_lflag = 0;
-	nTty.c_cc[VTIME]=0;
-	nTty.c_cc[VMIN]=1;
-	cfsetispeed(&nTty, 9600);
-	cfsetospeed(&nTty, 9600);
-	tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
-	return(xf86Info.consoleFd);
-}
-
-int
-xf86KbdOff()
-{
-	ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans);
-	tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
-	return(xf86Info.consoleFd);
-}
-
diff --git a/hw/xfree86/parser/Keyboard.c b/hw/xfree86/parser/Keyboard.c
deleted file mode 100644
index 62031f6..0000000
--- a/hw/xfree86/parser/Keyboard.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Keyboard.c,v 1.17 2003/08/24 17:37:07 dawes Exp $ */
-/* 
- * 
- * Copyright (c) 1997  Metro Link Incorporated
- * 
- * 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 X CONSORTIUM 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 Metro Link shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from Metro Link.
- * 
- */
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-
-/* View/edit this file with tab stops set to 4 */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86Parser.h"
-#include "xf86tokens.h"
-#include "Configint.h"
-#include "ctype.h"
-
-extern LexRec val;
-
-static xf86ConfigSymTabRec KeyboardTab[] =
-{
-	{ENDSECTION, "endsection"},
-	{KPROTOCOL, "protocol"},
-	{AUTOREPEAT, "autorepeat"},
-	{XLEDS, "xleds"},
-	{PANIX106, "panix106"},
-	{XKBKEYMAP, "xkbkeymap"},
-	{XKBCOMPAT, "xkbcompat"},
-	{XKBTYPES, "xkbtypes"},
-	{XKBKEYCODES, "xkbkeycodes"},
-	{XKBGEOMETRY, "xkbgeometry"},
-	{XKBSYMBOLS, "xkbsymbols"},
-	{XKBDISABLE, "xkbdisable"},
-	{XKBRULES, "xkbrules"},
-	{XKBMODEL, "xkbmodel"},
-	{XKBLAYOUT, "xkblayout"},
-	{XKBVARIANT, "xkbvariant"},
-	{XKBOPTIONS, "xkboptions"},
-	/* The next two have become ServerFlags options */
-	{VTINIT, "vtinit"},
-	{VTSYSREQ, "vtsysreq"},
-	/* Obsolete keywords */
-	{SERVERNUM, "servernumlock"},
-	{LEFTALT, "leftalt"},
-	{RIGHTALT, "rightalt"},
-	{RIGHTALT, "altgr"},
-	{SCROLLLOCK_TOK, "scrolllock"},
-	{RIGHTCTL, "rightctl"},
-	{-1, ""},
-};
-
-/* Obsolete */
-static xf86ConfigSymTabRec KeyMapTab[] =
-{
-	{CONF_KM_META, "meta"},
-	{CONF_KM_COMPOSE, "compose"},
-	{CONF_KM_MODESHIFT, "modeshift"},
-	{CONF_KM_MODELOCK, "modelock"},
-	{CONF_KM_SCROLLLOCK, "scrolllock"},
-	{CONF_KM_CONTROL, "control"},
-	{-1, ""},
-};
-
-#define CLEANUP xf86freeInputList
-
-XF86ConfInputPtr
-xf86parseKeyboardSection (void)
-{
-	char *s, *s1, *s2;
-	int l;
-	int token, ntoken;
-	parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
-
-	while ((token = xf86getToken (KeyboardTab)) != ENDSECTION)
-	{
-		switch (token)
-		{
-		case COMMENT:
-			ptr->inp_comment = xf86addComment(ptr->inp_comment, val.str);
-			break;
-		case KPROTOCOL:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "Protocol");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-							       xf86configStrdup("Protocol"),
-							       val.str);
-			break;
-		case AUTOREPEAT:
-			if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER)
-				Error (AUTOREPEAT_MSG, NULL);
-			s1 = xf86uLongToString(val.num);
-			if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER) {
-				xf86conffree(s1);
-				Error (AUTOREPEAT_MSG, NULL);
-			}
-			s2 = xf86uLongToString(val.num);
-			l = strlen(s1) + 1 + strlen(s2) + 1;
-			s = xf86confmalloc(l);
-			sprintf(s, "%s %s", s1, s2);
-			xf86conffree(s1);
-			xf86conffree(s2);
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-							       xf86configStrdup("AutoRepeat"), s);
-			break;
-		case XLEDS:
-			if (xf86getSubToken (&(ptr->inp_comment)) != NUMBER)
-				Error (XLEDS_MSG, NULL);
-			s = xf86uLongToString(val.num);
-			l = strlen(s) + 1;
-			while ((token = xf86getSubToken (&(ptr->inp_comment))) == NUMBER)
-			{
-				s1 = xf86uLongToString(val.num);
-				l += (1 + strlen(s1));
-				s = xf86confrealloc(s, l);
-				strcat(s, " ");
-				strcat(s, s1);
-				xf86conffree(s1);
-			}
-			xf86unGetToken (token);
-			xf86conffree(s);
-			break;
-		case SERVERNUM:
-			xf86parseWarning(OBSOLETE_MSG, xf86tokenString());
-			break;
-		case LEFTALT:
-		case RIGHTALT:
-		case SCROLLLOCK_TOK:
-		case RIGHTCTL:
-			xf86parseWarning(OBSOLETE_MSG, xf86tokenString());
-				break;
-			ntoken = xf86getToken (KeyMapTab);
-			switch (ntoken)
-			{
-			case EOF_TOKEN:
-				xf86parseError (UNEXPECTED_EOF_MSG);
-				CLEANUP (ptr);
-				return (NULL);
-				break;
-
-			default:
-				Error (INVALID_KEYWORD_MSG, xf86tokenString ());
-				break;
-			}
-			break;
-		case VTINIT:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "VTInit");
-			xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTInit");
-			break;
-		case VTSYSREQ:
-			xf86parseWarning(MOVED_TO_FLAGS_MSG, "VTSysReq");
-			break;
-		case XKBDISABLE:
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbDisable"),
-												NULL);
-			break;
-		case XKBKEYMAP:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBKeymap");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbKeymap"),
-												val.str);
-			break;
-		case XKBCOMPAT:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBCompat");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbCompat"),
-												val.str);
-			break;
-		case XKBTYPES:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBTypes");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbTypes"),
-												val.str);
-			break;
-		case XKBKEYCODES:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBKeycodes");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbKeycodes"),
-												val.str);
-			break;
-		case XKBGEOMETRY:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBGeometry");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbGeometry"),
-												val.str);
-			break;
-		case XKBSYMBOLS:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBSymbols");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbSymbols"),
-												val.str);
-			break;
-		case XKBRULES:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBRules");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbRules"),
-												val.str);
-			break;
-		case XKBMODEL:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBModel");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbModel"),
-												val.str);
-			break;
-		case XKBLAYOUT:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBLayout");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbLayout"),
-												val.str);
-			break;
-		case XKBVARIANT:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBVariant");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbVariant"),
-												val.str);
-			break;
-		case XKBOPTIONS:
-			if (xf86getSubToken (&(ptr->inp_comment)) != STRING)
-				Error (QUOTE_MSG, "XKBOptions");
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("XkbOptions"),
-												val.str);
-			break;
-		case PANIX106:
-			ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-												xf86configStrdup("Panix106"), NULL);
-			break;
-		case EOF_TOKEN:
-			Error (UNEXPECTED_EOF_MSG, NULL);
-			break;
-		default:
-			Error (INVALID_KEYWORD_MSG, xf86tokenString ());
-			break;
-		}
-	}
-
-	ptr->inp_identifier = xf86configStrdup(CONF_IMPLICIT_KEYBOARD);
-	ptr->inp_driver = xf86configStrdup("keyboard");
-	ptr->inp_option_lst = xf86addNewOption(ptr->inp_option_lst,
-										xf86configStrdup("CoreKeyboard"), NULL);
-
-#ifdef DEBUG
-	printf ("Keyboard section parsed\n");
-#endif
-
-	return ptr;
-}
-
diff --git a/hw/xfree86/parser/Makefile.am b/hw/xfree86/parser/Makefile.am
index acda83d..23db38e 100644
--- a/hw/xfree86/parser/Makefile.am
+++ b/hw/xfree86/parser/Makefile.am
@@ -9,7 +9,6 @@ libxf86config_a_SOURCES = \
 	Files.c \
 	Flags.c \
 	Input.c \
-	Keyboard.c \
 	Layout.c \
 	Module.c \
 	Video.c \
diff --git a/hw/xfree86/parser/configProcs.h b/hw/xfree86/parser/configProcs.h
index bb5f4e9..72b1607 100644
--- a/hw/xfree86/parser/configProcs.h
+++ b/hw/xfree86/parser/configProcs.h
@@ -46,8 +46,6 @@ XF86ConfInputPtr xf86parseInputSection(v
 void xf86printInputSection(FILE *f, XF86ConfInputPtr ptr);
 void xf86freeInputList(XF86ConfInputPtr ptr);
 int xf86validateInput (XF86ConfigPtr p);
-/* Keyboard.c */
-XF86ConfInputPtr xf86parseKeyboardSection(void);
 /* Layout.c */
 XF86ConfLayoutPtr xf86parseLayoutSection(void);
 void xf86printLayoutSection(FILE *cf, XF86ConfLayoutPtr ptr);
diff --git a/hw/xfree86/parser/read.c b/hw/xfree86/parser/read.c
index 59b0ea6..d93ad75 100644
--- a/hw/xfree86/parser/read.c
+++ b/hw/xfree86/parser/read.c
@@ -113,13 +113,6 @@ xf86readConfigFile (void)
 				val.str = NULL;
 				HANDLE_RETURN (conf_flags, xf86parseFlagsSection ());
 			}
-			else if (xf86nameCompare (val.str, "keyboard") == 0)
-			{
-				xf86conffree(val.str);
-				val.str = NULL;
-				HANDLE_LIST (conf_input_lst, xf86parseKeyboardSection,
-							 XF86ConfInputPtr);
-			}
 			else if (xf86nameCompare (val.str, "pointer") == 0)
 			{
 				xf86conffree(val.str);
diff --git a/hw/xfree86/utils/xorgcfg/interface.c b/hw/xfree86/utils/xorgcfg/interface.c
index b6ac82a..9c280e0 100644
--- a/hw/xfree86/utils/xorgcfg/interface.c
+++ b/hw/xfree86/utils/xorgcfg/interface.c
@@ -68,8 +68,7 @@
 #define DefaultXFree86Dir	"/usr"
 #endif
 
-#define IS_KBDDRIV(S) ((strcasecmp((S),"kbd") == 0) || \
-	(strcasecmp((S), "keyboard") == 0))
+#define IS_KBDDRIV(S) ((strcasecmp((S),"kbd") == 0)
 
 /*
  * Prototypes
diff --git a/hw/xfree86/utils/xorgcfg/keyboard-cfg.c b/hw/xfree86/utils/xorgcfg/keyboard-cfg.c
index 2e82323..dc45736 100644
--- a/hw/xfree86/utils/xorgcfg/keyboard-cfg.c
+++ b/hw/xfree86/utils/xorgcfg/keyboard-cfg.c
@@ -38,8 +38,7 @@
 #include <X11/Xaw/SimpleMenu.h>
 #include <X11/Xaw/SmeBSB.h>
 
-#define IS_KBDDRIV(X) ((strcasecmp((X),"kbd") == 0) || \
-	(strcasecmp((X), "keyboard") == 0))
+#define IS_KBDDRIV(X) ((strcasecmp((X),"kbd") == 0)
 
 /*
  * Types
@@ -255,11 +254,7 @@ KeyboardConfig(XtPointer config)
 	    keyboard = XtNew(XF86ConfInputRec);
 	    keyboard->list.next = NULL;
 	    keyboard->inp_identifier = XtNewString(ident_string);
-#if defined(USE_DEPRECATED_KEYBOARD_DRIVER)
-	    keyboard->inp_driver = XtNewString("keyboard");
-#else
 	    keyboard->inp_driver = XtNewString("kbd");
-#endif
 	    keyboard->inp_option_lst = xf86newOption(XtNewString(XkbRules),
 						     XtNewString(rules));
 	    xf86addNewOption(keyboard->inp_option_lst,
diff --git a/hw/xfree86/utils/xorgcfg/text-mode.c b/hw/xfree86/utils/xorgcfg/text-mode.c
index 8537252..0acc513 100644
--- a/hw/xfree86/utils/xorgcfg/text-mode.c
+++ b/hw/xfree86/utils/xorgcfg/text-mode.c
@@ -48,8 +48,7 @@
 #include "xf86config.h"
 #include "loader.h"
 
-#define IS_KBDDRIV(X) ((strcmp((X),"kbd") == 0) || \
-	(strcmp((X), "keyboard") == 0))
+#define IS_KBDDRIV(X) ((strcmp((X),"kbd") == 0)
 
 #ifndef PROJECT_ROOT
 #define PROJECT_ROOT "/usr"
@@ -746,11 +745,7 @@ KeyboardConfig(void)
 		input->inp_option_lst =
 		    xf86addNewOption(input->inp_option_lst,
 			XtNewString("XkbLayout"), XtNewString("us"));
-#if defined(USE_DEPRECATED_KEYBOARD_DRIVER)
-		input->inp_driver = XtNewString("keyboard");
-#else
 		input->inp_driver = XtNewString("kbd");
-#endif
 		XF86Config->conf_input_lst =
 		    xf86addInput(XF86Config, input);
 	    }
@@ -826,11 +821,7 @@ KeyboardConfig(void)
 		XtNewString("XkbLayout"), XtNewString(layout));
 
     if (input->inp_driver == NULL) {
-#if defined(USE_DEPRECATED_KEYBOARD_DRIVER)
-	input->inp_driver = XtNewString("keyboard");
-#else
 	input->inp_driver = XtNewString("kbd");
-#endif
 	XF86Config->conf_input_lst =
 	    xf86addInput(XF86Config->conf_input_lst, input);
     }
diff --git a/hw/xfree86/utils/xorgconfig/xorgconfig.c b/hw/xfree86/utils/xorgconfig/xorgconfig.c
index ab3c1d0..3bc05b8 100644
--- a/hw/xfree86/utils/xorgconfig/xorgconfig.c
+++ b/hw/xfree86/utils/xorgconfig/xorgconfig.c
@@ -2068,11 +2068,7 @@ static char *XF86Config_fontpathchunk_te
 "Section \"InputDevice\"\n"
 "\n"
 "    Identifier	\"Keyboard1\"\n"
-#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
-"    Driver	\"Keyboard\"\n"
-#else
 "    Driver	\"kbd\"\n"
-#endif
 "\n"
 "# For most OSs the protocol can be omitted (it defaults to \"Standard\").\n"
 "# When using XQUEUE (only for SVR3 and SVR4, but not Solaris),\n"
diff-tree 60ea7b51fe2b8a19a08b63db48504971a7a50ee6 (from d32dc8bf19e1071fc30af2f0bc6a6699b351f39e)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Fri Jul 21 15:23:37 2006 -0400

    xorg ddx: move to new input API, remove old keyboard driver
    Remove most of the rest of the old keyboard driver.
    Move to the new Get{Keyboard,Pointer}Events API, which is mostly
    complete at this stage: just missing the proximity events.

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index b932908..16591be 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -1136,7 +1136,6 @@ configInputKbd(IDevPtr inputp)
   xf86Info.kbdDelay      = 500;
   xf86Info.kbdRate       = 30;
   
-  xf86Info.kbdProc       = NULL;
   xf86Info.vtinit        = NULL;
   xf86Info.vtSysreq      = VT_SYSREQ_DEFAULT;
 #if defined(SVR4) && defined(i386)
@@ -1172,8 +1171,6 @@ configInputKbd(IDevPtr inputp)
 
   s = xf86SetStrOption(inputp->commonOptions, "Protocol", kbdproto);
   if (xf86NameCmp(s, "standard") == 0) {
-     xf86Info.kbdProc    = xf86KbdProc;
-     xf86Info.kbdEvents  = xf86KbdEvents;
      xfree(s);
   } else if (xf86NameCmp(s, "xqueue") == 0) {
 #ifdef __UNIXWARE__
@@ -1181,20 +1178,14 @@ configInputKbd(IDevPtr inputp)
      * To retain compatibility with older config files, on UnixWare, we
      * accept the xqueue protocol but use the normal keyboard procs.
      */
-     xf86Info.kbdProc    = xf86KbdProc;
-     xf86Info.kbdEvents  = xf86KbdEvents;
 #else
 #ifdef XQUEUE
-    xf86Info.kbdProc = xf86XqueKbdProc;
-    xf86Info.kbdEvents = xf86XqueEvents;
     xf86Msg(X_CONFIG, "Xqueue selected for keyboard input\n");
 #endif
 #endif
     xfree(s);
 #ifdef WSCONS_SUPPORT
   } else if (xf86NameCmp(s, "wskbd") == 0) {
-     xf86Info.kbdProc    = xf86KbdProc;
-     xf86Info.kbdEvents  = xf86WSKbdEvents;
      xfree(s);
      s = xf86SetStrOption(inputp->commonOptions, "Device", NULL);
      xf86Msg(X_CONFIG, "Keyboard: Protocol: wskbd\n");
diff --git a/hw/xfree86/common/xf86Cursor.c b/hw/xfree86/common/xf86Cursor.c
index 787c39d..61ce57d 100644
--- a/hw/xfree86/common/xf86Cursor.c
+++ b/hw/xfree86/common/xf86Cursor.c
@@ -78,14 +78,9 @@ static miPointerScreenFuncRec xf86Pointe
   xf86CursorOffScreen,
   xf86CrossScreen,
   xf86WarpCursor,
-#ifdef XINPUT
-  xf86eqEnqueue,
-  xf86eqSwitchScreen
-#else
   /* let miPointerInitialize take care of these */
   NULL,
   NULL
-#endif
 };
 
 static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 53186ea..807a94c 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -923,7 +923,7 @@ DGAStealKeyEvent(int index, xEvent *e)
     de.u.u.type = e->u.u.type + *XDGAEventBase;
     de.u.u.detail = e->u.u.detail;
     de.u.event.time = e->u.keyButtonPointer.time;
-    xf86eqEnqueue ((xEvent *) &de);
+    mieqEnqueue ((xEvent *) &de);
    return TRUE;
 }
 
@@ -960,7 +960,7 @@ DGAStealMouseEvent(int index, xEvent *e,
     de.u.event.dy = dy;
     de.u.event.pad1 = DGAMouseX;
     de.u.event.pad2 = DGAMouseY;
-    xf86eqEnqueue ((xEvent *) &de);
+    mieqEnqueue ((xEvent *) &de);
     return TRUE;
 }
 
diff --git a/hw/xfree86/common/xf86Debug.c b/hw/xfree86/common/xf86Debug.c
index 5579cde..e624e71 100644
--- a/hw/xfree86/common/xf86Debug.c
+++ b/hw/xfree86/common/xf86Debug.c
@@ -164,6 +164,7 @@ void xf86PokeMmio32(pointer Base, unsign
 }
 
 
+#if 0
 _X_EXPORT void
 xf86STimestamp(xf86TsPtr* timestamp)
 {
@@ -195,3 +196,4 @@ xf86SPTimestamp(xf86TsPtr* timestamp, ch
 	gettimeofday((struct timeval*)*timestamp,NULL);
     }
 }
+#endif
diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 831c68a..cc2ce9b 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -104,11 +104,7 @@ extern Bool noXkbExtension;
 #define XE_POINTER  1
 #define XE_KEYBOARD 2
 
-#ifdef XINPUT
-#define __EqEnqueue(ev) xf86eqEnqueue(ev)
-#else
 #define __EqEnqueue(ev) mieqEnqueue(ev)
-#endif
 
 #define EqEnqueue(ev) { \
     int __sigstate = xf86BlockSIGIO (); \
@@ -253,11 +249,7 @@ ProcessInputEvents ()
 
   xf86Info.inputPending = FALSE;
 
-#ifdef XINPUT
-  xf86eqProcessInputEvents();
-#else
   mieqProcessInputEvents();
-#endif
   miPointerUpdate();
 
   miPointerPosition(&x, &y);
@@ -403,679 +395,6 @@ xf86ProcessActionEvent(ActionEvent actio
     }
 }
 
-/*
- * xf86PostKbdEvent --
- *	Translate the raw hardware KbdEvent into an XEvent, and tell DIX
- *	about it. Scancode preprocessing and so on is done ...
- *
- *  OS/2 specific xf86PostKbdEvent(key) has been moved to os-support/os2/os2_kbd.c
- *  as some things differ, and I did not want to scatter this routine with
- *  ifdefs further (hv).
- */
-
-#ifdef __linux__
-extern u_char SpecialServerMap[];
-#endif
-
-#if !defined(__UNIXOS2__)
-void
-xf86PostKbdEvent(unsigned key)
-{
-  int         scanCode = (key & 0x7f);
-  int         specialkey = 0;
-  Bool        down = (key & 0x80 ? FALSE : TRUE);
-  KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key;
-  Bool        updateLeds = FALSE;
-  Bool        UsePrefix = FALSE;
-  Bool        Direction = FALSE;
-  xEvent      kevent;
-  KeySym      *keysym;
-  int         keycode;
-  static int  lockkeys = 0;
-#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
-  static Bool first_time = TRUE;
-#endif
-#if defined(__sparc__) && defined(__linux__)
-  static int  kbdSun = -1;
-#endif
-  /* Disable any keyboard processing while in suspend */
-  if (xf86inSuspend)
-      return;
-
-#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
-  if (first_time)
-  {
-    first_time = FALSE;
-    VTSwitchEnabled = (xf86Info.consType == SYSCONS)
-	    || (xf86Info.consType == PCVT);
-  }
-#endif
-
-#if defined (__sparc__) && defined(__linux__)
-  if (kbdSun == -1) {
-    if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun"))
-	|| (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun")))
-      kbdSun = 1;
-    else
-      kbdSun = 0;
-  }
-  if (kbdSun)
-    goto special;
-#endif /* __sparc__ && __linux__ */
-
-#ifdef __linux__
-  if (xf86Info.kbdCustomKeycodes) {
-    specialkey = SpecialServerMap[scanCode];
-    goto customkeycodes;
-  }
-#endif
-
-  /*
-   * First do some special scancode remapping ...
-   */
-  if (xf86Info.scanPrefix == 0) {
-
-    switch (scanCode) {
-    case KEY_Prefix0:
-    case KEY_Prefix1:
-#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
-      if (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS
-	  || xf86Info.consType == PCVT
-#ifdef WSCONS_SUPPORT
-	  || (xf86Info.consType == WSCONS && xf86Info.kbdEvents != xf86WSKbdEvents)
-#endif
-      ) {
-#endif
-        xf86Info.scanPrefix = scanCode;  /* special prefixes */
-        return;
-#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)
-      }
-      break;
-#endif
-    }
-#if defined (i386) && defined (SVR4)
-    /* 
-     * PANIX returns DICOP standards based keycodes in using 106jp 
-     * keyboard. We need to remap some keys. 
-     */
-    if(xf86Info.panix106 == TRUE){
-      switch (scanCode) {
-      case 0x56:        scanCode = KEY_BSlash2;	break;  /* Backslash */
-      case 0x5A:        scanCode = KEY_NFER;	break;  /* No Kanji Transfer*/
-      case 0x5B:        scanCode = KEY_XFER;	break;  /* Kanji Tranfer */
-      case 0x5C:        scanCode = KEY_Yen;	break;  /* Yen curs pgup */
-      case 0x6B:        scanCode = KEY_Left;	break;  /* Cur Left */
-      case 0x6F:        scanCode = KEY_PgUp;	break;  /* Cur PageUp */
-      case 0x72:        scanCode = KEY_AltLang;	break;  /* AltLang(right) */
-      case 0x73:        scanCode = KEY_RCtrl;	break;  /* not needed */
-      }
-    } else
-#endif /* i386 && SVR4 */
-    {
-      switch (scanCode) {
-      case 0x59:        scanCode = KEY_0x59; break;
-      case 0x5a:        scanCode = KEY_0x5A; break;
-      case 0x5b:        scanCode = KEY_0x5B; break;
-      case 0x5c:        scanCode = KEY_KP_Equal; break; /* Keypad Equal */
-      case 0x5d:        scanCode = KEY_0x5D; break;
-      case 0x5e:        scanCode = KEY_0x5E; break;
-      case 0x5f:        scanCode = KEY_0x5F; break;
-      case 0x62:        scanCode = KEY_0x62; break;
-      case 0x63:        scanCode = KEY_0x63; break;
-      case 0x64:        scanCode = KEY_0x64; break;
-      case 0x65:        scanCode = KEY_0x65; break;
-      case 0x66:        scanCode = KEY_0x66; break;
-      case 0x67:        scanCode = KEY_0x67; break;
-      case 0x68:        scanCode = KEY_0x68; break;
-      case 0x69:        scanCode = KEY_0x69; break;
-      case 0x6a:        scanCode = KEY_0x6A; break;
-      case 0x6b:        scanCode = KEY_0x6B; break;
-      case 0x6c:        scanCode = KEY_0x6C; break;
-      case 0x6d:        scanCode = KEY_0x6D; break;
-      case 0x6e:        scanCode = KEY_0x6E; break;
-      case 0x6f:        scanCode = KEY_0x6F; break;
-      case 0x70:        scanCode = KEY_0x70; break;
-      case 0x71:        scanCode = KEY_0x71; break;
-      case 0x72:        scanCode = KEY_0x72; break;
-      case 0x73:        scanCode = KEY_0x73; break;
-      case 0x74:        scanCode = KEY_0x74; break;
-      case 0x75:        scanCode = KEY_0x75; break;
-      case 0x76:        scanCode = KEY_0x76; break;
-      }
-    }
-  }
-
-  else if (
-#ifdef CSRG_BASED
-           (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS
-	    || xf86Info.consType == PCVT
-#ifdef WSCONS_SUPPORT
-	      || (xf86Info.consType == WSCONS && xf86Info.kbdEvents !=
-	      xf86WSKbdEvents)
-#endif
-	      ) &&
-#endif
-           (xf86Info.scanPrefix == KEY_Prefix0)) {
-    xf86Info.scanPrefix = 0;
-	  
-    switch (scanCode) {
-    case KEY_KP_7:        scanCode = KEY_Home;      break;  /* curs home */
-    case KEY_KP_8:        scanCode = KEY_Up;        break;  /* curs up */
-    case KEY_KP_9:        scanCode = KEY_PgUp;      break;  /* curs pgup */
-    case KEY_KP_4:        scanCode = KEY_Left;      break;  /* curs left */
-    case KEY_KP_5:        scanCode = KEY_Begin;     break;  /* curs begin */
-    case KEY_KP_6:        scanCode = KEY_Right;     break;  /* curs right */
-    case KEY_KP_1:        scanCode = KEY_End;       break;  /* curs end */
-    case KEY_KP_2:        scanCode = KEY_Down;      break;  /* curs down */
-    case KEY_KP_3:        scanCode = KEY_PgDown;    break;  /* curs pgdown */
-    case KEY_KP_0:        scanCode = KEY_Insert;    break;  /* curs insert */
-    case KEY_KP_Decimal:  scanCode = KEY_Delete;    break;  /* curs delete */
-    case KEY_Enter:       scanCode = KEY_KP_Enter;  break;  /* keypad enter */
-    case KEY_LCtrl:       scanCode = KEY_RCtrl;     break;  /* right ctrl */
-    case KEY_KP_Multiply: scanCode = KEY_Print;     break;  /* print */
-    case KEY_Slash:       scanCode = KEY_KP_Divide; break;  /* keyp divide */
-    case KEY_Alt:         scanCode = KEY_AltLang;   break;  /* right alt */
-    case KEY_ScrollLock:  scanCode = KEY_Break;     break;  /* curs break */
-    case 0x5b:            scanCode = KEY_LMeta;     break;
-    case 0x5c:            scanCode = KEY_RMeta;     break;
-    case 0x5d:            scanCode = KEY_Menu;      break;
-    case KEY_F3:          scanCode = KEY_F13;       break;
-    case KEY_F4:          scanCode = KEY_F14;       break;
-    case KEY_F5:          scanCode = KEY_F15;       break;
-    case KEY_F6:          scanCode = KEY_F16;       break;
-    case KEY_F7:          scanCode = KEY_F17;       break;
-    case KEY_KP_Plus:     scanCode = KEY_KP_DEC;    break;
-      /*
-       * Ignore virtual shifts (E0 2A, E0 AA, E0 36, E0 B6)
-       */
-    case 0x2A:
-    case 0x36:
-	return;
-    default:
-      xf86MsgVerb(X_INFO, 4, "Unreported Prefix0 scancode: 0x%02x\n",
-		  scanCode);
-      /*
-       * "Internet" keyboards are generating lots of new codes.  Let them
-       * pass.  There is little consistency between them, so don't bother
-       * with symbolic names at this level.
-       */
-      scanCode += 0x78;
-    }
-  }
-  
-  else if (xf86Info.scanPrefix == KEY_Prefix1)
-    {
-      xf86Info.scanPrefix = (scanCode == KEY_LCtrl) ? KEY_LCtrl : 0;
-      return;
-    }
-  
-  else if (xf86Info.scanPrefix == KEY_LCtrl)
-    {
-      xf86Info.scanPrefix = 0;
-      if (scanCode != KEY_NumLock) return;
-      scanCode = KEY_Pause;       /* pause */
-    }
-
-#ifndef __sparc64__
-  /*
-   * PC keyboards generate separate key codes for
-   * Alt+Print and Control+Pause but in the X keyboard model
-   * they need to get the same key code as the base key on the same
-   * physical keyboard key.
-   */
-  if (scanCode == KEY_SysReqest)
-    scanCode = KEY_Print;
-  else if (scanCode == KEY_Break)
-    scanCode = KEY_Pause;
-#endif
-  
-  /*
-   * and now get some special keysequences
-   */
-
-  specialkey = scanCode;
-
-#ifdef __linux__
-customkeycodes:
-#endif
-#if defined(i386) || defined(__i386__)
-  if (xf86IsPc98()) {
-    switch (scanCode) {
-      case 0x0e: specialkey = 0x0e; break; /* KEY_BackSpace */
-      case 0x40: specialkey = 0x4a; break; /* KEY_KP_Minus  */
-      case 0x49: specialkey = 0x4e; break; /* KEY_KP_Plus   */
-
-      /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */
-
-      case 0x62: specialkey = 0x3b; break; /* KEY_F1        */
-      case 0x63: specialkey = 0x3c; break; /* KEY_F2        */
-      case 0x64: specialkey = 0x3d; break; /* KEY_F3        */
-      case 0x65: specialkey = 0x3e; break; /* KEY_F4        */
-      case 0x66: specialkey = 0x3f; break; /* KEY_F5        */
-      case 0x67: specialkey = 0x40; break; /* KEY_F6        */
-      case 0x68: specialkey = 0x41; break; /* KEY_F7        */
-      case 0x69: specialkey = 0x42; break; /* KEY_F8        */
-      case 0x6a: specialkey = 0x43; break; /* KEY_F9        */
-      case 0x6b: specialkey = 0x44; break; /* KEY_F10       */
-      /* case 0x73: specialkey = 0x38; break; KEY_Alt       */
-      /* case 0x74: specialkey = 0x1d; break; KEY_LCtrl     */
-      default:   specialkey = 0x00; break;
-    }
-  }
-#endif
-#if defined (__sparc__) && defined(__linux__)
-special:
-  if (kbdSun) {
-    switch (scanCode) {
-      case 0x2b: specialkey = KEY_BackSpace; break;
-      case 0x47: specialkey = KEY_KP_Minus; break;
-      case 0x7d: specialkey = KEY_KP_Plus; break;
-
-      /* XXX needs cases for KEY_KP_Divide and KEY_KP_Multiply */
-
-      case 0x05: specialkey = KEY_F1; break;
-      case 0x06: specialkey = KEY_F2; break;
-      case 0x08: specialkey = KEY_F3; break;
-      case 0x0a: specialkey = KEY_F4; break;
-      case 0x0c: specialkey = KEY_F5; break;
-      case 0x0e: specialkey = KEY_F6; break;
-      case 0x10: specialkey = KEY_F7; break;
-      case 0x11: specialkey = KEY_F8; break;
-      case 0x12: specialkey = KEY_F9; break;
-      case 0x07: specialkey = KEY_F10; break;
-      case 0x09: specialkey = KEY_F11; break;
-      case 0x0b: specialkey = KEY_F12; break;
-      default: specialkey = 0; break;
-    }
-    /*
-     * XXX XXX XXX:
-     *
-     * I really don't know what's wrong here, but passing the real
-     * scanCode offsets by one from XKB's point of view.
-     *
-     * (ecd at skynet.be, 980405)
-     */
-    scanCode--;
-  }
-#endif /* defined (__sparc__) && defined(__linux__) */
-
-#ifdef XKB
-  if ((xf86Info.ddxSpecialKeys == SKWhenNeeded &&
-       !xf86Info.ActionKeyBindingsSet) ||
-      noXkbExtension || xf86Info.ddxSpecialKeys == SKAlways) {
-#endif
-  if (!(ModifierDown(ShiftMask)) &&
-      ((ModifierDown(ControlMask | AltMask)) ||
-       (ModifierDown(ControlMask | AltLangMask))))
-    {
-      switch (specialkey) {
-	
-      case KEY_BackSpace:
-	xf86ProcessActionEvent(ACTION_TERMINATE, NULL);
-	break;
-
-      /*
-       * Check grabs
-       */
-      case KEY_KP_Divide:
-	xf86ProcessActionEvent(ACTION_DISABLEGRAB, NULL);
-	break;
-      case KEY_KP_Multiply:
-	xf86ProcessActionEvent(ACTION_CLOSECLIENT, NULL);
-	break;
-
-      /*
-       * Video mode switches
-       */
-      case KEY_KP_Minus:   /* Keypad - */
-	if (down) xf86ProcessActionEvent(ACTION_PREV_MODE, NULL);
-	if (!xf86Info.dontZoom) return;
-	break;
-	
-      case KEY_KP_Plus:   /* Keypad + */
-	if (down) xf86ProcessActionEvent(ACTION_NEXT_MODE, NULL);
-	if (!xf86Info.dontZoom) return;
-	break;
-
-	/* Under QNX4, we set the vtPending flag for VT switching and 
-	 * let the VT switch function do the rest...
-	 * This is a little different from the other OS'es.
-	 */
-#if defined(QNX4)
-      case KEY_1:
-      case KEY_2:
-      case KEY_3:
-      case KEY_4:
-      case KEY_5:
-      case KEY_6:
-      case KEY_7:
-      case KEY_8:
-      case KEY_9:
-	if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
-	  if (down) {
-	    int vtno = specialkey - KEY_1 + 1;
-	    xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno);
-	  }
-	  return;
-	}
-	break;
-#endif
-
-#if defined(linux) || (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT))) || defined(__SCO__) || defined(__UNIXWARE__)
-	/*
-	 * Under Linux, the raw keycodes are consumed before the kernel
-	 * does any processing on them, so we must emulate the vt switching
-	 * we want ourselves.
-	 */
-      case KEY_F1:
-      case KEY_F2:
-      case KEY_F3:
-      case KEY_F4:
-      case KEY_F5:
-      case KEY_F6:
-      case KEY_F7:
-      case KEY_F8:
-      case KEY_F9:
-      case KEY_F10:
-      case KEY_F11:
-      case KEY_F12:
-	if ((VTSwitchEnabled && !xf86Info.vtSysreq && !xf86Info.dontVTSwitch)
-#if (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT) || defined(WSCONS_SUPPORT)))
-	    && (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
-#endif
-	   ) {
-	    int vtno = specialkey - KEY_F1 + 1;
-	    if (specialkey == KEY_F11 || specialkey == KEY_F12)
-		vtno = specialkey - KEY_F11 + 11;
-	    if (down)
-		xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno);
-	    return;
-	}
-	break;
-#endif /* linux || BSD with VTs */
-
-      /* just worth mentioning here: any 386bsd keyboard driver
-       * (pccons.c or co_kbd.c) catches CTRL-ALT-DEL and CTRL-ALT-ESC
-       * before any application (e.g. XF86) will see it
-       * OBS: syscons does not, nor does pcvt !
-       */
-      } 
-    }
-
-    /*
-     * Start of actual Solaris VT switching code.  
-     * This should pretty much emulate standard SVR4 switching keys.
-     * 
-     * DWH 12/2/93
-     */
-
-#ifdef USE_VT_SYSREQ
-    if (VTSwitchEnabled && xf86Info.vtSysreq && !xf86Info.dontVTSwitch)
-    {
-      switch (specialkey)
-      {
-      /*
-       * syscons on *BSD doesn't have a VT #0  -- don't think Linux does
-       * either
-       */
-#if defined (sun) && defined (i386) && defined (SVR4)
-      case KEY_H: 
-	if (VTSysreqToggle && down)
-        {
-	  xf86ProcessActionEvent(ACTION_SWITCHSCREEN, NULL);
-          VTSysreqToggle = 0;
-          return; 
-        }
-	break;
-
-      /*
-       * Yah, I know the N, and P keys seem backwards, however that's
-       * how they work under Solaris
-       * XXXX N means go to next active VT not necessarily vtno+1 (or vtno-1)
-       */
-
-      case KEY_N:
-	if (VTSysreqToggle && down)
-	{
-	  xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL);
-          VTSysreqToggle = FALSE;
-          return;
-        }
-	break;
-
-      case KEY_P:
-	if (VTSysreqToggle && down)
-	{
-	  xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL);
-          VTSysreqToggle = FALSE;
-          return;
-        }
-	break;
-#endif
-
-      case KEY_F1:
-      case KEY_F2:
-      case KEY_F3:
-      case KEY_F4:
-      case KEY_F5:
-      case KEY_F6:
-      case KEY_F7:
-      case KEY_F8:
-      case KEY_F9:
-      case KEY_F10:
-      case KEY_F11:
-      case KEY_F12:
-	if (VTSysreqToggle && down)
-	{ int vtno = specialkey - KEY_F1 + 1;
-	  if (specialkey == KEY_F11 || specialkey == KEY_F12)
-	    vtno = specialkey - KEY_F11 + 11;
-	  xf86ProcessActionEvent(ACTION_SWITCHSCREEN, (void *) &vtno);
-          VTSysreqToggle = FALSE;
-          return;
-        }
-	break;
-
-      /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
-      case KEY_Alt:
-      case KEY_AltLang:
-	break;
-
-      case KEY_SysReqest:
-        if (down && (ModifierDown(AltMask) || ModifierDown(AltLangMask)))
-          VTSysreqToggle = TRUE;
-	break;
-
-      default:
-        if (VTSysreqToggle)
-	{
-	  /*
-	   * We only land here when Alt-SysReq is followed by a
-	   * non-switching key.
-	   */
-          VTSysreqToggle = FALSE;
-
-        }
-      }
-    }
-
-#endif /* USE_VT_SYSREQ */
-
-#ifdef __SCO__
-    /*
-     *	With the console in raw mode, SCO will not switch consoles,
-     *	you get around this by activating the next console along, if
-     *	this fails then go back to console 0, if there is only one
-     *	then it doesn't matter, switching to yourself is a nop as far
-     *	as the console driver is concerned.
-     *	We could do something similar to linux here but SCO ODT uses
-     *	Ctrl-PrintScrn, so why change?
-     */
-    if (specialkey == KEY_Print && ModifierDown(ControlMask)) {
-      if (down)
-	xf86ProcessActionEvent(ACTION_SWITCHSCREEN_NEXT, NULL);
-      return;
-    }
-#endif /* __SCO__ */
-#ifdef XKB
-    }
-#endif
-
-  /*
-   * Now map the scancodes to real X-keycodes ...
-   */
-  keycode = scanCode + MIN_KEYCODE;
-  keysym = (keyc->curKeySyms.map +
-	    keyc->curKeySyms.mapWidth * 
-	    (keycode - keyc->curKeySyms.minKeyCode));
-#ifdef XKB
-  if (noXkbExtension) {
-#endif
-  /*
-   * Filter autorepeated caps/num/scroll lock keycodes.
-   */
-#define CAPSFLAG 0x01
-#define NUMFLAG 0x02
-#define SCROLLFLAG 0x04
-#define MODEFLAG 0x08
-  if( down ) {
-    switch( keysym[0] ) {
-        case XK_Caps_Lock :
-          if (lockkeys & CAPSFLAG)
-              return;
-	  else
-	      lockkeys |= CAPSFLAG;
-          break;
-
-        case XK_Num_Lock :
-          if (lockkeys & NUMFLAG)
-              return;
-	  else
-	      lockkeys |= NUMFLAG;
-          break;
-
-        case XK_Scroll_Lock :
-          if (lockkeys & SCROLLFLAG)
-              return;
-	  else
-	      lockkeys |= SCROLLFLAG;
-          break;
-    }
-    if (keysym[1] == XF86XK_ModeLock)
-    {
-      if (lockkeys & MODEFLAG)
-          return;
-      else
-          lockkeys |= MODEFLAG;
-    }
-      
-  }
-  else {
-    switch( keysym[0] ) {
-        case XK_Caps_Lock :
-            lockkeys &= ~CAPSFLAG;
-            break;
-
-        case XK_Num_Lock :
-            lockkeys &= ~NUMFLAG;
-            break;
-
-        case XK_Scroll_Lock :
-            lockkeys &= ~SCROLLFLAG;
-            break;
-    }
-    if (keysym[1] == XF86XK_ModeLock)
-      lockkeys &= ~MODEFLAG;
-  }
-
-  /*
-   * LockKey special handling:
-   * ignore releases, toggle on & off on presses.
-   * Don't deal with the Caps_Lock keysym directly, but check the lock modifier
-   */
-  if (keyc->modifierMap[keycode] & LockMask ||
-      keysym[0] == XK_Scroll_Lock ||
-      keysym[1] == XF86XK_ModeLock ||
-      keysym[0] == XK_Num_Lock)
-    {
-      Bool flag;
-
-      if (!down) return;
-      if (KeyPressed(keycode)) {
-	down = !down;
-	flag = FALSE;
-      }
-      else
-	flag = TRUE;
-
-      if (keyc->modifierMap[keycode] & LockMask)   xf86Info.capsLock   = flag;
-      if (keysym[0] == XK_Num_Lock)    xf86Info.numLock    = flag;
-      if (keysym[0] == XK_Scroll_Lock) xf86Info.scrollLock = flag;
-      if (keysym[1] == XF86XK_ModeLock)   xf86Info.modeSwitchLock = flag;
-      updateLeds = TRUE;
-    }
-
-  if (!xf86Info.kbdCustomKeycodes) {
-    /*
-     * normal, non-keypad keys
-     */
-    if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) {
-#if !defined(CSRG_BASED) && \
-    !defined(__GNU__) && \
-     defined(KB_84)
-      /*
-       * magic ALT_L key on AT84 keyboards for multilingual support
-       */
-      if (xf86Info.kbdType == KB_84 &&
-	  ModifierDown(AltMask) &&
-	  keysym[2] != NoSymbol)
-	{
-	  UsePrefix = TRUE;
-	  Direction = TRUE;
-	}
-#endif /* !CSRG_BASED && ... */
-    }
-  }
-  if (updateLeds) xf86UpdateKbdLeds();
-#ifdef XKB
-  }
-#endif
-
-  /*
-   * check for an autorepeat-event
-   */
-  if (down && KeyPressed(keycode)) {
-      KbdFeedbackClassRec *kbdfeed = ((DeviceIntPtr)xf86Info.pKeyboard)->kbdfeed;
-      if ((xf86Info.autoRepeat != AutoRepeatModeOn) ||
-          keyc->modifierMap[keycode] ||
-          (kbdfeed && !(kbdfeed->ctrl.autoRepeats[keycode>>3] & ( 1<<(keycode&7) ))))
-          return;
-  }
-
-
-  xf86Info.lastEventTime = kevent.u.keyButtonPointer.time = GetTimeInMillis();
-  /*
-   * And now send these prefixes ...
-   * NOTE: There cannot be multiple Mode_Switch keys !!!!
-   */
-  if (UsePrefix)
-    {
-      ENQUEUE(&kevent,
-	      keyc->modifierKeyMap[keyc->maxKeysPerModifier*7],
-	      (Direction ? KeyPress : KeyRelease),
-	      XE_KEYBOARD);
-      ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
-      ENQUEUE(&kevent,
-	      keyc->modifierKeyMap[keyc->maxKeysPerModifier*7],
-	      (Direction ? KeyRelease : KeyPress),
-	      XE_KEYBOARD);
-    }
-  else 
-    {
-      ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
-    }
-}
-#endif /* !__UNIXOS2__ */
-
 #define ModifierIsSet(k) ((modifiers & (k)) == (k))
 
 _X_EXPORT Bool
@@ -1137,8 +456,6 @@ xf86Wakeup(pointer blockData, int err, p
 
 	XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
 	if (XFD_ANYSET(&devicesWithInput)) {
-	    if (xf86Info.kbdEvents)
-	    	(xf86Info.kbdEvents)();
 	    pInfo = xf86InputDevs;
 	    while (pInfo) {
 		if (pInfo->read_input && pInfo->fd >= 0 &&
@@ -1161,8 +478,6 @@ xf86Wakeup(pointer blockData, int err, p
 
     InputInfoPtr pInfo;
 
-    (xf86Info.kbdEvents)();  /* Under OS/2 and QNX, always call */
-
     pInfo = xf86InputDevs;
     while (pInfo) {
 		if (pInfo->read_input && pInfo->fd >= 0) {
@@ -1470,6 +785,67 @@ xf86SigMemDebug(int signo)
 }
 #endif
 
+static void
+xf86ReleaseKeys(DeviceIntPtr pDev)
+{
+    KeyClassPtr keyc = NULL;
+    KeySym *map = NULL;
+    xEvent *events = NULL, ke;
+    int i = 0, j = 0, nevents = 0;
+
+    ErrorF("releasekeys: called on device %s (%d)\n", pDev->name, pDev->id);
+
+    if (!pDev || !pDev->key)
+        return;
+
+    keyc = pDev->key;
+    map = keyc->curKeySyms.map;
+
+    /*
+     * Hmm... here is the biggest hack of every time !
+     * It may be possible that a switch-vt procedure has finished BEFORE
+     * you released all keys neccessary to do this. That peculiar behavior
+     * can fool the X-server pretty much, cause it assumes that some keys
+     * were not released. TWM may stuck alsmost completly....
+     * OK, what we are doing here is after returning from the vt-switch
+     * exeplicitely unrelease all keyboard keys before the input-devices
+     * are reenabled.
+     */
+
+    for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
+         i < keyc->curKeySyms.maxKeyCode;
+         i++, map += keyc->curKeySyms.mapWidth) {
+        ErrorF("key %d: pressed is %s\n", i, KeyPressed(i) ? "true" : "false");
+        if (KeyPressed(i)) {
+            switch (*map) {
+            /* Don't release the lock keys */
+            case XK_Caps_Lock:
+            case XK_Shift_Lock:
+            case XK_Num_Lock:
+            case XK_Scroll_Lock:
+            case XK_Kana_Lock:
+                break;
+            default:
+                if (pDev == inputInfo.keyboard) {
+                    ke.u.keyButtonPointer.time = GetTimeInMillis();
+                    ke.u.keyButtonPointer.rootX = 0;
+                    ke.u.keyButtonPointer.rootY = 0;
+                    ke.u.u.type = KeyRelease;
+                    ke.u.u.detail = i;
+                    (*pDev->public.processInputProc) (&ke, pDev, 1);
+                }
+                else {
+                    nevents = GetKeyboardEvents(&events, pDev, KeyRelease, i);
+                    ErrorF("device %s: got %d events for %d key\n", pDev->name, nevents, i);
+                    for (j = 0; j < nevents; j++)
+                        mieqEnqueue(events++);
+                }
+                break;
+            }
+        }
+    }
+}
+
 /*
  * xf86VTSwitch --
  *      Handle requests for switching the vt.
@@ -1515,7 +891,6 @@ xf86VTSwitch()
      * Keep the order: Disable Device > LeaveVT
      *                        EnterVT > EnableDevice 
      */
-    DisableDevice((DeviceIntPtr)xf86Info.pKeyboard);
     pInfo = xf86InputDevs;
     while (pInfo) {
       DisableDevice(pInfo->dev);
@@ -1556,12 +931,14 @@ xf86VTSwitch()
       SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset);
 
 #if !defined(__UNIXOS2__)
-      EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
       pInfo = xf86InputDevs;
       while (pInfo) {
+        xf86ReleaseKeys(pInfo->dev);
 	EnableDevice(pInfo->dev);
 	pInfo = pInfo->next;
       }
+      /* XXX HACK */
+      xf86ReleaseKeys(inputInfo.keyboard);
 #endif /* !__UNIXOS2__ */
       for (ih = InputHandlers; ih; ih = ih->next)
         xf86EnableInputHandler(ih);
@@ -1618,12 +995,14 @@ xf86VTSwitch()
     SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
 
 #if !defined(__UNIXOS2__)
-    EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
     pInfo = xf86InputDevs;
     while (pInfo) {
+      xf86ReleaseKeys(pInfo->dev);
       EnableDevice(pInfo->dev);
       pInfo = pInfo->next;
     }
+    /* XXX HACK */
+    xf86ReleaseKeys(inputInfo.keyboard);
 #endif /* !__UNIXOS2__ */
     
     for (ih = InputHandlers; ih; ih = ih->next)
@@ -1745,9 +1124,6 @@ xf86ReloadInputDevs(int sig)
   
   signal(sig, (void(*)(int))xf86ReloadInputDevs);
 
-  DisableDevice((DeviceIntPtr)xf86Info.pKeyboard);
-  EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
-
   pInfo = xf86InputDevs;
   while (pInfo) {
     DisableDevice(pInfo->dev);
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index 1e0ac79..ab73c6c 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -94,9 +94,6 @@ InputInfoPtr xf86InputDevs = NULL;
 /* Globals that video drivers may not access */
 
 xf86InfoRec xf86Info = {
-	NULL,		/* pKeyboard */
-	NULL,		/* kbdProc */
-	NULL,		/* kbdEvents */
 	-1,		/* consoleFd */
 	-1,		/* kbdFd */
 	-1,		/* vtno */
diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index 05ac570..6c2cefb 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -155,6 +155,19 @@ xf86LookupInputDriver(const char *name)
     return NULL;
 }
 
+InputInfoPtr
+xf86LookupInput(const char *name)
+{
+    InputInfoPtr p;
+
+    for (p = xf86InputDevs; p != NULL; p = p->next) {
+        if (strcmp(name, p->name) == 0)
+            return p;
+    }
+
+    return NULL;
+}
+
 _X_EXPORT void
 xf86AddModuleInfo(ModuleInfoPtr info, pointer module)
 {
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 6defa94..e2622e3 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -1006,18 +1006,6 @@ InitInput(argc, argv)
     if (serverGeneration == 1) {
 	/* Call the PreInit function for each input device instance. */
 	for (pDev = xf86ConfigLayout.inputs; pDev && pDev->identifier; pDev++) {
-#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
-	    /* XXX The keyboard driver is a special case for now. */
-	    if (!xf86NameCmp(pDev->driver, "keyboard")) {
-		xf86MsgVerb(X_WARNING, 0, "*** WARNING the legacy keyboard driver \"keyboard\" is deprecated\n");
-		xf86MsgVerb(X_WARNING, 0, "*** and will be removed in the next release of the Xorg server.\n");
-		xf86MsgVerb(X_WARNING, 0, "*** Please consider using the the new \"kbd\" driver for \"%s\".\n",
-			pDev->identifier);
-
-		continue;
-	    }
-#endif
-
 	    if ((pDrv = xf86LookupInputDriver(pDev->driver)) == NULL) {
 		xf86Msg(X_ERROR, "No Input driver matching `%s'\n", pDev->driver);
 		/* XXX For now, just continue. */
@@ -1040,80 +1028,18 @@ InitInput(argc, argv)
 		xf86DeleteInput(pInfo, 0);
 		continue;
 	    }
-	    if (pInfo->flags & XI86_CORE_KEYBOARD) {
-		if (coreKeyboard) {
-		    xf86Msg(X_ERROR,
-		      "Attempt to register more than one core keyboard (%s)\n",
-		      pInfo->name);
-		    pInfo->flags &= ~XI86_CORE_KEYBOARD;
-		} else {
-		    if (!(pInfo->flags & XI86_KEYBOARD_CAPABLE)) {
-			/* XXX just a warning for now */
-			xf86Msg(X_WARNING,
-			    "%s: does not have core keyboard capabilities\n",
-			    pInfo->name);
-		    }
-		    coreKeyboard = pInfo;
-		}
-	    }
-	    if (pInfo->flags & XI86_CORE_POINTER) {
-		if (corePointer) {
-		    xf86Msg(X_ERROR,
-			"Attempt to register more than one core pointer (%s)\n",
-			pInfo->name);
-		    pInfo->flags &= ~XI86_CORE_POINTER;
-		} else {
-		    if (!(pInfo->flags & XI86_POINTER_CAPABLE)) {
-			/* XXX just a warning for now */
-			xf86Msg(X_WARNING,
-			    "%s: does not have core pointer capabilities\n",
-			    pInfo->name);
-		    }
-		    corePointer = pInfo;
-		}
-	    }
 	}
-	if (!corePointer) {
-	    xf86Msg(X_WARNING, "No core pointer registered\n");
-	    /* XXX register a dummy core pointer */
-	}
-#ifdef NEW_KBD
-	if (!coreKeyboard) {
-	    xf86Msg(X_WARNING, "No core keyboard registered\n");
-	    /* XXX register a dummy core keyboard */
-	}
-#endif
     }
 
     /* Initialise all input devices. */
     pInfo = xf86InputDevs;
     while (pInfo) {
+        xf86Msg(X_INFO, "evaluating device (%s)\n", pInfo->name);
 	xf86ActivateDevice(pInfo);
 	pInfo = pInfo->next;
     }
 
-    if (coreKeyboard) {
-      xf86Info.pKeyboard = coreKeyboard->dev;
-      xf86Info.kbdEvents = NULL; /* to prevent the internal keybord driver usage*/
-    }
-    else {
-#ifdef USE_DEPRECATED_KEYBOARD_DRIVER
-      /* Only set this if we're allowing the old driver. */
-	if (xf86Info.kbdProc != NULL) 
-	    xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE);
-#endif
-    }
-    if (corePointer)
-	xf86Info.pMouse = corePointer->dev;
-    if (xf86Info.pKeyboard)
-      RegisterKeyboardDevice(xf86Info.pKeyboard); 
-
-  miRegisterPointerDevice(screenInfo.screens[0], xf86Info.pMouse);
-#ifdef XINPUT
-  xf86eqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse);
-#else
-  mieqInit ((DevicePtr)xf86Info.pKeyboard, (DevicePtr)xf86Info.pMouse);
-#endif
+    mieqInit();
 }
 
 #ifndef SET_STDERR_NONBLOCKING
@@ -1233,12 +1159,6 @@ AbortDDX()
   int i;
 
   /*
-   * try to deinitialize all input devices
-   */
-  if (xf86Info.kbdProc && xf86Info.pKeyboard)
-    (xf86Info.kbdProc)(xf86Info.pKeyboard, DEVICE_CLOSE);
-
-  /*
    * try to restore the original video state
    */
 #ifdef HAS_USL_VTS
diff --git a/hw/xfree86/common/xf86Io.c b/hw/xfree86/common/xf86Io.c
index 318b245..d10ad43 100644
--- a/hw/xfree86/common/xf86Io.c
+++ b/hw/xfree86/common/xf86Io.c
@@ -160,313 +160,3 @@ xf86KbdLeds ()
   xf86SetKbdLeds(real_leds);
   (void)leds;
 }
-
-/*
- * xf86KbdCtrl --
- *      Alter some of the keyboard control parameters. All special protocol
- *      values are handled by dix (ProgChangeKeyboardControl)
- */
-
-void
-xf86KbdCtrl (pKeyboard, ctrl)
-     DevicePtr     pKeyboard;        /* Keyboard to alter */
-     KeybdCtrl     *ctrl;
-{
-  int leds;
-  xf86Info.bell_pitch    = ctrl->bell_pitch;
-  xf86Info.bell_duration = ctrl->bell_duration;
-  xf86Info.autoRepeat    = ctrl->autoRepeat;
-
-  xf86Info.composeLock   = (ctrl->leds & XCOMP) ? TRUE : FALSE;
-
-  leds = (ctrl->leds & ~(XCAPS | XNUM | XSCR));
-#ifdef XKB
-  if (noXkbExtension) {
-#endif
-      xf86Info.leds = (leds & xf86Info.xleds)|(xf86Info.leds & ~xf86Info.xleds);
-#ifdef XKB
-  } else {
-      xf86Info.leds = leds;
-  }
-#endif
-
-  xf86KbdLeds();
-}
-
-/*
- * xf86InitKBD --
- *      Reinitialize the keyboard. Only set Lockkeys according to ours leds.
- *      Depress all other keys.
- */
-
-void
-xf86InitKBD(init)
-Bool init;
-{
-  char            leds = 0, rad;
-  unsigned int    i;
-  xEvent          kevent;
-  DeviceIntPtr    pKeyboard = xf86Info.pKeyboard;
-  KeyClassRec     *keyc = xf86Info.pKeyboard->key;
-  KeySym          *map = keyc->curKeySyms.map;
-
-  kevent.u.keyButtonPointer.time = GetTimeInMillis();
-  kevent.u.keyButtonPointer.rootX = 0;
-  kevent.u.keyButtonPointer.rootY = 0;
-
-  /*
-   * Hmm... here is the biggest hack of every time !
-   * It may be possible that a switch-vt procedure has finished BEFORE
-   * you released all keys neccessary to do this. That peculiar behavior
-   * can fool the X-server pretty much, cause it assumes that some keys
-   * were not released. TWM may stuck alsmost completly....
-   * OK, what we are doing here is after returning from the vt-switch
-   * exeplicitely unrelease all keyboard keys before the input-devices
-   * are reenabled.
-   */
-  for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
-       i < keyc->curKeySyms.maxKeyCode;
-       i++, map += keyc->curKeySyms.mapWidth)
-    if (KeyPressed(i))
-      {
-        switch (*map) {
-	/* Don't release the lock keys */
-        case XK_Caps_Lock:
-        case XK_Shift_Lock:
-        case XK_Num_Lock:
-        case XK_Scroll_Lock:
-        case XK_Kana_Lock:
-	  break;
-        default:
-	  kevent.u.u.detail = i;
-	  kevent.u.u.type = KeyRelease;
-	  (* pKeyboard->public.processInputProc)(&kevent, pKeyboard, 1);
-        }
-      }
-  
-  xf86Info.scanPrefix      = 0;
-
-  if (init)
-    {
-      /*
-       * we must deal here with the fact, that on some cases the numlock or
-       * capslock key are enabled BEFORE the server is started up. So look
-       * here at the state on the according LEDS to determine whether a
-       * lock-key is already set.
-       */
-
-      xf86Info.capsLock        = FALSE;
-      xf86Info.numLock         = FALSE;
-      xf86Info.scrollLock      = FALSE;
-      xf86Info.modeSwitchLock  = FALSE;
-      xf86Info.composeLock     = FALSE;
-    
-#ifdef LED_CAP
-#ifdef INHERIT_LOCK_STATE
-      leds = xf86Info.leds;
-
-      for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
-           i < keyc->curKeySyms.maxKeyCode;
-           i++, map += keyc->curKeySyms.mapWidth)
-
-        switch(*map) {
-
-        case XK_Caps_Lock:
-        case XK_Shift_Lock:
-          if (leds & LED_CAP) 
-	    {
-	      xf86InitialCaps = i;
-	      xf86Info.capsLock = TRUE;
-	    }
-          break;
-
-        case XK_Num_Lock:
-          if (leds & LED_NUM)
-	    {
-	      xf86InitialNum = i;
-	      xf86Info.numLock = TRUE;
-	    }
-          break;
-
-        case XK_Scroll_Lock:
-        case XK_Kana_Lock:
-          if (leds & LED_SCR)
-	    {
-	      xf86InitialScroll = i;
-	      xf86Info.scrollLock = TRUE;
-	    }
-          break;
-        }
-#endif /* INHERIT_LOCK_STATE */
-      xf86SetKbdLeds(leds);
-#endif /* LED_CAP */
-      (void)leds;
-
-      if      (xf86Info.kbdDelay <= 375) rad = 0x00;
-      else if (xf86Info.kbdDelay <= 625) rad = 0x20;
-      else if (xf86Info.kbdDelay <= 875) rad = 0x40;
-      else                               rad = 0x60;
-    
-      if      (xf86Info.kbdRate <=  2)   rad |= 0x1F;
-      else if (xf86Info.kbdRate >= 30)   rad |= 0x00;
-      else                               rad |= ((58 / xf86Info.kbdRate) - 2);
-    
-      xf86SetKbdRepeat(rad);
-    }
-}
-
-/*
- * xf86KbdProc --
- *	Handle the initialization, etc. of a keyboard.
- */
-
-int
-xf86KbdProc (pKeyboard, what)
-     DeviceIntPtr pKeyboard;	/* Keyboard to manipulate */
-     int       what;	    	/* What to do to it */
-{
-  KeySymsRec           keySyms;
-  CARD8                modMap[MAP_LENGTH];
-  int                  kbdFd;
-
-  switch (what) {
-
-  case DEVICE_INIT:
-    /*
-     * First open and find the current state of the keyboard.
-     */
-
-    xf86KbdInit();
-
-    xf86KbdGetMapping(&keySyms, modMap);
-    
-
-#ifndef XKB
-    defaultKeyboardControl.leds = xf86GetKbdLeds();
-#else
-    defaultKeyboardControl.leds = 0;
-#endif
-
-    /*
-     * Perform final initialization of the system private keyboard
-     * structure and fill in various slots in the device record
-     * itself which couldn't be filled in before.
-     */
-
-    pKeyboard->public.on = FALSE;
-
-#ifdef XKB
-    if (noXkbExtension) {
-#endif
-    InitKeyboardDeviceStruct((DevicePtr)xf86Info.pKeyboard,
-			     &keySyms,
-			     modMap,
-			     xf86KbdBell,
-			     (KbdCtrlProcPtr)xf86KbdCtrl);
-#ifdef XKB
-    } else {
- 	XkbComponentNamesRec	names;
-	XkbDescPtr		desc;
-	Bool			foundTerminate = FALSE;
-	int			keyc;
-	if (xf86Info.xkbkeymap) {
-	    names.keymap = xf86Info.xkbkeymap;
-	    names.keycodes = NULL;
-	    names.types = NULL;
-	    names.compat = NULL;
-	    names.symbols = NULL;
-	    names.geometry = NULL;
-	} else {
-	    names.keymap = NULL;
-	    names.keycodes = xf86Info.xkbkeycodes;
-	    names.types = xf86Info.xkbtypes;
-	    names.compat = xf86Info.xkbcompat;
-	    names.symbols = xf86Info.xkbsymbols;
-	    names.geometry = xf86Info.xkbgeometry;
-	}
-	if ((xf86Info.xkbkeymap || xf86Info.xkbcomponents_specified)
-	   && (xf86Info.xkbmodel == NULL || xf86Info.xkblayout == NULL)) {
-		xf86Info.xkbrules = NULL;
-	}
-	XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel,
-			 xf86Info.xkblayout, xf86Info.xkbvariant,
-			 xf86Info.xkboptions);
-	
-	XkbInitKeyboardDeviceStruct(pKeyboard, 
-				    &names,
-				    &keySyms, 
-				    modMap, 
-				    xf86KbdBell,
-				    (KbdCtrlProcPtr)xf86KbdCtrl);
-
-	/* Search keymap for Terminate action */
-	desc  = pKeyboard->key->xkbInfo->desc;
-	for (keyc = desc->min_key_code; keyc <= desc->max_key_code; keyc++) {
-	    int i;
-	    for (i = 1; i <= XkbKeyNumActions(desc, keyc); i++) {
-		if (XkbKeyAction(desc, keyc, i)
-		  && XkbKeyAction(desc, keyc, i)->type == XkbSA_Terminate) {
-		    foundTerminate = TRUE;
-		    goto searchdone;
-		}
-	    }
-  	}
-searchdone:
-	xf86Info.ActionKeyBindingsSet = foundTerminate;
-	if (!foundTerminate)
-	    xf86Msg(X_INFO, "Server_Terminate keybinding not found\n");
-    }
-#endif
-    
-    xf86InitKBD(TRUE);
-    break;
-    
-  case DEVICE_ON:
-    /*
-     * Set the keyboard into "direct" mode and turn on
-     * event translation.
-     */
-
-    kbdFd = xf86KbdOn();
-    /*
-     * Discard any pending input after a VT switch to prevent the server
-     * passing on parts of the VT switch sequence.
-     */
-    sleep(1);
-#if defined(WSCONS_SUPPORT)
-    if (xf86Info.consType != WSCONS) {
-#endif
-	if (kbdFd != -1) {
-		char buf[16];
-		read(kbdFd, buf, 16);
-    	}
-#if defined(WSCONS_SUPPORT)
-    }
-#endif
-
-#if !defined(__UNIXOS2__) /* Under EMX, keyboard cannot be select()'ed */
-    if (kbdFd != -1)
-      AddEnabledDevice(kbdFd);
-#endif  /* __UNIXOS2__ */
-
-    pKeyboard->public.on = TRUE;
-    xf86InitKBD(FALSE);
-    break;
-    
-  case DEVICE_CLOSE:
-  case DEVICE_OFF:
-    /*
-     * Restore original keyboard directness and translation.
-     */
-
-    kbdFd = xf86KbdOff();
-
-    if (kbdFd != -1)
-      RemoveEnabledDevice(kbdFd);
-
-    pKeyboard->public.on = FALSE;
-    break;
-
-  }
-  return (Success);
-}
diff --git a/hw/xfree86/common/xf86MiscExt.c b/hw/xfree86/common/xf86MiscExt.c
index bdb02ce..3e741ba 100644
--- a/hw/xfree86/common/xf86MiscExt.c
+++ b/hw/xfree86/common/xf86MiscExt.c
@@ -366,7 +366,7 @@ MiscExtCreateStruct(MiscExtStructType ms
 	InputInfoPtr pInfo = xf86InputDevs;
 	
 	while (pInfo) {
-	    if (xf86IsCorePointer(pInfo->dev))
+	    if (pInfo->dev == inputInfo.pointer)
 		break;
 	    pInfo = pInfo->next;
 	}
diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h
index f97bbb3..b4e531c 100644
--- a/hw/xfree86/common/xf86Priv.h
+++ b/hw/xfree86/common/xf86Priv.h
@@ -200,9 +200,6 @@ void xf86KbdBell(int percent, DeviceIntP
 		 int unused);
 void xf86KbdLeds(void);
 void xf86UpdateKbdLeds(void);
-void xf86KbdCtrl(DevicePtr pKeyboard, KeybdCtrl *ctrl); 
-void xf86InitKBD(Bool init);  
-int xf86KbdProc(DeviceIntPtr pKeyboard, int what);
 
 /* xf86Kbd.c */ 
 
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index a35de20..c26e288 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -68,11 +68,6 @@ typedef enum {
  */
 
 typedef struct {
-
-    /* keyboard part */
-    DeviceIntPtr	pKeyboard;
-    DeviceProc		kbdProc;		/* procedure for initializing */
-    void		(* kbdEvents)(void);	/* proc for processing events */
     int			consoleFd;
     int			kbdFd;
     int			vtno;
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 329dcba..7c27e1f 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -39,7 +39,6 @@
  * 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)
@@ -65,6 +64,7 @@
 #include "xf86Xinput.h"
 #ifdef XINPUT
 #include "XIstubs.h"
+#include "xf86Optrec.h"
 #endif
 #include "mipointer.h"
 #include "xf86InPriv.h"
@@ -75,10 +75,6 @@
 #include "dpmsproc.h"
 #endif
 
-#ifdef XFreeXDGA
-#include "dgaproc.h"
-#endif
-
 #include "exevents.h"	/* AddInputDevice */
 #include "exglobals.h"
 
@@ -114,82 +110,17 @@ static int      debug_level = 0;
 #define DBG(lvl, f)
 #endif
 
-/******************************************************************************
- * macros
- *****************************************************************************/
-#define ENQUEUE(e) xf86eqEnqueue((e))
-
-/***********************************************************************
- *
- * xf86AlwaysCoreControl --
- *	
- *	Control proc for the integer feedback that controls the always
- * core feature.
- *
- ***********************************************************************
- */
-static void
-xf86AlwaysCoreControl(DeviceIntPtr	device,
-		      IntegerCtrl	*control)
-{
-}
-
-/***********************************************************************
- *
- * Core devices functions --
- *	
- *	Test if device is the core device by checking the
- * value of always core feedback and the inputInfo struct.
- *
- ***********************************************************************
- */
-_X_EXPORT int
-xf86IsCorePointer(DeviceIntPtr	device)
-{
-    return(device == inputInfo.pointer);
-}
-
-static int
-xf86ShareCorePointer(DeviceIntPtr	device)
-{
-    LocalDevicePtr	local = (LocalDevicePtr) device->public.devicePrivate;
-    
-    return((local->always_core_feedback &&
-	    local->always_core_feedback->ctrl.integer_displayed));
-}
-
 static Bool
 xf86SendDragEvents(DeviceIntPtr	device)
 {
     LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
     
     if (inputInfo.pointer->button->buttonsDown > 0)
-	return (local->flags & XI86_SEND_DRAG_EVENTS);
+        return (local->flags & XI86_SEND_DRAG_EVENTS);
     else
-	return (TRUE);
-}
-
-int
-xf86IsCoreKeyboard(DeviceIntPtr	device)
-{
-    LocalDevicePtr	local = (LocalDevicePtr) device->public.devicePrivate;
-    
-    return((local->flags & XI86_ALWAYS_CORE) ||
-	   (device == inputInfo.keyboard));
+        return (TRUE);
 }
 
-_X_EXPORT void
-xf86XInputSetSendCoreEvents(LocalDevicePtr local, Bool always)
-{
-    if (always) {
-	local->flags |= XI86_ALWAYS_CORE;
-    } else {
-	local->flags &= ~XI86_ALWAYS_CORE;
-    }
-}
-
-static int xf86CoreButtonState;
-
 /***********************************************************************
  *
  * xf86CheckButton --
@@ -201,23 +132,26 @@ static int xf86CoreButtonState;
  */
 Bool
 xf86CheckButton(int	button,
-		int	down)
+                int	down)
 {
     int	check;
     int bit = (1 << (button - 1));
 
+    /* XXX FIXME VERDAMMT */
+#if 0
     check = xf86CoreButtonState & bit;
     
     DBG(5, ErrorF("xf86CheckButton "
-		  "button=%d down=%d state=%d check=%d returns ",
-		   button, down, xf86CoreButtonState, check));
+                  "button=%d down=%d state=%d check=%d returns ",
+                   button, down, xf86CoreButtonState, check));
     if ((check && down) || (!check && !down)) {
-	DBG(5, ErrorF("FALSE\n"));
-	return FALSE;
+        DBG(5, ErrorF("FALSE\n"));
+        return FALSE;
     }
     xf86CoreButtonState ^= bit;
 
     DBG(5, ErrorF("TRUE\n"));
+#endif
     return TRUE;
 }
 
@@ -231,38 +165,35 @@ xf86CheckButton(int	button,
  */
 _X_EXPORT void
 xf86ProcessCommonOptions(LocalDevicePtr local,
-			 pointer	list)
+                         pointer	list)
 {
-    if (xf86SetBoolOption(list, "AlwaysCore", 0) ||
-	xf86SetBoolOption(list, "SendCoreEvents", 0)) {
-	local->flags |= XI86_ALWAYS_CORE;
-	xf86Msg(X_CONFIG, "%s: always reports core events\n", local->name);
-    }
-
-    if (xf86SetBoolOption(list, "CorePointer", 0)) {
-	local->flags |= XI86_CORE_POINTER;
-	xf86Msg(X_CONFIG, "%s: Core Pointer\n", local->name);
-    }
-
-    if (xf86SetBoolOption(list, "CoreKeyboard", 0)) {
-	local->flags |= XI86_CORE_KEYBOARD;
-	xf86Msg(X_CONFIG, "%s: Core Keyboard\n", local->name);
+    if (!xf86SetBoolOption(list, "AlwaysCore", 0) ||
+        xf86SetBoolOption(list, "SendCoreEvents", 0) ||
+        xf86SetBoolOption(list, "CorePointer", 0) ||
+        xf86SetBoolOption(list, "CoreKeyboard", 0)) {
+        local->flags |= XI86_ALWAYS_CORE;
+        xf86Msg(X_CONFIG, "%s: always reports core events\n", local->name);
     }
 
     if (xf86SetBoolOption(list, "SendDragEvents", 1)) {
-	local->flags |= XI86_SEND_DRAG_EVENTS;
+        local->flags |= XI86_SEND_DRAG_EVENTS;
     } else {
-	xf86Msg(X_CONFIG, "%s: doesn't report drag events\n", local->name);
+        xf86Msg(X_CONFIG, "%s: doesn't report drag events\n", local->name);
     }
     
     local->history_size = xf86SetIntOption(list, "HistorySize", 0);
 
     if (local->history_size > 0) {
-	xf86Msg(X_CONFIG, "%s: has a history of %d motions\n", local->name,
-		local->history_size);
+        xf86Msg(X_CONFIG, "%s: has a history of %d motions\n", local->name,
+                local->history_size);
     }
 }
 
+void
+xf86AlwaysCoreControl(DeviceIntPtr pDev, IntegerCtrl *control)
+{
+}
+
 /***********************************************************************
  *
  * xf86XinputFinalizeInit --
@@ -277,14 +208,11 @@ xf86XinputFinalizeInit(DeviceIntPtr	dev)
 {
     LocalDevicePtr        local = (LocalDevicePtr)dev->public.devicePrivate;
 
-    local->dxremaind = 0.0;
-    local->dyremaind = 0.0;
-    
     if (InitIntegerFeedbackClassDeviceStruct(dev, xf86AlwaysCoreControl) == FALSE) {
-	ErrorF("Unable to init integer feedback for always core feature\n");
+        ErrorF("Unable to init integer feedback for always core feature\n");
     } else {
-	local->always_core_feedback = dev->intfeed;
-	dev->intfeed->ctrl.integer_displayed = (local->flags & XI86_ALWAYS_CORE) ? 1 : 0;
+        local->always_core_feedback = dev->intfeed;
+        dev->intfeed->ctrl.integer_displayed = (local->flags & XI86_ALWAYS_CORE) ? 1 : 0;
     }
 }
 
@@ -302,42 +230,33 @@ xf86ActivateDevice(LocalDevicePtr local)
     DeviceIntPtr	dev;
 
     if (local->flags & XI86_CONFIGURED) {
-	int	open_on_init;
-	
-	open_on_init = local->flags &
-		(XI86_OPEN_ON_INIT |
-		 XI86_ALWAYS_CORE | XI86_CORE_POINTER | XI86_CORE_KEYBOARD);
-	
-	dev = AddInputDevice(local->device_control,
-			     open_on_init);
-	if (dev == NULL)
-	    FatalError("Too many input devices");
-	
-	local->atom = MakeAtom(local->type_name,
-			       strlen(local->type_name),
-			       TRUE);
-	AssignTypeAndName (dev, local->atom, local->name);
-	dev->public.devicePrivate = (pointer) local;
-	local->dev = dev;      
-	
-	xf86XinputFinalizeInit(dev);
-
-	/*
-	 * XXX Can a single device instance be both core keyboard and
-	 * core pointer?  If so, this should be changed.
-	 */
-	if (local->flags & XI86_CORE_POINTER)
-	    RegisterPointerDevice(dev);
-	else if (local->flags & XI86_CORE_KEYBOARD)
-	    RegisterKeyboardDevice(dev);
-#ifdef XINPUT
-	else
-	    RegisterOtherDevice(dev);
+        int	open_on_init;
+        
+        open_on_init = local->flags & (XI86_OPEN_ON_INIT | XI86_ALWAYS_CORE);
+        
+        dev = AddInputDevice(local->device_control,
+                             open_on_init);
+#ifdef DEBUG
+        ErrorF("activated device %d: %s\n", dev->id, local->name);
 #endif
-
-	if (serverGeneration == 1) 
-	    xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
-		    local->name, local->type_name);
+        if (dev == NULL)
+            FatalError("Too many input devices");
+        
+        local->atom = MakeAtom(local->type_name,
+                               strlen(local->type_name),
+                               TRUE);
+        AssignTypeAndName(dev, local->atom, local->name);
+        dev->public.devicePrivate = (pointer) local;
+        local->dev = dev;      
+        
+        xf86XinputFinalizeInit(dev);
+
+        dev->coreEvents = local->flags & XI86_ALWAYS_CORE;
+        RegisterOtherDevice(dev);
+
+        if (serverGeneration == 1) 
+            xf86Msg(X_INFO, "XINPUT: Adding extended input device \"%s\" (type: %s)\n",
+                    local->name, local->type_name);
     }
 }
 
@@ -368,20 +287,20 @@ xf86ActivateDevice(LocalDevicePtr local)
 
 void
 OpenInputDevice(DeviceIntPtr	dev,
-		ClientPtr	client,
-		int		*status)
+                ClientPtr	client,
+                int		*status)
 {
     if (!dev->inited) {
-	*status = BadDevice;
+        *status = BadDevice;
     } else {
-	if (!dev->public.on) {
-	    if (!EnableDevice(dev)) {
-		*status = BadDevice;
-	    } else {
-		/* to prevent ProcXOpenDevice to call EnableDevice again */
-		dev->startup = FALSE;
-	    }
-	}
+        if (!dev->public.on) {
+            if (EnableDevice(dev)) {
+                /* to prevent ProcXOpenDevice to call EnableDevice again */
+                dev->startup = FALSE;
+            } else {
+                *status = BadDevice;
+            }
+        }
     }
 }
 
@@ -515,7 +434,6 @@ ChangePointerDevice (
 void
 CloseInputDevice (DeviceIntPtr d, ClientPtr client)
 {
-  ErrorF("ProcXCloseDevice to close or not ?\n");
 }
 
 
@@ -593,7 +511,7 @@ SetDeviceMode (ClientPtr client, DeviceI
 
 int
 SetDeviceValuators (ClientPtr client, DeviceIntPtr dev, int *valuators,
-		    int first_valuator, int num_valuators)
+                    int first_valuator, int num_valuators)
 {
   return BadMatch;
 }
@@ -698,724 +616,246 @@ NewInputDeviceRequest (InputOption *opti
     return Success;
 }
 
-/*
- * adapted from mieq.c to support extended events
- *
- */
-#define QUEUE_SIZE  256
-
-typedef struct _Event {
-    xEvent	event;
-#ifdef XINPUT
-  deviceValuator val;
-#endif
-    ScreenPtr	pScreen;
-} EventRec, *EventPtr;
-
-typedef struct _EventQueue {
-    HWEventQueueType head, tail;
-    CARD32	lastEventTime;	    /* to avoid time running backwards */
-    Bool	lastMotion;
-    EventRec	events[QUEUE_SIZE]; /* static allocation for signals */
-    DevicePtr	pKbd, pPtr;	    /* device pointer, to get funcs */
-    ScreenPtr	pEnqueueScreen;	    /* screen events are being delivered to */
-    ScreenPtr	pDequeueScreen;	    /* screen events are being dispatched to */
-} EventQueueRec, *EventQueuePtr;
-
-static EventQueueRec xf86EventQueue;
-
-Bool
-xf86eqInit (DevicePtr pKbd, DevicePtr pPtr)
-{
-    xf86EventQueue.head = xf86EventQueue.tail = 0;
-    xf86EventQueue.lastEventTime = GetTimeInMillis ();
-    xf86EventQueue.pKbd = pKbd;
-    xf86EventQueue.pPtr = pPtr;
-    xf86EventQueue.lastMotion = FALSE;
-    xf86EventQueue.pEnqueueScreen = screenInfo.screens[0];
-    xf86EventQueue.pDequeueScreen = xf86EventQueue.pEnqueueScreen;
-    SetInputCheck (&xf86EventQueue.head, &xf86EventQueue.tail);
-    return TRUE;
-}
-
-/*
- * Must be reentrant with ProcessInputEvents.  Assumption: xf86eqEnqueue
- * will never be interrupted.  If this is called from both signal
- * handlers and regular code, make sure the signal is suspended when
- * called from regular code.
+/* 
+ * convenient functions to post events
  */
 
 _X_EXPORT void
-xf86eqEnqueue (xEvent *e)
-{
-    int		oldtail, newtail;
-    Bool	isMotion;
-#ifdef XINPUT
-    int		count;
-    
-    xf86AssertBlockedSIGIO ("xf86eqEnqueue");
-    switch (e->u.u.type) {
-    case KeyPress:
-    case KeyRelease:
-#ifdef XFreeXDGA
-	/* we do this here, because nobody seems to be calling
-	   xf86PostKeyEvent().  We can't steal MotionNotify events here
-	   because the motion-relative information has been lost already. */
-	if(DGAStealKeyEvent(xf86EventQueue.pEnqueueScreen->myNum, e))
-	    return;
-#endif
-	/* fall through */
-    case ButtonPress:
-    case ButtonRelease:
-    case MotionNotify:
-        count = 1;
-        break;
-    default:
-#ifdef XFreeXDGA
-	if (DGAIsDgaEvent (e))
-	{
-	    count = 1;
-	    break;
-	}
-#endif
-	if (!((deviceKeyButtonPointer *) e)->deviceid & MORE_EVENTS) {
-            count = 1;
-	}
-        else {
-	    count = 2;
-	}
-        break;
-    }
-#endif
-
-    oldtail = xf86EventQueue.tail;
-    isMotion = e->u.u.type == MotionNotify;
-    if (isMotion && xf86EventQueue.lastMotion && oldtail != xf86EventQueue.head) {
-	if (oldtail == 0)
-	    oldtail = QUEUE_SIZE;
-	oldtail = oldtail - 1;
-    }
-    else {
-    	newtail = oldtail + 1;
-    	if (newtail == QUEUE_SIZE)
-	    newtail = 0;
-    	/* Toss events which come in late */
-    	if (newtail == xf86EventQueue.head)
-	    return;
-	xf86EventQueue.tail = newtail;
-    }
-    
-    xf86EventQueue.lastMotion = isMotion;
-    xf86EventQueue.events[oldtail].event = *e;
-#ifdef XINPUT
-    if (count == 2) {
-	xf86EventQueue.events[oldtail].val = *((deviceValuator *) (((deviceKeyButtonPointer *) e)+1));
-    }
-#endif
-    /*
-     * Make sure that event times don't go backwards - this
-     * is "unnecessary", but very useful
-     */
-    if (e->u.keyButtonPointer.time < xf86EventQueue.lastEventTime &&
-	xf86EventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000) {
-	
-	xf86EventQueue.events[oldtail].event.u.keyButtonPointer.time =
-	    xf86EventQueue.lastEventTime;
-    }
-    xf86EventQueue.events[oldtail].pScreen = xf86EventQueue.pEnqueueScreen;
-}
-
-/*
- * Call this from ProcessInputEvents()
- */
-void
-xf86eqProcessInputEvents ()
-{
-    EventRec	*e;
-    int		x, y;
-    struct {
-	xEvent	event;
-#ifdef XINPUT
-	deviceValuator	val;
-#endif
-    }		xe;
-#ifdef XINPUT
-    DeviceIntPtr                dev;
-    int                         id, count;
-    deviceKeyButtonPointer      *dev_xe;
-#endif
-
-    while (xf86EventQueue.head != xf86EventQueue.tail) {
-	if (screenIsSaved == SCREEN_SAVER_ON)
-	    SaveScreens (SCREEN_SAVER_OFF, ScreenSaverReset);
-#ifdef DPMSExtension
-	else if (DPMSPowerLevel != DPMSModeOn)
-	    SetScreenSaverTimer();
+xf86PostMotionEvent(DeviceIntPtr	device,
+                    int			is_absolute,
+                    int			first_valuator,
+                    int			num_valuators,
+                    ...)
+{
+    va_list var;
+    int i = 0, nevents = 0;
+    Bool drag = xf86SendDragEvents(device);
+    LocalDevicePtr local = (LocalDevicePtr) device->public.devicePrivate;
+    xEvent *xE = NULL;
+    int *valuators = NULL;
+    int flags = 0;
 
-        if (DPMSPowerLevel != DPMSModeOn)
-            DPMSSet(DPMSModeOn);
+#ifdef DEBUG
+    ErrorF("xf8PostMotionEvent enter: is_absolute %s\n",
+           is_absolute ? "yes" : "no");
 #endif
+    if (is_absolute)
+        flags = POINTER_ABSOLUTE;
+    else
+        flags = POINTER_RELATIVE | POINTER_ACCELERATE;
+    
+    valuators = xcalloc(sizeof(int), num_valuators);
 
-	e = &xf86EventQueue.events[xf86EventQueue.head];
-	/*
-	 * Assumption - screen switching can only occur on motion events
-	 */
-	if (e->pScreen != xf86EventQueue.pDequeueScreen) {
-	    xf86EventQueue.pDequeueScreen = e->pScreen;
-	    x = e->event.u.keyButtonPointer.rootX;
-	    y = e->event.u.keyButtonPointer.rootY;
-	    if (xf86EventQueue.head == QUEUE_SIZE - 1)
-	    	xf86EventQueue.head = 0;
-	    else
-	    	++xf86EventQueue.head;
-	    NewCurrentScreen (xf86EventQueue.pDequeueScreen, x, y);
-	}
-	else {
-	    xe.event = e->event;
-	    xe.val = e->val;
-	    if (xf86EventQueue.head == QUEUE_SIZE - 1)
-	    	xf86EventQueue.head = 0;
-	    else
-	    	++xf86EventQueue.head;
-	    switch (xe.event.u.u.type) {
-	    case KeyPress:
-	    case KeyRelease:
-	    	(*xf86EventQueue.pKbd->processInputProc)
-		    (&xe.event, (DeviceIntPtr)xf86EventQueue.pKbd, 1);
-	    	break;
-#ifdef XINPUT
-            case ButtonPress:
-            case ButtonRelease:
-            case MotionNotify:
-	    	(*(inputInfo.pointer->public.processInputProc))
-		    (&xe.event, (DeviceIntPtr)inputInfo.pointer, 1);
-		break;
-
-	    default:
-#ifdef XFreeXDGA
-		if (DGADeliverEvent (xf86EventQueue.pDequeueScreen, &xe.event))
-		    break;
-#endif
-		dev_xe = (deviceKeyButtonPointer *) &xe.event;
-		id = dev_xe->deviceid & DEVICE_BITS;
-		if (!(dev_xe->deviceid & MORE_EVENTS)) {
-		    count = 1;
-		}
-		else {
-		    count = 2;
-		}
-		dev = LookupDeviceIntRec(id);
-		if (dev == NULL) {
-		    ErrorF("LookupDeviceIntRec id=0x%x not found\n", id);
-/*                   FatalError("xf86eqProcessInputEvents : device not found.\n");
- */
-		    break;
-		}
-		if (!dev->public.processInputProc) {
-		    FatalError("xf86eqProcessInputEvents : device has no input proc.\n");
-		    break;
-		}
-		(*dev->public.processInputProc)(&xe.event, dev, count);
-#else
-	    default:
-	    	(*xf86EventQueue.pPtr->processInputProc)
-		    (&xe.event, (DeviceIntPtr)xf86EventQueue.pPtr, 1);
+    va_start(var, num_valuators);
+    for (i = 0; i < num_valuators; i++) {
+        valuators[i] = va_arg(var, int);
+#ifdef DEBUG
+        ErrorF("valuator %d: %d\n", i, valuators[i]);
 #endif
-	    	break;
-	    }
-	}
     }
-}
 
-void
-xf86eqSwitchScreen(ScreenPtr	pScreen,
-		   Bool		fromDIX)
-{
-    xf86EventQueue.pEnqueueScreen = pScreen;
-  
-    if (fromDIX)
-	xf86EventQueue.pDequeueScreen = pScreen;
-}
+    nevents = GetPointerEvents(&xE, device, MotionNotify, 0,
+                               flags, num_valuators, valuators);
 
-/* 
- * convenient functions to post events
- */
-
-_X_EXPORT void
-xf86PostMotionEvent(DeviceIntPtr	device,
-		    int			is_absolute,
-		    int			first_valuator,
-		    int			num_valuators,
-		    ...)
-{
-    va_list			var;
-    int				loop;
-    xEvent			xE[2];
-    deviceKeyButtonPointer	*xev  = (deviceKeyButtonPointer*) xE;
-    deviceValuator		*xv   = (deviceValuator*) xev+1;
-    LocalDevicePtr		local = (LocalDevicePtr) device->public.devicePrivate;
-    char			*buff = 0;
-    Time			current;
-    Bool			is_core = xf86IsCorePointer(device);
-    Bool			is_shared = xf86ShareCorePointer(device);
-    Bool			drag = xf86SendDragEvents(device);
-    ValuatorClassPtr		val = device->valuator;
-    int				valuator[6];
-    int				oldaxis[6];
-    int				*axisvals;
-    int				dx = 0, dy = 0;
-    float			mult;
-    int				x, y;
-    int				loop_start;
-    int				i;
-    int				num;
-    
-    DBG(5, ErrorF("xf86PostMotionEvent BEGIN 0x%x(%s) is_core=%s is_shared=%s is_absolute=%s\n",
-		  device, device->name,
-		  is_core ? "True" : "False",
-		  is_shared ? "True" : "False",
-		  is_absolute ? "True" : "False"));
-    
-    xf86Info.lastEventTime = xev->time = current = GetTimeInMillis();
+    for (i = 0; i < nevents; i++) {
+        if (xE->u.keyButtonPointer.time > xf86Info.lastEventTime)
+            xf86Info.lastEventTime = xE->u.keyButtonPointer.time;
+        mieqEnqueue(xE++);
+    }
     
-    if (!is_core) {
-      if (HAS_MOTION_HISTORY(local)) {
-	buff = ((char *)local->motion_history +
-		(sizeof(INT32) * local->dev->valuator->numAxes + sizeof(Time)) * local->last);
-      }
+#if 0
+    if (HAS_MOTION_HISTORY(local)) {
+      buff = ((char *)local->motion_history +
+              (sizeof(INT32) * local->dev->valuator->numAxes + sizeof(Time)) * local->last);
     }
 
-    if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
-	ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
-	return;
+    if (HAS_MOTION_HISTORY(local)) {
+        local->last = (local->last + 1) % device->valuator->numMotionEvents;
+        if (local->last == local->first)
+            local->first = (local->first + 1) % device->valuator->numMotionEvents;
     }
-
-    axisvals = val->axisVal;
-    
-    va_start(var, num_valuators);
-
-    loop_start = first_valuator;
-    for(loop=0; loop<num_valuators; loop++) {
-	
-	valuator[loop%6] = va_arg(var,int);
-	
-	if (loop % 6 == 5 || loop == num_valuators - 1)	{
-	    num = loop % 6 + 1;
-	    /*
-	     * Adjust first two relative valuators
-	     */
-	    if (!is_absolute && num_valuators >= 2 && loop_start == 0) {
-		
-		dx = valuator[0];
-		dy = valuator[1];
-
-		/*
-		 * Accelerate
-		 */
-		if (device->ptrfeed && device->ptrfeed->ctrl.num) {
-		    /* modeled from xf86Events.c */
-		    if (device->ptrfeed->ctrl.threshold) {
-			if ((abs(dx) + abs(dy)) >= device->ptrfeed->ctrl.threshold) {
-			    local->dxremaind = ((float)dx * (float)(device->ptrfeed->ctrl.num)) /
-			        (float)(device->ptrfeed->ctrl.den) + local->dxremaind;
-			    valuator[0] = (int)local->dxremaind;
-			    local->dxremaind = local->dxremaind - (float)valuator[0];
-			    
-			    local->dyremaind = ((float)dy * (float)(device->ptrfeed->ctrl.num)) /
-			        (float)(device->ptrfeed->ctrl.den) + local->dyremaind;
-			    valuator[1] = (int)local->dyremaind;
-			    local->dyremaind = local->dyremaind - (float)valuator[1];
-			}
-		    }
-		    else if (dx || dy) {
-			mult = pow((float)(dx*dx+dy*dy),
-				   ((float)(device->ptrfeed->ctrl.num) /
-				    (float)(device->ptrfeed->ctrl.den) - 1.0) / 
-				   2.0) / 2.0;
-			if (dx) {
-			    local->dxremaind = mult * (float)dx + local->dxremaind;
-			    valuator[0] = (int)local->dxremaind;
-			    local->dxremaind = local->dxremaind - (float)valuator[0];
-			}
-			if (dy) {
-			    local->dyremaind = mult * (float)dy + local->dyremaind;
-			    valuator[1] = (int)local->dyremaind;
-			    local->dyremaind = local->dyremaind - (float)valuator[1];
-			}
-		    }
-		    DBG(6, ErrorF("xf86PostMotionEvent acceleration v0=%d v1=%d\n",
-				  valuator[0], valuator[1]));
-		}
-		
-		/*
-		 * Map current position back to device space in case
-		 * the cursor was warped
-		 */
-		if (is_core || is_shared)
-		{
-		    miPointerPosition (&x, &y);
-		    if (local->reverse_conversion_proc)
-			(*local->reverse_conversion_proc)(local, x, y, axisvals);
-		    else
-		    {
-			axisvals[0] = x;
-			axisvals[1] = y;
-		    }
-		}
-	    }
-		
-	    /*
-	     * Update axes
-	     */
-	    for (i = 0; i < num; i++)
-	    {
-		oldaxis[i] = axisvals[loop_start + i];
-	        if (is_absolute)
-		    axisvals[loop_start + i] = valuator[i];
-		else
-		    axisvals[loop_start + i] += valuator[i];
-	    }
-		
-	    /*
-	     * Deliver extension event
-	     */
-	    if (!is_core) {
-		xev->type = DeviceMotionNotify;
-		xev->detail = 0;
-		xev->deviceid = device->id | MORE_EVENTS;
-            
-		xv->type = DeviceValuator;
-		xv->deviceid = device->id;
-	    
-		xv->device_state = 0;
-		xv->num_valuators = num;
-		xv->first_valuator = loop_start;
-		memcpy (&xv->valuator0, &axisvals[loop_start],
-			sizeof(INT32)*xv->num_valuators);
-		
-		if (HAS_MOTION_HISTORY(local)) {
-		    *(Time*)buff = current;
-		    memcpy(buff+sizeof(Time)+sizeof(INT32)*xv->first_valuator,
-			   &axisvals[loop_start],
-			   sizeof(INT32)*xv->num_valuators);
-		}
-		ENQUEUE(xE);
-	    }
-	    
-	    /*
-	     * Deliver core event
-	     */
-	    if (is_core ||
-		(is_shared && num_valuators >= 2 && loop_start == 0)) {
-#ifdef XFreeXDGA
-		/*
-		 * Let DGA peek at the event and steal it
-		 */
-		xev->type = MotionNotify;
-		xev->detail = 0;
-		if (is_absolute)
-		{
-		    dx = axisvals[0] - oldaxis[0];
-		    dy = axisvals[1] - oldaxis[1];
-		}
-		if (DGAStealMouseEvent(xf86EventQueue.pEnqueueScreen->myNum,
-				       xE, dx, dy))
-		    continue;
 #endif
-		if (!(*local->conversion_proc)(local, loop_start, num,
-					       axisvals[0], axisvals[1],
-					       axisvals[2], axisvals[3],
-					       axisvals[4], axisvals[5],
-					       &x, &y))
-		    continue;
-
-		if (drag)
-		    miPointerAbsoluteCursor (x, y, current);
-		/*
-		 * Retrieve the position
-		 */
-		miPointerPosition (&x, &y);
-		if (local->reverse_conversion_proc)
-		    (*local->reverse_conversion_proc)(local, x, y, axisvals);
-		else
-		{
-		    axisvals[0] = x;
-		    axisvals[1] = y;
-		}
-	    }
-	    loop_start += 6;
-	}
-    }
-    va_end(var);
-    if (HAS_MOTION_HISTORY(local)) {
-	local->last = (local->last + 1) % device->valuator->numMotionEvents;
-	if (local->last == local->first)
-	    local->first = (local->first + 1) % device->valuator->numMotionEvents;
-    }
-    DBG(5, ErrorF("xf86PostMotionEvent END   0x%x(%s) is_core=%s is_shared=%s\n",
-		  device, device->name,
-		  is_core ? "True" : "False",
-		  is_shared ? "True" : "False"));
 }
 
 _X_EXPORT void
 xf86PostProximityEvent(DeviceIntPtr	device,
-		       int		is_in,
-		       int		first_valuator,
-		       int		num_valuators,
-		       ...)
+                       int		is_in,
+                       int		first_valuator,
+                       int		num_valuators,
+                       ...)
 {
     va_list			var;
     int				loop;
-    xEvent			xE[2];
-    deviceKeyButtonPointer	*xev = (deviceKeyButtonPointer*) xE;
-    deviceValuator		*xv = (deviceValuator*) xev+1;
-    ValuatorClassPtr		val = device->valuator;
-    Bool			is_core = xf86IsCorePointer(device);
-    Bool			is_absolute = val && ((val->mode & 1) == Relative);
+    Bool			is_core = device->coreEvents;
+
+#ifdef DEBUG
+    ErrorF("xf86PostProximityEvent enter\n");
+#endif
     
+#if 0
     DBG(5, ErrorF("xf86PostProximityEvent BEGIN 0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
-		  device, device->name, is_in ? "true" : "false",
-		  is_core ? "True" : "False",
-		  is_absolute ? "True" : "False"));
+                  device, device->name, is_in ? "true" : "false",
+                  is_core ? "True" : "False",
+                  is_absolute ? "True" : "False"));
     
     if (is_core) {
-	return;
+        return;
     }
   
     if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
-	ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
-	return;
+        ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
+        return;
     }
 
     xev->type = is_in ? ProximityIn : ProximityOut;
     xev->detail = 0;
     xev->deviceid = device->id | MORE_EVENTS;
-	
+        
     xv->type = DeviceValuator;
     xv->deviceid = device->id;
     xv->device_state = 0;
 
     if ((device->valuator->mode & 1) == Relative) {
-	num_valuators = 0;
+        num_valuators = 0;
     }
   
     if (num_valuators != 0) {
-	int	*axisvals = val->axisVal;
-	    
-	va_start(var, num_valuators);
-
-	for(loop=0; loop<num_valuators; loop++) {
-	    switch (loop % 6) {
-	    case 0:
-		xv->valuator0 = is_absolute ? va_arg(var, int) : axisvals[loop]; 
-		break;
-	    case 1:
-		xv->valuator1 = is_absolute ? va_arg(var, int) : axisvals[loop];
-		break;
-	    case 2:
-		xv->valuator2 = is_absolute ? va_arg(var, int) : axisvals[loop];
-		break;
-	    case 3:
-		xv->valuator3 = is_absolute ? va_arg(var, int) : axisvals[loop];
-		break;
-	    case 4:
-		xv->valuator4 = is_absolute ? va_arg(var, int) : axisvals[loop];
-		break;
-	    case 5:
-		xv->valuator5 = is_absolute ? va_arg(var, int) : axisvals[loop];
-		break;
-	    }
-	    if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
-		xf86Info.lastEventTime = xev->time = GetTimeInMillis();
-
-		xv->num_valuators = (loop % 6) + 1;
-		xv->first_valuator = first_valuator + (loop / 6) * 6;
-		ENQUEUE(xE);
-	    }
-	}
-	va_end(var);
+        int	*axisvals = val->axisVal;
+            
+        va_start(var, num_valuators);
+
+        for(loop=0; loop<num_valuators; loop++) {
+            switch (loop % 6) {
+            case 0:
+                xv->valuator0 = is_absolute ? va_arg(var, int) : axisvals[loop]; 
+                break;
+            case 1:
+                xv->valuator1 = is_absolute ? va_arg(var, int) : axisvals[loop];
+                break;
+            case 2:
+                xv->valuator2 = is_absolute ? va_arg(var, int) : axisvals[loop];
+                break;
+            case 3:
+                xv->valuator3 = is_absolute ? va_arg(var, int) : axisvals[loop];
+                break;
+            case 4:
+                xv->valuator4 = is_absolute ? va_arg(var, int) : axisvals[loop];
+                break;
+            case 5:
+                xv->valuator5 = is_absolute ? va_arg(var, int) : axisvals[loop];
+                break;
+            }
+            if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
+                xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+
+                xv->num_valuators = (loop % 6) + 1;
+                xv->first_valuator = first_valuator + (loop / 6) * 6;
+                mieqEnqueue(xE);
+            }
+        }
+        va_end(var);
     }
     else {
-	/* no valuator */
-	xf86Info.lastEventTime = xev->time = GetTimeInMillis();
+        /* no valuator */
+        xf86Info.lastEventTime = xev->time = GetTimeInMillis();
 
-	xv->num_valuators = 0;
-	xv->first_valuator = 0;
-	ENQUEUE(xE);
+        xv->num_valuators = 0;
+        xv->first_valuator = 0;
+        mieqEnqueue(xE);
     }
     DBG(5, ErrorF("xf86PostProximityEvent END   0x%x(%s) prox=%s is_core=%s is_absolute=%s\n",
-		  device, device->name, is_in ? "true" : "false",
-		  is_core ? "True" : "False",
-		  is_absolute ? "True" : "False"));
-    
+                  device, device->name, is_in ? "true" : "false",
+                  is_core ? "True" : "False",
+                  is_absolute ? "True" : "False"));
+#endif
 }
 
 _X_EXPORT void
 xf86PostButtonEvent(DeviceIntPtr	device,
-		    int			is_absolute,
-		    int			button,
-		    int			is_down,
-		    int			first_valuator,
-		    int			num_valuators,
-		    ...)
-{
-    va_list			var;
-    int				loop;
-    xEvent			xE[2];
-    deviceKeyButtonPointer	*xev	        = (deviceKeyButtonPointer*) xE;
-    deviceValuator		*xv	        = (deviceValuator*) xev+1;
-    ValuatorClassPtr		val		= device->valuator;
-    Bool			is_core		= xf86IsCorePointer(device);
-    Bool			is_shared       = xf86ShareCorePointer(device);
-    
-    DBG(5, ErrorF("xf86PostButtonEvent BEGIN 0x%x(%s) button=%d down=%s is_core=%s is_shared=%s is_absolute=%s\n",
-		  device, device->name, button,
-		  is_down ? "True" : "False",
-		  is_core ? "True" : "False",
-		  is_shared ? "True" : "False",
-		  is_absolute ? "True" : "False"));
-    
-    /* Check the core pointer button state not to send an inconsistent
-     * event. This can happen with the AlwaysCore feature.
-     */
-    if ((is_core || is_shared) && 
-	!xf86CheckButton(device->button->map[button], is_down)) 
-    {
-	return;
-    }
+                    int			is_absolute,
+                    int			button,
+                    int			is_down,
+                    int			first_valuator,
+                    int			num_valuators,
+                    ...)
+{
+    va_list var;
+    int *valuators = NULL;
+    int i = 0, nevents = 0;
+    xEvent *events = NULL;
     
-    if (num_valuators && (!val || (first_valuator + num_valuators > val->numAxes))) {
-	ErrorF("Bad valuators reported for device \"%s\"\n", device->name);
-	return;
-    }
+#ifdef DEBUG
+    ErrorF("xf86PostButtonEvent BEGIN 0x%x(%s) button=%d down=%s is_absolute=%s\n",
+                  device, device->name, button,
+                  is_down ? "True" : "False",
+                  is_absolute ? "True" : "False");
+#endif
 
-    if (!is_core) {
-	xev->type = is_down ? DeviceButtonPress : DeviceButtonRelease;
-	xev->detail = button;
-	xev->deviceid = device->id | MORE_EVENTS;
-	    
-	xv->type = DeviceValuator;
-	xv->deviceid = device->id;
-	xv->device_state = 0;
-
-	if (num_valuators != 0) {
-	    int			*axisvals = val->axisVal;
-	    
-	    va_start(var, num_valuators);
-      
-	    for(loop=0; loop<num_valuators; loop++) {
-		switch (loop % 6) {
-		case 0:
-		    xv->valuator0 = is_absolute ? va_arg(var, int) : axisvals[loop];
-		    break;
-		case 1:
-		    xv->valuator1 = is_absolute ? va_arg(var, int) : axisvals[loop];
-		    break;
-		case 2:
-		    xv->valuator2 = is_absolute ? va_arg(var, int) : axisvals[loop];
-		    break;
-		case 3:
-		    xv->valuator3 = is_absolute ? va_arg(var, int) : axisvals[loop];
-		    break;
-		case 4:
-		    xv->valuator4 = is_absolute ? va_arg(var, int) : axisvals[loop];
-		    break;
-		case 5:
-		    xv->valuator5 = is_absolute ? va_arg(var, int) : axisvals[loop];
-		    break;
-		}
-		if ((loop % 6 == 5) || (loop == num_valuators - 1)) {
-		    xf86Info.lastEventTime = xev->time = GetTimeInMillis();
-		    xv->num_valuators = (loop % 6) + 1;
-		    xv->first_valuator = first_valuator + (loop / 6) * 6;
-		    ENQUEUE(xE);
-		    
-		}
-	    }
-	    va_end(var);
-	}
-	else {
-	    /* no valuator */
-	    xf86Info.lastEventTime = xev->time = GetTimeInMillis();
-	    xv->num_valuators = 0;
-	    xv->first_valuator = 0;
-	    ENQUEUE(xE);
-	}
-    }
-
-    /* removed rootX/rootY as DIX sets these fields */
-    if (is_core || is_shared) {
-	xE->u.u.type = is_down ? ButtonPress : ButtonRelease;
-	xE->u.u.detail =  device->button->map[button];
-	xf86Info.lastEventTime = xE->u.keyButtonPointer.time = GetTimeInMillis();
-	
-#ifdef XFreeXDGA
-	if (!DGAStealMouseEvent(xf86EventQueue.pEnqueueScreen->myNum, xE, 0, 0))
+    valuators = xcalloc(sizeof(int), num_valuators);
+
+    va_start(var, num_valuators);
+    for (i = 0; i < num_valuators; i++) {
+#ifdef DEBUG
+        ErrorF("valuator %d: %d\n", i, valuators[i]);
 #endif
-	    ENQUEUE(xE);
+        valuators[i] = va_arg(var, int);
+    }
+
+    nevents = GetPointerEvents(&events, device,
+                               is_down ? ButtonPress : ButtonRelease, button,
+                               is_absolute ? POINTER_ABSOLUTE :
+                                             POINTER_RELATIVE,
+                               num_valuators, valuators);
+
+    for (i = 0; i < nevents; i++) {
+        if (events->u.keyButtonPointer.time > xf86Info.lastEventTime)
+            xf86Info.lastEventTime = events->u.keyButtonPointer.time;
+        mieqEnqueue(events++);
     }
-    DBG(5, ErrorF("xf86PostButtonEvent END\n"));
 }
 
 _X_EXPORT void
 xf86PostKeyEvent(DeviceIntPtr	device,
-		 unsigned int	key_code,
-		 int		is_down,
-		 int		is_absolute,
-		 int		first_valuator,
-		 int		num_valuators,
-		 ...)
-{
-    va_list			var;
-    int				loop;
-    xEvent			xE[2];
-    deviceKeyButtonPointer	*xev = (deviceKeyButtonPointer*) xE;
-    deviceValuator		*xv = (deviceValuator*) xev+1;
-    
-    va_start(var, num_valuators);
+                 unsigned int	key_code,
+                 int		is_down,
+                 int		is_absolute,
+                 int		first_valuator,
+                 int		num_valuators,
+                 ...)
+{
+    va_list var;
+    int i = 0, nevents = 0, *valuators = NULL;
+    xEvent *events = NULL;
+
+    /* instil confidence in the user */
+    ErrorF("this function has never been tested properly.  if things go quite "
+           "badly south after this message, then xf86PostKeyEvent is "
+           "broken.\n");
+
+    /* the spec says that dkp/dkr events should only get valuators in
+     * absolute mode.  the spec knows all.  BOW BEFORE etc. */
+    if (is_absolute) {
+        nevents = GetKeyboardValuatorEvents(&events, device,
+                                            is_down ? KeyPress : KeyRelease,
+                                            key_code, num_valuators,
+                                            valuators);
+        valuators = xcalloc(sizeof(int), num_valuators);
+        va_start(var, num_valuators);
+        for (i = 0; i < num_valuators; i++)
+            valuators[i] = va_arg(var, int);
+        va_end(var);
+    }
+    else {
+        nevents = GetKeyboardEvents(&events, device,
+                                    is_down ? KeyPress : KeyRelease,
+                                    key_code);
+    }
 
-    for(loop=0; loop<num_valuators; loop++) {
-	switch (loop % 6) {
-	case 0:
-	    xv->valuator0 = va_arg(var, int);
-	    break;
-	case 1:
-	    xv->valuator1 = va_arg(var, int);
-	    break;
-	case 2:
-	    xv->valuator2 = va_arg(var, int);
-	    break;
-	case 3:
-	    xv->valuator3 = va_arg(var, int);
-	    break;
-	case 4:
-	    xv->valuator4 = va_arg(var, int);
-	    break;
-	case 5:
-	    xv->valuator5 = va_arg(var, int);
-	    break;
-	}
-	if (((loop % 6 == 5) || (loop == num_valuators - 1))) {
-	    xev->type = is_down ? DeviceKeyPress : DeviceKeyRelease;
-	    xev->detail = key_code;
-	    
-	    xf86Info.lastEventTime = xev->time = GetTimeInMillis();
-	    xev->deviceid = device->id | MORE_EVENTS;
-	    
-	    xv->type = DeviceValuator;
-	    xv->deviceid = device->id;
-	    xv->device_state = 0;
-	    /* if the device is in the relative mode we don't have to send valuators */
-	    xv->num_valuators = is_absolute ? (loop % 6) + 1 : 0;
-	    xv->first_valuator = first_valuator + (loop / 6) * 6;
-	    
-	    ENQUEUE(xE);
-	    /* if the device is in the relative mode only one event is needed */
-	    if (!is_absolute) break;
-	}
+    for (i = 0; i < nevents; i++) {
+        if (events->u.keyButtonPointer.time > xf86Info.lastEventTime)
+            xf86Info.lastEventTime = events->u.keyButtonPointer.time;
+        mieqEnqueue(events++);
     }
-    va_end(var);
 }
 
 _X_EXPORT void
@@ -1423,21 +863,22 @@ xf86PostKeyboardEvent(DeviceIntPtr      
                       unsigned int      key_code,
                       int               is_down)
 {
-    xEvent                      xE[2];
-    deviceKeyButtonPointer      *xev = (deviceKeyButtonPointer*) xE;
+    xEvent *events = NULL;
+    int nevents = 0, i = 0;
 
-    if (xf86IsCoreKeyboard(device)) {
-        xev->type = is_down ? KeyPress : KeyRelease;
-    } else {
-        xev->type = is_down ? DeviceKeyPress : DeviceKeyRelease;
-    }
-    xev->detail = key_code;
-    xf86Info.lastEventTime = xev->time = GetTimeInMillis();
-
-#ifdef XFreeXDGA
-    /* if(!DGAStealKeyEvent(xf86EventQueue.pEnqueueScreen->myNum, xE)) */
+#ifdef DEBUG
+    ErrorF("xf86PKE enter: keycode %d is %s, device %d\n", key_code,
+           is_down ? "down" : "up", device->id);
 #endif
-    ENQUEUE(xE);
+
+    nevents = GetKeyboardEvents(&events, device,
+                                is_down ? KeyPress : KeyRelease, key_code);
+
+    for (i = 0; i < nevents; i++) {
+        if (events->u.keyButtonPointer.time > xf86Info.lastEventTime)
+            xf86Info.lastEventTime = events->u.keyButtonPointer.time;
+        mieqEnqueue(events++);
+    }
 }
 
 /* 
@@ -1450,20 +891,20 @@ xf86MotionHistoryAllocate(LocalDevicePtr
     ValuatorClassPtr	valuator = local->dev->valuator;
     
     if (!HAS_MOTION_HISTORY(local))
-	return;
+        return;
     if (local->motion_history) xfree(local->motion_history);
     local->motion_history = xalloc((sizeof(INT32) * valuator->numAxes + sizeof(Time))
-				   * valuator->numMotionEvents);
+                                   * valuator->numMotionEvents);
     local->first = 0;
     local->last	 = 0;
 }
 
 _X_EXPORT int
 xf86GetMotionEvents(DeviceIntPtr	dev,
-		    xTimecoord		*buff,
-		    unsigned long	start,
-		    unsigned long	stop,
-		    ScreenPtr		pScreen)
+                    xTimecoord		*buff,
+                    unsigned long	start,
+                    unsigned long	stop,
+                    ScreenPtr		pScreen)
 {
     LocalDevicePtr	local	 = (LocalDevicePtr)dev->public.devicePrivate;
     ValuatorClassPtr	valuator = dev->valuator;
@@ -1473,20 +914,20 @@ xf86GetMotionEvents(DeviceIntPtr	dev,
     Time		current;
     
     if (!HAS_MOTION_HISTORY(local))
-	return 0;
+        return 0;
 
     size = (sizeof(INT32) * valuator->numAxes + sizeof(Time));
 
     while (loop != local->last) {
-	current = *(Time*)(((char *)local->motion_history)+loop*size);
-	if (current > stop)
-	    return num;
-	if (current >= start) {
-	    memcpy(((char *)buff)+size*num,
-		   ((char *)local->motion_history)+loop*size, size);
-	    num++;
-	}
-	loop = (loop + 1) % valuator->numMotionEvents;
+        current = *(Time*)(((char *)local->motion_history)+loop*size);
+        if (current > stop)
+            return num;
+        if (current >= start) {
+            memcpy(((char *)buff)+size*num,
+                   ((char *)local->motion_history)+loop*size, size);
+            num++;
+        }
+        loop = (loop + 1) % valuator->numMotionEvents;
     }
     return num;
 }
@@ -1512,10 +953,10 @@ xf86FirstLocalDevice()
 
 _X_EXPORT int
 xf86ScaleAxis(int	Cx,
-	      int	Sxhigh,
-	      int	Sxlow,
-	      int	Rxhigh,
-	      int	Rxlow )
+              int	Sxhigh,
+              int	Sxlow,
+              int	Rxhigh,
+              int	Rxlow )
 {
     int X;
     int dSx = Sxhigh - Sxlow;
@@ -1550,7 +991,7 @@ xf86XInputSetScreen(LocalDevicePtr	local
 		    int			x,
 		    int			y)
 {
-    if ((xf86IsCorePointer(local->dev) || xf86ShareCorePointer(local->dev)) &&
+    if (local->dev->coreEvents &&
 	(miPointerCurrentScreen() != screenInfo.screens[screen_number])) {
 	miPointerSetNewScreen (screen_number, x, y);
     }
@@ -1562,6 +1003,9 @@ xf86InitValuatorAxisStruct(DeviceIntPtr 
 			   int resolution, int min_res, int max_res)
 {
 #ifdef XINPUT
+    if (!dev || !dev->valuator)
+        return;
+
     if (maxval == -1) {
 	if (axnum == 0)
 	    maxval = screenInfo.screens[0]->width - 1;
@@ -1582,10 +1026,14 @@ _X_EXPORT void
 xf86InitValuatorDefaults(DeviceIntPtr dev, int axnum)
 {
 #ifdef XINPUT
-    if (axnum == 0)
+    if (axnum == 0) {
 	dev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
-    else if (axnum == 1)
+        dev->valuator->lastx = dev->valuator->axisVal[0];
+    }
+    else if (axnum == 1) {
 	dev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
+        dev->valuator->lasty = dev->valuator->axisVal[1];
+    }
 #endif
 }
 
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 9fb3041..d4fa43f 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -147,8 +147,6 @@ typedef struct _LocalDeviceRec {
     unsigned int	    last;
     int			    old_x;
     int			    old_y;
-    float		    dxremaind;
-    float		    dyremaind;
     char *		    type_name;
     IntegerFeedbackPtr	    always_core_feedback;
     IDevPtr		    conf_idev;
@@ -167,16 +165,7 @@ typedef struct _DeviceAssocRec 
 extern InputInfoPtr xf86InputDevs;
 
 /* xf86Xinput.c */
-int xf86IsCorePointer(DeviceIntPtr dev);
-int xf86IsCoreKeyboard(DeviceIntPtr dev);
-void xf86XInputSetSendCoreEvents(LocalDevicePtr local, Bool always);
-#define xf86AlwaysCore(a,b) xf86XInputSetSendCoreEvents(a,b)
-
 void InitExtInput(void);
-Bool xf86eqInit(DevicePtr pKbd, DevicePtr pPtr);
-void xf86eqEnqueue(struct _xEvent *event);
-void xf86eqProcessInputEvents (void);
-void xf86eqSwitchScreen(ScreenPtr pScreen, Bool fromDIX);
 void xf86PostMotionEvent(DeviceIntPtr device, int is_absolute,
 			 int first_valuator, int num_valuators, ...);
 void xf86PostProximityEvent(DeviceIntPtr device, int is_in,
@@ -212,10 +201,16 @@ void xf86RemoveEnabledDevice(InputInfoPt
 void xf86AddInputDriver(InputDriverPtr driver, pointer module, int flags);
 void xf86DeleteInputDriver(int drvIndex);
 InputInfoPtr xf86AllocateInput(InputDriverPtr drv, int flags);
+InputDriverPtr xf86LookupInputDriver(const char *name);
+InputInfoPtr xf86LookupInput(const char *name);
 void xf86DeleteInput(InputInfoPtr pInp, int flags);
 
 /* xf86Option.c */
 void xf86CollectInputOptions(InputInfoPtr pInfo, const char **defaultOpts,
 			     pointer extraOpts);
 
+/* Legacy hatred */
+#define SendCoreEvents 59
+#define DontSendCoreEvents 60
+
 #endif /* _xf86Xinput_h */
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index ad4f773..f9d11e8 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -293,7 +293,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86SoundKbdBell)
     SYMFUNC(xf86GARTCloseScreen)
 #ifdef XINPUT
-    /* XISB routines  (Merged from Metrolink tree) */
     SYMFUNC(XisbNew)
     SYMFUNC(XisbFree)
     SYMFUNC(XisbRead)
@@ -695,7 +694,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     /* xf86Xinput.c */
 #ifdef XINPUT
     SYMFUNC(xf86ProcessCommonOptions)
-    SYMFUNC(xf86IsCorePointer)
     SYMFUNC(xf86PostMotionEvent)
     SYMFUNC(xf86PostProximityEvent)
     SYMFUNC(xf86PostButtonEvent)
@@ -704,13 +702,9 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86GetMotionEvents)
     SYMFUNC(xf86MotionHistoryAllocate)
     SYMFUNC(xf86FirstLocalDevice)
-    SYMFUNC(xf86eqEnqueue)
     SYMFUNC(xf86ActivateDevice)
-/* The following segment merged from Metrolink tree */
     SYMFUNC(xf86XInputSetScreen)
     SYMFUNC(xf86ScaleAxis)
-    SYMFUNC(xf86XInputSetSendCoreEvents)
-/* End merged segment */
 #endif
 #ifdef DPMSExtension
     SYMFUNC(DPMSGet)
diff-tree d32dc8bf19e1071fc30af2f0bc6a6699b351f39e (from 7711c56d2e2aeae4dcd6d9297bc144c1cb3cfab1)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Thu Jul 20 18:40:47 2006 -0400

    be more careful in IVAS
    
    Don't walk off the end of a NULL pointer in InitValuatorAxisStruct.

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 2932ab2..9fdea6d 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -302,7 +302,12 @@ _X_EXPORT void
 InitValuatorAxisStruct(DeviceIntPtr dev, int axnum, int minval, int maxval,
 		       int resolution, int min_res, int max_res)
 {
-    register AxisInfoPtr ax = dev->valuator->axes + axnum;
+    register AxisInfoPtr ax;
+   
+    if (!dev || !dev->valuator)
+        return NULL;
+
+    ax = dev->valuator->axes + axnum;
 
     ax->min_value = minval;
     ax->max_value = maxval;
diff-tree 7711c56d2e2aeae4dcd6d9297bc144c1cb3cfab1 (from f18c3122a57df9770087e5fc70ac488552222233)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Thu Jul 20 18:38:57 2006 -0400

    xephyr: fix keymap, pointer; dix: fix multiple axes
    
    Initialise our axes properly in the DIX, and make sure we don't
    unnecessarily clip maxval when it's not set.
    Fix keymap copying in Xephyr (to some degree: it's still broken),
    and set nAxes and nButtons properly.

diff --git a/dix/devices.c b/dix/devices.c
index 52a0a0a..ee0c74b 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -815,6 +815,9 @@ InitValuatorClassDeviceStruct(DeviceIntP
     int i;
     register ValuatorClassPtr valc;
 
+    if (!dev)
+        return FALSE;
+
     valc = (ValuatorClassPtr)xalloc(sizeof(ValuatorClassRec) +
 				    numAxes * sizeof(AxisInfo) +
 				    numAxes * sizeof(unsigned int));
@@ -827,13 +830,15 @@ InitValuatorClassDeviceStruct(DeviceIntP
     valc->mode = mode;
     valc->axes = (AxisInfoPtr)(valc + 1);
     valc->axisVal = (int *)(valc->axes + numAxes);
-    for (i=0; i<numAxes; i++)
-	valc->axisVal[i]=0;
     valc->lastx = 0;
     valc->lasty = 0;
     valc->dxremaind = 0;
     valc->dyremaind = 0;
     dev->valuator = valc;
+    for (i=0; i<numAxes; i++) {
+        InitValuatorAxisStruct(dev, i, 0, -1, 0, 0, 0);
+	valc->axisVal[i]=0;
+    }
     return TRUE;
 }
 
diff --git a/dix/events.c b/dix/events.c
index fac492c..6c44485 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -4953,12 +4953,12 @@ GetPointerEvents(xEvent **xE, DeviceIntP
     axes = pDev->valuator->axes;
     if (kbp->root_x < axes->min_value)
         kbp->root_x = axes->min_value;
-    if (kbp->root_x > axes->max_value)
+    if (axes->max_value > 0 && kbp->root_x > axes->max_value)
         kbp->root_x = axes->max_value;
     axes++;
     if (kbp->root_y < axes->min_value)
         kbp->root_y = axes->min_value;
-    if (kbp->root_y > axes->max_value)
+    if (axes->max_value > 0 && kbp->root_y > axes->max_value)
         kbp->root_y = axes->max_value;
 
     if (pDev->coreEvents) {
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index 92fd831..6a337bc 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -863,10 +863,10 @@ MouseInit (KdPointerInfo *pi)
     pi->driverPrivate = (EphyrPointerPrivate *)
                          xcalloc(sizeof(EphyrPointerPrivate), 1);
     ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
+    pi->nAxes = 3;
+    pi->nButtons = 32;
     ephyrMouse = pi;
-    /* FIXME DO NOT COMMIT */
     KdAddPointerDriver(&EphyrMouseDriver);
-    ErrorF("SUCCESS!\n");
     return Success;
 }
 
@@ -874,7 +874,6 @@ static Status
 MouseEnable (KdPointerInfo *pi)
 {
     ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = TRUE;
-    ErrorF("SUCCESS ENABLE!\n");
     return Success;
 }
 
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index b23532f..96d1211 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -675,13 +675,6 @@ hostx_load_keymap(void)
 			       max_keycode - min_keycode + 1,
 			       &host_width);
 
-
-  ephyrKeySyms.map = (KeySym *)calloc(sizeof(KeySym),
-                                      (max_keycode - min_keycode + 1) *
-                                      width);
-  if (!ephyrKeySyms.map)
-        return;
-  
   /* Try and copy the hosts keymap into our keymap to avoid loads
    * of messing around.
    *
@@ -690,15 +683,21 @@ hostx_load_keymap(void)
    */
   width = (host_width > 4) ? 4 : host_width;
 
+  ephyrKeySyms.map = (KeySym *)calloc(sizeof(KeySym),
+                                      (max_keycode - min_keycode + 1) *
+                                      width);
+  if (!ephyrKeySyms.map)
+        return;
+
   for (i=0; i<(max_keycode - min_keycode+1); i++)
     for (j=0; j<width; j++)
-      kdKeymap[ (i*width)+j ] = keymap[ (i*host_width) + j ];
+      ephyrKeySyms.map[(i*width)+j] = keymap[(i*host_width) + j];
 
   EPHYR_DBG("keymap width, host:%d kdrive:%d", host_width, width);
   
   ephyrKeySyms.minKeyCode  = min_keycode;
   ephyrKeySyms.maxKeyCode  = max_keycode;
-  ephyrKeySyms.mapWidth    = (width > 4) ? 4 : width;
+  ephyrKeySyms.mapWidth    = width;
 
   XFree(keymap);
 }
diff-tree f18c3122a57df9770087e5fc70ac488552222233 (from 463e0fe35bec3c91b19be9aacf34babb146a88c9)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Thu Jul 20 16:49:17 2006 -0400

    sanitise debug output
    
    Don't spit out huge chunks of pointless ephemera, especially without
    --enable-debug.

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 13869c9..d46694f 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -408,7 +408,9 @@ KdPointerProc(DeviceIntPtr pDevice, int 
     switch (onoff)
     {
     case DEVICE_INIT:
+#ifdef DEBUG
         ErrorF("initialising pointer %s ...\n", pi->name);
+#endif
         if (!pi->driver) {
             if (!pi->driverPrivate) {
                 ErrorF("no driver specified for %s\n", pi->name);
@@ -468,7 +470,6 @@ KdPointerProc(DeviceIntPtr pDevice, int 
         }
 
         if ((*pi->driver->Enable) (pi) == Success) {
-            ErrorF("initialised fine, returning success\n");
             pDev->on = TRUE;
             return Success;
         }
@@ -495,13 +496,11 @@ KdPointerProc(DeviceIntPtr pDevice, int 
         return Success;
 
     case DEVICE_CLOSE:
-        ErrorF("D_C\n");
 	if (pDev->on) {
             if (!pi->driver->Disable) {
                 return BadImplementation;
             }
             (*pi->driver->Disable) (pi);
-            ErrorF("disabled\n");
             pDev->on = FALSE;
         }
 
@@ -509,10 +508,8 @@ KdPointerProc(DeviceIntPtr pDevice, int 
             return BadImplementation;
 
         (*pi->driver->Fini) (pi);
-        ErrorF("finished\n");
 
         KdRemovePointer(pi);
-        ErrorF("removed\n");
         
         return Success;
     }
diff --git a/mi/mieq.c b/mi/mieq.c
index b05210c..062914c 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -101,7 +101,10 @@ mieqEnqueue (xEvent *e)
     deviceKeyButtonPointer *lastkbp = (deviceKeyButtonPointer *)
                                       &laste->event[0];
 
+#ifdef DEBUG
     ErrorF("mieqEnqueue: slamming an event on to the queue from %d\n", kbp->deviceid & DEVICE_BITS);
+#endif
+
     if (e->u.u.type == MotionNotify) {
         miPointerAbsoluteCursor(e->u.keyButtonPointer.rootX,
                                 e->u.keyButtonPointer.rootY,
@@ -135,7 +138,6 @@ mieqEnqueue (xEvent *e)
                 return;
             }
             laste->event[laste->nevents++] = *e;
-            ErrorF("put a valuator event into the queue\n");
             return;
         }
         else if (e->u.u.type == DeviceMotionNotify) {
@@ -174,9 +176,11 @@ mieqEnqueue (xEvent *e)
     if (e->u.keyButtonPointer.time < miEventQueue.lastEventTime &&
 	miEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
     {
+#ifdef DEBUG
         ErrorF("mieq: rewinding event time from %d to %d\n",
                miEventQueue.lastEventTime,
                miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time);
+#endif
 	miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time =
 	    miEventQueue.lastEventTime;
     }
@@ -186,7 +190,6 @@ mieqEnqueue (xEvent *e)
     miEventQueue.events[oldtail].pDev = pDev;
 
     miEventQueue.lastMotion = isMotion;
-    ErrorF("bottom of mieqEnqueue\n");
 }
 
 void
@@ -206,8 +209,6 @@ void mieqProcessInputEvents ()
     EventRec	*e;
     int		x, y;
 
-    ErrorF("mieqPIE: head %p, tail %p\n", miEventQueue.head, miEventQueue.tail);
-
     while (miEventQueue.head != miEventQueue.tail)
     {
 	if (screenIsSaved == SCREEN_SAVER_ON)
@@ -234,7 +235,6 @@ void mieqProcessInputEvents ()
 	    	miEventQueue.head = 0;
 	    else
 	    	++miEventQueue.head;
-            ErrorF("calling pIP from mieqPIE\n");
             (*e->pDev->public.processInputProc)(e->event, e->pDev, e->nevents);
 	}
     }
diff-tree 463e0fe35bec3c91b19be9aacf34babb146a88c9 (from 1987af8c498a1bf394a8951ca6d5b0b7f7a35188)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Thu Jul 20 16:45:15 2006 -0400

    update KDrive to new input API
    
    Update KDrive to fit the new API (mieqInit and InitPointerDeviceStruct), and
    include InitTouchscreenDeviceStruct in the DIX.

diff --git a/dix/devices.c b/dix/devices.c
index a3ce178..52a0a0a 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -838,6 +838,27 @@ InitValuatorClassDeviceStruct(DeviceIntP
 }
 
 _X_EXPORT Bool
+InitTouchscreenClassDeviceStruct(DeviceIntPtr dev)
+{
+    register TouchscreenClassPtr tsc;
+
+    tsc = (TouchscreenClassPtr)xalloc(sizeof(TouchscreenClassRec));
+    if (!tsc)
+        return FALSE;
+
+    /* we don't do anything sensible with these, but should */
+    tsc->min_x = -1;
+    tsc->min_y = -1;
+    tsc->max_x = -1;
+    tsc->max_y = -1;
+
+    tsc->button_threshold = 0;
+    dev->touchscreen = tsc;
+
+    return TRUE;
+}
+
+_X_EXPORT Bool
 InitFocusClassDeviceStruct(DeviceIntPtr dev)
 {
     register FocusClassPtr focc;
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 94c3abd..13869c9 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -441,7 +441,7 @@ KdPointerProc(DeviceIntPtr pDevice, int 
 	InitPointerDeviceStruct(pDev, pi->map, pi->nButtons,
 	    miPointerGetMotionEvents,
 	    (PtrCtrlProcPtr)NoopDDA,
-	    miPointerGetMotionBufferSize());
+	    miPointerGetMotionBufferSize(), pi->nAxes);
 
 #ifdef XINPUT
         if (pi->inputClass == KD_TOUCHSCREEN) {
@@ -1280,7 +1280,7 @@ KdInitInput (void)
             ErrorF("Failed to add keyboard!\n");
     }
 
-    mieqInit(NULL, NULL);
+    mieqInit();
 }
 
 /*
diff-tree 1987af8c498a1bf394a8951ca6d5b0b7f7a35188 (from 737e6e4836a6af26fedc22cda8e7d366b52c8fa7)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Thu Jul 20 16:39:54 2006 -0400

    add virtual core devices to DIX
    
    Add virtual core devices, with proper keymaps etc, to the DIX.

diff --git a/dix/devices.c b/dix/devices.c
index 37720f3..a3ce178 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -80,6 +80,13 @@ SOFTWARE.
 #include "swaprep.h"
 #include "dixevents.h"
 
+#ifdef XINPUT
+#include <X11/extensions/XIproto.h>
+#include "exglobals.h"
+#endif
+
+int CoreDevicePrivatesIndex = 0, CoreDevicePrivatesGeneration = -1;
+
 DeviceIntPtr
 AddInputDevice(DeviceProc deviceProc, Bool autoStart)
 {
@@ -87,7 +94,7 @@ AddInputDevice(DeviceProc deviceProc, Bo
 
     if (inputInfo.numDevices >= MAX_DEVICES)
 	return (DeviceIntPtr)NULL;
-    dev = (DeviceIntPtr) xalloc(sizeof(DeviceIntRec));
+    dev = (DeviceIntPtr) xcalloc(sizeof(DeviceIntRec), 1);
     if (!dev)
 	return (DeviceIntPtr)NULL;
     dev->name = (char *)NULL;
@@ -113,19 +120,21 @@ AddInputDevice(DeviceProc deviceProc, Bo
     dev->button = (ButtonClassPtr)NULL;
     dev->focus = (FocusClassPtr)NULL;
     dev->proximity = (ProximityClassPtr)NULL;
+    dev->touchscreen = (TouchscreenClassPtr)NULL;
     dev->kbdfeed = (KbdFeedbackPtr)NULL;
     dev->ptrfeed = (PtrFeedbackPtr)NULL;
     dev->intfeed = (IntegerFeedbackPtr)NULL;
     dev->stringfeed = (StringFeedbackPtr)NULL;
     dev->bell = (BellFeedbackPtr)NULL;
     dev->leds = (LedFeedbackPtr)NULL;
-    dev->next = inputInfo.off_devices;
 #ifdef XKB
-    dev->xkb_interest= NULL;
+    dev->xkb_interest = NULL;
 #endif
     dev->nPrivates = 0;
     dev->devPrivates = NULL;
     dev->unwrapProc = NULL;
+    dev->coreEvents = TRUE;
+    dev->next = inputInfo.off_devices;
     inputInfo.off_devices = dev;
     return dev;
 }
@@ -134,14 +143,20 @@ Bool
 EnableDevice(register DeviceIntPtr dev)
 {
     register DeviceIntPtr *prev;
+    int ret;
 
     for (prev = &inputInfo.off_devices;
 	 *prev && (*prev != dev);
 	 prev = &(*prev)->next)
 	;
     if ((*prev != dev) || !dev->inited ||
-	((*dev->deviceProc)(dev, DEVICE_ON) != Success))
+	((ret = (*dev->deviceProc)(dev, DEVICE_ON)) != Success)) {
+        ErrorF("couldn't enable device %d\n", dev->id);
+#ifdef DEBUG
+        ErrorF("prev is %p, dev is %p, dev->inited is %d, ret is %d\n", prev, dev, dev->inited, ret);
+#endif
 	return FALSE;
+    }
     *prev = dev->next;
     dev->next = inputInfo.devices;
     inputInfo.devices = dev;
@@ -167,22 +182,220 @@ DisableDevice(register DeviceIntPtr dev)
 }
 
 int
+ActivateDevice(DeviceIntPtr dev)
+{
+    int ret = Success;
+#ifdef XINPUT
+    devicePresenceNotify ev;
+    DeviceIntRec dummyDev;
+#endif
+
+    if (!dev || !dev->deviceProc)
+        return BadImplementation;
+
+    ret = (*dev->deviceProc) (dev, DEVICE_INIT);
+    dev->inited = (ret == Success);
+    
+#ifdef XINPUT
+    ev.type = DevicePresenceNotify;
+    ev.time = currentTime.milliseconds;
+    dummyDev.id = 0;
+    SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
+                          &ev, 1);
+#endif
+
+    return ret;
+}
+
+static void
+CoreKeyboardBell(int volume, DeviceIntPtr pDev, pointer ctrl, int something)
+{
+    return;
+}
+
+static void
+CoreKeyboardCtl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
+{
+    return;
+}
+
+static int
+CoreKeyboardProc(DeviceIntPtr pDev, int what)
+{
+    CARD8 *modMap;
+    KeySymsRec keySyms;
+#ifdef XKB
+    XkbComponentNamesRec names;
+#endif
+
+    switch (what) {
+    case DEVICE_INIT:
+        keySyms.minKeyCode = 8;
+        keySyms.maxKeyCode = 255;
+        keySyms.mapWidth = 4;
+        keySyms.map = (KeySym *)xcalloc(sizeof(KeySym),
+                                        (keySyms.maxKeyCode -
+                                         keySyms.minKeyCode) *
+                                        keySyms.mapWidth);
+        if (!keySyms.map) {
+            ErrorF("Couldn't allocate core keymap\n");
+            return BadAlloc;
+        }
+
+        modMap = (CARD8 *)xalloc(MAP_LENGTH);
+        if (!modMap) {
+            ErrorF("Couldn't allocate core modifier map\n");
+            return BadAlloc;
+        }
+        bzero((char *)modMap, MAP_LENGTH);
+
+#ifdef XKB
+        if (!noXkbExtension) {
+            bzero(&names, sizeof(names));
+            XkbSetRulesDflts("base", "pc105", "us", NULL, NULL);
+            XkbInitKeyboardDeviceStruct(pDev, &names, &keySyms, modMap,
+                                        CoreKeyboardBell, CoreKeyboardCtl);
+        }
+        else
+#endif
+        InitKeyboardDeviceStruct((DevicePtr)pDev, &keySyms, modMap,
+                                 CoreKeyboardBell, CoreKeyboardCtl);
+        break;
+
+    case DEVICE_CLOSE:
+        /* This, uh, probably requires some explanation.
+         * Press a key on another keyboard.
+         * Watch its xkbInfo get pivoted into core's.
+         * Kill the server.
+         * Watch the first device's xkbInfo get freed.
+         * Try to free ours, which points to same.
+         *
+         * ... yeah.
+         */
+        pDev->key->xkbInfo = NULL;
+        break;
+
+    default:
+        break;
+    }
+    return Success;
+}
+
+static int
+CorePointerProc(DeviceIntPtr pDev, int what)
+{
+    BYTE map[33];
+    int i = 0;
+
+    switch (what) {
+    case DEVICE_INIT:
+        for (i = 1; i <= 32; i++)
+            map[i] = i;
+        /* we don't keep history, for now. */
+        InitPointerDeviceStruct((DevicePtr)pDev, map, 32,
+                                NULL, (PtrCtrlProcPtr)NoopDDA,
+                                0, 2);
+        pDev->valuator->axisVal[0] = screenInfo.screens[0]->width / 2;
+        pDev->valuator->lastx = pDev->valuator->axisVal[0];
+        pDev->valuator->axisVal[1] = screenInfo.screens[0]->height / 2;
+        pDev->valuator->lasty = pDev->valuator->axisVal[1];
+        break;
+
+    default:
+        break;
+    }
+
+    return Success;
+}
+
+void
+InitCoreDevices()
+{
+    register DeviceIntPtr dev;
+
+    if (CoreDevicePrivatesGeneration != serverGeneration) {
+        CoreDevicePrivatesIndex = AllocateDevicePrivateIndex();
+        CoreDevicePrivatesGeneration = serverGeneration;
+    }
+
+    if (!inputInfo.keyboard) {
+        dev = AddInputDevice(CoreKeyboardProc, TRUE);
+        if (!dev)
+            FatalError("Failed to allocate core keyboard");
+        dev->name = strdup("Virtual core keyboard");
+#ifdef XKB
+        dev->public.processInputProc = CoreProcessKeyboardEvent;
+        dev->public.realInputProc = CoreProcessKeyboardEvent;
+        if (!noXkbExtension)
+           XkbSetExtension(dev, ProcessKeyboardEvent);
+#else
+        dev->public.processInputProc = ProcessKeyboardEvent;
+        dev->public.realInputProc = ProcessKeyboardEvent;
+#endif
+        dev->ActivateGrab = ActivateKeyboardGrab;
+        dev->DeactivateGrab = DeactivateKeyboardGrab;
+        dev->coreEvents = FALSE;
+        if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex))
+            FatalError("Couldn't allocate keyboard devPrivates\n");
+        dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
+        (void)ActivateDevice(dev);
+        inputInfo.keyboard = dev;
+    }
+
+    if (!inputInfo.pointer) {
+        dev = AddInputDevice(CorePointerProc, TRUE);
+        if (!dev)
+            FatalError("Failed to allocate core pointer");
+        dev->name = strdup("Virtual core pointer");
+#ifdef XKB
+        dev->public.processInputProc = CoreProcessPointerEvent;
+        dev->public.realInputProc = CoreProcessPointerEvent;
+        if (!noXkbExtension)
+           XkbSetExtension(dev, ProcessPointerEvent);
+#else
+        dev->public.processInputProc = ProcessPointerEvent;
+        dev->public.realInputProc = ProcessPointerEvent;
+#endif
+        dev->ActivateGrab = ActivatePointerGrab;
+        dev->DeactivateGrab = DeactivatePointerGrab;
+        dev->coreEvents = FALSE;
+        if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex))
+            FatalError("Couldn't allocate pointer devPrivates\n");
+        dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
+        (void)ActivateDevice(dev);
+        inputInfo.pointer = dev;
+    }
+}
+
+int
 InitAndStartDevices()
 {
     register DeviceIntPtr dev, next;
 
-    for (dev = inputInfo.off_devices; dev; dev = dev->next)
-	dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+    for (dev = inputInfo.off_devices; dev; dev = dev->next) {
+#ifdef DEBUG
+        ErrorF("(dix) initialising device %d\n", dev->id);
+#endif
+	ActivateDevice(dev);
+#ifdef DEBUG
+        ErrorF("(dix) finished device %d, inited is %d\n", dev->id, dev->inited);
+#endif
+    }
     for (dev = inputInfo.off_devices; dev; dev = next)
     {
+#ifdef DEBUG
+        ErrorF("(dix) enabling device %d\n", dev->id);
+#endif
 	next = dev->next;
 	if (dev->inited && dev->startup)
 	    (void)EnableDevice(dev);
+#ifdef DEBUG
+        ErrorF("(dix) finished device %d\n", dev->id);
+#endif
     }
     for (dev = inputInfo.devices;
 	 dev && (dev != inputInfo.keyboard);
 	 dev = dev->next)
-	;
     if (!dev || (dev != inputInfo.keyboard)) {
 	ErrorF("No core keyboard\n");
 	return BadImplementation;
@@ -210,9 +423,10 @@ CloseDevice(register DeviceIntPtr dev)
 
     if (dev->inited)
 	(void)(*dev->deviceProc)(dev, DEVICE_CLOSE);
+
     xfree(dev->name);
-    if (dev->key)
-    {
+
+    if (dev->key) {
 #ifdef XKB
 	if (dev->key->xkbInfo)
 	    XkbFreeInfo(dev->key->xkbInfo);
@@ -221,20 +435,27 @@ CloseDevice(register DeviceIntPtr dev)
 	xfree(dev->key->modifierKeyMap);
 	xfree(dev->key);
     }
-    xfree(dev->valuator);
+
+    if (dev->valuator)
+        xfree(dev->valuator);
+
+    if (dev->button) {
 #ifdef XKB
-    if ((dev->button)&&(dev->button->xkb_acts))
-	xfree(dev->button->xkb_acts);
+        if (dev->button->xkb_acts)
+            xfree(dev->button->xkb_acts);
 #endif
-    xfree(dev->button);
-    if (dev->focus)
-    {
+        xfree(dev->button);
+    }
+
+    if (dev->focus) {
 	xfree(dev->focus->trace);
 	xfree(dev->focus);
     }
-    xfree(dev->proximity);
-    for (k=dev->kbdfeed; k; k=knext)
-    {
+
+    if (dev->proximity)
+        xfree(dev->proximity);
+
+    for (k = dev->kbdfeed; k; k = knext) {
 	knext = k->next;
 #ifdef XKB
 	if (k->xkb_sli)
@@ -242,30 +463,30 @@ CloseDevice(register DeviceIntPtr dev)
 #endif
 	xfree(k);
     }
-    for (p=dev->ptrfeed; p; p=pnext)
-    {
+
+    for (p = dev->ptrfeed; p; p = pnext) {
 	pnext = p->next;
 	xfree(p);
     }
-    for (i=dev->intfeed; i; i=inext)
-    {
+    
+    for (i = dev->intfeed; i; i = inext) {
 	inext = i->next;
 	xfree(i);
     }
-    for (s=dev->stringfeed; s; s=snext)
-    {
+
+    for (s = dev->stringfeed; s; s = snext) {
 	snext = s->next;
 	xfree(s->ctrl.symbols_supported);
 	xfree(s->ctrl.symbols_displayed);
 	xfree(s);
     }
-    for (b=dev->bell; b; b=bnext)
-    {
+
+    for (b = dev->bell; b; b = bnext) {
 	bnext = b->next;
 	xfree(b);
     }
-    for (l=dev->leds; l; l=lnext)
-    {
+
+    for (l = dev->leds; l; l = lnext) {
 	lnext = l->next;
 #ifdef XKB
 	if (l->xkb_sli)
@@ -273,11 +494,12 @@ CloseDevice(register DeviceIntPtr dev)
 #endif
 	xfree(l);
     }
+
 #ifdef XKB
-    while (dev->xkb_interest) {
+    while (dev->xkb_interest)
 	XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
-    }
 #endif
+
     xfree(dev->sync.event);
     xfree(dev);
 }
@@ -303,48 +525,78 @@ CloseDownDevices()
     inputInfo.pointer = NULL;
 }
 
-void
-RemoveDevice(register DeviceIntPtr dev)
+int
+RemoveDevice(DeviceIntPtr dev)
 {
-    register DeviceIntPtr prev,tmp,next;
+    DeviceIntPtr prev,tmp,next;
+    int ret = BadMatch;
+#ifdef XINPUT
+    devicePresenceNotify ev;
+    DeviceIntRec dummyDev;
+#endif
 
-    prev= NULL;
-    for (tmp= inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {
+#ifdef DEBUG
+    ErrorF("want to remove device %p, kb is %p, pointer is %p\n", dev, inputInfo.keyboard, inputInfo.pointer);
+#endif
+
+    if (!dev)
+        return BadImplementation;
+
+    prev = NULL;
+    for (tmp = inputInfo.devices; tmp; (prev = tmp), (tmp = next)) {
 	next = tmp->next;
-	if (tmp==dev) {
+	if (tmp == dev) {
 	    CloseDevice(tmp);
+
 	    if (prev==NULL)
 		inputInfo.devices = next;
 	    else
 		prev->next = next;
+
 	    inputInfo.numDevices--;
+
 	    if (inputInfo.keyboard == tmp)
 	        inputInfo.keyboard = NULL;
 	    else if (inputInfo.pointer == tmp)
 	        inputInfo.pointer = NULL;
-	    return;
+
+	    ret = Success;
 	}
     }
 
-    prev= NULL;
-    for (tmp= inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) {
+    prev = NULL;
+    for (tmp = inputInfo.off_devices; tmp; (prev = tmp), (tmp = next)) {
 	next = tmp->next;
-	if (tmp==dev) {
+	if (tmp == dev) {
 	    CloseDevice(tmp);
-	    if (prev==NULL)
+
+	    if (prev == NULL)
 		inputInfo.off_devices = next;
 	    else
 		prev->next = next;
+
 	    inputInfo.numDevices--;
+
 	    if (inputInfo.keyboard == tmp)
 	        inputInfo.keyboard = NULL;
 	    else if (inputInfo.pointer == tmp)
 	        inputInfo.pointer = NULL;
-	    return;
+
+            ret = Success;
 	}
     }
-    ErrorF("Internal Error! Attempt to remove a non-existent device\n");
-    return;
+    
+#ifdef XINPUT
+    if (ret == Success) {
+        ev.type = DevicePresenceNotify;
+        ev.time = currentTime.milliseconds;
+        dummyDev.id = 0;
+        SendEventToAllWindows(&dummyDev, DevicePresenceNotifyMask,
+                              &ev, 1);
+    }
+#endif
+
+    return ret;
 }
 
 int
@@ -356,47 +608,13 @@ NumMotionEvents()
 void
 RegisterPointerDevice(DeviceIntPtr device)
 {
-    inputInfo.pointer = device;
-#ifdef XKB
-    device->public.processInputProc = CoreProcessPointerEvent;
-    device->public.realInputProc = CoreProcessPointerEvent;
-    if (!noXkbExtension)
-       XkbSetExtension(device,ProcessPointerEvent);
-#else
-    device->public.processInputProc = ProcessPointerEvent;
-    device->public.realInputProc = ProcessPointerEvent;
-#endif
-    device->ActivateGrab = ActivatePointerGrab;
-    device->DeactivateGrab = DeactivatePointerGrab;
-    if (!device->name)
-    {
-	char *p = "pointer";
-	device->name = (char *)xalloc(strlen(p) + 1);
-	strcpy(device->name, p);
-    }
+    RegisterOtherDevice(device);
 }
 
 void
 RegisterKeyboardDevice(DeviceIntPtr device)
 {
-    inputInfo.keyboard = device;
-#ifdef XKB
-    device->public.processInputProc = CoreProcessKeyboardEvent;
-    device->public.realInputProc = CoreProcessKeyboardEvent;
-    if (!noXkbExtension)
-       XkbSetExtension(device,ProcessKeyboardEvent);
-#else
-    device->public.processInputProc = ProcessKeyboardEvent;
-    device->public.realInputProc = ProcessKeyboardEvent;
-#endif
-    device->ActivateGrab = ActivateKeyboardGrab;
-    device->DeactivateGrab = DeactivateKeyboardGrab;
-    if (!device->name)
-    {
-	char *k = "keyboard";
-	device->name = (char *)xalloc(strlen(k) + 1);
-	strcpy(device->name, k);
-    }
+    RegisterOtherDevice(device);
 }
 
 _X_EXPORT DevicePtr
@@ -441,8 +659,8 @@ SetKeySymsMap(register KeySymsPtr dst, r
 {
     int i, j;
     int rowDif = src->minKeyCode - dst->minKeyCode;
-           /* if keysym map size changes, grow map first */
 
+    /* if keysym map size changes, grow map first */
     if (src->mapWidth < dst->mapWidth)
     {
         for (i = src->minKeyCode; i <= src->maxKeyCode; i++)
@@ -532,7 +750,7 @@ InitKeyClassDeviceStruct(DeviceIntPtr de
 {
     int i;
     register KeyClassPtr keyc;
-
+    
     keyc = (KeyClassPtr)xalloc(sizeof(KeyClassRec));
     if (!keyc)
 	return FALSE;
@@ -808,12 +1026,13 @@ InitIntegerFeedbackClassDeviceStruct (De
 _X_EXPORT Bool
 InitPointerDeviceStruct(DevicePtr device, CARD8 *map, int numButtons, 
                         ValuatorMotionProcPtr motionProc, 
-                        PtrCtrlProcPtr controlProc, int numMotionEvents)
+                        PtrCtrlProcPtr controlProc, int numMotionEvents,
+                        int numAxes)
 {
     DeviceIntPtr dev = (DeviceIntPtr)device;
 
     return(InitButtonClassDeviceStruct(dev, numButtons, map) &&
-	   InitValuatorClassDeviceStruct(dev, 2, motionProc,
+	   InitValuatorClassDeviceStruct(dev, numAxes, motionProc,
 					 numMotionEvents, 0) &&
 	   InitPtrFeedbackClassDeviceStruct(dev, controlProc));
 }
diff --git a/dix/events.c b/dix/events.c
index 1b0aee5..fac492c 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -134,6 +134,7 @@ of the copyright holder.
 #include "globals.h"
 
 #ifdef XKB
+#include <X11/extensions/XKBproto.h>
 #include <X11/extensions/XKBsrv.h>
 extern Bool XkbFilterEvents(ClientPtr, int, xEvent *);
 #endif
@@ -159,14 +160,13 @@ xEvent *xeviexE;
 #include <X11/extensions/XIproto.h>
 #include "exglobals.h"
 #include "exevents.h"
+#include "exglobals.h"
 #include "extnsionst.h"
 
 #include "dixevents.h"
 #include "dixgrabs.h"
 #include "dispatch.h"
 
-int CoreDevicePrivatesIndex = 0, CoreDevicePrivatesGeneration = -1;
-
 #define EXTENSION_EVENT_BASE  64
 
 #define NoSuchEvent 0x80000000	/* so doesn't match NoEventMask */
diff --git a/dix/main.c b/dix/main.c
index e186e89..5ac8f18 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -398,6 +398,7 @@ main(int argc, char *argv[], char *envp[
 	    if (!CreateRootWindow(pScreen))
 		FatalError("failed to create root window");
 	}
+        InitCoreDevices();
 	InitInput(argc, argv);
 	if (InitAndStartDevices() != Success)
 	    FatalError("failed to initialize core devices");
diff --git a/include/input.h b/include/input.h
index d550bbe..36d8038 100644
--- a/include/input.h
+++ b/include/input.h
@@ -176,6 +176,9 @@ extern DeviceIntPtr AddInputDevice(
 extern Bool EnableDevice(
     DeviceIntPtr /*device*/);
 
+extern Bool ActivateDevice(
+    DeviceIntPtr /*device*/);
+
 extern Bool DisableDevice(
     DeviceIntPtr /*device*/);
 
@@ -183,7 +186,7 @@ extern int InitAndStartDevices(void);
 
 extern void CloseDownDevices(void);
 
-extern void RemoveDevice(
+extern int RemoveDevice(
     DeviceIntPtr /*dev*/);
 
 extern int NumMotionEvents(void);
@@ -233,6 +236,9 @@ extern Bool InitValuatorClassDeviceStruc
     int /*numMotionEvents*/,
     int /*mode*/);
 
+extern Bool InitTouchscreenClassDeviceStruct(
+    DeviceIntPtr /*device*/);
+
 extern Bool InitFocusClassDeviceStruct(
     DeviceIntPtr /*device*/);
 
@@ -302,7 +308,8 @@ extern Bool InitPointerDeviceStruct(
     int /*numButtons*/,
     ValuatorMotionProcPtr /*motionProc*/,
     PtrCtrlProcPtr /*controlProc*/,
-    int /*numMotionEvents*/);
+    int /*numMotionEvents*/,
+    int /*numAxes*/);
 
 extern Bool InitKeyboardDeviceStruct(
     DevicePtr /*device*/,
diff --git a/include/inputstr.h b/include/inputstr.h
index 8b877bc..9e293f0 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -68,6 +68,8 @@ SOFTWARE.
 #define POINTER_ABSOLUTE (1 << 2)
 #define POINTER_ACCELERATE (1 << 3)
 
+extern int CoreDevicePrivatesIndex, CoreDevicePrivatesGeneration;
+
 /* Kludge: OtherClients and InputClients must be compatible, see code */
 
 typedef struct _OtherClients {
diff --git a/mi/mi.h b/mi/mi.h
index 2de5233..d350f1c 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -171,8 +171,7 @@ typedef struct _DeviceRec *DevicePtr;
 #endif
 
 extern Bool mieqInit(
-    DevicePtr /*pKbd*/,
-    DevicePtr /*pPtr*/
+    void
 );
 
 extern void mieqEnqueue(
diff --git a/mi/mieq.c b/mi/mieq.c
index 3766262..b05210c 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -43,35 +43,38 @@ in this Software without prior written a
 # include   "pixmapstr.h"
 # include   "inputstr.h"
 # include   "mi.h"
+# include   "mipointer.h"
 # include   "scrnintstr.h"
+# include   <X11/extensions/XI.h>
+# include   <X11/extensions/XIproto.h>
+# include   "extinit.h"
+# include   "exglobals.h"
 
 #define QUEUE_SIZE  256
 
 typedef struct _Event {
-    xEvent	event;
-    ScreenPtr	pScreen;
+    xEvent          event[2];
+    int             nevents;
+    ScreenPtr	    pScreen;
+    DeviceIntPtr    pDev;
 } EventRec, *EventPtr;
 
 typedef struct _EventQueue {
-    HWEventQueueType	head, tail;	    /* long for SetInputCheck */
-    CARD32	lastEventTime;	    /* to avoid time running backwards */
-    Bool	lastMotion;
-    EventRec	events[QUEUE_SIZE]; /* static allocation for signals */
-    DevicePtr	pKbd, pPtr;	    /* device pointer, to get funcs */
-    ScreenPtr	pEnqueueScreen;	    /* screen events are being delivered to */
-    ScreenPtr	pDequeueScreen;	    /* screen events are being dispatched to */
+    HWEventQueueType head, tail;         /* long for SetInputCheck */
+    CARD32           lastEventTime;      /* to avoid time running backwards */
+    int              lastMotion;         /* device ID if last event motion? */
+    EventRec         events[QUEUE_SIZE]; /* static allocation for signals */
+    ScreenPtr        pEnqueueScreen;     /* screen events are being delivered to */
+    ScreenPtr        pDequeueScreen;     /* screen events are being dispatched to */
 } EventQueueRec, *EventQueuePtr;
 
 static EventQueueRec miEventQueue;
 
 Bool
-mieqInit (pKbd, pPtr)
-    DevicePtr	pKbd, pPtr;
+mieqInit ()
 {
     miEventQueue.head = miEventQueue.tail = 0;
     miEventQueue.lastEventTime = GetTimeInMillis ();
-    miEventQueue.pKbd = pKbd;
-    miEventQueue.pPtr = pPtr;
     miEventQueue.lastMotion = FALSE;
     miEventQueue.pEnqueueScreen = screenInfo.screens[0];
     miEventQueue.pDequeueScreen = miEventQueue.pEnqueueScreen;
@@ -87,32 +90,83 @@ mieqInit (pKbd, pPtr)
  */
 
 void
-mieqEnqueue (e)
-    xEvent	*e;
+mieqEnqueue (xEvent *e)
 {
-    HWEventQueueType	oldtail, newtail;
-    Bool    isMotion;
+    HWEventQueueType       oldtail = miEventQueue.tail, newtail;
+    int                    isMotion = 0;
+    DeviceIntPtr           pDev = NULL;
+    deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) e;
+    deviceValuator         *v = (deviceValuator *) e;
+    EventPtr               laste = &miEventQueue.events[oldtail - 1];
+    deviceKeyButtonPointer *lastkbp = (deviceKeyButtonPointer *)
+                                      &laste->event[0];
+
+    ErrorF("mieqEnqueue: slamming an event on to the queue from %d\n", kbp->deviceid & DEVICE_BITS);
+    if (e->u.u.type == MotionNotify) {
+        miPointerAbsoluteCursor(e->u.keyButtonPointer.rootX,
+                                e->u.keyButtonPointer.rootY,
+                                e->u.keyButtonPointer.time);
+        pDev = inputInfo.pointer;
+        isMotion = inputInfo.pointer->id & DEVICE_BITS;
+    }
+    else if (e->u.u.type == KeyPress || e->u.u.type == KeyRelease) {
+        pDev = inputInfo.keyboard;
+    }
+    else if (e->u.u.type == ButtonPress || e->u.u.type == ButtonRelease) {
+        pDev = inputInfo.pointer;
+    }
+    else {
+        pDev = LookupDeviceIntRec(kbp->deviceid & DEVICE_BITS);
 
-    oldtail = miEventQueue.tail;
-    isMotion = e->u.u.type == MotionNotify;
-    if (isMotion && miEventQueue.lastMotion && oldtail != miEventQueue.head)
-    {
+        /* We silently steal valuator events: just tack them on to the last
+         * motion event they need to be attached to.  Sigh. */
+        if (e->u.u.type == DeviceValuator) {
+            if (laste->nevents >= 6) {
+                ErrorF("mieqEnqueue: more than six valuator events; dropping.\n");
+                return;
+            }
+            if (oldtail == miEventQueue.head || 
+                !(lastkbp->type == DeviceMotionNotify ||
+                  lastkbp->type == DeviceButtonPress ||
+                  lastkbp->type == DeviceButtonRelease) ||
+                ((lastkbp->deviceid & DEVICE_BITS) !=
+                 (v->deviceid & DEVICE_BITS))) {
+                ErrorF("mieqEnequeue: out-of-order valuator event; dropping.\n");
+                return;
+            }
+            laste->event[laste->nevents++] = *e;
+            ErrorF("put a valuator event into the queue\n");
+            return;
+        }
+        else if (e->u.u.type == DeviceMotionNotify) {
+            isMotion = pDev->id & DEVICE_BITS;
+        }
+    }
+
+    if (!pDev)
+        FatalError("Couldn't find device for event!\n");
+
+    if (isMotion && isMotion == miEventQueue.lastMotion &&
+        oldtail != miEventQueue.head) {
 	if (oldtail == 0)
 	    oldtail = QUEUE_SIZE;
 	oldtail = oldtail - 1;
     }
-    else
-    {
+    else {
     	newtail = oldtail + 1;
     	if (newtail == QUEUE_SIZE)
 	    newtail = 0;
     	/* Toss events which come in late */
-    	if (newtail == miEventQueue.head)
+    	if (newtail == miEventQueue.head) {
+            ErrorF("tossed event which came in late\n");
 	    return;
+        }
 	miEventQueue.tail = newtail;
     }
-    miEventQueue.lastMotion = isMotion;
-    miEventQueue.events[oldtail].event = *e;
+
+    miEventQueue.events[oldtail].event[0] = *e;
+    miEventQueue.events[oldtail].nevents = 1;
+
     /*
      * Make sure that event times don't go backwards - this
      * is "unnecessary", but very useful
@@ -120,18 +174,23 @@ mieqEnqueue (e)
     if (e->u.keyButtonPointer.time < miEventQueue.lastEventTime &&
 	miEventQueue.lastEventTime - e->u.keyButtonPointer.time < 10000)
     {
-	miEventQueue.events[oldtail].event.u.keyButtonPointer.time =
+        ErrorF("mieq: rewinding event time from %d to %d\n",
+               miEventQueue.lastEventTime,
+               miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time);
+	miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time =
 	    miEventQueue.lastEventTime;
     }
     miEventQueue.lastEventTime =
-	miEventQueue.events[oldtail].event.u.keyButtonPointer.time;
+	miEventQueue.events[oldtail].event[0].u.keyButtonPointer.time;
     miEventQueue.events[oldtail].pScreen = miEventQueue.pEnqueueScreen;
+    miEventQueue.events[oldtail].pDev = pDev;
+
+    miEventQueue.lastMotion = isMotion;
+    ErrorF("bottom of mieqEnqueue\n");
 }
 
 void
-mieqSwitchScreen (pScreen, fromDIX)
-    ScreenPtr	pScreen;
-    Bool	fromDIX;
+mieqSwitchScreen (ScreenPtr pScreen, Bool fromDIX)
 {
     miEventQueue.pEnqueueScreen = pScreen;
     if (fromDIX)
@@ -146,7 +205,8 @@ void mieqProcessInputEvents ()
 {
     EventRec	*e;
     int		x, y;
-    xEvent	xe;
+
+    ErrorF("mieqPIE: head %p, tail %p\n", miEventQueue.head, miEventQueue.tail);
 
     while (miEventQueue.head != miEventQueue.tail)
     {
@@ -160,8 +220,8 @@ void mieqProcessInputEvents ()
 	if (e->pScreen != miEventQueue.pDequeueScreen)
 	{
 	    miEventQueue.pDequeueScreen = e->pScreen;
-	    x = e->event.u.keyButtonPointer.rootX;
-	    y = e->event.u.keyButtonPointer.rootY;
+	    x = e->event[0].u.keyButtonPointer.rootX;
+	    y = e->event[0].u.keyButtonPointer.rootY;
 	    if (miEventQueue.head == QUEUE_SIZE - 1)
 	    	miEventQueue.head = 0;
 	    else
@@ -170,23 +230,12 @@ void mieqProcessInputEvents ()
 	}
 	else
 	{
-	    xe = e->event;
 	    if (miEventQueue.head == QUEUE_SIZE - 1)
 	    	miEventQueue.head = 0;
 	    else
 	    	++miEventQueue.head;
-	    switch (xe.u.u.type) 
-	    {
-	    case KeyPress:
-	    case KeyRelease:
-	    	(*miEventQueue.pKbd->processInputProc)
-				(&xe, (DeviceIntPtr)miEventQueue.pKbd, 1);
-	    	break;
-	    default:
-	    	(*miEventQueue.pPtr->processInputProc)
-				(&xe, (DeviceIntPtr)miEventQueue.pPtr, 1);
-	    	break;
-	    }
+            ErrorF("calling pIP from mieqPIE\n");
+            (*e->pDev->public.processInputProc)(e->event, e->pDev, e->nevents);
 	}
     }
 }
diff --git a/mi/mipointer.c b/mi/mipointer.c
index 4602d47..f52116f 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -490,12 +490,6 @@ miPointerMove (pScreen, x, y, time)
     miPointer.y = y;
     miPointer.pScreen = pScreen;
 
-    xE.u.u.type = MotionNotify;
-    xE.u.keyButtonPointer.rootX = x;
-    xE.u.keyButtonPointer.rootY = y;
-    xE.u.keyButtonPointer.time = time;
-    (*pScreenPriv->screenFuncs->EnqueueEvent) (&xE);
-
     end = miPointer.history_end;
     start = miPointer.history_start;
     prev = end - 1;
@@ -521,11 +515,3 @@ miPointerMove (pScreen, x, y, time)
     history->event.time = time;
     history->pScreen = pScreen;
 }
-
-void
-miRegisterPointerDevice (pScreen, pDevice)
-    ScreenPtr	pScreen;
-    DeviceIntPtr pDevice;
-{
-    miPointer.pPointer = (DevicePtr)pDevice;
-}
diff --git a/mi/mipointrst.h b/mi/mipointrst.h
index 682f8ac..feeb5ec 100644
--- a/mi/mipointrst.h
+++ b/mi/mipointrst.h
@@ -50,7 +50,6 @@ typedef struct {
     Bool		    confined;	/* pointer can't change screens */
     int			    x, y;	/* hot spot location */
     int			    devx, devy;	/* sprite position */
-    DevicePtr		    pPointer;   /* pointer device structure */
     miHistoryRec	    history[MOTION_SIZE];
     int			    history_start, history_end;
 } miPointerRec, *miPointerPtr;
diff-tree 737e6e4836a6af26fedc22cda8e7d366b52c8fa7 (from 7f36cc533e7f6ae44e973c5f00f9bfec7c6b7b50)
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Wed Jul 19 20:10:48 2006 -0400

    define SDevicePresenceNotifyEvent prototype

diff --git a/include/extinit.h b/include/extinit.h
index 37fa9a2..c471008 100644
--- a/include/extinit.h
+++ b/include/extinit.h
@@ -105,6 +105,12 @@ SDeviceMappingNotifyEvent (
 	);
 
 void
+SDevicePresenceNotifyEvent (
+       devicePresenceNotify * /* from */,
+       devicePresenceNotify * /* to */
+       );
+
+void
 FixExtensionEvents (
 	ExtensionEntry 	*      /* extEntry */
 	);
diff-tree 7f36cc533e7f6ae44e973c5f00f9bfec7c6b7b50 (from e896195eab726a2b307200958308eda8c93dd3cd)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Jul 19 20:09:13 2006 -0400

    distribute config.h

diff --git a/include/Makefile.am b/include/Makefile.am
index 9e340d7..9f07fa6 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -7,6 +7,7 @@ sdk_HEADERS =		\
 	closure.h	\
 	colormap.h	\
 	colormapst.h	\
+	config.h	\
 	cursor.h	\
 	cursorstr.h	\
 	dix.h		\
diff-tree e896195eab726a2b307200958308eda8c93dd3cd (from 99c57674c002c5e88c6db34488a27b05004c9197)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Wed Jul 19 20:05:33 2006 -0400

    remove extraneous font debugging code
    
    Some of it didn't compile, and some of it was just unnecessary.

diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index ef23fa8..1f5b3b4 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -158,11 +158,6 @@ QueueFontWakeup(FontPathElementPtr fpe)
 
     for (i = 0; i < num_slept_fpes; i++) {
 	if (slept_fpes[i] == fpe) {
-
-#ifdef DEBUG
-	    fprintf(stderr, "re-queueing fpe wakeup\n");
-#endif
-
 	    return;
 	}
     }
@@ -2063,11 +2058,6 @@ init_fs_handlers(FontPathElementPtr fpe,
 	fs_handlers_installed = 0;
     }
     if (fs_handlers_installed == 0) {
-
-#ifdef DEBUG
-	fprintf(stderr, "adding FS b & w handlers\n");
-#endif
-
 	if (!RegisterBlockAndWakeupHandlers(block_handler,
 					    FontWakeup, (pointer) 0))
 	    return AllocError;
@@ -2083,55 +2073,9 @@ remove_fs_handlers(FontPathElementPtr fp
     if (all) {
 	/* remove the handlers if no one else is using them */
 	if (--fs_handlers_installed == 0) {
-
-#ifdef DEBUG
-	    fprintf(stderr, "removing FS b & w handlers\n");
-#endif
-
 	    RemoveBlockAndWakeupHandlers(block_handler, FontWakeup,
 					 (pointer) 0);
 	}
     }
     RemoveFontWakeup(fpe);
 }
-
-#ifdef DEBUG
-#define GLWIDTHBYTESPADDED(bits,nbytes) \
-	((nbytes) == 1 ? (((bits)+7)>>3)        /* pad to 1 byte */ \
-	:(nbytes) == 2 ? ((((bits)+15)>>3)&~1)  /* pad to 2 bytes */ \
-	:(nbytes) == 4 ? ((((bits)+31)>>3)&~3)  /* pad to 4 bytes */ \
-	:(nbytes) == 8 ? ((((bits)+63)>>3)&~7)  /* pad to 8 bytes */ \
-	: 0)
-
-#define GLYPH_SIZE(ch, nbytes)          \
-	GLWIDTHBYTESPADDED((ch)->metrics.rightSideBearing - \
-			(ch)->metrics.leftSideBearing, (nbytes))
-void
-dump_char_ascii(CharInfoPtr cip)
-{
-    int         r,
-                l;
-    int         bpr;
-    int         byte;
-    static unsigned maskTab[] = {
-	(1 << 7), (1 << 6), (1 << 5), (1 << 4),
-	(1 << 3), (1 << 2), (1 << 1), (1 << 0),
-    };
-
-    bpr = GLYPH_SIZE(cip, 4);
-    for (r = 0; r < (cip->metrics.ascent + cip->metrics.descent); r++) {
-	pointer     row = (pointer) cip->bits + r * bpr;
-
-	byte = 0;
-	for (l = 0; l <= (cip->metrics.rightSideBearing -
-			  cip->metrics.leftSideBearing); l++) {
-	    if (maskTab[l & 7] & row[l >> 3])
-		putchar('X');
-	    else
-		putchar('.');
-	}
-	putchar('\n');
-    }
-}
-
-#endif
diff-tree 99c57674c002c5e88c6db34488a27b05004c9197 (from ecfad74c48f633916305bcc25baaaad74aa52b78)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Wed Jul 19 19:59:11 2006 -0400

    avoid using font servers with built-in fonts

diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 14164fb..2cf9eaf 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -442,4 +442,7 @@
 /* Use only built-in fonts */
 #undef BUILTIN_FONTS
 
+/* Avoid using font servers */
+#undef NOFONTSERVERACCESS
+
 #endif /* _DIX_CONFIG_H_ */
diff-tree ecfad74c48f633916305bcc25baaaad74aa52b78 (from 0a2068d123520d35818c38a555ae3ba06d8ca7fb)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Wed Jul 19 19:55:13 2006 -0400

    add support for built-in fonts
    
    Use --enable-builtin-fonts to only use built-in fonts, and avoid loading
    fonts.

diff --git a/configure.ac b/configure.ac
index 7a97970..815f1f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -392,6 +392,9 @@ AC_ARG_ENABLE(install-libxf86config,
 				[Install libxf86config (default: disabled)]),
 				[INSTALL_LIBXF86CONFIG=$enableval],
 				[INSTALL_LIBXF86CONFIG=no])
+AC_ARG_ENABLE(builtin-fonts,  AS_HELP_STRING([--enable-builtin-fonts], [Use only built-in fonts (default: use external)]),
+                                [BUILTIN_FONTS=$enableval],
+                                [BUILTIN_FONTS=no])
 
 dnl Extensions.
 AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
@@ -710,6 +713,11 @@ if test "x$XPRINT" = xyes; then
 	REQUIRED_MODULES="$REQUIRED_MODULES printproto"
 fi
 
+if test "x$BUILTIN_FONTS" = xyes; then
+       AC_DEFINE(BUILTIN_FONTS, 1, [Use only built-in fonts])
+       AC_DEFINE(NOFONTSERVERACCESS, 1, [Avoid using a font server])
+fi
+
 AC_DEFINE(RENDER, 1, [Support RENDER extension])
 RENDER_LIB='$(top_builddir)/render/librender.la'
 RENDER_INC='-I$(top_srcdir)/render'
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index cb0df3c..ef23fa8 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1889,7 +1889,7 @@ InitFonts ()
 {
     patternCache = MakeFontPatternCache();
 
-#ifndef KDRIVESERVER
+#ifndef BUILTIN_FONTS
     if (screenInfo.numScreens > screenInfo.numVideoScreens) {
 	PrinterFontRegisterFpeFunctions();
 	FontFileCheckRegisterFpeFunctions();
@@ -1897,10 +1897,11 @@ InitFonts ()
     } else 
 #endif
     {
-#ifdef KDRIVESERVER
-	BuiltinRegisterFpeFunctions();
-#endif
+#ifdef BUILTIN_FONTS
+        BuiltinRegisterFpeFunctions();
+#else
 	FontFileRegisterFpeFunctions();
+#endif
 #ifndef NOFONTSERVERACCESS
 	fs_register_fpe_functions();
 #endif
diff --git a/dix/main.c b/dix/main.c
index 5f53989..e186e89 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -403,9 +403,14 @@ main(int argc, char *argv[], char *envp[
 	    FatalError("failed to initialize core devices");
 
 	InitFonts();
+#ifdef BUILTIN_FONTS
+        defaultFontPath = "built-ins";
+#else
 	if (loadableFonts) {
 	    SetFontPath(0, 0, (unsigned char *)defaultFontPath, &error);
-	} else {
+	} else 
+#endif
+        {
 	    if (SetDefaultFontPath(defaultFontPath) != Success)
 		ErrorF("failed to set default font path '%s'",
 			defaultFontPath);
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 72a329c..14164fb 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -439,4 +439,7 @@
 /* Support D-BUS */
 #undef HAVE_DBUS
 
+/* Use only built-in fonts */
+#undef BUILTIN_FONTS
+
 #endif /* _DIX_CONFIG_H_ */
diff-tree 0a2068d123520d35818c38a555ae3ba06d8ca7fb (from c7577f9b88aac84d59404f29d994ee7af583d33b)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Wed Jul 19 17:29:23 2006 -0400

    Xi: add XExtension{Keyboard,Pointer} types
    
    Report XExtensionKeyboard for non-core keyboards, and XExtensionPointer for
    non-core pointers/mice.

diff --git a/Xi/listdev.c b/Xi/listdev.c
index 13e5ca7..91e8f22 100644
--- a/Xi/listdev.c
+++ b/Xi/listdev.c
@@ -241,6 +241,10 @@ CopySwapDevice(register ClientPtr client
 	dev->use = IsXKeyboard;
     else if (d == inputInfo.pointer)
 	dev->use = IsXPointer;
+    else if (d->key && d->kbdfeed)
+        dev->use = IsXExtensionKeyboard;
+    else if (d->valuator && d->button)
+        dev->use = IsXExtensionPointer;
     else
 	dev->use = IsXExtensionDevice;
     if (client->swapped) {
diff-tree c7577f9b88aac84d59404f29d994ee7af583d33b (from 3a23e499017d5823157806029263edac53c663fd)
Author: Kristian Høgsberg <krh at redhat.com>
Date:   Wed Jul 19 17:27:58 2006 -0400

    Xi: add DevicePresenceNotify
    
    Add support for DevicePresenceNotify events.

diff --git a/Xi/exglobals.h b/Xi/exglobals.h
index c64b848..3afd1bb 100644
--- a/Xi/exglobals.h
+++ b/Xi/exglobals.h
@@ -51,6 +51,7 @@ extern Mask DeviceMappingNotifyMask;
 extern Mask DeviceOwnerGrabButtonMask;
 extern Mask DeviceButtonGrabMask;
 extern Mask DeviceButtonMotionMask;
+extern Mask DevicePresenceNotifyMask;
 extern Mask PropagateMask[];
 
 extern int DeviceValuator;
@@ -68,12 +69,8 @@ extern int DeviceKeyStateNotify;
 extern int DeviceButtonStateNotify;
 extern int DeviceMappingNotify;
 extern int ChangeDeviceNotify;
+extern int DevicePresenceNotify;
 
 extern int RT_INPUTCLIENT;
 
-#if 0
-/* FIXME: in dix */
-extern InputInfo inputInfo;
-#endif
-
 #endif /* EXGLOBALS_H */
diff --git a/Xi/extinit.c b/Xi/extinit.c
index f3aabe3..c1ba462 100644
--- a/Xi/extinit.c
+++ b/Xi/extinit.c
@@ -166,6 +166,7 @@ Mask DeviceMappingNotifyMask;
 Mask DeviceOwnerGrabButtonMask;
 Mask DeviceButtonGrabMask;
 Mask DeviceButtonMotionMask;
+Mask DevicePresenceNotifyMask;
 
 int DeviceValuator;
 int DeviceKeyPress;
@@ -182,6 +183,7 @@ int DeviceKeyStateNotify;
 int DeviceButtonStateNotify;
 int DeviceMappingNotify;
 int ChangeDeviceNotify;
+int DevicePresenceNotify;
 
 int RT_INPUTCLIENT;
 
@@ -202,8 +204,8 @@ Mask PropagateMask[MAX_DEVICES];
  */
 
 static XExtensionVersion thisversion = { XI_Present,
-    XI_Add_XChangeDeviceControl_Major,
-    XI_Add_XChangeDeviceControl_Minor
+    XI_Add_DevicePresenceNotify_Major,
+    XI_Add_DevicePresenceNotify_Minor
 };
 
 /**********************************************************************
@@ -648,6 +650,16 @@ SDeviceMappingNotifyEvent(deviceMappingN
     swapl(&to->time, n);
 }
 
+void
+SDevicePresenceNotifyEvent (devicePresenceNotify *from, devicePresenceNotify *to)
+{
+    register char n;
+
+    *to = *from;
+    swaps(&to->sequenceNumber,n);
+    swapl(&to->time, n);
+}
+
 /************************************************************************
  *
  * This function sets up extension event types and masks.
@@ -674,6 +686,7 @@ FixExtensionEvents(ExtensionEntry * extE
     ChangeDeviceNotify = DeviceMappingNotify + 1;
     DeviceKeyStateNotify = ChangeDeviceNotify + 1;
     DeviceButtonStateNotify = DeviceKeyStateNotify + 1;
+    DevicePresenceNotify = DeviceButtonStateNotify + 1;
 
     event_base[KeyClass] = DeviceKeyPress;
     event_base[ButtonClass] = DeviceButtonPress;
@@ -746,6 +759,9 @@ FixExtensionEvents(ExtensionEntry * extE
 
     DeviceOwnerGrabButtonMask = GetNextExtEventMask();
     SetEventInfo(DeviceOwnerGrabButtonMask, _deviceOwnerGrabButton);
+
+    DevicePresenceNotifyMask = GetNextExtEventMask();
+    SetEventInfo(DevicePresenceNotifyMask, _devicePresence);
     SetEventInfo(0, _noExtensionEvent);
 }
 
@@ -786,6 +802,7 @@ RestoreExtensionEvents(void)
     ChangeDeviceNotify = 12;
     DeviceKeyStateNotify = 13;
     DeviceButtonStateNotify = 13;
+    DevicePresenceNotify = 14;
 
     BadDevice = 0;
     BadEvent = 1;
@@ -823,6 +840,7 @@ IResetProc(ExtensionEntry * unused)
     EventSwapVector[DeviceButtonStateNotify] = NotImplemented;
     EventSwapVector[DeviceMappingNotify] = NotImplemented;
     EventSwapVector[ChangeDeviceNotify] = NotImplemented;
+    EventSwapVector[DevicePresenceNotify] = NotImplemented;
     RestoreExtensionEvents();
 }
 
@@ -857,9 +875,7 @@ MakeDeviceTypeAtoms(void)
 }
 
 /**************************************************************************
- *
  * Return a DeviceIntPtr corresponding to a specified device id.
- * This will not return the pointer or keyboard, or devices that are not on.
  *
  */
 
@@ -869,13 +885,16 @@ LookupDeviceIntRec(CARD8 id)
     DeviceIntPtr dev;
 
     for (dev = inputInfo.devices; dev; dev = dev->next) {
-	if (dev->id == id) {
-	    if (id == inputInfo.pointer->id || id == inputInfo.keyboard->id)
-		return (NULL);
-	    return (dev);
-	}
+	if (dev->id == id)
+	    return dev;
     }
-    return (NULL);
+
+    for (dev = inputInfo.off_devices; dev; dev = dev->next) {
+	if (dev->id == id)
+	    return dev;
+    }
+
+    return NULL;
 }
 
 /**************************************************************************
diff --git a/Xi/selectev.c b/Xi/selectev.c
index 3483804..1f6713a 100644
--- a/Xi/selectev.c
+++ b/Xi/selectev.c
@@ -74,6 +74,53 @@ SOFTWARE.
 extern Mask ExtExclusiveMasks[];
 extern Mask ExtValidMasks[];
 
+static int
+HandleDevicePresenceMask(ClientPtr client, WindowPtr win,
+                         XEventClass *cls, CARD16 *count)
+{
+    int i, j;
+    Mask mask;
+
+    /* We use the device ID 256 to select events that aren't bound to
+     * any device.  For now we only handle the device presence event,
+     * but this could be extended to other events that aren't bound to
+     * a device.
+     *
+     * In order not to break in CreateMaskFromList() we remove the
+     * entries with device ID 256 from the XEventClass array.
+     */
+
+    mask = 0;
+    for (i = 0, j = 0; i < *count; i++) {
+        if (cls[i] >> 8 != 256) {
+            cls[j] = cls[i];
+            j++;
+            continue;
+        }
+
+        switch (cls[i] & 0xff) {
+        case _devicePresence:
+            mask |= DevicePresenceNotifyMask;
+            break;
+        }
+    }
+
+    *count = j;
+
+    if (mask == 0)
+        return Success;
+
+    /* We always only use mksidx = 0 for events not bound to
+     * devices */
+
+    if (AddExtensionClient (win, client, mask, 0) != Success)
+        return BadAlloc;
+
+    RecalculateDeviceDeliverableEvents(win);
+
+    return Success;
+}
+
 /***********************************************************************
  *
  * Handle requests from clients with a different byte order.
@@ -131,6 +178,13 @@ ProcXSelectExtensionEvent(register Clien
 	return Success;
     }
 
+    if (HandleDevicePresenceMask(client, pWin, (XEventClass *) & stuff[i],
+                                &stuff->count) != Success) {
+       SendErrorToClient(client, IReqCode, X_SelectExtensionEvent, 0,
+                         BadAlloc);
+       return Success;
+    }
+
     if ((ret = CreateMaskFromList(client, (XEventClass *) & stuff[1],
 				  stuff->count, tmp, NULL,
 				  X_SelectExtensionEvent)) != Success)
diff-tree 3a23e499017d5823157806029263edac53c663fd (from 02d09105113fb9b560a770fe15f7bb041165831c)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Wed Jul 19 17:00:23 2006 -0400

    make XInput mandatory
    
    Always build Xi, since GetPointerEvents/GetKeyboardEvents relies on it.

diff --git a/Makefile.am b/Makefile.am
index 799815e..eebdd0a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -26,10 +26,6 @@ if GLX
 GLX_DIR=GL
 endif
 
-if XINPUT
-XINPUT_DIR=Xi
-endif
-
 if DBE
 DBE_DIR=dbe
 endif
@@ -45,7 +41,7 @@ SUBDIRS = \
 	os \
 	randr \
 	render  \
-	$(XINPUT_DIR) \
+	Xi \
 	xkb \
 	$(DBE_DIR) \
 	$(MFB_DIR) \
diff --git a/configure.ac b/configure.ac
index 186f2f9..7a97970 100644
--- a/configure.ac
+++ b/configure.ac
@@ -422,7 +422,6 @@ AC_ARG_ENABLE(fontcache,      AS_HELP_ST
 AC_ARG_ENABLE(dbe,            AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes])
 AC_ARG_ENABLE(xf86bigfont,    AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big Font extension (default: enabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=yes])
 AC_ARG_ENABLE(dpms,           AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes])
-AC_ARG_ENABLE(xinput,         AS_HELP_STRING([--disable-xinput], [Build XInput Extension (default: enabled)]), [XINPUT=$enableval], [XINPUT=yes])
 AC_ARG_ENABLE(dbus,           AS_HELP_STRING([--disable-dbus], [Build D-BUS support (default: auto)]), [DBUS=$enableval], [DBUS=auto])
 
 dnl DDXes.
@@ -733,12 +732,9 @@ if test "$COMPOSITE" = yes; then
 fi
 MIEXT_DAMAGE_INC='-I$(top_srcdir)/miext/damage'
 
-AM_CONDITIONAL(XINPUT, [test "x$XINPUT" = xyes])
-if test "x$XINPUT" = xyes; then
-   	AC_DEFINE(XINPUT, 1, [Support X Input extension])
-	XI_LIB='$(top_builddir)/Xi/libXi.la'
-	XI_INC='-I$(top_srcdir)/Xi'
-fi
+AC_DEFINE(XINPUT, 1, [Support X Input extension])
+XI_LIB='$(top_builddir)/Xi/libXi.la'
+XI_INC='-I$(top_srcdir)/Xi'
 
 AC_DEFINE(SHAPE, 1, [Support SHAPE extension])
 
diff-tree 02d09105113fb9b560a770fe15f7bb041165831c (from a274e7296b1bdd6f6c921f28b087610cec9548e0)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Wed Jul 19 16:51:04 2006 -0400

    new KDrive input world order
    
    Convert KDrive to GPE/GKE interface.
    Add first-class drivers and enumerate every device separately through
    Xi, instead of lamely attempting to aggregate them.
    Add XKB support to the Linux keyboard driver.
    Add 'thumb button' support to the tslib driver.
    Rejig InitInput, so each DDX has to add a list of drivers it supports.
    Support NewInputDeviceRequest, et al.

diff --git a/configure.ac b/configure.ac
index 41536f7..186f2f9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -439,6 +439,9 @@ dnl kdrive and its subsystems
 AC_ARG_ENABLE(kdrive,         AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no])
 AC_ARG_ENABLE(xephyr,         AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto])
 AC_ARG_ENABLE(xsdl,           AS_HELP_STRING([--enable-xsdl], [Build the kdrive Xsdl server (default: auto)]), [XSDL=$enableval], [XSDL=auto])
+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])
+AC_ARG_ENABLE(kdrive-vesa,    AS_HELP_STRING([--enable-kdrive-vesa], [Build the kdrive VESA-based servers (default: auto)]), [KDRIVEVESA=$enableval], [KDRIVEVESA=auto])
 dnl xprint
 AC_ARG_ENABLE(freetype,       AS_HELP_STRING([ --enable-freetype], [Build Xprint FreeType backend (default: yes)]), [XP_USE_FREETYPE=$enableval],[XP_USE_FREETYPE=no])
 AC_ARG_WITH(freetype-config,  AS_HELP_STRING([ --with-freetype-config=PROG], [Use FreeType configuration program PROG (default: auto)]), freetype_config=$withval, freetype_config=auto)
@@ -510,7 +513,7 @@ XEXT_LIB='$(top_builddir)/Xext/libXext.l
 XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
 
 dnl Core modules for most extensions, et al.
-REQUIRED_MODULES="randrproto renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto xproto xtrans xf86miscproto xf86vidmodeproto xf86bigfontproto [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto inputproto xf86dgaproto"
+REQUIRED_MODULES="randrproto renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto xproto xtrans [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto [inputproto >= 1.4]"
 REQUIRED_LIBS="xfont xau fontenc"
 
 if test "x$DBUS" = xauto; then
@@ -824,11 +827,35 @@ AC_DEFINE(DDXOSINIT, 1, [Use OsVendorIni
 AC_DEFINE(SERVER_LOCK, 1, [Use a lock to prevent multiple servers on a display])
 AC_DEFINE(SMART_SCHEDULE, 1, [Include time-based scheduler])
 AC_DEFINE(NO_LIBCWRAPPER, 1, [Define to 1 if modules should avoid the libcwrapper])
-AM_CONDITIONAL(DEBUG, test "x$DEBUGGING" = xyes)
 
-if ! test "x$DEBUGGING" = xyes; then
-  AC_DEFINE(NDEBUG, 1, [Disable some debugging code])
+if test "x$DEBUGGING" = xyes; then
+       AC_DEFINE(DEBUG, 1, [Enable debugging code])
+else
+       AC_DEFINE(NDEBUG, 1, [Disable some debugging code])
+fi
+AM_CONDITIONAL(DEBUG, [test "x$DEBUGGING" = xyes])
+
+# The Xorg binary needs to export symbols so that they can be used from modules
+# Some platforms require extra flags to do this.   gcc should set these flags
+# when -rdynamic is passed to it, other compilers/linkers may need to be added
+# here.
+if test "x$GCC" = "xyes"; then
+       GCC_WARNINGS1="-Wall -Wpointer-arith -Wstrict-prototypes"
+       GCC_WARNINGS2="-Wmissing-prototypes -Wmissing-declarations"
+       GCC_WARNINGS3="-Wnested-externs -fno-strict-aliasing"
+       GCC_WARNINGS="$GCC_WARNINGS1 $GCC_WARNINGS2 $GCC_WARNINGS3"
+       if test "x$WERROR" = "xyes"; then
+               GCC_WARNINGS="${GCC_WARNINGS} -Werror"
+       fi
+       XSERVER_CFLAGS="$GCC_WARNINGS $XSERVER_CFLAGS"
+       LD_EXPORT_SYMBOLS_FLAG="-rdynamic"
 fi
+case $host_os in
+       openbsd*)
+       LD_EXPORT_SYMBOLS_FLAG="-Wl,--export-dynamic"
+       ;;
+esac
+AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])
 
 AC_DEFINE(USE_RGB_TXT, 1, [Use rgb.txt directly])
 AC_DEFINE(MITMISC, 1, [Support MIT Misc extension])
@@ -1038,6 +1065,14 @@ if test "x$XORG" = xyes -o "x$XGL" = xye
 	XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
 	XORG_LIBS="$COMPOSITE_LIB $MI_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XPSTUBS_LIB $OS_LIB"
 
+        AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension])
+        AC_DEFINE(XF86MISC, 1, [Support XFree86 miscellaneous extensions])
+
+        XORG_MODULES="xf86miscproto xf86vidmodeproto xf86dgaproto"
+        PKG_CHECK_MODULES(XORG_MODULES, [$XORG_MODULES])
+        XORG_CFLAGS="$XORG_CFLAGS $XORG_MODULES_CFLAGS"
+        XORG_LIBS="$XORG_LIBS $XORG_MODULES_LIBS"
+
 dnl Check to see if dlopen is in default libraries (like Solaris, which
 dnl has it in libc), or if libdl is needed to get it.
 	AC_CHECK_FUNC([dlopen], [], 
@@ -1229,28 +1264,7 @@ int main () { 
 	fi
 	AC_SUBST(PERL)
 
-	# The Xorg binary needs to export symbols so that they can be used from modules
-	# Some platforms require extra flags to do this.   gcc should set these flags
-	# when -rdynamic is passed to it, other compilers/linkers may need to be added
-	# here.
-	if test "x$GCC" = "xyes"; then
-		GCC_WARNINGS1="-Wall -Wpointer-arith -Wstrict-prototypes"
-		GCC_WARNINGS2="-Wmissing-prototypes -Wmissing-declarations"
-		GCC_WARNINGS3="-Wnested-externs -fno-strict-aliasing"
-		GCC_WARNINGS="$GCC_WARNINGS1 $GCC_WARNINGS2 $GCC_WARNINGS3"
-		if test "x$WERROR" = "xyes"; then
-			GCC_WARNINGS="${GCC_WARNINGS} -Werror"
-		fi
-		XSERVER_CFLAGS="$GCC_WARNINGS $XSERVER_CFLAGS"
-		LD_EXPORT_SYMBOLS_FLAG="-rdynamic"
-	fi
-	case $host_os in
-		openbsd*)
-		LD_EXPORT_SYMBOLS_FLAG="-Wl,--export-dynamic"
-		;;
-	esac
 	AC_SUBST([XORG_CFLAGS])
-	AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])
 
 	dnl these only go in xorg-config.h
 	XF86CONFIGFILE="xorg.conf"
@@ -1438,16 +1452,58 @@ if test "$KDRIVE" = yes; then
     AC_DEFINE(KDRIVEDDXACTIONS,,[Build kdrive ddx])
 
     AC_CHECK_HEADERS([sys/vm86.h sys/io.h])
-    if test "$ac_cv_header_sys_vm86_h" = yes; then
+    if test "$ac_cv_header_sys_vm86_h" = yes && test "x$KDRIVEVESA" = xauto; then
+        KDRIVEVESA=yes
+    fi
+
+    if test "x$KDRIVEVESA" = xyes; then
+        KDRIVEFBDEVLIB=yes
         AC_DEFINE(KDRIVEVESA, 1, [Build VESA-based kdrive servers])
     fi
 
     AC_CHECK_HEADERS([linux/fb.h])
-    if test "$ac_cv_header_linux_fb_h" = yes; then
+    if test "$ac_cv_header_linux_fb_h" = yes && test "x$XFBDEV" = xauto; then
+        XFBDEV=yes
+    fi
+
+    if test "x$XFBDEV" = xyes; then
+        KDRIVEFBDEVLIB=yes
         AC_DEFINE(KDRIVEFBDEV, 1, [Build fbdev-based kdrive server])
     fi
     
     # tslib...
+    AC_CHECK_LIB(ts, ts_open, [HAVE_TSLIB="yes"])
+    if test "x$TSLIB" = xauto && test "x$HAVE_TSLIB" = xyes; then
+        TSLIB=yes
+    fi
+
+    if test "x$TSLIB" = xyes; then
+        if ! test "x$HAVE_TSLIB" = xyes; then
+            AC_MSG_ERROR([tslib must be installed to build the tslib input driver.])
+        fi
+        TSLIB_LIBS="-lts"
+        AC_DEFINE(TSLIB, 1, [Have tslib support])
+    fi
+
+    if test x"$ac_cv_header_SDL_SDL_h" = xyes && "x$XSDL" = xauto; then
+       XSDL=yes
+    fi
+
+    if test x"$XSDL" = xyes; then
+       # PKG_CHECK_MODULES(XSDL_EXTRA, Xfont xau $XDMCP_MODULES)
+       AC_DEFINE(XSDLSERVER,1,[Build Xsdl server])
+       XSDL_LIBS="`sdl-config --libs` $XSERVER_LIBS"
+       XSDL_INCS="`sdl-config --cflags` $XSERVER_CFLAGS"
+    fi
+
+    PKG_CHECK_MODULES(XEPHYR, x11 xext xfont xau xdmcp, [xephyr="yes"], [xephyr="no"])
+    if test "x$XEPHYR" = xauto; then
+       XEPHYR=xephyr
+    fi
+    # Xephyr needs nanosleep() which is in librt on Solaris
+    AC_CHECK_FUNC([nanosleep], [],
+        AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
+    XEPHYR_LIBS="$XEPHYR_LIBS $XSERVER_LIBS"
 
     # damage shadow extension glx (NOTYET) fb mi
     KDRIVE_INC='-I$(top_srcdir)/hw/kdrive/src'
@@ -1460,48 +1516,38 @@ if test "$KDRIVE" = yes; then
     # dix os fb mi extension glx (NOTYET) damage shadow xpstubs
     #KDRIVE_PURE_LIBS="$DIX_LIB $OS_LIB $FB_LIB $XEXT_LIB $MIEXT_DAMAGE_LIB \
     #    $MIEXT_SHADOW_LIB $XPSTUBS_LIB"
-    KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $OS_LIB"
+    KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $TSLIB_LIBS $DBE_LIB $XTRAP_LIB $RECORD_LIB $GLX_LIBS $RENDER_LIB $RANDR_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $XPSTUBS_LIB $OS_LIB"
     KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.a'
     KDRIVE_OS_LIB='$(top_builddir)/hw/kdrive/linux/liblinux.a'
     KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.a'
-    KDRIVE_LIBS="$DIX_LIB $CONFIG_LIB $KDRIVE_LIB $KDRIVE_OS_LIB $KDRIVE_PURE_LIBS $KDRIVE_STUB_LIB"
+    KDRIVE_LIBS="$XSERVERLIBS_LIBS $DIX_LIB $CONFIG_LIB $KDRIVE_LIB $KDRIVE_OS_LIB $KDRIVE_PURE_LIBS $KDRIVE_STUB_LIB"
 
     # check if we can build Xephyr
     PKG_CHECK_MODULES(XEPHYR, x11 xext xfont xau xdmcp, [xephyr="yes"], [xephyr="no"])
-    
-    # check for SDL SDK
-    AC_CHECK_HEADERS([SDL/SDL.h])
-fi
-AC_SUBST(KDRIVE_INCS)
-AC_SUBST(KDRIVE_PURE_INCS)
-AC_SUBST(KDRIVE_CFLAGS)
-AC_SUBST(KDRIVE_PURE_LIBS)
-AC_SUBST(KDRIVE_LIBS)
-AM_CONDITIONAL(TSLIB, false)
+    XEPHYR_LIBS="$XEPHYR_LIBS $XSERVER_LIBS"
+
+    # Xephyr needs nanosleep() which is in librt on Solaris
+    AC_CHECK_FUNC([nanosleep], [],
+        AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
+
+    AC_SUBST([XEPHYR_LIBS])
+    AC_SUBST([XEPHYR_INCS])
+    AC_SUBST([XSDL_LIBS])
+    AC_SUBST([XSDL_INCS])
+fi
+AC_SUBST([KDRIVE_INCS])
+AC_SUBST([KDRIVE_PURE_INCS])
+AC_SUBST([KDRIVE_CFLAGS])
+AC_SUBST([KDRIVE_PURE_LIBS])
+AC_SUBST([KDRIVE_LIBS])
+AM_CONDITIONAL(TSLIB, [test "x$TSLIB" = xyes])
 AM_CONDITIONAL(H3600_TS, false)
-AM_CONDITIONAL(KDRIVEVESA, [test x"$ac_cv_header_sys_vm86_h" = xyes])
-AM_CONDITIONAL(KDRIVEFBDEV, [test x"$ac_cv_header_linux_fb_h" = xyes])
-#AM_CONDITIONAL(KDRIVEVESA, false)
-#AM_CONDITIONAL(KDRIVEFBDEV, false)
-
-# Xephyr needs nanosleep() which is in librt on Solaris
-AC_CHECK_FUNC([nanosleep], [],
-	AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
-
-AM_CONDITIONAL(XEPHYR, [test x"$xephyr" = xyes])
-XEPHYR_LIBS="$XEPHYR_LIBS $XSERVER_LIBS"
-AC_SUBST([XEPHYR_LIBS])
-AC_SUBST([XEPHYR_INCS])
-
-AM_CONDITIONAL(XSDLSERVER, [test x"$ac_cv_header_SDL_SDL_h" = xyes])
-if test x"$ac_cv_header_SDL_SDL_h" = xyes -o x"$XSDL" = xyes; then
-    # PKG_CHECK_MODULES(XSDL_EXTRA, Xfont xau $XDMCP_MODULES)
-    AC_DEFINE(XSDLSERVER,,[Build Xsdl server])
-    XSDL_LIBS="`sdl-config --libs` $XSERVER_LIBS"
-    XSDL_INCS="`sdl-config --cflags` $XSERVER_CFLAGS"
-fi
-AC_SUBST([XSDL_LIBS])
-AC_SUBST([XSDL_INCS])
+AM_CONDITIONAL(KDRIVEVESA, [test "x$KDRIVEVESA" = xyes])
+AM_CONDITIONAL(KDRIVEFBDEV, [test "x$XFBDEV" = xyes])
+AM_CONDITIONAL(XSDLSERVER, [test x"$XSDL" = xyes])
+AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$xephyr" = xyes])
+AM_CONDITIONAL(BUILD_KDRIVEFBDEVLIB, [test "x$KDRIVE" = xyes && test "x$KDRIVEFBDEVLIB" = xyes])
+AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
 
 
 dnl these only go in xkb-config.h (which is shared by the Xorg and Xnest servers)
@@ -1510,7 +1556,6 @@ AC_DEFINE_DIR(XKB_BASE_DIRECTORY, XKBPAT
 AC_DEFINE_DIR(XKB_BIN_DIRECTORY, bindir, [Path to XKB bin dir])
 
 # Make sure XKM_OUTPUT_DIR is an absolute path
-
 XKBOUTPUT_FIRSTCHAR=`echo $XKBOUTPUT | cut -b 1`
 
 if [[ x$XKBOUTPUT_FIRSTCHAR != x/ ]] ; then
@@ -1549,15 +1594,21 @@ esac
 AC_DEFINE_DIR(PROJECTROOT, prefix, [Overall prefix])
 
 dnl xorgconfig CLI configuration utility
-PKG_CHECK_MODULES([XORGCONFIG_DEP], [xkbfile x11])
-AC_SUBST(XORGCONFIG_DEP_CFLAGS)
-AC_SUBST(XORGCONFIG_DEP_LIBS)
+if test "x$XORG" = xyes; then
+    PKG_CHECK_MODULES([XORGCONFIG_DEP], [xkbfile x11])
+    AC_SUBST(XORGCONFIG_DEP_CFLAGS)
+    AC_SUBST(XORGCONFIG_DEP_LIBS)
+fi
 
 dnl xorgcfg GUI configuration utility
 AC_ARG_ENABLE(xorgcfg, AS_HELP_STRING([--enable-xorgcfg], 
-	[Build xorgcfg GUI configuration utility (default: yes)]),
-	[XORGCFG=$enableval],[XORGCFG=yes])
-if test x$XORGCFG = xyes ; then
+	[Build xorgcfg GUI configuration utility (default: auto)]),
+	[XORGCFG=$enableval],[XORGCFG=auto])
+if test "x$XORGCFG" = xauto && test "x$XORG" = xyes; then
+    XORGCFG=yes
+fi
+
+if test "x$XORGCFG" = xyes; then
 	PKG_CHECK_MODULES([XORGCFG_DEP], 
 	    [xkbui >= 1.0.2 xkbfile xxf86misc xxf86vm xaw7 xmu xt xpm xext x11])
 	AC_CHECK_LIB([curses],[waddstr],
diff --git a/hw/kdrive/Makefile.am b/hw/kdrive/Makefile.am
index c8832eb..fa1dba9 100644
--- a/hw/kdrive/Makefile.am
+++ b/hw/kdrive/Makefile.am
@@ -3,10 +3,14 @@ VESA_SUBDIRS = vesa ati chips epson i810
                smi via
 endif
 
-if KDRIVEFBDEV
+if BUILD_KDRIVEFBDEVLIB
 FBDEV_SUBDIRS = fbdev
 endif
 
+if XFAKESERVER
+XFAKE_SUBDIRS = fake
+endif
+
 if XSDLSERVER
 XSDL_SUBDIRS = sdl
 endif
@@ -22,7 +26,7 @@ SUBDIRS =			\
 	$(FBDEV_SUBDIRS)	\
 	$(VESA_SUBDIRS)		\
 	$(XEPHYR_SUBDIRS)       \
-	fake
+	$(XFAKE_SUBDIRS)
 
 DIST_SUBDIRS = vesa ati chips epson i810 mach64 mga neomagic nvidia pm2 r128 \
                smi via fbdev sdl ephyr src linux fake sis300
diff --git a/hw/kdrive/ati/ati_stub.c b/hw/kdrive/ati/ati_stub.c
index 01ebc31..d0bc4ca 100644
--- a/hw/kdrive/ati/ati_stub.c
+++ b/hw/kdrive/ati/ati_stub.c
@@ -53,7 +53,15 @@ InitOutput(ScreenInfo *pScreenInfo, int 
 void
 InitInput(int argc, char **argv)
 {
-	KdInitInput(&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+        KdKeyboardInfo *ki = NULL;
+        
+        KdAddPointerDriver(&LinuxMouseDriver);
+        ki = KdNewKeyboard();
+        if (ki) {
+            ki->driver = &LinuxKeyboardDriver;
+            KdAddKeyboard(ki);
+        }
+	KdInitInput();
 }
 
 void
diff --git a/hw/kdrive/ephyr/Makefile.am b/hw/kdrive/ephyr/Makefile.am
index f423bfe..6982d80 100644
--- a/hw/kdrive/ephyr/Makefile.am
+++ b/hw/kdrive/ephyr/Makefile.am
@@ -33,7 +33,6 @@ Xephyr_LDADD = 						\
 	libxephyr-hostx.a			        \
 	../../../exa/libexa.la				\
 	@KDRIVE_LIBS@					\
-	@KDRIVE_LIBS@					\
         $(TSLIB_LIBS)                                   \
         @XEPHYR_LIBS@
 
diff --git a/hw/kdrive/ephyr/ephyr.c b/hw/kdrive/ephyr/ephyr.c
index fbb16a4..92fd831 100644
--- a/hw/kdrive/ephyr/ephyr.c
+++ b/hw/kdrive/ephyr/ephyr.c
@@ -36,10 +36,16 @@
 #include "inputstr.h"
 
 extern int KdTsPhyScreen;
-extern DeviceIntPtr pKdKeyboard;
+KdKeyboardInfo *ephyrKbd;
+KdPointerInfo *ephyrMouse;
+EphyrKeySyms ephyrKeySyms;
 
 static int mouseState = 0;
 
+typedef struct _EphyrInputPrivate {
+    Bool    enabled;
+} EphyrKbdPrivate, EphyrPointerPrivate;
+
 Bool   EphyrWantGrayScale = 0;
 
 Bool
@@ -206,15 +212,14 @@ ephyrMapFramebuffer (KdScreenInfo *scree
 {
   EphyrScrPriv  *scrpriv = screen->driver;
   EphyrPriv	  *priv    = screen->card->driver;
-  KdMouseMatrix m;
+  KdPointerMatrix m;
   int buffer_height;
   
   EPHYR_DBG(" screen->width: %d, screen->height: %d",
 	    screen->width, screen->height);
   
-  KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height);
-    
-  KdSetMouseMatrix (&m);
+  KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
+  KdSetPointerMatrix (&m);
   
   priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2;
   
@@ -719,8 +724,9 @@ ephyrUpdateModifierState(unsigned int st
 		kptr = &keyc->down[key >> 3];
 		bit = 1 << (key & 7);
 		
-		if (*kptr & bit)
-		  KdEnqueueKeyboardEvent(key, TRUE); /* release */
+		if (*kptr & bit && ephyrKbd &&
+                    ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+		  KdEnqueueKeyboardEvent(ephyrKbd, key, TRUE); /* release */
 		
 		if (--count == 0)
 		  break;
@@ -732,7 +738,9 @@ ephyrUpdateModifierState(unsigned int st
 	for (key = 0; key < MAP_LENGTH; key++)
 	  if (keyc->modifierMap[key] & mask) 
 	    {
-	      KdEnqueueKeyboardEvent(key, FALSE); /* press */
+              if (keyc->modifierMap[key] & mask && ephyrKbd &&
+                  ((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+	          KdEnqueueKeyboardEvent(ephyrKbd, key, FALSE); /* press */
 	      break;
 	    }
     }
@@ -748,31 +756,47 @@ ephyrPoll(void)
       switch (ev.type)
 	{
 	case EPHYR_EV_MOUSE_MOTION:
-	  KdEnqueueMouseEvent(kdMouseInfo, mouseState,  
-			      ev.data.mouse_motion.x, 
-			      ev.data.mouse_motion.y);
+          if (!ephyrMouse ||
+              !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled)
+              continue;
+	  KdEnqueuePointerEvent(ephyrMouse, mouseState,  
+			        ev.data.mouse_motion.x, 
+			        ev.data.mouse_motion.y,
+                                0);
 	  break;
 	  
 	case EPHYR_EV_MOUSE_PRESS:
+          if (!ephyrMouse ||
+              !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled)
+              continue;
 	  ephyrUpdateModifierState(ev.key_state);
 	  mouseState |= ev.data.mouse_down.button_num;
-	  KdEnqueueMouseEvent(kdMouseInfo, mouseState|KD_MOUSE_DELTA, 0, 0);
+	  KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
 	  break;
 
 	case EPHYR_EV_MOUSE_RELEASE:
+          if (!ephyrMouse ||
+              !((EphyrPointerPrivate *)ephyrMouse->driverPrivate)->enabled)
+              continue;
 	  ephyrUpdateModifierState(ev.key_state);
 	  mouseState &= ~ev.data.mouse_up.button_num;
-	  KdEnqueueMouseEvent(kdMouseInfo, mouseState|KD_MOUSE_DELTA, 0, 0);
+	  KdEnqueuePointerEvent(ephyrMouse, mouseState|KD_MOUSE_DELTA, 0, 0, 0);
 	  break;
 
 	case EPHYR_EV_KEY_PRESS:
+          if (!ephyrKbd ||
+              !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+              continue;
 	  ephyrUpdateModifierState(ev.key_state);
-	  KdEnqueueKeyboardEvent (ev.data.key_down.scancode, FALSE);
+	  KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_down.scancode, FALSE);
 	  break;
 
 	case EPHYR_EV_KEY_RELEASE:
+          if (!ephyrKbd ||
+              !((EphyrKbdPrivate *)ephyrKbd->driverPrivate)->enabled)
+              continue;
 	  ephyrUpdateModifierState(ev.key_state);
-	  KdEnqueueKeyboardEvent (ev.data.key_up.scancode, TRUE);
+	  KdEnqueueKeyboardEvent (ephyrKbd, ev.data.key_up.scancode, TRUE);
 	  break;
 
 	default:
@@ -833,59 +857,115 @@ ephyrPutColors (ScreenPtr pScreen, int f
 
 /* Mouse calls */
 
-static Bool
-MouseInit (void)
+static Status
+MouseInit (KdPointerInfo *pi)
+{
+    pi->driverPrivate = (EphyrPointerPrivate *)
+                         xcalloc(sizeof(EphyrPointerPrivate), 1);
+    ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
+    ephyrMouse = pi;
+    /* FIXME DO NOT COMMIT */
+    KdAddPointerDriver(&EphyrMouseDriver);
+    ErrorF("SUCCESS!\n");
+    return Success;
+}
+
+static Status
+MouseEnable (KdPointerInfo *pi)
+{
+    ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = TRUE;
+    ErrorF("SUCCESS ENABLE!\n");
+    return Success;
+}
+
+static void
+MouseDisable (KdPointerInfo *pi)
 {
-    return TRUE;
+    ((EphyrPointerPrivate *)pi->driverPrivate)->enabled = FALSE;
+    return;
 }
 
 static void
-MouseFini (void)
+MouseFini (KdPointerInfo *pi)
 {
-  ;
+    ephyrMouse = NULL; 
+    return;
 }
 
-KdMouseFuncs EphyrMouseFuncs = {
+KdPointerDriver EphyrMouseDriver = {
+    "ephyr",
     MouseInit,
+    MouseEnable,
+    MouseDisable,
     MouseFini,
+    NULL,
 };
 
 /* Keyboard */
 
-static void
-EphyrKeyboardLoad (void)
+static Status
+EphyrKeyboardInit (KdKeyboardInfo *ki)
 {
-  EPHYR_DBG("mark");
+  ki->driverPrivate = (EphyrKbdPrivate *)
+                       xcalloc(sizeof(EphyrKbdPrivate), 1);
+  /* FIXME blah blah overrunning memory blah blah */
+  ki->minScanCode = ki->keySyms.minKeyCode = 0;
+  ki->maxScanCode = ki->keySyms.maxKeyCode = 255;
+  ephyrKbd = ki;
+  return Success;
+}
+
+static Status
+EphyrKeyboardEnable (KdKeyboardInfo *ki)
+{
+    hostx_load_keymap();
+    if (!ephyrKeySyms.map) {
+        ErrorF("Couldn't load keymap from host\n");
+        return BadAlloc;
+    }
+    ki->keySyms.minKeyCode = ephyrKeySyms.minKeyCode;
+    ki->keySyms.maxKeyCode = ephyrKeySyms.maxKeyCode;
+    ki->minScanCode = ki->keySyms.minKeyCode;
+    ki->maxScanCode = ki->keySyms.maxKeyCode;
+    ki->keySyms.mapWidth = ephyrKeySyms.mapWidth;
+    ki->keySyms.map = ephyrKeySyms.map;
+    ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = TRUE;
 
-  hostx_load_keymap();
+    return Success;
 }
 
-static int
-EphyrKeyboardInit (void)
+static void
+EphyrKeyboardDisable (KdKeyboardInfo *ki)
 {
-  return 0;
+    ((EphyrKbdPrivate *)ki->driverPrivate)->enabled = FALSE;
 }
 
 static void
-EphyrKeyboardFini (void)
+EphyrKeyboardFini (KdKeyboardInfo *ki)
 {
+    /* not xfree: we call malloc from hostx.c. */
+    free(ki->keySyms.map);
+    ephyrKbd = NULL;
+    return;
 }
 
 static void
-EphyrKeyboardLeds (int leds)
+EphyrKeyboardLeds (KdKeyboardInfo *ki, int leds)
 {
 }
 
 static void
-EphyrKeyboardBell (int volume, int frequency, int duration)
+EphyrKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration)
 {
 }
 
-KdKeyboardFuncs	EphyrKeyboardFuncs = {
-    EphyrKeyboardLoad,
+KdKeyboardDriver EphyrKeyboardDriver = {
+    "ephyr",
     EphyrKeyboardInit,
+    EphyrKeyboardEnable,
     EphyrKeyboardLeds,
     EphyrKeyboardBell,
+    EphyrKeyboardDisable,
     EphyrKeyboardFini,
-    0,
+    NULL,
 };
diff --git a/hw/kdrive/ephyr/ephyr.h b/hw/kdrive/ephyr/ephyr.h
index 707cb01..f49d920 100644
--- a/hw/kdrive/ephyr/ephyr.h
+++ b/hw/kdrive/ephyr/ephyr.h
@@ -31,7 +31,6 @@
 
 #include "os.h"  		/* for OsSignal() */
 #include "kdrive.h"
-#include "kkeymap.h"
 #include "hostx.h"
 #include "exa.h"
 
@@ -68,7 +67,9 @@ typedef struct _ephyrScrPriv {
     EphyrFakexaPriv *fakexa;
 } EphyrScrPriv;
 
-extern KdCardFuncs  ephyrFuncs;
+extern KdCardFuncs ephyrFuncs;
+extern KdKeyboardInfo *ephyrKbd;
+extern KdPointerInfo *ephyrMouse;
 
 Bool
 ephyrInitialize (KdCardInfo *card, EphyrPriv *priv);
@@ -167,9 +168,9 @@ ephyrShadowUpdate (ScreenPtr pScreen, sh
 void
 ephyrUpdateModifierState(unsigned int state);
 
-extern KdMouseFuncs EphyrMouseFuncs;
+extern KdPointerDriver EphyrMouseDriver;
 
-extern KdKeyboardFuncs	EphyrKeyboardFuncs;
+extern KdKeyboardDriver	EphyrKeyboardDriver;
 
 extern KdOsFuncs   EphyrOsFuncs;
 
diff --git a/hw/kdrive/ephyr/ephyrinit.c b/hw/kdrive/ephyr/ephyrinit.c
index 1aa608e..021abd6 100644
--- a/hw/kdrive/ephyr/ephyrinit.c
+++ b/hw/kdrive/ephyr/ephyrinit.c
@@ -51,7 +51,24 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-  KdInitInput (&EphyrMouseFuncs, &EphyrKeyboardFuncs);
+  KdKeyboardInfo *ki;
+  KdPointerInfo *pi;
+        
+  ki = KdNewKeyboard();
+  if (!ki)
+    FatalError("Couldn't create Xephyr keyboard\n");
+  ki->driver = &EphyrKeyboardDriver;
+  ki->name = KdSaveString("Xephyr virtual keyboard");
+  KdAddKeyboard(ki);
+
+  pi = KdNewPointer();
+  if (!pi)
+    FatalError("Couldn't create Xephyr pointer\n");
+  pi->driver = &EphyrMouseDriver;
+  pi->name = KdSaveString("Xephyr virtual mouse");
+  KdAddPointer(pi);
+
+  KdInitInput();
 }
 
 void
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 32a46dc..b23532f 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -77,14 +77,8 @@ static EphyrHostXVars HostX = { "?", 0,0
 
 static int            HostXWantDamageDebug = 0;
 
-extern KeySym         EphyrKeymap[];
+extern EphyrKeySyms   ephyrKeySyms;
 
-extern KeySym	      kdKeymap[];
-extern int	      kdMinScanCode;
-extern int	      kdMaxScanCode;
-extern int	      kdMinKeyCode;
-extern int	      kdMaxKeyCode;
-extern int	      kdKeymapWidth;
 extern int            monitorResolution;
 
 static void
@@ -403,9 +397,9 @@ hostx_get_bpp(void)
 }
 
 void
-hostx_get_visual_masks (unsigned long *rmsk, 
-			unsigned long *gmsk, 
-			unsigned long *bmsk)
+hostx_get_visual_masks (CARD32 *rmsk, 
+			CARD32 *gmsk, 
+			CARD32 *bmsk)
 {
   if (host_depth_matches_server())
     {
@@ -681,6 +675,13 @@ hostx_load_keymap(void)
 			       max_keycode - min_keycode + 1,
 			       &host_width);
 
+
+  ephyrKeySyms.map = (KeySym *)calloc(sizeof(KeySym),
+                                      (max_keycode - min_keycode + 1) *
+                                      width);
+  if (!ephyrKeySyms.map)
+        return;
+  
   /* Try and copy the hosts keymap into our keymap to avoid loads
    * of messing around.
    *
@@ -695,13 +696,9 @@ hostx_load_keymap(void)
 
   EPHYR_DBG("keymap width, host:%d kdrive:%d", host_width, width);
   
-  /* all kdrive vars - see kkeymap.c */
-
-  kdMinScanCode = min_keycode;
-  kdMaxScanCode = max_keycode;
-  kdMinKeyCode  = min_keycode;
-  kdMaxKeyCode  = max_keycode;
-  kdKeymapWidth = width;
+  ephyrKeySyms.minKeyCode  = min_keycode;
+  ephyrKeySyms.maxKeyCode  = max_keycode;
+  ephyrKeySyms.mapWidth    = (width > 4) ? 4 : width;
 
   XFree(keymap);
 }
diff --git a/hw/kdrive/ephyr/hostx.h b/hw/kdrive/ephyr/hostx.h
index d3f6da3..4e3c6af 100644
--- a/hw/kdrive/ephyr/hostx.h
+++ b/hw/kdrive/ephyr/hostx.h
@@ -26,6 +26,9 @@
 #ifndef _XLIBS_STUFF_H_
 #define _XLIBS_STUFF_H_
 
+#include <X11/X.h>
+#include <X11/Xmd.h>
+
 #define EPHYR_WANT_DEBUG 0
 
 #if (EPHYR_WANT_DEBUG)
@@ -48,6 +51,14 @@ typedef enum EphyrHostXEventType 
 } 
 EphyrHostXEventType;
 
+/* I can't believe it's not a KeySymsRec. */
+typedef struct {
+  int             minKeyCode;
+  int             maxKeyCode;
+  int             mapWidth;
+  KeySym         *map;
+} EphyrKeySyms;
+
 struct EphyrHostXEvent
 {
   EphyrHostXEventType type;
@@ -126,9 +137,9 @@ int
 hostx_get_bpp(void);
 
 void
-hostx_get_visual_masks (unsigned long *rmsk, 
-			unsigned long *gmsk, 
-			unsigned long *bmsk);
+hostx_get_visual_masks (CARD32 *rmsk, 
+			CARD32 *gmsk, 
+			CARD32 *bmsk);
 void
 hostx_set_cmap_entry(unsigned char idx, 
 		     unsigned char r, 
diff --git a/hw/kdrive/fake/fake.c b/hw/kdrive/fake/fake.c
index d56512b..ca515f9 100644
--- a/hw/kdrive/fake/fake.c
+++ b/hw/kdrive/fake/fake.c
@@ -158,7 +158,7 @@ Bool
 fakeMapFramebuffer (KdScreenInfo *screen)
 {
     FakeScrPriv	*scrpriv = screen->driver;
-    KdMouseMatrix	m;
+    KdPointerMatrix	m;
     FakePriv		*priv = screen->card->driver;
 
     if (scrpriv->randr != RR_Rotate_0)
@@ -166,9 +166,9 @@ fakeMapFramebuffer (KdScreenInfo *screen
     else
 	scrpriv->shadow = FALSE;
     
-    KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height);
+    KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
     
-    KdSetMouseMatrix (&m);
+    KdSetPointerMatrix (&m);
     
     priv->bytes_per_line = ((screen->width * screen->fb[0].bitsPerPixel + 31) >> 5) << 2;
     if (priv->base)
diff --git a/hw/kdrive/fake/fake.h b/hw/kdrive/fake/fake.h
index 4d90d31..f7c8c34 100644
--- a/hw/kdrive/fake/fake.h
+++ b/hw/kdrive/fake/fake.h
@@ -130,9 +130,9 @@ fakeRandRInit (ScreenPtr pScreen);
 
 #endif
 
-extern KdMouseFuncs FakeMouseFuncs;
+extern KdPointerDriver FakePointerDriver;
 
-extern KdKeyboardFuncs	FakeKeyboardFuncs;
+extern KdKeyboardDriver	FakeKeyboardDriver;
 
 extern KdOsFuncs   FakeOsFuncs;
 
diff --git a/hw/kdrive/fake/fakeinit.c b/hw/kdrive/fake/fakeinit.c
index c5ee4bc..dd88bc5 100644
--- a/hw/kdrive/fake/fakeinit.c
+++ b/hw/kdrive/fake/fakeinit.c
@@ -44,7 +44,22 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&FakeMouseFuncs, &FakeKeyboardFuncs);
+    KdPointerInfo *pi;
+    KdKeyboardInfo *ki;
+
+    pi = KdNewPointer ();
+    if (!pi)
+        return;
+    pi->driver = &FakePointerDriver;
+    KdAddPointer(pi);
+
+    ki = KdNewKeyboard ();
+    if (!ki)
+        return;
+    ki->driver = &FakeKeyboardDriver;
+    KdAddKeyboard(ki);
+
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/fake/kbd.c b/hw/kdrive/fake/kbd.c
index 9cf4de0..db224c9 100644
--- a/hw/kdrive/fake/kbd.c
+++ b/hw/kdrive/fake/kbd.c
@@ -27,7 +27,6 @@
 #include <kdrive-config.h>
 #endif
 #include "fake.h"
-#include "kkeymap.h"
 #include <X11/keysym.h>
 
 #define FAKE_WIDTH  2
@@ -155,41 +154,58 @@ KeySym FakeKeymap[] = {
 /*    116   123 */	 NoSymbol,	NoSymbol,   /* tiny button */
 };
 
-static void
-FakeKeyboardLoad (void)
+static Status
+FakeKeyboardInit (KdKeyboardInfo *ki)
+{
+    ki->keySyms.minKeyCode = 1;
+    ki->keySyms.maxKeyCode = (sizeof (FakeKeymap) / sizeof (FakeKeymap[0])) / FAKE_WIDTH;
+    ki->keySyms.mapWidth = FAKE_WIDTH;
+    if (ki->keySyms.map)
+        xfree(ki->keySyms.map);
+    ki->keySyms.map = (KeySym *)xalloc(sizeof(FakeKeymap));
+    if (!ki->keySyms.map)
+        return BadAlloc;
+    memcpy (ki->keySyms.map, FakeKeymap, sizeof (FakeKeymap));
+
+    return Success;
+}
+
+static Status
+FakeKeyboardEnable (KdKeyboardInfo *ki)
 {
-    kdMinScanCode = 1;
-    kdKeymapWidth = FAKE_WIDTH;
-    kdMaxScanCode = (sizeof (FakeKeymap) / sizeof (FakeKeymap[0])) / FAKE_WIDTH;
-    memcpy (kdKeymap, FakeKeymap, sizeof (FakeKeymap));
+    return Success;
 }
 
-static int
-FakeKeyboardInit (void)
+static void
+FakeKeyboardDisable (KdKeyboardInfo *ki)
 {
-    return 0;
+    return;
 }
 
 static void
-FakeKeyboardFini (void)
+FakeKeyboardFini (KdKeyboardInfo *ki)
 {
+    xfree(ki->keySyms.map);
+    ki->keySyms.map = NULL;
 }
 
 static void
-FakeKeyboardLeds (int leds)
+FakeKeyboardLeds (KdKeyboardInfo *ki, int leds)
 {
 }
 
 static void
-FakeKeyboardBell (int volume, int frequency, int duration)
+FakeKeyboardBell (KdKeyboardInfo *ki, int volume, int frequency, int duration)
 {
 }
 
-KdKeyboardFuncs	FakeKeyboardFuncs = {
-    FakeKeyboardLoad,
+KdKeyboardDriver FakeKeyboardDriver = {
+    "fake",
     FakeKeyboardInit,
+    FakeKeyboardEnable,
     FakeKeyboardLeds,
     FakeKeyboardBell,
+    FakeKeyboardDisable,
     FakeKeyboardFini,
-    0,
+    NULL,
 };
diff --git a/hw/kdrive/fake/mouse.c b/hw/kdrive/fake/mouse.c
index 714a451..beb6ff5 100644
--- a/hw/kdrive/fake/mouse.c
+++ b/hw/kdrive/fake/mouse.c
@@ -35,19 +35,35 @@
 #include "scrnintstr.h"
 #include "kdrive.h"
 
-static Bool
-MouseInit (void)
+static Status
+MouseInit (KdPointerInfo *pi)
 {
-    return TRUE;
+    return Success;
+}
+
+static Status
+MouseEnable (KdPointerInfo *pi)
+{
+    return Success;
+}
+
+static void
+MouseDisable (KdPointerInfo *pi)
+{
+    return;
 }
 
 static void
-MouseFini (void)
+MouseFini (KdPointerInfo *pi)
 {
+    return;
 }
 
 
-KdMouseFuncs FakeMouseFuncs = {
+KdPointerDriver FakePointerDriver = {
+    "fake",
     MouseInit,
+    MouseEnable,
+    MouseDisable,
     MouseFini,
 };
diff --git a/hw/kdrive/fbdev/Makefile.am b/hw/kdrive/fbdev/Makefile.am
index fce6df9..39e9ba4 100644
--- a/hw/kdrive/fbdev/Makefile.am
+++ b/hw/kdrive/fbdev/Makefile.am
@@ -4,8 +4,6 @@ INCLUDES = 					\
 
 noinst_LIBRARIES = libfbdev.a
 
-bin_PROGRAMS = Xfbdev
-
 if TSLIB
 TSLIB_FLAG = -lts
 endif
@@ -14,6 +12,9 @@ libfbdev_a_SOURCES =	\
 	fbdev.c		\
 	fbdev.h
 
+if KDRIVEFBDEV
+bin_PROGRAMS = Xfbdev
+
 Xfbdev_SOURCES = \
 	fbinit.c
 
@@ -26,4 +27,4 @@ Xfbdev_LDADD = 						\
 Xfbdev_DEPENDENCIES =					\
 	libfbdev.a					\
 	@KDRIVE_LIBS@					
-
+endif
diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c
index 86384f0..8ff32ef 100644
--- a/hw/kdrive/fbdev/fbdev.c
+++ b/hw/kdrive/fbdev/fbdev.c
@@ -323,7 +323,7 @@ Bool
 fbdevMapFramebuffer (KdScreenInfo *screen)
 {
     FbdevScrPriv	*scrpriv = screen->driver;
-    KdMouseMatrix	m;
+    KdPointerMatrix	m;
     FbdevPriv		*priv = screen->card->driver;
 
     if (scrpriv->randr != RR_Rotate_0)
@@ -331,9 +331,9 @@ fbdevMapFramebuffer (KdScreenInfo *scree
     else
 	scrpriv->shadow = FALSE;
     
-    KdComputeMouseMatrix (&m, scrpriv->randr, screen->width, screen->height);
+    KdComputePointerMatrix (&m, scrpriv->randr, screen->width, screen->height);
     
-    KdSetMouseMatrix (&m);
+    KdSetPointerMatrix (&m);
     
     screen->width = priv->var.xres;
     screen->height = priv->var.yres;
diff --git a/hw/kdrive/fbdev/fbinit.c b/hw/kdrive/fbdev/fbinit.c
index ba9d1c6..9d7c492 100644
--- a/hw/kdrive/fbdev/fbinit.c
+++ b/hw/kdrive/fbdev/fbinit.c
@@ -45,10 +45,18 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
-#ifdef TOUCHSCREEN
-    KdAddMouseDriver (&TsFuncs);
+    KdKeyboardInfo *ki;
+
+    KdAddKeyboardDriver (&LinuxKeyboardDriver);
+    KdAddPointerDriver (&LinuxMouseDriver);
+#ifdef TSLIB
+    KdAddPointerDriver (&TsDriver);
 #endif
+
+    ki = KdParseKeyboard ("keybd");
+    KdAddKeyboard(ki);
+
+    KdInitInput ();
 }
 
 void
diff --git a/hw/kdrive/itsy/kbd.c b/hw/kdrive/itsy/kbd.c
index 76062c5..beb4685 100644
--- a/hw/kdrive/itsy/kbd.c
+++ b/hw/kdrive/itsy/kbd.c
@@ -27,7 +27,6 @@
 #include <kdrive-config.h>
 #endif
 #include "itsy.h"
-#include "kkeymap.h"
 #include <X11/keysym.h>
 #include <linux/itsy_buttons.h>
 
@@ -167,28 +166,44 @@ ItsyKeyboardLoad (void)
 {
     KeySym  *k;
 
-    itsyButtonState = 0;
-    kdMinScanCode = 1;
-    kdKeymapWidth = ITSY_WIDTH;
-    kdMaxScanCode = (sizeof (ItsyKeymap) / sizeof (ItsyKeymap[0])) / ITSY_WIDTH;
-    memcpy (kdKeymap, ItsyKeymap, sizeof (ItsyKeymap));
 }
 
-int
-ItsyKeyboardInit (void)
+static Status
+ItsyKeyboardInit (KdKeyboardInfo *ki)
 {
-    int	butPort;
+    if (!ki)
+        return BadImplementation;
+
+    ki->driverPrivate = open ("/dev/buttons", 0);
+
+    itsyButtonState = 0;
+    ki->keySyms.minKeyCode = 1;
+    ki->keySyms.maxKeyCode = (sizeof (ItsyKeymap) / sizeof (ItsyKeymap[0])) / ITSY_WIDTH;
+    ki->minScanCode = ki->keySyms.minKeyCode;
+    ki->maxScanCode = ki->keySyms.maxKeyCode;
+    ki->keySyms.mapWidth = ITSY_WIDTH;
+
+    if (ki->keySyms.map)
+        xfree(ki->keySyms.map);
+    ki->keySyms.map = xalloc(sizeof(ItsyKeymap));
+    if (!ki->keySyms.map)
+        return BadAlloc;
+    memcpy (kdKeymap, ItsyKeymap, sizeof (ItsyKeymap));
 
-    butPort = open ("/dev/buttons", 0);
-    fprintf (stderr, "butPort %d\n", butPort);
-    return butPort;
+    return Success;
 }
 
-void
-ItsyKeyboardFini (int fd)
+static void
+ItsyKeyboardDisable (KdKeybdInfo *ki)
 {
     if (fd >= 0)
-	close (fd);
+	close ((int)ki->driverPrivate);
+}
+
+static void
+ItsyKeyboardFini (KdKeybdInfo *ki)
+{
+    return;
 }
 
 void
@@ -227,11 +242,13 @@ ItsyKeyboardBell (int volume, int freque
 }
 
 KdKeyboardFuncs	itsyKeyboardFuncs = {
-    ItsyKeyboardLoad,
+    "itsy",
     ItsyKeyboardInit,
+    ItsyKeyboardEnable,
     ItsyKeyboardRead,
     ItsyKeyboardLeds,
     ItsyKeyboardBell,
+    ItsyKeyboardDisable
     ItsyKeyboardFini,
-    0,
+    NULL,
 };
diff --git a/hw/kdrive/itsy/ts.c b/hw/kdrive/itsy/ts.c
index c773c0e..180d1fd 100644
--- a/hw/kdrive/itsy/ts.c
+++ b/hw/kdrive/itsy/ts.c
@@ -63,7 +63,7 @@ itsyTsReadBytes (int fd, char *buf, int 
 }
 
 void
-itsyTsRead (int tsPort)
+itsyTsRead (KdPointerInfo *pi, int tsPort)
 {
     ts_event	    event;
     long	    buf[3];
@@ -89,7 +89,7 @@ itsyTsRead (int tsPort)
 	    x = 0;
 	    y = 0;
 	}
-	KdEnqueueMouseEvent (flags, x, y);
+	KdEnqueuePointerEvent (pi, flags, x, y, 0);
     }
 }
 
@@ -204,7 +204,8 @@ itsyTsFini (int tsPort)
 	close (tsPort);
 }
 
-KdMouseFuncs itsyTsMouseFuncs = {
+KdPointerDriver itsyTsMouseDriver = {
+    "itsyts",
     itsyTsInit,
     itsyTsRead,
     itsyTsFini
diff --git a/hw/kdrive/linux/bus.c b/hw/kdrive/linux/bus.c
index be61f89..8cf5f90 100644
--- a/hw/kdrive/linux/bus.c
+++ b/hw/kdrive/linux/bus.c
@@ -55,7 +55,7 @@ BusRead (int adbPort, void *closure)
 	    flags |= KD_BUTTON_2;
 	if ((buf[0] & 1) == 0)
 	    flags |= KD_BUTTON_3;
-        KdEnqueueMouseEvent (kdMouseInfo, flags, dx, dy);
+        KdEnqueuePointerEvent (closure, flags, dx, dy, 0);
     }
 }
 
@@ -66,36 +66,71 @@ char	*BusNames[] = {
 
 #define NUM_BUS_NAMES	(sizeof (BusNames) / sizeof (BusNames[0]))
 
-int	BusInputType;
+static int
+BusInit (KdPointerInfo *pi)
+{
+    int	    i, fd = 0;
+
+    if (!pi->path || (strcmp(pi->path, "auto") == 0))
+    {
+        for (i = 0; i < NUM_BUS_NAMES; i++)
+        {
+            if ((fd = open (BusNames[i], 0)) > 0)
+            {
+                close(fd);
+                if (pi->path)
+                    xfree(pi->path);
+                pi->path = KdSaveString(BusNames[i]);
+                return Success;
+            }
+        }
+    }
+    else
+    {
+        if ((fd = open(pi->path, 0)) > 0)
+        {
+            close(fd);
+            return Success;
+        }
+    }
+
+    return !Success;
+}
 
 static int
-BusInit (void)
+BusEnable (KdPointerInfo *pi)
 {
-    int	    i;
-    int	    busPort;
-    int	    n = 0;
-
-    if (!BusInputType)
-	BusInputType = KdAllocInputType ();
-    
-    for (i = 0; i < NUM_BUS_NAMES; i++)
+    int fd = open(pi->path, 0);
+
+    if (fd > 0)
+    {
+        KdRegisterFd(fd, BusRead, pi);
+        pi->driverPrivate = (void *)fd;
+        return Success;
+    }
+    else
     {
-	busPort = open (BusNames[i], 0);
-	{
-	    KdRegisterFd (BusInputType, busPort, BusRead, 0);
-	    n++;
-	}
+        return !Success;
     }
-    return n;
 }
 
 static void
-BusFini (void)
+BusDisable (KdPointerInfo *pi)
+{
+    KdUnregisterFd(pi, (int)pi->driverPrivate, TRUE);
+}
+
+static void
+BusFini (KdPointerInfo *pi)
 {
-    KdUnregisterFds (BusInputType, TRUE);
+    return;
 }
 
-KdMouseFuncs BusMouseFuncs = {
+KdPointerDriver BusMouseDriver = {
+    "bus",
     BusInit,
-    BusFini
+    BusEnable,
+    BusDisable,
+    BusFini,
+    NULL
 };
diff --git a/hw/kdrive/linux/evdev.c b/hw/kdrive/linux/evdev.c
index d83b13a..6c08cfa 100644
--- a/hw/kdrive/linux/evdev.c
+++ b/hw/kdrive/linux/evdev.c
@@ -43,98 +43,100 @@
 #define ISBITSET(x,y) ((x)[LONG(y)] & BIT(y))
 #define OFF(x)   ((x)%BITS_PER_LONG)
 #define LONG(x)  ((x)/BITS_PER_LONG)
-#define BIT(x)	 (1 << OFF(x))
+#define BIT(x)         (1 << OFF(x))
 #define SETBIT(x,y) ((x)[LONG(y)] |= BIT(y))
 #define CLRBIT(x,y) ((x)[LONG(y)] &= ~BIT(y))
 #define ASSIGNBIT(x,y,z)    ((x)[LONG(y)] = ((x)[LONG(y)] & ~BIT(y)) | (z << OFF(y)))
 
 typedef struct _kevdevMouse {
     /* current device state */
-    int			    rel[REL_MAX + 1];
-    int			    abs[ABS_MAX + 1];
-    int			    prevabs[ABS_MAX + 1];
-    long		    key[NBITS(KEY_MAX + 1)];
+    int                            rel[REL_MAX + 1];
+    int                            abs[ABS_MAX + 1];
+    int                            prevabs[ABS_MAX + 1];
+    long                    key[NBITS(KEY_MAX + 1)];
     
     /* supported device info */
-    long		    relbits[NBITS(REL_MAX + 1)];
-    long		    absbits[NBITS(ABS_MAX + 1)];
-    long		    keybits[NBITS(KEY_MAX + 1)];
+    long                    relbits[NBITS(REL_MAX + 1)];
+    long                    absbits[NBITS(ABS_MAX + 1)];
+    long                    keybits[NBITS(KEY_MAX + 1)];
     struct input_absinfo    absinfo[ABS_MAX + 1];
-    int			    max_rel;
-    int			    max_abs;
+    int                            max_rel;
+    int                            max_abs;
+
+    int                     fd;
 } Kevdev;
 
 static void
-EvdevMotion (KdMouseInfo    *mi)
+EvdevMotion (KdPointerInfo    *pi)
 {
-    Kevdev		*ke = mi->driver;
-    int			i;
+    Kevdev                *ke = pi->driverPrivate;
+    int                        i;
 
     for (i = 0; i <= ke->max_rel; i++)
-	if (ke->rel[i])
-	{
-	    int a;
-	    ErrorF ("rel");
-	    for (a = 0; a <= ke->max_rel; a++)
-	    {
-		if (ISBITSET (ke->relbits, a))
-		    ErrorF (" %d=%d", a, ke->rel[a]);
-		ke->rel[a] = 0;
-	    }
-	    ErrorF ("\n");
-	    break;
-	}
+        if (ke->rel[i])
+        {
+            int a;
+            ErrorF ("rel");
+            for (a = 0; a <= ke->max_rel; a++)
+            {
+                if (ISBITSET (ke->relbits, a))
+                    ErrorF (" %d=%d", a, ke->rel[a]);
+                ke->rel[a] = 0;
+            }
+            ErrorF ("\n");
+            break;
+        }
     for (i = 0; i < ke->max_abs; i++)
-	if (ke->abs[i] != ke->prevabs[i])
-	{
-	    int a;
-	    ErrorF ("abs");
-	    for (a = 0; a <= ke->max_abs; a++)
-	    {
-		if (ISBITSET (ke->absbits, a))
-		    ErrorF (" %d=%d", a, ke->abs[a]);
-		ke->prevabs[a] = ke->abs[a];
-	    }
-	    ErrorF ("\n");
-	    break;
-	}
+        if (ke->abs[i] != ke->prevabs[i])
+        {
+            int a;
+            ErrorF ("abs");
+            for (a = 0; a <= ke->max_abs; a++)
+            {
+                if (ISBITSET (ke->absbits, a))
+                    ErrorF (" %d=%d", a, ke->abs[a]);
+                ke->prevabs[a] = ke->abs[a];
+            }
+            ErrorF ("\n");
+            break;
+        }
 }
 
 static void
 EvdevRead (int evdevPort, void *closure)
 {
-    KdMouseInfo		*mi = closure;
-    Kevdev		*ke = mi->driver;
-    int			i;
-    struct input_event	events[NUM_EVENTS];
-    int			n;
+    KdPointerInfo                *pi = closure;
+    Kevdev                       *ke = pi->driverPrivate;
+    int                        i;
+    struct input_event        events[NUM_EVENTS];
+    int                        n;
 
     n = read (evdevPort, &events, NUM_EVENTS * sizeof (struct input_event));
     if (n <= 0)
-	return;
+        return;
     n /= sizeof (struct input_event);
     for (i = 0; i < n; i++)
     {
-	switch (events[i].type) {
-	case EV_SYN:
-	    break;
-	case EV_KEY:
-	    EvdevMotion (mi);
-	    ASSIGNBIT(ke->key,events[i].code, events[i].value);
-	    if (events[i].code < 0x100)
-		ErrorF ("key %d %d\n", events[i].code, events[i].value);
-	    else
-		ErrorF ("key 0x%x %d\n", events[i].code, events[i].value);
-	    break;
-	case EV_REL:
-	    ke->rel[events[i].code] += events[i].value;
-	    break;
-	case EV_ABS:
-	    ke->abs[events[i].code] = events[i].value;
-	    break;
-	}
+        switch (events[i].type) {
+        case EV_SYN:
+            break;
+        case EV_KEY:
+            EvdevMotion (pi);
+            ASSIGNBIT(ke->key,events[i].code, events[i].value);
+            if (events[i].code < 0x100)
+                ErrorF ("key %d %d\n", events[i].code, events[i].value);
+            else
+                ErrorF ("key 0x%x %d\n", events[i].code, events[i].value);
+            break;
+        case EV_REL:
+            ke->rel[events[i].code] += events[i].value;
+            break;
+        case EV_ABS:
+            ke->abs[events[i].code] = events[i].value;
+            break;
+        }
     }
-    EvdevMotion (mi);
+    EvdevMotion (pi);
 }
 
 int EvdevInputType;
@@ -148,143 +150,153 @@ char *kdefaultEvdev[] =  {
 
 #define NUM_DEFAULT_EVDEV    (sizeof (kdefaultEvdev) / sizeof (kdefaultEvdev[0]))
 
-static Bool
-EvdevInit (void)
+static Status
+EvdevInit (KdPointerInfo *pi)
 {
-    int		i;
-    int		fd;
-    KdMouseInfo	*mi, *next;
-    int		n = 0;
-    char	*prot;
+    int                i;
+    int                fd;
+    int                n = 0;
+    char        *prot;
+
+    if (!pi->path) {
+        for (i = 0; i < NUM_DEFAULT_EVDEV; i++) {
+            fd = open (kdefaultEvdev[i], 2);
+                if (fd >= 0) {
+                    pi->path = KdSaveString (kdefaultEvdev[i]);
+                    break;
+                }
+            }
+    }
+    else {
+        fd = open (pi->path, 2);
+        if (fd < 0) {
+            ErrorF("Failed to open evdev device %s\n", pi->path);
+            return BadMatch;
+        }
+    }
 
-    if (!EvdevInputType)
-	EvdevInputType = KdAllocInputType ();
+    return Success;
+}
 
-    for (mi = kdMouseInfo; mi; mi = next)
+static Status
+EvdevEnable (KdPointerInfo *pi)
+{        
+    int fd;
+
+    if (!pi || !pi->path)
+        return BadImplementation;
+
+    fd = open(pi->path, 2);
+    if (fd < 0)
+        return BadMatch;
+
+    unsigned long   ev[NBITS(EV_MAX)];
+    Kevdev            *ke;
+        
+    if (ioctl (fd, EVIOCGBIT(0 /*EV*/, sizeof (ev)), ev) < 0)
+    {
+        perror ("EVIOCGBIT 0");
+        close (fd);
+        return BadMatch;
+    }
+    ke = xalloc (sizeof (Kevdev));
+    if (!ke)
     {
-	next = mi->next;
-	prot = mi->prot;
-	if (mi->inputType)
-	    continue;
-	if (!mi->name)
-	{
-	    for (i = 0; i < NUM_DEFAULT_EVDEV; i++)
-	    {
-		fd = open (kdefaultEvdev[i], 2);
-		if (fd >= 0)
-		{
-		    mi->name = KdSaveString (kdefaultEvdev[i]);
-		    break;
-		}
-	    }
-	}
-	else
-	    fd = open (mi->name, 2);
-	    
-	if (fd >= 0)
-	{
-	    unsigned long   ev[NBITS(EV_MAX)];
-	    Kevdev	    *ke;
-	    
-	    if (ioctl (fd, EVIOCGBIT(0 /*EV*/, sizeof (ev)), ev) < 0)
-	    {
-		perror ("EVIOCGBIT 0");
-		close (fd);
-		continue;
-	    }
-	    ke = xalloc (sizeof (Kevdev));
-	    if (!ke)
-	    {
-		close (fd);
-		continue;
-	    }
-	    memset (ke, '\0', sizeof (Kevdev));
-	    if (ISBITSET (ev, EV_KEY))
-	    {
-		if (ioctl (fd, EVIOCGBIT (EV_KEY, sizeof (ke->keybits)),
-			   ke->keybits) < 0)
-		{
-		    perror ("EVIOCGBIT EV_KEY");
-		    xfree (ke);
-		    close (fd);
-		    continue;
-		}
-	    }
-	    if (ISBITSET (ev, EV_REL))
-	    {
-		if (ioctl (fd, EVIOCGBIT (EV_REL, sizeof (ke->relbits)),
-			   ke->relbits) < 0)
-		{
-		    perror ("EVIOCGBIT EV_REL");
-		    xfree (ke);
-		    close (fd);
-		    continue;
-		}
-		for (ke->max_rel = REL_MAX; ke->max_rel >= 0; ke->max_rel--)
-		    if (ISBITSET(ke->relbits, ke->max_rel))
-			break;
-	    }
-	    if (ISBITSET (ev, EV_ABS))
-	    {
-		int i;
-
-		if (ioctl (fd, EVIOCGBIT (EV_ABS, sizeof (ke->absbits)),
-			   ke->absbits) < 0)
-		{
-		    perror ("EVIOCGBIT EV_ABS");
-		    xfree (ke);
-		    close (fd);
-		    continue;
-		}
-		for (ke->max_abs = ABS_MAX; ke->max_abs >= 0; ke->max_abs--)
-		    if (ISBITSET(ke->absbits, ke->max_abs))
-			break;
-		for (i = 0; i <= ke->max_abs; i++)
-		{
-		    if (ISBITSET (ke->absbits, i))
-			if (ioctl (fd, EVIOCGABS(i), &ke->absinfo[i]) < 0)
-			{
-			    perror ("EVIOCGABS");
-			    break;
-			}
-		    ke->prevabs[i] = ABS_UNSET;
-		}
-		if (i <= ke->max_abs)
-		{
-		    xfree (ke);
-		    close (fd);
-		    continue;
-		}
-	    }
-	    mi->driver = ke;
-	    mi->inputType = EvdevInputType;
-	    if (KdRegisterFd (EvdevInputType, fd, EvdevRead, (void *) mi))
-		n++;
-	}
+        close (fd);
+        return BadAlloc;
     }
-    return TRUE;
+    memset (ke, '\0', sizeof (Kevdev));
+    if (ISBITSET (ev, EV_KEY))
+    {
+        if (ioctl (fd, EVIOCGBIT (EV_KEY, sizeof (ke->keybits)),
+                   ke->keybits) < 0)
+        {
+            perror ("EVIOCGBIT EV_KEY");
+            xfree (ke);
+            close (fd);
+            return BadMatch;
+        }
+    }
+    if (ISBITSET (ev, EV_REL))
+    {
+        if (ioctl (fd, EVIOCGBIT (EV_REL, sizeof (ke->relbits)),
+                       ke->relbits) < 0)
+        {
+            perror ("EVIOCGBIT EV_REL");
+            xfree (ke);
+            close (fd);
+            return BadMatch;
+        }
+        for (ke->max_rel = REL_MAX; ke->max_rel >= 0; ke->max_rel--)
+            if (ISBITSET(ke->relbits, ke->max_rel))
+                break;
+    }
+    if (ISBITSET (ev, EV_ABS))
+    {
+        int i;
+
+        if (ioctl (fd, EVIOCGBIT (EV_ABS, sizeof (ke->absbits)),
+                   ke->absbits) < 0)
+            {
+            perror ("EVIOCGBIT EV_ABS");
+            xfree (ke);
+            close (fd);
+            return BadMatch;
+        }
+        for (ke->max_abs = ABS_MAX; ke->max_abs >= 0; ke->max_abs--)
+            if (ISBITSET(ke->absbits, ke->max_abs))
+                break;
+        for (i = 0; i <= ke->max_abs; i++)
+        {
+            if (ISBITSET (ke->absbits, i))
+                if (ioctl (fd, EVIOCGABS(i), &ke->absinfo[i]) < 0)
+                {
+                    perror ("EVIOCGABS");
+                    break;
+                }
+            ke->prevabs[i] = ABS_UNSET;
+        }
+        if (i <= ke->max_abs)
+        {
+            xfree (ke);
+            close (fd);
+            return BadValue;
+        }
+    }
+    if (!KdRegisterFd (fd, EvdevRead, pi)) {
+        xfree (ke);
+        close (fd);
+        return BadAlloc;
+    }
+    pi->driverPrivate = ke;
+    return Success;
 }
 
 static void
-EvdevFini (void)
+EvdevDisable (KdPointerInfo *pi)
 {
-    KdMouseInfo	*mi;
+    Kevdev              *ke;
 
-    KdUnregisterFds (EvdevInputType, TRUE);
-    for (mi = kdMouseInfo; mi; mi = mi->next)
-    {
-	if (mi->inputType == EvdevInputType)
-	{
-	    xfree (mi->driver);
-	    mi->driver = 0;
-	    mi->inputType = 0;
-	}
-    }
+    if (!pi || !pi->driverPrivate)
+        return;
+
+    KdUnregisterFd (pi, ke->fd, TRUE);
+    xfree (ke);
+    pi->driverPrivate = 0;
+}
+
+static void
+EvdevFini (KdPointerInfo *pi)
+{
 }
 
-KdMouseFuncs LinuxEvdevMouseFuncs = {
+KdPointerDriver LinuxEvdevMouseDriver = {
+    "evdev",
     EvdevInit,
+    EvdevEnable,
+    EvdevDisable,
     EvdevFini,
+    NULL,
 };
 
 #if 0
diff --git a/hw/kdrive/linux/keyboard.c b/hw/kdrive/linux/keyboard.c
index cfafbb3..9400e6b 100644
--- a/hw/kdrive/linux/keyboard.c
+++ b/hw/kdrive/linux/keyboard.c
@@ -2,31 +2,40 @@
  * $RCSId: xc/programs/Xserver/hw/kdrive/linux/keyboard.c,v 1.10 2001/11/08 10:26:24 keithp Exp $
  *
  * Copyright © 1999 Keith Packard
+ * XKB integration © 2006 Nokia Corporation, author: Tomas Frydrych <tf at o-hand.com>
  *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name 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.
+ * 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 "kkeymap.h"
 #include <linux/keyboard.h>
 #include <linux/kd.h>
 #define XK_PUBLISHING
@@ -34,7 +43,7 @@
 #include <termios.h>
 #include <sys/ioctl.h>
 
-extern int  LinuxConsoleFd;
+extern int LinuxConsoleFd;
 
 static const KeySym linux_to_x[256] = {
 	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
@@ -103,7 +112,108 @@ static const KeySym linux_to_x[256] = {
 	XK_udiaeresis,	XK_yacute,	XK_thorn,	XK_ydiaeresis
 };
 
-static unsigned char tbl[KD_MAX_WIDTH] = 
+#ifdef XKB
+/*
+ * Getting a keycode from scancode
+ *
+ * With XKB
+ * --------
+ *
+ * We have to enqueue keyboard events using standard X keycodes which correspond
+ * to AT scancode + 8; this means that we need to translate the Linux scancode
+ * provided by the kernel to an AT scancode -- this translation is not linear
+ * and requires that we use a LUT.
+ *
+ *
+ * Without XKB
+ * -----------
+ *
+ * We can use custom keycodes, which makes things simpler; we define our custom
+ * keycodes as Linux scancodes + KD_KEY_OFFSET
+*/
+
+/*
+   This LUT translates AT scancodes into Linux ones -- the keymap we create
+   for the core X keyboard protocol has to be AT-scancode based so that it
+   corresponds to the Xkb keymap.
+*/
+static unsigned char at2lnx[] =
+{
+	0x0,    /* no valid scancode */
+	0x01,	/* KEY_Escape */	0x02,	/* KEY_1 */
+	0x03,	/* KEY_2 */		0x04,	/* KEY_3 */
+	0x05,	/* KEY_4 */		0x06,	/* KEY_5 */
+	0x07,	/* KEY_6 */		0x08,	/* KEY_7 */
+	0x09,	/* KEY_8 */		0x0a,	/* KEY_9 */
+	0x0b,	/* KEY_0 */		0x0c,	/* KEY_Minus */
+	0x0d,	/* KEY_Equal */		0x0e,	/* KEY_BackSpace */
+	0x0f,	/* KEY_Tab */		0x10,	/* KEY_Q */
+	0x11,	/* KEY_W */		0x12,	/* KEY_E */
+	0x13,	/* KEY_R */		0x14,	/* KEY_T */
+	0x15,	/* KEY_Y */		0x16,	/* KEY_U */
+	0x17,	/* KEY_I */		0x18,	/* KEY_O */
+	0x19,	/* KEY_P */		0x1a,	/* KEY_LBrace */
+	0x1b,	/* KEY_RBrace */	0x1c,	/* KEY_Enter */
+	0x1d,	/* KEY_LCtrl */		0x1e,	/* KEY_A */
+	0x1f,	/* KEY_S */		0x20,	/* KEY_D */
+	0x21,	/* KEY_F */		0x22,	/* KEY_G */
+	0x23,	/* KEY_H */		0x24,	/* KEY_J */
+	0x25,	/* KEY_K */		0x26,	/* KEY_L */
+	0x27,	/* KEY_SemiColon */	0x28,	/* KEY_Quote */
+	0x29,	/* KEY_Tilde */		0x2a,	/* KEY_ShiftL */
+	0x2b,	/* KEY_BSlash */	0x2c,	/* KEY_Z */
+	0x2d,	/* KEY_X */		0x2e,	/* KEY_C */
+	0x2f,	/* KEY_V */		0x30,	/* KEY_B */
+	0x31,	/* KEY_N */		0x32,	/* KEY_M */
+	0x33,	/* KEY_Comma */		0x34,	/* KEY_Period */
+	0x35,	/* KEY_Slash */		0x36,	/* KEY_ShiftR */
+	0x37,	/* KEY_KP_Multiply */	0x38,	/* KEY_Alt */
+	0x39,	/* KEY_Space */		0x3a,	/* KEY_CapsLock */
+	0x3b,	/* KEY_F1 */		0x3c,	/* KEY_F2 */
+	0x3d,	/* KEY_F3 */		0x3e,	/* KEY_F4 */
+	0x3f,	/* KEY_F5 */		0x40,	/* KEY_F6 */
+	0x41,	/* KEY_F7 */		0x42,	/* KEY_F8 */
+	0x43,	/* KEY_F9 */		0x44,	/* KEY_F10 */
+	0x45,	/* KEY_NumLock */	0x46,	/* KEY_ScrollLock */
+	0x47,	/* KEY_KP_7 */		0x48,	/* KEY_KP_8 */
+	0x49,	/* KEY_KP_9 */		0x4a,	/* KEY_KP_Minus */
+	0x4b,	/* KEY_KP_4 */		0x4c,	/* KEY_KP_5 */
+	0x4d,	/* KEY_KP_6 */		0x4e,	/* KEY_KP_Plus */
+	0x4f,	/* KEY_KP_1 */		0x50,	/* KEY_KP_2 */
+	0x51,	/* KEY_KP_3 */		0x52,	/* KEY_KP_0 */
+	0x53,	/* KEY_KP_Decimal */	0x54,	/* KEY_SysReqest */
+	0x00,	/* 0x55 */		0x56,	/* KEY_Less */
+	0x57,	/* KEY_F11 */		0x58,	/* KEY_F12 */
+	0x66,	/* KEY_Home */		0x67,	/* KEY_Up */
+	0x68,	/* KEY_PgUp */		0x69,	/* KEY_Left */
+	0x5d,	/* KEY_Begin */		0x6a,	/* KEY_Right */
+	0x6b,	/* KEY_End */		0x6c,	/* KEY_Down */
+	0x6d,	/* KEY_PgDown */	0x6e,	/* KEY_Insert */
+	0x6f,	/* KEY_Delete */	0x60,	/* KEY_KP_Enter */
+	0x61,	/* KEY_RCtrl */		0x77,	/* KEY_Pause */
+	0x63,	/* KEY_Print */		0x62,	/* KEY_KP_Divide */
+	0x64,	/* KEY_AltLang */	0x65,	/* KEY_Break */
+	0x00,	/* KEY_LMeta */		0x00,	/* KEY_RMeta */
+	0x7A,	/* KEY_Menu/FOCUS_PF11*/0x00,	/* 0x6e */
+	0x7B,	/* FOCUS_PF12 */	0x00,	/* 0x70 */
+	0x00,	/* 0x71 */		0x00,	/* 0x72 */
+	0x59,	/* FOCUS_PF2 */		0x78,	/* FOCUS_PF9 */
+	0x00,	/* 0x75 */		0x00,	/* 0x76 */
+	0x5A,	/* FOCUS_PF3 */		0x5B,	/* FOCUS_PF4 */
+	0x5C,	/* FOCUS_PF5 */		0x5D,	/* FOCUS_PF6 */
+	0x5E,	/* FOCUS_PF7 */		0x5F,	/* FOCUS_PF8 */
+	0x7C,	/* JAP_86 */		0x79,	/* FOCUS_PF10 */
+	0x00,	/* 0x7f */
+};
+
+#define NUM_AT_KEYS (sizeof(at2lnx)/sizeof(at2lnx[0]))
+#define LNX_KEY_INDEX(n) n < NUM_AT_KEYS ? at2lnx[n] : 0
+
+#else /* not XKB */
+#define LNX_KEY_INDEX(n) n
+#endif
+
+static unsigned char tbl[KD_MAX_WIDTH] =
 {
     0,
     1 << KG_SHIFT,
@@ -112,24 +222,31 @@ static unsigned char tbl[KD_MAX_WIDTH] =
 };
 
 static void
-readKernelMapping(void)
+readKernelMapping(KdKeyboardInfo *ki)
 {
     KeySym	    *k;
     int		    i, j;
     struct kbentry  kbe;
     int		    minKeyCode, maxKeyCode;
     int		    row;
+    int             fd;
+
+    if (!ki)
+        return;
 
+    fd = LinuxConsoleFd;
+    
     minKeyCode = NR_KEYS;
     maxKeyCode = 0;
     row = 0;
+    ki->keySyms.mapWidth = KD_MAX_WIDTH;
     for (i = 0; i < NR_KEYS && row < KD_MAX_LENGTH; ++i)
     {
-	kbe.kb_index = i;
+        kbe.kb_index = LNX_KEY_INDEX(i);
 
-        k = kdKeymap + row * KD_MAX_WIDTH;
+        k = ki->keySyms.map + row * ki->keySyms.mapWidth;
 	
-	for (j = 0; j < KD_MAX_WIDTH; ++j)
+	for (j = 0; j < ki->keySyms.mapWidth; ++j)
 	{
 	    unsigned short kval;
 
@@ -137,7 +254,7 @@ readKernelMapping(void)
 
 	    kbe.kb_table = tbl[j];
 	    kbe.kb_value = 0;
-	    if (ioctl(LinuxConsoleFd, KDGKBENT, &kbe))
+	    if (ioctl(fd, KDGKBENT, &kbe))
 		continue;
 
 	    kval = KVAL(kbe.kb_value);
@@ -362,7 +479,7 @@ readKernelMapping(void)
 
 	if (minKeyCode == NR_KEYS)
 	    continue;
-	
+
 	if (k[3] == k[2]) k[3] = NoSymbol;
 	if (k[2] == k[1]) k[2] = NoSymbol;
 	if (k[1] == k[0]) k[1] = NoSymbol;
@@ -370,28 +487,212 @@ readKernelMapping(void)
 	if (k[3] == k[0] && k[2] == k[1] && k[2] == NoSymbol) k[3] =NoSymbol;
 	row++;
     }
-    kdMinScanCode = minKeyCode;
-    kdMaxScanCode = maxKeyCode;
+    ki->minScanCode = minKeyCode;
+    ki->maxScanCode = maxKeyCode;
 }
 
-static void
-LinuxKeyboardLoad (void)
-{
-    readKernelMapping ();
-}
+#ifdef XKB
+
+/*
+ * 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
+
+#endif /* XKB */
+
 
 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)
-    {
+    while ((n = read (fd, buf, sizeof (buf))) > 0) {
 	b = buf;
-	while (n--)
-	{
-	    KdEnqueueKeyboardEvent (b[0] & 0x7f, b[0] & 0x80);
+	while (n--) {
+#ifdef XKB
+            if (!noXkbExtension) {
+                /*
+                 * 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;
+                        ErrorF("Prefix0");
+                        /* swallow this up */
+                        b++;
+                        continue;
+                }
+                else if (!prefix && ((b[0] & 0x7f) == KEY_Prefix1))
+                {
+                        prefix = KEY_Prefix1;
+                        ErrorF("Prefix1");
+                        /* swallow this up */
+                        b++;
+                        continue;
+                }
+                scancode  = b[0] & 0x7f;
+
+                switch (prefix) {
+                        /* from xf86Events.c */
+                        case KEY_Prefix0:
+                        {
+                            ErrorF("Prefix0 scancode: 0x%02x\n", scancode);
+                            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:
+                                    ErrorF("Unreported Prefix0 scancode: 0x%02x\n",
+                                           scancode);
+                                     /*
+                                      * "Internet" keyboards are generating lots of new
+                                      * codes.  Let them pass.  There is little consistency
+                                      * between them, so don't bother with symbolic names at
+                                      * this level.
+                                      */
+                                    scancode += 0x78;
+                            }
+                            break;
+                        }
+
+                        case KEY_Prefix1:
+                        {
+                            /* we do no handle these */
+                            ErrorF("Prefix1 scancode: 0x%02x\n", scancode);
+                            b++;
+                            prefix = 0;
+                            continue;
+                        }
+
+                        default: /* should not happen*/
+                        case 0: /* do nothing */
+                            ErrorF("Plain scancode: 0x%02x\n", scancode);
+                }
+
+                prefix = 0;
+            }
+            /* without xkb we use mediumraw mode -- enqueue the scancode as is */
+            else
+#endif
+                scancode = b[0] & 0x7f;
+	    KdEnqueueKeyboardEvent (closure, scancode, b[0] & 0x80);
 	    b++;
 	}
     }
@@ -399,19 +700,30 @@ LinuxKeyboardRead (int fd, void *closure
 
 static int		LinuxKbdTrans;
 static struct termios	LinuxTermios;
-static int		LinuxKbdType;
 
-static int
-LinuxKeyboardEnable (int fd, void *closure)
+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 *) fd;
 
     ioctl (fd, KDGKBMODE, &LinuxKbdTrans);
     tcgetattr (fd, &LinuxTermios);
-    
-    ioctl(fd, KDSKBMODE, K_MEDIUMRAW);
+#ifdef XKB
+    if (!noXkbExtension)
+        ioctl(fd, KDSKBMODE, K_RAW);
+    else
+#else
+        ioctl(fd, KDSKBMODE, K_MEDIUMRAW);
+#endif
     nTty = LinuxTermios;
     nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
     nTty.c_oflag = 0;
@@ -422,54 +734,74 @@ LinuxKeyboardEnable (int fd, void *closu
     cfsetispeed(&nTty, 9600);
     cfsetospeed(&nTty, 9600);
     tcsetattr(fd, TCSANOW, &nTty);
+    /* Our kernel cleverly ignores O_NONBLOCK.  Sigh. */
+#if 0
     /*
      * Flush any pending keystrokes
      */
     while ((n = read (fd, buf, sizeof (buf))) > 0)
 	;
-    return fd;
+#endif
+    KdRegisterFd (fd, LinuxKeyboardRead, ki);
+    return Success;
 }
 
 static void
-LinuxKeyboardDisable (int fd, void *closure)
+LinuxKeyboardDisable (KdKeyboardInfo *ki)
 {
-    ioctl(LinuxConsoleFd, KDSKBMODE, LinuxKbdTrans);
-    tcsetattr(LinuxConsoleFd, TCSANOW, &LinuxTermios);
+    int fd;
+    
+    if (!ki)
+        return;
+
+    fd = (int) ki->driverPrivate;
+
+    KdUnregisterFd(ki, fd, FALSE);
+    ioctl(fd, KDSKBMODE, LinuxKbdTrans);
+    tcsetattr(fd, TCSANOW, &LinuxTermios);
 }
 
-static int
-LinuxKeyboardInit (void)
+static Status
+LinuxKeyboardInit (KdKeyboardInfo *ki)
 {
-    if (!LinuxKbdType)
-	LinuxKbdType = KdAllocInputType ();
+    if (!ki)
+        return !Success;
+
+    if (ki->path)
+        xfree(ki->path);
+    ki->path = KdSaveString("console");
+    if (ki->name)
+        xfree(ki->name);
+    ki->name = KdSaveString("Linux console keyboard");
+
+    readKernelMapping (ki);
 
-    KdRegisterFd (LinuxKbdType, LinuxConsoleFd, LinuxKeyboardRead, 0);
-    LinuxKeyboardEnable (LinuxConsoleFd, 0);
-    KdRegisterFdEnableDisable (LinuxConsoleFd, 
-			       LinuxKeyboardEnable,
-			       LinuxKeyboardDisable);
-    return 1;
+    return Success;
 }
 
 static void
-LinuxKeyboardFini (void)
+LinuxKeyboardFini (KdKeyboardInfo *ki)
 {
-    LinuxKeyboardDisable (LinuxConsoleFd, 0);
-    KdUnregisterFds (LinuxKbdType, FALSE);
 }
 
 static void
-LinuxKeyboardLeds (int leds)
+LinuxKeyboardLeds (KdKeyboardInfo *ki, int leds)
 {
-    ioctl (LinuxConsoleFd, KDSETLED, leds & 7);
+    if (!ki)
+        return;
+
+    ioctl ((int)ki->driverPrivate, KDSETLED, leds & 7);
 }
 
 static void
-LinuxKeyboardBell (int volume, int pitch, int duration)
+LinuxKeyboardBell (KdKeyboardInfo *ki, int volume, int pitch, int duration)
 {
+    if (!ki)
+        return;
+
     if (volume && pitch)
     {
-	ioctl(LinuxConsoleFd, KDMKTONE,
+	ioctl((int)ki->driverPrivate, KDMKTONE,
 	      ((1193190 / pitch) & 0xffff) |
 	      (((unsigned long)duration *
 		volume / 50) << 16));
@@ -477,11 +809,13 @@ LinuxKeyboardBell (int volume, int pitch
     }
 }
 
-KdKeyboardFuncs	LinuxKeyboardFuncs = {
-    LinuxKeyboardLoad,
+KdKeyboardDriver LinuxKeyboardDriver = {
+    "keyboard",
     LinuxKeyboardInit,
+    LinuxKeyboardEnable,
     LinuxKeyboardLeds,
     LinuxKeyboardBell,
+    LinuxKeyboardDisable,
     LinuxKeyboardFini,
-    3,
+    NULL,
 };
diff --git a/hw/kdrive/linux/linux.c b/hw/kdrive/linux/linux.c
index be11ec5..e75f8d5 100644
--- a/hw/kdrive/linux/linux.c
+++ b/hw/kdrive/linux/linux.c
@@ -456,6 +456,7 @@ LinuxFini (void)
 	}
     }
     close(LinuxConsoleFd);                /* make the vt-manager happy */
+    LinuxConsoleFd = -1;
     fd = open ("/dev/tty0", O_RDWR|O_NDELAY, 0);
     if (fd >= 0)
     {
diff --git a/hw/kdrive/linux/mouse.c b/hw/kdrive/linux/mouse.c
index 5fe9978..77ec3b3 100644
--- a/hw/kdrive/linux/mouse.c
+++ b/hw/kdrive/linux/mouse.c
@@ -206,10 +206,10 @@ MouseWriteBytes (int fd, unsigned char *
 
 typedef struct _kmouseProt {
     char	    *name;
-    Bool	    (*Complete) (KdMouseInfo *mi, unsigned char *ev, int ne);
-    int		    (*Valid) (KdMouseInfo *mi, unsigned char *ev, int ne);
-    Bool	    (*Parse) (KdMouseInfo *mi, unsigned char *ev, int ne);
-    Bool	    (*Init) (KdMouseInfo *mi);
+    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;
@@ -238,9 +238,9 @@ typedef struct _kmouse {
     unsigned long	state;	/* private per protocol, init to prot->state */
 } Kmouse;
     
-static int mouseValid (KdMouseInfo *mi, unsigned char *ev, int ne)
+static int mouseValid (KdPointerInfo *pi, unsigned char *ev, int ne)
 {
-    Kmouse		*km = mi->driver;
+    Kmouse		*km = pi->driverPrivate;
     const KmouseProt	*prot = km->prot;
     int	    i;
 
@@ -255,24 +255,24 @@ static int mouseValid (KdMouseInfo *mi, 
     return 0;
 }
 
-static Bool threeComplete (KdMouseInfo *mi, unsigned char *ev, int ne)
+static Bool threeComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
 {
     return ne == 3;
 }
 
-static Bool fourComplete (KdMouseInfo *mi, unsigned char *ev, int ne)
+static Bool fourComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
 {
     return ne == 4;
 }
 
-static Bool fiveComplete (KdMouseInfo *mi, unsigned char *ev, int ne)
+static Bool fiveComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
 {
     return ne == 5;
 }
 
-static Bool MouseReasonable (KdMouseInfo *mi, unsigned long flags, int dx, int dy)
+static Bool MouseReasonable (KdPointerInfo *pi, unsigned long flags, int dx, int dy)
 {
-    Kmouse		*km = mi->driver;
+    Kmouse		*km = pi->driverPrivate;
 
     if (km->stage == MouseWorking) 
 	return TRUE;
@@ -296,9 +296,9 @@ static Bool MouseReasonable (KdMouseInfo
 /*
  * Standard PS/2 mouse protocol
  */
-static Bool ps2Parse (KdMouseInfo *mi, unsigned char *ev, int ne)
+static Bool ps2Parse (KdPointerInfo *pi, unsigned char *ev, int ne)
 {
-    Kmouse	    *km = mi->driver;
+    Kmouse	    *km = pi->driverPrivate;
     int		    dx, dy, dz;
     unsigned long   flags;
     unsigned long   flagsrelease = 0;
@@ -333,21 +333,21 @@ static Bool ps2Parse (KdMouseInfo *mi, u
     if (ev[0] & 0x20)
 	dy -= 256;
     dy = -dy;
-    if (!MouseReasonable (mi, flags, dx, dy))
+    if (!MouseReasonable (pi, flags, dx, dy))
 	return FALSE;
     if (km->stage == MouseWorking)
     {
-	KdEnqueueMouseEvent (mi, flags, dx, dy);
+	KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
 	if (flagsrelease)
 	{
 	    flags &= ~flagsrelease;
-	    KdEnqueueMouseEvent (mi, flags, dx, dy);
+	    KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
 	}
     }
     return TRUE;
 }
 
-static Bool ps2Init (KdMouseInfo *mi);
+static Bool ps2Init (KdPointerInfo *pi);
 
 static const KmouseProt ps2Prot = {
     "ps/2",
@@ -450,9 +450,9 @@ static unsigned char	intelli_init[] = {
 #define NINIT_INTELLI	3
 
 static int
-ps2SkipInit (KdMouseInfo *mi, int ninit, Bool ret_next)
+ps2SkipInit (KdPointerInfo *pi, int ninit, Bool ret_next)
 {
-    Kmouse  *km = mi->driver;
+    Kmouse  *km = pi->driverPrivate;
     int	    c = -1;
     int	    skipping;
     Bool    waiting;
@@ -481,9 +481,9 @@ ps2SkipInit (KdMouseInfo *mi, int ninit,
 }
 
 static Bool
-ps2Init (KdMouseInfo *mi)
+ps2Init (KdPointerInfo *pi)
 {
-    Kmouse	    *km = mi->driver;
+    Kmouse	    *km = pi->driverPrivate;
     int		    skipping;
     Bool	    waiting;
     int		    id;
@@ -499,7 +499,7 @@ ps2Init (KdMouseInfo *mi)
 	return FALSE;
     skipping = 0;
     waiting = FALSE;
-    id = ps2SkipInit (mi, 0, TRUE);
+    id = ps2SkipInit (pi, 0, TRUE);
     switch (id) {
     case 3:
 	init = wheel_3button_init;
@@ -524,13 +524,13 @@ ps2Init (KdMouseInfo *mi)
      * initialization string.  Make sure any partial event is
      * skipped
      */
-    (void) ps2SkipInit (mi, ninit, FALSE);
+    (void) ps2SkipInit (pi, ninit, FALSE);
     return TRUE;
 }
 
-static Bool busParse (KdMouseInfo *mi, unsigned char *ev, int ne)
+static Bool busParse (KdPointerInfo *pi, unsigned char *ev, int ne)
 {
-    Kmouse	    *km = mi->driver;
+    Kmouse	    *km = pi->driverPrivate;
     int		    dx, dy;
     unsigned long   flags;
     
@@ -543,10 +543,10 @@ static Bool busParse (KdMouseInfo *mi, u
 	flags |= KD_BUTTON_2;
     if ((ev[0] & 1) == 0)
 	flags |= KD_BUTTON_3;
-    if (!MouseReasonable (mi, flags, dx, dy))
+    if (!MouseReasonable (pi, flags, dx, dy))
 	return FALSE;
     if (km->stage == MouseWorking)
-	KdEnqueueMouseEvent (mi, flags, dx, dy);
+	KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
     return TRUE;
 }
 
@@ -561,9 +561,9 @@ static const KmouseProt busProt = {
  * Standard MS serial protocol, three bytes
  */
 
-static Bool msParse (KdMouseInfo *mi, unsigned char *ev, int ne)
+static Bool msParse (KdPointerInfo *pi, unsigned char *ev, int ne)
 {
-    Kmouse	    *km = mi->driver;
+    Kmouse	    *km = pi->driverPrivate;
     int		    dx, dy;
     unsigned long   flags;
 
@@ -576,10 +576,10 @@ static Bool msParse (KdMouseInfo *mi, un
 
     dx = (signed char)(((ev[0] & 0x03) << 6) | (ev[1] & 0x3F));
     dy = (signed char)(((ev[0] & 0x0C) << 4) | (ev[2] & 0x3F));
-    if (!MouseReasonable (mi, flags, dx, dy))
+    if (!MouseReasonable (pi, flags, dx, dy))
 	return FALSE;
     if (km->stage == MouseWorking)
-	KdEnqueueMouseEvent (mi, flags, dx, dy);
+	KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
     return TRUE;
 }
 
@@ -600,9 +600,9 @@ static const KmouseProt msProt = {
  * 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 (KdMouseInfo *mi, unsigned char *ev, int ne)
+static Bool logiComplete (KdPointerInfo *pi, unsigned char *ev, int ne)
 {
-    Kmouse		*km = mi->driver;
+    Kmouse		*km = pi->driverPrivate;
 
     if ((ev[0] & 0x40) == 0x40)
 	return ne == 3;
@@ -611,9 +611,9 @@ static Bool logiComplete (KdMouseInfo *m
     return FALSE;
 }
 
-static int logiValid (KdMouseInfo *mi, unsigned char *ev, int ne)
+static int logiValid (KdPointerInfo *pi, unsigned char *ev, int ne)
 {
-    Kmouse		*km = mi->driver;
+    Kmouse		*km = pi->driverPrivate;
     const KmouseProt	*prot = km->prot;
     int	    i;
 
@@ -632,9 +632,9 @@ static int logiValid (KdMouseInfo *mi, u
     return 0;
 }
 
-static Bool logiParse (KdMouseInfo *mi, unsigned char *ev, int ne)
+static Bool logiParse (KdPointerInfo *pi, unsigned char *ev, int ne)
 {
-    Kmouse	    *km = mi->driver;
+    Kmouse	    *km = pi->driverPrivate;
     int		    dx, dy;
     unsigned long   flags;
 
@@ -660,10 +660,10 @@ static Bool logiParse (KdMouseInfo *mi, 
 	flags |= km->state & (KD_BUTTON_1|KD_BUTTON_3);
     }
 
-    if (!MouseReasonable (mi, flags, dx, dy))
+    if (!MouseReasonable (pi, flags, dx, dy))
 	return FALSE;
     if (km->stage == MouseWorking)
-	KdEnqueueMouseEvent (mi, flags, dx, dy);
+	KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
     return TRUE;
 }
 
@@ -682,9 +682,9 @@ static const KmouseProt logiProt = {
 /*
  * Mouse systems protocol, 5 bytes
  */
-static Bool mscParse (KdMouseInfo *mi, unsigned char *ev, int ne)
+static Bool mscParse (KdPointerInfo *pi, unsigned char *ev, int ne)
 {
-    Kmouse	    *km = mi->driver;
+    Kmouse	    *km = pi->driverPrivate;
     int		    dx, dy;
     unsigned long   flags;
 
@@ -699,10 +699,10 @@ static Bool mscParse (KdMouseInfo *mi, u
     dx =    (signed char)(ev[1]) + (signed char)(ev[3]);
     dy = - ((signed char)(ev[2]) + (signed char)(ev[4]));
 
-    if (!MouseReasonable (mi, flags, dx, dy))
+    if (!MouseReasonable (pi, flags, dx, dy))
 	return FALSE;
     if (km->stage == MouseWorking)
-	KdEnqueueMouseEvent (mi, flags, dx, dy);
+	KdEnqueuePointerEvent (pi, flags, dx, dy, 0);
     return TRUE;
 }
 
@@ -810,8 +810,8 @@ MouseNextProtocol (Kmouse *km)
 static void
 MouseRead (int mousePort, void *closure)
 {
-    KdMouseInfo	    *mi = closure;
-    Kmouse	    *km = mi->driver;
+    KdPointerInfo   *pi = closure;
+    Kmouse	    *km = pi->driverPrivate;
     unsigned char   event[MAX_MOUSE];
     int		    ne;
     int		    c;
@@ -835,7 +835,7 @@ MouseRead (int mousePort, void *closure)
 	    break;
 	}
 	event[ne++] = c;
-	i = (*km->prot->Valid) (mi, event, ne);
+	i = (*km->prot->Valid) (pi, event, ne);
 	if (i != 0)
 	{
 #ifdef DEBUG
@@ -867,9 +867,9 @@ MouseRead (int mousePort, void *closure)
 	}
 	else
 	{
-	    if ((*km->prot->Complete) (mi, event, ne))
+	    if ((*km->prot->Complete) (pi, event, ne))
 	    {
-		if ((*km->prot->Parse) (mi, event, ne))
+		if ((*km->prot->Parse) (pi, event, ne))
 		{
 		    switch (km->stage)
 		    {
@@ -896,7 +896,7 @@ MouseRead (int mousePort, void *closure)
 			    km->invalid = 0;
 			    km->tested = 0;
 			    km->valid = 0;
-			    if (km->prot->Init && !(*km->prot->Init) (mi))
+			    if (km->prot->Init && !(*km->prot->Init) (pi))
 				km->stage = MouseBroken;
 			}
 			break;
@@ -923,9 +923,9 @@ MouseRead (int mousePort, void *closure)
 int MouseInputType;
 
 char *kdefaultMouse[] =  {
+    "/dev/input/mice",
     "/dev/mouse",
     "/dev/psaux",
-    "/dev/input/mice",
     "/dev/adbmouse",
     "/dev/ttyS0",
     "/dev/ttyS1",
@@ -933,81 +933,97 @@ char *kdefaultMouse[] =  {
 
 #define NUM_DEFAULT_MOUSE    (sizeof (kdefaultMouse) / sizeof (kdefaultMouse[0]))
 
-static Bool
-MouseInit (void)
+static Status
+MouseInit (KdPointerInfo *pi)
 {
     int		i;
     int		fd;
     Kmouse	*km;
-    KdMouseInfo	*mi, *next;
-    int		n = 0;
-    char	*prot;
-
-    if (!MouseInputType)
-	MouseInputType = KdAllocInputType ();
-
-    for (mi = kdMouseInfo; mi; mi = next)
-    {
-	next = mi->next;
-	prot = mi->prot;
-	if (mi->inputType)
-	    continue;
-	if (!mi->name)
-	{
-	    for (i = 0; i < NUM_DEFAULT_MOUSE; i++)
-	    {
-		fd = open (kdefaultMouse[i], 2);
-		if (fd >= 0)
-		{
-		    mi->name = KdSaveString (kdefaultMouse[i]);
-		    break;
-		}
-	    }
-	}
-	else
-	    fd = open (mi->name, 2);
+
+    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 = KdSaveString (kdefaultMouse[i]);
+                break;
+            }
+        }
+    }
+    else {
+        fd = open (pi->path, 2);
+    }
 	    
-	if (fd >= 0)
-	{
-	    km = (Kmouse *) xalloc (sizeof (Kmouse));
-	    if (km)
-	    {
-		km->iob.fd = fd;
-		km->iob.avail = km->iob.used = 0;
-		km->prot = 0;
-		km->i_prot = 0;
-		km->tty = isatty (fd);
-		mi->driver = km;
-		mi->inputType = MouseInputType;
-		MouseFirstProtocol (km, mi->prot);
-		if (KdRegisterFd (MouseInputType, fd, MouseRead, (void *) mi))
-		    n++;
-	    }
-	    else
-		close (fd);
-	}
+    if (fd < 0)
+        return BadMatch;
+
+    close(fd);
+
+    km = (Kmouse *) xalloc (sizeof (Kmouse));
+    if (km) {
+        km->iob.avail = km->iob.used = 0;
+        MouseFirstProtocol(km, "exps/2");
+        km->i_prot = 0;
+        km->tty = isatty (fd);
+        km->iob.fd = -1;
+        pi->driverPrivate = km;
     }
-    return TRUE;
+    else {
+        close (fd);
+        return BadAlloc;
+    }
+
+    return Success;
 }
 
-static void
-MouseFini (void)
+static Status
+MouseEnable (KdPointerInfo *pi)
 {
-    KdMouseInfo	*mi;
+    Kmouse *km;
 
-    KdUnregisterFds (MouseInputType, TRUE);
-    for (mi = kdMouseInfo; mi; mi = mi->next)
+    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))
     {
-	if (mi->inputType == MouseInputType)
-	{
-	    xfree (mi->driver);
-	    mi->driver = 0;
-	    mi->inputType = 0;
-	}
+        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)
+{
+    xfree (pi->driverPrivate);
+    pi->driverPrivate = NULL;
 }
 
-KdMouseFuncs LinuxMouseFuncs = {
+KdPointerDriver LinuxMouseDriver = {
+    "mouse",
     MouseInit,
+    MouseEnable,
+    MouseDisable,
     MouseFini,
+    NULL,
 };
diff --git a/hw/kdrive/linux/ms.c b/hw/kdrive/linux/ms.c
index 7f046bd..e62cebc 100644
--- a/hw/kdrive/linux/ms.c
+++ b/hw/kdrive/linux/ms.c
@@ -90,41 +90,50 @@ MsRead (int port, void *closure)
 	    dy = (char)(((b[0] & 0x0C) << 4) | (b[2] & 0x3F));
             n -= 3;
             b += 3;
-	    KdEnqueueMouseEvent (kdMouseInfo, flags, dx, dy);
+	    KdEnqueuePointerEvent (closure, flags, dx, dy, 0);
 	}
     }
 }
 
-int MsInputType;
+static Status
+MsInit (KdPointerInfo *pi)
+{
+    if (!pi)
+        return BadImplementation;
+
+    if (!pi->path || strcmp(pi->path, "auto"))
+        pi->path = KdSaveString("/dev/mouse");
+    if (!pi->name)
+        pi->name = KdSaveString("Microsoft protocol mouse");
+    
+    return Success; 
+}
 
-static int
-MsInit (void)
+static Status
+MsEnable (KdPointerInfo *pi)
 {
     int port;
-    char *device = "/dev/mouse";
     struct termios t;
     int ret;
 
-    if (!MsInputType)
-	MsInputType = KdAllocInputType ();
-    port = open (device, O_RDWR | O_NONBLOCK);
+    port = open (pi->path, O_RDWR | O_NONBLOCK);
     if(port < 0) {
-        ErrorF("Couldn't open %s (%d)\n", device, (int)errno);
+        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",
-               device);
+               pi->path);
 	goto bail;
     }
 
     if(!isatty(port)) {
-        ErrorF("%s is not a tty\n", device);
+        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", device, errno);
+        ErrorF("Couldn't tcgetattr(%s): %d\n", pi->path, errno);
         goto bail;
     }
     t.c_iflag &= ~ (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR |
@@ -140,24 +149,36 @@ MsInit (void)
     t.c_cc[VTIME] = 0;
     ret = tcsetattr(port, TCSANOW, &t);
     if(ret < 0) {
-        ErrorF("Couldn't tcsetattr(%s): %d\n", device, errno);
+        ErrorF("Couldn't tcsetattr(%s): %d\n", pi->path, errno);
         goto bail;
     }
-    if (KdRegisterFd (MsInputType, port, MsRead, (void *) 0))
-	return 1;
+    if (KdRegisterFd (port, MsRead, pi))
+	return TRUE;
+    pi->driverPrivate = (void *)port;
+
+    return Success;
 
  bail:
     close(port);
-    return 0;
+    return BadMatch;
+}
+
+static void
+MsDisable (KdPointerInfo *pi)
+{
+    KdUnregisterFd (pi, (int)pi->driverPrivate, TRUE);
 }
 
 static void
-MsFini (void)
+MsFini (KdPointerInfo *pi)
 {
-    KdUnregisterFds (MsInputType, TRUE);
 }
 
-KdMouseFuncs MsMouseFuncs = {
+KdPointerDriver MsMouseDriver = {
+    "ms",
     MsInit,
-    MsFini
+    MsEnable,
+    MsDisable,
+    MsFini,
+    NULL,
 };
diff --git a/hw/kdrive/linux/ps2.c b/hw/kdrive/linux/ps2.c
index b59dbfa..5d523a2 100644
--- a/hw/kdrive/linux/ps2.c
+++ b/hw/kdrive/linux/ps2.c
@@ -112,42 +112,78 @@ Ps2Read (int ps2Port, void *closure)
 	    dy = -dy;
 	    n -= 3;
 	    b += 3;
-	    KdEnqueueMouseEvent (kdMouseInfo, flags, dx, dy);
+	    KdEnqueuePointerEvent (closure, flags, dx, dy, 0);
 	}
     }
 }
 
-int Ps2InputType;
-
-static int
-Ps2Init (void)
+static Status
+Ps2Init (KdPointerInfo *pi)
 {
-    int	    i;
-    int	    ps2Port;
-    int	    n;
-
-    if (!Ps2InputType)
-	Ps2InputType = KdAllocInputType ();
-    n = 0;
-    for (i = 0; i < NUM_PS2_NAMES; i++)
-    {
-	ps2Port = open (Ps2Names[i], 0);
-	if (ps2Port >= 0)
-	{
-	    if (KdRegisterFd (Ps2InputType, ps2Port, Ps2Read, (void *) i))
-		n++;
+    int	ps2Port, i;
+
+    if (!pi->path) {
+        for (i = 0; i < NUM_PS2_NAMES; i++) {
+            ps2Port = open (Ps2Names[i], 0);
+            if (ps2Port >= 0) {
+                pi->path = KdSaveString (Ps2Names[i]);
+                break;
+            }
 	}
     }
-    return n;
+    else {
+        ps2Port = open (pi->path, 0);
+    }
+
+    if (ps2Port < 0)
+        return BadMatch;
+
+    close(ps2Port);
+    if (!pi->name)
+        pi->name = KdSaveString ("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 *)fd;
+
+    return Success;
+}
+
+
+static void
+Ps2Disable (KdPointerInfo *pi)
+{
+    KdUnregisterFd (pi, (int)pi->driverPrivate, TRUE);
 }
 
 static void
-Ps2Fini (void)
+Ps2Fini (KdPointerInfo *pi)
 {
-    KdUnregisterFds (Ps2InputType, TRUE);
 }
 
-KdMouseFuncs Ps2MouseFuncs = {
+KdPointerDriver Ps2MouseDriver = {
+    "ps2",
     Ps2Init,
-    Ps2Fini
+    Ps2Enable,
+    Ps2Disable,
+    Ps2Fini,
+    NULL,
 };
diff --git a/hw/kdrive/linux/ts.c b/hw/kdrive/linux/ts.c
index 70c7361..701fdc8 100644
--- a/hw/kdrive/linux/ts.c
+++ b/hw/kdrive/linux/ts.c
@@ -75,7 +75,7 @@ TsReadBytes (int fd, char *buf, int len,
 static void
 TsRead (int tsPort, void *closure)
 {
-    KdMouseInfo	    *mi = closure;
+    KdPointerInfo    *pi = closure;
     TS_EVENT	    event;
     int		    n;
     long	    x, y;
@@ -117,7 +117,7 @@ TsRead (int tsPort, void *closure)
 	    lastx = 0;
 	    lasty = 0;
 	}
-	KdEnqueueMouseEvent (mi, flags, x, y);
+	KdEnqueuePointerEvent (pi, flags, x, y, 0);
     }
 }
 
@@ -129,95 +129,83 @@ char	*TsNames[] = {
 
 #define NUM_TS_NAMES	(sizeof (TsNames) / sizeof (TsNames[0]))
 
-int TsInputType;
-
-static int
-TsEnable (int fd, void *closure)
-{
-    KdMouseInfo *mi = (KdMouseInfo *)closure;
-
-    return open (mi->name, 0);
-}
-
-static void
-TsDisable (int fd, void *closure)
-{
-    close (fd);
-}
-
-static int
-TsInit (void)
+static Status
+TsInit (KdPointerInfo *pi)
 {
     int		i;
     int		fd;
-    KdMouseInfo	*mi, *next;
     int		n = 0;
 
-    if (!TsInputType)
-	TsInputType = KdAllocInputType ();
-    
-    for (mi = kdMouseInfo; mi; mi = next)
-    {
-	next = mi->next;
-	if (mi->inputType)
-	    continue;
-	if (!mi->name)
-	{
-	    for (i = 0; i < NUM_TS_NAMES; i++)    
-	    {
-		fd = open (TsNames[i], 0);
-		if (fd >= 0) 
-		{
-		    mi->name = KdSaveString (TsNames[i]);
-		    break;
-		}
-	    }
+    if (!pi->path || strcmp(pi->path, "auto") == 0) {
+        for (i = 0; i < NUM_TS_NAMES; i++)    {
+            fd = open (TsNames[i], 0);
+            if (fd >= 0) {
+                pi->path = KdSaveString (TsNames[i]);
+                break;
+            }
 	}
-	else
-	    fd = open (mi->name, 0);
-	if (fd >= 0)
-	{
-	    struct h3600_ts_calibration cal;
-	    /*
-	     * Check to see if this is a touch screen
-	     */
-	    if (ioctl (fd, TS_GET_CAL, &cal) != -1)
-	    {
-		mi->driver = (void *) fd;
-		mi->inputType = TsInputType;
-		if (KdRegisterFd (TsInputType, fd, TsRead, (void *) mi))
-		{
-		    /* Set callbacks for vt switches etc */
-		    KdRegisterFdEnableDisable (fd, TsEnable, TsDisable);
+    }
+    else {
+        fd = open (pi->path, 0);
+    }
 
-		    n++;
-		}
-	    }
-	    else
-		close (fd);
-	}
+    if (fd < 0) {
+        ErrorF("TsInit: Couldn't open %s\n", pi->path);
+        return BadMatch;
     }
+    close(fd);
 
-    return 0;
+    pi->name = KdSaveString("H3600 Touchscreen");
+
+    return Success;
 }
 
-static void
-TsFini (void)
+static Status
+TsEnable (KdPointerInfo *pi)
 {
-    KdMouseInfo	*mi;
+    int fd;
 
-    KdUnregisterFds (TsInputType, TRUE);
-    for (mi = kdMouseInfo; mi; mi = mi->next)
-    {
-	if (mi->inputType == TsInputType)
-	{
-	    mi->driver = 0;
-	    mi->inputType = 0;
+    if (!pi || !pi->path)
+        return BadImplementation;
+
+    fd = open(pi->path, 0);
+
+    if (fd < 0) {
+        ErrorF("TsInit: Couldn't open %s\n", pi->path);
+        return BadMatch;
+    }
+
+    struct h3600_ts_calibration cal;
+    /*
+     * Check to see if this is a touch screen
+     */
+    if (ioctl (fd, TS_GET_CAL, &cal) != -1) {
+	mi->driverPrivate = (void *) fd;
+	if (!KdRegisterFd (fd, TsRead, (void *) mi)) {
+            close(fd);
+            return BadAlloc;
 	}
     }
+    else {
+        ErrorF("TsEnable: %s is not a touchscreen\n", pi->path);
+	close (fd);
+        return BadMatch;
+    }
+
+    return Success;
+}
+
+static void
+TsFini (KdPointerInfo *pi)
+{
+    KdUnregisterFds (pi, (int)pi->driverPrivate, TRUE);
+    mi->driverPrivate = NULL;
 }
 
-KdMouseFuncs TsFuncs = {
+KdPointerDriver TsDriver = {
     TsInit,
-    TsFini
+    TsEnable,
+    TsDisable,
+    TsFini,
+    NULL,
 };
diff --git a/hw/kdrive/linux/tslib.c b/hw/kdrive/linux/tslib.c
index c4caff9..aa57e87 100644
--- a/hw/kdrive/linux/tslib.c
+++ b/hw/kdrive/linux/tslib.c
@@ -1,73 +1,39 @@
 /*
- * $RCSId: xc/programs/Xserver/hw/kdrive/linux/tslib.c,v 1.1 2002/11/01 22:27:49 keithp Exp $
- * TSLIB based touchscreen driver for TinyX
+ * TSLIB based touchscreen driver for KDrive
+ * Porting to new input API and event queueing by Daniel Stone.
  * Derived from ts.c by Keith Packard
  * Derived from ps2.c by Jim Gettys
  *
  * Copyright © 1999 Keith Packard
  * Copyright © 2000 Compaq Computer Corporation
  * Copyright © 2002 MontaVista Software Inc.
- * Copyright © 2005 OpenedHand Ltd.
+ * Copyright © 2006 Nokia Corporation
  * 
  * 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 or Compaq not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard and Compaq makes no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
+ * documentation, and that the name of the authors and/or copyright holders
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  The authors and/or
+ * copyright holders make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
+ * implied warranty.
  *
- * KEITH PACKARD AND COMPAQ DISCLAIM 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.
- * 
- * 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 Michael Taht or MontaVista not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Michael Taht and Montavista make no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * MICHAEL TAHT AND MONTAVISTA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, 
- * IN NO EVENT SHALL EITHER 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.
- *
- * 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 Matthew Allum or OpenedHand not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Matthew Allum and OpenedHand make no
- * representations about the suitability of this software for any purpose.  It
- * is provided "as is" without express or implied warranty.
- *
- * MATTHEW ALLUM AND OPENEDHAND DISCLAIM ALL WARRANTIES WITH REGARD TO THIS 
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, 
- * IN NO EVENT SHALL EITHER 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.
+ * THE AUTHORS AND/OR COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL THE AUTHORS AND/OR COPYRIGHT HOLDERS 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
+#ifdef HAVE_KDRIVE_CONFIG_H
 #include <kdrive-config.h>
 #endif
+
 #define NEED_EVENTS
 #include <X11/X.h>
 #include <X11/Xproto.h>
@@ -77,186 +43,171 @@
 #include "kdrive.h"
 #include <sys/ioctl.h>
 #include <tslib.h>
+#include <dirent.h>
+#include <linux/input.h>
 
-static struct tsdev *tsDev = NULL;
-
-static char *TsNames[] = {
-  NULL, 			/* set via TSLIB_TSDEVICE */
-  "/dev/ts",	
-  "/dev/touchscreen/0",
+struct TslibPrivate {
+    int fd;
+    int lastx, lasty;
+    struct tsdev *tsDev;
+    void (*raw_event_hook)(int x, int y, int pressure, void *closure);
+    void *raw_event_closure;
+    int phys_screen;
 };
 
-#define NUM_TS_NAMES (sizeof (TsNames) / sizeof (TsNames[0]))
-
-/* For XCalibrate extension */
-void (*tslib_raw_event_hook)(int x, int y, int pressure, void *closure);
-void *tslib_raw_event_closure;
-
-int TsInputType = 0;
-int KdTsPhyScreen = 0; 		/* XXX Togo .. */
 
 static void
-TsRead (int tsPort, void *closure)
+TsRead (int fd, void *closure)
 {
-    KdMouseInfo	    *mi = closure;
-    struct ts_sample event;
-    long	    x, y;
-    unsigned long   flags;
-
-    if (tslib_raw_event_hook)
-      {
-	/* XCalibrate Ext */
-	if (ts_read_raw(tsDev, &event, 1) == 1)
-	  {
-	    tslib_raw_event_hook (event.x, 
-				  event.y, 
-				  event.pressure, 
-				  tslib_raw_event_closure);
-	  }
-	return;
-      }
-
-    while (ts_read(tsDev, &event, 1) == 1)
-      {
-	flags = (event.pressure) ? KD_BUTTON_1 : 0;
-	x = event.x;
-	y = event.y;
-	
-	KdEnqueueMouseEvent (mi, flags, x, y);
-      }
-}
-
-static int
-TsLibOpen(char *dev)
-{
-  if(!(tsDev = ts_open(dev, 0)))
-    return -1;
+    KdPointerInfo       *pi = closure;
+    struct TslibPrivate *private = pi->driverPrivate;
+    struct ts_sample    event;
+    long                x = 0, y = 0;
+    unsigned long       flags;
+
+    if (private->raw_event_hook) {
+        while (ts_read_raw(private->tsDev, &event, 1) == 1)
+            private->raw_event_hook (event.x, event.y, event.pressure,
+                                     private->raw_event_closure);
+        return;
+    }
 
-  if (ts_config(tsDev))
-    return -1;
+    while (ts_read(private->tsDev, &event, 1) == 1) {
+#ifdef DEBUG
+        ErrorF("[tslib] originally from (%d, %d)\n", event.x, event.y);
+#endif
+        if (event.pressure) {
+            if (event.pressure > pi->dixdev->touchscreen->button_threshold) 
+                flags = KD_BUTTON_8;
+            else
+                flags = KD_BUTTON_1;
+
+            /* 
+             * Here we test for the touch screen driver actually being on the
+             * touch screen, if it is we send absolute coordinates. If not,
+             * then we send delta's so that we can track the entire vga screen.
+             */
+            if (KdCurScreen == private->phys_screen) {
+                x = event.x;
+                y = event.y;
+            } else {
+                flags |= KD_MOUSE_DELTA;
+                if ((private->lastx == 0) || (private->lasty == 0)) {
+                    x = event.x;
+                    y = event.y;
+                } else {
+                    x = event.x - private->lastx;
+                    y = event.y - private->lasty;
+	    	}
+            }
+            private->lastx = x;
+            private->lasty = y;
+        } else {
+            flags = 0;
+            x = private->lastx;
+            y = private->lasty;
+        }
 
-  return ts_fd(tsDev);
+#ifdef DEBUG
+        ErrorF("event at (%lu, %lu), pressure is %d, sending flags %lu\n", x, y, event.pressure, flags);
+#endif
+        KdEnqueuePointerEvent (pi, flags, x, y, event.pressure);
+    }
 }
 
-static int
-TslibEnable (int not_needed_fd, void *closure)
+static Status
+TslibEnable (KdPointerInfo *pi)
 {
-  KdMouseInfo	    *mi = closure;
-  int		     fd = 0;
+  struct TslibPrivate *private = pi->driverPrivate;
+
+    private->holdThumbEvents = 1;
+    private->raw_event_hook = NULL;
+    private->raw_event_closure = NULL;
+    private->tsDev = ts_open(pi->path, 0);
+    private->fd = ts_fd(private->tsDev);
+    if (!private->tsDev || ts_config(private->tsDev) || private->fd < 0) {
+        ErrorF("[tslib/TslibEnable] failed to open %s\n", pi->path);
+        if (private->fd > 0);
+            close(private->fd);
+        return BadAlloc;
+    }
+    if (pi->dixdev && pi->dixdev->touchscreen &&
+        pi->dixdev->touchscreen->button_threshold == 0)
+        pi->dixdev->touchscreen->button_threshold = 115;
 
-  if ((fd = TsLibOpen(mi->name)) == -1)
-    ErrorF ("Unable to re-enable TSLib ( on %s )", mi->name);
+#ifdef DEBUG
+    ErrorF("[tslib/TslibEnable] successfully enabled %s\n", pi->path);
+#endif
 
-  return fd;
+    KdRegisterFd(private->fd, TsRead, pi);
+  
+    return Success;
 }
 
+
 static void
-TslibDisable (int fd, void *closure)
+TslibDisable (KdPointerInfo *pi)
 {
-  if (tsDev)
-    ts_close(tsDev);
-  tsDev = NULL;
-}
+    struct TslibPrivate *private = pi->driverPrivate;
 
-static int
-TslibInit (void)
-{
-  int		i, j = 0;
-  KdMouseInfo	*mi, *next;
-  int		fd = 0;
-  int           req_type;
-
-  if (!TsInputType)
-    {
-      TsInputType = KdAllocInputType ();
-      KdParseMouse(0); /* allocate safe slot in kdMouseInfo */
-      req_type = 0;
+    if (private->fd) {
+        KdUnregisterFd(pi, private->fd);
+        close(private->fd);
     }
-  else req_type = TsInputType; 	/* is being re-inited */
-  
-  for (mi = kdMouseInfo; mi; mi = next)
-    {
-      next = mi->next;
-      
-      /* find a usuable slot */
-      if (mi->inputType != req_type) 
-	continue;
-      
-      /* Check for tslib env var device setting */
-      if ((TsNames[0] = getenv("TSLIB_TSDEVICE")) == NULL)
-	j++;
-      
-      if (!mi->name)
-	{
-	  for (i = j; i < NUM_TS_NAMES; i++)    
-	    {
-	      fd = TsLibOpen(TsNames[i]);
-	      
-	      if (fd >= 0) 
-		{
-		  mi->name = KdSaveString (TsNames[i]);
-		  break;
-		}
-	    }
-	} 
-      else 
-	fd = TsLibOpen(mi->name);
-      
-      if (fd >= 0 && tsDev != NULL) 
-	{
-	  mi->driver    = (void *) fd;
-	  mi->inputType = TsInputType;
-	  
-	  KdRegisterFd (TsInputType, fd, TsRead, (void *) mi);
-	  
-	  /* Set callbacks for vt switches etc */
-	  KdRegisterFdEnableDisable (fd, TslibEnable, TslibDisable);
-	  
-	  return TRUE;
-	} 
-    }
-  
-  ErrorF ("Failed to open TSLib device, tried ");
-  for (i = j; i < NUM_TS_NAMES; i++)    
-    ErrorF ("%s ", TsNames[i]);
-  ErrorF (".\n");
-  if (!TsNames[0]) 
-    ErrorF ("Try setting TSLIB_TSDEVICE to valid /dev entry?\n");
-  
-  if (fd > 0) 
-    close(fd);
-  
-  return FALSE;
+    if (private->tsDev)
+        ts_close(private->tsDev);
+    private->fd = 0;
+    private->tsDev = NULL;
+}
+
+
+static Status
+TslibInit (KdPointerInfo *pi)
+{
+    int		        fd = 0, i = 0;
+    char                devpath[PATH_MAX], devname[TS_NAME_SIZE];
+    DIR                 *inputdir = NULL;
+    struct dirent       *inputent = NULL;
+    struct tsdev        *tsDev = NULL;
+    struct TslibPrivate *private = NULL;
+
+    if (!pi || !pi->dixdev)
+        return !Success;
+    
+    pi->driverPrivate = (struct TslibPrivate *)
+                        xcalloc(sizeof(struct TslibPrivate), 1);
+    if (!pi->driverPrivate)
+        return !Success;
+
+    private = pi->driverPrivate;
+    /* hacktastic */
+    private->phys_screen = 0;
+    pi->nAxes = 3;
+    pi->name = KdSaveString("Touchscreen");
+    pi->inputClass = KD_TOUCHSCREEN;
+#ifdef DEBUG
+    ErrorF("[tslib/TslibInit] successfully inited for device %s\n", pi->path);
+#endif
+
+    return Success;
 }
 
+
 static void
-TslibFini (void)
+TslibFini (KdPointerInfo *pi)
 {
-    KdMouseInfo	*mi;
-
-    KdUnregisterFds (TsInputType, TRUE);
-    for (mi = kdMouseInfo; mi; mi = mi->next)
-    {
-	if (mi->inputType == TsInputType)
-	{
-	    if(mi->driver) 
-	      {
-		ts_close(tsDev);
-		tsDev = NULL;
-	      }
-	    mi->driver    = 0;
-
-	    /* If below is set to 0, then MouseInit() will trash it,
-	     * setting to 'mouse type' ( via server reset). Therefore 
-             * Leave it alone and work around in TslibInit()  ( see
-             * req_type ).
-	    */
-	    /* mi->inputType = 0; */
-	}
+    if (pi->driverPrivate) {
+        xfree(pi->driverPrivate);
+        pi->driverPrivate = NULL;
     }
 }
 
-KdMouseFuncs TsFuncs = {
+
+KdPointerDriver TsDriver = {
+    "tslib",
     TslibInit,
-    TslibFini
+    TslibEnable,
+    TslibDisable,
+    TslibFini,
+    NULL,
 };
diff --git a/hw/kdrive/src/Makefile.am b/hw/kdrive/src/Makefile.am
index 53d5095..20fae55 100644
--- a/hw/kdrive/src/Makefile.am
+++ b/hw/kdrive/src/Makefile.am
@@ -24,7 +24,7 @@ libkdrive_a_SOURCES =	\
 	kdrive.h	\
 	kinfo.c		\
 	kinput.c	\
-	kkeymap.h	\
+	kkeymap.c	\
 	kmap.c		\
 	kmode.c		\
 	knoop.c		\
@@ -37,5 +37,4 @@ libkdrive_a_SOURCES =	\
         $(top_srcdir)/mi/miinitext.c
 
 libkdrivestubs_a_SOURCES = \
-        $(top_srcdir)/Xi/stubs.c \
         $(top_srcdir)/fb/fbcmap.c
diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c
index 52e56e9..05102ab 100644
--- a/hw/kdrive/src/kdrive.c
+++ b/hw/kdrive/src/kdrive.c
@@ -43,6 +43,12 @@
 #include "dpmsproc.h"
 #endif
 
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
+#endif
+
+#include <signal.h>
+
 typedef struct _kdDepths {
     CARD8   depth;
     CARD8   bpp;
@@ -60,6 +66,8 @@ KdDepths    kdDepths[] = {
 
 #define NUM_KD_DEPTHS (sizeof (kdDepths) / sizeof (kdDepths[0]))
 
+#define KD_DEFAULT_BUTTONS 5
+
 int                 kdScreenPrivateIndex;
 unsigned long       kdGeneration;
 
@@ -76,6 +84,8 @@ Bool		    kdSwitchPending;
 char		    *kdSwitchCmd;
 DDXPointRec	    kdOrigin;
 
+static Bool         kdCaughtSignal = FALSE;
+
 /*
  * Carry arguments from InitOutput through driver initialization
  * to KdScreenInit
@@ -368,6 +378,9 @@ AbortDDX(void)
 	(*kdOsFuncs->Fini) ();
 	KdDoSwitchCmd ("stop");
     }
+
+    if (kdCaughtSignal)
+        abort();
 }
 
 void
@@ -379,7 +392,7 @@ ddxGiveUp ()
 Bool	kdDumbDriver;
 Bool	kdSoftCursor;
 
-static char *
+char *
 KdParseFindNext (char *cur, char *delim, char *save, char *last)
 {
     while (*cur && !strchr (delim, *cur))
@@ -560,97 +573,6 @@ KdSaveString (char *str)
     return n;
 }
 
-/*
- * Parse mouse information.  Syntax:
- *
- *  <device>,<nbutton>,<protocol>{,<option>}...
- *
- * options: {nmo}   pointer mapping (e.g. {321})
- *	    2button emulate middle button
- *	    3button dont emulate middle button
- */
-
-void
-KdParseMouse (char *arg)
-{
-    char	save[1024];
-    char	delim;
-    KdMouseInfo	*mi;
-    int		i;
-    
-    mi = KdMouseInfoAdd ();
-    if (!mi)
-	return;
-    mi->name = 0;
-    mi->prot = 0;
-    mi->emulateMiddleButton = kdEmulateMiddleButton;
-    mi->transformCoordinates = !kdRawPointerCoordinates;
-    mi->nbutton = 3;
-    for (i = 0; i < KD_MAX_BUTTON; i++)
-	mi->map[i] = i + 1;
-    
-    if (!arg)
-	return;
-    if (strlen (arg) >= sizeof (save))
-	return;
-    arg = KdParseFindNext (arg, ",", save, &delim);
-    if (!save[0])
-	return;
-    mi->name = KdSaveString (save);
-    if (delim != ',')
-	return;
-    
-    arg = KdParseFindNext (arg, ",", save, &delim);
-    if (!save[0])
-	return;
-    
-    if ('1' <= save[0] && save[0] <= '0' + KD_MAX_BUTTON && save[1] == '\0')
-    {
-        mi->nbutton = save[0] - '0';
-	if (mi->nbutton > KD_MAX_BUTTON)
-	{
-	    UseMsg ();
-	    return;
-	}
-    }
-    
-    if (!delim != ',')
-	return;
-    
-    arg = KdParseFindNext (arg, ",", save, &delim);
-    
-    if (save[0])
-	mi->prot = KdSaveString (save);
-    
-    while (delim == ',')
-    {
-	arg = KdParseFindNext (arg, ",", save, &delim);
-	if (save[0] == '{')
-	{
-	    char	*s = save + 1;
-	    i = 0;
-	    while (*s && *s != '}')
-	    {
-		if ('1' <= *s && *s <= '0' + mi->nbutton)
-		    mi->map[i] = *s - '0';
-		else
-		    UseMsg ();
-		s++;
-	    }
-	}
-	else if (!strcmp (save, "2button"))
-	    mi->emulateMiddleButton = TRUE;
-	else if (!strcmp (save, "3button"))
-	    mi->emulateMiddleButton = FALSE;
-	else if (!strcmp (save, "rawcoord"))
-	    mi->transformCoordinates = FALSE;
-	else if (!strcmp (save, "transform"))
-	    mi->transformCoordinates = TRUE;
-	else
-	    UseMsg ();
-    }
-}
-
 void
 KdParseRgba (char *rgba)
 {
@@ -697,6 +619,8 @@ KdProcessArgument (int argc, char **argv
 {
     KdCardInfo	    *card;
     KdScreenInfo    *screen;
+    KdPointerInfo   *pi;
+    KdKeyboardInfo  *ki;
 
     if (!strcmp (argv[i], "-card"))
     {
@@ -736,6 +660,11 @@ KdProcessArgument (int argc, char **argv
 	kdDontZap = TRUE;
 	return 1;
     }
+    if (!strcmp (argv[i], "-nozap"))
+    {
+	kdDontZap = TRUE;
+	return 1;
+    }
     if (!strcmp (argv[i], "-3button"))
     {
 	kdEmulateMiddleButton = FALSE;
@@ -785,14 +714,6 @@ KdProcessArgument (int argc, char **argv
 	    UseMsg ();
 	return 2;
     }
-    if (!strcmp (argv[i], "-mouse"))
-    {
-	if ((i+1) < argc)
-	    KdParseMouse (argv[i+1]);
-	else
-	    UseMsg ();
-	return 2;
-    }
     if (!strcmp (argv[i], "-rgba"))
     {
 	if ((i+1) < argc)
@@ -814,6 +735,20 @@ KdProcessArgument (int argc, char **argv
     {
 	return 1;
     }
+    if (!strcmp (argv[i], "-mouse") ||
+        !strcmp (argv[i], "-pointer")) {
+        if (i + 1 >= argc)
+            UseMsg();
+        KdAddConfigPointer(argv[i + 1]);
+        return 2;
+    }
+    if (!strcmp (argv[i], "-keybd")) {
+        if (i + 1 >= argc)
+            UseMsg();
+        KdAddConfigKeyboard(argv[i + 1]);
+        return 2;
+    }
+
 #ifdef PSEUDO8
     return p8ProcessArgument (argc, argv, i);
 #else
@@ -1420,6 +1355,39 @@ KdDepthToFb (ScreenPtr	pScreen, int dept
 
 #endif
 
+#ifdef HAVE_BACKTRACE
+/* shamelessly ripped from xf86Events.c */
+void
+KdBacktrace (int signum)
+{
+    void *array[32]; /* more than 32 and you have bigger problems */
+    size_t size, i;
+    char **strings;
+
+    signal(signum, SIG_IGN);
+
+    size = backtrace (array, 32);
+    fprintf (stderr, "\nBacktrace (%d deep):\n", size);
+    strings = backtrace_symbols (array, size);
+    for (i = 0; i < size; i++)
+        fprintf (stderr, "%d: %s\n", i, strings[i]);
+    free (strings);
+    
+    kdCaughtSignal = TRUE;    
+    if (signum == SIGSEGV)
+        FatalError("Segmentation fault caught\n");
+    else if (signum > 0)
+        FatalError("Signal %d caught\n", signum);
+}
+#else
+void
+KdBacktrace (int signum)
+{
+    kdCaughtSignal = TRUE;
+    FatalError("Segmentation fault caught\n");
+}
+#endif
+
 void
 KdInitOutput (ScreenInfo    *pScreenInfo,
 	      int	    argc,
@@ -1427,6 +1395,10 @@ KdInitOutput (ScreenInfo    *pScreenInfo
 {
     KdCardInfo	    *card;
     KdScreenInfo    *screen;
+
+    /* kind of a hack: we want Composite enabled, but it's disabled per
+     * default. */
+    noCompositeExtension = FALSE;
     
     if (!kdCardInfo)
     {
@@ -1464,6 +1436,8 @@ KdInitOutput (ScreenInfo    *pScreenInfo
     for (card = kdCardInfo; card; card = card->next)
 	for (screen = card->screenList; screen; screen = screen->next)
 	    KdAddScreen (pScreenInfo, screen, argc, argv);
+
+    signal(SIGSEGV, KdBacktrace);
 }
 
 #ifdef DPMSExtension
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index c371263..843f921 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -47,6 +47,10 @@
 #include "shadow.h"
 #include "randrstr.h"
 
+#ifdef XKB
+#include <X11/extensions/XKBstr.h>
+#endif
+
 extern WindowPtr    *WindowTable;
 
 #define KD_DPMS_NORMAL	    0
@@ -63,6 +67,8 @@ extern WindowPtr    *WindowTable;
 #define KD_MAX_CARD_ADDRESS 8
 #endif
 
+#define Status int
+
 /*
  * Configuration information per video card
  */
@@ -215,7 +221,7 @@ typedef struct {
 #endif
 } KdPrivScreenRec, *KdPrivScreenPtr;
 
-typedef enum _kdMouseState {
+typedef enum _kdPointerState {
     start,
     button_1_pend,
     button_1_down,
@@ -226,51 +232,135 @@ typedef enum _kdMouseState {
     synth_2_down_3,
     synth_2_down_1,
     num_input_states
-} KdMouseState;
+} KdPointerState;
 
-#define KD_MAX_BUTTON  7
+#define KD_MAX_BUTTON  16
 
-typedef struct _KdMouseInfo {
-    struct _KdMouseInfo	*next;
-    void		*driver;
-    void		*closure;
-    char		*name;
-    char		*prot;
-    char		map[KD_MAX_BUTTON];
-    int			nbutton;
-    Bool		emulateMiddleButton;
-    unsigned long	emulationTimeout;
-    Bool		timeoutPending;
-    KdMouseState	mouseState;
-    Bool		eventHeld;
-    xEvent		heldEvent;
-    unsigned char	buttonState;
-    int			emulationDx, emulationDy;
-    int			inputType;
-    Bool		transformCoordinates;
-} KdMouseInfo;
+#define KD_KEYBOARD 1
+#define KD_MOUSE 2
+#define KD_TOUCHSCREEN 3
+
+typedef struct _KdPointerInfo KdPointerInfo;
+
+typedef struct _KdPointerDriver {
+    char                    *name;
+    Status                  (*Init)    (KdPointerInfo *);
+    Status                  (*Enable)  (KdPointerInfo *);
+    void                    (*Disable) (KdPointerInfo *);
+    void                    (*Fini)    (KdPointerInfo *);
+    struct _KdPointerDriver *next;
+} KdPointerDriver;
+
+struct _KdPointerInfo {
+    DeviceIntPtr          dixdev;
+    char                  *name;
+    char                  *path;
+    InputOption           *options;
+    int                   inputClass;
+
+    CARD8                 map[KD_MAX_BUTTON];
+    int                   nButtons;
+    int                   nAxes;
+
+    Bool                  emulateMiddleButton;
+    unsigned long         emulationTimeout;
+    int                   emulationDx, emulationDy;
+
+    Bool                  timeoutPending;
+    KdPointerState        mouseState;
+    Bool                  eventHeld;
+    struct {
+        int type;
+        int x;
+        int y;
+        int z;
+        int flags;
+        int absrel;
+    } heldEvent;         
+    unsigned char         buttonState;
+    Bool                  transformCoordinates;
+    int                   pressureThreshold;
 
-extern KdMouseInfo	*kdMouseInfo;
+    KdPointerDriver       *driver;
+    void                  *driverPrivate;
+
+    struct _KdPointerInfo *next;
+};
 
 extern int KdCurScreen;
 
-KdMouseInfo *KdMouseInfoAdd (void);
-void	    KdMouseInfoDispose (KdMouseInfo *mi);
-void	    KdParseMouse (char *);
+void KdAddPointerDriver (KdPointerDriver *driver);
+void KdRemovePointerDriver (KdPointerDriver *driver);
+KdPointerInfo *KdNewPointer (void);
+void KdFreePointer (KdPointerInfo *);
+int KdAddPointer (KdPointerInfo *ki);
+int KdAddConfigPointer (char *pointer);
+void KdRemovePointer (KdPointerInfo *ki);
 
-typedef struct _KdMouseFuncs {
-    Bool    	    (*Init) (void);
-    void	    (*Fini) (void);
-} KdMouseFuncs;
 
-typedef struct _KdKeyboardFuncs {
-    void	    (*Load) (void);
-    int		    (*Init) (void);
-    void	    (*Leds) (int);
-    void	    (*Bell) (int, int, int);
-    void	    (*Fini) (void);
-    int		    LockLed;
-} KdKeyboardFuncs;
+#define KD_KEY_COUNT 248
+#define KD_MIN_KEYCODE  8
+#define KD_MAX_KEYCODE  255
+#define KD_MAX_WIDTH    4
+#define KD_MAX_LENGTH   (KD_MAX_KEYCODE - KD_MIN_KEYCODE + 1)
+
+typedef struct {
+    KeySym modsym;
+    int    modbit;
+} KdKeySymModsRec;
+
+extern const KeySym       kdDefaultKeymap[KD_MAX_LENGTH * KD_MAX_WIDTH];
+extern const int          kdDefaultKeymapWidth;
+extern const CARD8        kdDefaultModMap[MAP_LENGTH];
+extern const KeySymsRec   kdDefaultKeySyms;
+
+typedef struct _KdKeyboardInfo KdKeyboardInfo;
+
+typedef struct _KdKeyboardDriver {
+    char                  *name;
+    Bool                  (*Init)    (KdKeyboardInfo *);
+    Bool                  (*Enable)  (KdKeyboardInfo *);
+    void                  (*Leds)    (KdKeyboardInfo *, int);
+    void                  (*Bell)    (KdKeyboardInfo *, int, int, int);
+    void                  (*Disable) (KdKeyboardInfo *);
+    void                  (*Fini)    (KdKeyboardInfo *);
+    struct _KdKeyboardDriver *next;
+} KdKeyboardDriver;
+
+struct _KdKeyboardInfo {
+    struct _KdKeyboardInfo *next;
+    DeviceIntPtr        dixdev;
+    void                *closure;
+    char                *name;
+    char                *path;
+    int                 inputClass;
+#ifdef XKB
+    XkbDescPtr          xkb;
+#endif
+    int                 LockLed;
+
+    CARD8               keyState[KD_KEY_COUNT/8];
+    int                 minScanCode;
+    int                 maxScanCode;
+    CARD8               modmap[MAP_LENGTH];
+    KeySymsRec          keySyms; 
+
+    int                 leds;
+    int                 bellPitch;
+    int                 bellDuration;
+    InputOption         *options;
+
+    KdKeyboardDriver    *driver;
+    void                *driverPrivate;
+};
+
+void KdAddKeyboardDriver (KdKeyboardDriver *driver);
+void KdRemoveKeyboardDriver (KdKeyboardDriver *driver);
+KdKeyboardInfo *KdNewKeyboard (void);
+void KdFreeKeyboard (KdKeyboardInfo *ki);
+int KdAddConfigKeyboard (char *pointer);
+int KdAddKeyboard (KdKeyboardInfo *ki);
+void KdRemoveKeyboard (KdKeyboardInfo *ki);
 
 typedef struct _KdOsFuncs {
     int		    (*Init) (void);
@@ -307,9 +397,9 @@ typedef struct _KdMonitorTiming {
 extern const KdMonitorTiming	kdMonitorTimings[];
 extern const int		kdNumMonitorTimings;
 
-typedef struct _KdMouseMatrix {
+typedef struct _KdPointerMatrix {
     int	    matrix[2][3];
-} KdMouseMatrix;
+} KdPointerMatrix;
 
 typedef struct _KaaTrapezoid {
     float tl, tr, ty;
@@ -628,8 +718,14 @@ KdParseScreen (KdScreenInfo *screen,
 char *
 KdSaveString (char *str);
 
-void
-KdParseMouse (char *arg);
+KdPointerInfo *
+KdParsePointer (char *arg);
+
+KdKeyboardInfo *
+KdParseKeyboard (char *arg);
+
+char *
+KdParseFindNext (char *cur, char *delim, char *save, char *last);
 
 void
 KdParseRgba (char *rgba);
@@ -677,6 +773,9 @@ KdInitOutput (ScreenInfo    *pScreenInfo
  
 void
 KdSetSubpixelOrder (ScreenPtr pScreen, Rotation randr);
+
+void
+KdBacktrace (int signum);
     
 /* kinfo.c */
 KdCardInfo *
@@ -699,53 +798,51 @@ KdScreenInfoDispose (KdScreenInfo *si);
 
 /* kinput.c */
 void
-KdInitInput(KdMouseFuncs *, KdKeyboardFuncs *);
+KdInitInput(void);
 
 void
-KdAddMouseDriver(KdMouseFuncs *);
+KdAddPointerDriver(KdPointerDriver *);
 
-int
-KdAllocInputType (void);
+void
+KdAddKeyboardDriver(KdKeyboardDriver *);
 
 Bool
-KdRegisterFd (int type, int fd, void (*read) (int fd, void *closure), void *closure);
+KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure);
 
 void
-KdRegisterFdEnableDisable (int fd, 
-			   int (*enable) (int fd, void *closure),
-			   void (*disable) (int fd, void *closure));
+KdUnregisterFds (void *closure, Bool do_close);
 
 void
-KdUnregisterFds (int type, Bool do_close);
-
-void
-KdEnqueueKeyboardEvent(unsigned char	scan_code,
-		       unsigned char	is_up);
+KdEnqueueKeyboardEvent(KdKeyboardInfo *ki, unsigned char scan_code,
+                    unsigned char is_up);
 
 #define KD_BUTTON_1	0x01
 #define KD_BUTTON_2	0x02
 #define KD_BUTTON_3	0x04
 #define KD_BUTTON_4	0x08
 #define KD_BUTTON_5	0x10
+#define KD_BUTTON_8	0x80
 #define KD_MOUSE_DELTA	0x80000000
 
 void
-KdEnqueueMouseEvent(KdMouseInfo *mi, unsigned long flags, int x, int y);
+KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
+                      int rz);
 
 void
-KdEnqueueMotionEvent (KdMouseInfo *mi, int x, int y);
+_KdEnqueuePointerEvent(KdPointerInfo *pi, int type, int x, int y, int z,
+                       int b, int absrel, Bool force);
 
 void
 KdReleaseAllKeys (void);
     
 void
-KdSetLed (int led, Bool on);
+KdSetLed (KdKeyboardInfo *ki, int led, Bool on);
 
 void
-KdSetMouseMatrix (KdMouseMatrix *matrix);
+KdSetPointerMatrix (KdPointerMatrix *pointer);
 
 void
-KdComputeMouseMatrix (KdMouseMatrix *matrix, Rotation randr, int width, int height);
+KdComputePointerMatrix (KdPointerMatrix *pointer, Rotation randr, int width, int height);
     
 void
 KdBlockHandler (int		screen,
@@ -768,19 +865,17 @@ KdEnableInput (void);
 void
 ProcessInputEvents (void);
 
-extern KdMouseFuncs	LinuxMouseFuncs;
-extern KdMouseFuncs	LinuxEvdevFuncs;
-extern KdMouseFuncs	Ps2MouseFuncs;
-extern KdMouseFuncs	BusMouseFuncs;
-extern KdMouseFuncs	MsMouseFuncs;
-#ifdef TOUCHSCREEN
-extern KdMouseFuncs	TsFuncs;
-#endif
-extern KdKeyboardFuncs	LinuxKeyboardFuncs;
+extern KdPointerDriver	LinuxMouseDriver;
+extern KdPointerDriver	LinuxEvdevDriver;
+extern KdPointerDriver	Ps2MouseDriver;
+extern KdPointerDriver	BusMouseDriver;
+extern KdPointerDriver	MsMouseDriver;
+extern KdPointerDriver	TsDriver;
+extern KdKeyboardDriver	LinuxKeyboardDriver;
 extern KdOsFuncs	LinuxFuncs;
 
-extern KdMouseFuncs	VxWorksMouseFuncs;
-extern KdKeyboardFuncs	VxWorksKeyboardFuncs;
+extern KdPointerDriver	VxWorksMouseDriver;
+extern KdKeyboardDriver	VxWorksKeyboardDriver;
 extern KdOsFuncs	VxWorksFuncs;
 
 /* kmap.c */
diff --git a/hw/kdrive/src/kinfo.c b/hw/kdrive/src/kinfo.c
index 3ba7687..1d81ed3 100644
--- a/hw/kdrive/src/kinfo.c
+++ b/hw/kdrive/src/kinfo.c
@@ -101,7 +101,7 @@ KdScreenInfoDispose (KdScreenInfo *si)
     KdCardInfo	    *ci = si->card;
     KdScreenInfo    **prev;
 
-    for (prev = &ci->screenList; *prev; prev = &(*prev)->next)
+    for (prev = &ci->screenList; *prev; prev = &(*prev)->next) {
 	if (*prev == si)
 	{
 	    *prev = si->next;
@@ -110,38 +110,63 @@ KdScreenInfoDispose (KdScreenInfo *si)
 		KdCardInfoDispose (ci);
 	    break;
 	}
+    }
 }
 
-KdMouseInfo *kdMouseInfo;
-
-KdMouseInfo *
-KdMouseInfoAdd (void)
+KdPointerInfo *
+KdNewPointer (void)
 {
-    KdMouseInfo	*mi, **prev;
+    KdPointerInfo *pi;
+
+    pi = (KdPointerInfo *)xcalloc(1, sizeof(KdPointerInfo));
+    if (!pi)
+        return NULL;
+
+    pi->name = KdSaveString("Generic Pointer");
+    pi->path = NULL;
+    pi->inputClass = KD_MOUSE;
+    pi->driver = NULL;
+    pi->driverPrivate = NULL;
+    pi->next = NULL;
+    pi->options = NULL;
+    pi->nAxes = 3;
 
-    mi = (KdMouseInfo *) xalloc (sizeof (KdMouseInfo));
-    if (!mi)
-	return 0;
-    bzero (mi, sizeof (KdMouseInfo));
-    for (prev = &kdMouseInfo; *prev; prev = &(*prev)->next);
-    *prev = mi;
-    return mi;
+    return pi;
 }
 
 void
-KdMouseInfoDispose (KdMouseInfo *mi)
+KdFreePointer(KdPointerInfo *pi)
 {
-    KdMouseInfo	**prev;
+    InputOption *option, *prev = NULL;
 
-    for (prev = &kdMouseInfo; *prev; prev = &(*prev)->next)
-	if (*prev == mi)
-	{
-	    *prev = mi->next;
-	    if (mi->name)
-		xfree (mi->name);
-	    if (mi->prot)
-		xfree (mi->prot);
-	    xfree (mi);
-	    break;
-	}
+    if (pi->name)
+        xfree(pi->name);
+    if (pi->path)
+        xfree(pi->path);
+
+    for (option = pi->options; option; option = option->next) {
+        if (prev)
+            xfree(prev);
+        if (option->key)
+            xfree(option->key);
+        if (option->value)
+            xfree(option->value);
+        prev = option;
+    }
+
+    if (prev)
+        xfree(prev);
+    
+    xfree(pi);
+}
+ 
+void
+KdFreeKeyboard(KdKeyboardInfo *ki)
+{
+    if (ki->name)
+        xfree(ki->name);
+    if (ki->path)
+        xfree(ki->path);
+    ki->next = NULL;
+    xfree(ki);
 }
diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index f671eb6..94c3abd 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -2,20 +2,21 @@
  * Id: kinput.c,v 1.1 1999/11/02 03:54:46 keithp Exp $
  *
  * Copyright © 1999 Keith Packard
+ * Copyright © 2006 Nokia Corporation
  *
  * 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
+ * documentation, and that the name of the authors not be used in
  * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission.  Keith Packard makes no
+ * specific, written prior permission.  The authors make 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,
+ * THE AUTHORS DISCLAIM 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
+ * EVENT SHALL THE AUTHORS 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
@@ -34,7 +35,6 @@
 #if HAVE_X11_XF86KEYSYM_H
 #include <X11/XF86keysym.h>
 #endif
-#include "kkeymap.h"
 #include <signal.h>
 #include <stdio.h>
 #ifdef sun
@@ -45,58 +45,60 @@
 #include <X11/extensions/XKBsrv.h>
 #endif
 
-static DeviceIntPtr	pKdKeyboard, pKdPointer;
+#ifdef XINPUT
+#include <X11/extensions/XI.h>
+#include <X11/extensions/XIproto.h>
+#include "exevents.h"
+#include "extinit.h"
+#include "exglobals.h"
+#endif
+
+#define AtomFromName(x) MakeAtom(x, strlen(x), 1)
+
+struct KdConfigDevice {
+    char *line;
+    struct KdConfigDevice *next;
+};
+
+/* kdKeyboards and kdPointers hold all the real devices. */
+static KdKeyboardInfo *kdKeyboards         = NULL;
+static KdPointerInfo  *kdPointers          = NULL;
+static struct KdConfigDevice *kdConfigKeyboards   = NULL;
+static struct KdConfigDevice *kdConfigPointers    = NULL;
 
-#define MAX_MOUSE_DRIVERS   4
+static KdKeyboardDriver *kdKeyboardDrivers = NULL;
+static KdPointerDriver  *kdPointerDrivers  = NULL;
 
-static KdMouseFuncs	*kdMouseFuncs[MAX_MOUSE_DRIVERS];
-static int		kdNMouseFuncs;
-static KdKeyboardFuncs	*kdKeyboardFuncs;
-static int		kdBellPitch;
-static int		kdBellDuration;
-static int		kdLeds;
 static Bool		kdInputEnabled;
 static Bool		kdOffScreen;
 static unsigned long	kdOffScreenTime;
-static KdMouseMatrix	kdMouseMatrix = {
+static KdPointerMatrix	kdPointerMatrix = {
    { { 1, 0, 0 },
      { 0, 1, 0 } }
 };
 
-int		kdMouseButtonCount;
-int		kdMinScanCode;
-int		kdMaxScanCode;
-int		kdMinKeyCode;
-int		kdMaxKeyCode;
-int		kdKeymapWidth = KD_MAX_WIDTH;
-KeySym		kdKeymap[KD_MAX_LENGTH * KD_MAX_WIDTH];
-CARD8		kdModMap[MAP_LENGTH];
-KeySymsRec	kdKeySyms;
-
-
-void
-KdResetInputMachine (void);
+void KdResetInputMachine (void);
     
-#define KD_KEY_COUNT		248
-
-CARD8		kdKeyState[KD_KEY_COUNT/8];
-
-#define IsKeyDown(key) ((kdKeyState[(key) >> 3] >> ((key) & 7)) & 1)
+#define IsKeyDown(ki, key) ((ki->keyState[(key) >> 3] >> ((key) & 7)) & 1)
+#define KEYMAP(ki)        (ki->dixdev->key->curKeySyms)
+#define KEYMAPDDX(ki)     (ki->keySyms)
+#define KEYCOL1(ki, k)    (KEYMAP(ki).map[((k)-(KEYMAP(ki).minKeyCode))*KEYMAP(ki).mapWidth])
+#define KEYCOL1DDX(ki, k) (KEYMAPDDX(ki).map[((k)-(KEYMAPDDX(ki).minKeyCode))*KEYMAPDDX(ki).mapWidth])
 
 #define KD_MAX_INPUT_FDS    8
 
 typedef struct _kdInputFd {
-    int	    type;
-    int	    fd;
-    void    (*read) (int fd, void *closure);
-    int	    (*enable) (int fd, void *closure);
-    void    (*disable) (int fd, void *closure);
-    void    *closure;
+    int	        fd;
+    void        (*read) (int fd, void *closure);
+    int	        (*enable) (int fd, void *closure);
+    void        (*disable) (int fd, void *closure);
+    void        *closure;
 } KdInputFd;
 
-KdInputFd    	kdInputFds[KD_MAX_INPUT_FDS];
-int		kdNumInputFds;
-int		kdInputTypeSequence;
+static KdInputFd kdInputFds[KD_MAX_INPUT_FDS];
+static int	 kdNumInputFds;
+
+extern Bool      kdRawPointerCoordinates;
 
 static void
 KdSigio (int sig)
@@ -137,8 +139,10 @@ KdAssertSigioBlocked (char *where)
 
     sigemptyset (&set);
     sigprocmask (SIG_BLOCK, &set, &old);
-    if (!sigismember (&old, SIGIO))
+    if (!sigismember (&old, SIGIO)) {
 	ErrorF ("SIGIO not blocked at %s\n", where);
+        KdBacktrace();
+    }
 }
 
 #else
@@ -155,6 +159,17 @@ static int  kdnFds;
 #define NOBLOCK FNDELAY
 #endif
 
+void
+KdResetInputMachine (void)
+{
+    KdPointerInfo *pi;
+
+    for (pi = kdPointers; pi; pi = pi->next) {
+        pi->mouseState = start;
+        pi->eventHeld = FALSE;
+    }
+}
+
 static void
 KdNonBlockFd (int fd)
 {
@@ -205,98 +220,126 @@ KdRemoveFd (int fd)
     }
 }
 
-int
-KdAllocInputType (void)
-{
-    return ++kdInputTypeSequence;
-}
-
 Bool
-KdRegisterFd (int type, int fd, void (*read) (int fd, void *closure), void *closure)
+KdRegisterFd (int fd, void (*read) (int fd, void *closure), void *closure)
 {
     if (kdNumInputFds == KD_MAX_INPUT_FDS)
 	return FALSE;
-    kdInputFds[kdNumInputFds].type = type;
     kdInputFds[kdNumInputFds].fd = fd;
     kdInputFds[kdNumInputFds].read = read;
     kdInputFds[kdNumInputFds].enable = 0;
     kdInputFds[kdNumInputFds].disable = 0;
     kdInputFds[kdNumInputFds].closure = closure;
-    ++kdNumInputFds;
+    kdNumInputFds++;
     if (kdInputEnabled)
 	KdAddFd (fd);
     return TRUE;
 }
 
 void
-KdRegisterFdEnableDisable (int fd, 
-			   int (*enable) (int fd, void *closure),
-			   void (*disable) (int fd, void *closure))
-{
-    int	i;
-    
-    for (i = 0; i < kdNumInputFds; i++)
-	if (kdInputFds[i].fd == fd)
-	{
-	    kdInputFds[i].enable = enable;
-	    kdInputFds[i].disable = disable;
-	    break;
-	}
-}
-			   
-void
-KdUnregisterFds (int type, Bool do_close)
+KdUnregisterFd (void *closure, int fd, Bool do_close)
 {
     int	i, j;
 
-    for (i = 0; i < kdNumInputFds;)
-    {
-	if (kdInputFds[i].type == type)
-	{
+    for (i = 0; i < kdNumInputFds; i++) {
+	if (kdInputFds[i].closure == closure &&
+            kdInputFds[i].fd == fd) {
 	    if (kdInputEnabled)
 		KdRemoveFd (kdInputFds[i].fd);
 	    if (do_close)
 		close (kdInputFds[i].fd);
-	    --kdNumInputFds;
+	    kdNumInputFds--;
 	    for (j = i; j < kdNumInputFds; j++)
 		kdInputFds[j] = kdInputFds[j+1];
+            break;
 	}
-	else
-	    i++;
     }
 }
 
 void
 KdDisableInput (void)
 {
-    int	i;
-
-    KdBlockSigio ();
-
-    for (i = 0; i < kdNumInputFds; i++)
-    {
-	KdRemoveFd (kdInputFds[i].fd);
-	if (kdInputFds[i].disable)
-	    (*kdInputFds[i].disable) (kdInputFds[i].fd, kdInputFds[i].closure);
+    KdKeyboardInfo *ki;
+    KdPointerInfo *pi;
+    int found = 0, i = 0;
+
+    KdBlockSigio();
+
+    for (ki = kdKeyboards; ki; ki = ki->next) {
+        if (ki->driver && ki->driver->Disable)
+            (*ki->driver->Disable) (ki);
+    }
+
+    for (pi = kdPointers; pi; pi = pi->next) {
+        if (pi->driver && pi->driver->Disable)
+            (*pi->driver->Disable) (pi);
+    }
+
+    if (kdNumInputFds) {
+        ErrorF("[KdDisableInput] Buggy drivers: still %d input fds left!",
+               kdNumInputFds);
+        i = 0;
+        while (i < kdNumInputFds) {
+            found = 0;
+            for (ki = kdKeyboards; ki; ki = ki->next) {
+                if (ki == kdInputFds[i].closure) {
+                    ErrorF("    fd %d belongs to keybd driver %s\n",
+                           kdInputFds[i].fd,
+                           ki->driver && ki->driver->name ?
+                             ki->driver->name : "(unnamed!)");
+                    found = 1;
+                    break;
+                }
+            }
+
+            if (found) {
+                i++;
+                continue;
+            }
+
+            for (pi = kdPointers; pi; pi = pi->next) {
+                if (pi == kdInputFds[i].closure) {
+                    ErrorF("    fd %d belongs to pointer driver %s\n",
+                           kdInputFds[i].fd,
+                           pi->driver && pi->driver->name ?
+                             pi->driver->name : "(unnamed!)");
+                    break;
+                }
+            }
+
+            if (found) {
+                i++;
+                continue;
+            }
+
+            ErrorF("    fd %d not claimed by any active device!\n",
+                   kdInputFds[i].fd);
+            KdUnregisterFd(kdInputFds[i].closure, kdInputFds[i].fd, TRUE);
+        }
     }
+
     kdInputEnabled = FALSE;
 }
 
 void
 KdEnableInput (void)
 {
-    xEvent	xE;
-    int	i;
+    xEvent xE;
+    KdKeyboardInfo *ki;
+    KdPointerInfo *pi;
     
     kdInputEnabled = TRUE;
-    for (i = 0; i < kdNumInputFds; i++)
-    {
-	KdNonBlockFd (kdInputFds[i].fd);
-	if (kdInputFds[i].enable)
-	    kdInputFds[i].fd = (*kdInputFds[i].enable) (kdInputFds[i].fd, kdInputFds[i].closure);
-	KdAddFd (kdInputFds[i].fd);
+
+    for (ki = kdKeyboards; ki; ki = ki->next) {
+        if (ki->driver && ki->driver->Enable)
+            (*ki->driver->Enable) (ki);
     }
-    
+
+    for (pi = kdPointers; pi; pi = pi->next) {
+        if (pi->driver && pi->driver->Enable)
+            (*pi->driver->Enable) (pi);
+    }
+
     /* reset screen saver */
     xE.u.keyButtonPointer.time = GetTimeInMillis ();
     NoticeEventTime (&xE);
@@ -304,45 +347,178 @@ KdEnableInput (void)
     KdUnblockSigio ();
 }
 
-static int
-KdMouseProc(DeviceIntPtr pDevice, int onoff)
+KdKeyboardDriver *
+KdFindKeyboardDriver (char *name)
 {
-    BYTE	map[KD_MAX_BUTTON];
-    DevicePtr	pDev = (DevicePtr)pDevice;
-    int		i;
+    KdKeyboardDriver *ret;
+
+    /* ask a stupid question ... */
+    if (!name)
+        return NULL;
     
+    for (ret = kdKeyboardDrivers; ret; ret = ret->next) {
+        if (strcmp(ret->name, name) == 0)
+            return ret;
+    }
+
+    return NULL;
+}
+
+KdPointerDriver *
+KdFindPointerDriver (char *name)
+{
+    KdPointerDriver *ret;
+
+    /* ask a stupid question ... */
+    if (!name)
+        return NULL;
+
+    for (ret = kdPointerDrivers; ret; ret = ret->next) {
+        if (strcmp(ret->name, name) == 0)
+            return ret;
+    }
+
+    return NULL;
+}
+
+static int
+KdPointerProc(DeviceIntPtr pDevice, int onoff)
+{
+    DevicePtr       pDev = (DevicePtr)pDevice;
+    int             i;
+    KdPointerInfo   *pi;
+#ifdef XINPUT
+    Atom            xiclass;
+#endif
+
     if (!pDev)
 	return BadImplementation;
-    
+
+    for (pi = kdPointers; pi; pi = pi->next) {
+        if (pi->dixdev && pi->dixdev->id == pDevice->id)
+            break;
+    }
+
+    if (!pi || !pi->dixdev || pi->dixdev->id != pDevice->id) {
+        ErrorF("[KdPointerProc] Failed to find pointer for device %d!\n",
+               pDevice->id);
+        return BadImplementation;
+    }
+
     switch (onoff)
     {
     case DEVICE_INIT:
-	for (i = 1; i <= kdMouseButtonCount; i++)
-	    map[i] = i;
-	InitPointerDeviceStruct(pDev, map, kdMouseButtonCount,
+        ErrorF("initialising pointer %s ...\n", pi->name);
+        if (!pi->driver) {
+            if (!pi->driverPrivate) {
+                ErrorF("no driver specified for %s\n", pi->name);
+                return BadImplementation;
+            }
+
+            pi->driver = KdFindPointerDriver(pi->driverPrivate);
+            if (!pi->driver) {
+                ErrorF("Couldn't find pointer driver %s\n",
+                       pi->driverPrivate ? (char *) pi->driverPrivate :
+                       "(unnamed)");
+                return !Success;
+            }
+            xfree(pi->driverPrivate);
+            pi->driverPrivate = NULL;
+        }
+
+        if (!pi->driver->Init) {
+            ErrorF("no init function\n");
+            return BadImplementation;
+        }
+
+	for (i = 1; i <= pi->nButtons; i++)
+	    pi->map[i] = i; 
+
+        if ((*pi->driver->Init) (pi) != Success) {
+            return !Success;
+        }
+
+	InitPointerDeviceStruct(pDev, pi->map, pi->nButtons,
 	    miPointerGetMotionEvents,
 	    (PtrCtrlProcPtr)NoopDDA,
 	    miPointerGetMotionBufferSize());
-	break;
+
+#ifdef XINPUT
+        if (pi->inputClass == KD_TOUCHSCREEN) {
+            InitTouchscreenClassDeviceStruct(pDevice);
+            xiclass = AtomFromName(XI_TOUCHSCREEN);
+        }
+        else {
+            xiclass = AtomFromName(XI_MOUSE);
+        }
+
+        AssignTypeAndName(pi->dixdev, xiclass,
+                          pi->name ? pi->name : "Generic KDrive Pointer");
+#endif
+
+	return Success;
 	
     case DEVICE_ON:
-	pDev->on = TRUE;
-	pKdPointer = pDevice;
-	for (i = 0; i < kdNMouseFuncs; i++)
-	    (*kdMouseFuncs[i]->Init)();
-	break;
+        if (pDev->on == TRUE)
+            return Success;
+        
+        if (!pi->driver->Enable) {
+            ErrorF("no enable function\n");
+            return BadImplementation;
+        }
+
+        if ((*pi->driver->Enable) (pi) == Success) {
+            ErrorF("initialised fine, returning success\n");
+            pDev->on = TRUE;
+            return Success;
+        }
+        else {
+            return BadImplementation;
+        }
+
+	return Success;
+
     case DEVICE_OFF:
+        if (pDev->on == FALSE) {
+            return Success;
+        }
+
+        if (!pi->driver->Disable) {
+            return BadImplementation;
+        }
+        else {
+            (*pi->driver->Disable) (pi);
+            pDev->on = FALSE;
+            return Success;
+        }
+
+        return Success;
+
     case DEVICE_CLOSE:
-	if (pDev->on)
-	{
-	    pDev->on = FALSE;
-	    pKdPointer = 0;
-	    for (i = 0; i < kdNMouseFuncs; i++)
-		(*kdMouseFuncs[i]->Fini) ();
-	}
-	break;
+        ErrorF("D_C\n");
+	if (pDev->on) {
+            if (!pi->driver->Disable) {
+                return BadImplementation;
+            }
+            (*pi->driver->Disable) (pi);
+            ErrorF("disabled\n");
+            pDev->on = FALSE;
+        }
+
+        if (!pi->driver->Fini)
+            return BadImplementation;
+
+        (*pi->driver->Fini) (pi);
+        ErrorF("finished\n");
+
+        KdRemovePointer(pi);
+        ErrorF("removed\n");
+        
+        return Success;
     }
-    return Success;
+
+    /* NOTREACHED */
+    return BadImplementation;
 }
 
 Bool
@@ -354,34 +530,54 @@ LegalModifier(unsigned int key, DevicePt
 static void
 KdBell (int volume, DeviceIntPtr pDev, pointer ctrl, int something)
 {
-    if (kdInputEnabled)
-	(*kdKeyboardFuncs->Bell) (volume, kdBellPitch, kdBellDuration);
+    KdKeyboardInfo *ki = NULL;
+
+    for (ki = kdKeyboards; ki; ki = ki->next) {
+        if (ki->dixdev && (ki->dixdev->id == pDev->id))
+            break;
+    }
+
+    if (!ki || !ki->dixdev || ki->dixdev->id != pDev->id || !ki->driver)
+        return;
+        
+    if (kdInputEnabled) {
+        if (ki->driver->Bell)
+            (*ki->driver->Bell) (ki, volume, ki->bellPitch, ki->bellDuration);
+    }
 }
 
 
 static void
-KdSetLeds (void)
+KdSetLeds (KdKeyboardInfo *ki, int leds)
 {
-    if (kdInputEnabled)
-	(*kdKeyboardFuncs->Leds) (kdLeds);
+    if (!ki || !ki->driver)
+        return;
+
+    if (kdInputEnabled) {
+        if (ki->driver->Leds)
+            (*ki->driver->Leds) (ki, leds);
+    }
 }
 
 void
-KdSetLed (int led, Bool on)
+KdSetLed (KdKeyboardInfo *ki, int led, Bool on)
 {
-    NoteLedState (pKdKeyboard, led, on);
-    kdLeds = pKdKeyboard->kbdfeed->ctrl.leds;
-    KdSetLeds ();
+    if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed)
+        return;
+
+    NoteLedState (ki->dixdev, led, on);
+    KdSetLeds (ki, ki->dixdev->kbdfeed->ctrl.leds);
 }
 
 void
-KdSetMouseMatrix (KdMouseMatrix *matrix)
+KdSetPointerMatrix (KdPointerMatrix *matrix)
 {
-    kdMouseMatrix = *matrix;
+    kdPointerMatrix = *matrix;
 }
 
 void
-KdComputeMouseMatrix (KdMouseMatrix *m, Rotation randr, int width, int height)
+KdComputePointerMatrix (KdPointerMatrix *m, Rotation randr, int width,
+                        int height)
 {
     int		    x_dir = 1, y_dir = 1;
     int		    i, j;
@@ -422,73 +618,25 @@ KdComputeMouseMatrix (KdMouseMatrix *m, 
 static void
 KdKbdCtrl (DeviceIntPtr pDevice, KeybdCtrl *ctrl)
 {
-    kdLeds = ctrl->leds;
-    kdBellPitch = ctrl->bell_pitch;
-    kdBellDuration = ctrl->bell_duration;
-    KdSetLeds ();
-}
-
-static int
-KdKeybdProc(DeviceIntPtr pDevice, int onoff)
-{
-    Bool        ret;
-    DevicePtr   pDev = (DevicePtr)pDevice;
-#ifdef XKB
-    XkbComponentNamesRec names;
-#endif
+    KdKeyboardInfo *ki;
 
-    if (!pDev)
-	return BadImplementation;
+    for (ki = kdKeyboards; ki; ki = ki->next) {
+        if (ki->dixdev && ki->dixdev->id == pDevice->id)
+            break;
+    }
 
-    switch (onoff)
-    {
-    case DEVICE_INIT:
-	if (pDev != LookupKeyboardDevice())
-	{
-	    return !Success;
-	}
-#ifndef XKB
-	ret = InitKeyboardDeviceStruct(pDev,
-				       &kdKeySyms,
-				       kdModMap,
-				       KdBell, KdKbdCtrl);
-#else
-	memset(&names, 0, sizeof(XkbComponentNamesRec));
+    if (!ki || !ki->dixdev || ki->dixdev->id != pDevice->id || !ki->driver)
+        return;
 
-	XkbSetRulesDflts ("base", "pc101", "us", NULL, NULL);
-	ret = XkbInitKeyboardDeviceStruct ((DeviceIntPtr) pDev,
-					   &names,
-					   &kdKeySyms,
-					   kdModMap,
-					   KdBell, KdKbdCtrl);
-#endif
-	if (!ret)
-	    return BadImplementation;
-	break;
-    case DEVICE_ON:
-	pDev->on = TRUE;
-	pKdKeyboard = pDevice;
-	if (kdKeyboardFuncs)
-	    (*kdKeyboardFuncs->Init) ();
-	break;
-    case DEVICE_OFF:
-    case DEVICE_CLOSE:
-	pKdKeyboard = 0;
-	if (pDev->on)
-	{
-	    pDev->on = FALSE;
-	    if (kdKeyboardFuncs)
-		(*kdKeyboardFuncs->Fini) ();
-	}
-	break;
-    }
-    return Success;
+    KdSetLeds(ki, ctrl->leds);
+    ki->bellPitch = ctrl->bell_pitch;
+    ki->bellDuration = ctrl->bell_duration; 
 }
 
 extern KeybdCtrl defaultKeyboardControl;
 
 static void
-KdInitAutoRepeats (void)
+KdInitAutoRepeats (KdKeyboardInfo *ki)
 {
     int		    key_code;
     unsigned char   mask;
@@ -499,7 +647,7 @@ KdInitAutoRepeats (void)
     memset (repeats, '\0', 32);
     for (key_code = KD_MIN_KEYCODE; key_code <= KD_MAX_KEYCODE; key_code++)
     {
-	if (!kdModMap[key_code])
+	if (!ki->modmap[key_code])
 	{
 	    i = key_code >> 3;
 	    mask = 1 << (key_code & 7);
@@ -525,7 +673,6 @@ const KdKeySymModsRec kdKeySymMods[] = {
   {  XK_Hyper_L,	Mod3Mask },
   {  XK_Hyper_R,	Mod3Mask },
   {  XK_Mode_switch, Mod4Mask },
-#ifdef TOUCHSCREEN
   /* PDA specific hacks */
 #ifdef XF86XK_Start
   {  XF86XK_Start, ControlMask },
@@ -538,13 +685,12 @@ const KdKeySymModsRec kdKeySymMods[] = {
 #ifdef XF86XK_Calendar
   {  XF86XK_Calendar, Mod3Mask }
 #endif
-#endif
 };
 
 #define NUM_SYM_MODS (sizeof(kdKeySymMods) / sizeof(kdKeySymMods[0]))
 
 static void
-KdInitModMap (void)
+KdInitModMap (KdKeyboardInfo *ki)
 {
     int	    key_code;
     int	    row;
@@ -552,79 +698,589 @@ KdInitModMap (void)
     KeySym  *syms;
     int	    i;
 
-    width = kdKeySyms.mapWidth;
-    for (key_code = kdMinKeyCode; key_code <= kdMaxKeyCode; key_code++)
+    width = ki->keySyms.mapWidth;
+    for (key_code = ki->keySyms.minKeyCode; key_code <= ki->keySyms.maxKeyCode; key_code++)
     {
-	kdModMap[key_code] = 0;
-	syms = kdKeymap + (key_code - kdMinKeyCode) * width;
+	ki->modmap[key_code] = 0;
+	syms = ki->keySyms.map + (key_code - ki->keySyms.minKeyCode) * width;
 	for (row = 0; row < width; row++, syms++)
 	{
 	    for (i = 0; i < NUM_SYM_MODS; i++) 
 	    {
 		if (*syms == kdKeySymMods[i].modsym) 
-		    kdModMap[key_code] |= kdKeySymMods[i].modbit;
+		    ki->modmap[key_code] |= kdKeySymMods[i].modbit;
 	    }
 	}
     }
 }
 
+static int
+KdKeyboardProc(DeviceIntPtr pDevice, int onoff)
+{
+    Bool        ret;
+    DevicePtr   pDev = (DevicePtr)pDevice;
+    KdKeyboardInfo *ki;
+#ifdef XKB
+    XkbComponentNamesRec names;
+#endif
+#ifdef XINPUT
+    Atom xiclass;
+#endif
+
+    if (!pDev)
+	return BadImplementation;
+
+    for (ki = kdKeyboards; ki; ki = ki->next) {
+        if (ki->dixdev && ki->dixdev->id == pDevice->id)
+            break;
+    }
+
+    if (!ki || !ki->dixdev || ki->dixdev->id != pDevice->id) {
+        return BadImplementation;
+    }
+
+    switch (onoff)
+    {
+    case DEVICE_INIT:
+#ifdef DEBUG
+        ErrorF("initialising keyboard %s\n", ki->name);
+#endif
+        if (!ki->driver) {
+            if (!ki->driverPrivate) {
+                ErrorF("no driver specified!\n");
+                return BadImplementation;
+            }
+
+            ki->driver = KdFindKeyboardDriver(ki->driverPrivate);
+            if (!ki->driver) {
+                ErrorF("Couldn't find keyboard driver %s\n",
+                       ki->driverPrivate ? (char *) ki->driverPrivate :
+                       "(unnamed)");
+                return !Success;
+            }
+            xfree(ki->driverPrivate);
+            ki->driverPrivate = NULL;
+        }
+
+        if (!ki->driver->Init) {
+            ErrorF("Keyboard %s: no init function\n", ki->name);
+            return BadImplementation;
+        }
+
+        if ((*ki->driver->Init) (ki) != Success) {
+            return !Success;
+        }
+
+        KdInitModMap(ki);
+        KdInitAutoRepeats(ki);
+
+#ifndef XKB
+        if (!noXkbExtension) {
+            memset(&names, 0, sizeof(XkbComponentNamesRec));
+            if (XkbInitialMap) 
+                names.keymap = XkbInitialMap;
+
+            XkbSetRulesDflts ("base", "pc105", "us", NULL, NULL);
+            ret = XkbInitKeyboardDeviceStruct (pDevice,
+                                               &names,
+                                               &ki->keySyms,
+                                               ki->modmap,
+                                               KdBell, KdKbdCtrl);
+        }
+        else
+#endif
+	ret = InitKeyboardDeviceStruct(pDev,
+				       &ki->keySyms,
+				       ki->modmap,
+				       KdBell, KdKbdCtrl);
+	if (!ret) {
+            ErrorF("Couldn't initialise keyboard %s\n", ki->name);
+	    return BadImplementation;
+        }
+
+#ifdef XINPUT
+        xiclass = AtomFromName(XI_KEYBOARD);
+        AssignTypeAndName(pDevice, xiclass,
+                          ki->name ? ki->name : "Generic KDrive Keyboard");
+#endif
+
+        KdResetInputMachine();
+
+        return Success;
+
+    case DEVICE_ON:
+        if (pDev->on == TRUE)
+            return Success;
+
+        if (!ki->driver->Enable)
+            return BadImplementation;
+
+        if ((*ki->driver->Enable) (ki) != Success) {
+            return BadMatch;
+        }
+
+        pDev->on = TRUE;
+        return Success;
+
+    case DEVICE_OFF:
+        if (pDev->on == FALSE)
+            return Success;
+
+        if (!ki->driver->Disable)
+            return BadImplementation;
+
+        (*ki->driver->Disable) (ki);
+        pDev->on = FALSE;
+
+        return Success;
+        
+        break;
+
+    case DEVICE_CLOSE:
+	if (pDev->on) {
+            if (!ki->driver->Disable)
+                return BadImplementation;
+
+            (*ki->driver->Disable) (ki);
+            pDev->on = FALSE;
+	}
+
+        if (!ki->driver->Fini)
+            return BadImplementation;
+
+        (*ki->driver->Fini) (ki);
+
+        KdRemoveKeyboard(ki);
+
+        return Success;
+    }
+
+    /* NOTREACHED */
+    return BadImplementation;
+}
+
+void
+KdAddPointerDriver (KdPointerDriver *driver)
+{
+    KdPointerDriver **prev;
+
+    if (!driver)
+        return;
+
+    for (prev = &kdPointerDrivers; *prev; prev = &(*prev)->next) {
+        if (*prev == driver)
+            return;
+    }
+    *prev = driver;
+}
+
 void
-KdAddMouseDriver(KdMouseFuncs *pMouseFuncs)
+KdRemovePointerDriver (KdPointerDriver *driver)
 {
-    if (kdNMouseFuncs < MAX_MOUSE_DRIVERS)
-	kdMouseFuncs[kdNMouseFuncs++] = pMouseFuncs;
+    KdPointerDriver *tmp;
+
+    if (!driver)
+        return;
+
+    /* FIXME remove all pointers using this driver */
+    for (tmp = kdPointerDrivers; tmp; tmp = tmp->next) {
+        if (tmp->next == driver)
+            tmp->next = driver->next;
+    }
+    if (tmp == driver)
+        tmp = NULL;
 }
 
 void
-KdInitInput(KdMouseFuncs    *pMouseFuncs,
-	    KdKeyboardFuncs *pKeyboardFuncs)
+KdAddKeyboardDriver (KdKeyboardDriver *driver)
 {
-    DeviceIntPtr	pKeyboard, pPointer;
-    KdMouseInfo		*mi;
+    KdKeyboardDriver **prev;
+
+    if (!driver)
+        return;
+
+    for (prev = &kdKeyboardDrivers; *prev; prev = &(*prev)->next) {
+        if (*prev == driver)
+            return;
+    }
+    *prev = driver;
+}
+
+void
+KdRemoveKeyboardDriver (KdKeyboardDriver *driver)
+{
+    KdKeyboardDriver *tmp;
+
+    if (!driver)
+        return;
+
+    /* FIXME remove all keyboards using this driver */
+    for (tmp = kdKeyboardDrivers; tmp; tmp = tmp->next) {
+        if (tmp->next == driver)
+            tmp->next = driver->next;
+    }
+    if (tmp == driver)
+        tmp = NULL;
+}
+
+KdKeyboardInfo *
+KdNewKeyboard (void)
+{
+    KdKeyboardInfo *ki = xcalloc(sizeof(KdKeyboardInfo), 1);
+
+    if (!ki)
+        return NULL;
     
-    if (!kdMouseInfo)
-	KdParseMouse (0);
-    kdMouseButtonCount = 0;
-    for (mi = kdMouseInfo; mi; mi = mi->next)
-    {
-	if (mi->nbutton > kdMouseButtonCount)
-	    kdMouseButtonCount = mi->nbutton;
-    }
-
-    kdNMouseFuncs = 0;
-    KdAddMouseDriver (pMouseFuncs);
-    kdKeyboardFuncs = pKeyboardFuncs;
-    memset (kdKeyState, '\0', sizeof (kdKeyState));
-    if (kdKeyboardFuncs)
-	(*kdKeyboardFuncs->Load) ();
-    kdMinKeyCode = kdMinScanCode + KD_KEY_OFFSET;
-    kdMaxKeyCode = kdMaxScanCode + KD_KEY_OFFSET;
-    kdKeySyms.map = kdKeymap;
-    kdKeySyms.minKeyCode = kdMinKeyCode;
-    kdKeySyms.maxKeyCode = kdMaxKeyCode;
-    kdKeySyms.mapWidth = kdKeymapWidth;
-    kdLeds = 0;
-    kdBellPitch = 1000;
-    kdBellDuration = 200;
-    kdInputEnabled = TRUE;
-    KdInitModMap ();
-    KdInitAutoRepeats ();
-    KdResetInputMachine ();
-    pPointer  = AddInputDevice(KdMouseProc, TRUE);
-    pKeyboard = AddInputDevice(KdKeybdProc, TRUE);
-    RegisterPointerDevice(pPointer);
-    RegisterKeyboardDevice(pKeyboard);
-    miRegisterPointerDevice(screenInfo.screens[0], pPointer);
-    mieqInit(&pKeyboard->public, &pPointer->public);
+    ki->keySyms.map = (KeySym *)xcalloc(sizeof(KeySym),
+                                        KD_MAX_LENGTH *
+                                         kdDefaultKeySyms.mapWidth);
+    if (!ki->keySyms.map) {
+        xfree(ki);
+        return NULL;
+    }
+
+    memcpy(ki->keySyms.map, kdDefaultKeySyms.map,
+           sizeof(KeySym) * (KD_MAX_LENGTH * kdDefaultKeySyms.mapWidth));
+    ki->keySyms.minKeyCode = kdDefaultKeySyms.minKeyCode;
+    ki->keySyms.maxKeyCode = kdDefaultKeySyms.maxKeyCode;
+    ki->keySyms.mapWidth = kdDefaultKeySyms.mapWidth;
+    ki->minScanCode = 0;
+    ki->maxScanCode = 0;
+    ki->leds = 0;
+    ki->bellPitch = 1000;
+    ki->bellDuration = 200;
+    ki->next = NULL;
+    ki->options = NULL;
+
+    return ki;
+}
+
+int
+KdAddConfigKeyboard (char *keyboard)
+{
+    struct KdConfigDevice **prev, *new;
+
+    if (!keyboard)
+        return Success;
+
+    new = (struct KdConfigDevice *) xcalloc(sizeof(struct KdConfigDevice), 1);
+    if (!new)
+        return BadAlloc;
+
+    new->line = xstrdup(keyboard);
+    new->next = NULL;
+
+    for (prev = &kdConfigKeyboards; *prev; prev = &(*prev)->next);
+    *prev = new;
+
+    return Success;
+}
+
+int
+KdAddKeyboard (KdKeyboardInfo *ki)
+{
+    KdKeyboardInfo **prev;
+
+    if (!ki)
+        return !Success;
+    
+    ki->dixdev = AddInputDevice(KdKeyboardProc, TRUE);
+    if (!ki->dixdev) {
+        ErrorF("Couldn't register keyboard device %s\n",
+               ki->name ? ki->name : "(unnamed)");
+        return !Success;
+    }
+
 #ifdef XINPUT
-    {
-	static long zero1, zero2;
+    RegisterOtherDevice(ki->dixdev);
+#endif
+
+#ifdef DEBUG
+    ErrorF("added keyboard %s with dix id %d\n", ki->name, ki->dixdev->id);
+#endif
+
+    for (prev = &kdKeyboards; *prev; prev = &(*prev)->next);
+    *prev = ki;
+
+    return Success;
+}
+
+void
+KdRemoveKeyboard (KdKeyboardInfo *ki)
+{
+    KdKeyboardInfo **prev;
+
+    if (!ki)
+        return;
+
+    for (prev = &kdKeyboards; *prev; prev = &(*prev)->next) {
+        if (*prev == ki) {
+            *prev = ki->next;
+            break;
+        }
+    }
+
+    KdFreeKeyboard(ki);
+}
+
+int
+KdAddConfigPointer (char *pointer)
+{
+    struct KdConfigDevice **prev, *new;
+
+    if (!pointer)
+        return Success;
+
+    new = (struct KdConfigDevice *) xcalloc(sizeof(struct KdConfigDevice), 1);
+    if (!new)
+        return BadAlloc;
+
+    new->line = xstrdup(pointer);
+    new->next = NULL;
+
+    for (prev = &kdConfigPointers; *prev; prev = &(*prev)->next);
+    *prev = new;
+
+    return Success;
+}
+
+int
+KdAddPointer (KdPointerInfo *pi)
+{
+    KdPointerInfo **prev;
+
+    if (!pi)
+        return Success;
+
+    pi->mouseState = start;
+    pi->eventHeld = FALSE;
+
+    pi->dixdev = AddInputDevice(KdPointerProc, TRUE);
+    if (!pi->dixdev) {
+        ErrorF("Couldn't add pointer device %s\n",
+               pi->name ? pi->name : "(unnamed)");
+        return BadDevice;
+    }
+
+#ifdef XINPUT
+    RegisterOtherDevice(pi->dixdev);
+#endif
+
+    for (prev = &kdPointers; *prev; prev = &(*prev)->next);
+    *prev = pi;
+
+    return Success;
+}
 
-	//SetExtInputCheck (&zero1, &zero2);
-	ErrorF("Extended Input Devices not yet supported. Impelement it at line %d in %s\n",
-	       __LINE__, __FILE__);
+void
+KdRemovePointer (KdPointerInfo *pi)
+{
+    KdPointerInfo **prev;
+
+    if (!pi)
+        return;
+
+    for (prev = &kdPointers; *prev; prev = &(*prev)->next) {
+        if (*prev == pi) {
+            *prev = pi->next;
+            break;
+        }
     }
+
+    KdFreePointer(pi);
+}
+
+KdKeyboardInfo *
+KdParseKeyboard (char *arg)
+{
+    char            save[1024];
+    char            delim;
+    KdKeyboardInfo     *ki = NULL;
+
+    ki = KdNewKeyboard();
+    if (!ki)
+        return NULL;
+
+    ki->name = strdup("Unknown KDrive Keyboard");
+    ki->path = NULL;
+    ki->driver = NULL;
+    ki->driverPrivate = NULL;
+#ifdef XKB
+    ki->xkb = NULL;
 #endif
+    ki->next = NULL;
+
+    if (!arg)
+    {
+        ErrorF("keybd: no arg\n");
+        KdFreeKeyboard (ki);
+        return NULL;
+    }
+
+    if (strlen (arg) >= sizeof (save))
+    {
+        ErrorF("keybd: arg too long\n");
+        KdFreeKeyboard (ki);
+        return NULL;
+    }
+
+    arg = KdParseFindNext (arg, ",", save, &delim);
+    if (!save[0])
+    {
+        ErrorF("keybd: failed on save[0]\n");
+        KdFreeKeyboard (ki);
+        return NULL;
+    }
+
+    if (strcmp (save, "auto") == 0)
+        ki->driverPrivate = NULL;
+    else
+        ki->driverPrivate = xstrdup(save);
+
+    /* FIXME actually implement options */
+
+    return ki;
+}
+
+KdPointerInfo *
+KdParsePointer (char *arg)
+{
+    char            save[1024];
+    char            delim;
+    KdPointerInfo   *pi = NULL;
+    InputOption     *options = NULL, *newopt = NULL, **tmpo = NULL;
+    int             i = 0;
+
+    pi = KdNewPointer();
+    if (!pi)
+        return NULL;
+    pi->emulateMiddleButton = kdEmulateMiddleButton;
+    pi->transformCoordinates = !kdRawPointerCoordinates;
+    pi->nButtons = 3;
+    pi->inputClass = KD_MOUSE;
+
+    for (i = 0; i < KD_MAX_BUTTON; i++)
+        pi->map[i] = i + 1;
+
+    if (!arg)
+    {
+        ErrorF("mouse: no arg\n");
+        KdFreePointer (pi);
+        return NULL;
+    }
+
+    if (strlen (arg) >= sizeof (save))
+    {
+        ErrorF("mouse: arg too long\n");
+        KdFreePointer (pi);
+        return NULL;
+    }
+    arg = KdParseFindNext (arg, ",", save, &delim);
+    if (!save[0])
+    {
+        ErrorF("failed on save[0]\n");
+        KdFreePointer (pi);
+        return NULL;
+    }
+
+    if (strcmp(save, "auto") == 0)
+        pi->driverPrivate = NULL;
+    else
+        pi->driverPrivate = xstrdup(save);
+
+    if (delim != ',')
+    {
+        return pi;
+    }
+
+    arg = KdParseFindNext (arg, ",", save, &delim);
+
+    while (delim == ',')
+    {
+        arg = KdParseFindNext (arg, ",", save, &delim);
+        if (save[0] == '{')
+        {
+            char *s = save + 1;
+             i = 0;
+             while (*s && *s != '}')
+             {
+                if ('1' <= *s && *s <= '0' + pi->nButtons)
+                    pi->map[i] = *s - '0';
+                else
+                    UseMsg ();
+                s++;
+             }
+        }
+        else if (!strcmp (save, "emulatemiddle"))
+            pi->emulateMiddleButton = TRUE;
+        else if (!strcmp (save, "noemulatemiddle"))
+            pi->emulateMiddleButton = FALSE;
+        else if (!strcmp (save, "transformcoord"))
+            pi->transformCoordinates = TRUE;
+        else if (!strcmp (save, "rawcoord"))
+            pi->transformCoordinates = FALSE;
+        else
+        {
+            newopt = (InputOption *) xalloc(sizeof (InputOption));
+            if (!newopt)
+            {
+                KdFreePointer(pi);
+                return NULL;
+            }
+            bzero(newopt, sizeof (InputOption));
+
+            for (tmpo = &options; *tmpo; tmpo = &(*tmpo)->next)
+            *tmpo = newopt;
+
+            if (strchr(arg, '='))
+            {
+                i = (strchr(arg, '=') - arg);
+                newopt->key = (char *)xalloc(i+1);
+                strncpy(newopt->key, arg, i+1);
+                newopt->value = xstrdup(strchr(arg, '=') + 1);
+            }
+            else
+            {
+                newopt->key = xstrdup(save);
+                newopt->value = NULL;
+            }
+            newopt->next = NULL;
+        }
+    }
+
+    if (options)
+        pi->options = options;
+
+    return pi;
+}
+
+
+void
+KdInitInput (void)
+{
+    KdPointerInfo *pi;
+    KdKeyboardInfo *ki;
+    struct KdConfigDevice *dev;
+    int i = 0;
+
+    kdInputEnabled = TRUE;
+
+    for (dev = kdConfigPointers; dev; dev = dev->next) {
+        pi = KdParsePointer(dev->line);
+        if (!pi)
+            ErrorF("Failed to parse pointer\n");
+        if (KdAddPointer(pi) != Success)
+            ErrorF("Failed to add pointer!\n");
+    }
+    for (dev = kdConfigKeyboards; dev; dev = dev->next) {
+        ki = KdParseKeyboard(dev->line);
+        if (!ki)
+            ErrorF("Failed to parse keyboard\n");
+        if (KdAddKeyboard(ki) != Success)
+            ErrorF("Failed to add keyboard!\n");
+    }
+
+    mieqInit(NULL, NULL);
 }
 
 /*
@@ -786,7 +1442,7 @@ typedef enum _inputAction {
 
 typedef struct _inputTransition {
     KdInputAction  actions[MAX_ACTIONS];
-    KdMouseState   nextState;
+    KdPointerState nextState;
 } KdInputTransition;
 
 static const
@@ -931,32 +1587,22 @@ KdInputTransition  kdInputMachine[num_in
 #define EMULATION_WINDOW    10
 #define EMULATION_TIMEOUT   100
 
-#define EventX(e)   ((e)->u.keyButtonPointer.rootX)
-#define EventY(e)   ((e)->u.keyButtonPointer.rootY)
-
 static int
-KdInsideEmulationWindow (KdMouseInfo *mi, xEvent *ev)
+KdInsideEmulationWindow (KdPointerInfo *pi, int x, int y, int z)
 {
-    if (ev->u.keyButtonPointer.pad1)
-    {
-	mi->emulationDx += EventX(ev);
-	mi->emulationDy += EventY(ev);
-    }
-    else
-    {
-	mi->emulationDx = EventX(&mi->heldEvent) - EventX(ev);
-	mi->emulationDy = EventY(&mi->heldEvent) - EventY(ev);
-    }
-    return (abs (mi->emulationDx) < EMULATION_WINDOW &&
-	    abs (mi->emulationDy) < EMULATION_WINDOW);
+    pi->emulationDx = pi->heldEvent.x - x;
+    pi->emulationDy = pi->heldEvent.y - y;
+
+    return (abs (pi->emulationDx) < EMULATION_WINDOW &&
+	    abs (pi->emulationDy) < EMULATION_WINDOW);
 }
 				     
 static KdInputClass
-KdClassifyInput (KdMouseInfo *mi, xEvent *ev)
+KdClassifyInput (KdPointerInfo *pi, int type, int x, int y, int z, int b)
 {
-    switch (ev->u.u.type) {
+    switch (type) {
     case ButtonPress:
-	switch (ev->u.u.detail) {
+	switch (b) {
 	case 1: return down_1;
 	case 2: return down_2;
 	case 3: return down_3;
@@ -964,7 +1610,7 @@ KdClassifyInput (KdMouseInfo *mi, xEvent
 	}
 	break;
     case ButtonRelease:
-	switch (ev->u.u.detail) {
+	switch (b) {
 	case 1: return up_1;
 	case 2: return up_2;
 	case 3: return up_3;
@@ -972,7 +1618,7 @@ KdClassifyInput (KdMouseInfo *mi, xEvent
 	}
 	break;
     case MotionNotify:
-	if (mi->eventHeld && !KdInsideEmulationWindow(mi, ev))
+	if (pi->eventHeld && !KdInsideEmulationWindow(pi, x, y, z))
 	    return outside_box;
 	else
 	    return motion;
@@ -1021,116 +1667,98 @@ static void
 KdQueueEvent (xEvent *ev)
 {
     KdAssertSigioBlocked ("KdQueueEvent");
-    if (ev->u.u.type == MotionNotify)
-    {
-	if (ev->u.keyButtonPointer.pad1)
-	{
-	    ev->u.keyButtonPointer.pad1 = 0;
-	    miPointerDeltaCursor (ev->u.keyButtonPointer.rootX, 
-				  ev->u.keyButtonPointer.rootY, 
-				  ev->u.keyButtonPointer.time);
-	}
-	else
-	{
-	    miPointerAbsoluteCursor(ev->u.keyButtonPointer.rootX, 
-				    ev->u.keyButtonPointer.rootY, 
-				    ev->u.keyButtonPointer.time);
-	}
-    }
-    else
-    {
-	mieqEnqueue (ev);
-    }
+    mieqEnqueue (ev);
 }
 
-static void
-KdRunMouseMachine (KdMouseInfo *mi, KdInputClass c, xEvent *ev)
+/* We return true if we're stealing the event. */
+static Bool
+KdRunMouseMachine (KdPointerInfo *pi, KdInputClass c, int type, int x, int y,
+                   int z, int b, int absrel)
 {
     const KdInputTransition *t;
-    int			a;
+    int	a;
 
-    t = &kdInputMachine[mi->mouseState][c];
+    c = KdClassifyInput(pi, type, x, y, z, b);
+    t = &kdInputMachine[pi->mouseState][c];
     for (a = 0; a < MAX_ACTIONS; a++)
     {
 	switch (t->actions[a]) {
 	case noop:
 	    break;
 	case hold:
-	    mi->eventHeld = TRUE;
-	    mi->emulationDx = 0;
-	    mi->emulationDy = 0;
-	    mi->heldEvent = *ev;
+	    pi->eventHeld = TRUE;
+	    pi->emulationDx = 0;
+	    pi->emulationDy = 0;
+	    pi->heldEvent.type = type;
+            pi->heldEvent.x = x;
+            pi->heldEvent.y = y;
+            pi->heldEvent.z = z;
+            pi->heldEvent.flags = b;
+            pi->heldEvent.absrel = absrel;
+            return TRUE;
 	    break;
 	case setto:
-	    mi->emulationTimeout = GetTimeInMillis () + EMULATION_TIMEOUT;
-	    mi->timeoutPending = TRUE;
+	    pi->emulationTimeout = GetTimeInMillis () + EMULATION_TIMEOUT;
+	    pi->timeoutPending = TRUE;
 	    break;
 	case deliver:
-	    KdQueueEvent (ev);
+            _KdEnqueuePointerEvent (pi, pi->heldEvent.type, pi->heldEvent.x,
+                                    pi->heldEvent.y, pi->heldEvent.z,
+                                    pi->heldEvent.flags, pi->heldEvent.absrel,
+                                    TRUE);
 	    break;
 	case release:
-	    mi->eventHeld = FALSE;
-	    mi->timeoutPending = FALSE;
-	    KdQueueEvent (&mi->heldEvent);
+	    pi->eventHeld = FALSE;
+	    pi->timeoutPending = FALSE;
+            _KdEnqueuePointerEvent (pi, pi->heldEvent.type, pi->heldEvent.x,
+                                    pi->heldEvent.y, pi->heldEvent.z,
+                                    pi->heldEvent.flags, pi->heldEvent.absrel,
+                                    TRUE);
+            return TRUE;
 	    break;
 	case clearto:
-	    mi->timeoutPending = FALSE;
+	    pi->timeoutPending = FALSE;
 	    break;
 	case gen_down_2:
-	    ev->u.u.detail = 2;
-	    mi->eventHeld = FALSE;
-	    KdQueueEvent (ev);
+            _KdEnqueuePointerEvent (pi, ButtonPress, x, y, z, 2, absrel,
+                                    TRUE);
+	    pi->eventHeld = FALSE;
+            return TRUE;
 	    break;
 	case gen_up_2:
-	    ev->u.u.detail = 2;
-	    KdQueueEvent (ev);
+            _KdEnqueuePointerEvent (pi, ButtonRelease, x, y, z, 2, absrel,
+                                    TRUE);
+            return TRUE;
 	    break;
 	}
     }
-    mi->mouseState = t->nextState;
-}
-
-void
-KdResetInputMachine (void)
-{
-    KdMouseInfo	*mi;
-
-    for (mi = kdMouseInfo; mi; mi = mi->next)
-    {
-	mi->mouseState = start;
-	mi->eventHeld = FALSE;
-    }
+    pi->mouseState = t->nextState;
+    return FALSE;
 }
 
-static void
-KdHandleMouseEvent (KdMouseInfo *mi, xEvent *ev)
+static int
+KdHandlePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z, int b,
+                      int absrel)
 {
-    if (mi->emulateMiddleButton)
-	KdRunMouseMachine (mi, KdClassifyInput (mi, ev), ev);
-    else
-	KdQueueEvent (ev);
+    if (pi->emulateMiddleButton)
+        return KdRunMouseMachine (pi, KdClassifyInput(pi, type, x, y, z, b),
+                                  type, x, y, z, b, absrel);
+    return FALSE;
 }
 
 static void
-KdReceiveTimeout (KdMouseInfo *mi)
+KdReceiveTimeout (KdPointerInfo *pi)
 {
-    KdRunMouseMachine (mi, timeout, 0);
+    KdRunMouseMachine (pi, timeout, 0, 0, 0, 0, 0, 0);
 }
 
-#define KILL_SEQUENCE ((1L << KK_CONTROL)|(1L << KK_ALT)|(1L << KK_F8)|(1L << KK_F10))
-#define SPECIAL_SEQUENCE ((1L << KK_CONTROL) | (1L << KK_ALT))
-#define SETKILLKEY(b) (KdSpecialKeys |= (1L << (b)))
-#define CLEARKILLKEY(b) (KdSpecialKeys &= ~(1L << (b)))
-#define KEYMAP	    (pKdKeyboard->key->curKeySyms)
-#define KEYCOL1(k) (KEYMAP.map[((k)-kdMinKeyCode)*KEYMAP.mapWidth])
+#define KILL_SEQUENCE     ((1L << KK_CONTROL)|(1L << KK_ALT)|(1L << KK_F8)|(1L << KK_F10))
+#define SPECIAL_SEQUENCE  ((1L << KK_CONTROL) | (1L << KK_ALT))
+#define SETKILLKEY(b)     (KdSpecialKeys |= (1L << (b)))
+#define CLEARKILLKEY(b)   (KdSpecialKeys &= ~(1L << (b)))
 
 CARD32	KdSpecialKeys = 0;
 
-#if 0
-/* already defined in opaque.h */
-extern char dispatchException;
-#endif
-
 /*
  * kdCheckTermination
  *
@@ -1145,44 +1773,28 @@ extern char dispatchException;
 extern int nClients;
 
 static void
-KdCheckSpecialKeys(xEvent *xE)
+KdCheckSpecialKeys(KdKeyboardInfo *ki, int type, int sym)
 {
-    KeySym	sym = KEYCOL1(xE->u.u.detail);
-    
-    if (!pKdKeyboard) return;
+    if (!ki)
+        return;
 
     /*
      * Ignore key releases
      */
-    
-    if (xE->u.u.type == KeyRelease) return;
 
-#ifdef XIPAQ
-    /* 
-     * Check for buttons 1, 2 and 3 on the iPAQ
-     */
-    if (sym == XK_Pointer_Button1 && kdMouseInfo) {
-	KdEnqueueMouseEvent(kdMouseInfo, KD_MOUSE_DELTA | KD_BUTTON_1, 0, 0);
-	return;
-    }
-    if (sym == XK_Pointer_Button2 && kdMouseInfo) {
-	KdEnqueueMouseEvent(kdMouseInfo, KD_MOUSE_DELTA | KD_BUTTON_2, 0, 0);
-	return;
-    }
-    if (sym == XK_Pointer_Button3 && kdMouseInfo) {
-	KdEnqueueMouseEvent(kdMouseInfo, KD_MOUSE_DELTA | KD_BUTTON_3, 0, 0);
-	return;
-    }
-#endif
+    if (type == KeyRelease)
+        return;
+
+    /* Some iPaq keyboard -> mouse button mapping used to be here, but I
+     * refuse to perpetuate this madness. -daniels */
 
     /*
      * Check for control/alt pressed
      */
-    if ((pKdKeyboard->key->state & (ControlMask|Mod1Mask)) !=
+    if ((ki->dixdev->key->state & (ControlMask|Mod1Mask)) !=
 	(ControlMask|Mod1Mask))
 	return;
-    
-    
+
     /*
      * Let OS function see keysym first
      */
@@ -1194,6 +1806,8 @@ KdCheckSpecialKeys(xEvent *xE)
     /*
      * Now check for backspace or delete; these signal the
      * X server to terminate
+     *
+     * I can't believe it's not XKB. -daniels
      */
     switch (sym) {
     case XK_BackSpace:
@@ -1219,150 +1833,164 @@ KdCheckSpecialKeys(xEvent *xE)
  */
 
 static void
-KdHandleKeyboardEvent (xEvent *ev)
+KdHandleKeyboardEvent (KdKeyboardInfo *ki, int type, int key)
 {
-    int		key = ev->u.u.detail;
-    int		byte;
-    CARD8	bit;
-    KdMouseInfo	*mi;
+    int           byte;
+    CARD8         bit;
+    KdPointerInfo *pi;
     
     byte = key >> 3;
     bit = 1 << (key & 7);
-    switch (ev->u.u.type) {
+
+    switch (type) {
     case KeyPress:
-	kdKeyState[byte] |= bit;
+	ki->keyState[byte] |= bit;
 	break;
     case KeyRelease:
-	kdKeyState[byte] &= ~bit;
+	ki->keyState[byte] &= ~bit;
 	break;
     }
-    for (mi = kdMouseInfo; mi; mi = mi->next)
-	KdRunMouseMachine (mi, keyboard, 0);
-    KdQueueEvent (ev);
+
+    for (pi = kdPointers; pi; pi = pi->next)
+	KdRunMouseMachine (pi, keyboard, 0, 0, 0, 0, 0, 0);
 }
 
 void
 KdReleaseAllKeys (void)
 {
-    xEvent  xE;
-    int	    key;
+    xEvent *xE;
+    int	key, nEvents, i;
+    KdKeyboardInfo *ki;
 
     KdBlockSigio ();
-    for (key = 0; key < KD_KEY_COUNT; key++)
-	if (IsKeyDown(key))
-	{
-	    xE.u.keyButtonPointer.time = GetTimeInMillis();
-	    xE.u.u.type = KeyRelease;
-	    xE.u.u.detail = key;
-	    KdHandleKeyboardEvent (&xE);
-	}
+
+    for (ki = kdKeyboards; ki; ki = ki->next) {
+        for (key = ki->keySyms.minKeyCode; key < ki->keySyms.maxKeyCode;
+             key++) {
+            if (IsKeyDown(ki, key)) {
+                KdHandleKeyboardEvent(ki, KeyRelease, key);
+                nEvents = GetKeyboardEvents(&xE, ki->dixdev, KeyRelease, key);
+                for (i = 0; i < nEvents; i++)
+                    KdQueueEvent (xE++);
+            }
+        }
+    }
+
     KdUnblockSigio ();
 }
 
 static void
 KdCheckLock (void)
 {
-    KeyClassPtr	    keyc = pKdKeyboard->key;
-    Bool	    isSet, shouldBeSet;
-
-    if (kdKeyboardFuncs->LockLed)
-    {
-	isSet = (kdLeds & (1 << (kdKeyboardFuncs->LockLed-1))) != 0;
-	shouldBeSet = (keyc->state & LockMask) != 0;
-	if (isSet != shouldBeSet)
-	{
-	    KdSetLed (kdKeyboardFuncs->LockLed, shouldBeSet);
-	}
+    KeyClassPtr	    keyc = NULL;
+    Bool	    isSet = FALSE, shouldBeSet = FALSE;
+    KdKeyboardInfo     *tmp = NULL;
+
+    for (tmp = kdKeyboards; tmp; tmp = tmp->next) {
+        if (tmp->LockLed && tmp->dixdev && tmp->dixdev->key) {
+            keyc = tmp->dixdev->key;
+            isSet = (tmp->leds & (1 << (tmp->LockLed-1))) != 0;
+            shouldBeSet = (keyc->state & LockMask) != 0;
+            if (isSet != shouldBeSet)
+                KdSetLed (tmp, tmp->LockLed, shouldBeSet);
+        }
     }
 }
 
 void
-KdEnqueueKeyboardEvent(unsigned char	scan_code,
-		       unsigned char	is_up)
-{
-    unsigned char   key_code;
-    xEvent	    xE;
-    KeyClassPtr	    keyc;
-
-    if (!pKdKeyboard)
+KdEnqueueKeyboardEvent(KdKeyboardInfo   *ki,
+                       unsigned char scan_code,
+		       unsigned char is_up)
+{
+    unsigned char key_code;
+    KeyClassPtr	keyc = NULL;
+    KeybdCtrl *ctrl = NULL;
+    int type, nEvents, i;
+    xEvent *xE = NULL;
+
+#ifdef DEBUG
+    ErrorF("enqueuing kb event (scancode %d, %s)\n", scan_code, is_up ? "up" : "down");
+    ErrorF("event is from %s\n", ki->name);
+#endif
+    
+    if (!ki || !ki->dixdev || !ki->dixdev->kbdfeed || !ki->dixdev->key)
 	return;
-    keyc = pKdKeyboard->key;
 
-    xE.u.keyButtonPointer.time = GetTimeInMillis();
+    keyc = ki->dixdev->key;
+    ctrl = &ki->dixdev->kbdfeed->ctrl;
 
-    if (kdMinScanCode <= scan_code && scan_code <= kdMaxScanCode)
+    if (scan_code >= ki->minScanCode && scan_code <= ki->maxScanCode)
     {
-	key_code = scan_code + KD_MIN_KEYCODE - kdMinScanCode;
+	key_code = scan_code + KD_MIN_KEYCODE - ki->minScanCode;
 	
 	/*
 	 * Set up this event -- the type may be modified below
 	 */
 	if (is_up)
-	    xE.u.u.type = KeyRelease;
+	    type = KeyRelease;
 	else
-	    xE.u.u.type = KeyPress;
-	xE.u.u.detail = key_code;
+	    type = KeyPress;
 	
-	switch (KEYCOL1(key_code)) 
+        /* HRNGH */
+	switch (KEYCOL1(ki, key_code)) 
 	{
 	case XK_Num_Lock:
 	case XK_Scroll_Lock:
 	case XK_Shift_Lock:
 	case XK_Caps_Lock:
-	    if (xE.u.u.type == KeyRelease)
+	    if (type == KeyRelease)
 		return;
-	    if (IsKeyDown (key_code))
-		xE.u.u.type = KeyRelease;
+	    if (IsKeyDown (ki, key_code))
+		type = KeyRelease;
 	    else
-		xE.u.u.type = KeyPress;
+		type = KeyPress;
 	}
 	
 	/*
 	 * Check pressed keys which are already down
 	 */
-	if (IsKeyDown (key_code) && xE.u.u.type == KeyPress)
-	{
-	    KeybdCtrl	*ctrl = &pKdKeyboard->kbdfeed->ctrl;
-	    
+	if (IsKeyDown (ki, key_code) && type == KeyPress) {
 	    /*
 	     * Check auto repeat
 	     */
 	    if (!ctrl->autoRepeat || keyc->modifierMap[key_code] ||
 		!(ctrl->autoRepeats[key_code >> 3] & (1 << (key_code & 7))))
-	    {
 		return;
-	    }
+
 	    /*
 	     * X delivers press/release even for autorepeat
 	     */
-	    xE.u.u.type = KeyRelease;
-	    KdHandleKeyboardEvent (&xE);
-	    xE.u.u.type = KeyPress;
+            nEvents = GetKeyboardEvents(&xE, ki->dixdev, KeyRelease, key_code);
+            for (i = 0; i < nEvents; i++)
+                KdQueueEvent(xE++);
+            nEvents = GetKeyboardEvents(&xE, ki->dixdev, KeyPress, key_code);
+            for (i = 0; i < nEvents; i++)
+                KdQueueEvent(xE++);
 	}
 	/*
 	 * Check released keys which are already up
 	 */
-	else if (!IsKeyDown (key_code) && xE.u.u.type == KeyRelease)
-	{
+	else if (!IsKeyDown (ki, key_code) && type == KeyRelease) {
 	    return;
-	}
-	KdCheckSpecialKeys (&xE);
-	KdHandleKeyboardEvent (&xE);
-    }
-}
+        }
 
-#define SetButton(mi, b, v, s) \
-{\
-    xE.u.u.detail = mi->map[b]; \
-    xE.u.u.type = v; \
-    KdHandleMouseEvent (mi, &xE); \
+        KdCheckSpecialKeys(ki, type, key_code);
+        KdHandleKeyboardEvent(ki, type, key_code);
+        nEvents = GetKeyboardEvents(&xE, ki->dixdev, type, key_code);
+#ifdef DEBUG
+        ErrorF("KdEnqueueKeyboardEvent: got %d events from GKE\n", nEvents);
+#endif
+        for (i = 0; i < nEvents; i++)
+            KdQueueEvent(xE++);
+    }
+    else {
+        ErrorF("driver %s wanted to post scancode %d outside of [%d, %d]!\n",
+               ki->name, scan_code, ki->minScanCode, ki->maxScanCode);
+    }
 }
 
-#define Press(mi, b)         SetButton(mi, b, ButtonPress, "Down")
-#define Release(mi, b)       SetButton(mi, b, ButtonRelease, "Up")
-
 /*
- * kdEnqueueMouseEvent
+ * kdEnqueuePointerEvent
  *
  * This function converts hardware mouse event information into X event
  * information.  A mouse movement event is passed off to MI to generate
@@ -1371,8 +1999,9 @@ KdEnqueueKeyboardEvent(unsigned char	sca
  */
 
 static void
-KdMouseAccelerate (DeviceIntPtr	device, int *dx, int *dy)
+KdMouseAccelerate (KdPointerInfo *pi, int *dx, int *dy)
 {
+    DeviceIntPtr device = pi->dixdev;
     PtrCtrl *pCtrl = &device->ptrfeed->ctrl;
     double  speed = sqrt (*dx * *dx + *dy * *dy);
     double  accel;
@@ -1402,92 +2031,111 @@ KdMouseAccelerate (DeviceIntPtr	device, 
     *dy = accel * *dy;
 }
 
+/* FIXME do something a little more clever to deal with multiple axes here */
 void
-KdEnqueueMouseEvent(KdMouseInfo *mi, unsigned long flags, int rx, int ry)
+KdEnqueuePointerEvent(KdPointerInfo *pi, unsigned long flags, int rx, int ry,
+                      int rz)
 {
-    CARD32	    ms;
-    xEvent	    xE;
-    unsigned char   buttons;
-    int		    x, y;
-    int		    (*matrix)[3] = kdMouseMatrix.matrix;
-    unsigned long   button;
-    int		    n;
+    CARD32        ms;
+    unsigned char buttons;
+    int           x, y, z;
+    int           (*matrix)[3] = kdPointerMatrix.matrix;
+    unsigned long button;
+    int           n;
+    int           dixflags;
 
-    if (!pKdPointer)
+    if (!pi)
 	return;
     
     ms = GetTimeInMillis();
-    
-    if (flags & KD_MOUSE_DELTA)
-    {
-	if (mi->transformCoordinates)
-	{
+
+    /* we don't need to transform z, so we don't. */
+    if (flags & KD_MOUSE_DELTA) {
+	if (pi->transformCoordinates) {
 	    x = matrix[0][0] * rx + matrix[0][1] * ry;
 	    y = matrix[1][0] * rx + matrix[1][1] * ry;
 	}
-	else
-	{
+	else {
 	    x = rx;
 	    y = ry;
 	}
-	KdMouseAccelerate (pKdPointer, &x, &y);
-	xE.u.keyButtonPointer.pad1 = 1;
+        /* screw this, use the DIX's acceleration (stolen from XFree86)
+         * instead.
+         * KdMouseAccelerate (pi, &x, &y); */
     }
-    else
-    {
-	if (mi->transformCoordinates)
-	{
-	    x = matrix[0][0] * rx + matrix[0][1] * ry + matrix[0][2];
-	    y = matrix[1][0] * rx + matrix[1][1] * ry + matrix[1][2];
+    else {
+	if (pi->transformCoordinates) {
+	    x = matrix[0][0] * rx + matrix[0][1] * ry;
+	    y = matrix[1][0] * rx + matrix[1][1] * ry;
 	}
-	else
-	{
+	else {
 	    x = rx;
 	    y = ry;
 	}
-	xE.u.keyButtonPointer.pad1 = 0;
     }
-    xE.u.keyButtonPointer.time = ms;
-    xE.u.keyButtonPointer.rootX = x;
-    xE.u.keyButtonPointer.rootY = y;
-
-    xE.u.u.type = MotionNotify;
-    xE.u.u.detail = 0;
-    KdHandleMouseEvent (mi, &xE);
+    z = rz;
+
+#ifdef DEBUG
+    ErrorF("sending motion notification for (%d, %d, %d)\n", x, y, z);
+    ErrorF("  comes from (%d, %d, %d)\n", rx, ry, rz);
+    ErrorF("  is %s\n", (flags & KD_MOUSE_DELTA) ? "relative" : "absolute");
+#endif
+
+    if (flags & KD_MOUSE_DELTA)
+        dixflags = POINTER_RELATIVE & POINTER_ACCELERATE;
+    else
+        dixflags = POINTER_ABSOLUTE;
+
+    _KdEnqueuePointerEvent(pi, MotionNotify, x, y, z, 0, dixflags, FALSE);
 
     buttons = flags;
 
-    for (button = KD_BUTTON_1, n = 0; button <= KD_BUTTON_5; button <<= 1, n++)
-    {
-	if ((mi->buttonState & button) ^ (buttons & button))
-	{
-	    if (buttons & button)
-	    {
-		Press(mi, n);
-	    }
-	    else
-	    {
-		Release(mi, n);
-	    }
+    for (button = KD_BUTTON_1, n = 1; button <= pi->nButtons;
+         button <<= 1, n++) {
+        if (((pi->buttonState & button) ^ (buttons & button)) &&
+           !(buttons & button)) {
+#ifdef DEBUG
+            ErrorF("  posting button release %d\n", n);
+#endif
+            _KdEnqueuePointerEvent(pi, ButtonRelease, x, y, z, n,
+                                   dixflags, FALSE);
 	}
     }
-    mi->buttonState = buttons;
+    for (button = KD_BUTTON_1, n = 1; button <= pi->nButtons;
+         button <<= 1, n++) {
+	if (((pi->buttonState & button) ^ (buttons & button)) &&
+	    (buttons & button)) {
+#ifdef DEBUG
+            ErrorF("  posting button press %d\n", n);
+#endif
+            _KdEnqueuePointerEvent(pi, ButtonPress, x, y, z, n,
+                                   dixflags, FALSE);
+        }
+    }
+
+    pi->buttonState = buttons;
 }
 
 void
-KdEnqueueMotionEvent (KdMouseInfo *mi, int x, int y)
+_KdEnqueuePointerEvent (KdPointerInfo *pi, int type, int x, int y, int z,
+                        int b, int absrel, Bool force)
 {
-    xEvent  xE;
-    CARD32  ms;
-    
-    ms = GetTimeInMillis();
-    
-    xE.u.u.type = MotionNotify;
-    xE.u.keyButtonPointer.time = ms;
-    xE.u.keyButtonPointer.rootX = x;
-    xE.u.keyButtonPointer.rootY = y;
+    xEvent *xE = NULL;
+    int n = 0, i = 0;
+    int valuators[3] = { x, y, z };
+
+#ifdef DEBUG
+    ErrorF("mouse enqueuing event from device %s (%d, %d, %d; %d)\n",
+           pi->name, x, y, z, b);
+#endif
 
-    KdHandleMouseEvent (mi, &xE);
+    /* TRUE from KdHandlePointerEvent, means 'we swallowed the event'. */
+    if (!force && KdHandlePointerEvent(pi, type, x, y, z, b, absrel))
+        return;
+
+    n = GetPointerEvents(&xE, pi->dixdev, type, b, absrel, 3, valuators);
+    for (i = 0; i < n; i++)
+        KdQueueEvent(xE++);
 }
 
 void
@@ -1496,16 +2144,16 @@ KdBlockHandler (int		screen,
 		pointer		timeout,
 		pointer		readmask)
 {
-    KdMouseInfo		    *mi;
+    KdPointerInfo		    *pi;
     int myTimeout=0;
 
-    for (mi = kdMouseInfo; mi; mi = mi->next)
+    for (pi = kdPointers; pi; pi = pi->next)
     {
-	if (mi->timeoutPending)
+	if (pi->timeoutPending)
 	{
 	    int	ms;
     
-	    ms = mi->emulationTimeout - GetTimeInMillis ();
+	    ms = pi->emulationTimeout - GetTimeInMillis ();
 	    if (ms < 1)
 		ms = 1;
 	    if(ms<myTimeout || myTimeout==0)
@@ -1531,7 +2179,7 @@ KdWakeupHandler (int		screen, 
     int		result = (int) lresult;
     fd_set	*pReadmask = (fd_set *) readmask;
     int		i;
-    KdMouseInfo	*mi;
+    KdPointerInfo	*pi;
     
     if (kdInputEnabled && result > 0)
     {
@@ -1543,15 +2191,15 @@ KdWakeupHandler (int		screen, 
 		KdUnblockSigio ();
 	    }
     }
-    for (mi = kdMouseInfo; mi; mi = mi->next)
+    for (pi = kdPointers; pi; pi = pi->next)
     {
-	if (mi->timeoutPending)
+	if (pi->timeoutPending)
 	{
-	    if ((long) (GetTimeInMillis () - mi->emulationTimeout) >= 0)
+	    if ((long) (GetTimeInMillis () - pi->emulationTimeout) >= 0)
 	    {
-		mi->timeoutPending = FALSE;
+		pi->timeoutPending = FALSE;
 		KdBlockSigio ();
-		KdReceiveTimeout (mi);
+		KdReceiveTimeout (pi);
 		KdUnblockSigio ();
 	    }
 	}
@@ -1686,3 +2334,156 @@ ProcessInputEvents ()
 	KdProcessSwitch ();
     KdCheckLock ();
 }
+
+/* We don't want to allow people to change the core devices, because the DIX
+ * does magical repeating goodness for us. */
+int
+ChangeKeyboardDevice(DeviceIntPtr pOldDev, DeviceIntPtr pDev)
+{
+    return BadDevice;
+}
+
+int
+ChangePointerDevice(DeviceIntPtr pOldDev, DeviceIntPtr pDev, int x, int y)
+{
+    return BadDevice;
+}
+
+/* FIXME use XSECURITY to work out whether the client should be allowed to
+ * open and close. */
+void
+OpenInputDevice(DeviceIntPtr pDev, ClientPtr client, int *status)
+{
+    if (!pDev)
+        *status = BadDevice;
+    else
+        *status = Success;
+}
+
+int
+CloseInputDevice(DeviceIntPtr pDev, ClientPtr client)
+{
+    if (!pDev)
+        return BadDevice;
+
+    return Success;
+}
+
+/* We initialise all input devices at startup. */
+int
+AddOtherInputDevices(void)
+{
+    return Success;
+}
+
+/* At the moment, absolute/relative is up to the client. */
+int
+SetDeviceMode(register ClientPtr client, DeviceIntPtr pDev, int mode)
+{
+    return BadMatch;
+}
+
+int
+SetDeviceValuators(register ClientPtr client, DeviceIntPtr pDev,
+                   int *valuators, int first_valuator, int num_valuators)
+{
+    return BadMatch;
+}
+
+int
+ChangeDeviceControl(register ClientPtr client, DeviceIntPtr pDev,
+                        xDeviceCtl *control)
+{
+    switch (control->control) {
+    case DEVICE_RESOLUTION:
+        /* FIXME do something more intelligent here */
+        return BadMatch;
+
+    case DEVICE_TOUCHSCREEN:
+        if (!pDev->touchscreen)
+            return BadDevice;
+        else
+            return Success;
+
+    case DEVICE_CORE:
+        return Success;
+
+    default:
+        return BadMatch;
+    }
+
+    /* NOTREACHED */
+    return BadImplementation;
+}
+
+int
+NewInputDeviceRequest(InputOption *options)
+{
+    InputOption *option = NULL;
+    KdPointerInfo *pi = NULL;
+    KdKeyboardInfo *ki = NULL;
+
+    ErrorF("handling NIDR\n");
+
+    for (option = options; option; option = option->next) {
+        if (strcmp(option->key, "type") == 0) {
+            if (strcmp(option->value, "pointer") == 0) {
+                pi = KdNewPointer();
+                if (!pi)
+                    return BadAlloc;
+                pi->options = options;
+            }
+            else if (strcmp(option->value, "keyboard") == 0) {
+                ki = KdNewKeyboard();
+                if (!ki)
+                    return BadAlloc;
+                ki->options = options;
+            }
+            else {
+                ErrorF("unrecognised device type!\n");
+                return BadValue;
+            }
+        }
+    }
+
+    for (option = options; option; option = option->next) {
+        ErrorF("option '%s': '%s'\n", option->key, option->value);
+        if (strcmp(option->key, "driver") == 0) {
+            if (pi) {
+                pi->driver = KdFindPointerDriver(option->value);
+                if (!pi->driver) {
+                    ErrorF("couldn't find driver!\n");
+                    KdFreePointer(pi);
+                    return BadValue;
+                }
+            }
+            else if (ki) {
+                ki->driver = KdFindKeyboardDriver(option->value);
+                if (!ki->driver) {
+                    ErrorF("couldn't find driver!\n");
+                    KdFreeKeyboard(ki);
+                    return BadValue;
+                }
+            }
+        }
+    }
+
+    if (pi) {
+        if (KdAddPointer(pi) != Success ||
+            ActivateDevice(pi->dixdev) != Success ||
+            EnableDevice(pi->dixdev) != TRUE) {
+            ErrorF("couldn't add or enable pointer\n");
+            return BadImplementation;
+        }
+    }
+    else if (ki) {
+        if (KdAddKeyboard(ki) != Success ||
+            ActivateDevice(ki->dixdev) != Success ||
+            EnableDevice(ki->dixdev) != TRUE) {
+            ErrorF("couldn't add or enable keyboard\n");
+            return BadImplementation;
+        }
+    }
+
+    ErrorF("done handling NIDR\n");
+}
diff --git a/hw/kdrive/src/kkeymap.c b/hw/kdrive/src/kkeymap.c
index 66383e7..ce4596f 100644
--- a/hw/kdrive/src/kkeymap.c
+++ b/hw/kdrive/src/kkeymap.c
@@ -28,14 +28,13 @@
 #endif
 #include "kdrive.h"
 #include <X11/keysym.h>
-#include "kkeymap.h"
 
 /*
  * Map scan codes (both regular and synthesized from extended keys)
  * to X keysyms
  */
 
-KeySym kdKeymap[(MAX_SCANCODE - MIN_SCANCODE + 1) * MAX_WIDTH] = {
+const KeySym kdDefaultKeymap[KD_MAX_LENGTH * KD_MAX_WIDTH] = {
 /* These are directly mapped from DOS scanset 0 */
 /*      1     8 */	 XK_Escape, NoSymbol,
 /*      2     9 */	 XK_1,	XK_exclam,
@@ -152,58 +151,13 @@ KeySym kdKeymap[(MAX_SCANCODE - MIN_SCAN
 /*    110   117 */	 NoSymbol,	NoSymbol,
 /*    111   118 */	 NoSymbol,	NoSymbol,
 /*    112   119 */	 NoSymbol,	NoSymbol,
-;
-
-/*
- * Map extended keys to additional scancodes
- */
-KdExtendMap kdExtendMap[] = {
-    0x1d,   89,	    /* Control_R */
-    0x1c,   90,	    /* KP_Enter */
-    0x35,   91,	    /* KP_Divide */
-    0x37,   92,	    /* Sys_Req */
-    0x38,   93,	    /* Alt_R */
-    0x45,   94,	    /* Num_Lock */
-    0x47,   95,	    /* Home */
-    0x48,   96,	    /* Up */
-    0x49,   97,	    /* Page_Up */
-    0x4b,   98,	    /* Left */
-    0x4d,   99,	    /* Right */
-    0x4f,   100,    /* End */
-    0x50,   101,    /* Down */
-    0x51,   102,    /* Page_Down */
-    0x52,   103,    /* Insert */
-    0x53,   104,    /* Delete */
-    0x5b,   105,    /* Super_L (Windows_L) */
-    0x5c,   106,    /* Super_R (Windows_R) */
-    0x5d,   107,    /* Menu */
-    0x46,   69,	    /* Break (with control pressed) */
 };
 
-#define NUM_EXTEND   (sizeof (kdExtendMap)/ sizeof (kdExtendMap[0]))
-
-int kdNumExtend = NUM_EXTEND;
-
-/*
- * Map keys on Japanese keyboard far from zero back to reasonable values
- */
-KdExtendMap kdJapanMap[] = {
-    0x70,   108,    /* next to Alt key */
-    0x73,   109,    /* dash/vbar */
-    0x79,   110,    /* right of space bar */
-    0x7b,   111,    /* left of space bar */
-    0x7d,   112,    /* Yen */
-};
-
-#define NUM_JAPAN   (sizeof (kdJapanMap)/sizeof (kdJapanMap[0]))
-
-int kdNumJapan = NUM_JAPAN;
-
 /*
  * List of locking key codes
  */
 
-CARD8  kdLockMap[] = {
+CARD8 kdLockMap[] = {
     65,
     101,
     77,
@@ -218,7 +172,7 @@ int kdNumLock = NUM_LOCK;
  * the KEYMAP_LOCKING_ALTGR flag is set in CEKeymapFlags
  */
 
-CARD8	kdOptionalLockMap[] = {
+CARD8 kdOptionalLockMap[] = {
     100,
 };
 
@@ -226,13 +180,13 @@ CARD8	kdOptionalLockMap[] = {
 
 int kdNumOptionalLock = NUM_OPTIONAL_LOCK;
 
-CARD8	kdModMap[MAP_LENGTH];
+const CARD8 kdDefaultModMap[MAP_LENGTH];
 
-unsigned long	kdKeymapFlags = 0;
+unsigned long kdDefaultKeymapFlags = 0;
 
-KeySymsRec  kdKeySyms = {
-    kdKeymap,
-    MIN_KEYCODE,
-    MAX_KEYCODE,
-    2
+const KeySymsRec kdDefaultKeySyms = {
+    kdDefaultKeymap,
+    KD_MIN_KEYCODE,
+    KD_MAX_KEYCODE,
+    KD_MAX_WIDTH
 };
diff --git a/hw/kdrive/src/kloadmap.c b/hw/kdrive/src/kloadmap.c
index bc003d4..b62b2de 100644
--- a/hw/kdrive/src/kloadmap.c
+++ b/hw/kdrive/src/kloadmap.c
@@ -27,7 +27,6 @@
 #include <kdrive-config.h>
 #endif
 #include "kdrive.h"
-#include "kkeymap.h"
 
 #ifdef WINDOWS
 #define KM_BUF	1024
diff --git a/hw/kdrive/vesa/vesa.c b/hw/kdrive/vesa/vesa.c
index 67d2d43..766cacd 100644
--- a/hw/kdrive/vesa/vesa.c
+++ b/hw/kdrive/vesa/vesa.c
@@ -871,7 +871,7 @@ vesaComputeFramebufferMapping (KdScreenI
     VesaScreenPrivPtr	pscr = screen->driver;
     int			depth, bpp, fbbpp;
     Pixel		allbits;
-    KdMouseMatrix	m;
+    KdPointerMatrix	m;
 
     if (vesa_linear_fb)
     {
@@ -970,10 +970,10 @@ vesaComputeFramebufferMapping (KdScreenI
 	pscr->mapping = VESA_WINDOWED;
 	pscr->shadow = TRUE;
     }
-    KdComputeMouseMatrix (&m, pscr->randr, 
-			  pscr->mode.XResolution, pscr->mode.YResolution);
+    KdComputePointerMatrix (&m, pscr->randr, 
+                            pscr->mode.XResolution, pscr->mode.YResolution);
     
-    KdSetMouseMatrix (&m);
+    KdSetPointerMatrix (&m);
     
     screen->width = pscr->mode.XResolution;
     screen->height = pscr->mode.YResolution;
diff --git a/hw/kdrive/vesa/vesainit.c b/hw/kdrive/vesa/vesainit.c
index 9337157..4f552d1 100644
--- a/hw/kdrive/vesa/vesainit.c
+++ b/hw/kdrive/vesa/vesainit.c
@@ -71,7 +71,16 @@ InitOutput (ScreenInfo *pScreenInfo, int
 void
 InitInput (int argc, char **argv)
 {
-    KdInitInput(&LinuxMouseFuncs, &LinuxKeyboardFuncs);
+    KdKeyboardInfo *ki = NULL;
+        
+    KdAddPointerDriver(&LinuxMouseDriver);
+    KdAddKeyboardDriver(&LinuxKeyboardDriver);
+    ki = KdNewKeyboard();
+    if (ki) {
+        ki->driver = &LinuxKeyboardDriver;
+        KdAddKeyboard(ki);
+    }
+    KdInitInput();
 }
 
 void
diff --git a/hw/kdrive/vxworks/vxkbd.c b/hw/kdrive/vxworks/vxkbd.c
index 1c23aa9..b421e92 100644
--- a/hw/kdrive/vxworks/vxkbd.c
+++ b/hw/kdrive/vxworks/vxkbd.c
@@ -171,7 +171,7 @@ static int  kbdFd = -1;
 #include <event.h>
 #include <kbd_ioctl.h>
 
-extern KeybdCtrl    defaultKeyboardControl;
+extern KeyboardCtrl    defaultKeyboardControl;
 
 static void
 VxWorksSetAutorepeat (unsigned char *repeats, Bool on)
@@ -235,7 +235,7 @@ void
 VxWorksKeyboardLeds (int leds)
 {
     DeviceIntPtr	pKeyboard = (DeviceIntPtr) LookupKeyboardDevice ();
-    KeybdCtrl		*ctrl = &pKeyboard->kbdfeed->ctrl;
+    KeyboardCtrl		*ctrl = &pKeyboard->kbdfeed->ctrl;
     led_ioctl_info	led_info;
     int			i;
 
diff-tree a274e7296b1bdd6f6c921f28b087610cec9548e0 (from b308dbf273f8c26361b0fee7aca64aec3245f60b)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Wed Jul 19 13:56:23 2006 -0400

    add GetPointerEvents/GetKeyboardEvents framework
    
    Add GetPointerEvents (with XFree86 pointer acceleration) and GetKeyboardEvents
    to the DIX.  Extend the ValuatorClass structure to account for same.

diff --git a/dix/devices.c b/dix/devices.c
index 40afac9..37720f3 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -611,6 +611,10 @@ InitValuatorClassDeviceStruct(DeviceIntP
     valc->axisVal = (int *)(valc->axes + numAxes);
     for (i=0; i<numAxes; i++)
 	valc->axisVal[i]=0;
+    valc->lastx = 0;
+    valc->lasty = 0;
+    valc->dxremaind = 0;
+    valc->dyremaind = 0;
     dev->valuator = valc;
     return TRUE;
 }
diff --git a/dix/events.c b/dix/events.c
index 479b4d8..1b0aee5 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -157,6 +157,7 @@ xEvent *xeviexE;
 #endif
 
 #include <X11/extensions/XIproto.h>
+#include "exglobals.h"
 #include "exevents.h"
 #include "extnsionst.h"
 
@@ -164,6 +165,8 @@ xEvent *xeviexE;
 #include "dixgrabs.h"
 #include "dispatch.h"
 
+int CoreDevicePrivatesIndex = 0, CoreDevicePrivatesGeneration = -1;
+
 #define EXTENSION_EVENT_BASE  64
 
 #define NoSuchEvent 0x80000000	/* so doesn't match NoEventMask */
@@ -4660,3 +4663,401 @@ WriteEventsToClient(ClientPtr pClient, i
 	(void)WriteToClient(pClient, count * sizeof(xEvent), (char *) events);
     }
 }
+
+int
+GetKeyboardEvents(xEvent **xE, DeviceIntPtr pDev, int type, int key_code) {
+    return GetKeyboardValuatorEvents(xE, pDev, type, key_code, 0, NULL);
+}
+
+int GetKeyboardValuatorEvents(xEvent **xE, DeviceIntPtr pDev, int type,
+                              int key_code, int num_valuators,
+                              int *valuators) {
+    int numEvents = 0, ms = 0, first_valuator = 0;
+    deviceKeyButtonPointer *kbp = NULL;
+    deviceValuator *xv = NULL;
+    xEvent *ev = NULL;
+    KeyClassPtr ckeyc;
+#ifdef XKB
+    xkbNewKeyboardNotify nkn;
+#endif
+
+    if (type != KeyPress && type != KeyRelease)
+        return 0;
+
+    if (!pDev->key || !pDev->focus ||
+        (pDev->coreEvents && !inputInfo.keyboard->key))
+        return 0;
+
+    if (pDev->coreEvents)
+        numEvents = 2;
+    else
+        numEvents = 1;
+
+    if (num_valuators)
+        numEvents += (num_valuators % 6) + 1;
+
+    ev = (xEvent *)xcalloc(sizeof(xEvent), numEvents);
+    if (!ev)
+        return 0;
+
+    *xE = ev;
+    ms = GetTimeInMillis();
+
+    kbp = (deviceKeyButtonPointer *) ev;
+    kbp->time = ms;
+    kbp->deviceid = pDev->id;
+    if (type == KeyPress)
+        kbp->type = DeviceKeyPress;
+    else if (type == KeyRelease)
+        kbp->type = DeviceKeyRelease;
+
+    if (num_valuators) {
+        kbp->deviceid |= MORE_EVENTS;
+        while (first_valuator < num_valuators) {
+            xv = (deviceValuator *) ++ev;
+            xv->type = DeviceValuator;
+            xv->first_valuator = first_valuator;
+            xv->num_valuators = num_valuators;
+            xv->deviceid = kbp->deviceid;
+            switch (num_valuators - first_valuator) {
+            case 6:
+                xv->valuator5 = valuators[first_valuator+5];
+            case 5:
+                xv->valuator4 = valuators[first_valuator+4];
+            case 4:
+                xv->valuator3 = valuators[first_valuator+3];
+            case 3:
+                xv->valuator2 = valuators[first_valuator+2];
+            case 2:
+                xv->valuator1 = valuators[first_valuator+1];
+            case 1:
+                xv->valuator0 = valuators[first_valuator];
+            }
+            first_valuator += 6;
+        }
+#ifdef DEBUG
+        ErrorF("GKVE: DV event with %d valuators\n", xv->num_valuators);
+#endif
+    }
+
+    if (pDev->coreEvents) {
+        ev++;
+        ev->u.keyButtonPointer.time = ms;
+        ev->u.u.type = type;
+        ev->u.u.detail = key_code;
+
+        if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr !=
+            pDev) {
+            ckeyc = inputInfo.keyboard->key;
+            memcpy(ckeyc->modifierMap, pDev->key->modifierMap, MAP_LENGTH);
+            if (ckeyc->modifierKeyMap)
+                xfree(ckeyc->modifierKeyMap);
+            ckeyc->modifierKeyMap = xalloc(8 * pDev->key->maxKeysPerModifier);
+            memcpy(ckeyc->modifierKeyMap, pDev->key->modifierKeyMap,
+                    (8 * pDev->key->maxKeysPerModifier));
+            ckeyc->maxKeysPerModifier = pDev->key->maxKeysPerModifier;
+            ckeyc->curKeySyms.map = NULL;
+            ckeyc->curKeySyms.mapWidth = 0;
+            ckeyc->curKeySyms.minKeyCode = pDev->key->curKeySyms.minKeyCode;
+            ckeyc->curKeySyms.maxKeyCode = pDev->key->curKeySyms.maxKeyCode;
+            SetKeySymsMap(&ckeyc->curKeySyms, &pDev->key->curKeySyms);
+#ifdef XKB
+            if (!noXkbExtension) {
+                nkn.oldMinKeyCode = ckeyc->xkbInfo->desc->min_key_code;
+                nkn.oldMaxKeyCode = ckeyc->xkbInfo->desc->max_key_code;
+                nkn.deviceID = nkn.oldDeviceID = inputInfo.keyboard->id;
+                nkn.minKeyCode = pDev->key->xkbInfo->desc->min_key_code;
+                nkn.maxKeyCode = pDev->key->xkbInfo->desc->max_key_code;
+                nkn.requestMajor = XkbReqCode;
+                nkn.requestMinor = X_kbSetMap; /* XXX bare-faced lie */
+                nkn.changed = XkbAllNewKeyboardEventsMask;
+                /* Free the map we set up at DEVICE_INIT time, since it's
+                 * going to just quietly disappear.  Shameful hack. */
+                if (!inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr
+                    && ckeyc->xkbInfo)
+                    XkbFreeInfo(ckeyc->xkbInfo);
+                ckeyc->xkbInfo = pDev->key->xkbInfo;
+                /* FIXME OH MY GOD SO AWFUL let's hope nobody notices */
+                if (nkn.oldMinKeyCode == nkn.minKeyCode)
+                    nkn.oldMinKeyCode--;
+                if (nkn.oldMaxKeyCode == nkn.maxKeyCode)
+                    nkn.oldMaxKeyCode++;
+                XkbSendNewKeyboardNotify(inputInfo.keyboard, &nkn);
+            }
+#endif
+            SendMappingNotify(MappingKeyboard, ckeyc->curKeySyms.minKeyCode,
+                              (ckeyc->curKeySyms.maxKeyCode -
+                               ckeyc->curKeySyms.minKeyCode),
+                              serverClient);
+            inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
+        }
+    }
+
+#ifdef DEBUG
+    ErrorF("GKE: putting out %d events with detail %d\n", numEvents, key_code);
+#endif
+
+    return numEvents;
+}
+
+/* Originally a part of xf86PostMotionEvent. */
+static void
+acceleratePointer(DeviceIntPtr pDev, int num_valuators, int *valuators)
+{
+    float mult = 0.0;
+    int dx = num_valuators >= 1 ? valuators[0] : 0;
+    int dy = num_valuators >= 2 ? valuators[1] : 0;
+
+    if (!num_valuators || !valuators)
+        return;
+
+    /*
+     * Accelerate
+     */
+    if (pDev->ptrfeed && pDev->ptrfeed->ctrl.num) {
+        /* modeled from xf86Events.c */
+        if (pDev->ptrfeed->ctrl.threshold) {
+            if ((abs(dx) + abs(dy)) >= pDev->ptrfeed->ctrl.threshold) {
+                pDev->valuator->dxremaind = ((float)dx *
+                                             (float)(pDev->ptrfeed->ctrl.num)) /
+                                             (float)(pDev->ptrfeed->ctrl.den) +
+                                            pDev->valuator->dxremaind;
+                valuators[0] = (int)pDev->valuator->dxremaind;
+                pDev->valuator->dxremaind = pDev->valuator->dxremaind -
+                                            (float)valuators[0];
+
+                pDev->valuator->dyremaind = ((float)dy *
+                                             (float)(pDev->ptrfeed->ctrl.num)) /
+                                             (float)(pDev->ptrfeed->ctrl.den) +
+                                            pDev->valuator->dyremaind;
+                valuators[1] = (int)pDev->valuator->dyremaind;
+                pDev->valuator->dyremaind = pDev->valuator->dyremaind -
+                                            (float)valuators[1];
+            }
+        }
+        else if (dx || dy) {
+            mult = pow((float)(dx * dx + dy * dy),
+                       ((float)(pDev->ptrfeed->ctrl.num) /
+                        (float)(pDev->ptrfeed->ctrl.den) - 1.0) /
+                       2.0) / 2.0;
+            if (dx) {
+                pDev->valuator->dxremaind = mult * (float)dx +
+                                            pDev->valuator->dxremaind;
+                valuators[0] = (int)pDev->valuator->dxremaind;
+                pDev->valuator->dxremaind = pDev->valuator->dxremaind -
+                                            (float)valuators[0];
+            }
+            if (dy) {
+                pDev->valuator->dyremaind = mult * (float)dy +
+                                            pDev->valuator->dyremaind;
+                valuators[1] = (int)pDev->valuator->dyremaind;
+                pDev->valuator->dyremaind = pDev->valuator->dyremaind -
+                                            (float)valuators[1];
+            }
+        }
+    }
+}
+
+int
+GetPointerEvents(xEvent **xE, DeviceIntPtr pDev, int type, int buttons,
+                 int flags, int num_valuators, int *valuators) {
+    int numEvents, ms, first_valuator = 0;
+    deviceKeyButtonPointer *kbp = NULL;
+    deviceValuator *xv = NULL;
+    AxisInfoPtr axes = NULL;
+    xEvent *ev = NULL;
+    DeviceIntPtr cp = inputInfo.pointer;
+
+    if (type != MotionNotify && type != ButtonPress && type != ButtonRelease)
+        return 0;
+
+    if (!pDev->button || (pDev->coreEvents && !(cp->button || !cp->valuator)))
+        return 0;
+
+#ifdef DEBUG
+    ErrorF("GPE: called with device %d, type %d\n", pDev->id, type);
+    ErrorF("GPE: relative %s, accelerate %s\n", flags & POINTER_RELATIVE ? "yes" : "no",
+           flags & POINTER_ACCELERATE ? "yes" : "no");
+#endif
+
+    if (pDev->coreEvents)
+        numEvents = 2;
+    else
+        numEvents = 1;
+
+    if (type == MotionNotify) {
+        if (num_valuators > 2)
+            numEvents += (num_valuators / 6) + 1;
+        else if (num_valuators < 2)
+            return 0;
+    }
+
+    ev = (xEvent *)xcalloc(sizeof(xEvent), numEvents);
+    if (!ev)
+        return 0;
+
+    *xE = ev;
+    ms = GetTimeInMillis();
+
+    kbp = (deviceKeyButtonPointer *) ev;
+    kbp->time = ms;
+    kbp->deviceid = pDev->id;
+
+    if (flags & POINTER_ABSOLUTE) {
+        if (num_valuators >= 1) {
+            kbp->root_x = valuators[0];
+        }
+        else {
+            if (pDev->coreEvents)
+                kbp->root_x = cp->valuator->lastx;
+            else
+                kbp->root_x = pDev->valuator->lastx;
+        }
+        if (num_valuators >= 2) {
+            kbp->root_y = valuators[1];
+        }
+        else {
+            if (pDev->coreEvents)
+                kbp->root_x = cp->valuator->lasty;
+            else
+                kbp->root_y = pDev->valuator->lasty;
+        }
+    }
+    else {
+        if (flags & POINTER_ACCELERATE)
+            acceleratePointer(pDev, num_valuators, valuators);
+
+        if (pDev->coreEvents) {
+            if (num_valuators >= 1)
+                kbp->root_x = cp->valuator->lastx + valuators[0];
+            else
+                kbp->root_x = cp->valuator->lastx;
+            if (num_valuators >= 2)
+                kbp->root_y = cp->valuator->lasty + valuators[1];
+            else
+                kbp->root_y = cp->valuator->lasty;
+        }
+        else {
+            if (num_valuators >= 1)
+                kbp->root_x = pDev->valuator->lastx + valuators[0];
+            else
+                kbp->root_x = pDev->valuator->lastx;
+            if (num_valuators >= 2)
+                kbp->root_y = pDev->valuator->lasty + valuators[1];
+            else
+                kbp->root_y = pDev->valuator->lasty;
+        }
+    }
+
+    /* FIXME: need mipointer-like semantics to move on to different screens. */
+    axes = pDev->valuator->axes;
+    if (kbp->root_x < axes->min_value)
+        kbp->root_x = axes->min_value;
+    if (kbp->root_x > axes->max_value)
+        kbp->root_x = axes->max_value;
+    axes++;
+    if (kbp->root_y < axes->min_value)
+        kbp->root_y = axes->min_value;
+    if (kbp->root_y > axes->max_value)
+        kbp->root_y = axes->max_value;
+
+    if (pDev->coreEvents) {
+#ifdef DEBUG
+        ErrorF("warping core lastx from %d to %d\n", cp->valuator->lastx, kbp->root_x);
+        ErrorF("x value given was %d\n", valuators[0]);
+#endif
+        cp->valuator->lastx = kbp->root_x;
+#ifdef DEBUG
+        ErrorF("warping core lasty from %d to %d\n", cp->valuator->lasty, kbp->root_y);
+        ErrorF("y value given was %d\n", valuators[1]);
+#endif
+        cp->valuator->lasty = kbp->root_y;
+    }
+    pDev->valuator->lastx = kbp->root_x;
+    pDev->valuator->lasty = kbp->root_y;
+
+    if (type == MotionNotify) {
+        kbp->type = DeviceMotionNotify;
+#ifdef DEBUG
+        ErrorF("GPE: motion at %d, %d\n", kbp->root_x, kbp->root_y);
+#endif
+    }
+    else {
+        if (type == ButtonPress)
+            kbp->type = DeviceButtonPress;
+        else if (type == ButtonRelease)
+            kbp->type = DeviceButtonRelease;
+#ifdef DEBUG
+        ErrorF("GPE: detail is %d\n", buttons);
+#endif
+        kbp->detail = buttons;
+    }
+
+    /* XXX: the spec says that Device{Key,Button}{Press,Release} events
+     * for relative devices shouldn't contain valuators since only the
+     * state field will have meaning, but I don't see why. */
+    if (num_valuators > 2 && (type == MotionNotify ||
+                              flags & POINTER_ABSOLUTE)) {
+        kbp->deviceid |= MORE_EVENTS;
+        while (first_valuator < num_valuators) {
+            xv = (deviceValuator *) ++ev;
+            xv->type = DeviceValuator;
+            xv->first_valuator = first_valuator;
+            xv->num_valuators = num_valuators;
+            xv->deviceid = kbp->deviceid;
+            switch (num_valuators - first_valuator) {
+            case 6:
+                xv->valuator5 = valuators[first_valuator+5];
+            case 5:
+                xv->valuator4 = valuators[first_valuator+4];
+            case 4:
+                xv->valuator3 = valuators[first_valuator+3];
+            case 3:
+                xv->valuator2 = valuators[first_valuator+2];
+            case 2:
+                if (first_valuator == 0)
+                    xv->valuator1 = kbp->root_y;
+                else
+                    xv->valuator1 = valuators[first_valuator+1];
+            case 1:
+                if (first_valuator == 0)
+                    xv->valuator0 = kbp->root_x;
+                else
+                    xv->valuator0 = valuators[first_valuator];
+            }
+            first_valuator += 6;
+        }
+#ifdef DEBUG
+        ErrorF("GPE: DV event with %d valuators\n", xv->num_valuators);
+#endif
+    }
+
+    if (pDev->coreEvents) {
+        ev++;
+        ev->u.u.type = type;
+        ev->u.keyButtonPointer.time = ms;
+        ev->u.keyButtonPointer.rootX = kbp->root_x;
+        ev->u.keyButtonPointer.rootY = kbp->root_y;
+        cp->valuator->lastx = kbp->root_x;
+        cp->valuator->lasty = kbp->root_y;
+#ifdef DEBUG
+        ErrorF("GPE: core co-ords at %d, %d\n", kbp->root_x, kbp->root_y);
+#endif
+        if (type == ButtonPress || type == ButtonRelease) {
+#ifdef DEBUG
+            ErrorF("GPE: core detail is %d\n", buttons);
+#endif
+            /* Core buttons remapping shouldn't be transitive. */
+            ev->u.u.detail = pDev->button->map[buttons];
+        }
+        else {
+            ev->u.u.detail = 0;
+        }
+
+        if (inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr !=
+            pDev)
+            inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
+    }
+
+    return numEvents;
+}
diff --git a/include/input.h b/include/input.h
index 3e00be6..d550bbe 100644
--- a/include/input.h
+++ b/include/input.h
@@ -372,6 +372,32 @@ extern void InitInput(
     int  /*argc*/,
     char ** /*argv*/);
 
+extern int GetPointerEvents(
+    xEvent **xE,
+    DeviceIntPtr pDev,
+    int type,
+    int buttons,
+    int flags,
+    int num_axes,
+    int *valuators);
+
+extern int GetKeyboardEvents(
+    xEvent **xE,
+    DeviceIntPtr pDev,
+    int type,
+    int key_code);
+
+extern int GetKeyboardValuatorEvents(
+    xEvent **xE,
+    DeviceIntPtr pDev,
+    int type,
+    int key_code,
+    int num_axes,
+    int *valuators);
+
+extern DeviceIntPtr LookupDeviceIntRec(
+    CARD8 deviceid);
+
 /* Implemented by the DDX. */
 extern int NewInputDeviceRequest(
     InputOption *options);
diff --git a/include/inputstr.h b/include/inputstr.h
index 5c29497..8b877bc 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -64,6 +64,10 @@ SOFTWARE.
 
 #define EMASKSIZE	MAX_DEVICES
 
+#define POINTER_RELATIVE (1 << 1)
+#define POINTER_ABSOLUTE (1 << 2)
+#define POINTER_ACCELERATE (1 << 3)
+
 /* Kludge: OtherClients and InputClients must be compatible, see code */
 
 typedef struct _OtherClients {
@@ -150,6 +154,9 @@ typedef struct _ValuatorClassRec {
     unsigned short	numAxes;
     int			*axisVal;
     CARD8	 	mode;
+    int                 lastx, lasty; /* last event recorded, not posted to
+                                       * client; see dix/devices.c */
+    int                 dxremaind, dyremaind; /* for acceleration */
 } ValuatorClassRec, *ValuatorClassPtr;
 
 typedef struct _ButtonClassRec {
diff-tree b308dbf273f8c26361b0fee7aca64aec3245f60b (from c9a3d9baa81ceb940032ffe529d9eadf2d202ab2)
Author: Daniel Stone <daniel.stone at nokia.com>
Date:   Wed Jul 19 12:15:18 2006 -0400

    add DEVICE_TOUCHSCREEN and DEVICE_CORE Xi controls (DeviceIntRec ABI break)
    
    Add DEVICE_TOUCHSCREEN and DEVICE_CORE controls to the Xi code, and the
    TouchscreenClassRec and a coreEvents flag, to toggle propagation of core
    events.

diff --git a/Xi/chgdctl.c b/Xi/chgdctl.c
index d507513..ebe0865 100644
--- a/Xi/chgdctl.c
+++ b/Xi/chgdctl.c
@@ -104,6 +104,8 @@ ProcXChangeDeviceControl(ClientPtr clien
     xChangeDeviceControlReply rep;
     AxisInfoPtr a;
     CARD32 *resolution;
+    xDeviceTSCtl *ts;
+    xDeviceCoreCtl *c;
 
     REQUEST(xChangeDeviceControlReq);
     REQUEST_AT_LEAST_SIZE(xChangeDeviceControlReq);
@@ -168,6 +170,54 @@ ProcXChangeDeviceControl(ClientPtr clien
 	    return Success;
 	}
 	break;
+    case DEVICE_TOUCHSCREEN:
+        ts = (xDeviceTSCtl *)&stuff[1];
+
+        if (ts->button_threshold < 0 || ts->button_threshold > 255) {
+            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
+                              BadValue);
+            return Success;
+        }
+
+        status = ChangeDeviceControl(client, dev, (xDeviceCtl *) ts);
+
+        if (status == Success) {
+            dev->touchscreen->min_x = ts->min_x;
+            dev->touchscreen->max_x = ts->max_x;
+            dev->touchscreen->min_y = ts->min_y;
+            dev->touchscreen->max_y = ts->max_y;
+            dev->touchscreen->button_threshold = ts->button_threshold;
+        } else if (status == DeviceBusy) {
+            rep.status = DeviceBusy;
+            WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
+                               &rep);
+            return Success;
+        } else {
+            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
+                              BadMatch);
+            return Success;
+        }
+
+        break;
+    case DEVICE_CORE:
+        c = (xDeviceCoreCtl *)&stuff[1];
+
+        status = ChangeDeviceControl(client, dev, (xDeviceCtl *) c);
+
+        if (status == Success) {
+            dev->coreEvents = c->status;
+        } else if (status == DeviceBusy) {
+            rep.status = DeviceBusy;
+            WriteReplyToClient(client, sizeof(xChangeDeviceControlReply),
+                               &rep);
+            return Success;
+        } else {
+            SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0,
+                              BadMatch);
+            return Success;
+        }
+
+        break;
     default:
 	SendErrorToClient(client, IReqCode, X_ChangeDeviceControl, 0, BadValue);
 	return Success;
diff --git a/Xi/getdctl.c b/Xi/getdctl.c
index c2b69fd..66342b3 100644
--- a/Xi/getdctl.c
+++ b/Xi/getdctl.c
@@ -124,6 +124,18 @@ ProcXGetDeviceControl(ClientPtr client)
 	total_length = sizeof(xDeviceResolutionState) +
 	    (3 * sizeof(int) * dev->valuator->numAxes);
 	break;
+    case DEVICE_TOUCHSCREEN:
+        if (!dev->touchscreen) {
+            SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0,
+                              BadMatch);
+            return Success;
+        }
+
+        total_length = sizeof(xDeviceTSCtl);
+        break;
+    case DEVICE_CORE:
+        total_length = sizeof(xDeviceCoreCtl);
+        break;
     default:
 	SendErrorToClient(client, IReqCode, X_GetDeviceControl, 0, BadValue);
 	return Success;
@@ -140,6 +152,11 @@ ProcXGetDeviceControl(ClientPtr client)
     case DEVICE_RESOLUTION:
 	CopySwapDeviceResolution(client, dev->valuator, buf, total_length);
 	break;
+    case DEVICE_TOUCHSCREEN:
+        CopySwapDeviceTouchscreen(client, dev->touchscreen, buf);
+        break;
+    case DEVICE_CORE:
+        CopySwapDeviceCore(client, dev, buf);
     default:
 	break;
     }
@@ -189,6 +206,48 @@ CopySwapDeviceResolution(ClientPtr clien
     }
 }
 
+void CopySwapDeviceTouchscreen (ClientPtr client, TouchscreenClassPtr dts,
+                                char *buf)
+{
+    register char n;
+    xDeviceTSState *ts = (xDeviceTSState *) buf;
+
+    ts->control = DEVICE_TOUCHSCREEN;
+    ts->length = sizeof(ts);
+    ts->min_x = dts->min_x;
+    ts->max_x = dts->max_x;
+    ts->min_y = dts->min_y;
+    ts->max_y = dts->max_y;
+    ts->button_threshold = dts->button_threshold;
+
+    if (client->swapped) {
+        swaps(&ts->control, n);
+        swaps(&ts->length, n);
+        swapl(&ts->min_x, n);
+        swapl(&ts->max_x, n);
+        swapl(&ts->min_y, n);
+        swapl(&ts->max_y, n);
+        swapl(&ts->button_threshold, n);
+    }
+}
+
+void CopySwapDeviceCore (ClientPtr client, DeviceIntPtr dev, char *buf)
+{
+    register char n;
+    xDeviceCoreState *c = (xDeviceCoreState *) buf;
+
+    c->control = DEVICE_CORE;
+    c->length = sizeof(c);
+    c->status = dev->coreEvents;
+
+    if (client->swapped) {
+        swaps(&c->control, n);
+        swaps(&c->length, n);
+        swaps(&c->status, n);
+    }
+}
+
+
 /***********************************************************************
  *
  * This procedure writes the reply for the xGetDeviceControl function,
diff --git a/Xi/getdctl.h b/Xi/getdctl.h
index c7cfb19..1417d1b 100644
--- a/Xi/getdctl.h
+++ b/Xi/getdctl.h
@@ -42,6 +42,16 @@ void CopySwapDeviceResolution(ClientPtr 
 			      int	/* length */
     );
 
+void CopySwapDeviceTouchscreen(ClientPtr /* client */ ,
+                               TouchscreenClassPtr /* ts */ ,
+                               char * /* buf */
+    );
+
+void CopySwapDeviceCore(ClientPtr /* client */ ,
+                        DeviceIntPtr /* dev */ ,
+                        char * /* buf */
+    );
+
 void SRepXGetDeviceControl(ClientPtr /* client */ ,
 			   int /* size */ ,
 			   xGetDeviceControlReply *	/* rep */
diff --git a/Xi/stubs.c b/Xi/stubs.c
index 6b9e682..90aeddb 100644
--- a/Xi/stubs.c
+++ b/Xi/stubs.c
@@ -287,6 +287,10 @@ ChangeDeviceControl(register ClientPtr c
     switch (control->control) {
     case DEVICE_RESOLUTION:
 	return (BadMatch);
+    case DEVICE_TOUCHSCREEN:
+        return (BadMatch);
+    case DEVICE_CORE:
+        return (BadMatch);
     default:
 	return (BadMatch);
     }
diff --git a/include/inputstr.h b/include/inputstr.h
index b54e8a1..5c29497 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -177,6 +177,14 @@ typedef struct _ProximityClassRec {
     char	pad;
 } ProximityClassRec, *ProximityClassPtr;
 
+typedef struct _TouchscreenClassRec {
+    int         min_x;
+    int         max_x;
+    int         min_y;
+    int         max_y;
+    int         button_threshold;
+} TouchscreenClassRec, *TouchscreenClassPtr;
+
 typedef struct _KbdFeedbackClassRec *KbdFeedbackPtr;
 typedef struct _PtrFeedbackClassRec *PtrFeedbackPtr;
 typedef struct _IntegerFeedbackClassRec *IntegerFeedbackPtr;
@@ -250,6 +258,7 @@ typedef struct _DeviceIntRec {
 					  used to initialize, turn on, or
 					  turn off the device */
     Bool	inited;			/* TRUE if INIT returns Success */
+    Bool        coreEvents;             /* TRUE if device also sends core */
     GrabPtr	grab;			/* the grabber - used by DIX */
     struct {
 	Bool		frozen;
@@ -276,6 +285,7 @@ typedef struct _DeviceIntRec {
     ButtonClassPtr	button;
     FocusClassPtr	focus;
     ProximityClassPtr	proximity;
+    TouchscreenClassPtr touchscreen;
     KbdFeedbackPtr	kbdfeed;
     PtrFeedbackPtr	ptrfeed;
     IntegerFeedbackPtr	intfeed;
diff-tree c9a3d9baa81ceb940032ffe529d9eadf2d202ab2 (from 02a95311568e24e1055ea52c7df8cb7aa3f38ad0)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Jul 19 11:41:16 2006 -0400

    xorg DDX: implement NewInputDeviceRequest
    
    Implement NewInputDeviceRequest for Xorg, mainly written by Kristian Høgsberg.
    Move MatchInput to xf86Helper.c, as xf86LookupInputDriver.

diff --git a/hw/xfree86/common/xf86Helper.c b/hw/xfree86/common/xf86Helper.c
index ebc460f..05ac570 100644
--- a/hw/xfree86/common/xf86Helper.c
+++ b/hw/xfree86/common/xf86Helper.c
@@ -142,6 +142,19 @@ xf86DeleteInputDriver(int drvIndex)
     xf86InputDriverList[drvIndex] = NULL;
 }
 
+InputDriverPtr
+xf86LookupInputDriver(const char *name)
+{
+    int i;
+
+    for (i = 0; i < xf86NumInputDrivers; i++) {
+       if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
+           xf86NameCmp(name, xf86InputDriverList[i]->driverName) == 0)
+           return xf86InputDriverList[i];
+    }
+    return NULL;
+}
+
 _X_EXPORT void
 xf86AddModuleInfo(ModuleInfoPtr info, pointer module)
 {
diff --git a/hw/xfree86/common/xf86InPriv.h b/hw/xfree86/common/xf86InPriv.h
index a14e9e7..940e8ba 100644
--- a/hw/xfree86/common/xf86InPriv.h
+++ b/hw/xfree86/common/xf86InPriv.h
@@ -41,4 +41,7 @@ extern int xf86NumInputDrivers;
 /* xf86Xinput.c */
 void xf86ActivateDevice(InputInfoPtr pInfo);
 
+/* xf86Helper.c */
+InputDriverPtr xf86LookupInputDriver(const char *name);
+
 #endif /* _xf86InPriv_h */
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 9939184..6defa94 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -985,21 +985,6 @@ InitOutput(ScreenInfo *pScreenInfo, int 
 				 NULL);
 }
 
-
-static InputDriverPtr
-MatchInput(IDevPtr pDev)
-{
-    int i;
-
-    for (i = 0; i < xf86NumInputDrivers; i++) {
-	if (xf86InputDriverList[i] && xf86InputDriverList[i]->driverName &&
-	    xf86NameCmp(pDev->driver, xf86InputDriverList[i]->driverName) == 0)
-	    return xf86InputDriverList[i];
-    }
-    return NULL;
-}
-
-
 /*
  * InitInput --
  *      Initialize all supported input devices.
@@ -1033,7 +1018,7 @@ InitInput(argc, argv)
 	    }
 #endif
 
-	    if ((pDrv = MatchInput(pDev)) == NULL) {
+	    if ((pDrv = xf86LookupInputDriver(pDev->driver)) == NULL) {
 		xf86Msg(X_ERROR, "No Input driver matching `%s'\n", pDev->driver);
 		/* XXX For now, just continue. */
 		continue;
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index a931a5d..329dcba 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -622,6 +622,82 @@ ChangeDeviceControl (ClientPtr client, D
 }
 #endif
 
+int
+NewInputDeviceRequest (InputOption *options)
+{
+    IDevRec *idev = NULL;
+    InputDriverPtr drv = NULL;
+    InputInfoPtr pInfo = NULL;
+    InputOption *option = NULL;
+    DeviceIntPtr dev = NULL;
+    int i;
+
+    idev = xcalloc(sizeof(*idev), 1);
+    if (!idev)
+        return BadAlloc;
+
+    for (option = options; option; option = option->next) {
+        if (strcmp(option->key, "driver") == 0) {
+            if (!xf86LoadOneModule(option->value, NULL))
+                return BadName;
+            drv = xf86LookupInputDriver(option->value);
+            if (!drv) {
+                xf86Msg(X_ERROR, "No input driver matching `%s'\n",
+                        option->value);
+                return BadName;
+            }
+            idev->driver = xstrdup(option->value);
+            if (!idev->driver) {
+                xfree(idev);
+                return BadAlloc;
+            }
+        }
+        if (strcmp(option->key, "name") == 0 ||
+            strcmp(option->key, "identifier") == 0) {
+            idev->identifier = xstrdup(option->value);
+            if (!idev->identifier) {
+                xfree(idev);
+                return BadAlloc;
+            }
+        }
+    }
+
+    if (!drv->PreInit) {
+        xf86Msg(X_ERROR,
+                "Input driver `%s' has no PreInit function (ignoring)\n",
+                drv->driverName);
+        return BadImplementation;
+    }
+
+    idev->commonOptions = NULL;
+    for (option = options; option; option = option->next)
+        idev->commonOptions = xf86addNewOption(idev->commonOptions,
+                                               option->key, option->value);
+    idev->extraOptions = NULL;
+
+    pInfo = drv->PreInit(drv, idev, 0);
+
+    if (!pInfo) {
+        xf86Msg(X_ERROR, "PreInit returned NULL for \"%s\"\n", idev->identifier);
+        return BadMatch;
+    }
+    else if (!(pInfo->flags & XI86_CONFIGURED)) {
+        xf86Msg(X_ERROR, "PreInit failed for input device \"%s\"\n",
+                idev->identifier);
+        xf86DeleteInput(pInfo, 0);
+        return BadMatch;
+    }
+
+    xf86ActivateDevice(pInfo);
+
+    dev = pInfo->dev;
+    dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+    if (dev->inited && dev->startup)
+        EnableDevice(dev);
+
+    return Success;
+}
+
 /*
  * adapted from mieq.c to support extended events
  *
diff-tree 02a95311568e24e1055ea52c7df8cb7aa3f38ad0 (from 93cd53860c3aca182a0a02543c41b5d71d65926b)
Author: Daniel Stone <daniel at fooishbar.org>
Date:   Wed Jul 19 10:05:12 2006 -0400

    add basic D-BUS configuration mechanism
    
    Also move LookupDeviceIntRec into the DIX, and add InputOption type, and
    NewInputDeviceRequest prototype (DIX requests DDX to add a device).  Does not
    link without an implemented NIDR.

diff --git a/Makefile.am b/Makefile.am
index c425cc6..799815e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -59,6 +59,7 @@ SUBDIRS = \
 	$(COMPOSITE_DIR) \
 	$(GLX_DIR) \
 	exa \
+	config \
 	hw
 
 aclocaldir = $(datadir)/aclocal
diff --git a/config/Makefile.am b/config/Makefile.am
new file mode 100644
index 0000000..1cc9109
--- /dev/null
+++ b/config/Makefile.am
@@ -0,0 +1,10 @@
+AM_CFLAGS = @DIX_CFLAGS@
+
+dbusconfigdir = $(sysconfdir)/dbus-1/system.d
+dbusconfig_DATA = xorg-server.conf
+
+lib_LIBRARIES = libconfig.a
+
+libconfig_a_SOURCES = config.c
+
+EXTRA_DIST = xorg-server.conf
diff --git a/config/config.c b/config/config.c
new file mode 100644
index 0000000..b85b120
--- /dev/null
+++ b/config/config.c
@@ -0,0 +1,289 @@
+/*
+ * Copyright © 2006 Daniel Stone
+ *
+ * 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 the copyright holders and/or authors
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  The copyright holders
+ * and/or authors make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS AND/OR AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND/OR AUTHORS 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_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#ifdef HAVE_DBUS
+#define DBUS_API_SUBJECT_TO_CHANGE
+#include <dbus/dbus.h>
+#include <string.h>
+#include "opaque.h" /* for 'display': there has to be a better way */
+                    /* the above comment lies.  there is no better way. */
+#include "input.h"
+#include "config.h"
+
+#define MATCH_RULE "type='method_call',interface='org.x.config.input'"
+
+static DBusConnection *configConnection = NULL;
+static int configfd = -1;
+static char busobject[32] = { 0 };
+static char busname[64] = { 0 };
+
+void
+configDispatch()
+{
+    if (!configConnection)
+        return;
+
+    dbus_connection_read_write_dispatch(configConnection, 0);
+}
+
+static DBusHandlerResult
+configMessage(DBusConnection *connection, DBusMessage *message, void *closure)
+{
+    InputOption *option = NULL, *ret = NULL;
+    DBusMessageIter iter, subiter;
+    DBusError error;
+    char *tmp = NULL;
+    int deviceid = -1;
+    DeviceIntPtr pDev = NULL;
+
+    ErrorF("[dbus] new message!\n");
+    ErrorF("       source: %s\n", dbus_message_get_sender(message));
+    ErrorF("       destination: %s\n", dbus_message_get_destination(message));
+    ErrorF("       signature: %s\n", dbus_message_get_signature(message));
+    ErrorF("       path: %s\n", dbus_message_get_path(message));
+    ErrorF("       interface: %s\n", dbus_message_get_interface(message));
+    ErrorF("       member: %s\n", dbus_message_get_member(message));
+    ErrorF("       method call? %s\n", (dbus_message_get_type(message) ==
+                                         DBUS_MESSAGE_TYPE_METHOD_CALL) ?
+                                        "yes" : "no");
+
+    dbus_error_init(&error);
+
+    if (strcmp(dbus_message_get_interface(message),
+               "org.x.config.input") == 0) {
+        if (!dbus_message_iter_init(message, &iter)) {
+            ErrorF("failed to init iterator! this is probably bad.\n");
+            dbus_error_free(&error);
+            return DBUS_HANDLER_RESULT_NEED_MEMORY; /* ?? */
+        }
+        if (strcmp(dbus_message_get_member(message), "add") == 0) {
+            ErrorF("       we want to add a device!\n");
+            /* signature should be [ss][ss]... */
+            while (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_ARRAY) {
+                option = (InputOption *)xcalloc(sizeof(InputOption), 1);
+                if (!option) {
+                    while (ret) {
+                        option = ret;
+                        ret = ret->next;
+                        xfree(option);
+                    }
+                    dbus_error_free(&error);
+                    return DBUS_HANDLER_RESULT_NEED_MEMORY;
+                }
+
+                dbus_message_iter_recurse(&iter, &subiter);
+
+                if (dbus_message_iter_get_arg_type(&subiter) !=
+                    DBUS_TYPE_STRING) {
+                    ErrorF("couldn't get the arg type\n");
+                    xfree(option);
+                    dbus_error_free(&error);
+                    return DBUS_HANDLER_RESULT_HANDLED;
+                }
+                dbus_message_iter_get_basic(&subiter, &tmp);
+                if (!tmp) {
+                    ErrorF("couldn't get the key!\n");
+                    xfree(option);
+                    break;
+                }
+                option->key = xstrdup(tmp);
+                if (!option->key) {
+                    ErrorF("couldn't duplicate the key!\n");
+                    xfree(option);
+                    break;
+                }
+
+                if (!dbus_message_iter_has_next(&subiter)) {
+                    ErrorF("broken message: no next\n");
+                    xfree(option->key);
+                    xfree(option);
+                    dbus_error_free(&error);
+                    return DBUS_HANDLER_RESULT_HANDLED;
+                }
+                dbus_message_iter_next(&subiter);
+
+                if (dbus_message_iter_get_arg_type(&subiter) !=
+                    DBUS_TYPE_STRING) {
+                    ErrorF("couldn't get the arg type\n");
+                    xfree(option);
+                    dbus_error_free(&error);
+                    return DBUS_HANDLER_RESULT_HANDLED;
+                }
+                dbus_message_iter_get_basic(&subiter, &tmp);
+                if (!tmp) {
+                    ErrorF("couldn't get the value!\n");
+                    xfree(option->key);
+                    xfree(option);
+                    break;
+                }
+                option->value = xstrdup(tmp);
+                if (!option->value) {
+                    ErrorF("couldn't duplicate the option!\n");
+                    xfree(option->value);
+                    xfree(option);
+                    break;
+                }
+
+                option->next = ret;
+                ret = option;
+                dbus_message_iter_next(&iter);
+            }
+
+            if (NewInputDeviceRequest(ret) != Success) {
+                ErrorF("[config] NIDR failed\n");
+            }
+            dbus_error_free(&error);
+            return DBUS_HANDLER_RESULT_HANDLED;
+        }
+        else if (strcmp(dbus_message_get_member(message), "remove") == 0) {
+            ErrorF("        we want to remove a device!\n");
+            if (!dbus_message_get_args(message, &error, DBUS_TYPE_INT32,
+                                       &deviceid, DBUS_TYPE_INVALID)) {
+                ErrorF("couldn't get args: %s %s\n", error.name, error.message);
+                dbus_error_free(&error);
+                return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+            }
+            if (deviceid < 0 || !(pDev = LookupDeviceIntRec(deviceid))) {
+                ErrorF("bogus device id %d\n", deviceid);
+                dbus_error_free(&error);
+                return DBUS_HANDLER_RESULT_HANDLED;
+            }
+            ErrorF("pDev is %p\n", pDev);
+            RemoveDevice(pDev);
+            dbus_error_free(&error);
+            return DBUS_HANDLER_RESULT_HANDLED;
+        }
+    }
+
+    dbus_error_free(&error);
+
+    return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+}
+
+void
+configInitialise()
+{
+    DBusConnection *bus = NULL;
+    DBusError error;
+    DBusObjectPathVTable vtable;
+
+    configConnection = NULL;
+
+    dbus_error_init(&error);
+    bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+    if (!bus || dbus_error_is_set(&error)) {
+        ErrorF("[dbus] some kind of error occurred: %s (%s)\n", error.name,
+                error.message);
+        dbus_error_free(&error);
+        return;
+    }
+
+    if (!dbus_connection_get_unix_fd(bus, &configfd)) {
+        ErrorF("[dbus] couldn't get fd for bus\n");
+        dbus_connection_close(bus);
+        configfd = -1;
+        return;
+    }
+
+    snprintf(busname, sizeof(busname), "org.x.config.display%d", atoi(display));
+    if (!dbus_bus_request_name(bus, busname, 0, &error) ||
+        dbus_error_is_set(&error)) {
+        ErrorF("[dbus] couldn't take over org.x.config: %s (%s)\n",
+               error.name, error.message);
+        dbus_error_free(&error);
+        dbus_connection_close(bus);
+        configfd = -1;
+        return;
+    }
+
+    /* blocks until we get a reply. */
+    dbus_bus_add_match(bus, MATCH_RULE, &error);
+    if (dbus_error_is_set(&error)) {
+        ErrorF("[dbus] couldn't match X.Org rule: %s (%s)\n", error.name,
+               error.message);
+        dbus_error_free(&error);
+        dbus_bus_release_name(bus, busname, &error);
+        dbus_connection_close(bus);
+        configfd = -1;
+        return;
+    }
+
+    vtable.message_function = configMessage;
+    snprintf(busobject, sizeof(busobject), "/org/x/config/%d", atoi(display));
+    if (!dbus_connection_register_object_path(bus, busobject, &vtable, NULL)) {
+        ErrorF("[dbus] couldn't register object path\n");
+        configfd = -1;
+        dbus_bus_release_name(bus, busname, &error);
+        dbus_bus_remove_match(bus, MATCH_RULE, &error);
+        dbus_connection_close(bus);
+        configfd = -1;
+        return;
+    }
+    ErrorF("[dbus] registered object path %s\n", busobject);
+
+    ErrorF("[dbus] registered and listening\n");
+
+    dbus_error_free(&error);
+
+    configConnection = bus;
+
+    AddGeneralSocket(configfd);
+}
+
+void
+configFini()
+{
+    DBusError error;
+
+    if (configConnection) {
+        dbus_error_init(&error);
+        ErrorF("configFini being called\n");
+        dbus_bus_remove_match(configConnection, MATCH_RULE, &error);
+        dbus_bus_release_name(configConnection, busname, &error);
+        dbus_connection_close(configConnection);
+        RemoveGeneralSocket(configfd);
+        configConnection = NULL;
+        configfd = -1;
+        dbus_error_free(&error);
+    }
+}
+#else
+void
+configDispatch()
+{
+}
+
+void
+configInitialise()
+{
+}
+
+void
+configFini()
+{
+}
+#endif
diff --git a/config/xorg-server.conf b/config/xorg-server.conf
new file mode 100644
index 0000000..47a9a78
--- /dev/null
+++ b/config/xorg-server.conf
@@ -0,0 +1,13 @@
+<!DOCTYPE busconfig PUBLIC
+ "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+	<policy context="default">
+		<allow own="org.x.config.display0"/>
+		<allow send_destination="org.x.config.display0"/>
+		<allow send_interface="org.x.config.display0"/>
+		<allow own="org.x.config.display1"/>
+		<allow send_destination="org.x.config.display1"/>
+		<allow send_interface="org.x.config.display1"/>
+	</policy>
+</busconfig>
diff --git a/configure.ac b/configure.ac
index a2af599..41536f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -423,6 +423,7 @@ AC_ARG_ENABLE(dbe,            AS_HELP_ST
 AC_ARG_ENABLE(xf86bigfont,    AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big Font extension (default: enabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=yes])
 AC_ARG_ENABLE(dpms,           AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes])
 AC_ARG_ENABLE(xinput,         AS_HELP_STRING([--disable-xinput], [Build XInput Extension (default: enabled)]), [XINPUT=$enableval], [XINPUT=yes])
+AC_ARG_ENABLE(dbus,           AS_HELP_STRING([--disable-dbus], [Build D-BUS support (default: auto)]), [DBUS=$enableval], [DBUS=auto])
 
 dnl DDXes.
 AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
@@ -512,6 +513,18 @@ dnl Core modules for most extensions, et
 REQUIRED_MODULES="randrproto renderproto [fixesproto >= 4.0] damageproto xcmiscproto xextproto xproto xtrans xf86miscproto xf86vidmodeproto xf86bigfontproto [scrnsaverproto >= 1.1] bigreqsproto resourceproto fontsproto inputproto xf86dgaproto"
 REQUIRED_LIBS="xfont xau fontenc"
 
+if test "x$DBUS" = xauto; then
+       PKG_CHECK_MODULES(DBUS, dbus-1, [DBUS=yes], [DBUS=no])
+fi
+if test "x$DBUS" = xyes; then
+       PKG_CHECK_MODULES(DBUS, dbus-1)
+       AC_DEFINE(HAVE_DBUS, 1, [Have D-BUS support])
+       REQUIRED_MODULES="$REQUIRED_MODULES dbus-1"
+       REQUIRED_LIBS="$REQUIRED_LIBS dbus-1"
+fi
+CONFIG_LIB='$(top_builddir)/config/libconfig.a'
+AM_CONDITIONAL(DBUS, [test "x$DBUS" = xyes])
+
 AM_CONDITIONAL(XV, [test "x$XV" = xyes])
 if test "x$XV" = xyes; then
 	AC_DEFINE(XV, 1, [Support Xv extension])
@@ -1007,7 +1020,7 @@ if test "x$XGLX" = xyes; then
 fi
 
 # XORG_CORE_LIBS is needed even if you're not building the Xorg DDX
-XORG_CORE_LIBS="$DIX_LIB"
+XORG_CORE_LIBS="$DIX_LIB $CONFIG_LIB"
 AC_SUBST([XORG_CORE_LIBS])
 
 xorg_bus_linuxpci=no
@@ -1295,7 +1308,7 @@ AC_MSG_RESULT([$XPRINT])
 if test "x$XPRINT" = xyes; then
 	PKG_CHECK_MODULES([XPRINT], [printproto x11 xfont $XDMCP_MODULES xau])
 	XPRINT_EXTENSIONS="$XEXT_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $COMPOSITE_LIB $RANDR_LIB $XI_LIB $FIXES_LIB $DAMAGE_LIB $XI_LIB $GLX_LIBS"
-	XPRINT_LIBS="$XPRINT_LIBS $DIX_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MI_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB $OS_LIB"
+	XPRINT_LIBS="$XPRINT_LIBS $DIX_LIB $CONFIG_LIB $XKB_LIB $XKB_STUB_LIB $XPRINT_EXTENSIONS $MI_LIB $MIEXT_DAMAGE_LIB $CWRAP_LIB $OS_LIB"
 	AC_SUBST([XPRINT_CFLAGS])
 	AC_SUBST([XPRINT_LIBS])
 
@@ -1451,7 +1464,7 @@ if test "$KDRIVE" = yes; then
     KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.a'
     KDRIVE_OS_LIB='$(top_builddir)/hw/kdrive/linux/liblinux.a'
     KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.a'
-    KDRIVE_LIBS="$DIX_LIB $KDRIVE_LIB $KDRIVE_OS_LIB $KDRIVE_PURE_LIBS $KDRIVE_STUB_LIB"
+    KDRIVE_LIBS="$DIX_LIB $CONFIG_LIB $KDRIVE_LIB $KDRIVE_OS_LIB $KDRIVE_PURE_LIBS $KDRIVE_STUB_LIB"
 
     # check if we can build Xephyr
     PKG_CHECK_MODULES(XEPHYR, x11 xext xfont xau xdmcp, [xephyr="yes"], [xephyr="no"])
@@ -1630,6 +1643,7 @@ XTrap/Makefile
 mfb/Makefile
 cfb/Makefile
 cfb32/Makefile
+config/Makefile
 mi/Makefile
 miext/Makefile
 miext/damage/Makefile
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 72d4995..066b608 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -103,6 +103,7 @@ int ProcInitialConnection();
 #include "dispatch.h"
 #include "swaprep.h"
 #include "swapreq.h"
+#include "config.h"
 #ifdef PANORAMIX
 #include "panoramiX.h"
 #include "panoramiXsrv.h"
@@ -385,6 +386,9 @@ Dispatch(void)
 
 	nready = WaitForSomething(clientReady);
 
+        /* this is an enormous hack and NEEDS TO GO AWAY. */
+        configDispatch();
+
 #ifdef SMART_SCHEDULE
 	if (nready && !SmartScheduleDisable)
 	{
diff --git a/dix/main.c b/dix/main.c
index 9d66a4f..5f53989 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -101,6 +101,7 @@ Equipment Corporation.
 #include <X11/fonts/font.h>
 #include "opaque.h"
 #include "servermd.h"
+#include "config.h"
 #include "site.h"
 #include "dixfont.h"
 #include "extnsionst.h"
@@ -311,6 +312,7 @@ main(int argc, char *argv[], char *envp[
 	DPMSPowerLevel = 0;
 #endif
 	InitBlockAndWakeupHandlers();
+        configInitialise();
 	/* Perform any operating system dependent initializations you'd like */
 	OsInit();		
 	if(serverGeneration == 1)
@@ -463,6 +465,7 @@ main(int argc, char *argv[], char *envp[
 	FreeAllResources();
 #endif
 
+        configFini();
 	CloseDownDevices();
 	for (i = screenInfo.numScreens - 1; i >= 0; i--)
 	{
diff --git a/include/config.h b/include/config.h
new file mode 100644
index 0000000..0c304b1
--- /dev/null
+++ b/include/config.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright © 2006 Daniel Stone
+ *
+ * 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 the copyright holders and/or authors
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  The copyright holders
+ * and/or authors make no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS AND/OR AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND/OR AUTHORS 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.
+ */
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+void configInitialise(void);
+void configFini(void);
+void configDispatch(void);
+
+#endif /* CONFIG_H */
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 2b9f273..72a329c 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -436,4 +436,7 @@
 /* Define to 1 if modules should avoid the libcwrapper */
 #undef NO_LIBCWRAPPER
 
+/* Support D-BUS */
+#undef HAVE_DBUS
+
 #endif /* _DIX_CONFIG_H_ */
diff --git a/include/input.h b/include/input.h
index e32182d..3e00be6 100644
--- a/include/input.h
+++ b/include/input.h
@@ -163,6 +163,12 @@ extern void ResetDevicePrivateIndex(void
 extern KeybdCtrl	defaultKeyboardControl;
 extern PtrCtrl		defaultPointerControl;
 
+typedef struct _InputOption {
+    char                *key;
+    char                *value;
+    struct _InputOption *next;
+} InputOption;
+
 extern DeviceIntPtr AddInputDevice(
     DeviceProc /*deviceProc*/,
     Bool /*autoStart*/);
@@ -366,4 +372,11 @@ extern void InitInput(
     int  /*argc*/,
     char ** /*argv*/);
 
+/* Implemented by the DDX. */
+extern int NewInputDeviceRequest(
+    InputOption *options);
+
+extern DeviceIntPtr LookupDeviceIntRec(
+    CARD8 deviceid);
+
 #endif /* INPUT_H */
diff --git a/include/os.h b/include/os.h
index e16839c..d459e9e 100644
--- a/include/os.h
+++ b/include/os.h
@@ -149,6 +149,10 @@ extern void CheckConnections(void);
 
 extern void CloseDownConnection(ClientPtr /*client*/);
 
+extern void AddGeneralSocket(int /*fd*/);
+
+extern void RemoveGeneralSocket(int /*fd*/);
+
 extern void AddEnabledDevice(int /*fd*/);
 
 extern void RemoveEnabledDevice(int /*fd*/);
diff --git a/os/connection.c b/os/connection.c
index ce76566..7648a52 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -1014,16 +1014,22 @@ CloseDownConnection(ClientPtr client)
 }
 
 _X_EXPORT void
-AddEnabledDevice(int fd)
+AddGeneralSocket(int fd)
 {
-    FD_SET(fd, &EnabledDevices);
     FD_SET(fd, &AllSockets);
     if (GrabInProgress)
 	FD_SET(fd, &SavedAllSockets);
 }
 
 _X_EXPORT void
-RemoveEnabledDevice(int fd)
+AddEnabledDevice(int fd)
+{
+    FD_SET(fd, &EnabledDevices);
+    AddGeneralSocket(fd);
+}
+
+_X_EXPORT void
+RemoveGeneralSocket(int fd)
 {
     FD_CLR(fd, &EnabledDevices);
     FD_CLR(fd, &AllSockets);
@@ -1031,6 +1037,13 @@ RemoveEnabledDevice(int fd)
 	FD_CLR(fd, &SavedAllSockets);
 }
 
+_X_EXPORT void
+RemoveEnabledDevice(int fd)
+{
+    FD_CLR(fd, &EnabledDevices);
+    RemoveGeneralSocket(fd);
+}
+
 /*****************
  * OnlyListenToOneClient:
  *    Only accept requests from  one client.  Continue to handle new



More information about the xorg-commit mailing list