diff options
| author | 2023-06-01 17:30:27 -0400 | |
|---|---|---|
| committer | 2023-06-03 00:06:07 -0700 | |
| commit | ca4b07a2d7b67ee042ab886d8373faf88c2fd883 (patch) | |
| tree | ef85ce03398e98ab41409b123eb602196701f03c /src/android | |
| parent | Add image to card_game.xml to preview in the Layout Editor (diff) | |
| download | yuzu-ca4b07a2d7b67ee042ab886d8373faf88c2fd883.tar.gz yuzu-ca4b07a2d7b67ee042ab886d8373faf88c2fd883.tar.xz yuzu-ca4b07a2d7b67ee042ab886d8373faf88c2fd883.zip | |
android: Enable overlay scale/opacity dialog
Diffstat (limited to 'src/android')
10 files changed, 182 insertions, 65 deletions
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt index 37caa1b83..abeb01995 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/activities/EmulationActivity.kt | |||
| @@ -252,39 +252,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 252 | View.SYSTEM_UI_FLAG_IMMERSIVE | 252 | View.SYSTEM_UI_FLAG_IMMERSIVE |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | private fun editControlsPlacement() { | ||
| 256 | if (emulationFragment!!.isConfiguringControls) { | ||
| 257 | emulationFragment!!.stopConfiguringControls() | ||
| 258 | } else { | ||
| 259 | emulationFragment!!.startConfiguringControls() | ||
| 260 | } | ||
| 261 | } | ||
| 262 | |||
| 263 | private fun adjustScale() { | ||
| 264 | val sliderBinding = DialogSliderBinding.inflate(layoutInflater) | ||
| 265 | sliderBinding.slider.valueTo = 150F | ||
| 266 | sliderBinding.slider.value = | ||
| 267 | PreferenceManager.getDefaultSharedPreferences(applicationContext) | ||
| 268 | .getInt(Settings.PREF_CONTROL_SCALE, 50).toFloat() | ||
| 269 | sliderBinding.slider.addOnChangeListener(OnChangeListener { _, value, _ -> | ||
| 270 | sliderBinding.textValue.text = value.toString() | ||
| 271 | setControlScale(value.toInt()) | ||
| 272 | }) | ||
| 273 | sliderBinding.textValue.text = sliderBinding.slider.value.toString() | ||
| 274 | sliderBinding.textUnits.text = "%" | ||
| 275 | MaterialAlertDialogBuilder(this) | ||
| 276 | .setTitle(R.string.emulation_control_scale) | ||
| 277 | .setView(sliderBinding.root) | ||
| 278 | .setNegativeButton(android.R.string.cancel, null) | ||
| 279 | .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int -> | ||
| 280 | setControlScale(sliderBinding.slider.value.toInt()) | ||
| 281 | } | ||
| 282 | .setNeutralButton(R.string.slider_default) { _: DialogInterface?, _: Int -> | ||
| 283 | setControlScale(50) | ||
| 284 | } | ||
| 285 | .show() | ||
| 286 | } | ||
| 287 | |||
| 288 | private fun startMotionSensorListener() { | 255 | private fun startMotionSensorListener() { |
| 289 | val sensorManager = this.getSystemService(Context.SENSOR_SERVICE) as SensorManager | 256 | val sensorManager = this.getSystemService(Context.SENSOR_SERVICE) as SensorManager |
| 290 | val gyroSensor = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) | 257 | val gyroSensor = sensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE) |
| @@ -302,22 +269,6 @@ class EmulationActivity : AppCompatActivity(), SensorEventListener { | |||
| 302 | sensorManager.unregisterListener(this, accelSensor) | 269 | sensorManager.unregisterListener(this, accelSensor) |
| 303 | } | 270 | } |
| 304 | 271 | ||
| 305 | private fun setControlScale(scale: Int) { | ||
| 306 | PreferenceManager.getDefaultSharedPreferences(applicationContext).edit() | ||
| 307 | .putInt(Settings.PREF_CONTROL_SCALE, scale) | ||
| 308 | .apply() | ||
| 309 | emulationFragment!!.refreshInputOverlay() | ||
| 310 | } | ||
| 311 | |||
| 312 | private fun resetOverlay() { | ||
| 313 | MaterialAlertDialogBuilder(this) | ||
| 314 | .setTitle(getString(R.string.emulation_touch_overlay_reset)) | ||
| 315 | .setPositiveButton(android.R.string.ok) { _: DialogInterface?, _: Int -> emulationFragment!!.resetInputOverlay() } | ||
| 316 | .setNegativeButton(android.R.string.cancel, null) | ||
| 317 | .create() | ||
| 318 | .show() | ||
| 319 | } | ||
| 320 | |||
| 321 | companion object { | 272 | companion object { |
| 322 | const val EXTRA_SELECTED_GAME = "SelectedGame" | 273 | const val EXTRA_SELECTED_GAME = "SelectedGame" |
| 323 | 274 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt index a904c2011..23c31e13a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/features/settings/model/Settings.kt | |||
| @@ -111,6 +111,7 @@ class Settings { | |||
| 111 | 111 | ||
| 112 | const val PREF_OVERLAY_INIT = "OverlayInit" | 112 | const val PREF_OVERLAY_INIT = "OverlayInit" |
| 113 | const val PREF_CONTROL_SCALE = "controlScale" | 113 | const val PREF_CONTROL_SCALE = "controlScale" |
| 114 | const val PREF_CONTROL_OPACITY = "controlOpacity" | ||
| 114 | const val PREF_TOUCH_ENABLED = "isTouchEnabled" | 115 | const val PREF_TOUCH_ENABLED = "isTouchEnabled" |
| 115 | const val PREF_BUTTON_TOGGLE_0 = "buttonToggle0" | 116 | const val PREF_BUTTON_TOGGLE_0 = "buttonToggle0" |
| 116 | const val PREF_BUTTON_TOGGLE_1 = "buttonToggle1" | 117 | const val PREF_BUTTON_TOGGLE_1 = "buttonToggle1" |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt index ea44733c1..5f1a94190 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/fragments/EmulationFragment.kt | |||
| @@ -3,8 +3,10 @@ | |||
| 3 | 3 | ||
| 4 | package org.yuzu.yuzu_emu.fragments | 4 | package org.yuzu.yuzu_emu.fragments |
| 5 | 5 | ||
| 6 | import android.annotation.SuppressLint | ||
| 6 | import android.app.AlertDialog | 7 | import android.app.AlertDialog |
| 7 | import android.content.Context | 8 | import android.content.Context |
| 9 | import android.content.DialogInterface | ||
| 8 | import android.content.SharedPreferences | 10 | import android.content.SharedPreferences |
| 9 | import android.graphics.Color | 11 | import android.graphics.Color |
| 10 | import android.os.Bundle | 12 | import android.os.Bundle |
| @@ -21,10 +23,12 @@ import androidx.core.view.WindowInsetsCompat | |||
| 21 | import androidx.fragment.app.Fragment | 23 | import androidx.fragment.app.Fragment |
| 22 | import androidx.preference.PreferenceManager | 24 | import androidx.preference.PreferenceManager |
| 23 | import com.google.android.material.dialog.MaterialAlertDialogBuilder | 25 | import com.google.android.material.dialog.MaterialAlertDialogBuilder |
| 26 | import com.google.android.material.slider.Slider | ||
| 24 | import org.yuzu.yuzu_emu.NativeLibrary | 27 | import org.yuzu.yuzu_emu.NativeLibrary |
| 25 | import org.yuzu.yuzu_emu.R | 28 | import org.yuzu.yuzu_emu.R |
| 26 | import org.yuzu.yuzu_emu.YuzuApplication | 29 | import org.yuzu.yuzu_emu.YuzuApplication |
| 27 | import org.yuzu.yuzu_emu.activities.EmulationActivity | 30 | import org.yuzu.yuzu_emu.activities.EmulationActivity |
| 31 | import org.yuzu.yuzu_emu.databinding.DialogOverlayAdjustBinding | ||
| 28 | import org.yuzu.yuzu_emu.databinding.FragmentEmulationBinding | 32 | import org.yuzu.yuzu_emu.databinding.FragmentEmulationBinding |
| 29 | import org.yuzu.yuzu_emu.features.settings.model.Settings | 33 | import org.yuzu.yuzu_emu.features.settings.model.Settings |
| 30 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity | 34 | import org.yuzu.yuzu_emu.features.settings.ui.SettingsActivity |
| @@ -168,14 +172,14 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 168 | super.onDetach() | 172 | super.onDetach() |
| 169 | } | 173 | } |
| 170 | 174 | ||
| 171 | fun refreshInputOverlay() { | 175 | private fun refreshInputOverlay() { |
| 172 | binding.surfaceInputOverlay.refreshControls() | 176 | binding.surfaceInputOverlay.refreshControls() |
| 173 | } | 177 | } |
| 174 | 178 | ||
| 175 | fun resetInputOverlay() { | 179 | private fun resetInputOverlay() { |
| 176 | // Reset button scale | ||
| 177 | preferences.edit() | 180 | preferences.edit() |
| 178 | .putInt(Settings.PREF_CONTROL_SCALE, 50) | 181 | .remove(Settings.PREF_CONTROL_SCALE) |
| 182 | .remove(Settings.PREF_CONTROL_OPACITY) | ||
| 179 | .apply() | 183 | .apply() |
| 180 | binding.surfaceInputOverlay.post { binding.surfaceInputOverlay.resetButtonPlacement() } | 184 | binding.surfaceInputOverlay.post { binding.surfaceInputOverlay.resetButtonPlacement() } |
| 181 | } | 185 | } |
| @@ -251,6 +255,11 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 251 | true | 255 | true |
| 252 | } | 256 | } |
| 253 | 257 | ||
| 258 | R.id.menu_adjust_overlay -> { | ||
| 259 | adjustOverlay() | ||
| 260 | true | ||
| 261 | } | ||
| 262 | |||
| 254 | R.id.menu_toggle_controls -> { | 263 | R.id.menu_toggle_controls -> { |
| 255 | val preferences = | 264 | val preferences = |
| 256 | PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) | 265 | PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) |
| @@ -278,9 +287,9 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 278 | // Override normal behaviour so the dialog doesn't close | 287 | // Override normal behaviour so the dialog doesn't close |
| 279 | dialog.getButton(AlertDialog.BUTTON_NEUTRAL) | 288 | dialog.getButton(AlertDialog.BUTTON_NEUTRAL) |
| 280 | .setOnClickListener { | 289 | .setOnClickListener { |
| 281 | val isChecked = !optionsArray[0]; | 290 | val isChecked = !optionsArray[0] |
| 282 | for (i in 0..14) { | 291 | for (i in 0..14) { |
| 283 | optionsArray[i] = isChecked; | 292 | optionsArray[i] = isChecked |
| 284 | dialog.listView.setItemChecked(i, isChecked) | 293 | dialog.listView.setItemChecked(i, isChecked) |
| 285 | preferences.edit() | 294 | preferences.edit() |
| 286 | .putBoolean("buttonToggle$i", isChecked) | 295 | .putBoolean("buttonToggle$i", isChecked) |
| @@ -328,18 +337,64 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { | |||
| 328 | popup.show() | 337 | popup.show() |
| 329 | } | 338 | } |
| 330 | 339 | ||
| 331 | fun startConfiguringControls() { | 340 | private fun startConfiguringControls() { |
| 332 | binding.doneControlConfig.visibility = View.VISIBLE | 341 | binding.doneControlConfig.visibility = View.VISIBLE |
| 333 | binding.surfaceInputOverlay.setIsInEditMode(true) | 342 | binding.surfaceInputOverlay.setIsInEditMode(true) |
| 334 | } | 343 | } |
| 335 | 344 | ||
| 336 | fun stopConfiguringControls() { | 345 | private fun stopConfiguringControls() { |
| 337 | binding.doneControlConfig.visibility = View.GONE | 346 | binding.doneControlConfig.visibility = View.GONE |
| 338 | binding.surfaceInputOverlay.setIsInEditMode(false) | 347 | binding.surfaceInputOverlay.setIsInEditMode(false) |
| 339 | } | 348 | } |
| 340 | 349 | ||
| 341 | val isConfiguringControls: Boolean | 350 | @SuppressLint("SetTextI18n") |
| 342 | get() = binding.surfaceInputOverlay.isInEditMode | 351 | private fun adjustOverlay() { |
| 352 | val adjustBinding = DialogOverlayAdjustBinding.inflate(layoutInflater) | ||
| 353 | adjustBinding.apply { | ||
| 354 | inputScaleSlider.apply { | ||
| 355 | valueTo = 150F | ||
| 356 | value = preferences.getInt(Settings.PREF_CONTROL_SCALE, 50).toFloat() | ||
| 357 | addOnChangeListener(Slider.OnChangeListener { _, value, _ -> | ||
| 358 | inputScaleValue.text = "${value.toInt()}%" | ||
| 359 | setControlScale(value.toInt()) | ||
| 360 | }) | ||
| 361 | } | ||
| 362 | inputOpacitySlider.apply { | ||
| 363 | valueTo = 100F | ||
| 364 | value = preferences.getInt(Settings.PREF_CONTROL_OPACITY, 100).toFloat() | ||
| 365 | addOnChangeListener(Slider.OnChangeListener { _, value, _ -> | ||
| 366 | inputOpacityValue.text = "${value.toInt()}%" | ||
| 367 | setControlOpacity(value.toInt()) | ||
| 368 | }) | ||
| 369 | } | ||
| 370 | inputScaleValue.text = "${inputScaleSlider.value.toInt()}%" | ||
| 371 | inputOpacityValue.text = "${inputOpacitySlider.value.toInt()}%" | ||
| 372 | } | ||
| 373 | |||
| 374 | MaterialAlertDialogBuilder(requireContext()) | ||
| 375 | .setTitle(R.string.emulation_control_adjust) | ||
| 376 | .setView(adjustBinding.root) | ||
| 377 | .setPositiveButton(android.R.string.ok, null) | ||
| 378 | .setNeutralButton(R.string.slider_default) { _: DialogInterface?, _: Int -> | ||
| 379 | setControlScale(50) | ||
| 380 | setControlOpacity(100) | ||
| 381 | } | ||
| 382 | .show() | ||
| 383 | } | ||
| 384 | |||
| 385 | private fun setControlScale(scale: Int) { | ||
| 386 | preferences.edit() | ||
| 387 | .putInt(Settings.PREF_CONTROL_SCALE, scale) | ||
| 388 | .apply() | ||
| 389 | refreshInputOverlay() | ||
| 390 | } | ||
| 391 | |||
| 392 | private fun setControlOpacity(opacity: Int) { | ||
| 393 | preferences.edit() | ||
| 394 | .putInt(Settings.PREF_CONTROL_OPACITY, opacity) | ||
| 395 | .apply() | ||
| 396 | refreshInputOverlay() | ||
| 397 | } | ||
| 343 | 398 | ||
| 344 | private fun setInsets() { | 399 | private fun setInsets() { |
| 345 | ViewCompat.setOnApplyWindowInsetsListener(binding.inGameMenu) { v: View, windowInsets: WindowInsetsCompat -> | 400 | ViewCompat.setOnApplyWindowInsetsListener(binding.inGameMenu) { v: View, windowInsets: WindowInsetsCompat -> |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt index bb20e5207..693e70973 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlay.kt | |||
| @@ -49,9 +49,6 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context | |||
| 49 | private var dpadBeingConfigured: InputOverlayDrawableDpad? = null | 49 | private var dpadBeingConfigured: InputOverlayDrawableDpad? = null |
| 50 | private var joystickBeingConfigured: InputOverlayDrawableJoystick? = null | 50 | private var joystickBeingConfigured: InputOverlayDrawableJoystick? = null |
| 51 | 51 | ||
| 52 | private val preferences: SharedPreferences = | ||
| 53 | PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) | ||
| 54 | |||
| 55 | private lateinit var windowInsets: WindowInsets | 52 | private lateinit var windowInsets: WindowInsets |
| 56 | 53 | ||
| 57 | override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { | 54 | override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) { |
| @@ -709,6 +706,9 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context | |||
| 709 | } | 706 | } |
| 710 | 707 | ||
| 711 | companion object { | 708 | companion object { |
| 709 | private val preferences: SharedPreferences = | ||
| 710 | PreferenceManager.getDefaultSharedPreferences(YuzuApplication.appContext) | ||
| 711 | |||
| 712 | /** | 712 | /** |
| 713 | * Resizes a [Bitmap] by a given scale factor | 713 | * Resizes a [Bitmap] by a given scale factor |
| 714 | * | 714 | * |
| @@ -899,6 +899,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context | |||
| 899 | drawableX - (width / 2), | 899 | drawableX - (width / 2), |
| 900 | drawableY - (height / 2) | 900 | drawableY - (height / 2) |
| 901 | ) | 901 | ) |
| 902 | val savedOpacity = preferences.getInt(Settings.PREF_CONTROL_OPACITY, 100) | ||
| 903 | overlayDrawable.setOpacity(savedOpacity * 255 / 100) | ||
| 902 | return overlayDrawable | 904 | return overlayDrawable |
| 903 | } | 905 | } |
| 904 | 906 | ||
| @@ -973,6 +975,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context | |||
| 973 | 975 | ||
| 974 | // Need to set the image's position | 976 | // Need to set the image's position |
| 975 | overlayDrawable.setPosition(drawableX - (width / 2), drawableY - (height / 2)) | 977 | overlayDrawable.setPosition(drawableX - (width / 2), drawableY - (height / 2)) |
| 978 | val savedOpacity = preferences.getInt(Settings.PREF_CONTROL_OPACITY, 100) | ||
| 979 | overlayDrawable.setOpacity(savedOpacity * 255 / 100) | ||
| 976 | return overlayDrawable | 980 | return overlayDrawable |
| 977 | } | 981 | } |
| 978 | 982 | ||
| @@ -1052,6 +1056,8 @@ class InputOverlay(context: Context, attrs: AttributeSet?) : SurfaceView(context | |||
| 1052 | 1056 | ||
| 1053 | // Need to set the image's position | 1057 | // Need to set the image's position |
| 1054 | overlayDrawable.setPosition(drawableX, drawableY) | 1058 | overlayDrawable.setPosition(drawableX, drawableY) |
| 1059 | val savedOpacity = preferences.getInt(Settings.PREF_CONTROL_OPACITY, 100) | ||
| 1060 | overlayDrawable.setOpacity(savedOpacity * 255 / 100) | ||
| 1055 | return overlayDrawable | 1061 | return overlayDrawable |
| 1056 | } | 1062 | } |
| 1057 | } | 1063 | } |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableButton.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableButton.kt index 99d7d9521..4a93e0b14 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableButton.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableButton.kt | |||
| @@ -114,6 +114,7 @@ class InputOverlayDrawableButton( | |||
| 114 | controlPositionX = fingerPositionX - (width / 2) | 114 | controlPositionX = fingerPositionX - (width / 2) |
| 115 | controlPositionY = fingerPositionY - (height / 2) | 115 | controlPositionY = fingerPositionY - (height / 2) |
| 116 | } | 116 | } |
| 117 | |||
| 117 | MotionEvent.ACTION_MOVE -> { | 118 | MotionEvent.ACTION_MOVE -> { |
| 118 | controlPositionX += fingerPositionX - previousTouchX | 119 | controlPositionX += fingerPositionX - previousTouchX |
| 119 | controlPositionY += fingerPositionY - previousTouchY | 120 | controlPositionY += fingerPositionY - previousTouchY |
| @@ -135,6 +136,11 @@ class InputOverlayDrawableButton( | |||
| 135 | pressedStateBitmap.setBounds(left, top, right, bottom) | 136 | pressedStateBitmap.setBounds(left, top, right, bottom) |
| 136 | } | 137 | } |
| 137 | 138 | ||
| 139 | fun setOpacity(value: Int) { | ||
| 140 | defaultStateBitmap.alpha = value | ||
| 141 | pressedStateBitmap.alpha = value | ||
| 142 | } | ||
| 143 | |||
| 138 | val status: Int | 144 | val status: Int |
| 139 | get() = if (pressedState) ButtonState.PRESSED else ButtonState.RELEASED | 145 | get() = if (pressedState) ButtonState.PRESSED else ButtonState.RELEASED |
| 140 | val bounds: Rect | 146 | val bounds: Rect |
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableDpad.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableDpad.kt index 625cad661..43d664d21 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableDpad.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableDpad.kt | |||
| @@ -231,6 +231,7 @@ class InputOverlayDrawableDpad( | |||
| 231 | previousTouchX = fingerPositionX | 231 | previousTouchX = fingerPositionX |
| 232 | previousTouchY = fingerPositionY | 232 | previousTouchY = fingerPositionY |
| 233 | } | 233 | } |
| 234 | |||
| 234 | MotionEvent.ACTION_MOVE -> { | 235 | MotionEvent.ACTION_MOVE -> { |
| 235 | controlPositionX += fingerPositionX - previousTouchX | 236 | controlPositionX += fingerPositionX - previousTouchX |
| 236 | controlPositionY += fingerPositionY - previousTouchY | 237 | controlPositionY += fingerPositionY - previousTouchY |
| @@ -258,6 +259,12 @@ class InputOverlayDrawableDpad( | |||
| 258 | pressedTwoDirectionsStateBitmap.setBounds(left, top, right, bottom) | 259 | pressedTwoDirectionsStateBitmap.setBounds(left, top, right, bottom) |
| 259 | } | 260 | } |
| 260 | 261 | ||
| 262 | fun setOpacity(value: Int) { | ||
| 263 | defaultStateBitmap.alpha = value | ||
| 264 | pressedOneDirectionStateBitmap.alpha = value | ||
| 265 | pressedTwoDirectionsStateBitmap.alpha = value | ||
| 266 | } | ||
| 267 | |||
| 261 | val bounds: Rect | 268 | val bounds: Rect |
| 262 | get() = defaultStateBitmap.bounds | 269 | get() = defaultStateBitmap.bounds |
| 263 | 270 | ||
diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableJoystick.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableJoystick.kt index 1960eaff0..f1d32192a 100644 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableJoystick.kt +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/overlay/InputOverlayDrawableJoystick.kt | |||
| @@ -48,6 +48,8 @@ class InputOverlayDrawableJoystick( | |||
| 48 | val width: Int | 48 | val width: Int |
| 49 | val height: Int | 49 | val height: Int |
| 50 | 50 | ||
| 51 | private var opacity: Int = 0 | ||
| 52 | |||
| 51 | private var virtBounds: Rect | 53 | private var virtBounds: Rect |
| 52 | private var origBounds: Rect | 54 | private var origBounds: Rect |
| 53 | 55 | ||
| @@ -121,7 +123,7 @@ class InputOverlayDrawableJoystick( | |||
| 121 | } | 123 | } |
| 122 | pressedState = true | 124 | pressedState = true |
| 123 | outerBitmap.alpha = 0 | 125 | outerBitmap.alpha = 0 |
| 124 | boundsBoxBitmap.alpha = 255 | 126 | boundsBoxBitmap.alpha = opacity |
| 125 | if (EmulationMenuSettings.joystickRelCenter) { | 127 | if (EmulationMenuSettings.joystickRelCenter) { |
| 126 | virtBounds.offset( | 128 | virtBounds.offset( |
| 127 | xPosition - virtBounds.centerX(), | 129 | xPosition - virtBounds.centerX(), |
| @@ -139,7 +141,7 @@ class InputOverlayDrawableJoystick( | |||
| 139 | pressedState = false | 141 | pressedState = false |
| 140 | xAxis = 0.0f | 142 | xAxis = 0.0f |
| 141 | yAxis = 0.0f | 143 | yAxis = 0.0f |
| 142 | outerBitmap.alpha = 255 | 144 | outerBitmap.alpha = opacity |
| 143 | boundsBoxBitmap.alpha = 0 | 145 | boundsBoxBitmap.alpha = 0 |
| 144 | virtBounds = Rect( | 146 | virtBounds = Rect( |
| 145 | origBounds.left, | 147 | origBounds.left, |
| @@ -203,6 +205,7 @@ class InputOverlayDrawableJoystick( | |||
| 203 | controlPositionX = fingerPositionX - (width / 2) | 205 | controlPositionX = fingerPositionX - (width / 2) |
| 204 | controlPositionY = fingerPositionY - (height / 2) | 206 | controlPositionY = fingerPositionY - (height / 2) |
| 205 | } | 207 | } |
| 208 | |||
| 206 | MotionEvent.ACTION_MOVE -> { | 209 | MotionEvent.ACTION_MOVE -> { |
| 207 | controlPositionX += fingerPositionX - previousTouchX | 210 | controlPositionX += fingerPositionX - previousTouchX |
| 208 | controlPositionY += fingerPositionY - previousTouchY | 211 | controlPositionY += fingerPositionY - previousTouchY |
| @@ -261,4 +264,19 @@ class InputOverlayDrawableJoystick( | |||
| 261 | controlPositionX = x | 264 | controlPositionX = x |
| 262 | controlPositionY = y | 265 | controlPositionY = y |
| 263 | } | 266 | } |
| 267 | |||
| 268 | fun setOpacity(value: Int) { | ||
| 269 | opacity = value | ||
| 270 | |||
| 271 | defaultStateInnerBitmap.alpha = value | ||
| 272 | pressedStateInnerBitmap.alpha = value | ||
| 273 | |||
| 274 | if (trackId == -1) { | ||
| 275 | outerBitmap.alpha = value | ||
| 276 | boundsBoxBitmap.alpha = 0 | ||
| 277 | } else { | ||
| 278 | outerBitmap.alpha = 0 | ||
| 279 | boundsBoxBitmap.alpha = value | ||
| 280 | } | ||
| 281 | } | ||
| 264 | } | 282 | } |
diff --git a/src/android/app/src/main/res/layout/dialog_overlay_adjust.xml b/src/android/app/src/main/res/layout/dialog_overlay_adjust.xml new file mode 100644 index 000000000..59bb983e1 --- /dev/null +++ b/src/android/app/src/main/res/layout/dialog_overlay_adjust.xml | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <androidx.constraintlayout.widget.ConstraintLayout | ||
| 3 | xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 4 | xmlns:tools="http://schemas.android.com/tools" | ||
| 5 | xmlns:app="http://schemas.android.com/apk/res-auto" | ||
| 6 | android:layout_width="match_parent" | ||
| 7 | android:layout_height="match_parent"> | ||
| 8 | |||
| 9 | <TextView | ||
| 10 | android:id="@+id/input_scale_name" | ||
| 11 | android:layout_width="wrap_content" | ||
| 12 | android:layout_height="wrap_content" | ||
| 13 | android:layout_marginTop="16dp" | ||
| 14 | android:text="@string/emulation_control_scale" | ||
| 15 | android:textAlignment="viewStart" | ||
| 16 | android:textSize="16sp" | ||
| 17 | app:layout_constraintStart_toStartOf="@+id/input_scale_slider" | ||
| 18 | app:layout_constraintTop_toTopOf="parent" /> | ||
| 19 | |||
| 20 | <com.google.android.material.slider.Slider | ||
| 21 | android:id="@+id/input_scale_slider" | ||
| 22 | android:layout_width="0dp" | ||
| 23 | android:layout_height="wrap_content" | ||
| 24 | android:layout_marginHorizontal="24dp" | ||
| 25 | app:layout_constraintEnd_toEndOf="parent" | ||
| 26 | app:layout_constraintStart_toStartOf="parent" | ||
| 27 | app:layout_constraintTop_toBottomOf="@+id/input_scale_name" /> | ||
| 28 | |||
| 29 | <TextView | ||
| 30 | android:id="@+id/input_scale_value" | ||
| 31 | android:layout_width="wrap_content" | ||
| 32 | android:layout_height="wrap_content" | ||
| 33 | android:gravity="end" | ||
| 34 | app:layout_constraintBottom_toTopOf="@+id/input_scale_slider" | ||
| 35 | app:layout_constraintEnd_toEndOf="@+id/input_scale_slider" | ||
| 36 | tools:text="100%" /> | ||
| 37 | |||
| 38 | <TextView | ||
| 39 | android:id="@+id/input_opacity_name" | ||
| 40 | android:layout_width="wrap_content" | ||
| 41 | android:layout_height="wrap_content" | ||
| 42 | android:layout_marginTop="16dp" | ||
| 43 | android:text="@string/emulation_control_opacity" | ||
| 44 | android:textAlignment="viewStart" | ||
| 45 | android:textSize="16sp" | ||
| 46 | app:layout_constraintStart_toStartOf="@+id/input_opacity_slider" | ||
| 47 | app:layout_constraintTop_toBottomOf="@+id/input_scale_slider" /> | ||
| 48 | |||
| 49 | <com.google.android.material.slider.Slider | ||
| 50 | android:id="@+id/input_opacity_slider" | ||
| 51 | android:layout_width="0dp" | ||
| 52 | android:layout_height="wrap_content" | ||
| 53 | android:layout_marginHorizontal="24dp" | ||
| 54 | app:layout_constraintEnd_toEndOf="parent" | ||
| 55 | app:layout_constraintStart_toStartOf="parent" | ||
| 56 | app:layout_constraintTop_toBottomOf="@+id/input_opacity_name" /> | ||
| 57 | |||
| 58 | <TextView | ||
| 59 | android:id="@+id/input_opacity_value" | ||
| 60 | android:layout_width="wrap_content" | ||
| 61 | android:layout_height="wrap_content" | ||
| 62 | android:gravity="end" | ||
| 63 | app:layout_constraintBottom_toTopOf="@+id/input_opacity_slider" | ||
| 64 | app:layout_constraintEnd_toEndOf="@+id/input_opacity_slider" | ||
| 65 | tools:text="100%" /> | ||
| 66 | |||
| 67 | </androidx.constraintlayout.widget.ConstraintLayout> | ||
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 09e8b7970..4885b4f6f 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 | |||
| @@ -11,6 +11,10 @@ | |||
| 11 | android:title="@string/emulation_touch_overlay_edit" /> | 11 | android:title="@string/emulation_touch_overlay_edit" /> |
| 12 | 12 | ||
| 13 | <item | 13 | <item |
| 14 | android:id="@+id/menu_adjust_overlay" | ||
| 15 | android:title="@string/emulation_control_adjust" /> | ||
| 16 | |||
| 17 | <item | ||
| 14 | android:id="@+id/menu_toggle_controls" | 18 | android:id="@+id/menu_toggle_controls" |
| 15 | android:title="@string/emulation_toggle_controls" /> | 19 | android:title="@string/emulation_toggle_controls" /> |
| 16 | 20 | ||
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml index d3340fe99..5e44551ad 100644 --- a/src/android/app/src/main/res/values/strings.xml +++ b/src/android/app/src/main/res/values/strings.xml | |||
| @@ -204,7 +204,9 @@ | |||
| 204 | <string name="emulation_haptics">Haptics</string> | 204 | <string name="emulation_haptics">Haptics</string> |
| 205 | <string name="emulation_show_overlay">Show Overlay</string> | 205 | <string name="emulation_show_overlay">Show Overlay</string> |
| 206 | <string name="emulation_toggle_all">Toggle All</string> | 206 | <string name="emulation_toggle_all">Toggle All</string> |
| 207 | <string name="emulation_control_scale">Adjust Scale</string> | 207 | <string name="emulation_control_adjust">Adjust Overlay</string> |
| 208 | <string name="emulation_control_scale">Scale</string> | ||
| 209 | <string name="emulation_control_opacity">Opacity</string> | ||
| 208 | <string name="emulation_touch_overlay_reset">Reset Overlay</string> | 210 | <string name="emulation_touch_overlay_reset">Reset Overlay</string> |
| 209 | <string name="emulation_touch_overlay_edit">Edit Overlay</string> | 211 | <string name="emulation_touch_overlay_edit">Edit Overlay</string> |
| 210 | <string name="emulation_pause">Pause Emulation</string> | 212 | <string name="emulation_pause">Pause Emulation</string> |