adapt auto hide setting for spinbox

This commit is contained in:
nyx-ynx 2025-09-27 19:18:31 +02:00 committed by crueter
parent 3603240b8a
commit 6b53bf3c5b
6 changed files with 32 additions and 17 deletions

View file

@ -55,6 +55,8 @@ enum class BooleanSetting(override val key: String) : AbstractBooleanSetting {
FRAME_INTERPOLATION("frame_interpolation"),
// FRAME_SKIPPING("frame_skipping"),
ENABLE_INPUT_OVERLAY_AUTO_HIDE("enable_input_overlay_auto_hide"),
PERF_OVERLAY_BACKGROUND("perf_overlay_background"),
SHOW_PERFORMANCE_OVERLAY("show_performance_overlay"),

View file

@ -387,12 +387,18 @@ abstract class SettingsItem(
)
)
put(
SingleChoiceSetting(
SwitchSetting(
BooleanSetting.ENABLE_INPUT_OVERLAY_AUTO_HIDE,
titleId = R.string.enable_input_overlay_auto_hide,
)
)
put(
SpinBoxSetting(
IntSetting.INPUT_OVERLAY_AUTO_HIDE,
titleId = R.string.overlay_auto_hide,
descriptionId = R.string.overlay_auto_hide_description,
choicesId = R.array.overlayAutoHideEntries,
valuesId = R.array.overlayAutoHideValues,
min = 1,
max = 999
)
)

View file

@ -275,6 +275,7 @@ class SettingsFragmentPresenter(
private fun addInputOverlaySettings(sl: ArrayList<SettingsItem>) {
sl.apply {
add(BooleanSetting.ENABLE_INPUT_OVERLAY_AUTO_HIDE.key)
add(IntSetting.INPUT_OVERLAY_AUTO_HIDE.key)
}
}

View file

@ -1750,20 +1750,20 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
}, seconds * 1000L)
}
fun handleScreenTap(isLongTap: Boolean) {
val autoHideSeconds = IntSetting.INPUT_OVERLAY_AUTO_HIDE.getInt()
val shouldProceed = BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean() && BooleanSetting.ENABLE_INPUT_OVERLAY_AUTO_HIDE.getBoolean()
if (!BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean()) {
if (!shouldProceed) {
return
}
// failsafe
if (autoHideSeconds == 0) {
showOverlay()
return
}
// Show overlay for quick taps when it's hidden
if (!isOverlayVisible && !isLongTap) {
showOverlay()
}
@ -1773,11 +1773,12 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
private fun initializeOverlayAutoHide() {
val autoHideSeconds = IntSetting.INPUT_OVERLAY_AUTO_HIDE.getInt()
if (autoHideSeconds > 0) {
handler.postDelayed({
// since the timer starts only after touch input, we need to always force hide it
hideOverlay()
}, autoHideSeconds * 1000L)
val autoHideEnabled = BooleanSetting.ENABLE_INPUT_OVERLAY_AUTO_HIDE.getBoolean()
val showOverlay = BooleanSetting.SHOW_INPUT_OVERLAY.getBoolean()
if (autoHideEnabled && showOverlay) {
showOverlay()
startOverlayAutoHideTimer(autoHideSeconds)
}
}

View file

@ -79,10 +79,15 @@ namespace AndroidSettings {
Settings::Category::Overlay,
Settings::Specialization::Paired, true,
true};
Settings::Setting<u32> input_overlay_auto_hide{linkage, 0, "input_overlay_auto_hide",
Settings::Setting<bool> enable_input_overlay_auto_hide{linkage, false,
"enable_input_overlay_auto_hide",
Settings::Category::Overlay,
Settings::Specialization::Default, true, true,};
Settings::Specialization::Default, true,
true,};
Settings::Setting<u32> input_overlay_auto_hide{linkage, 5, "input_overlay_auto_hide",
Settings::Category::Overlay,
Settings::Specialization::Default, true, true, &enable_input_overlay_auto_hide};
Settings::Setting<bool> perf_overlay_background{linkage, false, "perf_overlay_background",
Settings::Category::Overlay,
Settings::Specialization::Default, true,

View file

@ -24,8 +24,8 @@
<!-- Input Overlay -->
<string name="overlay_auto_hide">Overlay Auto Hide</string>
<string name="overlay_auto_hide_description">Automatically hide the touch controls overlay after the specified time of inactivity. Select "Never" to keep the overlay always visible.</string>
<string name="overlay_auto_hide_description">Automatically hide the touch controls overlay after the specified time of inactivity.</string>
<string name="enable_input_overlay_auto_hide">Enable Overlay Auto Hide</string>
<string name="overlay_auto_hide_never">Never</string>
<string name="overlay_auto_hide_instant">Instantly</string>
<string name="overlay_auto_hide_5s">5 seconds</string>