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 f6756d30b0..4f4ddf2c71 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
@@ -100,7 +100,7 @@ public final class EmulationActivity extends AppCompatActivity
MENU_ACTION_LOAD_SLOT3, MENU_ACTION_LOAD_SLOT4, MENU_ACTION_LOAD_SLOT5,
MENU_ACTION_LOAD_SLOT6, MENU_ACTION_EXIT, MENU_ACTION_CHANGE_DISC,
MENU_ACTION_RESET_OVERLAY, MENU_SET_IR_SENSITIVITY, MENU_ACTION_CHOOSE_DOUBLETAP,
- MENU_ACTION_SCREEN_ORIENTATION})
+ MENU_ACTION_SCREEN_ORIENTATION, MENU_ACTION_MOTION_CONTROLS})
public @interface MenuAction
{
}
@@ -135,6 +135,7 @@ public final class EmulationActivity extends AppCompatActivity
public static final int MENU_SET_IR_SENSITIVITY = 27;
public static final int MENU_ACTION_CHOOSE_DOUBLETAP = 28;
public static final int MENU_ACTION_SCREEN_ORIENTATION = 29;
+ public static final int MENU_ACTION_MOTION_CONTROLS = 30;
private static SparseIntArray buttonsActionsMap = new SparseIntArray();
@@ -183,6 +184,8 @@ public final class EmulationActivity extends AppCompatActivity
EmulationActivity.MENU_ACTION_CHOOSE_DOUBLETAP);
buttonsActionsMap.append(R.id.menu_screen_orientation,
EmulationActivity.MENU_ACTION_SCREEN_ORIENTATION);
+ buttonsActionsMap.append(R.id.menu_emulation_motion_controls,
+ EmulationActivity.MENU_ACTION_MOTION_CONTROLS);
}
private static String[] scanForSecondDisc(GameFile gameFile)
@@ -349,7 +352,7 @@ public final class EmulationActivity extends AppCompatActivity
protected void onResume()
{
super.onResume();
- if (!sIsGameCubeGame)
+ if (!sIsGameCubeGame && mPreferences.getInt("motionControlsEnabled", 0) != 2)
mMotionListener.enable();
}
@@ -357,8 +360,7 @@ public final class EmulationActivity extends AppCompatActivity
protected void onPause()
{
super.onPause();
- if (!sIsGameCubeGame)
- mMotionListener.disable();
+ mMotionListener.disable();
}
@Override
@@ -651,6 +653,10 @@ public final class EmulationActivity extends AppCompatActivity
chooseOrientation();
return;
+ case MENU_ACTION_MOTION_CONTROLS:
+ showMotionControlsOptions();
+ return;
+
case MENU_ACTION_EXIT:
// ATV menu is built using a fragment, this will pop that fragment before emulation ends.
if (TvUtil.isLeanback(getApplicationContext()))
@@ -888,6 +894,32 @@ public final class EmulationActivity extends AppCompatActivity
alertDialog.show();
}
+ private void showMotionControlsOptions()
+ {
+ final SharedPreferences.Editor editor = mPreferences.edit();
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.emulation_motion_controls);
+ builder.setSingleChoiceItems(R.array.motionControlsEntries,
+ mPreferences.getInt("motionControlsEnabled", 0),
+ (dialog, indexSelected) ->
+ {
+ editor.putInt("motionControlsEnabled", indexSelected);
+
+ if (indexSelected != 2)
+ mMotionListener.enable();
+ else
+ mMotionListener.disable();
+
+ NativeLibrary.SetConfig("WiimoteNew.ini", "Wiimote1", "IMUIR/Enabled",
+ indexSelected != 1 ? "True" : "False");
+ NativeLibrary.ReloadWiimoteConfig();
+ });
+ builder.setPositiveButton(getString(R.string.ok), (dialogInterface, i) -> editor.apply());
+
+ AlertDialog alertDialog = builder.create();
+ alertDialog.show();
+ }
+
private void chooseOrientation()
{
final int[] orientationValues = getResources().getIntArray(R.array.orientationValues);
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/MotionListener.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/MotionListener.java
index 4230b0b7bc..31d1641aba 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/MotionListener.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/MotionListener.java
@@ -18,6 +18,8 @@ public class MotionListener implements SensorEventListener
private final Sensor mAccelSensor;
private final Sensor mGyroSensor;
+ private boolean mEnabled = false;
+
// The same sampling period as for Wii Remotes
private static final int SAMPLING_PERIOD_US = 1000000 / 200;
@@ -97,18 +99,28 @@ public class MotionListener implements SensorEventListener
public void enable()
{
+ if (mEnabled)
+ return;
+
if (mAccelSensor != null)
mSensorManager.registerListener(this, mAccelSensor, SAMPLING_PERIOD_US);
if (mGyroSensor != null)
mSensorManager.registerListener(this, mGyroSensor, SAMPLING_PERIOD_US);
NativeLibrary.SetMotionSensorsEnabled(mAccelSensor != null, mGyroSensor != null);
+
+ mEnabled = true;
}
public void disable()
{
+ if (!mEnabled)
+ return;
+
mSensorManager.unregisterListener(this);
NativeLibrary.SetMotionSensorsEnabled(false, false);
+
+ mEnabled = false;
}
}
diff --git a/Source/Android/app/src/main/res/menu/menu_emulation_wii.xml b/Source/Android/app/src/main/res/menu/menu_emulation_wii.xml
index d8b1de13ff..73a4d6a506 100644
--- a/Source/Android/app/src/main/res/menu/menu_emulation_wii.xml
+++ b/Source/Android/app/src/main/res/menu/menu_emulation_wii.xml
@@ -112,6 +112,10 @@
+
+
- 1
- -1
+
+
+ - Use Device Sensors (With Pointer Emulation)
+ - Use Device Sensors (Without Pointer Emulation)
+ - Don\'t Use Device Sensors
+
diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml
index 14b992aea2..fa48815ec9 100644
--- a/Source/Android/app/src/main/res/values/strings.xml
+++ b/Source/Android/app/src/main/res/values/strings.xml
@@ -314,6 +314,7 @@
IR Sensitivity
Double tap button
Screen Orientation
+ Motion Controls
Enable Vibration