Enable full screen on resume

* Fix registering of buttons pairs in OSC with multiple fingers
* Enable OSC by default
* Increased OSC scale by default
This commit is contained in:
Willi Ye 2021-02-05 17:37:05 +01:00 committed by ◱ Mark
parent 1fae3488ad
commit 4b53a3b1a6
5 changed files with 35 additions and 24 deletions

View File

@ -194,14 +194,6 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.hide(WindowInsets.Type.navigationBars() or WindowInsets.Type.systemBars() or WindowInsets.Type.systemGestures() or WindowInsets.Type.statusBars()) window.insetsController?.hide(WindowInsets.Type.navigationBars() or WindowInsets.Type.systemBars() or WindowInsets.Type.systemGestures() or WindowInsets.Type.statusBars())
window.insetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE window.insetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
} else {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN)
} }
binding.gameView.holder.addCallback(this) binding.gameView.holder.addCallback(this)
@ -239,6 +231,20 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo
executeApplication(intent.data!!) executeApplication(intent.data!!)
} }
override fun onResume() {
super.onResume()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
@Suppress("DEPRECATION")
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_FULLSCREEN)
}
}
/** /**
* This is used to stop the currently executing ROM and replace it with the one specified in the new intent * This is used to stop the currently executing ROM and replace it with the one specified in the new intent
*/ */

View File

@ -30,7 +30,7 @@ class ControllerConfigurationImpl(private val context : Context, private val but
private inline fun <reified T> config(default : T, prefix : String = "${buttonId.name}_") = sharedPreferences(context, default, prefix, "controller_config") private inline fun <reified T> config(default : T, prefix : String = "${buttonId.name}_") = sharedPreferences(context, default, prefix, "controller_config")
override var enabled by config(true) override var enabled by config(true)
override var globalScale by config(1f, "") override var globalScale by config(1.15f, "")
override var relativeX by config(defaultRelativeX) override var relativeX by config(defaultRelativeX)
override var relativeY by config(defaultRelativeY) override var relativeY by config(defaultRelativeY)
} }

View File

@ -87,16 +87,18 @@ class OnScreenControllerView @JvmOverloads constructor(context : Context, attrs
} }
MotionEvent.ACTION_MOVE -> { MotionEvent.ACTION_MOVE -> {
if (pointerId == button.touchPointerId) { for (fingerId in 0 until event.pointerCount) {
for (buttonPair in controls.buttonPairs) { if (fingerId == button.touchPointerId) {
if (buttonPair.contains(button)) { for (buttonPair in controls.buttonPairs) {
for (otherButton in buttonPair) { if (buttonPair.contains(button)) {
if (otherButton != button && otherButton.config.enabled && otherButton.isTouched(x, y)) { for (otherButton in buttonPair) {
otherButton.partnerPointerId = pointerId if (otherButton != button && otherButton.config.enabled && otherButton.isTouched(event.getX(fingerId), event.getY(fingerId))) {
otherButton.onFingerDown(x, y) otherButton.partnerPointerId = fingerId
performClick() otherButton.onFingerDown(x, y)
onButtonStateChangedListener?.invoke(otherButton.buttonId, ButtonState.Pressed) performClick()
handled = true onButtonStateChangedListener?.invoke(otherButton.buttonId, ButtonState.Pressed)
handled = true
}
} }
} }
} }

View File

@ -94,18 +94,21 @@ class OnScreenEditActivity : AppCompatActivity() {
fabMapping[pair.first] = this fabMapping[pair.first] = this
}) })
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.hide(WindowInsets.Type.navigationBars() or WindowInsets.Type.systemBars() or WindowInsets.Type.systemGestures() or WindowInsets.Type.statusBars())
window.insetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
} }
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
fullScreen() fullScreen()
} }
private fun fullScreen() { private fun fullScreen() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
window.insetsController?.hide(WindowInsets.Type.navigationBars() or WindowInsets.Type.systemBars() or WindowInsets.Type.systemGestures() or WindowInsets.Type.statusBars())
window.insetsController?.systemBarsBehavior = WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
} else {
@Suppress("DEPRECATION") @Suppress("DEPRECATION")
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_STABLE

View File

@ -22,7 +22,7 @@ class Settings(context : Context) {
var operationMode by sharedPreferences(context, true) var operationMode by sharedPreferences(context, true)
var onScreenControl by sharedPreferences(context, false) var onScreenControl by sharedPreferences(context, true)
var onScreenControlRecenterSticks by sharedPreferences(context, true) var onScreenControlRecenterSticks by sharedPreferences(context, true)