aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorCharles Lombardo <[email protected]>2023-09-25 10:27:09 -0400
committerGitHub <[email protected]>2023-09-25 10:27:09 -0400
commita19f62e636b516b8a4d218f3f7327c16bd70af94 (patch)
tree6dfc48f780ab72abf1e208fcc7fc2a04aa8fdada /src
parent854457a392b6d38168f7f9d19d1fa8c43fad653c (diff)
parent0d7d3d938cf61faa48cbcfcfe61e2143452dd823 (diff)
downloadyuzu-mainline-a19f62e636b516b8a4d218f3f7327c16bd70af94.tar.gz
yuzu-mainline-a19f62e636b516b8a4d218f3f7327c16bd70af94.zip
Merge pull request #11583 from t895/overlay-fix-2
android: Use measured size of view for input overlay bounds
Diffstat (limited to 'src')
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt
index c055c2e35..a13faf3c7 100644
--- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt
+++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt
@@ -352,7 +352,7 @@ class InputOverlay(context: Context, attrs: AttributeSet?) :
}
private fun addOverlayControls(layout: String) {
- val windowSize = getSafeScreenSize(context)
+ val windowSize = getSafeScreenSize(context, Pair(measuredWidth, measuredHeight))
if (preferences.getBoolean(Settings.PREF_BUTTON_A, true)) {
overlayButtons.add(
initializeOverlayButton(
@@ -593,7 +593,7 @@ class InputOverlay(context: Context, attrs: AttributeSet?) :
}
private fun saveControlPosition(prefId: String, x: Int, y: Int, layout: String) {
- val windowSize = getSafeScreenSize(context)
+ val windowSize = getSafeScreenSize(context, Pair(measuredWidth, measuredHeight))
val min = windowSize.first
val max = windowSize.second
PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext).edit()
@@ -968,14 +968,17 @@ class InputOverlay(context: Context, attrs: AttributeSet?) :
* @return A pair of points, the first being the top left corner of the safe area,
* the second being the bottom right corner of the safe area
*/
- private fun getSafeScreenSize(context: Context): Pair<Point, Point> {
+ private fun getSafeScreenSize(
+ context: Context,
+ screenSize: Pair<Int, Int>
+ ): Pair<Point, Point> {
// Get screen size
val windowMetrics = WindowMetricsCalculator.getOrCreate()
.computeCurrentWindowMetrics(context as Activity)
- var maxY = windowMetrics.bounds.height().toFloat()
- var maxX = windowMetrics.bounds.width().toFloat()
- var minY = 0
+ var maxX = screenSize.first.toFloat()
+ var maxY = screenSize.second.toFloat()
var minX = 0
+ var minY = 0
// If we have API access, calculate the safe area to draw the overlay
var cutoutLeft = 0