summaryrefslogtreecommitdiff
path: root/Source/Android/app/src/main/java
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2022-06-26 20:27:18 +0200
committerJosJuice <josjuice@gmail.com>2023-03-07 17:39:34 +0100
commit1b55d7c59429ae96b014b61c5393a4dacc578cfa (patch)
tree0040ea59416409088b1c37a5b2ecbf75925417e7 /Source/Android/app/src/main/java
parent4c326f2030fda4c23cb4374fef1dee3da0c4822d (diff)
Android: Change how the overlay controller setting works
Up until now, there have been two settings on Android that stored the selected Wii Remote extension: the normal one that's also used on PC, and a SharedPreferences one that's used by the overlay controls to determine what controls to show. It is possible for these two to end up out of sync, and my input changes have made that more likely to happen. To fix this, let's rework how the overlay controller setting works. We don't want it to encode the currently selected Wii Remote extension. However, we can't simply get rid of the setting, because for some Wii games we need the ability to switch between a GameCube controller and a Wii Remote. What this commit does is give the user the option to select any of the 4 GameCube controllers and any of the 4 Wii Remotes. (Before, controllers 2-4 weren't available in the overlay.) Could be useful for things like the Psycho Mantis fight in Metal Gear Solid. I'm also switching from SharedPreferences to Dolphin.ini while I'm at it.
Diffstat (limited to 'Source/Android/app/src/main/java')
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java2
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/activities/EmulationActivity.java96
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.java4
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java16
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java2
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/fragments/EmulationFragment.java18
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/overlay/InputOverlay.java202
-rw-r--r--Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/DirectoryInitialization.java8
8 files changed, 191 insertions, 157 deletions
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
index 1db70b72d9..68fdfee277 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/NativeLibrary.java
@@ -404,8 +404,6 @@ public final class NativeLibrary
*/
public static native void RefreshWiimotes();
- public static native void ReloadWiimoteConfig();
-
public static native LinkedHashMap<String, String> GetLogTypeNames();
public static native void ReloadLoggerConfig();
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 439d697247..9780f8de7b 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,7 +2,6 @@
package org.dolphinemu.dolphinemu.activities;
-import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -48,7 +47,6 @@ import org.dolphinemu.dolphinemu.features.settings.model.Settings;
import org.dolphinemu.dolphinemu.features.settings.model.StringSetting;
import org.dolphinemu.dolphinemu.features.settings.ui.MenuTag;
import org.dolphinemu.dolphinemu.features.settings.ui.SettingsActivity;
-import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
import org.dolphinemu.dolphinemu.features.skylanders.SkylanderConfig;
import org.dolphinemu.dolphinemu.features.skylanders.model.Skylander;
import org.dolphinemu.dolphinemu.features.skylanders.ui.SkylanderSlot;
@@ -62,10 +60,8 @@ import org.dolphinemu.dolphinemu.ui.main.MainPresenter;
import org.dolphinemu.dolphinemu.ui.main.ThemeProvider;
import org.dolphinemu.dolphinemu.utils.AfterDirectoryInitializationRunner;
import org.dolphinemu.dolphinemu.utils.FileBrowserHelper;
-import org.dolphinemu.dolphinemu.utils.IniFile;
import org.dolphinemu.dolphinemu.utils.ThemeHelper;
-import java.io.File;
import java.lang.annotation.Retention;
import java.util.ArrayList;
import java.util.List;
@@ -290,21 +286,6 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
sIgnoreLaunchRequests = false;
}
- public static void updateWiimoteNewIniPreferences(Context context)
- {
- updateWiimoteNewController(InputOverlay.getConfiguredControllerType(context), context);
- }
-
- private static void updateWiimoteNewController(int value, Context context)
- {
- File wiimoteNewFile = SettingsFile.getSettingsFile(Settings.FILE_WIIMOTE);
- IniFile wiimoteNewIni = new IniFile(wiimoteNewFile);
- wiimoteNewIni.setString("Wiimote1", "Extension",
- context.getResources().getStringArray(R.array.controllersValues)[value]);
- wiimoteNewIni.setBoolean("Wiimote1", "Options/Sideways Wiimote", value == 2);
- wiimoteNewIni.save(wiimoteNewFile);
- }
-
@Override
protected void onCreate(Bundle savedInstanceState)
{
@@ -456,7 +437,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
setTitle(NativeLibrary.GetCurrentTitleDescription());
- mEmulationFragment.refreshInputOverlay();
+ mEmulationFragment.refreshInputOverlay(mSettings);
}
@Override
@@ -680,7 +661,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
adjustScale();
break;
- // (Wii games only) Change the controller for the input overlay.
+ // Change the controller for the input overlay.
case MENU_ACTION_CHOOSE_CONTROLLER:
chooseController();
break;
@@ -850,9 +831,9 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this)
.setTitle(R.string.emulation_toggle_controls);
- int currentController = InputOverlay.getConfiguredControllerType(this);
+ int currentController = InputOverlay.getConfiguredControllerType(mSettings);
- if (!NativeLibrary.IsEmulatingWii() || currentController == InputOverlay.OVERLAY_GAMECUBE)
+ if (currentController == InputOverlay.OVERLAY_GAMECUBE)
{
boolean[] gcEnabledButtons = new boolean[11];
String gcSettingBase = "MAIN_BUTTON_TOGGLE_GC_";
@@ -906,7 +887,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
builder.setNeutralButton(R.string.emulation_toggle_all,
(dialogInterface, i) -> mEmulationFragment.toggleInputOverlayVisibility(mSettings))
.setPositiveButton(R.string.ok, (dialogInterface, i) ->
- mEmulationFragment.refreshInputOverlay())
+ mEmulationFragment.refreshInputOverlay(mSettings))
.show();
}
@@ -914,7 +895,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
{
int currentValue = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getInt(mSettings);
- int buttonList = InputOverlay.getConfiguredControllerType(this) ==
+ int buttonList = InputOverlay.getConfiguredControllerType(mSettings) ==
InputOverlay.OVERLAY_WIIMOTE_CLASSIC ? R.array.doubleTapWithClassic : R.array.doubleTap;
int checkedItem = -1;
@@ -933,7 +914,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
(DialogInterface dialog, int which) -> IntSetting.MAIN_DOUBLE_TAP_BUTTON.setInt(
mSettings, InputOverlayPointer.DOUBLE_TAP_OPTIONS.get(which)))
.setPositiveButton(R.string.ok,
- (dialogInterface, i) -> mEmulationFragment.initInputPointer())
+ (dialogInterface, i) -> mEmulationFragment.initInputPointer(mSettings))
.show();
}
@@ -967,35 +948,72 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
{
IntSetting.MAIN_CONTROL_SCALE.setInt(mSettings, (int) scaleSlider.getValue());
IntSetting.MAIN_CONTROL_OPACITY.setInt(mSettings, (int) sliderOpacity.getValue());
- mEmulationFragment.refreshInputOverlay();
+ mEmulationFragment.refreshInputOverlay(mSettings);
})
.setNeutralButton(R.string.default_values, (dialog, which) ->
{
IntSetting.MAIN_CONTROL_SCALE.delete(mSettings);
IntSetting.MAIN_CONTROL_OPACITY.delete(mSettings);
- mEmulationFragment.refreshInputOverlay();
+ mEmulationFragment.refreshInputOverlay(mSettings);
})
.show();
}
+ private void addControllerIfNotNone(List<CharSequence> entries, List<Integer> values,
+ IntSetting controller, int entry, int value)
+ {
+ if (controller.getInt(mSettings) != 0)
+ {
+ entries.add(getString(entry));
+ values.add(value);
+ }
+ }
+
private void chooseController()
{
+ ArrayList<CharSequence> entries = new ArrayList<>();
+ ArrayList<Integer> values = new ArrayList<>();
+
+ entries.add(getString(R.string.none));
+ values.add(-1);
+
+ addControllerIfNotNone(entries, values, IntSetting.MAIN_SI_DEVICE_0, R.string.controller_0, 0);
+ addControllerIfNotNone(entries, values, IntSetting.MAIN_SI_DEVICE_1, R.string.controller_1, 1);
+ addControllerIfNotNone(entries, values, IntSetting.MAIN_SI_DEVICE_2, R.string.controller_2, 2);
+ addControllerIfNotNone(entries, values, IntSetting.MAIN_SI_DEVICE_3, R.string.controller_3, 3);
+
+ if (NativeLibrary.IsEmulatingWii())
+ {
+ addControllerIfNotNone(entries, values, IntSetting.WIIMOTE_1_SOURCE, R.string.wiimote_0, 4);
+ addControllerIfNotNone(entries, values, IntSetting.WIIMOTE_2_SOURCE, R.string.wiimote_1, 5);
+ addControllerIfNotNone(entries, values, IntSetting.WIIMOTE_3_SOURCE, R.string.wiimote_2, 6);
+ addControllerIfNotNone(entries, values, IntSetting.WIIMOTE_4_SOURCE, R.string.wiimote_3, 7);
+ }
+
+ IntSetting controllerSetting = NativeLibrary.IsEmulatingWii() ?
+ IntSetting.MAIN_OVERLAY_WII_CONTROLLER : IntSetting.MAIN_OVERLAY_GC_CONTROLLER;
+ int currentValue = controllerSetting.getInt(mSettings);
+
+ int checkedItem = -1;
+ for (int i = 0; i < values.size(); i++)
+ {
+ if (values.get(i) == currentValue)
+ {
+ checkedItem = i;
+ break;
+ }
+ }
+
final SharedPreferences.Editor editor = mPreferences.edit();
new MaterialAlertDialogBuilder(this)
.setTitle(R.string.emulation_choose_controller)
- .setSingleChoiceItems(R.array.controllersEntries,
- InputOverlay.getConfiguredControllerType(this),
+ .setSingleChoiceItems(entries.toArray(new CharSequence[]{}), checkedItem,
(dialog, indexSelected) ->
- {
- editor.putInt("wiiController", indexSelected);
-
- updateWiimoteNewController(indexSelected, this);
- NativeLibrary.ReloadWiimoteConfig();
- })
+ controllerSetting.setInt(mSettings, values.get(indexSelected)))
.setPositiveButton(R.string.ok, (dialogInterface, i) ->
{
editor.apply();
- mEmulationFragment.refreshInputOverlay();
+ mEmulationFragment.refreshInputOverlay(mSettings);
})
.show();
}
@@ -1045,7 +1063,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
new MaterialAlertDialogBuilder(this)
.setTitle(getString(R.string.emulation_touch_overlay_reset))
.setPositiveButton(R.string.yes,
- (dialogInterface, i) -> mEmulationFragment.resetInputOverlay())
+ (dialogInterface, i) -> mEmulationFragment.resetInputOverlay(mSettings))
.setNegativeButton(R.string.cancel, null)
.show();
}
@@ -1140,7 +1158,7 @@ public final class EmulationActivity extends AppCompatActivity implements ThemeP
public void initInputPointer()
{
- mEmulationFragment.initInputPointer();
+ mEmulationFragment.initInputPointer(mSettings);
}
@Override
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.java
index 47d4dc5c96..39645ffbba 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/controlleremu/EmulatedController.java
@@ -45,4 +45,8 @@ public class EmulatedController
public static native EmulatedController getWiimoteAttachment(int controllerIndex,
int attachmentIndex);
+
+ public static native int getSelectedWiimoteAttachment(int controllerIndex);
+
+ public static native NumericSetting getSidewaysWiimoteSetting(int controllerIndex);
}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java
index 10503f7da0..77cf7b339a 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/model/IntSetting.java
@@ -33,6 +33,10 @@ public enum IntSetting implements AbstractIntSetting
MAIN_AUDIO_VOLUME(Settings.FILE_DOLPHIN, Settings.SECTION_INI_DSP, "Volume", 100),
+ MAIN_OVERLAY_GC_CONTROLLER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
+ "OverlayGCController", 0), // Defaults to GameCube controller 1
+ MAIN_OVERLAY_WII_CONTROLLER(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
+ "OverlayWiiController", 4), // Defaults to Wii Remote 1
MAIN_CONTROL_SCALE(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "ControlScale", 50),
MAIN_CONTROL_OPACITY(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID, "ControlOpacity", 65),
MAIN_EMULATION_ORIENTATION(Settings.FILE_DOLPHIN, Settings.SECTION_INI_ANDROID,
@@ -188,4 +192,16 @@ public enum IntSetting implements AbstractIntSetting
{
NativeConfig.setInt(layer, mFile, mSection, mKey, newValue);
}
+
+ public static IntSetting getSettingForSIDevice(int channel)
+ {
+ return new IntSetting[]{MAIN_SI_DEVICE_0, MAIN_SI_DEVICE_1, MAIN_SI_DEVICE_2, MAIN_SI_DEVICE_3}
+ [channel];
+ }
+
+ public static IntSetting getSettingForWiimoteSource(int index)
+ {
+ return new IntSetting[]{WIIMOTE_1_SOURCE, WIIMOTE_2_SOURCE, WIIMOTE_3_SOURCE, WIIMOTE_4_SOURCE,
+ WIIMOTE_BB_SOURCE}[index];
+ }
}
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java
index 2cabb8edc7..acad8c2d19 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/settings/utils/SettingsFile.java
@@ -20,8 +20,6 @@ public final class SettingsFile
public static final String KEY_ISO_PATH_BASE = "ISOPath";
public static final String KEY_ISO_PATHS = "ISOPaths";
- public static final String KEY_GCPAD_PLAYER_1 = "SIDevice0";
-
private static BiMap<String, String> sectionsMap = new BiMap<>();
static
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 c356969136..27e425d8b6 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
@@ -115,7 +115,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
{
int overlayX = mInputOverlay.getLeft();
int overlayY = mInputOverlay.getTop();
- mInputOverlay.setSurfacePosition(new Rect(
+ mInputOverlay.setSurfacePosition(activity.getSettings(), new Rect(
surfaceView.getLeft() - overlayX, surfaceView.getTop() - overlayY,
surfaceView.getRight() - overlayX, surfaceView.getBottom() - overlayY));
});
@@ -135,7 +135,7 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
super.onResume();
if (mInputOverlay != null && NativeLibrary.IsGameMetadataValid())
- mInputOverlay.refreshControls();
+ mInputOverlay.refreshControls(activity.getSettings());
run(activity.isActivityRecreated());
}
@@ -174,19 +174,19 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
.setBoolean(settings, !BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBoolean(settings));
if (mInputOverlay != null)
- mInputOverlay.refreshControls();
+ mInputOverlay.refreshControls(settings);
}
- public void initInputPointer()
+ public void initInputPointer(Settings settings)
{
if (mInputOverlay != null)
- mInputOverlay.initTouchPointer();
+ mInputOverlay.initTouchPointer(settings);
}
- public void refreshInputOverlay()
+ public void refreshInputOverlay(Settings settings)
{
if (mInputOverlay != null)
- mInputOverlay.refreshControls();
+ mInputOverlay.refreshControls(settings);
}
public void refreshOverlayPointer(Settings settings)
@@ -195,10 +195,10 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
mInputOverlay.refreshOverlayPointer(settings);
}
- public void resetInputOverlay()
+ public void resetInputOverlay(Settings settings)
{
if (mInputOverlay != null)
- mInputOverlay.resetButtonPlacement();
+ mInputOverlay.resetButtonPlacement(settings);
}
@Override
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 0a961ac16f..1fed472b56 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
@@ -29,13 +29,14 @@ import androidx.preference.PreferenceManager;
import org.dolphinemu.dolphinemu.NativeLibrary;
import org.dolphinemu.dolphinemu.NativeLibrary.ButtonType;
import org.dolphinemu.dolphinemu.R;
+import org.dolphinemu.dolphinemu.features.input.model.InputMappingBooleanSetting;
import org.dolphinemu.dolphinemu.features.input.model.InputOverrider;
import org.dolphinemu.dolphinemu.features.input.model.InputOverrider.ControlId;
+import org.dolphinemu.dolphinemu.features.input.model.controlleremu.EmulatedController;
+import org.dolphinemu.dolphinemu.features.input.model.controlleremu.NumericSetting;
import org.dolphinemu.dolphinemu.features.settings.model.BooleanSetting;
import org.dolphinemu.dolphinemu.features.settings.model.IntSetting;
import org.dolphinemu.dolphinemu.features.settings.model.Settings;
-import org.dolphinemu.dolphinemu.features.settings.utils.SettingsFile;
-import org.dolphinemu.dolphinemu.utils.IniFile;
import java.util.ArrayList;
import java.util.HashSet;
@@ -69,6 +70,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
private boolean mGameCubeRegistered = false;
private boolean mWiiRegistered = false;
private boolean mIsInEditMode = false;
+ private int mControllerType = -1;
private InputOverlayDrawableButton mButtonBeingConfigured;
private InputOverlayDrawableDpad mDpadBeingConfigured;
private InputOverlayDrawableJoystick mJoystickBeingConfigured;
@@ -141,13 +143,13 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
requestFocus();
}
- public void setSurfacePosition(Rect rect)
+ public void setSurfacePosition(Settings settings, Rect rect)
{
mSurfacePosition = rect;
- initTouchPointer();
+ initTouchPointer(settings);
}
- public void initTouchPointer()
+ public void initTouchPointer(Settings settings)
{
// Check if we have all the data we need yet
boolean aspectRatioAvailable = NativeLibrary.IsRunningAndStarted();
@@ -160,7 +162,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
int doubleTapButton = IntSetting.MAIN_DOUBLE_TAP_BUTTON.getIntGlobal();
- if (getConfiguredControllerType() != InputOverlay.OVERLAY_WIIMOTE_CLASSIC &&
+ if (getConfiguredControllerType(settings) != InputOverlay.OVERLAY_WIIMOTE_CLASSIC &&
doubleTapButton == ButtonType.CLASSIC_BUTTON_A)
{
doubleTapButton = ButtonType.WIIMOTE_BUTTON_A;
@@ -355,7 +357,6 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
int fingerPositionX = (int) event.getX(pointerIndex);
int fingerPositionY = (int) event.getY(pointerIndex);
- int controller = getConfiguredControllerType();
String orientation =
getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ?
"-Portrait" : "";
@@ -394,7 +395,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Persist button position by saving new place.
saveControlPosition(mButtonBeingConfigured.getLegacyId(),
mButtonBeingConfigured.getBounds().left,
- mButtonBeingConfigured.getBounds().top, controller, orientation);
+ mButtonBeingConfigured.getBounds().top, orientation);
mButtonBeingConfigured = null;
}
break;
@@ -432,7 +433,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// Persist button position by saving new place.
saveControlPosition(mDpadBeingConfigured.getLegacyId(),
mDpadBeingConfigured.getBounds().left, mDpadBeingConfigured.getBounds().top,
- controller, orientation);
+ orientation);
mDpadBeingConfigured = null;
}
break;
@@ -465,7 +466,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
{
saveControlPosition(mJoystickBeingConfigured.getLegacyId(),
mJoystickBeingConfigured.getBounds().left,
- mJoystickBeingConfigured.getBounds().top, controller, orientation);
+ mJoystickBeingConfigured.getBounds().top, orientation);
mJoystickBeingConfigured = null;
}
break;
@@ -781,7 +782,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
}
}
- public void refreshControls()
+ public void refreshControls(Settings settings)
{
unregisterControllers();
@@ -794,67 +795,52 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ?
"-Portrait" : "";
+ mControllerType = getConfiguredControllerType(settings);
+
if (BooleanSetting.MAIN_SHOW_INPUT_OVERLAY.getBooleanGlobal())
{
// Add all the enabled overlay items back to the HashSet.
- if (!NativeLibrary.IsEmulatingWii())
+ switch (mControllerType)
{
- IniFile dolphinIni = new IniFile(SettingsFile.getSettingsFile(Settings.FILE_DOLPHIN));
+ case OVERLAY_GAMECUBE:
+ IntSetting controllerSetting = NativeLibrary.IsEmulatingWii() ?
+ IntSetting.MAIN_OVERLAY_WII_CONTROLLER : IntSetting.MAIN_OVERLAY_GC_CONTROLLER;
+ int controllerIndex = controllerSetting.getInt(settings);
- switch (dolphinIni.getInt(Settings.SECTION_INI_CORE, SettingsFile.KEY_GCPAD_PLAYER_1,
- EMULATED_GAMECUBE_CONTROLLER))
- {
- case DISABLED_GAMECUBE_CONTROLLER:
- if (mIsFirstRun)
- {
- Toast.makeText(getContext(), R.string.disabled_gc_overlay_notice, Toast.LENGTH_SHORT)
- .show();
- }
- break;
+ if (IntSetting.getSettingForSIDevice(controllerIndex).getInt(settings) ==
+ DISABLED_GAMECUBE_CONTROLLER && mIsFirstRun)
+ {
+ Toast.makeText(getContext(), R.string.disabled_gc_overlay_notice, Toast.LENGTH_SHORT)
+ .show();
+ }
- case EMULATED_GAMECUBE_CONTROLLER:
- InputOverrider.registerGameCube(0);
- mGameCubeRegistered = true;
- addGameCubeOverlayControls(orientation);
- break;
+ InputOverrider.registerGameCube(0);
+ mGameCubeRegistered = true;
+ addGameCubeOverlayControls(orientation);
+ break;
- case GAMECUBE_ADAPTER:
- break;
- }
- }
- else
- {
- switch (getConfiguredControllerType())
- {
- case OVERLAY_GAMECUBE:
- InputOverrider.registerGameCube(0);
- mGameCubeRegistered = true;
- addGameCubeOverlayControls(orientation);
- break;
-
- case OVERLAY_WIIMOTE:
- case OVERLAY_WIIMOTE_SIDEWAYS:
- InputOverrider.registerWii(0);
- mWiiRegistered = true;
- addWiimoteOverlayControls(orientation);
- break;
-
- case OVERLAY_WIIMOTE_NUNCHUK:
- InputOverrider.registerWii(0);
- mWiiRegistered = true;
- addWiimoteOverlayControls(orientation);
- addNunchukOverlayControls(orientation);
- break;
-
- case OVERLAY_WIIMOTE_CLASSIC:
- InputOverrider.registerWii(0);
- mWiiRegistered = true;
- addClassicOverlayControls(orientation);
- break;
-
- case OVERLAY_NONE:
- break;
- }
+ case OVERLAY_WIIMOTE:
+ case OVERLAY_WIIMOTE_SIDEWAYS:
+ InputOverrider.registerWii(0);
+ mWiiRegistered = true;
+ addWiimoteOverlayControls(orientation);
+ break;
+
+ case OVERLAY_WIIMOTE_NUNCHUK:
+ InputOverrider.registerWii(0);
+ mWiiRegistered = true;
+ addWiimoteOverlayControls(orientation);
+ addNunchukOverlayControls(orientation);
+ break;
+
+ case OVERLAY_WIIMOTE_CLASSIC:
+ InputOverrider.registerWii(0);
+ mWiiRegistered = true;
+ addClassicOverlayControls(orientation);
+ break;
+
+ case OVERLAY_NONE:
+ break;
}
}
@@ -871,20 +857,20 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
}
}
- public void resetButtonPlacement()
+ public void resetButtonPlacement(Settings settings)
{
boolean isLandscape =
getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
- // Values for these come from R.array.controllersEntries
- if (!NativeLibrary.IsEmulatingWii() || getConfiguredControllerType() == OVERLAY_GAMECUBE)
+ final int controller = getConfiguredControllerType(settings);
+ if (controller == OVERLAY_GAMECUBE)
{
if (isLandscape)
gcDefaultOverlay();
else
gcPortraitDefaultOverlay();
}
- else if (getConfiguredControllerType() == OVERLAY_WIIMOTE_CLASSIC)
+ else if (controller == OVERLAY_WIIMOTE_CLASSIC)
{
if (isLandscape)
wiiClassicDefaultOverlay();
@@ -904,27 +890,52 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
wiiOnlyPortraitDefaultOverlay();
}
}
- refreshControls();
+ refreshControls(settings);
}
- public static int getConfiguredControllerType(Context context)
+ public static int getConfiguredControllerType(Settings settings)
{
- return PreferenceManager.getDefaultSharedPreferences(context)
- .getInt("wiiController", OVERLAY_WIIMOTE_NUNCHUK);
- }
+ IntSetting controllerSetting = NativeLibrary.IsEmulatingWii() ?
+ IntSetting.MAIN_OVERLAY_WII_CONTROLLER : IntSetting.MAIN_OVERLAY_GC_CONTROLLER;
+ int controllerIndex = controllerSetting.getInt(settings);
- private int getConfiguredControllerType()
- {
- return mPreferences.getInt("wiiController", OVERLAY_WIIMOTE_NUNCHUK);
+ if (controllerIndex >= 0 && controllerIndex < 4)
+ {
+ // GameCube controller
+ if (IntSetting.getSettingForSIDevice(controllerIndex).getInt(settings) == 6)
+ return OVERLAY_GAMECUBE;
+ }
+ else if (controllerIndex >= 4 && controllerIndex < 8)
+ {
+ // Wii Remote
+ int wiimoteIndex = controllerIndex - 4;
+ if (IntSetting.getSettingForWiimoteSource(wiimoteIndex).getInt(settings) == 1)
+ {
+ int attachmentIndex = EmulatedController.getSelectedWiimoteAttachment(wiimoteIndex);
+ switch (attachmentIndex)
+ {
+ case 1:
+ return OVERLAY_WIIMOTE_NUNCHUK;
+ case 2:
+ return OVERLAY_WIIMOTE_CLASSIC;
+ }
+
+ NumericSetting sidewaysSetting = EmulatedController.getSidewaysWiimoteSetting(wiimoteIndex);
+ boolean sideways = new InputMappingBooleanSetting(sidewaysSetting).getBoolean(settings);
+
+ return sideways ? OVERLAY_WIIMOTE_SIDEWAYS : OVERLAY_WIIMOTE;
+ }
+ }
+
+ return OVERLAY_NONE;
}
- private void saveControlPosition(int sharedPrefsId, int x, int y, int controller,
- String orientation)
+ private void saveControlPosition(int sharedPrefsId, int x, int y, String orientation)
{
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
SharedPreferences.Editor sPrefsEditor = sPrefs.edit();
- sPrefsEditor.putFloat(getXKey(sharedPrefsId, controller, orientation), x);
- sPrefsEditor.putFloat(getYKey(sharedPrefsId, controller, orientation), y);
+ sPrefsEditor.putFloat(getXKey(sharedPrefsId, mControllerType, orientation), x);
+ sPrefsEditor.putFloat(getYKey(sharedPrefsId, mControllerType, orientation), y);
sPrefsEditor.apply();
}
@@ -985,7 +996,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
* @param control Control identifier for the button the InputOverlayDrawableButton represents.
* @return An {@link InputOverlayDrawableButton} with the correct drawing bounds set.
*/
- private static InputOverlayDrawableButton initializeOverlayButton(Context context,
+ private InputOverlayDrawableButton initializeOverlayButton(Context context,
int defaultResId, int pressedResId, int legacyId, int control, String orientation)
{
// Resources handle for fetching the initial Drawable resource.
@@ -993,7 +1004,6 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// SharedPreference to retrieve the X and Y coordinates for the InputOverlayDrawableButton.
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- int controller = getConfiguredControllerType(context);
// Decide scale based on button ID and user preference
float scale;
@@ -1019,7 +1029,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
break;
case ButtonType.WIIMOTE_BUTTON_1:
case ButtonType.WIIMOTE_BUTTON_2:
- if (controller == 2)
+ if (mControllerType == OVERLAY_WIIMOTE_SIDEWAYS)
scale = 0.14f;
else
scale = 0.0875f;
@@ -1057,8 +1067,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay.
// These were set in the input overlay configuration menu.
- int drawableX = (int) sPrefs.getFloat(getXKey(legacyId, controller, orientation), 0f);
- int drawableY = (int) sPrefs.getFloat(getYKey(legacyId, controller, orientation), 0f);
+ int drawableX = (int) sPrefs.getFloat(getXKey(legacyId, mControllerType, orientation), 0f);
+ int drawableY = (int) sPrefs.getFloat(getYKey(legacyId, mControllerType, orientation), 0f);
int width = overlayDrawable.getWidth();
int height = overlayDrawable.getHeight();
@@ -1088,7 +1098,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
* @param rightControl Control identifier for the right button.
* @return the initialized {@link InputOverlayDrawableDpad}
*/
- private static InputOverlayDrawableDpad initializeOverlayDpad(Context context,
+ private InputOverlayDrawableDpad initializeOverlayDpad(Context context,
int defaultResId,
int pressedOneDirectionResId,
int pressedTwoDirectionsResId,
@@ -1104,7 +1114,6 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// SharedPreference to retrieve the X and Y coordinates for the InputOverlayDrawableDpad.
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- int controller = getConfiguredControllerType(context);
// Decide scale based on button ID and user preference
float scale;
@@ -1118,7 +1127,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
scale = 0.275f;
break;
default:
- if (controller == 2 || controller == 1)
+ if (mControllerType == OVERLAY_WIIMOTE_SIDEWAYS || mControllerType == OVERLAY_WIIMOTE)
scale = 0.275f;
else
scale = 0.2125f;
@@ -1144,8 +1153,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// The X and Y coordinates of the InputOverlayDrawableDpad on the InputOverlay.
// These were set in the input overlay configuration menu.
- int drawableX = (int) sPrefs.getFloat(getXKey(legacyId, controller, orientation), 0f);
- int drawableY = (int) sPrefs.getFloat(getYKey(legacyId, controller, orientation), 0f);
+ int drawableX = (int) sPrefs.getFloat(getXKey(legacyId, mControllerType, orientation), 0f);
+ int drawableY = (int) sPrefs.getFloat(getYKey(legacyId, mControllerType, orientation), 0f);
int width = overlayDrawable.getWidth();
int height = overlayDrawable.getHeight();
@@ -1173,16 +1182,15 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
* @param yControl Control identifier for the Y axis.
* @return the initialized {@link InputOverlayDrawableJoystick}.
*/
- private static InputOverlayDrawableJoystick initializeOverlayJoystick(Context context,
- int resOuter, int defaultResInner, int pressedResInner, int legacyId, int xControl,
- int yControl, String orientation)
+ private InputOverlayDrawableJoystick initializeOverlayJoystick(Context context, int resOuter,
+ int defaultResInner, int pressedResInner, int legacyId, int xControl, int yControl,
+ String orientation)
{
// Resources handle for fetching the initial Drawable resource.
final Resources res = context.getResources();
// SharedPreference to retrieve the X and Y coordinates for the InputOverlayDrawableJoystick.
final SharedPreferences sPrefs = PreferenceManager.getDefaultSharedPreferences(context);
- int controller = getConfiguredControllerType(context);
// Decide scale based on user preference
float scale = 0.275f;
@@ -1197,8 +1205,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
// The X and Y coordinates of the InputOverlayDrawableButton on the InputOverlay.
// These were set in the input overlay configuration menu.
- int drawableX = (int) sPrefs.getFloat(getXKey(legacyId, controller, orientation), 0f);
- int drawableY = (int) sPrefs.getFloat(getYKey(legacyId, controller, orientation), 0f);
+ int drawableX = (int) sPrefs.getFloat(getXKey(legacyId, mControllerType, orientation), 0f);
+ int drawableY = (int) sPrefs.getFloat(getYKey(legacyId, mControllerType, orientation), 0f);
// Decide inner scale based on joystick ID
float innerScale;
diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/DirectoryInitialization.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/DirectoryInitialization.java
index 45f2960bd9..bb2f45de43 100644
--- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/DirectoryInitialization.java
+++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/DirectoryInitialization.java
@@ -85,14 +85,6 @@ public final class DirectoryInitialization
checkThemeSettings(context);
- // TODO: Does doing this still make sense?
- if (false)
- {
- // This has to be done after calling NativeLibrary.Initialize(),
- // as it relies on the config system
- EmulationActivity.updateWiimoteNewIniPreferences(context);
- }
-
directoryState.postValue(DirectoryInitializationState.DOLPHIN_DIRECTORIES_INITIALIZED);
}