mirror of
https://github.com/starr-dusT/yuzu-mainline
synced 2024-03-05 21:12:25 -08:00
Merge pull request #11583 from t895/overlay-fix-2
android: Use measured size of view for input overlay bounds
This commit is contained in:
commit
a19f62e636
@ -352,7 +352,7 @@ class InputOverlay(context: Context, attrs: AttributeSet?) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addOverlayControls(layout: String) {
|
private fun addOverlayControls(layout: String) {
|
||||||
val windowSize = getSafeScreenSize(context)
|
val windowSize = getSafeScreenSize(context, Pair(measuredWidth, measuredHeight))
|
||||||
if (preferences.getBoolean(Settings.PREF_BUTTON_A, true)) {
|
if (preferences.getBoolean(Settings.PREF_BUTTON_A, true)) {
|
||||||
overlayButtons.add(
|
overlayButtons.add(
|
||||||
initializeOverlayButton(
|
initializeOverlayButton(
|
||||||
@ -593,7 +593,7 @@ class InputOverlay(context: Context, attrs: AttributeSet?) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun saveControlPosition(prefId: String, x: Int, y: Int, layout: String) {
|
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 min = windowSize.first
|
||||||
val max = windowSize.second
|
val max = windowSize.second
|
||||||
PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext).edit()
|
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,
|
* @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
|
* 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
|
// Get screen size
|
||||||
val windowMetrics = WindowMetricsCalculator.getOrCreate()
|
val windowMetrics = WindowMetricsCalculator.getOrCreate()
|
||||||
.computeCurrentWindowMetrics(context as Activity)
|
.computeCurrentWindowMetrics(context as Activity)
|
||||||
var maxY = windowMetrics.bounds.height().toFloat()
|
var maxX = screenSize.first.toFloat()
|
||||||
var maxX = windowMetrics.bounds.width().toFloat()
|
var maxY = screenSize.second.toFloat()
|
||||||
var minY = 0
|
|
||||||
var minX = 0
|
var minX = 0
|
||||||
|
var minY = 0
|
||||||
|
|
||||||
// If we have API access, calculate the safe area to draw the overlay
|
// If we have API access, calculate the safe area to draw the overlay
|
||||||
var cutoutLeft = 0
|
var cutoutLeft = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user