mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-04-21 10:51:35 -06:00
Turbo Hold button for android
This commit is contained in:
parent
39363cd435
commit
be3125105a
@ -11,6 +11,7 @@ enum class Hotkey(val button: Int) {
|
||||
PAUSE_OR_RESUME(10004),
|
||||
QUICKSAVE(10005),
|
||||
QUICKLOAD(10006),
|
||||
TURBO_LIMIT(10007),
|
||||
ENABLE(10008);
|
||||
TURBO_TOGGLE(10007),
|
||||
ENABLE(10008),
|
||||
TURBO_HOLD(10009);
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import org.citra.citra_emu.utils.TurboHelper
|
||||
import org.citra.citra_emu.display.ScreenAdjustmentUtil
|
||||
import org.citra.citra_emu.features.settings.model.view.InputBindingSetting
|
||||
import org.citra.citra_emu.features.settings.model.Settings
|
||||
import org.citra.citra_emu.utils.Log
|
||||
|
||||
class HotkeyUtility(
|
||||
private val screenAdjustmentUtil: ScreenAdjustmentUtil,
|
||||
@ -40,6 +41,7 @@ class HotkeyUtility(
|
||||
|
||||
// Now process all internal buttons associated with this keypress
|
||||
for (button in buttonSet) {
|
||||
Log.debug("Button pressed: " + button)
|
||||
currentlyPressedButtons.add(button)
|
||||
//option 1 - this is the enable command, which was already handled
|
||||
if (button == Hotkey.ENABLE.button) {
|
||||
@ -78,9 +80,11 @@ class HotkeyUtility(
|
||||
}
|
||||
|
||||
for (button in buttonSet) {
|
||||
Log.debug("Button released: " + button)
|
||||
// this is a hotkey button
|
||||
if (hotkeyButtons.contains(button)) {
|
||||
currentlyPressedButtons.remove(button)
|
||||
handleHotkeyRelease(button)
|
||||
if (!currentlyPressedButtons.any { hotkeyButtons.contains(it) }) {
|
||||
// all hotkeys are no longer pressed
|
||||
hotkeyIsPressed = false
|
||||
@ -106,13 +110,23 @@ class HotkeyUtility(
|
||||
return handled
|
||||
}
|
||||
|
||||
fun handleHotkeyRelease(bindedButton: Int): Boolean {
|
||||
Log.debug("Handling hotkey button release: " + bindedButton)
|
||||
if (bindedButton == Hotkey.TURBO_HOLD.button) {
|
||||
TurboHelper.setTurboEnabled(false, false)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun handleHotkey(bindedButton: Int): Boolean {
|
||||
Log.debug("Handling hotkey button press: " + bindedButton)
|
||||
when (bindedButton) {
|
||||
Hotkey.SWAP_SCREEN.button -> screenAdjustmentUtil.swapScreen()
|
||||
Hotkey.CYCLE_LAYOUT.button -> screenAdjustmentUtil.cycleLayouts()
|
||||
Hotkey.CLOSE_GAME.button -> EmulationLifecycleUtil.closeGame()
|
||||
Hotkey.PAUSE_OR_RESUME.button -> EmulationLifecycleUtil.pauseOrResume()
|
||||
Hotkey.TURBO_LIMIT.button -> TurboHelper.toggleTurbo(true)
|
||||
Hotkey.TURBO_TOGGLE.button -> TurboHelper.toggleTurbo(true)
|
||||
Hotkey.TURBO_HOLD.button -> TurboHelper.setTurboEnabled(true, false)
|
||||
Hotkey.QUICKSAVE.button -> {
|
||||
NativeLibrary.saveState(NativeLibrary.QUICKSAVE_SLOT)
|
||||
Toast.makeText(
|
||||
|
||||
@ -143,7 +143,8 @@ class Settings {
|
||||
const val HOTKEY_PAUSE_OR_RESUME = "hotkey_pause_or_resume_game"
|
||||
const val HOTKEY_QUICKSAVE = "hotkey_quickload"
|
||||
const val HOTKEY_QUICKlOAD = "hotkey_quickpause"
|
||||
const val HOTKEY_TURBO_LIMIT = "hotkey_turbo_limit"
|
||||
const val HOTKEY_TURBO_TOGGLE = "hotkey_turbo_limit"
|
||||
const val HOTKEY_TURBO_HOLD = "hotkey_turbo_hold"
|
||||
|
||||
val buttonKeys = listOf(
|
||||
KEY_BUTTON_A,
|
||||
@ -211,7 +212,8 @@ class Settings {
|
||||
HOTKEY_PAUSE_OR_RESUME,
|
||||
HOTKEY_QUICKSAVE,
|
||||
HOTKEY_QUICKlOAD,
|
||||
HOTKEY_TURBO_LIMIT
|
||||
HOTKEY_TURBO_TOGGLE,
|
||||
HOTKEY_TURBO_HOLD
|
||||
)
|
||||
val hotkeyTitles = listOf(
|
||||
R.string.controller_hotkey_enable_button,
|
||||
@ -221,7 +223,8 @@ class Settings {
|
||||
R.string.emulation_toggle_pause,
|
||||
R.string.emulation_quicksave,
|
||||
R.string.emulation_quickload,
|
||||
R.string.turbo_limit_hotkey
|
||||
R.string.turbo_limit_hotkey,
|
||||
R.string.turbo_hold_hotkey
|
||||
)
|
||||
|
||||
// TODO: Move these in with the other setting keys in GenerateSettingKeys.cmake
|
||||
|
||||
@ -136,7 +136,8 @@ class InputBindingSetting(
|
||||
Settings.HOTKEY_PAUSE_OR_RESUME -> Hotkey.PAUSE_OR_RESUME.button
|
||||
Settings.HOTKEY_QUICKSAVE -> Hotkey.QUICKSAVE.button
|
||||
Settings.HOTKEY_QUICKlOAD -> Hotkey.QUICKLOAD.button
|
||||
Settings.HOTKEY_TURBO_LIMIT -> Hotkey.TURBO_LIMIT.button
|
||||
Settings.HOTKEY_TURBO_TOGGLE -> Hotkey.TURBO_TOGGLE.button
|
||||
Settings.HOTKEY_TURBO_HOLD -> Hotkey.TURBO_HOLD.button
|
||||
else -> -1
|
||||
}
|
||||
|
||||
|
||||
@ -164,7 +164,8 @@
|
||||
<string name="button_zr" translatable="false">ZR</string>
|
||||
<string name="input_message_analog_only">This control must be bound to a gamepad analog stick or D-pad axis!</string>
|
||||
<string name="input_message_button_only">This control must be bound to a gamepad button!</string>
|
||||
<string name="turbo_limit_hotkey">Turbo Speed</string>
|
||||
<string name="turbo_limit_hotkey">Turbo (Toggle)</string>
|
||||
<string name="turbo_hold_hotkey">Turbo (Hold)</string>
|
||||
<string name="turbo_enabled_toast">Turbo Speed Enabled</string>
|
||||
<string name="turbo_disabled_toast">Turbo Speed Disabled</string>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user