mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 21:06:58 -05:00
android: Add toggle controls option to input overlay
This commit is contained in:
parent
8b99a1e49b
commit
1ea84854bd
5 changed files with 62 additions and 6 deletions
|
@ -21,6 +21,7 @@ import androidx.core.view.WindowInsetsCompat
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.preference.PreferenceManager
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import org.yuzu.yuzu_emu.NativeLibrary
|
||||
import org.yuzu.yuzu_emu.R
|
||||
import org.yuzu.yuzu_emu.YuzuApplication
|
||||
|
@ -30,12 +31,8 @@ import org.yuzu.yuzu_emu.features.settings.model.Settings
|
|||
import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity
|
||||
import org.yuzu.yuzu_emu.features.settings.utils.SettingsFile
|
||||
import org.yuzu.yuzu_emu.model.Game
|
||||
import org.yuzu.yuzu_emu.utils.DirectoryInitialization
|
||||
import org.yuzu.yuzu_emu.utils.*
|
||||
import org.yuzu.yuzu_emu.utils.DirectoryInitialization.DirectoryInitializationState
|
||||
import org.yuzu.yuzu_emu.utils.DirectoryStateReceiver
|
||||
import org.yuzu.yuzu_emu.utils.EmulationMenuSettings
|
||||
import org.yuzu.yuzu_emu.utils.InsetsHelper
|
||||
import org.yuzu.yuzu_emu.utils.Log
|
||||
import org.yuzu.yuzu_emu.utils.SerializableHelper.parcelable
|
||||
|
||||
class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.FrameCallback {
|
||||
|
@ -281,6 +278,35 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
|
|||
startConfiguringControls()
|
||||
true
|
||||
}
|
||||
R.id.menu_toggle_controls -> {
|
||||
val preferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||
val optionsArray = BooleanArray(15)
|
||||
for (i in 0..14) {
|
||||
optionsArray[i] = preferences.getBoolean("buttonToggle$i", i < 13)
|
||||
}
|
||||
|
||||
MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(R.string.emulation_toggle_controls)
|
||||
.setMultiChoiceItems(
|
||||
R.array.gamepadButtons,
|
||||
optionsArray
|
||||
) { _, indexSelected, isChecked ->
|
||||
preferences.edit()
|
||||
.putBoolean("buttonToggle$indexSelected", isChecked)
|
||||
.commit()
|
||||
}
|
||||
.setPositiveButton(android.R.string.ok) { _, _ ->
|
||||
refreshInputOverlay()
|
||||
}
|
||||
.setNeutralButton(R.string.emulation_toggle_all) { _, _ ->
|
||||
EmulationMenuSettings.showOverlay = !EmulationMenuSettings.showOverlay
|
||||
refreshInputOverlay()
|
||||
}
|
||||
.show()
|
||||
|
||||
true
|
||||
}
|
||||
R.id.menu_reset_overlay -> {
|
||||
binding.drawerLayout.close()
|
||||
resetInputOverlay()
|
||||
|
|
|
@ -57,6 +57,6 @@ object EmulationMenuSettings {
|
|||
set(value) {
|
||||
preferences.edit()
|
||||
.putBoolean(Settings.PREF_MENU_SETTINGS_SHOW_OVERLAY, value)
|
||||
.apply()
|
||||
.commit()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
android:id="@+id/menu_edit_overlay"
|
||||
android:title="@string/emulation_touch_overlay_edit" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_toggle_controls"
|
||||
android:title="@string/emulation_toggle_controls" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_reset_overlay"
|
||||
android:title="@string/emulation_touch_overlay_reset" />
|
||||
|
|
|
@ -135,4 +135,22 @@
|
|||
<item>3</item>
|
||||
</integer-array>
|
||||
|
||||
<string-array name="gamepadButtons">
|
||||
<item>A</item>
|
||||
<item>B</item>
|
||||
<item>X</item>
|
||||
<item>Y</item>
|
||||
<item>L</item>
|
||||
<item>R</item>
|
||||
<item>ZL</item>
|
||||
<item>ZR</item>
|
||||
<item>+</item>
|
||||
<item>-</item>
|
||||
<item>@string/gamepad_d_pad</item>
|
||||
<item>@string/gamepad_left_stick</item>
|
||||
<item>@string/gamepad_right_stick</item>
|
||||
<item>@string/gamepad_home</item>
|
||||
<item>@string/gamepad_screenshot</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
<string name="emulation_exit">Exit Emulation</string>
|
||||
<string name="emulation_done">Done</string>
|
||||
<string name="emulation_toggle_controls">Toggle Controls</string>
|
||||
<string name="emulation_toggle_all">Toggle All</string>
|
||||
<string name="emulation_control_scale">Adjust Scale</string>
|
||||
<string name="emulation_touch_overlay_reset">Reset Overlay</string>
|
||||
<string name="emulation_touch_overlay_edit">Edit Overlay</string>
|
||||
|
@ -173,4 +174,11 @@
|
|||
<string name="cpu_accuracy_unsafe">Unsafe</string>
|
||||
<string name="cpu_accuracy_paranoid">Paranoid (Slow)</string>
|
||||
|
||||
<!-- Gamepad Buttons -->
|
||||
<string name="gamepad_d_pad">D-Pad</string>
|
||||
<string name="gamepad_left_stick">Left Stick</string>
|
||||
<string name="gamepad_right_stick">Right Stick</string>
|
||||
<string name="gamepad_home">Home</string>
|
||||
<string name="gamepad_screenshot">Screenshot</string>
|
||||
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue