Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Steam Deck: Periodically reenable gyro #12172

Merged
merged 1 commit into from Sep 28, 2023

Conversation

ArcaneNibble
Copy link
Contributor

@ArcaneNibble ArcaneNibble commented Sep 7, 2023

As described in the code comment, a recent change to the Steam client disables sending of gyro data if Steam Input doesn't think the gyro is being used. This change adds some code to periodically try re-enabling the gyro data (so that users to not have to manually perform a workaround by assigning dummy unused behavior in Steam Input).

It is not sufficient to merely do this once at launch because opening and closing the Steam or performance ("..." button) overlays will disable gyro data again.

The magic number of 250 was originally chosen because the Deck controls poll at 250 Hz, and so the intent was to re-enable gyro data once per second. However, this was before I remembered that UpdateInput is nonblocking and not actually called at this frequency. In any case, the exact number here is not hugely important. I did not want to spam the re-enable command every poll due to (possibly/likely unfounded) concerns over causing performance issues, and this number is close enough.

After this patch, gyro data will still glitch whenever Steam overlays are enabled/disabled, but they will automatically re-enable themselves in ~a second. This appears to be unavoidable.

Incidentally, this change to the Steam client affects all third-party raw gyro applications including SteamDeckGyroDSU (where the suggested workaround is to assign a dummy behavior)

@AdmiralCurtiss
Copy link
Contributor

Mhm, I suppose it makes sense for the Deck to disable the gyro if it thinks it's unused, it probably saves a bit of battery.

@AdmiralCurtiss
Copy link
Contributor

Okay... I tested this and I'm not sure what to do with the results here.

First off, yes, I can confirm the issue that the Deck turns off the Accelerometer and Gyroscope in Dolphin without this patch, and this patch does allow them to work again. But the weird part is: If I launch a Dolphin build with this patch, close it, and then launch a Dolphin build without the patch, they still work! They only stop working if I put the Deck to sleep -- opening the sidebars doesn't stop them working either.

This makes me think that we should send a 'stop using motion' command when Dolphin is closed? But I'm not actually sure. Pretty strange if you ask me.

@ArcaneNibble
Copy link
Contributor Author

Are you testing in desktop mode or in gaming mode? I do not observe what you describe in my testing (all done in gaming mode) -- gyro gets disabled whenever a game that doesn't use it is launched. However, what you're describing would make sense in desktop mode (Steam seems to turn the gyro off and just leaves it off without sending more mode changes, so the most recent state change (i.e. from the patched Dolphin build) sticks around).

To turn the gyro back off, the command has 0x18 replaced with 0x00, but I don't know if there's any particular reason to send it (other than to save a small amount of power?).

Having global state flags in the controller firmware generally seems like a bad design (at least when multiple third-party programs exist and are all trying to do something different), but there isn't really anything one specific app can do about it.

@AdmiralCurtiss
Copy link
Contributor

I'm seeing this behavior in gaming mode. I just re-verified this with two builds that are identical other than your change from this PR, as soon as I start the build with the change the motion data just stays enabled forever -- even launching a regular Steam game in-between doesn't 'fix' it, only putting the Deck to sleep does. Maybe if I configured one of the games/dolphins to use the gyro in Steam's button mapping it would change the behavior?

Either way, I agree that it's probably not a huge deal, I just find it odd.

@AdmiralCurtiss AdmiralCurtiss merged commit 53df01f into dolphin-emu:master Sep 28, 2023
11 checks passed
@MayImilae
Copy link
Contributor

MayImilae commented Dec 4, 2023

After this change, 2022 Steam Deck LCDs will now get double / spurious inputs after running Dolphin that continue even after exiting Dolphin. But not newer machines though, which is curious.

https://bugs.dolphin-emu.org/issues/13412

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants