Search Unity

Check if running on Steam Deck

Discussion in 'General Discussion' started by kloot, Apr 13, 2022.

  1. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    78
    Hi there,
    I don't have a Steam Deck dev-kit, but my game does run on that platform. However, I can't seem to find a way to (in runtime) distinguish if the game is currently running on Linux or the Steam Deck. Usually one would check Application.platform, but even in 2021.3, there is no enum value for the SteamDeck...

    Any ideas?

    Thanks!
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,571
    Logically speaking steam deck is Linux.

    A good idea would be to contact valve support and ask them this question.

    You could also try poking /proc at runtime to determine CPU type, as it is supposed to be a fairly custom one.
     
  3. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,076
  4. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    78
    Thank you, no info about this question there, tho.
    I also asked on the Steamworks forum, will post here if I get an answer.
     
  5. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,076
    Ah, I hoped something would pop up there on the topic. I haven't gone through the material yet.

    My deck is on its way, but it's retail. I hear all devkit related content is publicly available so hopefully it won't lack much on dev side of things.
     
  6. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    78
    The folks at Steam answered
    Al long as you have a reference to Steamworks, you can check Steamworks.SteamUtils.IsSteamRunningOnSteamDeck();
     
  7. Jinja

    Jinja

    Joined:
    Nov 28, 2012
    Posts:
    10
    You could also place an option in your user options section for whatever reason you need to know if it's on Steam Deck. I'm guessing because you want to alter your UI for a small screen. You could add a "Small Screen UI" checkbox in your graphics options which would be useful for anyone who is running your software on a small screen, not just Steam Deck users. Autodetecting Steamdeck can set the default value.
     
    Linkupdated likes this.
  8. sarahnorthway

    sarahnorthway

    Joined:
    Jul 16, 2015
    Posts:
    78
    I don't know about Windows games running on Steam Deck, but my Linux-native build reports this metadata:

    Code (CSharp):
    1. SystemInfo.DeviceModel: PC
    2. SystemInfo.DeviceType: Desktop
    3. Application.platform: LinuxPlayer
    4. SystemInfo.OperatingSystem: Linux 5.13 SteamOS 3.3.1 64bit
    5. SystemInfo.OperatingSystemFamily: Linux
    6. Input.GetJoystickNames(): Steam Virtual Gamepad
    So I'm using SystemInfo.operatingSystem.Contains("SteamOS") if I need to know the device before Steamworks.NET initializes.

    After that I use Steamworks.SteamUtils.IsSteamRunningOnSteamDeck();
     
    Noisecrime, Bovine, DoDoot and 6 others like this.
  9. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,260
    Was going to look into this as I've just received my steam deck
     
  10. astracat111

    astracat111

    Joined:
    Sep 21, 2016
    Posts:
    725
    Official Steam documentation is here:

    https://partner.steamgames.com/doc/api/ISteamUtils

    According to Steam's readme.txt that comes with the Steamworks API:

    Code (CSharp):
    1. v1.52 14th September 2021
    2. ISteamUtils
    3. * Added IsSteamRunningOnSteamDeck - Can be used to optimize the experience of the game on Steam Deck, such as scaling the UI appropriately, applying performance related settings, etc.
    You can download the Steamworks API here:
    https://partner.steamgames.com/doc/gettingstarted

    Luckily, the Steamworks.NET thing is version 1.55 of Steam, so gonna try that out and report back here on how it goes:
    https://github.com/rlabrecque/Steamworks.NET/releases

    Right now my build for Linux is working perfectly on the Steam Deck, flawlessly even, all that's left is to add the inputs using the Steam API. ¯\_(ツ)_/¯
     
    Last edited: Dec 29, 2022
    FuriousEX and Deadcow_ like this.
  11. GameMechanics

    GameMechanics

    Joined:
    Jul 15, 2013
    Posts:
    57
    The only reason I want to do it is because they map the controls to keys and it looks bad if they press the dpad and it says they pressed the 'P' key. Plus I check for 'P' key in my code to 'Pause' but don't want to if it is really the dpad. The mix of keyboard/mouse, controller and touch interfaces just make set up complex.
     
  12. krupps

    krupps

    Joined:
    Oct 17, 2017
    Posts:
    159
    Its actually easy with the Player Input component
     
    Bovine likes this.