Why some games perform so poorly with some high-end mice



To play games on a PC, three types of input devices are commonly used: mouse, keyboard, and gamepad. However, using a certain high-end mouse on Windows can cause performance degradation in some games, including very popular titles. Peter Durante Thomann of PH3 GmbH , famous for porting the Legend of Heroes series to PC, analyzed why the problem occurs.

Things you really should know about Windows Input, but would rather not - Raw Mouse edition | PH3 Blog
https://ph3at.github.io/posts/Windows-Input/



The most traditional way to receive input from the user in Windows is to receive Windows messages sent to the application's message queue. Many Windows applications receive input from the keyboard and mouse through Windows messages, but when passing through Windows messages, the user's mouse operations are accelerated and adjusted by Windows, and they do not provide sub-pixel accuracy, making them unsuitable for input to games.

For this reason, the 'Raw Input API' is used in games where mouse input is extremely important, such as games where you use the mouse to move a 3D camera. By using the Raw Input API, you can receive 'raw' input from the mouse.

There are two ways to receive input with the Raw Input API, you can use a standard read from the device to process individual event messages, or you can use a buffered read to get all the input events present in a buffer. Naturally, reading events together from a buffer provides better performance than processing separate events individually.

However, even with buffer reads, if you move a mouse vigorously with a polling rate of 8kHz (the frequency at which data is sent from the mouse), the performance will deteriorate to the point where the frame rate in some games drops from 355 to 133, as shown in the figure below. This is because if you do not configure anything, the system outputs not only Raw Input messages but also legacy messages, and the legacy messages fill up the message queue.



It is possible to disable legacy messages, but legacy messages are used in many system processes such as 'moving the game window,' and disabling legacy messages would mean that you would need to implement processes that would normally be performed by the system.

After much consideration, Thoman solved the problem by 'leaving legacy messages enabled, but using buffer reads for input to the actual game, and then limiting the number of message queue events processed per frame to a certain number.' Although he was concerned about how it would work when a large number of messages accumulated, he tested it and no particular problems occurred, so although he is not satisfied with it, he says he will use it as a temporary solution.

'If you know how to do it properly please get in touch,' it states.

in Software,   Hardware,   Game, Posted by log1d_ts