Android: Fix touchscreen controller settings unpausing

This commit is contained in:
Connor McLaughlin 2021-02-27 21:59:12 +10:00
parent 49345a300c
commit 6e9a35806d
3 changed files with 20 additions and 9 deletions

View file

@ -517,9 +517,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
private void showTouchscreenControllerMenu() { private void showTouchscreenControllerMenu() {
AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog.Builder builder = new AlertDialog.Builder(this);
if (mGameTitle != null && !mGameTitle.isEmpty()) builder.setTitle(R.string.dialog_touchscreen_controller_settings);
builder.setTitle(mGameTitle);
builder.setItems(R.array.emulation_touchscreen_menu, (dialogInterface, i) -> { builder.setItems(R.array.emulation_touchscreen_menu, (dialogInterface, i) -> {
switch (i) { switch (i) {
case 0: // Change Type case 0: // Change Type
@ -554,7 +552,10 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
AlertDialog.Builder subBuilder = mTouchscreenController.createOpacityDialog(this); AlertDialog.Builder subBuilder = mTouchscreenController.createOpacityDialog(this);
subBuilder.setOnDismissListener(dialog -> onMenuClosed()); subBuilder.setOnDismissListener(dialog -> onMenuClosed());
subBuilder.create().show(); subBuilder.create().show();
} else {
onMenuClosed();
} }
} }
break; break;
@ -564,25 +565,30 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
AlertDialog.Builder subBuilder = mTouchscreenController.createAddRemoveButtonDialog(this); AlertDialog.Builder subBuilder = mTouchscreenController.createAddRemoveButtonDialog(this);
subBuilder.setOnDismissListener(dialog -> onMenuClosed()); subBuilder.setOnDismissListener(dialog -> onMenuClosed());
subBuilder.create().show(); subBuilder.create().show();
} else {
onMenuClosed();
} }
} }
break; break;
case 3: // Edit Layout 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(); mTouchscreenController.startLayoutEditing();
} else {
// no controller
onMenuClosed();
}
} }
break; break;
} }
}); });
builder.setOnDismissListener(dialogInterface -> onMenuClosed()); builder.setOnCancelListener(dialogInterface -> onMenuClosed());
builder.create().show(); builder.create().show();
/*
*/
} }
private void showPatchesMenu() { private void showPatchesMenu() {

View file

@ -352,6 +352,10 @@ public class TouchscreenControllerView extends FrameLayout {
mMovingName = null; mMovingName = null;
mMovingLastX = 0.0f; mMovingLastX = 0.0f;
mMovingLastY = 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) { private boolean handleEditingTouchEvent(MotionEvent event) {

View file

@ -225,4 +225,5 @@
<string name="dialog_touchscreen_controller_type">Touchscreen Controller Type</string> <string name="dialog_touchscreen_controller_type">Touchscreen Controller Type</string>
<string name="dialog_touchscreen_controller_opacity">Touchscreen Controller Opacity</string> <string name="dialog_touchscreen_controller_opacity">Touchscreen Controller Opacity</string>
<string name="dialog_touchscreen_controller_buttons">Touchscreen Controller Buttons</string> <string name="dialog_touchscreen_controller_buttons">Touchscreen Controller Buttons</string>
<string name="dialog_touchscreen_controller_settings">Touchscreen Controller Settings</string>
</resources> </resources>