Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 7703  / 2 Years ago, thu, march 10, 2022, 5:02:55

I have a very specific need to change the mousepoll value in Ubuntu 15.04.



In Kerbal Space Program there's a Linux bug where if you drag the view with the right mouse button while the mousepoll value is higher than 125hz the game will hang for a second or two making it very frustrating to play.



I have a Logitech G400 mouse that polls at up to 1000hz. I cannot work out how to change this.



I have tried:




  • Setting options usbhid mousepoll=8 in /etc/modprobe.d/usbhid

  • Setting usbhid.mousepoll=8 on the command line while booting

  • Running sudo modprobe -r usbhid && sudo modprobe usbhid mousepoll=8 from the command line



These are somewhat effective in that cat /sys/module/usbhid/parameters/mousepoll returns 8 as expected. But the problem remains in KSP, and when I run evhz from https://github.com/ian-kelling/evhz it still reports polling rate of 1000hz.



Possibly relevant:




  • I'm on a laptop. The touchpad isn't using usbhid and polls at 125hz according to evhz. No problems doing the right click panning in KSP using this.

  • Xfce 4.12 (tried with compositing enabled and disabled, no change)

  • Nvidia 346.59 drivers

  • Performance in KSP is otherwise as expected based on my laptop's hardware

  • Packages (including kernel) are all stock

  • Mouse is plugged into a USB 3.0 port


More From » mouse

 Answers
7

I did find a solution to this problem.



I installed Windows in a virtual machine, attached the USB mouse device to the VM, then traced the USB traffic with Wireshark and isolated the control command that the official Logitech driver used to set the polling rate. (This was quite helpful in pointing me in the right direction: https://unix.stackexchange.com/questions/138742/how-to-dump-usb-traffic)



This magic Ruby code (must be run as root, or by a user with permission to write to /dev/hidraw1) will set the polling rate to 125Hz on my mouse:



#!/bin/ruby
HIDIOCSFEATURE = 0xC0024806

f = File.open("/dev/hidraw1", "w+")
f.ioctl(HIDIOCSFEATURE,"x20x03")


/dev/hidraw1 is the hidraw device for my mouse. This path may be different depending on how many devices you have plugged into your machine.



The 0xC0024806 sequence is the ioctl value required to "Send a feature report" to the hidraw device. I can't remember exactly how I obtained this value unfortunately, and it may not be 100% technically correct. Works for me though!



The "x20x03" sequence was the data that the driver sent in the feature report to the mouse. 20 appears to be the value in hex used to identify a polling change request, and 03 sets it to 125hz. 02 sets it to 250hz, 01 to 500Hz and 00 to 1000hz.



BE WARNED: This works for me on a Logitech G400 mouse. I think there's only one hardware variant of this mouse so it should be safe on that model. It hasn't been tested on any other model, and will not work on any Logitech mouse that uses the HID++ protocol to communicate (this includes many newer mice, and any wireless models using the Unifying receiver).



I also barely knew what I was doing, and every single thing I did to figure it out was learned for the first time along the way, including this phrase: Caveat lector (reader beware)!


[#19998] Friday, March 11, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ticrew

Total Points: 190
Total Questions: 111
Total Answers: 99

Location: Fiji
Member since Wed, Jul 14, 2021
3 Years ago
ticrew questions
Mon, Jan 10, 22, 07:20, 2 Years ago
Wed, Dec 8, 21, 19:25, 3 Years ago
Wed, May 5, 21, 08:17, 3 Years ago
Fri, Mar 10, 23, 17:21, 1 Year ago
Fri, Nov 4, 22, 06:43, 2 Years ago
;