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

Change Android Display server DPI #10811

Open
reverseslayer opened this issue Sep 23, 2024 · 1 comment
Open

Change Android Display server DPI #10811

reverseslayer opened this issue Sep 23, 2024 · 1 comment

Comments

@reverseslayer
Copy link

reverseslayer commented Sep 23, 2024

Describe the project you are working on

A multiplayer game where 2 phones will be side by side and I need to reference exact display DPI on android and IOS

Describe the problem or limitation you are having in your project

The current implementation of
public int getScreenDPI()
in the file
platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
only allows for relative DPI

Describe the feature / enhancement and how it helps to overcome the problem or limitation

This would allow the game I am trying to make without having to rebuild from source every update of Godot Engine

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

The version of DPI that i'm using just gets an average of the width DPI and height DPI that android gives you

public int getScreenDPI() { float xDPI = activity.getResources().getDisplayMetrics().xdpi; float yDPI = activity.getResources().getDisplayMetrics().ydpi; return Math.round( (xDPI+yDPI)/2 ); }

and the documentation in
doc/classes/DisplayServer.xml
can have the part where android DPI's are relative can be removed.

If this enhancement will not be used often, can it be worked around with a few lines of script?

The current implementation is not work around-able due to android.permission.DUMP being blocked by default unless for system applications. So unable to get true DPI from the system.

Is there a reason why this should be core and not an add-on in the asset library?

Its a fix of an already existing feature

@reverseslayer
Copy link
Author

I have compiled the modifications into the export templates linked here and it results in accurate DPI returned from android. Ill link it here for anyone who wants to use it. Just copy the 3 android files from the zip to the current version of godot you are using at this reference. PLEASE DO NOT USE THIS IN PRODUCTION.

https://drive.google.com/file/d/10_H6EUC4wv1mSDK83DDHJXon-qeqPgeG/view?usp=sharing

C:\Users\user\AppData\Roaming\Godot\export_templates

@reverseslayer reverseslayer closed this as not planned Won't fix, can't repro, duplicate, stale Sep 23, 2024
@reverseslayer reverseslayer reopened this Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants