# Mouse back/forward thumb buttons in VMware?



## agrajag9 (Feb 9, 2021)

Does anybody know how to get mouse back/forward thumb buttons working in VMware Workstation 16? None of xinput, xev, nor libinput seems to think they exist.

I added the following to my vmx but it doesn't seem to have helped:


```
usb.generic.allowHID = "TRUE"
usb.generic.allowLastHID = "TRUE"
usb.generic. autoconnect = "FALSE"
```

X

`xinput list --long` (truncated to pointers only)

```
⎡ Virtual core pointer                        id=2    [master pointer  (3)]
    Reporting 7 classes:
        Class originated from: 9. Type: XIButtonClass
        Buttons supported: 12
        Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right" None None None None None
        Button state:
        Class originated from: 9. Type: XIValuatorClass
        Detail for Valuator 0:
          Label: Rel X
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 9. Type: XIValuatorClass
        Detail for Valuator 1:
          Label: Rel Y
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 9. Type: XIValuatorClass
        Detail for Valuator 2:
          Label: Rel Horiz Scroll
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 9. Type: XIValuatorClass
        Detail for Valuator 3:
          Label: Rel Vert Scroll
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 9. Type: XIScrollClass
        Scroll info for Valuator 2
          type: 2 (horizontal)
          increment: 15.000000
          flags: 0x0
        Class originated from: 9. Type: XIScrollClass
        Scroll info for Valuator 3
          type: 1 (vertical)
          increment: 15.000000
          flags: 0x0

⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
    Reporting 3 classes:
        Class originated from: 4. Type: XIButtonClass
        Buttons supported: 10
        Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right" None None None
        Button state:
        Class originated from: 4. Type: XIValuatorClass
        Detail for Valuator 0:
          Label: Rel X
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 4. Type: XIValuatorClass
        Detail for Valuator 1:
          Label: Rel Y
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative

⎜   ↳ System mouse                                id=7    [slave  pointer  (2)]
    Reporting 7 classes:
        Class originated from: 7. Type: XIButtonClass
        Buttons supported: 12
        Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right" "Button Side" "Button Extra" "Button Forward" "Button Back" None
        Button state:
        Class originated from: 7. Type: XIValuatorClass
        Detail for Valuator 0:
          Label: Rel X
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 7. Type: XIValuatorClass
        Detail for Valuator 1:
          Label: Rel Y
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 7. Type: XIValuatorClass
        Detail for Valuator 2:
          Label: Rel Horiz Scroll
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 7. Type: XIValuatorClass
        Detail for Valuator 3:
          Label: Rel Vert Scroll
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 7. Type: XIScrollClass
        Scroll info for Valuator 2
          type: 2 (horizontal)
          increment: 15.000000
          flags: 0x0
        Class originated from: 7. Type: XIScrollClass
        Scroll info for Valuator 3
          type: 1 (vertical)
          increment: 15.000000
          flags: 0x0

⎜   ↳ IntelliMouse                                id=9    [slave  pointer  (2)]
    Reporting 7 classes:
        Class originated from: 9. Type: XIButtonClass
        Buttons supported: 7
        Button labels: "Button Left" "Button Middle" "Button Right" "Button Wheel Up" "Button Wheel Down" "Button Horiz Wheel Left" "Button Horiz Wheel Right"
        Button state:
        Class originated from: 9. Type: XIValuatorClass
        Detail for Valuator 0:
          Label: Rel X
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 9. Type: XIValuatorClass
        Detail for Valuator 1:
          Label: Rel Y
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 9. Type: XIValuatorClass
        Detail for Valuator 2:
          Label: Rel Horiz Scroll
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 9. Type: XIValuatorClass
        Detail for Valuator 3:
          Label: Rel Vert Scroll
          Range: -1.000000 - -1.000000
          Resolution: 0 units/m
          Mode: relative
        Class originated from: 9. Type: XIScrollClass
        Scroll info for Valuator 2
          type: 2 (horizontal)
          increment: 15.000000
          flags: 0x0
        Class originated from: 9. Type: XIScrollClass
        Scroll info for Valuator 3
          type: 1 (vertical)
          increment: 15.000000
          flags: 0x0
```

`libinput list-devices` (truncated to pointers only)

