Using 3DConnexion Mouse on Ubuntu with Python

sudo apt install libhidapi-dev
pip install pyspacemouse

Create UDev rule for hidraw:

sudo nano /etc/udev/rules.d/50-hidraw.rules
50-hidraw.rules
# 3Dconnexion SpaceMouse Compact
SUBSYSTEMS=="usb", ATTRS{idVendor}=="256f", ATTRS{idProduct}=="c635", GROUP:="users", MODE:="0666"

# Logitech, Inc. 3Dconnexion Space Navigator 3D Mouse
SUBSYSTEMS=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c626", GROUP:="users", MODE:="0666"

And then

sudo udevadm control --reload-rules
sudo udevadm trigger

An easy way to check if the udev rule is applied successfully is through lsusb command.

Run

lsusb -d 046d: -v

If the access is granted, there will be no errors at the top of the log:

> lsusb -d 046d: -v

Bus 001 Device 022: ID 046d:c626 Logitech, Inc. 3Dconnexion Space Navigator 3D Mouse
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        32
...

Otherwise, it will show the Couldn't open device error message:

lsusb -d 046d: -v

Bus 001 Device 024: ID 046d:c626 Logitech, Inc. 3Dconnexion Space Navigator 3D Mouse
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        32
...

Last updated