From 77eb9ce725dc9a3f17394318356bcde39562169e Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 25 Oct 2013 23:10:17 -0400 Subject: [PATCH] [Android] Add the capability to dynamically enable and disable the input overlay during emulation. --- Source/Android/res/menu/emuwindow_overlay.xml | 11 +++- Source/Android/res/values-ja/strings.xml | 2 + Source/Android/res/values/strings.xml | 2 + .../emulation/EmulationActivity.java | 65 ++++++++++++++++--- 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/Source/Android/res/menu/emuwindow_overlay.xml b/Source/Android/res/menu/emuwindow_overlay.xml index d1c480c284..88b50f907d 100644 --- a/Source/Android/res/menu/emuwindow_overlay.xml +++ b/Source/Android/res/menu/emuwindow_overlay.xml @@ -1,4 +1,12 @@ + + + + + + diff --git a/Source/Android/res/values-ja/strings.xml b/Source/Android/res/values-ja/strings.xml index 4ecd85fd62..bab2d74b0a 100644 --- a/Source/Android/res/values-ja/strings.xml +++ b/Source/Android/res/values-ja/strings.xml @@ -29,6 +29,8 @@ クリックされたファイル: %1$s + 入力オーバーレイを有効 + 入力オーバーレイを無効 ステートセーブ ステートロード 終了 diff --git a/Source/Android/res/values/strings.xml b/Source/Android/res/values/strings.xml index b4943e8632..6c26d8828c 100644 --- a/Source/Android/res/values/strings.xml +++ b/Source/Android/res/values/strings.xml @@ -29,6 +29,8 @@ File clicked: %1$s + Enable Input Overlay + Disable Input Overlay Save State Load State Exit diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java index 8b8f4e0551..1d8b2afe17 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/emulation/EmulationActivity.java @@ -36,6 +36,7 @@ public final class EmulationActivity extends Activity private boolean IsActionBarHidden = false; private float screenWidth; private float screenHeight; + private SharedPreferences sharedPrefs; @Override public void onCreate(Bundle savedInstanceState) @@ -60,29 +61,36 @@ public final class EmulationActivity extends Activity getActionBar().setBackgroundDrawable(actionBarBackground); // Set the native rendering screen width/height. - // Also get the intent passed from the GameList when the game - // was selected. This is so the path of the game can be retrieved - // and set on the native side of the code so the emulator can actually - // load the game. - Intent gameToEmulate = getIntent(); - + // // Due to a bug in Adreno, it renders the screen rotated 90 degrees when using OpenGL // Flip the width and height when on Adreno to work around this. // Mali isn't affected by this bug. - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); - if (prefs.getString("gpuPref", "Software Rendering").equals("OGL") + sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); + if (sharedPrefs.getString("gpuPref", "Software Rendering").equals("OGL") && VideoSettingsFragment.SupportsGLES3() && VideoSettingsFragment.m_GLVendor != null && VideoSettingsFragment.m_GLVendor.equals("Qualcomm")) NativeLibrary.SetDimensions((int)screenHeight, (int)screenWidth); else NativeLibrary.SetDimensions((int)screenWidth, (int)screenHeight); + + // Get the intent passed from the GameList when the game + // was selected. This is so the path of the game can be retrieved + // and set on the native side of the code so the emulator can actually + // load the game. + Intent gameToEmulate = getIntent(); NativeLibrary.SetFilename(gameToEmulate.getStringExtra("SelectedGame")); Running = true; // Set the emulation window. setContentView(R.layout.emulation_view); + // If the input overlay was previously disabled, then don't show it. + if (!sharedPrefs.getBoolean("showInputOverlay", true)) + { + findViewById(R.id.emulationControlOverlay).setVisibility(View.INVISIBLE); + } + // Hide the action bar by default so it doesn't get in the way. getActionBar().hide(); IsActionBarHidden = true; @@ -168,11 +176,50 @@ public final class EmulationActivity extends Activity return true; } + @Override + public boolean onPrepareOptionsMenu(Menu menu) + { + // Determine which string the "Enable Input Overlay" menu item should have + // depending on its visibility at the time of preparing the options menu. + if (!sharedPrefs.getBoolean("showInputOverlay", true)) + { + menu.findItem(R.id.enableInputOverlay).setTitle(R.string.enable_input_overlay); + } + else + { + menu.findItem(R.id.enableInputOverlay).setTitle(R.string.disable_input_overlay); + } + + return true; + } + @Override public boolean onMenuItemSelected(int itemId, MenuItem item) { switch(item.getItemId()) { + // Enable/Disable input overlay. + case R.id.enableInputOverlay: + { + View overlay = findViewById(R.id.emulationControlOverlay); + + // Show the overlay + if (item.getTitle().equals(getString(R.string.enable_input_overlay))) + { + overlay.setVisibility(View.VISIBLE); + item.setTitle(R.string.disable_input_overlay); + sharedPrefs.edit().putBoolean("showInputOverlay", true).commit(); + } + else // Hide the overlay + { + overlay.setVisibility(View.INVISIBLE); + item.setTitle(R.string.enable_input_overlay); + sharedPrefs.edit().putBoolean("showInputOverlay", false).commit(); + } + + return true; + } + // Save state slots case R.id.saveSlot1: NativeLibrary.SaveState(0); @@ -194,7 +241,7 @@ public final class EmulationActivity extends Activity NativeLibrary.SaveState(4); return true; - // Load state slot + // Load state slots case R.id.loadSlot1: NativeLibrary.LoadState(0); return true;