```
Device:           System mouse
Kernel:           /dev/input/event1
Group:            2
Seat:             seat0, default
Capabilities:     pointer
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: disabled
Calibration:      n/a
Scroll methods:   button
Click methods:    none
Disable-w-typing: n/a
Accel profiles:   flat *adaptive
Rotation:         n/a

Device:           IntelliMouse
Kernel:           /dev/input/event3
Group:            4
Seat:             seat0, default
Capabilities:     pointer
Tap-to-click:     n/a
Tap-and-drag:     n/a
Tap drag lock:    n/a
Left-handed:      disabled
Nat.scrolling:    disabled
Middle emulation: disabled
Calibration:      n/a
Scroll methods:   button
Click methods:    none
Disable-w-typing: n/a
Accel profiles:   flat *adaptive
Rotation:         n/a
```

init lines from my Xorg log here: https://gist.github.com/agrajag9/f1d6a73e17e24e634f9b7d46b5d1eae9


----------



## olli@ (Feb 9, 2021)

Do you have anything mouse-related in your xorg.conf file?
I have the following to make the additional buttons work:

```
Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/sysmouse"
    Option         "Emulate3Buttons" "off"
    Option         "Buttons" "11"
    Option         "ButtonMapping" "1 2 3 8 9 6 7"
EndSection
```
To test if the buttons are working, install xev (x11/xev), run it and move the mouse pointer over the square. It will then display the “raw” events (including the button numbers) in the terminal when you press the various mouse buttons. The standard mouse buttons (left, middle, right) should be displayed as buttons 1, 2, 3, respectively. The vertical scroll wheel should be reported as buttons 4 and 5 (up and down), and if you have a “3D” scroll wheel that supports horizontal scrolling, that should be reported as buttons 6 and 7 (left and right). Finally, the buttons 8 and 9 are displayed for back and forward.
For example:

```
ButtonPress event, serial 29, synthetic NO, window 0x2400001,
    root 0x1e7, subw 0x2400002, time 21650610, (46,34), root:(141,151),
    state 0x0, button 8, same_screen YES
```
That’s the _back button_ (button 8, see the third line).


----------



## agrajag9 (Feb 10, 2021)

My xorg.conf was empty before. Adding that section though did not help - xev still doesn't report any events from the thumb buttons.


----------



## olli@ (Feb 10, 2021)

agrajag9 said:


> My xorg.conf was empty before. Adding that section though did not help - xev still doesn't report any events from the thumb buttons.


In your output from `xinput --list --long`, these buttons are listed under the “System mouse” device (id=7), so it seems they are detected correctly, it’s just a matter of assigning the buttons the correct numbers. Are you sure that your xorg.conf file is loaded when you start the X server? Did something change in your Xorg.0.log output?


----------



## agrajag9 (Feb 10, 2021)

Still doesn't work, nor are there any meaningful changes in my Xorg.0.log. I also disabled AutoAddDevices in the ServerFlags, but then I had no pointer events at all.


----------



## olli@ (Feb 11, 2021)

Ok. First, find out the device ID of your mouse: `xinput --list`
In my case I get this (keyboard devices omitted):

```
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ System mouse                              id=6    [slave  pointer  (2)]
⎜   ↳ Logitech USB Receiver, class 0/0, rev 2.00/12.07, addr 3  id=12   [slave  pointer  (2)]
```
In this case, my actual mouse device has ID 12 (the last one).
 
Now enter `xinput --test 12` (replace 12 with your ID number; it might be 9 from the output in your post above), and press the buttons on your mouse. The “back” button should be displayed as button 8, and the “foward” button should be displayed as button 9. If the numbers are different, you can change the mapping with `xinput --set-button-map 1 2 3 …`, see the xinput(1) manual page for details.
 
If nothing is displayed at all, I’m afraid that VMware might fail to forward those buttons to the guest OS.


----------



## agrajag9 (Feb 11, 2021)

Well, I confirmed with `xinput --test` that it's id=9. According to `libinput list-devices` this is `/dev/input/event3`. But there were no events for the back/forward buttons still.

For what it's worth the same VMX additions solved this in my Fedora 33 guest. And while that's Wayland not X, it does demonstrate that the buttons CAN work!

I'm wondering if maybe disabling libinput somewhere will help?


----------



## olli@ (Feb 11, 2021)

I don’t think it’s libinput, because Wayland uses libinput, too. And it works fine (with libinput) on my FreeBSD system without VMware. Therefore I assume that somehow VMware must be the culprit. But I have to admit that I’m running out of ideas …


----------



## agrajag9 (Feb 11, 2021)

So here's something. Decided to do some similar tests in Fed33 since I know it's working there. What I found is that libinput in Fedora detects the mouse correctly, but in FreeBSD incorrectly.

