# Help me rotate my trackball



## dpx (Oct 16, 2017)

I am using https://ergodox-ez.com/ keyboard and https://www.kensington.com/us/us/4493/k64325/expert-mouse-wired-trackball

They both show in /var/log/messages and work well using defaults in Xorg (nothing set in xorg.conf.d). Keyboard is pretty complicated, having mouse layer, which behaves like real mouse.

Here are related lines in /var/log/messages for trackball:

```
Oct 16 21:16:31 bsd kernel: ugen0.2: <Kensington Kensington Expert Mouse> at usbus0
Oct 16 21:16:31 bsd kernel: ums0: <Kensington Kensington Expert Mouse, class 0/0, rev 1.10/1.00, addr 2> on usbus0
```
Same thing for keyboard:

```
Oct 16 21:16:31 bsd kernel: ugen0.3: <ErgoDox EZ ErgoDox EZ> at usbus0
Oct 16 21:16:31 bsd kernel: ukbd0: <ErgoDox EZ ErgoDox EZ, class 0/0, rev 1.10/0.01, addr 3> on usbus0
Oct 16 21:16:31 bsd kernel: ukbd1: <ErgoDox EZ ErgoDox EZ, class 0/0, rev 1.10/0.01, addr 3> on usbus0
Oct 16 21:16:31 bsd kernel: ums1: <ErgoDox EZ ErgoDox EZ, class 0/0, rev 1.10/0.01, addr 3> on usbus0
Oct 16 21:16:31 bsd kernel: uhid1: <ErgoDox EZ ErgoDox EZ, class 0/0, rev 1.10/0.01, addr 3> on usbus0
```

I want to rotate trackball axis 90 degrees counter clock wise (270 degrees clock wise) so I tried defining new conf file in /usr/local/etc/X11/xorg.conf.d/, following all the docs on this site.

Following https://www.freebsd.org/cgi/man.cgi?query=mousedrv&sektion=4&manpath=freebsd-release-ports I tried adding Option "AngleOffset" "_integer_" but it simply does not show any difference. What I suspect is that I don't define conf properly, so it makes no difference for a trackball.

Question:
How do I define xorg.conf.d file for trackball? Preferably it will affect trackball only and not keyboard mouse that ergodox has.

Thanks.


----------



## SirDice (Oct 18, 2017)

dpx said:


> Following https://www.freebsd.org/cgi/man.cgi?query=mousedrv&sektion=4&manpath=freebsd-release-ports I tried adding* Option* *"AngleOffset"* *"*_integer_*"* but it simply does not show any difference. What I suspect is that I don't define conf properly, so it makes no difference for a trackball.


Have a look at /var/log/Xorg.0.log and see if your changes have been picked up or not.


----------



## dpx (Oct 18, 2017)

Good idea, thanks. I would usually know what to do but FreeBSD uses devd and I am unfamiliar with it.


----------



## dpx (Oct 18, 2017)

This are all relevant parts of Xorg.0.log:


```
└─► cat /var/log/Xorg.0.log | grep -i mouse
[ 79160.585] (==) NVIDIA(0): Silken mouse enabled
[ 79160.677] (II) config/devd: adding input device (null) (/dev/sysmouse)
[ 79160.677] (II) LoadModule: "mouse"
[ 79160.677] (II) Loading /usr/local/lib/xorg/modules/input/mouse_drv.so
[ 79160.677] (II) Module mouse: vendor="X.Org Foundation"
[ 79160.677] (II) Using input driver 'mouse' for 'sysmouse'
[ 79160.677] (**) sysmouse: always reports core events
[ 79160.677] (**) Option "Device" "/dev/sysmouse"
[ 79160.677] (==) sysmouse: Protocol: "Auto"
[ 79160.677] (**) sysmouse: always reports core events
[ 79160.677] (==) sysmouse: Emulate3Buttons, Emulate3Timeout: 50
[ 79160.677] (**) sysmouse: ZAxisMapping: buttons 4 and 5
[ 79160.677] (**) sysmouse: Buttons: 5
[ 79160.678] (**) Option "config_info" "devd:sysmouse"
[ 79160.678] (II) XINPUT: Adding extended input device "sysmouse" (type: MOUSE, id 7)
[ 79160.678] (**) sysmouse: (accel) keeping acceleration scheme 1
[ 79160.678] (**) sysmouse: (accel) acceleration profile 0
[ 79160.678] (**) sysmouse: (accel) acceleration factor: 2.000
[ 79160.678] (**) sysmouse: (accel) acceleration threshold: 4
[ 79160.678] (II) sysmouse: SetupAuto: hw.iftype is 4, hw.model is 0
[ 79160.678] (II) sysmouse: SetupAuto: protocol is SysMouse
```

I tried mapping different parts of this config in /usr/local/etc/X11/xorg.conf.d/20-mouse.conf, latest iteration being:

