[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-input-mouse: Changes to 'upstream-experimental'



 configure.ac      |   35 +-
 man/mousedrv.man  |   65 +++-
 src/Makefile.am   |   14 
 src/bsd_mouse.c   |  798 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/hurd_mouse.c  |  242 ++++++++++++++++
 src/lnx_mouse.c   |  221 ++++++++++++++
 src/mouse.c       |   25 -
 src/mouse.h       |    4 
 src/mousePriv.h   |    1 
 src/pnp.c         |    6 
 src/sco_mouse.c   |  258 +++++++++++++++++
 src/sun_mouse.c   |  744 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/xf86OSmouse.h |  277 ++++++++++++++++++
 13 files changed, 2632 insertions(+), 58 deletions(-)

New commits:
commit cd476cc0932bf9440a05e460cd22dbe584585746
Author: Peter Breitenlohner <peb@mppmu.mpg.de>
Date:   Wed Nov 19 22:23:34 2008 +0100

    Fix linux build
    
    HAVE_XORG_CONFIG_H is a leftover from the server sources (where this file used
    to reside).
    
    Signed-off-by: Peter Hutterer <peter.hutterer@redhat.com>

diff --git a/src/lnx_mouse.c b/src/lnx_mouse.c
index d282215..c317f5d 100644
--- a/src/lnx_mouse.c
+++ b/src/lnx_mouse.c
@@ -3,8 +3,8 @@
  * Copyright 1999 by The XFree86 Project, Inc.
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
 #endif
 
 #include <X11/X.h>

commit 003c297d2902092074ede131db0dbc08d9116a5b
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Mon Dec 1 14:36:06 2008 -0800

    sun_mouse: check for Device in commonOptions if pInfo->options isn't set yet

diff --git a/src/sun_mouse.c b/src/sun_mouse.c
index 13ce074..827af34 100644
--- a/src/sun_mouse.c
+++ b/src/sun_mouse.c
@@ -622,6 +622,10 @@ solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol,
     if (*device == NULL) {
 	/* Check to see if xorg.conf or HAL specified a device to use */
 	*device = xf86CheckStrOption(pInfo->options, "Device", NULL);
+	if (*device == NULL) {
+	    *device = xf86CheckStrOption(pInfo->conf_idev->commonOptions,
+					 "Device", NULL);
+	}
     }
 
     if (*device != NULL) {

commit 1e23b944aae3ef50cc764e6d2f0198deabe790ad
Author: Matthieu Herrb <matthieu.herrb@laas.fr>
Date:   Sat Nov 22 17:36:14 2008 +0100

    W axis support for bsd_mouse.

diff --git a/src/bsd_mouse.c b/src/bsd_mouse.c
index ede7612..83054eb 100644
--- a/src/bsd_mouse.c
+++ b/src/bsd_mouse.c
@@ -429,6 +429,11 @@ wsconsReadInput(InputInfoPtr pInfo)
 	    dz = event->value;
 	    break;
 #endif
+#ifdef WSCONS_EVENT_MOUSE_DELTA_W
+	case WSCONS_EVENT_MOUSE_DELTA_W:
+	    dw = event->value;
+	    break;
+#endif
 	default:
 	    xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n", pInfo->name,
 		    event->type);
@@ -491,6 +496,7 @@ typedef struct _UsbMseRec {
     hid_item_t loc_x;		/* x locator item */
     hid_item_t loc_y;		/* y locator item */
     hid_item_t loc_z;		/* z (wheel) locator item */
+    hid_item_t loc_w;		/* z (wheel) locator item */
     hid_item_t loc_btn[MSE_MAXBUTTONS]; /* buttons locator items */
    unsigned char *buffer;
 } UsbMseRec, *UsbMsePtr;
@@ -610,6 +616,7 @@ usbReadInput(InputInfoPtr pInfo)
     dx = hid_get_data(pBuf, &pUsbMse->loc_x);
     dy = hid_get_data(pBuf, &pUsbMse->loc_y);
     dz = hid_get_data(pBuf, &pUsbMse->loc_z);
+    dw = hid_get_data(pBuf, &pUsbMse->loc_w);
 
     buttons = 0;
     for (n = 0; n < pMse->buttons; n++) {

commit e7e3cd9bed2bfeb848d62062d0859aa813bf786d
Author: Matthieu Herrb <matthieu@deville.herrb.net>
Date:   Fri Nov 21 19:59:22 2008 +0100

    prevent a double free of mouse private structure.
    
    Mark pInfo->private as NULL after freeing it on the error path.

diff --git a/src/bsd_mouse.c b/src/bsd_mouse.c
index 886a6ff..ede7612 100644
--- a/src/bsd_mouse.c
+++ b/src/bsd_mouse.c
@@ -464,6 +464,7 @@ wsconsPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
 	else {
 	    xf86Msg(X_ERROR, "%s: cannot open input device\n", pInfo->name);
 	    xfree(pMse);
+	    pInfo->private = NULL;
 	    return FALSE;
 	}
     }

commit c98bc45557174f771b031d4a003b54d06b857785
Author: Matthieu Herrb <matthieu@deville.herrb.net>
Date:   Fri Nov 21 16:14:01 2008 +0100

    Include xorg-server.h to get the WSCONS_SUPPORT define from
    xerver SDK configuration.

diff --git a/src/bsd_mouse.c b/src/bsd_mouse.c
index 1b9d8a0..886a6ff 100644
--- a/src/bsd_mouse.c
+++ b/src/bsd_mouse.c
@@ -26,9 +26,7 @@
  * authorization from the copyright holder(s) and author(s).
  */
 
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
+#include <xorg-server.h>
 
 #include <X11/X.h>
 #include "xf86.h"

commit 87f20b0c06bc13ed603d36cca881ccf69ac0a68a
Author: Matthieu Herrb <matthieu@deville.herrb.net>
Date:   Fri Nov 21 15:42:31 2008 +0100

    Build fix: Add a prototype for FindDevice function.

diff --git a/src/bsd_mouse.c b/src/bsd_mouse.c
index ca2c1bb..1b9d8a0 100644
--- a/src/bsd_mouse.c
+++ b/src/bsd_mouse.c
@@ -70,6 +70,7 @@
 #ifdef USBMOUSE_SUPPORT
 static void usbSigioReadInput (int fd, void *closure);
 #endif
+static const char *FindDevice(InputInfoPtr, const char *, int);
 
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 /* These are for FreeBSD and DragonFly */

commit 790a78d3b3d81ea06fc1a31108a330adba8cc069
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Wed Nov 5 21:47:30 2008 -0800

    Fix solarisMouseAutoProbe to use device name & protocol specified by HAL

diff --git a/src/sun_mouse.c b/src/sun_mouse.c
index ee3ddd5..13ce074 100644
--- a/src/sun_mouse.c
+++ b/src/sun_mouse.c
@@ -617,6 +617,24 @@ solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol,
     const char **pdev, **pproto;
     int fd = -1;
     Bool found;
+    char *strmod;
+
+    if (*device == NULL) {
+	/* Check to see if xorg.conf or HAL specified a device to use */
+	*device = xf86CheckStrOption(pInfo->options, "Device", NULL);
+    }
+
+    if (*device != NULL) {
+	strmod = xf86CheckStrOption(pInfo->options, "StreamsModule", NULL);
+	if (strmod) {
+	    /* if a device name is already known, and a StreamsModule is
+	       specified to convert events to VUID, then we don't need to
+	       probe further */
+	    *protocol = "VUID";
+	    return TRUE;
+	}
+    }
+
 
     for (pdev = solarisMouseDevs; *pdev; pdev += 2) {
 	pproto = pdev + 1;

commit daac081f34baab7388a8c42e5a80a42cd6810d75
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Wed Nov 5 19:26:38 2008 -0800

    sun_mouse.c: Use miPointerGetScreen instead of miPointerCurrentScreen

diff --git a/src/sun_mouse.c b/src/sun_mouse.c
index d0867f1..ee3ddd5 100644
--- a/src/sun_mouse.c
+++ b/src/sun_mouse.c
@@ -397,9 +397,16 @@ vuidReadInput(InputInfoPtr pInfo)
 #endif
 #ifdef HAVE_ABSOLUTE_MOUSE_SCALING
 	else if (pVuidMse->event.id == MOUSE_TYPE_ABSOLUTE) {
+	    ScreenPtr 	ptrCurScreen;
+
 	    /* force sending absolute resolution scaling ioctl */
 	    pVuidMse->absres.height = pVuidMse->absres.width = 0;
-	    vuidMouseSendScreenSize(miPointerCurrentScreen(), pVuidMse);
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
+	    ptrCurScreen = miPointerCurrentScreen();
+#else
+	    ptrCurScreen = miPointerGetScreen(pInfo->dev);
+#endif	    
+	    vuidMouseSendScreenSize(ptrCurScreen, pVuidMse);
 	}
 #endif
 
@@ -457,6 +464,7 @@ static void vuidMouseAdjustFrame(int index, int x, int y, int flags)
       xf86AdjustFrameProc *wrappedAdjustFrame 
 	  = (xf86AdjustFrameProc *) vuidMouseGetScreenPrivate(pScreen);
       VuidMsePtr	m;
+      ScreenPtr 	ptrCurScreen;
 
       if(wrappedAdjustFrame) {
         pScrn->AdjustFrame = wrappedAdjustFrame;
@@ -464,8 +472,16 @@ static void vuidMouseAdjustFrame(int index, int x, int y, int flags)
         pScrn->AdjustFrame = vuidMouseAdjustFrame;
       }
 
-      if (miPointerCurrentScreen() == pScreen) {
-	  for (m = vuidMouseList; m != NULL ; m = m->next) {
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) == 0
+      ptrCurScreen = miPointerCurrentScreen();
+#endif
+      
+      for (m = vuidMouseList; m != NULL ; m = m->next) {
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 0
+	  ptrCurScreen = miPointerGetScreen(m->pInfo->dev);
+#endif
+	  if (ptrCurScreen == pScreen)
+	  {
 	      vuidMouseSendScreenSize(pScreen, m);
 	  }
       }

commit 431982e7c04ec076eeafd57190db4d7d901efa7c
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Wed Nov 5 19:04:32 2008 -0800

    sun_mouse.c: remove unused variables

diff --git a/src/sun_mouse.c b/src/sun_mouse.c
index 4913942..d0867f1 100644
--- a/src/sun_mouse.c
+++ b/src/sun_mouse.c
@@ -322,7 +322,6 @@ vuidReadInput(InputInfoPtr pInfo)
     unsigned int n;
     int c; 
     unsigned char *pBuf;
-    int wmask;
     int absX, absY;
     Bool absXset = FALSE, absYset = FALSE;
 
@@ -599,7 +598,7 @@ static Bool
 solarisMouseAutoProbe(InputInfoPtr pInfo, const char **protocol, 
 	const char **device)
 {
-    const char **pdev, **pproto, *dev = NULL;
+    const char **pdev, **pproto;
     int fd = -1;
     Bool found;
 

commit 7bb59519636a7e0028e6f0f63d8256a68a24792d
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Wed Nov 5 18:55:07 2008 -0800

    Remove checks for Solaris x86 versions older than Solaris 8

diff --git a/src/sun_mouse.c b/src/sun_mouse.c
index 79a06d4..4913942 100644
--- a/src/sun_mouse.c
+++ b/src/sun_mouse.c
@@ -59,9 +59,6 @@
 #include "xf86.h"
 #include "xf86_OSlib.h"
 #include "xf86OSmouse.h"
-
-#if defined(__SOL8__) || !defined(__i386)
-
 #include "xisb.h"
 #include "mipointer.h"
 #include <sys/stropts.h>
@@ -682,13 +679,6 @@ FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
     return pdev;
 }
 
-#else /* __SOL8__ || !__i386 */
-
-#undef MSE_MISC
-#define MSE_MISC 0
-
-#endif /* !__SOL8__ && __i386 */
-
 static int
 SupportedInterfaces(void)
 {
@@ -705,14 +695,13 @@ xf86OSMouseInit(int flags)
     if (!p)
 	return NULL;
     p->SupportedInterfaces = SupportedInterfaces;
-#if defined(__SOL8__) || !defined(__i386)
     p->BuiltinNames = BuiltinNames;
     p->CheckProtocol = CheckProtocol;
     p->PreInit = sunMousePreInit;
     p->DefaultProtocol = DefaultProtocol;
     p->SetupAuto = SetupAuto;
     p->FindDevice = FindDevice;
-#endif
+
     return p;
 }
 

commit 898dfc9ce731ea9515f7819a9f0583af81d7d8b2
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Wed Nov 5 18:51:04 2008 -0800

    Rename OS_SOURCES to stop automake complaints about not building program "OS"

diff --git a/src/Makefile.am b/src/Makefile.am
index 6c410db..9f42679 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,7 +30,7 @@
 
 # We have to list all the mouse drivers here, even if we don't build them, so
 # they get included in distcheck.
-OS_SOURCES = bsd_mouse.c hurd_mouse.c lnx_mouse.c sun_mouse.c
+OS_SRCS = bsd_mouse.c hurd_mouse.c lnx_mouse.c sun_mouse.c
 
 @DRIVER_NAME@_drv_la_SOURCES = \
 	mouse.c \
@@ -40,4 +40,4 @@ OS_SOURCES = bsd_mouse.c hurd_mouse.c lnx_mouse.c sun_mouse.c
 	xf86OSmouse.h \
 	@OS_MOUSE_NAME@_mouse.c
 
-EXTRA_DIST = $(OS_SOURCES)
+EXTRA_DIST = $(OS_SRCS)

commit ea5cfe804e112f320f14ad896c7802d53551d3e6
Author: Roland Scheidegger <zak@linux-x.site.my>
Date:   Sat Oct 4 16:02:08 2008 +0200

    fix compilation (upper/lower case typo)

diff --git a/src/Makefile.am b/src/Makefile.am
index 646d71a..6c410db 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -37,7 +37,7 @@ OS_SOURCES = bsd_mouse.c hurd_mouse.c lnx_mouse.c sun_mouse.c
 	mouse.h \
 	pnp.c \
 	mousePriv.h \
-	xf86OSMouse.h \
+	xf86OSmouse.h \
 	@OS_MOUSE_NAME@_mouse.c
 
 EXTRA_DIST = $(OS_SOURCES)

commit da2ab45e3ee85f164b5430a4d0c5d60cdf71a5ec
Author: Eamon Walsh <ewalsh@tycho.nsa.gov>
Date:   Tue Aug 26 22:39:27 2008 -0400

    Change screen private key to an integer variable.
    
    Prepares for a devPrivates system that will store an index.

diff --git a/src/sun_mouse.c b/src/sun_mouse.c
index c2c722a..79a06d4 100644
--- a/src/sun_mouse.c
+++ b/src/sun_mouse.c
@@ -122,11 +122,11 @@ static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse);
 static void vuidMouseAdjustFrame(int index, int x, int y, int flags);
 
 static int vuidMouseGeneration = 0;
-static DevPrivateKey vuidMouseScreenKey = &vuidMouseScreenKey;
+static int vuidMouseScreenIndex;
 #define vuidMouseGetScreenPrivate(s) ( \
-    dixLookupPrivate(&(s)->devPrivates, vuidMouseScreenKey))
+    dixLookupPrivate(&(s)->devPrivates, &vuidMouseScreenIndex))
 #define vuidMouseSetScreenPrivate(s,p) \
