v3.1.0: improved the weird steam deck reported display dimensions test
This commit is contained in:
@@ -100,15 +100,15 @@ public class Game implements ApplicationListener {
|
|||||||
if (density == Float.POSITIVE_INFINITY){
|
if (density == Float.POSITIVE_INFINITY){
|
||||||
density = 100f / 160f; //assume 100PPI if density can't be found
|
density = 100f / 160f; //assume 100PPI if density can't be found
|
||||||
} else if (DeviceCompat.isDesktop()) {
|
} else if (DeviceCompat.isDesktop()) {
|
||||||
float PpiX = Gdx.graphics.getPpiX();
|
float reportedWidth = dispWidth / Gdx.graphics.getPpiX();
|
||||||
float PpiY = Gdx.graphics.getPpiY();
|
float reportedHeight = dispHeight / Gdx.graphics.getPpiY();
|
||||||
|
|
||||||
//this exists because Steam deck reports its display size as 4"x6.3" for some reason
|
//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.
|
// 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
|
// So we check that the orientation of the resolution and the display dimensions match.
|
||||||
if (PpiX / PpiY > 1.1f || PpiX / PpiY < 0.9f ){
|
// If they don't, re-calculate density assuming reported dimensions are flipped.
|
||||||
float reportedDisplayHeightInches = dispHeight / PpiY; //it's actually the width
|
if (dispWidth > dispHeight != reportedWidth > reportedHeight){
|
||||||
float realPpiX = dispWidth / reportedDisplayHeightInches;
|
float realPpiX = dispWidth / reportedHeight;
|
||||||
density = realPpiX / 160f;
|
density = realPpiX / 160f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user