```
Section "InputDevice"
   Identifier  "mouse0"
   Driver      "mouse"
   Option      "config_info" "devd:sysmouse"
   Option      "Protocol" "Auto"
   Option      "AngleOffset" "60"
   Option      "Buttons" "7"
   Option      "Device"   "/dev/sysmouse"
EndSection
```

But regardless what kind of matching I try, Xorg.0.log stays the same -- I am checking if number of mouse buttons changes from 5 to 7 but no it stays 5 all the time.

So first quote never changes after xorg restart no matter what I do. I am sure I didn't match my 20-mouse.conf with actual trackball settings but no idea how to do the matching.


----------



## SirDice (Oct 18, 2017)

I think the issue might be because Xorg on FreeBSD uses /dev/sysmouse. The sysmouse(4) is actually a virtualized mouse driver. So it may not support all the option the "real" mouse (trackball in your case) does. Try setting the mouse device to the actual device /dev/ums0 instead (make sure there's no moused(8) running, trying to hog the device). Not sure if that's going to solve it, it could also introduce more issues, but it's worth a try.


----------



## dpx (Oct 18, 2017)

I did have moused running. Changing moused_enable="YES" to moused_enable="NO" in /etc/rc.conf actually does nothing, moused keeps starting on every boot. Temporarily I am pkilling process for test but if there is a way to disable it please let me know.

So without moused running, starting xorg shows both sysmouse and kensington (which is improvement). I still don't know how to prevent sysmouse from showing or how to match trackball.

```
└─► cat /var/log/Xorg.0.log | grep -i mouse
[   644.430] (==) NVIDIA(0): Silken mouse enabled
[   644.522] (II) config/devd: adding input device (null) (/dev/sysmouse)
[   644.522] (II) LoadModule: "mouse"
[   644.522] (II) Loading /usr/local/lib/xorg/modules/input/mouse_drv.so
[   644.522] (II) Module mouse: vendor="X.Org Foundation"
[   644.522] (II) Using input driver 'mouse' for 'sysmouse'
[   644.522] (**) sysmouse: always reports core events
[   644.522] (**) Option "Device" "/dev/sysmouse"
[   644.522] (==) sysmouse: Protocol: "Auto"
[   644.523] (**) sysmouse: always reports core events
[   644.523] (==) sysmouse: Emulate3Buttons, Emulate3Timeout: 50
[   644.523] (**) sysmouse: ZAxisMapping: buttons 4 and 5
[   644.523] (**) sysmouse: Buttons: 5
[   644.523] (**) Option "config_info" "devd:sysmouse"
[   644.523] (II) XINPUT: Adding extended input device "sysmouse" (type: MOUSE, id 7)
[   644.523] (**) sysmouse: (accel) keeping acceleration scheme 1
[   644.523] (**) sysmouse: (accel) acceleration profile 0
[   644.523] (**) sysmouse: (accel) acceleration factor: 2.000
[   644.523] (**) sysmouse: (accel) acceleration threshold: 4
[   644.523] (II) sysmouse: SetupAuto: hw.iftype is 4, hw.model is 0
[   644.523] (II) sysmouse: SetupAuto: protocol is SysMouse
[   644.523] (II) config/devd: adding input device Kensington Expert Mouse (/dev/ums0)
[   644.523] (II) Using input driver 'mouse' for 'Kensington Expert Mouse'
[   644.523] (**) Kensington Expert Mouse: always reports core events
[   644.523] (==) Kensington Expert Mouse: Protocol: "Auto"
[   644.523] (**) Kensington Expert Mouse: always reports core events
[   644.523] (==) Kensington Expert Mouse: Emulate3Buttons, Emulate3Timeout: 50
[   644.523] (**) Kensington Expert Mouse: ZAxisMapping: buttons 4 and 5
[   644.523] (**) Kensington Expert Mouse: Buttons: 5
[   644.523] (II) XINPUT: Adding extended input device "Kensington Expert Mouse" (type: MOUSE, id 8)
[   644.523] (**) Kensington Expert Mouse: (accel) keeping acceleration scheme 1
[   644.523] (**) Kensington Expert Mouse: (accel) acceleration profile 0
[   644.523] (**) Kensington Expert Mouse: (accel) acceleration factor: 2.000
[   644.523] (**) Kensington Expert Mouse: (accel) acceleration threshold: 4
[   644.523] (II) Kensington Expert Mouse: SetupAuto: hw.iftype is 5, hw.model is 0
[   644.523] (II) Kensington Expert Mouse: SetupAuto: protocol is SysMouse
[   644.524] (II) Using input driver 'mouse' for 'EZ ErgoDox EZ'
[   644.524] (II) XINPUT: Adding extended input device "EZ ErgoDox EZ" (type: MOUSE, id 9)
[   644.524] (II) EZ ErgoDox EZ: SetupAuto: protocol is SysMouse
```

I also tried disabling moused in xorg following this advice https://forums.freebsd.org/threads/2902/ but setting NO or YES makes no difference, without moused process my Xorg.0.log always looks like quoted above.

Edit: My latest /usr/local/etc/X11/xorg.conf.d/20-mouse.conf looks like this but no effect at all:

```
Section "InputDevice"
   Identifier  "Kensington Expert Mouse"
        Driver      "mouse"
   Option      "Protocol" "Auto"
   Option      "AngleOffset" "60"
   Option      "Buttons" "7"
   Option      "Device"   "/dev/ums0"
EndSection
```


----------



## SirDice (Oct 18, 2017)

dpx said:


> I did have moused running. Changing moused_enable="YES" to moused_enable="NO" in /etc/rc.conf actually does nothing, moused keeps starting on every boot.


It's automatically started by devd(8) if you plugin a USB mouse. There was a trick to prevent this from happening but I can't remember what it was. The old Synaptic mousepad X driver had the same issue, and you had to make absolutely sure moused(8) didn't grab the device.

You do need to add this to xorg.conf (ServerFlags section) or else it's simply going to ignore any "hard-coded" mouse and keyboard devices:

```
Option "AutoAddDevices" "false"
```


----------



## dpx (Oct 18, 2017)

Thanks, that solved the problem completely. At least I know more about FreeBSD architecture, even if it turned out to be bit of a lockdown situation.

With moused killed and Option "AutoAddDevices" "false" rotation works on trackball but my keyboard mouse doesn't work. It seems it can only work with moused enabled.
With moused killed and without AutoAddDevices modification nothing works.
With moused kept alive and any other combination keyboard mouse works but trackball doesn't respect rotation.

Most unexpected turn of events was actual trackball hardware, rotated works beautifully and much better from ergonomic perspective _but_ when I remap buttons to respect orientation (which makes browser back button becoming main button 1) pressing former back button (now button 1) and trying to rotate scroll ring doesn't work well. Kensington, due to some hardware hiccup, blocks ring from turning when you press back button at the same time. Which of course never happens when used in normal orientation.

Thanks again SirDice, this was brilliant help, now I have ton of variants to test but now I know who does what re drivers.


----------



## SirDice (Oct 18, 2017)

dpx said:


> With moused killed and Option "AutoAddDevices" "false" rotation works on trackball but my keyboard mouse doesn't work. It seems it can only work with moused enabled.


It may not need that. With AutoAddDevices set to false it means it won't auto-detect devices anymore. This is how X was traditionally configured, you had to explicitly specify all the devices you wanted to use. So you would have to add another mouse Device section to add the second mouse. And you would probably also need a keyboard Device section to get the keyboard working.


----------



## dpx (Oct 18, 2017)

Keyboard works well with or without it, tested. Yes, exactly what I am thinking of trying, creating new mouse device to handle ums1.

This is initial moused on boot, it creates two processes to handle ums0 (trackball) and ums1 (keyboard mouse).
└─► ps -ax | grep -i mous
28455  -  Is    0:00.00 /usr/sbin/moused -p /dev/ums1 -t auto -I /var/run/moused.ums1.pid
51455  -  Is    0:00.74 /usr/sbin/moused -p /dev/ums0 -t auto -I /var/run/moused.ums0.pid

However I am puzzled with hardware scrolling problem with trackball, something I couldn't expect before trying. Which makes whole rotation idea bit less appealing.

I also tried killing one of those two moused processes, to keep keyboard mouse covered with moused and trackball not handled by it but it seems to be all in process, killing one or both has the same result, not even related to which one I kill.


----------



## knightjp (Nov 23, 2018)

I was thinking of getting a Kensington Expert. But if it not supported by FreeBSD, which other trackballs are?


----------



## bart (Nov 23, 2018)

knightjp said:


> I was thinking of getting a Kensington Expert. But if it not supported by FreeBSD, which other trackballs are?


I use Logitech M570 everyday and it's well suported, but no support for the "unifier" system to connect multi device on the same dongle.


----------



## knightjp (Nov 23, 2018)

bart said:


> I use Logitech M570 everyday and it's well suported, but no support for the "unifier" system to connect multi device on the same dongle.


I have a Logitech M570. Love it, I just like the Kensington better.


----------



## MarcoB (Nov 23, 2018)

knightjp said:


> I was thinking of getting a Kensington Expert. But if it not supported by FreeBSD, which other trackballs are?


I use a Kensington Orbit trackball. Works great.


----------



## Deleted member 30996 (Nov 23, 2018)

knightjp said:


> But if it not supported by FreeBSD, which other trackballs are?




```
ums0: <Microsoft Microsoft Trackball Optical, class 0/0, rev 1.10/1.21, addr 2> on usbus0
```

Best thing MicroSoft ever made IMO.


----------

