diff --git a/Source/Android/res/values-ja/strings.xml b/Source/Android/res/values-ja/strings.xml
index 598799c30e..bab1991ce3 100644
--- a/Source/Android/res/values-ja/strings.xml
+++ b/Source/Android/res/values-ja/strings.xml
@@ -46,6 +46,10 @@
入力オーバーレイレイアウト
入力オーバーレイのためのボタンのレイアウト。
ゲームキューブの入力バインディング
+ コントローラ1
+ コントローラ2
+ コントローラ3
+ コントローラ4
入力バインディング
%1$sにバインドするための入力を移動または押してください。
Aボタン
diff --git a/Source/Android/res/values/strings.xml b/Source/Android/res/values/strings.xml
index 517a80dbd3..353559a0ed 100644
--- a/Source/Android/res/values/strings.xml
+++ b/Source/Android/res/values/strings.xml
@@ -46,6 +46,10 @@
Input Overlay Layout
Button layout for the input overlay.
Gamecube Input Bindings
+ Controller 1
+ Controller 2
+ Controller 3
+ Controller 4
Input Binding
Press or move an input to bind it to %1$s.
Button A
diff --git a/Source/Android/res/xml/input_prefs.xml b/Source/Android/res/xml/input_prefs.xml
index afd32b476b..30b069c37a 100644
--- a/Source/Android/res/xml/input_prefs.xml
+++ b/Source/Android/res/xml/input_prefs.xml
@@ -1,8 +1,7 @@
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputBindingPreference.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputBindingPreference.java
new file mode 100644
index 0000000000..e182f93a5c
--- /dev/null
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputBindingPreference.java
@@ -0,0 +1,55 @@
+package org.dolphinemu.dolphinemu.settings.input;
+
+import org.dolphinemu.dolphinemu.R;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.preference.Preference;
+import android.util.AttributeSet;
+
+/**
+ * {@link Preference} subclass that represents a preference
+ * used for assigning a key bind.
+ */
+public final class InputBindingPreference extends Preference
+{
+ /**
+ * Constructor that is called when inflating an InputBindingPreference from XML.
+ *
+ * @param context The current {@link Context}.
+ * @param attrs The attributes of the XML tag that is inflating the preference.
+ */
+ public InputBindingPreference(Context context, AttributeSet attrs)
+ {
+ super(context, attrs);
+ }
+
+ @Override
+ protected void onClick()
+ {
+ // Begin the creation of the input alert.
+ final MotionAlertDialog dialog = new MotionAlertDialog(getContext(), this);
+
+ // Set the cancel button.
+ dialog.setButton(AlertDialog.BUTTON_NEGATIVE, getContext().getString(R.string.cancel), new AlertDialog.OnClickListener()
+ {
+ @Override
+ public void onClick(DialogInterface dialog, int which)
+ {
+ // Do nothing. Just makes the cancel button show up.
+ }
+ });
+
+ // Set the title and description message.
+ dialog.setTitle(R.string.input_binding);
+ dialog.setMessage(String.format(getContext().getString(R.string.input_binding_descrip), getTitle()));
+
+ // Don't allow the dialog to close when a user taps
+ // outside of it. They must press cancel or provide an input.
+ dialog.setCanceledOnTouchOutside(false);
+
+ // Everything is set, show the dialog.
+ dialog.show();
+ }
+}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputConfigFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputConfigFragment.java
index 657c5f0817..3544010604 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputConfigFragment.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/InputConfigFragment.java
@@ -6,21 +6,16 @@
package org.dolphinemu.dolphinemu.settings.input;
-import android.app.AlertDialog;
+import java.util.List;
+
import android.app.Fragment;
-import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
-import android.util.Log;
-import android.view.*;
-
-import java.util.ArrayList;
-import java.util.List;
+import android.view.InputDevice;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.R;
@@ -31,6 +26,37 @@ import org.dolphinemu.dolphinemu.R;
*/
public final class InputConfigFragment extends PreferenceFragment
{
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ // Expand the preferences from the XML.
+ addPreferencesFromResource(R.xml.input_prefs);
+
+ // Set the summary messages of the preferences to whatever binding
+ // is currently set within the Dolphin config.
+ final String[] keys =
+ {
+ "InputA", "InputB", "InputX", "InputY", "InputZ", "InputStart",
+ "DPadUp", "DPadDown", "DPadLeft", "DPadRight",
+ "MainUp", "MainDown", "MainLeft", "MainRight",
+ "CStickUp", "CStickDown", "CStickLeft", "CStickRight",
+ "InputL", "InputR"
+ };
+
+ // Loop through the keys for all 4 GameCube controllers.
+ for (int i = 1; i <= 4; i++)
+ {
+ for (String key : keys)
+ {
+ final String binding = NativeLibrary.GetConfig("Dolphin.ini", "Android", key+"_"+i, "None");
+ final Preference pref = findPreference(key+"_"+i);
+ pref.setSummary(binding);
+ }
+ }
+ }
+
/**
* Gets the descriptor for the given {@link InputDevice}.
*
@@ -59,66 +85,9 @@ public final class InputConfigFragment extends PreferenceFragment
}
}
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
-
- // Expand the preferences from the XML.
- addPreferencesFromResource(R.xml.input_prefs);
-
- // Set the summary messages of the preferences to whatever binding
- // is currently set within the Dolphin config.
- final String[] keys =
- {
- "InputA", "InputB", "InputX", "InputY", "InputZ", "InputStart",
- "DPadUp", "DPadDown", "DPadLeft", "DPadRight",
- "MainUp", "MainDown", "MainLeft", "MainRight",
- "CStickUp", "CStickDown", "CStickLeft", "CStickRight",
- "InputL", "InputR",
- };
-
- Preference pref;
- for (String key : keys)
- {
- String binding = NativeLibrary.GetConfig("Dolphin.ini", "Android", key, "None");
- pref = findPreference(key);
- pref.setSummary(binding);
- }
- }
-
@Override
public boolean onPreferenceTreeClick(PreferenceScreen screen, Preference pref)
{
- // If the user is on the preference screen to set Gamecube input bindings.
- if (screen.getTitle().equals(getString(R.string.gamecube_bindings)))
- {
- // Begin the creation of the input alert.
- final MotionAlertDialog dialog = new MotionAlertDialog(getActivity(), pref);
-
- // Set the cancel button.
- dialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.cancel), new AlertDialog.OnClickListener()
- {
- @Override
- public void onClick(DialogInterface dialog, int which)
- {
- // Do nothing. Just makes the cancel button show up.
- }
- });
-
- // Set the title and description message.
- dialog.setTitle(R.string.input_binding);
- dialog.setMessage(String.format(getString(R.string.input_binding_descrip), pref.getTitle()));
-
- // Don't allow the dialog to close when a user taps
- // outside of it. They must press cancel or provide an input.
- dialog.setCanceledOnTouchOutside(false);
-
- // Everything is set, show the dialog.
- dialog.show();
- return true;
- }
-
// If the user has clicked the option to configure the input overlay.
if (pref.getTitle().equals(getString(R.string.input_overlay_layout)))
{
@@ -129,119 +98,4 @@ public final class InputConfigFragment extends PreferenceFragment
return false;
}
-
- /**
- * {@link AlertDialog} derivative that listens for
- * motion events from controllers and joysticks.
- */
- private static final class MotionAlertDialog extends AlertDialog
- {
- // The selected input preference
- private final Preference inputPref;
-
- private boolean firstEvent = true;
- private final ArrayList m_values = new ArrayList();
-
- /**
- * Constructor
- *
- * @param ctx The current {@link Context}.
- * @param inputPref The Preference to show this dialog for.
- */
- public MotionAlertDialog(Context ctx, Preference inputPref)
- {
- super(ctx);
-
- this.inputPref = inputPref;
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event)
- {
- Log.d("InputConfigFragment", "Received key event: " + event.getAction());
- switch (event.getAction())
- {
- case KeyEvent.ACTION_DOWN:
- case KeyEvent.ACTION_UP:
- InputDevice input = event.getDevice();
- String bindStr = "Device '" + getInputDesc(input) + "'-Button " + event.getKeyCode();
- NativeLibrary.SetConfig("Dolphin.ini", "Android", inputPref.getKey(), bindStr);
- inputPref.setSummary(bindStr);
- dismiss();
- return true;
-
- default:
- break;
- }
-
- return false;
- }
-
-
- // Method that will be called within dispatchGenericMotionEvent
- // that handles joystick/controller movements.
- private boolean onMotionEvent(MotionEvent event)
- {
- if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0)
- return false;
-
- Log.d("InputConfigFragment", "Received motion event: " + event.getAction());
-
- InputDevice input = event.getDevice();
- List motions = input.getMotionRanges();
- if (firstEvent)
- {
- m_values.clear();
-
- for (InputDevice.MotionRange range : motions)
- {
- m_values.add(event.getAxisValue(range.getAxis()));
- }
-
- firstEvent = false;
- }
- else
- {
- for (int a = 0; a < motions.size(); ++a)
- {
- InputDevice.MotionRange range = motions.get(a);
-
- if (m_values.get(a) > (event.getAxisValue(range.getAxis()) + 0.5f))
- {
- String bindStr = "Device '" + InputConfigFragment.getInputDesc(input) + "'-Axis " + range.getAxis() + "-";
- NativeLibrary.SetConfig("Dolphin.ini", "Android", inputPref.getKey(), bindStr);
- inputPref.setSummary(bindStr);
- dismiss();
- }
- else if (m_values.get(a) < (event.getAxisValue(range.getAxis()) - 0.5f))
- {
- String bindStr = "Device '" + InputConfigFragment.getInputDesc(input) + "'-Axis " + range.getAxis() + "+";
- NativeLibrary.SetConfig("Dolphin.ini", "Android", inputPref.getKey(), bindStr);
- inputPref.setSummary(bindStr);
- dismiss();
- }
- }
- }
-
- return true;
- }
-
- @Override
- public boolean dispatchKeyEvent(KeyEvent event)
- {
- if (onKeyDown(event.getKeyCode(), event))
- return true;
-
- return super.dispatchKeyEvent(event);
- }
-
- @Override
- public boolean dispatchGenericMotionEvent(MotionEvent event)
- {
- if (onMotionEvent(event))
- return true;
-
- return super.dispatchGenericMotionEvent(event);
- }
- }
}
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/MotionAlertDialog.java b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/MotionAlertDialog.java
new file mode 100644
index 0000000000..58d3a933a1
--- /dev/null
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/settings/input/MotionAlertDialog.java
@@ -0,0 +1,127 @@
+package org.dolphinemu.dolphinemu.settings.input;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.dolphinemu.dolphinemu.NativeLibrary;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.preference.Preference;
+import android.util.Log;
+import android.view.InputDevice;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+
+/**
+ * {@link AlertDialog} derivative that listens for
+ * motion events from controllers and joysticks.
+ */
+final class MotionAlertDialog extends AlertDialog
+{
+ // The selected input preference
+ private final Preference inputPref;
+
+ private boolean firstEvent = true;
+ private final ArrayList m_values = new ArrayList();
+
+ /**
+ * Constructor
+ *
+ * @param ctx The current {@link Context}.
+ * @param inputPref The Preference to show this dialog for.
+ */
+ public MotionAlertDialog(Context ctx, Preference inputPref)
+ {
+ super(ctx);
+
+ this.inputPref = inputPref;
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event)
+ {
+ Log.d("InputConfigFragment", "Received key event: " + event.getAction());
+ switch (event.getAction())
+ {
+ case KeyEvent.ACTION_DOWN:
+ case KeyEvent.ACTION_UP:
+ InputDevice input = event.getDevice();
+ String bindStr = "Device '" + InputConfigFragment.getInputDesc(input) + "'-Button " + event.getKeyCode();
+ NativeLibrary.SetConfig("Dolphin.ini", "Android", inputPref.getKey(), bindStr);
+ inputPref.setSummary(bindStr);
+ dismiss();
+ return true;
+
+ default:
+ return false;
+ }
+ }
+
+
+ // Method that will be called within dispatchGenericMotionEvent
+ // that handles joystick/controller movements.
+ private boolean onMotionEvent(MotionEvent event)
+ {
+ if ((event.getSource() & InputDevice.SOURCE_CLASS_JOYSTICK) == 0)
+ return false;
+
+ Log.d("InputConfigFragment", "Received motion event: " + event.getAction());
+
+ InputDevice input = event.getDevice();
+ List motions = input.getMotionRanges();
+ if (firstEvent)
+ {
+ m_values.clear();
+
+ for (InputDevice.MotionRange range : motions)
+ {
+ m_values.add(event.getAxisValue(range.getAxis()));
+ }
+
+ firstEvent = false;
+ }
+ else
+ {
+ for (int a = 0; a < motions.size(); ++a)
+ {
+ InputDevice.MotionRange range = motions.get(a);
+
+ if (m_values.get(a) > (event.getAxisValue(range.getAxis()) + 0.5f))
+ {
+ String bindStr = "Device '" + InputConfigFragment.getInputDesc(input) + "'-Axis " + range.getAxis() + "-";
+ NativeLibrary.SetConfig("Dolphin.ini", "Android", inputPref.getKey(), bindStr);
+ inputPref.setSummary(bindStr);
+ dismiss();
+ }
+ else if (m_values.get(a) < (event.getAxisValue(range.getAxis()) - 0.5f))
+ {
+ String bindStr = "Device '" + InputConfigFragment.getInputDesc(input) + "'-Axis " + range.getAxis() + "+";
+ NativeLibrary.SetConfig("Dolphin.ini", "Android", inputPref.getKey(), bindStr);
+ inputPref.setSummary(bindStr);
+ dismiss();
+ }
+ }
+ }
+
+ return true;
+ }
+
+ @Override
+ public boolean dispatchKeyEvent(KeyEvent event)
+ {
+ if (onKeyDown(event.getKeyCode(), event))
+ return true;
+
+ return super.dispatchKeyEvent(event);
+ }
+
+ @Override
+ public boolean dispatchGenericMotionEvent(MotionEvent event)
+ {
+ if (onMotionEvent(event))
+ return true;
+
+ return super.dispatchGenericMotionEvent(event);
+ }
+}
\ No newline at end of file