Make ums(4) present the mouse as a sysmouse type device by default

Laurent Sartran lsartran at no-log.org
Fri Feb 10 10:02:28 PST 2006


Hello,

I've ran into problems trying to get all the buttons of my Logitech MX 310 USB 
mouse to work on DragonFly 1.4-RELEASE with Xorg 6.9.

I had the following lines in my xorg.conf:
    Option "Protocol" "auto"
    Option "Device"   "/dev/ums0"

and these are the relevant lines of my dmesg:
    ums0: Logitech USB-PS/2 Optical Mouse, rev 2.00/18.00, addr 2, iclass 3/1
    ums0: 6 buttons and Z dir.

I could only use the first 3 buttons (left, middle and right click). The wheel, 
and 3 other buttons didn't work. xev showed that Xorg was receiving no events 
when I clicked these buttons or moved the wheel.

Indeed, hexdump /dev/ums0 revealed that the actions performed on the extra 
buttons didn't appear correctly in the mouse protocol:

Left-click:
    0000000 0083 0000 8700 0000 0000 0083 0000 8700
    0000010 0000 0000                              
    0000014

Click with button #4 (left thumb-button, which doesn't work under X):
    0000000 0087 0000 8700 0000 0000 0087 0000 8700
    0000010 0000 0000                              
    0000014

This protocol uses 5 bytes for one event (so it must be mousesystems ?), and 
pressing the button #4 looks like a button release... strange.

The solution I found is to force ums(4) to use the 8-byte SysMouse protocol, 
which is able to express the actions on the extra buttons. This is the patch to 
apply to /usr/src/sys/dev/usbmisc/ums/ums.c:

diff -uw ums.c.old ums.c
--- ums.c.old   2005-12-11 02:54:09.000000000 +0100
+++ ums.c       2006-02-10 18:33:33.000000000 +0100
@@ -323,22 +323,22 @@
        DPRINTF(("ums_attach: size=%d, id=%d\n", sc->sc_isize, sc->sc_iid));
 #endif
 
-       if (sc->nbuttons > MOUSE_MSC_MAXBUTTON)
-               sc->hw.buttons = MOUSE_MSC_MAXBUTTON;
+       if (sc->nbuttons > MOUSE_SYS_MAXBUTTON)
+               sc->hw.buttons = MOUSE_SYS_MAXBUTTON;
        else
                sc->hw.buttons = sc->nbuttons;
        sc->hw.iftype = MOUSE_IF_USB;
        sc->hw.type = MOUSE_MOUSE;
        sc->hw.model = MOUSE_MODEL_GENERIC;
        sc->hw.hwid = 0;
-       sc->mode.protocol = MOUSE_PROTO_MSC;
+       sc->mode.protocol = MOUSE_PROTO_SYSMOUSE;
        sc->mode.rate = -1;
        sc->mode.resolution = MOUSE_RES_UNKNOWN;
        sc->mode.accelfactor = 0;
-       sc->mode.level = 0;
-       sc->mode.packetsize = MOUSE_MSC_PACKETSIZE;
-       sc->mode.syncmask[0] = MOUSE_MSC_SYNCMASK;
-       sc->mode.syncmask[1] = MOUSE_MSC_SYNC;
+       sc->mode.level = 1;
+       sc->mode.packetsize = MOUSE_SYS_PACKETSIZE;
+       sc->mode.syncmask[0] = MOUSE_SYS_SYNCMASK;
+       sc->mode.syncmask[1] = MOUSE_SYS_SYNC;
 
        sc->status.flags = 0;
        sc->status.button = sc->status.obutton = 0;


Of course, xorg.conf needs to be modified to use this protocol:
    Option "Protocol" "sysmouse"
    Option "Device"   "/dev/ums0"
    
Now the wheel and the extra buttons (to go back/forward in a browser) all work,
which makes me a happy DFBSD user !
I don't know if this patch is the right way to fix the problem (IIRC, I didn't 
manage to fix it using moused), but it works for me, so it may be useful to 
someone else.

Regards,

Laurent Sartran






More information about the Submit mailing list