From owner-freebsd-usb@FreeBSD.ORG Fri Apr 23 18:49:28 2010 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5914B106566B for ; Fri, 23 Apr 2010 18:49:28 +0000 (UTC) (envelope-from henry.hu.sh@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 132598FC12 for ; Fri, 23 Apr 2010 18:49:27 +0000 (UTC) Received: by vws8 with SMTP id 8so2433451vws.13 for ; Fri, 23 Apr 2010 11:49:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=QjTb+juS34zP5FFNpcDgvYKNCJA2pBr3jQYu8mDJokM=; b=hT5VvfWmoLKdk1lBD5wT0xiJlM3IgAL87BjvRDmtn308QVPXc8nam+KkXtw8rgaosT MpQtuHUOO0+7nS0ITNTGqmBNwNsyGxJvPetQs+moGVVzdr9LXX5DHaMxsqrG2ECrhXOi +twnhl4j+Tfqycu63Qeg9VlCNEN01/EcqWeuY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=QvXSdRw7NsYsBgnrI65Ko8q+QosVHGmswKrV79mJsFYI3LCuiyrtFZBxKGn2W5eSuX 2K7tnZxUwbScRLwHFoh/y9foMDiAEqeKZl0lKOnZ/SPVtzmDCn+1JRMjRZ8XwldSn69a JIcXrrVKUMt/jYffwCMLjMsViTXGLdTYGphPE= Received: by 10.229.242.85 with SMTP id lh21mr525589qcb.67.1272048566385; Fri, 23 Apr 2010 11:49:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.193.15 with HTTP; Fri, 23 Apr 2010 11:49:03 -0700 (PDT) From: Henry Hu Date: Sat, 24 Apr 2010 02:49:03 +0800 Message-ID: To: freebsd-usb@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Subject: Enabling the extra wheel buttons in the Logitech optical mouse X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Apr 2010 18:49:28 -0000 Today I bought a logitech optical mouse. ugen3.3: 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