Linux mouse polling rate

How do I set the USB polling rate correctly for my Logitech mouse?

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.

  • 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

Same problem but with a Logitech G302 and the planetary annihilation game steamcommunity.com/app/233250/discussions/2/618463738394063157 . Did you find a solution ?

2 Answers 2

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,"\x20\x03") 

/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 «\x20\x03» 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).

Читайте также:  Linux and media server

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)!

Источник

Mouse polling rate

If you have invested in a high resolution mouse, adjusting the USB polling rate is a common trick to utilize the added precision it brings. The polling rate (or report rate) determines how often the mouse sends information to your computer.

Polling rate and polling interval

The polling rate of a device is measured in Hertz (Hz) and is determined by the polling interval. The polling interval is measured in milliseconds (ms) and equates to lag time.

The default polling interval is 10ms. However, USB controllers round the interval down to the nearest power of two. Thus, an interval setting of 10ms will actually use 8ms, 7ms will use 4ms, etc.

The following table shows the relation between polling rate Hertz and the corresponding interval milliseconds (rate = 1000 / interval).

Hz 1000 500 250 125
ms 1 2 4 8

If the polling rate is 125 Hz, the mouse position will be updated every 8 milliseconds. In situations where lag is critical — for example games — some users decrease the interval to as little as possible. However, this puts more load on the CPU, so care should be taken when adjusting this value.

Display polling rate

The evhz tool can display the actual mouse refresh rate.

You can install it from evhz-git AUR and execute as root:

Now move the mouse continuously in large circles until the displayed Average stabilizes then press Ctrl+c to exit.

If the Latest value does not stabilize and switches between two values, then the attempted polling rate is faster than the device is capable of; see #USB device speed.

Alternatively, Windows tools such as DirectX mouserate checker can be run using Wine. Or use a website based checker like the one provided by CPS-Check.

Display polling interval

Note: This only shows the polling interval requested by the device and not the actual interval being used. See BBS.

Device information including polling interval can be found in debugfs if it is mounted and you have root access.

First, find the vendor and product IDs of your device with:

Bus 001 Device 002: ID 045e:0024 Microsoft Corp. Trackball Explorer Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Then run the following as root with those IDs to display the debug information for that device:

# grep -B3 -A6 "045e.*0024" /sys/kernel/debug/usb/devices
T: Bus=01 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 2 Spd=1.5 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1 P: Vendor=045e ProdID=0024 Rev= 1.21 S: Manufacturer=Microsoft S: Product=Microsoft Trackball Explorer® C:* #Ifs= 1 Cfg#= 1 Atr=a0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=usbhid E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=10ms

