diff --git a/src/android/app/src/main/java/info/cemu/Cemu/emulation/EmulationActivity.java b/src/android/app/src/main/java/info/cemu/Cemu/emulation/EmulationActivity.java
index 001261eb0..2d5b6e687 100644
--- a/src/android/app/src/main/java/info/cemu/Cemu/emulation/EmulationActivity.java
+++ b/src/android/app/src/main/java/info/cemu/Cemu/emulation/EmulationActivity.java
@@ -6,6 +6,7 @@
import android.view.KeyEvent;
import android.view.MotionEvent;
+import androidx.activity.OnBackPressedCallback;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
@@ -44,6 +45,13 @@ public boolean dispatchKeyEvent(KeyEvent event) {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
+ @Override
+ public void handleOnBackPressed() {
+ showExitConfirmationDialog();
+ }
+ });
+
viewModel = new ViewModelProvider(this).get(EmulationViewModel.class);
viewModel.getEmulationData().observe(this, this);
Intent intent = getIntent();
@@ -70,11 +78,7 @@ protected void onCreate(Bundle savedInstanceState) {
.add(R.id.emulation_frame, emulationFragment)
.commit();
}
- }
- @Override
- public void onBackPressed() {
- showExitConfirmationDialog();
}
private void showExitConfirmationDialog() {
diff --git a/src/android/app/src/main/java/info/cemu/Cemu/emulation/EmulationFragment.java b/src/android/app/src/main/java/info/cemu/Cemu/emulation/EmulationFragment.java
index c0d85740d..833643dd8 100644
--- a/src/android/app/src/main/java/info/cemu/Cemu/emulation/EmulationFragment.java
+++ b/src/android/app/src/main/java/info/cemu/Cemu/emulation/EmulationFragment.java
@@ -228,6 +228,20 @@ public boolean onMenuItemClick(MenuItem item) {
else
sensorManager.pauseListening();
item.setChecked(isMotionEnabled);
+ return true;
+ }
+ if (itemId == R.id.exit_emulation) {
+ requireActivity().getOnBackPressedDispatcher().onBackPressed();
+ return true;
+ }
+ if (itemId == R.id.show_input_overlay) {
+ boolean showInputOverlay = !item.isChecked();
+ var menu = settingsMenu.getMenu();
+ menu.findItem(R.id.edit_inputs).setEnabled(showInputOverlay);
+ menu.findItem(R.id.reset_inputs).setEnabled(showInputOverlay);
+ item.setChecked(showInputOverlay);
+ inputOverlaySurfaceView.setVisibility(showInputOverlay ? View.VISIBLE : View.GONE);
+ return true;
}
return false;
}
@@ -265,8 +279,11 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
settingsMenu.getMenuInflater().inflate(R.menu.menu_emulation_in_game, settingsMenu.getMenu());
settingsMenu.setOnMenuItemClickListener(EmulationFragment.this);
binding.emulationSettingsButton.setOnClickListener(v -> settingsMenu.show());
-
+ var menu = settingsMenu.getMenu();
+ menu.findItem(R.id.show_input_overlay).setChecked(overlaySettings.isOverlayEnabled());
if (!overlaySettings.isOverlayEnabled()) {
+ menu.findItem(R.id.reset_inputs).setEnabled(false);
+ menu.findItem(R.id.edit_inputs).setEnabled(false);
inputOverlaySurfaceView.setVisibility(View.GONE);
}
SurfaceView mainCanvas = binding.mainCanvas;
diff --git a/src/android/app/src/main/java/info/cemu/Cemu/inputoverlay/InputOverlaySurfaceView.java b/src/android/app/src/main/java/info/cemu/Cemu/inputoverlay/InputOverlaySurfaceView.java
index c4ff440ee..bb1534e3a 100644
--- a/src/android/app/src/main/java/info/cemu/Cemu/inputoverlay/InputOverlaySurfaceView.java
+++ b/src/android/app/src/main/java/info/cemu/Cemu/inputoverlay/InputOverlaySurfaceView.java
@@ -26,6 +26,7 @@ public enum InputMode {
private InputMode inputMode = InputMode.DEFAULT;
public void resetInputs() {
+ if (inputs == null) return;
int width = getWidth();
int height = getHeight();
for (var input : InputOverlaySettingsProvider.Input.values()) {
diff --git a/src/android/app/src/main/res/menu/menu_emulation_in_game.xml b/src/android/app/src/main/res/menu/menu_emulation_in_game.xml
index 3ae28817c..6ecd8e9f3 100644
--- a/src/android/app/src/main/res/menu/menu_emulation_in_game.xml
+++ b/src/android/app/src/main/res/menu/menu_emulation_in_game.xml
@@ -17,5 +17,12 @@
android:title="@string/edit_inputs" />
+ android:title="@string/reset_input_overlay" />
+
+
diff --git a/src/android/app/src/main/res/values/strings.xml b/src/android/app/src/main/res/values/strings.xml
index 771c88e97..187667837 100644
--- a/src/android/app/src/main/res/values/strings.xml
+++ b/src/android/app/src/main/res/values/strings.xml
@@ -158,7 +158,7 @@
Done
Move inputs
Resize inputs
- Reset overlay inputs
+ Reset input overlay
Edit inputs
Show pad
Replace TV with PAD
@@ -189,4 +189,6 @@
Downscale filter
Overlay text scale
Notifications text scale
+ Exit
+ Show input overlay
\ No newline at end of file