android: Initialize defaults for each orientations
This commit is contained in:
parent
f34535f362
commit
e20c4fbbd4
|
@ -26,6 +26,8 @@ CMakeSettings.json
|
|||
# OSX global filetypes
|
||||
# Created by Finder or Spotlight in directories for various OS functionality (indexing, etc)
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
.Spotlight-V100
|
||||
|
|
|
@ -256,34 +256,50 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
private fun PictureInPictureParams.Builder.getPictureInPictureAspectBuilder() : PictureInPictureParams.Builder {
|
||||
private fun PictureInPictureParams.Builder.getPictureInPictureAspectBuilder(): PictureInPictureParams.Builder {
|
||||
val aspectRatio = when (IntSetting.RENDERER_ASPECT_RATIO.int) {
|
||||
0 -> Rational(16, 9)
|
||||
1 -> Rational(4, 3)
|
||||
2 -> Rational(21, 9)
|
||||
3 -> Rational(16, 10)
|
||||
else -> null
|
||||
else -> null // Best fit
|
||||
}
|
||||
return this.apply { aspectRatio?.let { setAspectRatio(it) } }
|
||||
}
|
||||
|
||||
private fun PictureInPictureParams.Builder.getPictureInPictureActionsBuilder() : PictureInPictureParams.Builder {
|
||||
val pictureInPictureActions : MutableList<RemoteAction> = mutableListOf()
|
||||
private fun PictureInPictureParams.Builder.getPictureInPictureActionsBuilder(): PictureInPictureParams.Builder {
|
||||
val pictureInPictureActions: MutableList<RemoteAction> = mutableListOf()
|
||||
val pendingFlags = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
|
||||
if (NativeLibrary.isPaused()) {
|
||||
val playIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_play)
|
||||
val playPendingIntent = PendingIntent.getBroadcast(
|
||||
this@EmulationActivity, R.drawable.ic_pip_play, Intent(actionPlay), pendingFlags
|
||||
this@EmulationActivity,
|
||||
R.drawable.ic_pip_play,
|
||||
Intent(actionPlay),
|
||||
pendingFlags
|
||||
)
|
||||
val playRemoteAction = RemoteAction(
|
||||
playIcon,
|
||||
getString(R.string.play),
|
||||
getString(R.string.play),
|
||||
playPendingIntent
|
||||
)
|
||||
val playRemoteAction = RemoteAction(playIcon, getString(R.string.play), getString(R.string.play), playPendingIntent)
|
||||
pictureInPictureActions.add(playRemoteAction)
|
||||
} else {
|
||||
val pauseIcon = Icon.createWithResource(this@EmulationActivity, R.drawable.ic_pip_pause)
|
||||
val pausePendingIntent = PendingIntent.getBroadcast(
|
||||
this@EmulationActivity, R.drawable.ic_pip_pause, Intent(actionPause), pendingFlags
|
||||
this@EmulationActivity,
|
||||
R.drawable.ic_pip_pause,
|
||||
Intent(actionPause),
|
||||
pendingFlags
|
||||
)
|
||||
val pauseRemoteAction = RemoteAction(
|
||||
pauseIcon,
|
||||
getString(R.string.pause),
|
||||
getString(R.string.pause),
|
||||
pausePendingIntent
|
||||
)
|
||||
val pauseRemoteAction = RemoteAction(pauseIcon, getString(R.string.pause), getString(R.string.pause), pausePendingIntent)
|
||||
pictureInPictureActions.add(pauseRemoteAction)
|
||||
}
|
||||
|
||||
|
@ -300,7 +316,7 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||
}
|
||||
|
||||
private var pictureInPictureReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context : Context?, intent : Intent) {
|
||||
override fun onReceive(context: Context?, intent: Intent) {
|
||||
if (intent.action == actionPlay) {
|
||||
if (NativeLibrary.isPaused()) NativeLibrary.unPauseEmulation()
|
||||
} else if (intent.action == actionPause) {
|
||||
|
@ -310,7 +326,10 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean, newConfig: Configuration) {
|
||||
override fun onPictureInPictureModeChanged(
|
||||
isInPictureInPictureMode: Boolean,
|
||||
newConfig: Configuration
|
||||
) {
|
||||
super.onPictureInPictureModeChanged(isInPictureInPictureMode, newConfig)
|
||||
if (isInPictureInPictureMode) {
|
||||
IntentFilter().apply {
|
||||
|
@ -322,7 +341,8 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener {
|
|||
} else {
|
||||
try {
|
||||
unregisterReceiver(pictureInPictureReceiver)
|
||||
} catch (ignored : Exception) { }
|
||||
} catch (ignored : Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -143,11 +143,7 @@ class Settings {
|
|||
|
||||
private val configFileSectionsMap: MutableMap<String, List<String>> = HashMap()
|
||||
|
||||
// These must match what is defined in src/core/settings.h
|
||||
const val LayoutOption_Default = 0
|
||||
const val LayoutOption_SingleScreen = 1
|
||||
const val LayoutOption_LargeScreen = 2
|
||||
const val LayoutOption_SideScreen = 3
|
||||
const val LayoutOption_Unspecified = 0
|
||||
const val LayoutOption_MobilePortrait = 4
|
||||
const val LayoutOption_MobileLandscape = 5
|
||||
|
||||
|
|
|
@ -241,7 +241,12 @@ class SettingsActivity : AppCompatActivity(), SettingsActivityView {
|
|||
context.startActivity(settings)
|
||||
}
|
||||
|
||||
fun launch(context: Context, launcher: ActivityResultLauncher<Intent>, menuTag: String?, gameId: String?) {
|
||||
fun launch(
|
||||
context: Context,
|
||||
launcher: ActivityResultLauncher<Intent>,
|
||||
menuTag: String?,
|
||||
gameId: String?
|
||||
) {
|
||||
val settings = Intent(context, SettingsActivity::class.java)
|
||||
settings.putExtra(ARG_MENU_TAG, menuTag)
|
||||
settings.putExtra(ARG_GAME_ID, gameId)
|
||||
|
|
|
@ -34,7 +34,6 @@ import androidx.fragment.app.Fragment
|
|||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.navigation.fragment.navArgs
|
||||
import androidx.preference.PreferenceManager
|
||||
import androidx.window.layout.FoldingFeature
|
||||
import androidx.window.layout.WindowInfoTracker
|
||||
|
@ -165,7 +164,10 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
|||
|
||||
R.id.menu_settings -> {
|
||||
SettingsActivity.launch(
|
||||
requireContext(), onReturnFromSettings, SettingsFile.FILE_NAME_CONFIG, ""
|
||||
requireContext(),
|
||||
onReturnFromSettings,
|
||||
SettingsFile.FILE_NAME_CONFIG,
|
||||
""
|
||||
)
|
||||
true
|
||||
}
|
||||
|
@ -219,9 +221,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
|||
}
|
||||
if (!isInFoldableLayout) {
|
||||
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
binding.surfaceInputOverlay.setOrientation(InputOverlay.PORTRAIT)
|
||||
binding.surfaceInputOverlay.orientation = InputOverlay.PORTRAIT
|
||||
} else {
|
||||
binding.surfaceInputOverlay.setOrientation(InputOverlay.LANDSCAPE)
|
||||
binding.surfaceInputOverlay.orientation = InputOverlay.LANDSCAPE
|
||||
}
|
||||
}
|
||||
if (!binding.surfaceInputOverlay.isInEditMode) {
|
||||
|
@ -311,17 +313,11 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
|||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
private fun updateScreenLayout() {
|
||||
emulationActivity?.let {
|
||||
when (IntSetting.RENDERER_SCREEN_LAYOUT.int) {
|
||||
Settings.LayoutOption_MobileLandscape -> {
|
||||
it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||
}
|
||||
Settings.LayoutOption_MobilePortrait -> {
|
||||
it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
}
|
||||
Settings.LayoutOption_Default -> {
|
||||
it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||
}
|
||||
else -> { it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE }
|
||||
it.requestedOrientation = when (IntSetting.RENDERER_SCREEN_LAYOUT.int) {
|
||||
Settings.LayoutOption_MobileLandscape -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||
Settings.LayoutOption_MobilePortrait -> ActivityInfo.SCREEN_ORIENTATION_USER_PORTRAIT
|
||||
Settings.LayoutOption_Unspecified -> ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||
else -> ActivityInfo.SCREEN_ORIENTATION_USER_LANDSCAPE
|
||||
}
|
||||
}
|
||||
onConfigurationChanged(resources.configuration)
|
||||
|
@ -337,7 +333,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
|||
binding.overlayContainer.layoutParams.height = it.bounds.bottom
|
||||
binding.inGameMenu.layoutParams.height = it.bounds.bottom
|
||||
isInFoldableLayout = true
|
||||
binding.surfaceInputOverlay.setOrientation(InputOverlay.FOLDABLE)
|
||||
binding.surfaceInputOverlay.orientation = InputOverlay.FOLDABLE
|
||||
refreshInputOverlay()
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +481,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
|||
@SuppressLint("SourceLockedOrientationActivity")
|
||||
private fun startConfiguringControls() {
|
||||
// Lock the current orientation to prevent editing inconsistencies
|
||||
if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Default) {
|
||||
if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Unspecified) {
|
||||
emulationActivity?.let {
|
||||
it.requestedOrientation =
|
||||
if (resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
|
@ -503,7 +499,7 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback {
|
|||
binding.doneControlConfig.visibility = View.GONE
|
||||
binding.surfaceInputOverlay.setIsInEditMode(false)
|
||||
// Unlock the orientation if it was locked for editing
|
||||
if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Default) {
|
||||
if (IntSetting.RENDERER_SCREEN_LAYOUT.int == Settings.LayoutOption_Unspecified) {
|
||||
emulationActivity?.let {
|
||||
it.requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
|
||||
}
|
||||
|
|
|
@ -51,12 +51,14 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
|
|||
|
||||
private lateinit var windowInsets: WindowInsets
|
||||
|
||||
var orientation = LANDSCAPE
|
||||
|
||||
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
||||
super.onLayout(changed, left, top, right, bottom)
|
||||
|
||||
windowInsets = rootWindowInsets
|
||||
|
||||
if (!preferences.getBoolean(Settings.PREF_OVERLAY_INIT, false)) {
|
||||
if (!preferences.getBoolean("${Settings.PREF_OVERLAY_INIT}$orientation", false)) {
|
||||
defaultOverlay()
|
||||
}
|
||||
|
||||
|
@ -542,8 +544,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
|
|||
val min = windowSize.first
|
||||
val max = windowSize.second
|
||||
PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext).edit()
|
||||
.putFloat("$sharedPrefsId$orientation-X", (x - min.x).toFloat() / max.x)
|
||||
.putFloat("$sharedPrefsId$orientation-Y", (y - min.y).toFloat() / max.y)
|
||||
.putFloat("$sharedPrefsId-X$orientation", (x - min.x).toFloat() / max.x)
|
||||
.putFloat("$sharedPrefsId-Y$orientation", (y - min.y).toFloat() / max.y)
|
||||
.apply()
|
||||
}
|
||||
|
||||
|
@ -552,13 +554,13 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
|
|||
}
|
||||
|
||||
private fun defaultOverlay() {
|
||||
if (!preferences.getBoolean(Settings.PREF_OVERLAY_INIT, false)) {
|
||||
if (!preferences.getBoolean("${Settings.PREF_OVERLAY_INIT}$orientation", false)) {
|
||||
defaultOverlayByLayout(orientation)
|
||||
}
|
||||
|
||||
resetButtonPlacement()
|
||||
preferences.edit()
|
||||
.putBoolean(Settings.PREF_OVERLAY_INIT, true)
|
||||
.putBoolean("${Settings.PREF_OVERLAY_INIT}$orientation", true)
|
||||
.apply()
|
||||
}
|
||||
|
||||
|
@ -601,69 +603,69 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
|
|||
)
|
||||
|
||||
private val portraitResources = arrayOf(
|
||||
R.integer.SWITCH_BUTTON_A_PORTRAIT_X,
|
||||
R.integer.SWITCH_BUTTON_A_PORTRAIT_Y,
|
||||
R.integer.SWITCH_BUTTON_B_PORTRAIT_X,
|
||||
R.integer.SWITCH_BUTTON_B_PORTRAIT_Y,
|
||||
R.integer.SWITCH_BUTTON_X_PORTRAIT_X,
|
||||
R.integer.SWITCH_BUTTON_X_PORTRAIT_Y,
|
||||
R.integer.SWITCH_BUTTON_Y_PORTRAIT_X,
|
||||
R.integer.SWITCH_BUTTON_Y_PORTRAIT_Y,
|
||||
R.integer.SWITCH_TRIGGER_ZL_PORTRAIT_X,
|
||||
R.integer.SWITCH_TRIGGER_ZL_PORTRAIT_Y,
|
||||
R.integer.SWITCH_TRIGGER_ZR_PORTRAIT_X,
|
||||
R.integer.SWITCH_TRIGGER_ZR_PORTRAIT_Y,
|
||||
R.integer.SWITCH_BUTTON_DPAD_PORTRAIT_X,
|
||||
R.integer.SWITCH_BUTTON_DPAD_PORTRAIT_Y,
|
||||
R.integer.SWITCH_TRIGGER_L_PORTRAIT_X,
|
||||
R.integer.SWITCH_TRIGGER_L_PORTRAIT_Y,
|
||||
R.integer.SWITCH_TRIGGER_R_PORTRAIT_X,
|
||||
R.integer.SWITCH_TRIGGER_R_PORTRAIT_Y,
|
||||
R.integer.SWITCH_BUTTON_PLUS_PORTRAIT_X,
|
||||
R.integer.SWITCH_BUTTON_PLUS_PORTRAIT_Y,
|
||||
R.integer.SWITCH_BUTTON_MINUS_PORTRAIT_X,
|
||||
R.integer.SWITCH_BUTTON_MINUS_PORTRAIT_Y,
|
||||
R.integer.SWITCH_BUTTON_HOME_PORTRAIT_X,
|
||||
R.integer.SWITCH_BUTTON_HOME_PORTRAIT_Y,
|
||||
R.integer.SWITCH_BUTTON_CAPTURE_PORTRAIT_X,
|
||||
R.integer.SWITCH_BUTTON_CAPTURE_PORTRAIT_Y,
|
||||
R.integer.SWITCH_STICK_R_PORTRAIT_X,
|
||||
R.integer.SWITCH_STICK_R_PORTRAIT_Y,
|
||||
R.integer.SWITCH_STICK_L_PORTRAIT_X,
|
||||
R.integer.SWITCH_STICK_L_PORTRAIT_Y
|
||||
R.integer.SWITCH_BUTTON_A_X_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_A_Y_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_B_X_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_B_Y_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_X_X_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_X_Y_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_Y_X_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_Y_Y_PORTRAIT,
|
||||
R.integer.SWITCH_TRIGGER_ZL_X_PORTRAIT,
|
||||
R.integer.SWITCH_TRIGGER_ZL_Y_PORTRAIT,
|
||||
R.integer.SWITCH_TRIGGER_ZR_X_PORTRAIT,
|
||||
R.integer.SWITCH_TRIGGER_ZR_Y_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_DPAD_X_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_DPAD_Y_PORTRAIT,
|
||||
R.integer.SWITCH_TRIGGER_L_X_PORTRAIT,
|
||||
R.integer.SWITCH_TRIGGER_L_Y_PORTRAIT,
|
||||
R.integer.SWITCH_TRIGGER_R_X_PORTRAIT,
|
||||
R.integer.SWITCH_TRIGGER_R_Y_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_PLUS_X_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_PLUS_Y_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_MINUS_X_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_MINUS_Y_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_HOME_X_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_HOME_Y_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_CAPTURE_X_PORTRAIT,
|
||||
R.integer.SWITCH_BUTTON_CAPTURE_Y_PORTRAIT,
|
||||
R.integer.SWITCH_STICK_R_X_PORTRAIT,
|
||||
R.integer.SWITCH_STICK_R_Y_PORTRAIT,
|
||||
R.integer.SWITCH_STICK_L_X_PORTRAIT,
|
||||
R.integer.SWITCH_STICK_L_Y_PORTRAIT
|
||||
)
|
||||
|
||||
private val foldableResources = arrayOf(
|
||||
R.integer.SWITCH_BUTTON_A_FOLDABLE_X,
|
||||
R.integer.SWITCH_BUTTON_A_FOLDABLE_Y,
|
||||
R.integer.SWITCH_BUTTON_B_FOLDABLE_X,
|
||||
R.integer.SWITCH_BUTTON_B_FOLDABLE_Y,
|
||||
R.integer.SWITCH_BUTTON_X_FOLDABLE_X,
|
||||
R.integer.SWITCH_BUTTON_X_FOLDABLE_Y,
|
||||
R.integer.SWITCH_BUTTON_Y_FOLDABLE_X,
|
||||
R.integer.SWITCH_BUTTON_Y_FOLDABLE_Y,
|
||||
R.integer.SWITCH_TRIGGER_ZL_FOLDABLE_X,
|
||||
R.integer.SWITCH_TRIGGER_ZL_FOLDABLE_Y,
|
||||
R.integer.SWITCH_TRIGGER_ZR_FOLDABLE_X,
|
||||
R.integer.SWITCH_TRIGGER_ZR_FOLDABLE_Y,
|
||||
R.integer.SWITCH_BUTTON_DPAD_FOLDABLE_X,
|
||||
R.integer.SWITCH_BUTTON_DPAD_FOLDABLE_Y,
|
||||
R.integer.SWITCH_TRIGGER_L_FOLDABLE_X,
|
||||
R.integer.SWITCH_TRIGGER_L_FOLDABLE_Y,
|
||||
R.integer.SWITCH_TRIGGER_R_FOLDABLE_X,
|
||||
R.integer.SWITCH_TRIGGER_R_FOLDABLE_Y,
|
||||
R.integer.SWITCH_BUTTON_PLUS_FOLDABLE_X,
|
||||
R.integer.SWITCH_BUTTON_PLUS_FOLDABLE_Y,
|
||||
R.integer.SWITCH_BUTTON_MINUS_FOLDABLE_X,
|
||||
R.integer.SWITCH_BUTTON_MINUS_FOLDABLE_Y,
|
||||
R.integer.SWITCH_BUTTON_HOME_FOLDABLE_X,
|
||||
R.integer.SWITCH_BUTTON_HOME_FOLDABLE_Y,
|
||||
R.integer.SWITCH_BUTTON_CAPTURE_FOLDABLE_X,
|
||||
R.integer.SWITCH_BUTTON_CAPTURE_FOLDABLE_Y,
|
||||
R.integer.SWITCH_STICK_R_FOLDABLE_X,
|
||||
R.integer.SWITCH_STICK_R_FOLDABLE_Y,
|
||||
R.integer.SWITCH_STICK_L_FOLDABLE_X,
|
||||
R.integer.SWITCH_STICK_L_FOLDABLE_Y
|
||||
R.integer.SWITCH_BUTTON_A_X_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_A_Y_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_B_X_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_B_Y_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_X_X_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_X_Y_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_Y_X_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_Y_Y_FOLDABLE,
|
||||
R.integer.SWITCH_TRIGGER_ZL_X_FOLDABLE,
|
||||
R.integer.SWITCH_TRIGGER_ZL_Y_FOLDABLE,
|
||||
R.integer.SWITCH_TRIGGER_ZR_X_FOLDABLE,
|
||||
R.integer.SWITCH_TRIGGER_ZR_Y_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_DPAD_X_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_DPAD_Y_FOLDABLE,
|
||||
R.integer.SWITCH_TRIGGER_L_X_FOLDABLE,
|
||||
R.integer.SWITCH_TRIGGER_L_Y_FOLDABLE,
|
||||
R.integer.SWITCH_TRIGGER_R_X_FOLDABLE,
|
||||
R.integer.SWITCH_TRIGGER_R_Y_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_PLUS_X_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_PLUS_Y_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_MINUS_X_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_MINUS_Y_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_HOME_X_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_HOME_Y_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_CAPTURE_X_FOLDABLE,
|
||||
R.integer.SWITCH_BUTTON_CAPTURE_Y_FOLDABLE,
|
||||
R.integer.SWITCH_STICK_R_X_FOLDABLE,
|
||||
R.integer.SWITCH_STICK_R_Y_FOLDABLE,
|
||||
R.integer.SWITCH_STICK_L_X_FOLDABLE,
|
||||
R.integer.SWITCH_STICK_L_Y_FOLDABLE
|
||||
)
|
||||
|
||||
private fun getResourceValue(descriptor: String, position: Int) : Float {
|
||||
|
@ -804,18 +806,13 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
|
|||
return inEditMode
|
||||
}
|
||||
|
||||
fun setOrientation(descriptor: String) {
|
||||
orientation = descriptor
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val preferences: SharedPreferences =
|
||||
PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext)
|
||||
|
||||
const val LANDSCAPE = ""
|
||||
const val PORTRAIT = "-Portrait"
|
||||
const val FOLDABLE = "-Foldable"
|
||||
private var orientation = LANDSCAPE
|
||||
const val PORTRAIT = "_Portrait"
|
||||
const val FOLDABLE = "_Foldable"
|
||||
|
||||
/**
|
||||
* Resizes a [Bitmap] by a given scale factor
|
||||
|
@ -985,8 +982,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
|
|||
|
||||
// The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay.
|
||||
// These were set in the input overlay configuration menu.
|
||||
val xKey = "$buttonId$orientation-X"
|
||||
val yKey = "$buttonId$orientation-Y"
|
||||
val xKey = "$buttonId-X$orientation"
|
||||
val yKey = "$buttonId-Y$orientation"
|
||||
val drawableXPercent = sPrefs.getFloat(xKey, 0f)
|
||||
val drawableYPercent = sPrefs.getFloat(yKey, 0f)
|
||||
val drawableX = (drawableXPercent * max.x + min.x).toInt()
|
||||
|
@ -1066,8 +1063,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
|
|||
|
||||
// The X and Y coordinates of the InputOverlayDrawableDpad on the InputOverlay.
|
||||
// These were set in the input overlay configuration menu.
|
||||
val drawableXPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}$orientation-X", 0f)
|
||||
val drawableYPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}$orientation-Y", 0f)
|
||||
val drawableXPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}-X$orientation", 0f)
|
||||
val drawableYPercent = sPrefs.getFloat("${ButtonType.DPAD_UP}-Y$orientation", 0f)
|
||||
val drawableX = (drawableXPercent * max.x + min.x).toInt()
|
||||
val drawableY = (drawableYPercent * max.y + min.y).toInt()
|
||||
val width = overlayDrawable.width
|
||||
|
@ -1133,8 +1130,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context
|
|||
|
||||
// The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay.
|
||||
// These were set in the input overlay configuration menu.
|
||||
val drawableXPercent = sPrefs.getFloat("$button$orientation-X", 0f)
|
||||
val drawableYPercent = sPrefs.getFloat("$button$orientation-Y", 0f)
|
||||
val drawableXPercent = sPrefs.getFloat("$button-X$orientation", 0f)
|
||||
val drawableYPercent = sPrefs.getFloat("$button-Y$orientation", 0f)
|
||||
val drawableX = (drawableXPercent * max.x + min.x).toInt()
|
||||
val drawableY = (drawableYPercent * max.y + min.y).toInt()
|
||||
val outerScale = 1.66f
|
||||
|
|
|
@ -35,67 +35,67 @@
|
|||
<integer name="SWITCH_BUTTON_DPAD_Y">790</integer>
|
||||
|
||||
<!-- Default SWITCH portrait layout -->
|
||||
<integer name="SWITCH_BUTTON_A_PORTRAIT_X">840</integer>
|
||||
<integer name="SWITCH_BUTTON_A_PORTRAIT_Y">820</integer>
|
||||
<integer name="SWITCH_BUTTON_B_PORTRAIT_X">740</integer>
|
||||
<integer name="SWITCH_BUTTON_B_PORTRAIT_Y">860</integer>
|
||||
<integer name="SWITCH_BUTTON_X_PORTRAIT_X">740</integer>
|
||||
<integer name="SWITCH_BUTTON_X_PORTRAIT_Y">780</integer>
|
||||
<integer name="SWITCH_BUTTON_Y_PORTRAIT_X">640</integer>
|
||||
<integer name="SWITCH_BUTTON_Y_PORTRAIT_Y">820</integer>
|
||||
<integer name="SWITCH_STICK_L_PORTRAIT_X">180</integer>
|
||||
<integer name="SWITCH_STICK_L_PORTRAIT_Y">640</integer>
|
||||
<integer name="SWITCH_STICK_R_PORTRAIT_X">820</integer>
|
||||
<integer name="SWITCH_STICK_R_PORTRAIT_Y">640</integer>
|
||||
<integer name="SWITCH_TRIGGER_L_PORTRAIT_X">140</integer>
|
||||
<integer name="SWITCH_TRIGGER_L_PORTRAIT_Y">240</integer>
|
||||
<integer name="SWITCH_TRIGGER_R_PORTRAIT_X">860</integer>
|
||||
<integer name="SWITCH_TRIGGER_R_PORTRAIT_Y">240</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZL_PORTRAIT_X">140</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZL_PORTRAIT_Y">180</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZR_PORTRAIT_X">860</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZR_PORTRAIT_Y">180</integer>
|
||||
<integer name="SWITCH_BUTTON_MINUS_PORTRAIT_X">440</integer>
|
||||
<integer name="SWITCH_BUTTON_MINUS_PORTRAIT_Y">950</integer>
|
||||
<integer name="SWITCH_BUTTON_PLUS_PORTRAIT_X">560</integer>
|
||||
<integer name="SWITCH_BUTTON_PLUS_PORTRAIT_Y">950</integer>
|
||||
<integer name="SWITCH_BUTTON_HOME_PORTRAIT_X">660</integer>
|
||||
<integer name="SWITCH_BUTTON_HOME_PORTRAIT_Y">950</integer>
|
||||
<integer name="SWITCH_BUTTON_CAPTURE_PORTRAIT_X">320</integer>
|
||||
<integer name="SWITCH_BUTTON_CAPTURE_PORTRAIT_Y">950</integer>
|
||||
<integer name="SWITCH_BUTTON_DPAD_PORTRAIT_X">240</integer>
|
||||
<integer name="SWITCH_BUTTON_DPAD_PORTRAIT_Y">820</integer>
|
||||
<integer name="SWITCH_BUTTON_A_X_PORTRAIT">840</integer>
|
||||
<integer name="SWITCH_BUTTON_A_Y_PORTRAIT">820</integer>
|
||||
<integer name="SWITCH_BUTTON_B_X_PORTRAIT">740</integer>
|
||||
<integer name="SWITCH_BUTTON_B_Y_PORTRAIT">860</integer>
|
||||
<integer name="SWITCH_BUTTON_X_X_PORTRAIT">740</integer>
|
||||
<integer name="SWITCH_BUTTON_X_Y_PORTRAIT">780</integer>
|
||||
<integer name="SWITCH_BUTTON_Y_X_PORTRAIT">640</integer>
|
||||
<integer name="SWITCH_BUTTON_Y_Y_PORTRAIT">820</integer>
|
||||
<integer name="SWITCH_STICK_L_X_PORTRAIT">180</integer>
|
||||
<integer name="SWITCH_STICK_L_Y_PORTRAIT">640</integer>
|
||||
<integer name="SWITCH_STICK_R_X_PORTRAIT">820</integer>
|
||||
<integer name="SWITCH_STICK_R_Y_PORTRAIT">640</integer>
|
||||
<integer name="SWITCH_TRIGGER_L_X_PORTRAIT">140</integer>
|
||||
<integer name="SWITCH_TRIGGER_L_Y_PORTRAIT">240</integer>
|
||||
<integer name="SWITCH_TRIGGER_R_X_PORTRAIT">860</integer>
|
||||
<integer name="SWITCH_TRIGGER_R_Y_PORTRAIT">240</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZL_X_PORTRAIT">140</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZL_Y_PORTRAIT">180</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZR_X_PORTRAIT">860</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZR_Y_PORTRAIT">180</integer>
|
||||
<integer name="SWITCH_BUTTON_MINUS_X_PORTRAIT">440</integer>
|
||||
<integer name="SWITCH_BUTTON_MINUS_Y_PORTRAIT">950</integer>
|
||||
<integer name="SWITCH_BUTTON_PLUS_X_PORTRAIT">560</integer>
|
||||
<integer name="SWITCH_BUTTON_PLUS_Y_PORTRAIT">950</integer>
|
||||
<integer name="SWITCH_BUTTON_HOME_X_PORTRAIT">680</integer>
|
||||
<integer name="SWITCH_BUTTON_HOME_Y_PORTRAIT">950</integer>
|
||||
<integer name="SWITCH_BUTTON_CAPTURE_X_PORTRAIT">320</integer>
|
||||
<integer name="SWITCH_BUTTON_CAPTURE_Y_PORTRAIT">950</integer>
|
||||
<integer name="SWITCH_BUTTON_DPAD_X_PORTRAIT">240</integer>
|
||||
<integer name="SWITCH_BUTTON_DPAD_Y_PORTRAIT">820</integer>
|
||||
|
||||
<!-- Default SWITCH foldable layout -->
|
||||
<integer name="SWITCH_BUTTON_A_FOLDABLE_X">840</integer>
|
||||
<integer name="SWITCH_BUTTON_A_FOLDABLE_Y">340</integer>
|
||||
<integer name="SWITCH_BUTTON_B_FOLDABLE_X">740</integer>
|
||||
<integer name="SWITCH_BUTTON_B_FOLDABLE_Y">380</integer>
|
||||
<integer name="SWITCH_BUTTON_X_FOLDABLE_X">740</integer>
|
||||
<integer name="SWITCH_BUTTON_X_FOLDABLE_Y">300</integer>
|
||||
<integer name="SWITCH_BUTTON_Y_FOLDABLE_X">640</integer>
|
||||
<integer name="SWITCH_BUTTON_Y_FOLDABLE_Y">340</integer>
|
||||
<integer name="SWITCH_STICK_L_FOLDABLE_X">180</integer>
|
||||
<integer name="SWITCH_STICK_L_FOLDABLE_Y">200</integer>
|
||||
<integer name="SWITCH_STICK_R_FOLDABLE_X">820</integer>
|
||||
<integer name="SWITCH_STICK_R_FOLDABLE_Y">200</integer>
|
||||
<integer name="SWITCH_TRIGGER_L_FOLDABLE_X">140</integer>
|
||||
<integer name="SWITCH_TRIGGER_L_FOLDABLE_Y">80</integer>
|
||||
<integer name="SWITCH_TRIGGER_R_FOLDABLE_X">860</integer>
|
||||
<integer name="SWITCH_TRIGGER_R_FOLDABLE_Y">80</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZL_FOLDABLE_X">140</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZL_FOLDABLE_Y">20</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZR_FOLDABLE_X">860</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZR_FOLDABLE_Y">20</integer>
|
||||
<integer name="SWITCH_BUTTON_MINUS_FOLDABLE_X">440</integer>
|
||||
<integer name="SWITCH_BUTTON_MINUS_FOLDABLE_Y">420</integer>
|
||||
<integer name="SWITCH_BUTTON_PLUS_FOLDABLE_X">560</integer>
|
||||
<integer name="SWITCH_BUTTON_PLUS_FOLDABLE_Y">420</integer>
|
||||
<integer name="SWITCH_BUTTON_HOME_FOLDABLE_X">680</integer>
|
||||
<integer name="SWITCH_BUTTON_HOME_FOLDABLE_Y">420</integer>
|
||||
<integer name="SWITCH_BUTTON_CAPTURE_FOLDABLE_X">320</integer>
|
||||
<integer name="SWITCH_BUTTON_CAPTURE_FOLDABLE_Y">420</integer>
|
||||
<integer name="SWITCH_BUTTON_DPAD_FOLDABLE_X">240</integer>
|
||||
<integer name="SWITCH_BUTTON_DPAD_FOLDABLE_Y">340</integer>
|
||||
<integer name="SWITCH_BUTTON_A_X_FOLDABLE">840</integer>
|
||||
<integer name="SWITCH_BUTTON_A_Y_FOLDABLE">340</integer>
|
||||
<integer name="SWITCH_BUTTON_B_X_FOLDABLE">740</integer>
|
||||
<integer name="SWITCH_BUTTON_B_Y_FOLDABLE">380</integer>
|
||||
<integer name="SWITCH_BUTTON_X_X_FOLDABLE">740</integer>
|
||||
<integer name="SWITCH_BUTTON_X_Y_FOLDABLE">300</integer>
|
||||
<integer name="SWITCH_BUTTON_Y_X_FOLDABLE">640</integer>
|
||||
<integer name="SWITCH_BUTTON_Y_Y_FOLDABLE">340</integer>
|
||||
<integer name="SWITCH_STICK_L_X_FOLDABLE">180</integer>
|
||||
<integer name="SWITCH_STICK_L_Y_FOLDABLE">200</integer>
|
||||
<integer name="SWITCH_STICK_R_X_FOLDABLE">820</integer>
|
||||
<integer name="SWITCH_STICK_R_Y_FOLDABLE">200</integer>
|
||||
<integer name="SWITCH_TRIGGER_L_X_FOLDABLE">140</integer>
|
||||
<integer name="SWITCH_TRIGGER_L_Y_FOLDABLE">80</integer>
|
||||
<integer name="SWITCH_TRIGGER_R_X_FOLDABLE">860</integer>
|
||||
<integer name="SWITCH_TRIGGER_R_Y_FOLDABLE">80</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZL_X_FOLDABLE">140</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZL_Y_FOLDABLE">20</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZR_X_FOLDABLE">860</integer>
|
||||
<integer name="SWITCH_TRIGGER_ZR_Y_FOLDABLE">20</integer>
|
||||
<integer name="SWITCH_BUTTON_MINUS_X_FOLDABLE">440</integer>
|
||||
<integer name="SWITCH_BUTTON_MINUS_Y_FOLDABLE">420</integer>
|
||||
<integer name="SWITCH_BUTTON_PLUS_X_FOLDABLE">560</integer>
|
||||
<integer name="SWITCH_BUTTON_PLUS_Y_FOLDABLE">420</integer>
|
||||
<integer name="SWITCH_BUTTON_HOME_X_FOLDABLE">680</integer>
|
||||
<integer name="SWITCH_BUTTON_HOME_Y_FOLDABLE">420</integer>
|
||||
<integer name="SWITCH_BUTTON_CAPTURE_X_FOLDABLE">320</integer>
|
||||
<integer name="SWITCH_BUTTON_CAPTURE_Y_FOLDABLE">420</integer>
|
||||
<integer name="SWITCH_BUTTON_DPAD_X_FOLDABLE">240</integer>
|
||||
<integer name="SWITCH_BUTTON_DPAD_Y_FOLDABLE">340</integer>
|
||||
|
||||
</resources>
|
||||
|
|
Reference in New Issue