The Ivl is the polling interval; this device has requested 10ms (and actually reports every 8ms as explained in #Polling rate and polling interval). The Spd is the device speed explained in #USB device speed. For information about the other fields, see the kernel documentation.

Читайте также:  Linux установка шрифтов ttf

If debugfs or root access are not available, the polling interval can be shown with:

$ lsusb -vd 045e:0024 | grep bInterval

USB device speed

USB devices are designed to operate at a certain bitrate. Many pointing devices are «Low Speed» 1.5Mbit/s devices. The speed of a device can be shown as explained in #Display polling interval.

«Low Speed» devices may not be capable of polling at intervals less than 8ms.

All USB hubs should be capable of at least «Full Speed» 12Mbit/s. The speed of the hub that the device is attached to can be shown with the following command with the same Bus=xx as the device:

# grep -B1 -A10 "Bus=01 Lev=00" /sys/kernel/debug/usb/devices
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=12 MxCh= 2 B: Alloc= 11/900 us ( 1%), #Int= 1, #Iso= 0 D: Ver= 1.10 Cls=09(hub ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=1d6b ProdID=0001 Rev= 4.01 S: Manufacturer=Linux 4.1.18-1-lts uhci_hcd S: Product=UHCI Host Controller S: SerialNumber=0000:00:10.0 C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub E: Ad=81(I) Atr=03(Int.) MxPS= 2 Ivl=255ms

The Ivl of the hub is independent of the device and does not affect the polling rate of the device.

Set polling interval

To configure the polling rate, use the mousepoll option of the usbhid kernel module. The default value is 0 which means the module uses the interval requested by the device(s).

The current value of the option can be verified with:

$ systool -m usbhid -A mousepoll
Module = "usbhid" mousepoll = "0"

To change the configuration, create the following file:

options usbhid mousepoll=4

This example requests a polling rate of 250Hz. Similarly, you may use jspoll or kbpoll to change the polling rate of gamepads/joysticks or keyboards.

To change the polling interval without rebooting

# modprobe -r usbhid && modprobe usbhid

Warning: If the second command fails, you will be unable to use any USB mouse or keyboard and may have to reboot or ssh into your machine.

You may have to unplug the mouse and plug it back in for the change to take effect.

Note: If the usbhid module is included on your initramfs image, you may need to add /etc/modprobe.d/usbhid.conf to the image also. See the note at Kernel modules#Using files in /etc/modprobe.d/. Alternatively, you can add usbhid.mousepoll=X to your kernel command line. See Kernel modules#Using kernel command line.

Читайте также:  Arch linux i3wm install

Tip: When using a smaller than default interval, you may want to adjust the Mouse acceleration option VelocityScale to match.

Known issues

Polling at half of requested rate

There is a kernel bug that for certain configurations prevents devices from reaching 1000 Hz (1ms) polling rate. See the BBS and Bug.

A work-around that may help is to connect the device to a port using a different driver.

Polling rate not changing

The USB 3 driver xhci-hcd may be ignoring the usbhid mousepoll setting. See the linux-usb mailing list message and Bug.

The xhci-hcd module should respect the interval requested by the device, so check the documentation for the device for a hardware or firmware setting.

A work-around that may help is to connect the device to a port using a different driver.

Another work-around is to disable xHCI. There might be a BIOS setting for this or you can do so by blacklisting the xhci-hcd module. However, either way will cause any USB 3 ports to act as USB 2 as the kernel will use the ehci-hcd module instead.

As an alternative, one can install a kernel module wmo_oc-dkms AUR (or build it manually from wmo_oc-kmod), which is a fork of gcadapter-oc-kmod for wmo1.1a (MS Wheel Mouse Optical 1.1a). The wmo_oc-dkms identifies a mouse with its vendor and product ID (VID:PID) values to overclock it even with XHCI hubs, without losing USB 3 functionality. Changing the polling rate of any USB mouse other than the default wmo1.1a requires modifying the default VID:PID values (045e:0040) found in the module’s source file wmo_oc.c in /usr/src/module_name/ and finally rebuilding (removing and installing) the kernel module using DKMS.

Tip: To see which hcd drivers are in use, see the S: Manufacturer line for hub devices in /sys/kernel/debug/usb/devices .

Polling rate resulting in lag with wine

Having a mouse with a high poll rate and using wine can result in game lag; see here. It would seem that the user who created that bug had the problem solved by updating the bios. The bug, however, is not resolved for other users.

It is not possible to change the polling rate of the mouse using the methods within this wiki (the «usbhid» method) if your computer only has a USB3 xHCI Controller.

Unfortunately, there is currently no fix for users with a combination of a mouse with a high polling rate and only a USB3 xHCI Controller.

A workaround is to use a mouse with a lower polling rate.

See also

Источник

Urban Terror Forums: Howto: Changing mouse polling rate on Ubuntu — Urban Terror Forums

  • homeHome
  • top pageForums home
UrT Forums
  • rulesForum Guidelines
  • noteActive Content
  • noteMark Board As Read
  • RSS FeedRSS feeds
Forums Search

find

  • Advanced Search
Forums Users
  • staffForums Staff
  • membersUrT Members
  • today postersToday Posters

Источник

Оцените статью
Adblock
detector