In Fedora:

```
# libinput debug-events
-event4   DEVICE_ADDED     VMware VMware Virtual USB Mouse   seat0 default group2  cap:p left scroll-nat calib
-event5   DEVICE_ADDED     VMware VMware Virtual USB Mouse   seat0 default group2  cap:p left scroll-nat scroll-button
event4   POINTER_MOTION_ABSOLUTE +2.418s     40.36/ 38.54
-event5   POINTER_BUTTON   +12.542s    BTN_LEFT (272) pressed, seat count: 1
event5   POINTER_BUTTON   +12.646s    BTN_LEFT (272) released, seat count: 0
event5   POINTER_BUTTON   +13.464s    BTN_RIGHT (273) pressed, seat count: 1
event5   POINTER_BUTTON   +13.584s    BTN_RIGHT (273) released, seat count: 0
event5   POINTER_BUTTON   +16.383s    BTN_MIDDLE (274) pressed, seat count: 1
event5   POINTER_BUTTON   +16.521s    BTN_MIDDLE (274) released, seat count: 0
event5   POINTER_AXIS     +19.939s    vert -15.00/-1* horiz 0.00/0 (wheel)
event5   POINTER_AXIS     +21.012s    vert 15.00/1* horiz 0.00/0 (wheel)
event5   POINTER_BUTTON   +22.345s    BTN_EXTRA (276) pressed, seat count: 1
event5   POINTER_BUTTON   +22.476s    BTN_EXTRA (276) released, seat count: 0
event5   POINTER_BUTTON   +23.133s    BTN_SIDE (275) pressed, seat count: 1
event5   POINTER_BUTTON   +23.273s    BTN_SIDE (275) released, seat count: 0
```
event4 and event5 correspond with:

```
Device:           VMware VMware Virtual USB Mouse
Kernel: /dev/input/event4
Group: 2
Seat: seat0, default
Capabilities: pointer
Tap-to-click: n/a
Tap-and-drag: n/a
Tap drag lock: n/a
Left-handed: disabled
Nat.scrolling: disabled
Middle emulation: disabled
Calibration: identity matrix
Scroll methods: none
Click methods: none
Disable-w-typing: n/a
Accel profiles: n/a
Rotation:         n/a

Device:           VMware VMware Virtual USB Mouse
Kernel: /dev/input/event5
Group: 2
Seat: seat0, default
Capabilities: pointer
Tap-to-click: n/a
Tap-and-drag: n/a
Tap drag lock: n/a
Left-handed: disabled
Nat.scrolling: disabled
Middle emulation: disabled
Calibration: n/a
Scroll methods: button
Click methods: none
Disable-w-typing: n/a
Accel profiles: flat *adaptive
Rotation:         n/a
```
But on FreeBSD:

```
# libinput debug-events
-event3   DEVICE_ADDED     IntelliMouse                      seat0 default group4  cap:p left scroll-nat scroll-button
event3 POINTER_MOTION +1.119s 0.00/ -0.30 ( +0.00/ -1.00)
event3 POINTER_BUTTON +1.968s BTN_LEFT (272) pressed, seat count: 1
event3 POINTER_BUTTON +2.034s BTN_LEFT (272) released, seat count: 0
event3 POINTER_BUTTON +2.475s BTN_RIGHT (273) pressed, seat count: 1
event3 POINTER_BUTTON +2.603s BTN_RIGHT (273) released, seat count: 0
event3 POINTER_BUTTON +4.688s BTN_MIDDLE (274) pressed, seat count: 1
event3 POINTER_BUTTON +4.758s BTN_MIDDLE (274) released, seat count: 0
event3 POINTER_AXIS +5.419s vert -15.00/-1* horiz 0.00/0 (wheel)
event3   POINTER_AXIS     +6.049s    vert 15.00/1* horiz 0.00/0 (wheel)
```
and event3 corresponds with:

```
Device:           IntelliMouse
Kernel: /dev/input/event3
Group: 4
Seat: seat0, default
Capabilities: pointer
Tap-to-click: n/a
Tap-and-drag: n/a
Tap drag lock: n/a
Left-handed: disabled
Nat.scrolling: disabled
Middle emulation: disabled
Calibration: n/a
Scroll methods: button
Click methods: none
Disable-w-typing: n/a
Accel profiles: flat *adaptive
Rotation:         n/a
```

I'm not super sure where to go from here to be honest, but maybe this will elicit something? Any idea why we're detecting it as IntelliMouse while Fedora gets it right?


