Skip to content

fix(Hardware Support): Use blocking read mechanism only for hidraw source polling - #708

Merged
pastaq merged 1 commit into
mainfrom
pastaq/hidraw_polling
Sep 11, 2026
Merged

fix(Hardware Support): Use blocking read mechanism only for hidraw source polling#708
pastaq merged 1 commit into
mainfrom
pastaq/hidraw_polling

Conversation

@pastaq

@pastaq pastaq commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

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.

@pastaq
pastaq force-pushed the pastaq/hidraw_polling branch from 006f0f2 to 34da343 Compare September 10, 2026 23:55
…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
pastaq force-pushed the pastaq/hidraw_polling branch from 34da343 to e05f5f2 Compare September 11, 2026 01:01
@pastaq
pastaq merged commit 6d08364 into main Sep 11, 2026
6 checks passed
@pastaq
pastaq deleted the pastaq/hidraw_polling branch September 11, 2026 01:43
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.79.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant