Skip to content

fix(DualSense): only emit changed input reports for IMU#601

Open
sunshineinabox wants to merge 2 commits into
ShadowBlip:mainfrom
sunshineinabox:Polling
Open

fix(DualSense): only emit changed input reports for IMU#601
sunshineinabox wants to merge 2 commits into
ShadowBlip:mainfrom
sunshineinabox:Polling

Conversation

@sunshineinabox

Copy link
Copy Markdown

DS5 emits at its standard poll rate of 250Hz, however for devices that don't have any IMU it continues to report the same data (zero). This should be a no-op for devices with actual IMU reported. Issue discovered on Rocknix Mangmi Air X build where the polling was causing high CPU usage in box86/64.

@pastaq pastaq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine from a code perspective. Does this match the behavior of the real hardware?

Comment thread src/input/target/dualsense.rs
Comment thread src/input/target/dualsense.rs
Comment thread src/input/target/dualsense.rs Outdated
// send UHID_INPUT events to the kernel.
uhid_virt::OutputEvent::Open => {
log::debug!("Open event received");
self.last_written = None;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be none by default, so it's a no-op at initial opening. Then we carry that stale data in memory until the next time it is opened. Rather than do this here, does it make more sense to do it after close?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with doing it around close. Only issue is resetting on close alone doesn't really work since write_state still runs every poll even with nothing attached, so it just repopulates last_written before the next open and the reconnecting consumer can get its first report skipped as unchanged. So I also skip write_state while closed and reset last_written on close.

@sunshineinabox

Copy link
Copy Markdown
Author

I don't have a real controller to actually test this on, if there is proper motion control this will likely be no behavior change as without fuzz it would constantly report anyway. This is effectively only useful for devices that are emulating the controller without motion sensors. If someone with real DS5 could look into real hardware behavior I would appreciate it.

@sunshineinabox sunshineinabox requested a review from pastaq June 12, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants