diff --git a/SPD-classes/src/main/java/com/watabou/noosa/Game.java b/SPD-classes/src/main/java/com/watabou/noosa/Game.java index 5289d67c9..7d95a5685 100644 --- a/SPD-classes/src/main/java/com/watabou/noosa/Game.java +++ b/SPD-classes/src/main/java/com/watabou/noosa/Game.java @@ -93,12 +93,25 @@ public class Game implements ApplicationListener { @Override public void create() { + dispHeight = Gdx.graphics.getDisplayMode().height; + dispWidth = Gdx.graphics.getDisplayMode().width; + density = Gdx.graphics.getDensity(); if (density == Float.POSITIVE_INFINITY){ density = 100f / 160f; //assume 100PPI if density can't be found + } else if (DeviceCompat.isDesktop()) { + float PpiX = Gdx.graphics.getPpiX(); + float PpiY = Gdx.graphics.getPpiY(); + + //this exists because Steam deck reports its display size as 4"x6.3" for some reason + // as if in portrait, instead of 6.3"x4". This results in incorrect PPI measurements. + // So when the PPIs differ, we assume reported display size is flipped and adjust + if (PpiX / PpiY > 1.1f || PpiX / PpiY < 0.9f ){ + float reportedDisplayHeightInches = dispHeight / PpiY; //it's actually the width + float realPpiX = dispWidth / reportedDisplayHeightInches; + density = realPpiX / 160f; + } } - dispHeight = Gdx.graphics.getDisplayMode().height; - dispWidth = Gdx.graphics.getDisplayMode().width; inputHandler = new InputHandler( Gdx.input ); if (ControllerHandler.controllersSupported()){