----------



## olli@ (Feb 12, 2021)

Please post the output from these commands (on the FreeBSD guest OS):
`xinput --list-props 9`
and
`grep ums /var/run/dmesg.boot`
 
It might also be useful to see whether you have moused running or not.
`pgrep -fl moused`
If it is, you might try to disable it in /etc/rc.conf: `moused_enable="NO"` (then reboot).
 
Just for comparison, this is the output from above commands on my system:

```
Device 'Logitech USB Receiver, class 0/0, rev 2.00/12.07, addr 3':
        Device Enabled (154):   1
        Coordinate Transformation Matrix (155): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        Device Accel Profile (274):     0
        Device Accel Constant Deceleration (275):       1.000000
        Device Accel Adaptive Deceleration (276):       1.000000
        Device Accel Velocity Scaling (277):    10.000000
        Device Product ID (278):        1133, 50475
        Device Node (279):      "/dev/input/event6"
        Evdev Axis Inversion (280):     0, 0
        Evdev Axes Swap (282):  0
        Axis Labels (283):      "Rel X" (164), "Rel Y" (165), "Rel Horiz Wheel" (272), "Rel Vert Wheel" (273)
        Button Labels (284):    "Button Left" (157), "Button Middle" (158), "Button Right" (159), "Button Wheel Up" (160), "Button Wheel Down" (161), "Button Horiz Wheel Left" (162), "Button Horiz Wheel Right" (163), "Button Side" (267), "Button Extra" (268), "Button Forward" (269), "Button Back" (270), "Button Task" (271), "Button Unknown" (266), "Button Unknown" (266), "Button Unknown" (266), "Button Unknown" (266), "Button Unknown" (266), "Button Unknown" (266), "Button Unknown" (266), "Button Unknown" (266), "Button Unknown" (266), "Button Unknown" (266), "Button Unknown" (266), "Button Unknown" (266)
        Evdev Scrolling Distance (285): 1, 1, 1
        Evdev Middle Button Emulation (286):    0
        Evdev Middle Button Timeout (287):      50
        Evdev Middle Button Button (288):       2
        Evdev Third Button Emulation (289):     0
        Evdev Third Button Emulation Timeout (290):     1000
        Evdev Third Button Emulation Button (291):      3
        Evdev Third Button Emulation Threshold (292):   20
        Evdev Wheel Emulation (293):    0
        Evdev Wheel Emulation Axes (294):       0, 0, 4, 5
        Evdev Wheel Emulation Inertia (295):    10
        Evdev Wheel Emulation Timeout (296):    200
        Evdev Wheel Emulation Button (297):     4
        Evdev Drag Lock Buttons (298):  0
```


```
ums0 on uhub2
ums0: <Logitech USB Receiver, class 0/0, rev 2.00/12.07, addr 3> on usbus0
ums0: 16 buttons and [XYZT] coordinates ID=2
```


----------



## agrajag9 (Feb 12, 2021)

Ah! I did have moused enabled. I have since disabled it, but didn't see any significant change.


```
Device 'IntelliMouse':
Device Enabled (115): 1
Coordinate Transformation Matrix (116): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
libinput Natural Scrolling Enabled (252): 0
libinput Natural Scrolling Enabled Default (253): 0
libinput Scroll Methods Available (254): 0, 0, 1
libinput Scroll Method Enabled (255): 0, 0, 0
libinput Scroll Method Enabled Default (256): 0, 0, 0
libinput Button Scrolling Button (257): 2
libinput Button Scrolling Button Default (258): 2
libinput Button Scrolling Button Lock Enabled (259): 0
libinput Button Scrolling Button Lock Enabled Default (260): 0
libinput Middle Emulation Enabled (261): 0
libinput Middle Emulation Enabled Default (262): 0
libinput Accel Speed (263): 0.000000
libinput Accel Speed Default (264): 0.000000
libinput Accel Profiles Available (265): 1, 1
libinput Accel Profile Enabled (266): 1, 0
libinput Accel Profile Enabled Default (267): 1, 0
libinput Left Handed Enabled (268): 0
libinput Left Handed Enabled Default (269): 0
libinput Send Events Modes Available (237): 1, 0
libinput Send Events Mode Enabled (238): 0, 0
libinput Send Events Mode Enabled Default (239): 0, 0
Device Node (240): "/dev/input/event3"
Device Product ID (241): 2, 1
libinput Drag Lock Buttons (270): <no items>
    libinput Horizontal Scroll Enabled (271):    1
```

