Enabling the extra wheel buttons in the Logitech optical mouse

Henry Hu henry.hu.sh at gmail.com
Fri Apr 23 18:49:28 UTC 2010


Today I bought a logitech optical mouse.
ugen3.3: <USB-PS/2 Optical Mouse Logitech> at usbus3, cfg=0 md=HOST
spd=LOW (1.5Mbps) pwr=ON
The wheel has two extra buttons, so you can push it left or right to
click the extra buttons.
However, the extra buttons does not work.
I inspected the device, and found that it reports extra features.
Here is the verbose output of uhidd, describing the report descriptor:

        #id=0 rid=()
        id( 0): input(5) output(0) feature(0)
        USAGE PAGE Generic Desktop(0x1)
        USAGE Mouse(0x2)[Generic Desktop(0x1)]
        COLLECTION Application(1)
          USAGE Pointer(0x1)[Generic Desktop(0x1)]
          COLLECTION Physical(0)
            USAGE PAGE Button(0x9)
            USAGE MINIMUM Button1(1)
            USAGE MAXIMUM Button8(8)
            LOGICAL MINIMUM 0
            LOGICAL MAXIMUM 1
            REPORT COUNT 8
            REPORT SIZE 1
            INPUT ( Data Variable Absolute ) (2)
            REPORT COUNT 0
            INPUT ( Const Variable Absolute ) (3)
            USAGE PAGE Generic Desktop(0x1)
            USAGE X(0x30)[Generic Desktop(0x1)]
            USAGE Y(0x31)[Generic Desktop(0x1)]
            USAGE Wheel(0x38)[Generic Desktop(0x1)]
            LOGICAL MINIMUM -127
            LOGICAL MAXIMUM 127
            REPORT SIZE 8
            REPORT COUNT 3
            INPUT ( Data Variable Relative ) (6)
            USAGE PAGE Consumer(0xc)
            USAGE AC Pan(0x238)[Consumer(0xc)]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            REPORT COUNT 1
            INPUT ( Data Variable Relative ) (6)
          END COLLECTION
        END COLLECTION

So you can see that there's extra feature, in the Conumser usage
page(0xc), named AC Pan (0x238).
When pushing the wheel left or right, it says:

/dev/ugen3.3[iface:0]=> received data(5): 00 00 00 00 01
/dev/ugen3.3[iface:0][c0:mouse]=> mouse received data: dx(0) dy(0) dw(0) btn(0)
/dev/ugen3.3[iface:0]=> received data(5): 00 00 00 00 -1
/dev/ugen3.3[iface:0][c0:mouse]=> mouse received data: dx(0) dy(0) dw(0) btn(0)

So it seems like that left results in -1, and right results 1 in the
extra feature.
Since we cannot report this axis now, I tried to translate it into buttons.

I changed ums.c and usbhid.h, and now the tile axis works as forward
and backward in firefox.
So maybe we can implement at least such tile axis as extra buttons
now? Until we have a better way to report the tile axis...
Currently the buttons are reported as button 8 and 9 in Xorg.

--- usbhid.h.orig       2010-04-23 22:49:47.000000000 +0800
+++ usbhid.h    2010-04-23 22:50:40.000000000 +0800
@@ -156,6 +156,9 @@
 #define        HUD_ERASER              0x0045
 #define        HUD_TABLET_PICK         0x0046

+/* Usages Conumsers */
+#define HUC_AC_PAN                     0x0238
+
 #define        HID_USAGE2(p,u) (((p) << 16) | (u))

 #define        UHID_INPUT_REPORT 0x01
--- /home/henryhu/ums.c 2010-04-24 02:43:42.000000000 +0800
+++ ums.c       2010-04-24 02:45:33.000000000 +0800
@@ -283,6 +283,11 @@
                if (dx || dy || dz || dt || dw ||
                    (buttons != sc->sc_status.button)) {

+                       if (dt == 1)
+                               buttons |= 1UL << 3;
+                       if (dt == -1)
+                               buttons |= 1UL << 4;
+
                        DPRINTFN(6, "x:%d y:%d z:%d t:%d w:%d buttons:0x%08x\n",
                            dx, dy, dz, dt, dw, buttons);

@@ -454,6 +459,13 @@
                if ((flags & MOUSE_FLAGS_MASK) == MOUSE_FLAGS) {
                        info->sc_flags |= UMS_FLAG_T_AXIS;
                }
+       } else if (hid_locate(buf, len, HID_USAGE2(HUP_CONSUMER,
+               HUC_AC_PAN), hid_input, index, &info->sc_loc_t,
+               &flags, &info->sc_iid_t)) {
+
+               if ((flags & MOUSE_FLAGS_MASK) == MOUSE_FLAGS) {
+                       info->sc_flags |= UMS_FLAG_T_AXIS;
+               }
        }
        /* figure out the number of buttons */


-- 
Cheers,
Henry


More information about the freebsd-usb mailing list