Created 01/12/2019 at 06:00PM

I recently bought a SpaceMouse Enterprise 3D mouse. I have wanted one for some time, but the price has always been prohibitive. However, I recently noticed that Amazon were selling a kit containing the 3D mouse, a CadMouse, and a mouse mat. Since it was on the border of my acceptable price range, and I get a decent amount of use from my current 3D mouse when using FreeCAD and Blender, I thought I would give it a shot.

I had looked through the forums and seen that 3Dconnexion offered no Linux support, but I assumed that was just for the LCD, which I could try and get working at a later date; In the meantime, I could still use it as a regular 3d mouse with spacenavd.

I did not realise that the device would not work at all. Oh no.

First step - spacenavd

I had previously had a look at the source code for spacenavd, the alternative driver for 3Dconnexion devices, back when I first bought a NuLOOQ. At that time, the NuLOOQ was not supported and I seem to recall adding the USB VID/PID to an internal list. I examined the code and saw that while the NuLOOQ had since been added, the SpaceMouse Enterprise was not there.

I patched the SpaceMouse VID/PID to the code and, after a few permission issues which were solved by writing some udev rules, I managed to get the SpaceMouse working with FreeCAD and Blender. Phew.

I did notice that FreeCAD had a problem with the buttons for the SpaceMouse, giving an error that seemed to indicate that either it did not expect the device to have as many buttons as it did, or that the driver was incorrectly reporting which button was being pressed. Still, most of the buttons worked, which was the main thing.

Now to see how the screen worked.

3DxWare on a Virtual Machine

I downloaded and installed the latest version of 3DxWare, the official driver from 3Dconnexion, on to a Windows 7 virtual machine. After installing, the LCD displayed the name of the currently active program, along with twelve icons, one for each of the function buttons. The icons and text changed as the focus moved from one program to another.

Setting a bad example

I then downloaded the 3Dconnexion SDK, which comes with some example code. I had hoped that it would include code to allow me to send custom images to the LCD, but the SDK does not give any direct control over the screen at all. All that you are allowed to do is register icons and text with the driver, which will then display them as part of the twelve icons shown on the screen.

Unfortunately, I could not get the sample code to even allow me to upload an icon, and the example itself did not seem to work correctly. I struggled for a bit, then gave up that approach. Time to see what the driver was sending to the device.

Wireshark and Usbmon

Wireshark has the ability to capture USB traffic if the usbmon kernel module is installed. I figured that I would have a look at the data being sent to the SpaceMouse, in the hope that it would be relatively straightforward to decode. All that is needed is to find the USB bus and device numbers, using lsusb, and capture the traffic on the respective Wireshark usbmon device.

In my case, the SpaceMouse showed up as:

Bus 001 Device 010: ID 256f:c633 Generic Mass Storage Device

so I captured using the Wireshark usbmon1 device, and used the rule:

usb.bus_id == 1 && usb.device_address == 10 && usb.src == host

to filter out everything except the traffic that was being sent from the PC to the SpaceMouse.

I then set about performing various actions that would cause the driver to send messages to the SpaceMouse, such as starting and stopping the driver, changing whether icons or text should be displayed on the LCD, altering the screen brightness, or just switching from one program to another. I captured the data and looked for any patterns.

Continued in part 2...

SpaceLCD repository