And no ums devices in dmesg either, but there is this which I find odd:

```
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: model IntelliMouse, device ID 3
ugen2.2: <VMware VMware Virtual USB Mouse> at usbus2
psm0: <PS/2 Mouse> irq 12 on atkbdc0
psm0: model IntelliMouse, device ID 3
ugen2.2: <VMware VMware Virtual USB Mouse> at usbus2
```
So VMware wants it to be a PS/2 mouse AND a USB mouse somehow?


----------



## olli@ (Feb 12, 2021)

That might explain it.
Basically, there are two pointer devices:

An emulated “IntelliMouse” on a virtual PS/2 socket. This protocol supports up to 5 buttons only, so that’s not sufficient here.
An emulated USB mouse. The USB HID protocol for mice supports an almost unlimited number of buttons.
However, apparently there is no kernel driver to attach to the USB mouse, so it is only recognized as a generic USB device.
Normally, the kernel loads drivers for any USB devices automatically. I have no idea why that mechanism doesn’t seem to work for you. Have you disabled `devmatch` in /etc/rc.conf?
 
Ok, next step: Please check if the `uhid.ko` and `ums.ko` modules are listed in the output of the `kldstat` command. I assume they are not, otherwise the ums(4) driver would attach to the USB mouse. So, please type `kldload uhid ums` to load those modules. You should then see the attachment in dmesg. To make that permanent, add `kld_list="uhid ums"` to /etc/rc.conf.
 
I’m not sure if X.org picks up the new device automatically. You might have to restart the X server.


----------



## agrajag9 (Feb 13, 2021)

Solved!

Adding `kld_list="uhid ums"` seems to have done it! I now see events from the side buttons and this from `libinput list-devices`:

```
-event0   DEVICE_ADDED     System keyboard multiplexer       seat0 default group1  cap:k
-event1   DEVICE_ADDED     System mouse                      seat0 default group2  cap:p left scroll-nat scroll-button
-event2   DEVICE_ADDED     AT keyboard                       seat0 default group3  cap:k
-event3   DEVICE_ADDED     IntelliMouse                      seat0 default group4  cap:p left scroll-nat scroll-button
-event4   DEVICE_ADDED     VMware                            seat0 default group5  cap:p left scroll-nat scroll-button
...
 event4   POINTER_BUTTON   +13.762s    BTN_LEFT (272) pressed, seat count: 1
 event4   POINTER_BUTTON   +13.846s    BTN_LEFT (272) released, seat count: 0
 event4   POINTER_BUTTON   +14.872s    BTN_MIDDLE (274) pressed, seat count: 1
 event4   POINTER_BUTTON   +15.023s    BTN_MIDDLE (274) released, seat count: 0
 event4   POINTER_BUTTON   +15.487s    BTN_RIGHT (273) pressed, seat count: 1
 event4   POINTER_BUTTON   +15.571s    BTN_RIGHT (273) released, seat count: 0
 event4   POINTER_AXIS     +16.197s    vert -15.00/-1* horiz 0.00/0 (wheel)
 event4   POINTER_AXIS     +16.846s    vert 15.00/1* horiz 0.00/0 (wheel)
 event4   POINTER_BUTTON   +18.228s    BTN_EXTRA (276) pressed, seat count: 1
 event4   POINTER_BUTTON   +18.379s    BTN_EXTRA (276) released, seat count: 0
 event4   POINTER_BUTTON   +18.783s    BTN_SIDE (275) pressed, seat count: 1
 event4   POINTER_BUTTON   +18.948s    BTN_SIDE (275) released, seat count: 0
```

I wonder why we aren't auto-loading those modules though?


----------



## olli@ (Feb 15, 2021)

agrajag9 said:


> Solved!
> 
> Adding `kld_list="uhid ums"` seems to have done it!


Really glad to hear that!


> I wonder why we aren't auto-loading those modules though?


I wonder, too. FreeBSD has a feature called “devmatch” that automatically loads kernel modules for devices that have been detected during boot. It is enabled by default, unless you have put `devmatch_enable="NO"` in /etc/rc.conf or /etc/rc.conf.local. It works fine on my machine, i.e. the uhid and ums modules are loaded automatically.

One possible explanation would be that the VMware mouse appears with a delay, after the devmatch function has run during the boot process. If you’re curious to find out, you can manually run it with `service devmatch start` (as root), and check if it loads the modules at that point.


----------

