From owner-freebsd-usb@freebsd.org Sat Oct 3 07:40:36 2015 Return-Path: Delivered-To: freebsd-usb@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BF092A0EED2 for ; Sat, 3 Oct 2015 07:40:36 +0000 (UTC) (envelope-from btik-fbsd@scoubidou.com) Received: from smtp4-g21.free.fr (smtp4-g21.free.fr [IPv6:2a01:e0c:1:1599::13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8D650139C for ; Sat, 3 Oct 2015 07:40:36 +0000 (UTC) (envelope-from btik-fbsd@scoubidou.com) Received: from max.scoubidou.com (unknown [82.237.209.39]) by smtp4-g21.free.fr (Postfix) with ESMTP id 5AC234C8038; Sat, 3 Oct 2015 09:40:25 +0200 (CEST) Received: from zetta.scoubidou.com (unknown [192.168.1.18]) by max.scoubidou.com (Postfix) with ESMTP id 6AAA5F28F; Sat, 3 Oct 2015 09:40:24 +0200 (CEST) To: freebsd-usb@FreeBSD.org From: =?UTF-8?Q?Maxime_Soul=c3=a9?= Subject: Feedback of Tecknet X9800 & M008 USB mice integration under X X-Enigmail-Draft-Status: N1110 Message-ID: <560F8668.5000103@scoubidou.com> Date: Sat, 3 Oct 2015 09:40:24 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Oct 2015 07:40:36 -0000 Hello, Since HPS committed "dynamic USB quirks at boot", I gave you a little howto to be able to use the Tecknet X9800 & M008 USB mice under X. Before continuing we have to know the profile of each mouse. For the Tecknet X9800 mouse, the 3 side buttons generate the following events: [LeftShift] [LeftControl] [LeftAlt] For the Tecknet M008, the 5 side buttons are: [LeftAlt][LeftControl][LeftShift] [Button 9] [Button 8] So we have to intercept LeftAlt, LeftControl and LeftShift "keyboard events" to translate them in X button clicks. HOWTO: In /boot/loader.conf, add the UQ_KBD_IGNORE to both mice (need Bug 203249 patch or r288273): # X9800 mouse hw.usb.quirk.0="0x04d9 0xfa50 0 0xffff UQ_KBD_IGNORE" # M008 mouse hw.usb.quirk.1="0x04d9 0xfc05 0 0xffff UQ_KBD_IGNORE" Then configure devd to dynamically intercept keyboard events and transform them in X button clicks. Create /usr/local/etc/devd/tecknet-mice.conf : attach 1000 { device-name "uhid[0-9]+"; match "vendor" "0x04d9"; match "product" "0xf(a50|c05)"; match "intsubclass" "0x01"; match "intprotocol" "0x01"; action "DISPLAY=:0.0 /usr/bin/usbhidaction -f $device-name \ -c /usr/local/etc/tecknet-mice-usbhidaction.conf \ -p /var/run/usbhidaction.$ugen.pid"; }; notify 1000 { match "system" "USB"; match "subsystem" "DEVICE"; match "type" "DETACH"; match "vendor" "0x04d9"; match "product" "0xf(a50|c05)"; action "[ -e /var/run/usbhidaction.$ugen.pid ] \ && kill `cat /var/run/usbhidaction.$ugen.pid`"; }; Create the /usr/local/etc/tecknet-mice-usbhidaction.conf as used above by usbhidaction: Keyboard:Keyboard_LeftShift 1 0 /usr/local/bin/xdotool mousedown 6 Keyboard:Keyboard_LeftShift 0 1 /usr/local/bin/xdotool mouseup 6 Keyboard:Keyboard_LeftControl 1 0 /usr/local/bin/xdotool mousedown 7 Keyboard:Keyboard_LeftControl 0 1 /usr/local/bin/xdotool mouseup 7 Keyboard:Keyboard_LeftAlt 1 0 /usr/local/bin/xdotool mousedown 10 Keyboard:Keyboard_LeftAlt 0 1 /usr/local/bin/xdotool mouseup 10 You have to install xdotool from ports or pkg. The number at the end of each line is the button click to simulate. So the result is the following: For the Tecknet X9800 mouse, the 3 side buttons are: [Button 6] [Button 7] [Button 10] For the Tecknet M008, the 5 side buttons are: [Button 10][Button 7][Button 6] [Button 9] [Button 8] Then one can use xmodmap to remap buttons to "real" buttons in the .xsession or equivalent. In my case, to support both mice without reconfiguring manually each time I start X, my .xsession contains: # In my window manager I configured: # Button 6 = move # Button 7 = resize # Button 8 = window manager menu # Tecknet X9800 mouse, + 3 buttons (resulting 10 and 7 not used) if devinfo -v | fgrep -q 'vendor=0x04d9 product=0xfa50'; then # Btn pressed = 1 2 3 4 5 6 7 8 9 10 echo 'pointer = 1 2 3 4 5 6 8 9 10 7' | xmodmap - # [6] # [7->8] [10->7] # Tecknet M008 mouse, + 5 buttons elif devinfo -v | fgrep -q 'vendor=0x04d9 product=0xfc05'; then # Btn pressed = 1 2 3 4 5 6 7 8 9 10 echo 'pointer = 1 2 3 4 5 10 9 7 8 6' | xmodmap - # [10->6][7->9][6->10] # [9->8] [8->7] fi I hope this can help current or future Tecknet mice owners :) Best regards, Max.