-    dixSetPrivate(&(s)->devPrivates, vuidMouseScreenKey, (void *) p)
+    dixSetPrivate(&(s)->devPrivates, &vuidMouseScreenIndex, (void *) p)
 #endif /* HAVE_ABSOLUTE_MOUSE_SCALING */
 
 static inline

commit d4ed78710b19a8b1c9b5349eacd44599ba075527
Author: Alan Coopersmith <alan.coopersmith@sun.com>
Date:   Tue Aug 19 15:12:52 2008 -0700

    Fix sun_mouse.c build on Solaris

diff --git a/src/sun_mouse.c b/src/sun_mouse.c
index a5955ef..c2c722a 100644
--- a/src/sun_mouse.c
+++ b/src/sun_mouse.c
@@ -55,6 +55,7 @@
 #include <xorg-config.h>
 #endif
 
+#include "xorg-server.h"
 #include "xf86.h"
 #include "xf86_OSlib.h"
 #include "xf86OSmouse.h"

commit 04730f0be48d464401796a224109adbee9cd51de
Author: Adam Jackson <ajax@redhat.com>
Date:   Tue Aug 19 15:28:48 2008 -0400

    Remove useless call to xf86AddModuleInfo

diff --git a/src/mouse.c b/src/mouse.c
index 52bd6e0..8adfba4 100644
--- a/src/mouse.c
+++ b/src/mouse.c
@@ -3777,13 +3777,8 @@ xf86MousePlug(pointer	module,
 {
     static Bool Initialised = FALSE;
 
-    if (!Initialised) {
+    if (!Initialised)
 	Initialised = TRUE;
-#ifndef REMOVE_LOADER_CHECK_MODULE_INFO
-	if (xf86LoaderCheckSymbol("xf86AddModuleInfo"))
-#endif
-	xf86AddModuleInfo(&MouseInfo, module);
-    }
 
     xf86AddInputDriver(&MOUSE, module, 0);
 

commit f3f0a5520ed7edac3867a97f5a001b91c870563e
Author: Daniel Stone <daniel@fooishbar.org>
Date:   Sun Jul 20 04:33:07 2008 +0300

    Add OS mouse sources to the driver build
    
    Copy across the OS mouse sources and add them to the driver build.  For
    convenience, the OS mouse versioning stuff was removed, but we have
    always had the same featureset in all modular builds, so that's okay.
    
    Only compile-tested, not runtime-tested.

diff --git a/configure.ac b/configure.ac
index 0f07cd0..80ab886 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,24 +44,6 @@ AC_PROG_CC
 
 AH_TOP([#include "xorg-server.h"])
 
-#AC_DEFINE(XFree86LOADER,1,[Stub define for loadable drivers])
-#
-#AC_ARG_ENABLE(XINPUT, AS_HELP_STRING([--enable-xinput],
-#              [Build XInput support (default: yes)]),
-#              [XINPUT=$enableval],[XINPUT=yes])
-#AM_CONDITIONAL(XINPUT, test "x$XINPUT" = "xyes")
-#if test "x$XINPUT" = "xyes" ; then
-#    AC_DEFINE(XINPUT,1,[Enable XInput support])
-#fi
-#
-#AC_ARG_ENABLE(XKB, AS_HELP_STRING([--enable-xkb],
-#              [Build XKB support (default: yes)]),
-#              [XKB=$enableval],[XKB=yes])
-#AM_CONDITIONAL(XKB, test "x$XKB" = "xyes")
-#if test "x$XKB" = "xyes" ; then
-#    AC_DEFINE(XKB,1,[Enable XKB support])
-#fi
-
 AC_ARG_WITH(xorg-module-dir,
             AC_HELP_STRING([--with-xorg-module-dir=DIR],
                            [Default xorg module directory [[default=$libdir/xorg/modules]]]),
@@ -86,6 +68,23 @@ AC_SUBST([CFLAGS])
 # Checks for header files.
 AC_HEADER_STDC
 
+# Work out which OS mouse driver we need to build
+case $host_os in
+  linux*)
+    OS_MOUSE_NAME=lnx
+    ;;
+  freebsd*|kfreebsd*-gnu|dragonfly*|netbsd*|openbsd*)
+    OS_MOUSE_NAME=bsd
+    ;;
+  solaris*)
+    OS_MOUSE_NAME=sun
+    ;;
+  gnu*)
+    OS_MOUSE_NAME=hurd
+    ;;
+esac
+AC_SUBST([OS_MOUSE_NAME])
+
 XORG_MANPAGE_SECTIONS
 XORG_RELEASE_VERSION
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 3c0962b..646d71a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,4 +28,16 @@
 @DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version
 @DRIVER_NAME@_drv_ladir = @inputdir@
 
-@DRIVER_NAME@_drv_la_SOURCES = @DRIVER_NAME@.c @DRIVER_NAME@.h pnp.c mousePriv.h
+# We have to list all the mouse drivers here, even if we don't build them, so
+# they get included in distcheck.
+OS_SOURCES = bsd_mouse.c hurd_mouse.c lnx_mouse.c sun_mouse.c
+
+@DRIVER_NAME@_drv_la_SOURCES = \
+	mouse.c \
+	mouse.h \
+	pnp.c \
+	mousePriv.h \
+	xf86OSMouse.h \
+	@OS_MOUSE_NAME@_mouse.c
+
+EXTRA_DIST = $(OS_SOURCES)
diff --git a/src/bsd_mouse.c b/src/bsd_mouse.c
new file mode 100644
index 0000000..ca2c1bb
--- /dev/null
+++ b/src/bsd_mouse.c
@@ -0,0 +1,791 @@
+
+/*
+ * Copyright (c) 1999-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 <X11/X.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "xisb.h"
+#include "mipointer.h"
+#ifdef WSCONS_SUPPORT
+#include <dev/wscons/wsconsio.h>
+#endif
+#ifdef USBMOUSE_SUPPORT
+#ifdef HAS_LIB_USB_HID
+#include <usbhid.h>
+#else
+#include "usb.h"
+#endif
+
+#include <dev/usb/usb.h>
+#ifdef USB_GET_REPORT_ID
+#define USB_NEW_HID
+#endif
+
+#define HUP_GENERIC_DESKTOP     0x0001
+#define HUP_BUTTON              0x0009
+
+#define HUG_X                   0x0030
+#define HUG_Y                   0x0031
+#define HUG_Z                   0x0032
+#define HUG_WHEEL               0x0038
+
+#define HID_USAGE2(p,u) (((p) << 16) | u)
+
+/* The UMS mices have middle button as number 3 */
+#define UMS_BUT(i) ((i) == 0 ? 2 : (i) == 1 ? 0 : (i) == 2 ? 1 : (i))
+#endif /* USBMOUSE_SUPPORT */
+
+#ifdef USBMOUSE_SUPPORT
+static void usbSigioReadInput (int fd, void *closure);
+#endif
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+/* These are for FreeBSD and DragonFly */
+#define DEFAULT_MOUSE_DEV		"/dev/mouse"
+#define DEFAULT_SYSMOUSE_DEV		"/dev/sysmouse"
+#define DEFAULT_PS2_DEV			"/dev/psm0"
+
+static const char *mouseDevs[] = {
+	DEFAULT_MOUSE_DEV,
+	DEFAULT_SYSMOUSE_DEV,
+	DEFAULT_PS2_DEV,
+	NULL
+};
+#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT)
+/* Only wsmouse mices are autoconfigured for now on OpenBSD */
+#define DEFAULT_WSMOUSE_DEV		"/dev/wsmouse"
+#define DEFAULT_WSMOUSE0_DEV		"/dev/wsmouse0"
+
+static const char *mouseDevs[] = {
+	DEFAULT_WSMOUSE_DEV,
+	DEFAULT_WSMOUSE0_DEV,
+	NULL
+};
+#endif
+
+static int
+SupportedInterfaces(void)
+{
+#if defined(__NetBSD__)
+    return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO;
+#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+    return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_AUTO | MSE_MISC;
+#else
+    return MSE_SERIAL | MSE_BUS | MSE_PS2 | MSE_XPS2 | MSE_AUTO;
+#endif
+}
+
+/* Names of protocols that are handled internally here. */
+static const char *internalNames[] = {
+#if defined(WSCONS_SUPPORT)
+	"WSMouse",
+#endif
+#if defined(USBMOUSE_SUPPORT)
+	"usb",
+#endif
+	NULL
+};
+
+/*
+ * Names of MSC_MISC protocols that the OS supports.  These are decoded by
+ * main "mouse" driver.
+ */
+static const char *miscNames[] = {
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+	"SysMouse",
+#endif
+	NULL
+};
+
+static const char **
+BuiltinNames(void)
+{
+    return internalNames;
+}
+
+static Bool
+CheckProtocol(const char *protocol)
+{
+    int i;
+
+    for (i = 0; internalNames[i]; i++)
+	if (xf86NameCmp(protocol, internalNames[i]) == 0)
+	    return TRUE;
+    for (i = 0; miscNames[i]; i++)
+	if (xf86NameCmp(protocol, miscNames[i]) == 0)
+	    return TRUE;
+    return FALSE;
+}
+
+static const char *
+DefaultProtocol(void)
+{
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+    return "Auto";
+#elif (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT)
+    return "WSMouse";
+#else
+    return NULL;
+#endif
+}
+
+#if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)) && defined(MOUSE_PROTO_SYSMOUSE)
+static struct {
+	int dproto;
+	const char *name;
+} devproto[] = {
+	{ MOUSE_PROTO_MS,		"Microsoft" },
+	{ MOUSE_PROTO_MSC,		"MouseSystems" },
+	{ MOUSE_PROTO_LOGI,		"Logitech" },
+	{ MOUSE_PROTO_MM,		"MMSeries" },
+	{ MOUSE_PROTO_LOGIMOUSEMAN,	"MouseMan" },
+	{ MOUSE_PROTO_BUS,		"BusMouse" },
+	{ MOUSE_PROTO_INPORT,		"BusMouse" },
+	{ MOUSE_PROTO_PS2,		"PS/2" },
+	{ MOUSE_PROTO_HITTAB,		"MMHitTab" },
+	{ MOUSE_PROTO_GLIDEPOINT,	"GlidePoint" },
+	{ MOUSE_PROTO_INTELLI,		"Intellimouse" },
+	{ MOUSE_PROTO_THINK,		"ThinkingMouse" },
+	{ MOUSE_PROTO_SYSMOUSE,		"SysMouse" }
+};
+	
+static const char *
+SetupAuto(InputInfoPtr pInfo, int *protoPara)
+{
+    int i;
+    mousehw_t hw;
+    mousemode_t mode;
+
+    if (pInfo->fd == -1)
+	return NULL;
+
+    /* set the driver operation level, if applicable */
+    i = 1;
+    ioctl(pInfo->fd, MOUSE_SETLEVEL, &i);
+    
+    /* interrogate the driver and get some intelligence on the device. */
+    hw.iftype = MOUSE_IF_UNKNOWN;
+    hw.model = MOUSE_MODEL_GENERIC;
+    ioctl(pInfo->fd, MOUSE_GETHWINFO, &hw);
+    xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: hw.iftype is %d, hw.model is %d\n",
+		pInfo->name, hw.iftype, hw.model);
+    if (ioctl(pInfo->fd, MOUSE_GETMODE, &mode) == 0) {
+	for (i = 0; i < sizeof(devproto)/sizeof(devproto[0]); ++i) {
+	    if (mode.protocol == devproto[i].dproto) {
+		/* override some parameters */
+		if (protoPara) {
+		    protoPara[4] = mode.packetsize;
+		    protoPara[0] = mode.syncmask[0];
+		    protoPara[1] = mode.syncmask[1];
+		}
+		xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n",
+			    pInfo->name, devproto[i].name);
+		return devproto[i].name;
+	    }
+	}
+    }
+    return NULL;
+}
+
+static void
+SetSysMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res)
+{
+    mousemode_t mode;
+    MouseDevPtr pMse;
+
+    pMse = pInfo->private;
+
+    mode.rate = rate > 0 ? rate : -1;
+    mode.resolution = res > 0 ? res : -1;
+    mode.accelfactor = -1;
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+    if (pMse->autoProbe ||
+	(protocol && xf86NameCmp(protocol, "SysMouse") == 0)) {
+	/*
+	 * As the FreeBSD sysmouse driver defaults to protocol level 0
+	 * everytime it is opened we enforce protocol level 1 again at
+	 * this point.
+	 */
+	mode.level = 1;
+    } else
+	mode.level = -1;
+#else
+    mode.level = -1;
+#endif
+    ioctl(pInfo->fd, MOUSE_SETMODE, &mode);
+}
+#endif
+
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+
+#define MOUSED_PID_FILE "/var/run/moused.pid"
+
+/*
+ * Try to check if moused is running.  DEFAULT_SYSMOUSE_DEV is useless without
+ * it.  There doesn't seem to be a better way of checking.
+ */
+static Bool
+MousedRunning(void)
+{
+    FILE *f = NULL;
+    unsigned int pid;
+
+    if ((f = fopen(MOUSED_PID_FILE, "r")) != NULL) {
+	if (fscanf(f, "%u", &pid) == 1 && pid > 0) {
+	    if (kill(pid, 0) == 0) {
+		fclose(f);
+		return TRUE;
+	    }
+	}
+	fclose(f);
+    }
+    return FALSE;
+}
+
+static const char *
+FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+    int fd = -1;
+    const char **pdev, *dev = NULL;
+    Bool devMouse = FALSE;
+    struct stat devMouseStat;
+    struct stat sb;
+
+    for (pdev = mouseDevs; *pdev; pdev++) {
+	SYSCALL (fd = open(*pdev, O_RDWR | O_NONBLOCK));
+	if (fd == -1) {
+#ifdef DEBUG
+	    ErrorF("Cannot open %s (%s)\n", *pdev, strerror(errno));
+#endif
+	} else {
+	    /*
+	     * /dev/mouse is held until checks for matches with other devices
+	     * are done.  This is so that when it points to /dev/sysmouse,
+	     * the test for whether /dev/sysmouse is usable can be made.
+	     */
+	    if (!strcmp(*pdev, DEFAULT_MOUSE_DEV)) {
+		if (fstat(fd, &devMouseStat) == 0)
+		    devMouse = TRUE;
+		close(fd);
+		continue;
+	    } else if (!strcmp(*pdev, DEFAULT_SYSMOUSE_DEV)) {
+		/* Check if /dev/mouse is the same as /dev/sysmouse. */
+		if (devMouse && fstat(fd, &sb) == 0 && 
+		    devMouseStat.st_dev == sb.st_dev &&
+		    devMouseStat.st_ino == sb.st_ino) {
+		    /* If the same, use /dev/sysmouse. */
+		    devMouse = FALSE;
+		}
+		close(fd);
+		if (MousedRunning())
+		    break;
+		else {
+#ifdef DEBUG
+	    	    ErrorF("moused isn't running\n");
+#endif
+		}
+	    } else {
+		close(fd);
+		break;
+	    }
+	}
+    }
+
+    if (*pdev)
+	dev = *pdev;
+    else if (devMouse)
+	dev = DEFAULT_MOUSE_DEV;
+
+    if (dev) {
+	/* Set the Device option. */
+	pInfo->conf_idev->commonOptions =
+	    xf86AddNewOption(pInfo->conf_idev->commonOptions, "Device", dev);
+	xf86Msg(X_INFO, "%s: Setting Device option to \"%s\"\n",
+		pInfo->name, dev);
+    }
+
+    return *pdev;
+}
+#endif
+
+#if (defined(__OpenBSD__) || defined(__NetBSD__)) && defined(WSCONS_SUPPORT)
+
+/* Only support wsmouse configuration for now */
+static const char *
+SetupAuto(InputInfoPtr pInfo, int *protoPara)
+{
+
+    xf86MsgVerb(X_INFO, 3, "%s: SetupAuto: protocol is %s\n",
+		pInfo->name, "wsmouse");
+    return "wsmouse";
+}
+
+static void
+SetMouseRes(InputInfoPtr pInfo, const char *protocol, int rate, int res)
+{
+
+    xf86MsgVerb(X_INFO, 3, "%s: SetMouseRes: protocol %s rate %d res %d\n",
+	    pInfo->name, protocol, rate, res);
+}
+
+static const char *
+FindDevice(InputInfoPtr pInfo, const char *protocol, int flags)
+{
+    int fd = -1;
+    const char **pdev;
+
+    for (pdev = mouseDevs; *pdev; pdev++) {
+	SYSCALL(fd = open(*pdev, O_RDWR | O_NONBLOCK));
+	if (fd != -1) {
+	    /* Set the Device option. */
+	    pInfo->conf_idev->commonOptions =
+		xf86AddNewOption(pInfo->conf_idev->commonOptions, 
+				 "Device", *pdev);
+	    xf86Msg(X_INFO, "%s: found Device \"%s\"\n",
+		    pInfo->name, *pdev);
+	    close(fd);
+	    break;
+	}
+    }
+    return *pdev;
+}
+#endif /* __OpenBSD__ || __NetBSD__ && WSCONS_SUPPORT */
+
+#ifdef WSCONS_SUPPORT
+#define NUMEVENTS 64
+
+static void
+wsconsReadInput(InputInfoPtr pInfo)
+{
+    MouseDevPtr pMse;
+    static struct wscons_event eventList[NUMEVENTS];
+    int n, c; 
+    struct wscons_event *event = eventList;
+    unsigned char *pBuf;
+
+    pMse = pInfo->private;
+
+    XisbBlockDuration(pMse->buffer, -1);
+    pBuf = (unsigned char *)eventList;
+    n = 0;
+    while (n < sizeof(eventList) && (c = XisbRead(pMse->buffer)) >= 0) {
+	pBuf[n++] = (unsigned char)c;
+    }
+
+    if (n == 0)
+	return;
+
+    n /= sizeof(struct wscons_event);
+    while( n-- ) {
+	int buttons = pMse->lastButtons;
+	int dx = 0, dy = 0, dz = 0, dw = 0;
+	switch (event->type) {
+	case WSCONS_EVENT_MOUSE_UP:
+#define BUTBIT (1 << (event->value <= 2 ? 2 - event->value : event->value))
+	    buttons &= ~BUTBIT;
+	    break;
+	case WSCONS_EVENT_MOUSE_DOWN:
+	    buttons |= BUTBIT;
+	    break;
+	case WSCONS_EVENT_MOUSE_DELTA_X:
+	    dx = event->value;
+	    break;
+	case WSCONS_EVENT_MOUSE_DELTA_Y:
+	    dy = -event->value;
+	    break;
+#ifdef WSCONS_EVENT_MOUSE_DELTA_Z
+	case WSCONS_EVENT_MOUSE_DELTA_Z:
+	    dz = event->value;
+	    break;
+#endif
+	default:
+	    xf86Msg(X_WARNING, "%s: bad wsmouse event type=%d\n", pInfo->name,
+		    event->type);
+	    ++event;
+	    continue;
+	}
+
+	pMse->PostEvent(pInfo, buttons, dx, dy, dz, dw);
+	++event;
+    }
+    return;
+}
+
+
+/* This function is called when the protocol is "wsmouse". */
+static Bool
+wsconsPreInit(InputInfoPtr pInfo, const char *protocol, int flags)
+{


Reply to: