mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-03 20:54:28 +00:00
[Android] Add the capability to dynamically enable and disable the input overlay during emulation.
This commit is contained in:
parent
d9be95ed9e
commit
77eb9ce725
@ -1,4 +1,12 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- Enable/Disabe Input Overlay -->
|
||||
<item
|
||||
android:id="@+id/enableInputOverlay"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/disable_input_overlay"/>
|
||||
|
||||
<!-- Save State Slots -->
|
||||
<item
|
||||
android:id="@+id/saveStateRoot"
|
||||
android:showAsAction="ifRoom"
|
||||
@ -21,6 +29,7 @@
|
||||
</menu>
|
||||
</item>
|
||||
|
||||
<!-- Load State Slots -->
|
||||
<item
|
||||
android:id="@+id/loadStateRoot"
|
||||
android:showAsAction="ifRoom"
|
||||
@ -45,7 +54,7 @@
|
||||
|
||||
<item
|
||||
android:id="@+id/exitEmulation"
|
||||
android:showAsAction="always"
|
||||
android:showAsAction="ifRoom"
|
||||
android:title="@string/overlay_exit_emulation">
|
||||
</item>
|
||||
</menu>
|
||||
|
@ -29,6 +29,8 @@
|
||||
<string name="file_clicked">クリックされたファイル: %1$s</string>
|
||||
|
||||
<!-- Emulation Window Overlay -->
|
||||
<string name="enable_input_overlay">入力オーバーレイを有効</string>
|
||||
<string name="disable_input_overlay">入力オーバーレイを無効</string>
|
||||
<string name="overlay_savestate">ステートセーブ</string>
|
||||
<string name="overlay_loadstate">ステートロード</string>
|
||||
<string name="overlay_exit_emulation">終了</string>
|
||||
|
@ -29,6 +29,8 @@
|
||||
<string name="file_clicked">File clicked: %1$s</string>
|
||||
|
||||
<!-- Emulation Overlay -->
|
||||
<string name="enable_input_overlay">Enable Input Overlay</string>
|
||||
<string name="disable_input_overlay">Disable Input Overlay</string>
|
||||
<string name="overlay_savestate">Save State</string>
|
||||
<string name="overlay_loadstate">Load State</string>
|
||||
<string name="overlay_exit_emulation">Exit</string>
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user