Skip to content

Commit

Permalink
cmd/ebitenmobile, internal/devicescale: Experimental fix of the displ…
Browse files Browse the repository at this point in the history
…ay density

Closes hajimehoshi#1481
  • Loading branch information
hajimehoshi committed Feb 7, 2021
1 parent 19b3735 commit 9db2017
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 15 deletions.
9 changes: 8 additions & 1 deletion cmd/ebitenmobile/gobind.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,18 +338,25 @@ import android.hardware.input.InputManager;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
import android.view.InputDevice;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.view.WindowManager;
import {{.JavaPkg}}.ebitenmobileview.Ebitenmobileview;
public class EbitenView extends ViewGroup implements InputManager.InputDeviceListener {
private double getDeviceScale() {
if (this.deviceScale == 0.0) {
this.deviceScale = getResources().getDisplayMetrics().density;
WindowManager windowManager = (WindowManager)getContext().getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
DisplayMetrics displayMetrics = new DisplayMetrics();
display.getRealMetrics(displayMetrics);
this.deviceScale = displayMetrics.density;
}
return this.deviceScale;
}
Expand Down
Loading

0 comments on commit 9db2017

Please sign in to comment.