I apologize in advance if this is not the correct forum for this question or if the question is too broad to answer. My background is in computer science and I work mostly in Java middleware so this is a bit out of my area of expertise.

I'm interested in capturing input from a mouse on a Linux operating system as quickly as possible. Let's assume I am working with a USB 3 mouse on conventional hardware (64bit i7 16gb ram). Can anyone recommend a way to formulate with some certainty the maximum input capture rate? Or if that is not possible could someone point out the most likely software, hardware, or physical phenomena that would act as the max limiter?

Some of my initial thoughts so far as to the max limitation

  1. The smallest unit of time the system can keep
  2. The transfer rate of USB 3
  3. Speed of the physical signal sent from the mouse
  • \$\begingroup\$ Comm bottleneck is likely inside the mouse. Some use SPI (serial) to a USB interface. The optical navigation technology internal to the mouse chip may limit frame rate to something far below their 6666 frame/sec maximum. \$\endgroup\$
    – glen_geek
    Jul 15 '17 at 13:40

USB is a host driven protocol. The driver on the operating system initiates talking to devices, and it controls the (maximum) polling rate. The only thing a device must do is make data ready in a buffer for the host to read.

Some "gaming mice" offer (unnecessarily) high polling of 1kHz. This is a combination of fast software in the mice but also the host OS driver set up to poll at 1kHz.

I say unnecessarily high because most game engines won't process data at that frequency, even racing simulators are known to process physics data in the few hundred Hz range. But I suppose you're developing some custom application, so this could be non applicable to you.

The USB2, USB3, USB-C standard or plug does not change anything to the polling rate. I bet there is hardly any chipset out there that talks native USB3.x for HID input purposes, like mouse or keyboard. USB2.0 provides more than enough bandwidth for this purpose. If the mouse outputs horizontal/vertical movement (16-bit signed deltas) and 8 buttons (1 byte) at 1kHz, that adds up to 5kB/s or about 40kBit of transfer speed. Even on a 12Mbit line (which most mice/keyboards are) there is plenty of bandwidth left.

Case in point: my keyboard apparently uses 1.5Mbits signalling speed, and my Logitech G500s "gaming mice" 12Mbits.

Can higher polling rates be supported? Perhaps outside the books; but the device enumeration holds a "bInterval" endpoint field which is expressed in ms (valid range 1 to 255).

  • \$\begingroup\$ Thank you for the answer. I am working on something that would benefit from maximum polling because it has nothing really to do with responding to the user input but rather gathering and modeling data \$\endgroup\$ Jul 15 '17 at 21:59

This is one of those situations where the theoretical approach will give you a number that's way too high to achieve in practice.

Firstly, is it actually a USB3 mouse? Or is it a USB2 12MHz mouse with a fancy plug?

USB HID devices like mice operate on polling. What is the shortest unit of time you can set the OS polling interval at? It may be a milisecond, although the system is quite capable of handling microsecond timers. That would limit you to 1000Hz polling.

The physical signal, as per Grace Hopper's famous lecture, travels at about one foot per nanosecond.

  • \$\begingroup\$ The hardware isn't clearly defined but for prototyping purposes I would be using a mouse and interface with the highest transfer rate available to the general consumer. Possibly USB-C if it's within the budget because the end goal is to test a hypothesis I have about a novel way to model input. I appreciate your response especially mentioning polling as that term I was unfamiliar with previously but just led me to some informative articles \$\endgroup\$ Jul 15 '17 at 8:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.