From 6e9a35806df6f55394f5e879a880033e55011389 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 27 Feb 2021 21:59:12 +1000 Subject: [PATCH] Android: Fix touchscreen controller settings unpausing --- .../duckstation/EmulationActivity.java | 24 ++++++++++++------- .../TouchscreenControllerView.java | 4 ++++ android/app/src/main/res/values/strings.xml | 1 + 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java b/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java index 3a2b5ae88..8cc180c6c 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java @@ -517,9 +517,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde private void showTouchscreenControllerMenu() { AlertDialog.Builder builder = new AlertDialog.Builder(this); - if (mGameTitle != null && !mGameTitle.isEmpty()) - builder.setTitle(mGameTitle); - + builder.setTitle(R.string.dialog_touchscreen_controller_settings); builder.setItems(R.array.emulation_touchscreen_menu, (dialogInterface, i) -> { switch (i) { case 0: // Change Type @@ -554,7 +552,10 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde AlertDialog.Builder subBuilder = mTouchscreenController.createOpacityDialog(this); subBuilder.setOnDismissListener(dialog -> onMenuClosed()); subBuilder.create().show(); + } else { + onMenuClosed(); } + } break; @@ -564,25 +565,30 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde AlertDialog.Builder subBuilder = mTouchscreenController.createAddRemoveButtonDialog(this); subBuilder.setOnDismissListener(dialog -> onMenuClosed()); subBuilder.create().show(); + } else { + onMenuClosed(); } } break; case 3: // Edit Layout { - if (mTouchscreenController != null) + if (mTouchscreenController != null) { + // we deliberately don't call onMenuClosed() here to keep the system paused. + // but we need to re-enable immersive mode to get proper editing. + enableFullscreenImmersive(); mTouchscreenController.startLayoutEditing(); + } else { + // no controller + onMenuClosed(); + } } break; } }); - builder.setOnDismissListener(dialogInterface -> onMenuClosed()); + builder.setOnCancelListener(dialogInterface -> onMenuClosed()); builder.create().show(); - - /* - - */ } private void showPatchesMenu() { diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java index 9fb537904..0ce216a6a 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/TouchscreenControllerView.java @@ -352,6 +352,10 @@ public class TouchscreenControllerView extends FrameLayout { mMovingName = null; mMovingLastX = 0.0f; mMovingLastY = 0.0f; + + // unpause if we're paused (from the setting) + if (AndroidHostInterface.getInstance().isEmulationThreadPaused()) + AndroidHostInterface.getInstance().pauseEmulationThread(false); } private boolean handleEditingTouchEvent(MotionEvent event) { diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 7e51c20e1..429b57078 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -225,4 +225,5 @@ Touchscreen Controller Type Touchscreen Controller Opacity Touchscreen Controller Buttons + Touchscreen Controller Settings