diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/fragments/EmulationFragment.kt b/src/android/app/src/main/java/io/github/lime3ds/android/fragments/EmulationFragment.kt
index f47a9e2a1..44c7c5a71 100644
--- a/src/android/app/src/main/java/io/github/lime3ds/android/fragments/EmulationFragment.kt
+++ b/src/android/app/src/main/java/io/github/lime3ds/android/fragments/EmulationFragment.kt
@@ -619,8 +619,88 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
true
}
+ R.id.menu_emulation_adjust_scale_reset_all -> {
+ resetAllScales()
+ true
+ }
+
R.id.menu_emulation_adjust_scale -> {
- showAdjustScaleDialog()
+ showAdjustScaleDialog("controlScale")
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_a -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.BUTTON_A)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_b -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.BUTTON_B)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_x -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.BUTTON_X)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_y -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.BUTTON_Y)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_l -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.TRIGGER_L)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_r -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.TRIGGER_R)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_zl -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.BUTTON_ZL)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_zr -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.BUTTON_ZR)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_start -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.BUTTON_START)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_select -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.BUTTON_SELECT)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_controller_dpad -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.DPAD)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_controller_circlepad -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.STICK_LEFT)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_controller_c -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.STICK_C)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_home -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.BUTTON_HOME)
+ true
+ }
+
+ R.id.menu_emulation_adjust_scale_button_swap -> {
+ showAdjustScaleDialog("controlScale-" + NativeLibrary.ButtonType.BUTTON_SWAP)
true
}
@@ -774,16 +854,16 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
.show()
}
- private fun showAdjustScaleDialog() {
+ private fun showAdjustScaleDialog(target: String) {
val sliderBinding = DialogSliderBinding.inflate(layoutInflater)
sliderBinding.apply {
slider.valueTo = 150f
- slider.value = preferences.getInt("controlScale", 50).toFloat()
+ slider.value = preferences.getInt(target, 50).toFloat()
slider.addOnChangeListener(
Slider.OnChangeListener { slider: Slider, progress: Float, _: Boolean ->
textValue.text = (progress.toInt() + 50).toString()
- setControlScale(slider.value.toInt())
+ setControlScale(slider.value.toInt(), target)
})
textValue.text = (sliderBinding.slider.value.toInt() + 50).toString()
textUnits.text = "%"
@@ -794,13 +874,13 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
.setTitle(R.string.emulation_control_scale)
.setView(sliderBinding.root)
.setNegativeButton(android.R.string.cancel) { _: DialogInterface?, _: Int ->
- setControlScale(previousProgress)
+ setControlScale(previousProgress, target)
}
.setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int ->
- setControlScale(sliderBinding.slider.value.toInt())
+ setControlScale(sliderBinding.slider.value.toInt(), target)
}
.setNeutralButton(R.string.slider_default) { _: DialogInterface?, _: Int ->
- setControlScale(50)
+ setControlScale(50, target)
}
.show()
}
@@ -836,13 +916,40 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
.show()
}
- private fun setControlScale(scale: Int) {
+ private fun setControlScale(scale: Int, target: String) {
preferences.edit()
- .putInt("controlScale", scale)
+ .putInt(target, scale)
.apply()
binding.surfaceInputOverlay.refreshControls()
}
+ private fun resetScale(target: String) {
+ preferences.edit().putInt(
+ target,
+ 50
+ ).apply()
+ }
+
+ private fun resetAllScales() {
+ resetScale("controlScale")
+ resetScale("controlScale-" + NativeLibrary.ButtonType.BUTTON_A)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.BUTTON_B)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.BUTTON_X)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.BUTTON_Y)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.TRIGGER_L)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.TRIGGER_R)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.BUTTON_ZL)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.BUTTON_ZR)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.BUTTON_START)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.BUTTON_SELECT)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.DPAD)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.STICK_LEFT)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.STICK_C)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.BUTTON_HOME)
+ resetScale("controlScale-" + NativeLibrary.ButtonType.BUTTON_SWAP)
+ binding.surfaceInputOverlay.refreshControls()
+ }
+
private fun setControlOpacity(opacity: Int) {
preferences.edit()
.putInt("controlOpacity", opacity)
@@ -861,8 +968,8 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback, Choreographer.Fram
}
private fun resetInputOverlay() {
+ resetAllScales()
preferences.edit()
- .putInt("controlScale", 50)
.putInt("controlOpacity", 50)
.apply()
diff --git a/src/android/app/src/main/java/io/github/lime3ds/android/overlay/InputOverlay.kt b/src/android/app/src/main/java/io/github/lime3ds/android/overlay/InputOverlay.kt
index ef251b468..9b68cd122 100644
--- a/src/android/app/src/main/java/io/github/lime3ds/android/overlay/InputOverlay.kt
+++ b/src/android/app/src/main/java/io/github/lime3ds/android/overlay/InputOverlay.kt
@@ -939,6 +939,10 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
scale *= (preferences.getInt("controlScale", 50) + 50).toFloat()
scale /= 100f
+
+ scale *= (preferences.getInt("controlScale-$buttonId", 50) + 50).toFloat()
+ scale /= 100f
+
val opacity: Int = preferences.getInt("controlOpacity", 50) * 255 / 100
// Initialize the InputOverlayDrawableButton.
@@ -997,6 +1001,13 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
scale *= (preferences.getInt("controlScale", 50) + 50).toFloat()
scale /= 100f
+ scale *= (preferences.getInt(
+ "controlScale-" + NativeLibrary.ButtonType.DPAD,
+ 50
+ ) + 50).toFloat()
+
+ scale /= 100f
+
val opacity: Int = preferences.getInt("controlOpacity", 50) * 255 / 100
// Initialize the InputOverlayDrawableDpad.
@@ -1057,6 +1068,9 @@ class InputOverlay(context: Context?, attrs: AttributeSet?) : SurfaceView(contex
scale *= (preferences.getInt("controlScale", 50) + 50).toFloat()
scale /= 100f
+ scale *= (preferences.getInt("controlScale-$joystick", 50) + 50).toFloat()
+ scale /= 100f
+
val opacity: Int = preferences.getInt("controlOpacity", 50) * 255 / 100
// Initialize the InputOverlayDrawableJoystick.
diff --git a/src/android/app/src/main/res/menu/menu_overlay_options.xml b/src/android/app/src/main/res/menu/menu_overlay_options.xml
index 14e9a788a..87cec02a7 100644
--- a/src/android/app/src/main/res/menu/menu_overlay_options.xml
+++ b/src/android/app/src/main/res/menu/menu_overlay_options.xml
@@ -25,8 +25,62 @@
android:title="@string/emulation_toggle_controls" />