android: Fixed Turbo toast appearing in situations other than toggling Turbo

+ minor code cleanup
This commit is contained in:
OpenSauce04 2025-05-09 20:14:23 +01:00 committed by OpenSauce
parent ea8e403f83
commit c204ebf021
4 changed files with 16 additions and 10 deletions

View File

@ -25,7 +25,7 @@ class HotkeyUtility(
Hotkey.CYCLE_LAYOUT.button -> screenAdjustmentUtil.cycleLayouts()
Hotkey.CLOSE_GAME.button -> EmulationLifecycleUtil.closeGame()
Hotkey.PAUSE_OR_RESUME.button -> EmulationLifecycleUtil.pauseOrResume()
Hotkey.TURBO_LIMIT.button -> TurboHelper.setTurboEnabled(!TurboHelper.isTurboSpeedEnabled())
Hotkey.TURBO_LIMIT.button -> TurboHelper.toggleTurbo(true)
Hotkey.QUICKSAVE.button -> {
NativeLibrary.saveState(NativeLibrary.QUICKSAVE_SLOT)
Toast.makeText(context,

View File

@ -67,7 +67,7 @@ class SettingsActivityPresenter(private val activityView: SettingsActivityView)
//added to ensure that layout changes take effect as soon as settings window closes
NativeLibrary.reloadSettings()
NativeLibrary.updateFramebuffer(NativeLibrary.isPortraitMode)
TurboHelper.reloadTurbo() // TODO: Can this go someone else? -OS
TurboHelper.reloadTurbo(false) // TODO: Can this go somewhere else? -OS
}
NativeLibrary.reloadSettings()
}

View File

@ -107,7 +107,7 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
}
if (button.id == NativeLibrary.ButtonType.BUTTON_TURBO && button.status == NativeLibrary.ButtonState.PRESSED) {
TurboHelper.setTurboEnabled((!TurboHelper.isTurboSpeedEnabled()))
TurboHelper.toggleTurbo(true)
}
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.id, button.status)

View File

@ -17,12 +17,7 @@ object TurboHelper {
return turboSpeedEnabled
}
fun setTurboEnabled(state: Boolean) {
turboSpeedEnabled = state
reloadTurbo()
}
fun reloadTurbo() {
fun reloadTurbo(showToast: Boolean) {
val context = CitraApplication.appContext
val toastMessage: String
@ -34,6 +29,17 @@ object TurboHelper {
toastMessage = context.getString(R.string.turbo_disabled_toast)
}
Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show()
if (showToast) {
Toast.makeText(context, toastMessage, Toast.LENGTH_SHORT).show()
}
}
fun setTurboEnabled(state: Boolean, showToast: Boolean) {
turboSpeedEnabled = state
reloadTurbo(showToast)
}
fun toggleTurbo(showToast: Boolean) {
setTurboEnabled(!TurboHelper.isTurboSpeedEnabled(), showToast)
}
}