fix(Hardware Support): Use blocking read mechanism only for hidraw source polling - #708
Merged
Conversation
pastaq
force-pushed
the
pastaq/hidraw_polling
branch
from
September 10, 2026 23:55
006f0f2 to
34da343
Compare
…urce polling Currently we synchronize the sleep timer based poll rate and the blocking read timeout for hidraw devices. The poll loop drains a single hid input report from the device event queue and we expect it will remain in sync as the arrival time should match the read time and a read will take only a few microseconds to complete. This is based on the assumption that the event pacing will remain consistent, but that is a flawed assumption as irregular event pacing can cause a backlog of events, leading to noticeable input lag. When the gamepad device on the MSI Claw, while in Dinput mode, is first attached, it has irregular event pacing. It sometimes produces read returns as quickly as every 3 ms before eventually stabilizing around 7.99-8.01ms. Under the current schema this can allow dozens of unread events to queue. As this device regularly runs at 120Hz framerate, every 8ms of delay puts the event read behind by ~1 frame. As dozens of these events pile up the effect becomes more and more noticeable. The mandatory poll rate sleep ensures the queue is never able to fully drain. As the blocking read and read timeout already directly manage the event pacing for hidraw devices, set all event driven device poll rates to 0ms. This ensures that all event reads become immediate and event queues are never allowed to build up over time. Blocked devices and configuration devices are set to 500ms as they are not event driven and waste CPU cycles once they do their setup. Notably, the DualSense and FTS 3528 Touchscreen drivers do not use read_timeout, so the poll rate is retained for those drivers.
pastaq
force-pushed
the
pastaq/hidraw_polling
branch
from
September 11, 2026 01:01
34da343 to
e05f5f2
Compare
Contributor
|
🎉 This PR is included in version 0.79.5 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently we synchronize the sleep timer based poll rate and the blocking read timeout for hidraw devices. The poll loop drains a single hid input report from the device event queue and we expect it will remain in sync as the arrival time should match the read time and a read will take only a few microseconds to complete. This is based on the assumption that the event pacing will remain consistent, but that is a flawed assumption as irregular event pacing can cause a backlog of events, leading to noticeable input lag.
When the gamepad device on the MSI Claw, while in Dinput mode, is first attached, it has irregular event pacing. It sometimes produces read returns as quickly as every 3 ms before eventually stabilizing around 7.99-8.01ms. Under the current schema this can allow dozens of unread events to queue. As this device regularly runs at 120Hz framerate, every 8ms of delay puts the event read behind by ~1 frame. As dozens of these events pile up the effect becomes more and more noticeable. The mandatory poll rate sleep ensures the queue is never able to fully drain.
As the blocking read and read timeout already directly manage the event pacing for hidraw devices, set all event driven device poll rates to 0ms. This ensures that all event reads become immediate and event queues are never allowed to build up over time. Blocked devices and configuration devices are set to 500ms as they are not event driven and waste CPU cycles once they do their setup.