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

Support Steam Deck controls natively through hidraw #11779

Merged
merged 1 commit into from May 12, 2023

Conversation

ArcaneNibble
Copy link
Contributor

Summary

This code adds an alternate way of accessing the Steam Deck's controls without going through Steam's input remapper. This has the following advantages:

  • can use motion controls without having to separately install a system service
  • can independently use the thumb sticks, touch pads, and back grip buttons (which do not map cleanly to an emulated Xbox 360 controller)

This works by opening the hidraw device corresponding to the Deck controls and manually parsing the input reports.

This does not inherently conflict with having Steam running (both processes can read input reports at the same time), but Steam will continue to respond to special buttons like the "STEAM" or "..." buttons.

Known limitations

This code does not support hotplugging or having multiple sets of Deck gamepads connected to the computer (this generally cannot happen in normal usage as the controls are a built-in component of the Deck, but it is theoretically possible as the controls are connected over USB internally).

Testing

I personally tested this only on a Steam Deck and only briefly in the controller configuration UI.

@AdmiralCurtiss
Copy link
Contributor

Oh this will be really useful for the Steam build, thanks a lot!

@AdmiralCurtiss
Copy link
Contributor

FYI if you want to keep the table formatting for the buttons you can use https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code

@ArcaneNibble ArcaneNibble marked this pull request as ready for review April 20, 2023 16:18
@TellowKrinkle
Copy link
Contributor

Have you considered adding this to SDL, which Dolphin (and many other emulators) use for input?

@ArcaneNibble
Copy link
Contributor Author

I was under the impression that SDL was not used by default on Linux ( https://github.com/dolphin-emu/dolphin/blob/master/CMakeLists.txt#L98 ), even though the flatpak build does seem to enable it

@OatmealDome
Copy link
Member

OatmealDome commented Apr 20, 2023

On our Linux builds for Steam, we do enable SDL. (The flag is set on our CI.)

That being said, since we're probably not moving to SDL3 any time soon, I'm willing to accept this backend into Dolphin mainline so we don't have to use Steam Input to access the gyro.

@ArcaneNibble
Copy link
Contributor Author

fixed, i am clearly much more familiar with C than C++

@Bitwolfies
Copy link

Have you considered adding this to SDL, which Dolphin (and many other emulators) use for input?

I agree, getting this into sdl would be a massive boon system wide, you should absolutely consider it!

Copy link
Member

@jordan-woyak jordan-woyak left a comment

Choose a reason for hiding this comment

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

Code seems fine. I have not tested it. I just have one comment about naming.
The commit history could probably be cleaned up a little.

AddInput(new Button("D-Pad Right", m_latest_input.buttons0, 0x00000200));
AddInput(new Button("D-Pad Left", m_latest_input.buttons0, 0x00000400));
AddInput(new Button("D-Pad Down", m_latest_input.buttons0, 0x00000800));
AddInput(new Button("VIEW", m_latest_input.buttons0, 0x00001000));
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense for "VIEW", "STEAM", "OPTIONS", and "DOTS" to be all caps? Maybe it does, I'm just asking.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've been trying to find official names for these buttons but I'm not really finding anything from Valve for the 'STEAM' and '...' buttons. The other two are lifted from the Xbox One controller and those are specifically mentioned as VIEW and MENU in the documentation. So I'd rename OPTIONS to MENU and the rest are probably fine as-is.

Choose a reason for hiding this comment

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

Dots is called the “quick access” button officially.

Choose a reason for hiding this comment

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

Steam button would also be "guide button"

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you have an official source for this? I can find a few references to Quick Access (or QAM) but none directly from Valve documentation or similar.

Copy link

@Bitwolfies Bitwolfies May 9, 2023

Choose a reason for hiding this comment

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

Do you have an official source for this? I can find a few references to Quick Access (or QAM) but none directly from Valve documentation or similar.

From my Deck itself, sadly I cannot prove the quick access name, but the dots refer to quick access button in a tutorial. Quick access is as close of a name you'll get since its a custom deck button with no equal on other controllers. (You have to press guide + a on other controllers to open the quick menu)

As for guide, that's what the console home buttons are always called on steam. Steam button on deck does the exact same actions as the xbox button, or ps button on controllers as an example. So we can equate the Steam button to a guide button under Valves terms.
Screenshot_20230509_155905

Copy link
Contributor

Choose a reason for hiding this comment

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

Counterpoint about the Steam/Guide button:

20230510010606_1

Also I assume you're referring to this initial tutorial popup thing: https://youtu.be/GF9g_bmi-cE?t=514

Which, yes, does definitely refer to it as the 'Quick Access button'... and also definitely refers to the other button as 'Steam button'.

So I guess it's 'Steam' and 'Quick Access'?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would also change 'Pad' to 'Trackpad' and 'Pad Force' to 'Trackpad Pressure' based on how they're referred to in the Steam Deck UI.

This reads Steam Deck controls bypassing Steam Input. This allows for access to
motion controls as well as independent access to thumb sticks, trackpads, and
back grip buttons.
Copy link
Contributor

@AdmiralCurtiss AdmiralCurtiss left a comment

Choose a reason for hiding this comment

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

Looks good to me. Untested.

@AdmiralCurtiss AdmiralCurtiss dismissed jordan-woyak’s stale review May 12, 2023 20:08

Changes have been made.

@AdmiralCurtiss AdmiralCurtiss merged commit 27d90a7 into dolphin-emu:master May 12, 2023
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants