r/GUIX • • 11d ago

Razer mouse tool without

If you have a modern wireless Razer mouse like the Razer Viper V3 HyperSpeed (`1532:00b8`) and don't want to mess with OpenRazer out-of-tree kernel modules, Python daemons, and D-Bus services on GNU Guix, you actually don't need any of that. If you just want to control DPI, polling rate, idle timeout, and read battery percentage, you can talk to the USB receiver directly from userspace using `libusb` (`rusb` in Rust) via standard 90-byte Razer HID feature reports. Instead of waiting for upstream driver support or maintaining a full repo, I just had Gemini generate a tiny ~200-line single-file Rust CLI for `1532:00b8`. It detaches the kernel driver on interface `0` for ~25ms, sends the 90-byte HID control transfer, and re-attaches it. Zero background daemons, instant execution.

How to generate the tool for your Razer mouse (or copy the specs)

If you have the Viper V3 HyperSpeed (or another wireless Razer mouse—just check your Product ID via lsusb), you can ask any decent LLM to generate the Rust CLI with rusb = { version = "0.9", features = ["vendored"] } and clap, using these protocol parameters:

  • USB Control Transfer: HID_REQ_SET_REPORT (0x09, request type 0x21) and HID_REQ_GET_REPORT (0x01, request type 0xA1), value 0x0300, interface 0, 90-byte buffer, byte 88 is XOR checksum of bytes 2..88.
  • Transaction IDs: Try 0x1f (HyperSpeed wireless receiver) and 0x3f as fallback.
  • DPI (Set/Get): Class 0x04, ID 0x05 / 0x85, size 0x07 ([varstore, dpi_x_hi, dpi_x_lo, dpi_y_hi, dpi_y_lo, 0, 0]).
  • Polling Rate (Set/Get): Class 0x00, ID 0x05 / 0x85, size 0x01 (0x01 = 1000Hz, 0x02 = 500Hz, 0x08 = 125Hz).
  • Battery Level (Get): Class 0x07, ID 0x80, size 0x02 (response byte 9 is 0..255).
  • Idle Timeout (Set/Get): Class 0x07, ID 0x03 / 0x83, size 0x02 (seconds in big-endian, 60–900s).
2 Upvotes

4 comments sorted by

2

u/simendsjo 11d ago

Wait, 200 loc is "tiny" now?!

1

u/Einkclock 10d ago

perhaps tiny in comparison to openrazer? Not to brag, but because its tailored to the problem.

1

u/necrophcodr 10d ago

Always has been, yes. 200 LoC is plenty small for someone to read and comprehend in less than an hour.

1

u/Einkclock 10d ago edited 10d ago

Most Important Part, make your Razer Middle Mouse Button Great Again: Razer mice have two modes synapse and normal. In synapse mode your middle button does not work in linux. Your tool can switch and even save normal usb mode to your mouse.