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.
_______________________________________________
freebsd-usb@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"

Reply via email to