diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
index 7ac735e7d9..7aa2800ea4 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java
@@ -2,13 +2,17 @@ package org.dolphinemu.dolphinemu.activities;
import android.app.Activity;
import android.app.ActivityOptions;
+import android.app.AlertDialog;
import android.app.Fragment;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
+import android.content.SharedPreferences;
import android.hardware.usb.UsbManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.view.InputDevice;
import android.view.KeyEvent;
@@ -48,6 +52,8 @@ public final class EmulationActivity extends AppCompatActivity
private String mSubmenuFragmentTag;
+ private SharedPreferences mPreferences;
+
// So that MainActivity knows which view to invalidate before the return animation.
private int mPosition;
@@ -212,6 +218,8 @@ public final class EmulationActivity extends AppCompatActivity
}
}
+ mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
+
mIsGameCubeGame = (NativeLibrary.GetPlatform(path) == 0);
}
@@ -387,13 +395,92 @@ public final class EmulationActivity extends AppCompatActivity
{
switch (id)
{
- // Enable/Disable input overlay.
+ // Enable/Disable specific buttons or the entire input overlay.
case R.id.menu_emulation_input_overlay:
{
- EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
- .findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
+ boolean[] enabledButtons = new boolean[11];
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.emulation_toggle_input);
+ if (mIsGameCubeGame)
+ {
+ for (int i = 0; i < enabledButtons.length; i++)
+ {
+ enabledButtons[i] = mPreferences.getBoolean("buttonToggleGc" + i, true);
+ }
+ builder.setMultiChoiceItems(R.array.gcpadButtons, enabledButtons,
+ new DialogInterface.OnMultiChoiceClickListener()
+ {
+ @Override
+ public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked)
+ {
+ SharedPreferences.Editor editor = mPreferences.edit();
- emulationFragment.toggleInputOverlayVisibility();
+ if (mPreferences.getBoolean("buttonToggleGc" + indexSelected, true))
+ {
+ // If the button is enabled, disable it.
+ editor.putBoolean("buttonToggleGc" + indexSelected, false);
+ }
+ else
+ {
+ // If the button is disabled, enable it.
+ editor.putBoolean("buttonToggleGc" + indexSelected, true);
+ }
+ editor.apply();
+ }
+ });
+ }
+ else
+ {
+ for (int i = 0; i < enabledButtons.length; i++)
+ {
+ enabledButtons[i] = mPreferences.getBoolean("buttonToggleWii" + i, true);
+ }
+ builder.setMultiChoiceItems(R.array.wiimoteButtons, enabledButtons,
+ new DialogInterface.OnMultiChoiceClickListener()
+ {
+ @Override
+ public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked)
+ {
+ SharedPreferences.Editor editor = mPreferences.edit();
+
+ if (mPreferences.getBoolean("buttonToggleWii" + indexSelected, true))
+ {
+ // If the button is enabled, disable it.
+ editor.putBoolean("buttonToggleWii" + indexSelected, false);
+ }
+ else
+ {
+ // If the button is disabled, enable it.
+ editor.putBoolean("buttonToggleWii" + indexSelected, true);
+ }
+
+ editor.apply();
+ }
+ });
+ }
+ builder.setNeutralButton(getString(R.string.emulation_toggle_all), new DialogInterface.OnClickListener()
+ {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i)
+ {
+ EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
+ .findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
+ emulationFragment.toggleInputOverlayVisibility();
+ }
+ });
+ builder.setPositiveButton(getString(R.string.emulation_done), new DialogInterface.OnClickListener()
+ {
+ @Override
+ public void onClick(DialogInterface dialogInterface, int i)
+ {
+ EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager()
+ .findFragmentByTag(EmulationFragment.FRAGMENT_TAG);
+ emulationFragment.refreshInputOverlay();
+ }
+ });
+
+ AlertDialog alertDialog = builder.create();
+ alertDialog.show();
return;
}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java
index 56a8b60c46..b70196a773 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java
@@ -162,6 +162,11 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
editor.apply();
}
+ public void refreshInputOverlay()
+ {
+ mInputOverlay.refreshControls();
+ }
+
@Override
public void surfaceCreated(SurfaceHolder holder)
{
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java
index b37343d128..cbdcc57246 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java
@@ -46,6 +46,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
private InputOverlayDrawableDpad mDpadBeingConfigured;
private InputOverlayDrawableJoystick mJoystickBeingConfigured;
+ private SharedPreferences mPreferences;
+
/**
* Resizes a {@link Bitmap} by a given scale factor
*
@@ -78,47 +80,10 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
{
super(context, attrs);
- // Add all the overlay items to the HashSet.
- if (EmulationActivity.isGameCubeGame())
- {
- // GameCube
- overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_a, ButtonType.BUTTON_A));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_b, ButtonType.BUTTON_B));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_x, ButtonType.BUTTON_X));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_y, ButtonType.BUTTON_Y));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_z, ButtonType.BUTTON_Z));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_start, ButtonType.BUTTON_START));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_l, ButtonType.TRIGGER_L));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.gcpad_r, ButtonType.TRIGGER_R));
- overlayDpads.add(initializeOverlayDpad(context, R.drawable.gcwii_dpad,
- ButtonType.BUTTON_UP, ButtonType.BUTTON_DOWN,
- ButtonType.BUTTON_LEFT, ButtonType.BUTTON_RIGHT));
- overlayJoysticks.add(initializeOverlayJoystick(context,
- R.drawable.gcwii_joystick_range, R.drawable.gcwii_joystick,
- ButtonType.STICK_MAIN));
- overlayJoysticks.add(initializeOverlayJoystick(context,
- R.drawable.gcwii_joystick_range, R.drawable.gcpad_c,
- ButtonType.STICK_C));
- }
- else
- {
- // Wiimote + Nunchuk
- overlayButtons.add(initializeOverlayButton(context, R.drawable.wiimote_a, ButtonType.WIIMOTE_BUTTON_A));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.wiimote_b, ButtonType.WIIMOTE_BUTTON_B));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.wiimote_one, ButtonType.WIIMOTE_BUTTON_1));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.wiimote_two, ButtonType.WIIMOTE_BUTTON_2));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.wiimote_plus, ButtonType.WIIMOTE_BUTTON_PLUS));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.wiimote_minus, ButtonType.WIIMOTE_BUTTON_MINUS));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.wiimote_home, ButtonType.WIIMOTE_BUTTON_HOME));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.nunchuk_c, ButtonType.NUNCHUK_BUTTON_C));
- overlayButtons.add(initializeOverlayButton(context, R.drawable.nunchuk_z, ButtonType.NUNCHUK_BUTTON_Z));
- overlayDpads.add(initializeOverlayDpad(context, R.drawable.gcwii_dpad,
- ButtonType.WIIMOTE_UP, ButtonType.WIIMOTE_DOWN,
- ButtonType.WIIMOTE_LEFT, ButtonType.WIIMOTE_RIGHT));
- overlayJoysticks.add(initializeOverlayJoystick(context,
- R.drawable.gcwii_joystick_range, R.drawable.gcwii_joystick,
- ButtonType.NUNCHUK_STICK));
- }
+ mPreferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+ // Load the controls.
+ refreshControls();
// Set the on touch listener.
setOnTouchListener(this);
@@ -358,6 +323,124 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
return true;
}
+ public void refreshControls()
+ {
+ // Remove all the overlay buttons from the HashSet.
+ overlayButtons.removeAll(overlayButtons);
+ overlayDpads.removeAll(overlayDpads);
+ overlayJoysticks.removeAll(overlayJoysticks);
+
+ // Add all the enabled overlay items back to the HashSet.
+ if (EmulationActivity.isGameCubeGame())
+ {
+ // GameCube
+ if (mPreferences.getBoolean("buttonToggleGc0", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_a, ButtonType.BUTTON_A));
+ }
+ if (mPreferences.getBoolean("buttonToggleGc1", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_b, ButtonType.BUTTON_B));
+ }
+ if (mPreferences.getBoolean("buttonToggleGc2", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_x, ButtonType.BUTTON_X));
+ }
+ if (mPreferences.getBoolean("buttonToggleGc3", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_y, ButtonType.BUTTON_Y));
+ }
+ if (mPreferences.getBoolean("buttonToggleGc4", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_z, ButtonType.BUTTON_Z));
+ }
+ if (mPreferences.getBoolean("buttonToggleGc5", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_start, ButtonType.BUTTON_START));
+ }
+ if (mPreferences.getBoolean("buttonToggleGc6", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_l, ButtonType.TRIGGER_L));
+ }
+ if (mPreferences.getBoolean("buttonToggleGc7", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.gcpad_r, ButtonType.TRIGGER_R));
+ }
+ if (mPreferences.getBoolean("buttonToggleGc8", true))
+ {
+ overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
+ ButtonType.BUTTON_UP, ButtonType.BUTTON_DOWN,
+ ButtonType.BUTTON_LEFT, ButtonType.BUTTON_RIGHT));
+ }
+ if (mPreferences.getBoolean("buttonToggleGc9", true))
+ {
+ overlayJoysticks.add(initializeOverlayJoystick(getContext(),
+ R.drawable.gcwii_joystick_range, R.drawable.gcwii_joystick,
+ ButtonType.STICK_MAIN));
+ }
+ if (mPreferences.getBoolean("buttonToggleGc10", true))
+ {
+ overlayJoysticks.add(initializeOverlayJoystick(getContext(),
+ R.drawable.gcwii_joystick_range, R.drawable.gcpad_c,
+ ButtonType.STICK_C));
+ }
+ }
+ else
+ {
+ // Wiimote + Nunchuk
+ if (mPreferences.getBoolean("buttonToggleWii0", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_a, ButtonType.WIIMOTE_BUTTON_A));
+ }
+ if (mPreferences.getBoolean("buttonToggleWii1", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_b, ButtonType.WIIMOTE_BUTTON_B));
+ }
+ if (mPreferences.getBoolean("buttonToggleWii2", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_one, ButtonType.WIIMOTE_BUTTON_1));
+ }
+ if (mPreferences.getBoolean("buttonToggleWii3", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_two, ButtonType.WIIMOTE_BUTTON_2));
+ }
+ if (mPreferences.getBoolean("buttonToggleWii4", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_plus, ButtonType.WIIMOTE_BUTTON_PLUS));
+ }
+ if (mPreferences.getBoolean("buttonToggleWii5", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_minus, ButtonType.WIIMOTE_BUTTON_MINUS));
+ }
+ if (mPreferences.getBoolean("buttonToggleWii6", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.wiimote_home, ButtonType.WIIMOTE_BUTTON_HOME));
+ }
+ if (mPreferences.getBoolean("buttonToggleWii7", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_c, ButtonType.NUNCHUK_BUTTON_C));
+ }
+ if (mPreferences.getBoolean("buttonToggleWii8", true))
+ {
+ overlayButtons.add(initializeOverlayButton(getContext(), R.drawable.nunchuk_z, ButtonType.NUNCHUK_BUTTON_Z));
+ }
+ if (mPreferences.getBoolean("buttonToggleWii9", true))
+ {
+ overlayDpads.add(initializeOverlayDpad(getContext(), R.drawable.gcwii_dpad,
+ ButtonType.WIIMOTE_UP, ButtonType.WIIMOTE_DOWN,
+ ButtonType.WIIMOTE_LEFT, ButtonType.WIIMOTE_RIGHT));
+ }
+ if (mPreferences.getBoolean("buttonToggleWii10", true))
+ {
+ overlayJoysticks.add(initializeOverlayJoystick(getContext(),
+ R.drawable.gcwii_joystick_range, R.drawable.gcwii_joystick,
+ ButtonType.NUNCHUK_STICK));
+ }
+ }
+
+ invalidate();
+ }
+
private void saveControlPosition(int sharedPrefsId, int x, int y)
{
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
diff --git a/Source/Android/app/src/main/res/values/arrays.xml b/Source/Android/app/src/main/res/values/arrays.xml
index 4335648861..62a15789d2 100644
--- a/Source/Android/app/src/main/res/values/arrays.xml
+++ b/Source/Android/app/src/main/res/values/arrays.xml
@@ -159,6 +159,20 @@
- 12
+
+ - A
+ - B
+ - X
+ - Y
+ - Z
+ - Start
+ - L
+ - R
+ - D-Pad
+ - Main Stick
+ - C Stick
+
+
- Disabled
- Emulated
@@ -170,4 +184,18 @@
- 2
+
+ - A
+ - B
+ - 1
+ - 2
+ - +
+ - -
+ - Home
+ - C
+ - Z
+ - D-Pad
+ - Nunchuk Stick
+
+
diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml
index 04db68eee8..5ad4e029b3 100644
--- a/Source/Android/app/src/main/res/values/strings.xml
+++ b/Source/Android/app/src/main/res/values/strings.xml
@@ -356,6 +356,7 @@
Toggle Touch Controls
+ Toggle All
Quick Save
Quick Load
Refresh Wiimotes