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

Detect when Steam Deck is Docked? #135

Open
GregAI opened this issue Feb 27, 2024 · 2 comments
Open

Detect when Steam Deck is Docked? #135

GregAI opened this issue Feb 27, 2024 · 2 comments

Comments

@GregAI
Copy link

GregAI commented Feb 27, 2024

Maybe this is a dumb question, but has anyone who has been testing on Steam Deck, figured out a way to detect when your game is not only running on a Steam Deck, but is docked (aka showing game on TV/monitor/etc).

I can detect if it's a Steam Deck playing the game, but I sadly can't figure out how to determine if docked and displaying on a larger screen/etc. As I need to change a few things in the game.

I have tried to check for Elecron JS call of "screen.getAllDisplays()", but only gives me back the original Steam Deck screen (1280 x 800) and not any connected screens sadly.

Thanks in advance

@dfabulich
Copy link
Contributor

dfabulich commented Feb 27, 2024

Not sure about this. steamworks.js wraps around https://github.com/Noxime/steamworks-rs which has documentation here https://docs.rs/steamworks/latest/steamworks/

steamworks-rs wraps around the Steamworks C++ API documented here https://partner.steamgames.com/doc/api

Questions like the one you're asking generally have an API in ISteamUtils https://partner.steamgames.com/doc/api/ISteamUtils

That's where you'll find the IsSteamRunningOnSteamDeck() function, as well as IsSteamInBigPictureMode(). I'm not sure, but maybe big picture mode is true when docked, and false when not docked?

But I think it might be challenging to test this using steamworks.js, because IsSteamInBigPictureMode() isn't exposed in steamworks-rs. https://docs.rs/steamworks/latest/steamworks/struct.Utils.html

… and so it's not available in steamworks.js, either.

So, the first step to investigate this might be to try using the Steamworks C++ API directly for a basic example game you author yourself, to see if you can find any way to use that to detect docking.

If you knew for sure that this does work properly in C++, well, in the past, I've filed PRs on steamworks-rs to add C++ features, get the PR merged, and then file a PR on steamworks.js to expose that functionality to Electron.

It's a lot of work, but, it's open source, so you might not have much luck waiting for someone else to implement IsSteamInBigPictureMode() for you.

Another related idea would be to post on (or search) the Steamworks Developer forum https://steamcommunity.com/groups/steamworks and ask how to use the C++ API to detect docking. If they say "yeah, just use IsSteamInBigPictureMode()", that's a strong indicator that adding that feature to steamworks.js will do what you want. But if they say "oh, I don't think it can be done" then that says something, too.

@GregAI
Copy link
Author

GregAI commented Mar 4, 2024

Interesting idea! I'm curious if that would work.

I ended up making it a setting in Options to force it one way or another as well as an Auto Detect method that basically works by checking if a 2nd Controller is being actively used (I use navigator.getGamepads() at the moment and not the Steam Input stuff in the API) for a "Steam Deck" player. So if a Steam Deck is being used & a 2nd Controller actively used, then switches the display resolution and treats the 2nd Controller as Controller 1 (since Steam Deck itself is normally controller 1). And of course switch it back to Steam Deck view (1280 x 800) if the Steam Deck Controller is used again.

Not perfect, but it works and is a working solution for now.

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

No branches or pull requests

2 participants