summaryrefslogtreecommitdiff
path: root/Source/Android
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2021-07-23 13:04:16 +0200
committerJosJuice <josjuice@gmail.com>2021-07-23 13:16:27 +0200
commit3accb06fe1ae18b0769bca2cb4f93be1ff3ee6e7 (patch)
tree95984638010047757c47fa74c6c0e7b7f15d600c /Source/Android
parentf380c23fda9fd1b45e458551a8dd1aa9ae60db0a (diff)
Android: Allow non-square overlay control images
This removes an assumption in the code which made every overlay control image be scaled to a square even if the actual image was rectangular.
Diffstat (limited to 'Source/Android')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java
index 5b3b232af4..1e7cb81b77 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java
@@ -102,11 +102,14 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Determine the button size based on the smaller screen dimension.
// This makes sure the buttons are the same size in both portrait and landscape.
DisplayMetrics dm = context.getResources().getDisplayMetrics();
- int minDimension = Math.min(dm.widthPixels, dm.heightPixels);
+ int minScreenDimension = Math.min(dm.widthPixels, dm.heightPixels);
+
+ int maxBitmapDimension = Math.max(bitmap.getWidth(), bitmap.getHeight());
+ float bitmapScale = scale * minScreenDimension / maxBitmapDimension;
return Bitmap.createScaledBitmap(bitmap,
- (int) (minDimension * scale),
- (int) (minDimension * scale),
+ (int) (bitmap.getWidth() * bitmapScale),
+ (int) (bitmap.getHeight() * bitmapScale),
true);
}