diff --git a/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java b/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java index 0a6762d21..b16865042 100644 --- a/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java +++ b/android/app/src/main/java/com/github/stenzek/duckstation/EmulationActivity.java @@ -55,6 +55,19 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde return mPreferences.getString(key, defaultValue); } + private int getIntSetting(String key, int defaultValue) { + try { + return mPreferences.getInt(key, defaultValue); + } catch (ClassCastException e) { + try { + final String stringValue = mPreferences.getString(key, Integer.toString(defaultValue)); + return Integer.parseInt(stringValue); + } catch (Exception e2) { + return defaultValue; + } + } + } + private void setStringSetting(String key, String value) { SharedPreferences.Editor editor = mPreferences.edit(); editor.putString(key, value); @@ -747,7 +760,9 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde TouchscreenControllerView mTouchscreenController; public void updateControllers() { - final String controllerType = getStringSetting("Controller1/Type", "DigitalController"); + final int touchscreenControllerIndex = getIntSetting("TouchscreenController/PortIndex", 0); + final String touchscreenControllerPrefix = String.format("Controller%d/", touchscreenControllerIndex + 1); + final String controllerType = getStringSetting(touchscreenControllerPrefix + "Type", "DigitalController"); final String viewType = getStringSetting("Controller1/TouchscreenControllerView", "digital"); final boolean autoHideTouchscreenController = getBooleanSetting("Controller1/AutoHideTouchscreenController", false); final boolean touchGliding = getBooleanSetting("Controller1/TouchGliding", false); @@ -762,7 +777,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde AndroidHostInterface.getInstance().updateInputMap(); final boolean hasAnyControllers = mContentView.hasAnyGamePads(); - if (controllerType.equals("none") || viewType.equals("none") || (hasAnyControllers && autoHideTouchscreenController)) { + if (controllerType.equals("None") || viewType.equals("none") || (hasAnyControllers && autoHideTouchscreenController)) { if (mTouchscreenController != null) { activityLayout.removeView(mTouchscreenController); mTouchscreenController = null; @@ -773,7 +788,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde activityLayout.addView(mTouchscreenController); } - mTouchscreenController.init(0, controllerType, viewType, hapticFeedback, touchGliding); + mTouchscreenController.init(touchscreenControllerIndex, controllerType, viewType, hapticFeedback, touchGliding); } if (vibration) diff --git a/android/app/src/main/res/values/arrays.xml b/android/app/src/main/res/values/arrays.xml index baa597043..d484f69d7 100644 --- a/android/app/src/main/res/values/arrays.xml +++ b/android/app/src/main/res/values/arrays.xml @@ -488,4 +488,24 @@ Copy Save Delete Save + + Port 1 + Port 2 + Multitap 3 + Multitap 4 + Multitap 5 + Multitap 6 + Multitap 7 + Multitap 8 + + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 52944ebca..61da2691d 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -335,4 +335,5 @@ Global Settings Achievement Settings Multitap Mode + Touchscreen Controller Port diff --git a/android/app/src/main/res/xml/controllers_preferences.xml b/android/app/src/main/res/xml/controllers_preferences.xml index 261473598..8b0654dcc 100644 --- a/android/app/src/main/res/xml/controllers_preferences.xml +++ b/android/app/src/main/res/xml/controllers_preferences.xml @@ -27,6 +27,14 @@ app:key="Controller1/TouchscreenControllerView" app:title="@string/settings_touchscreen_controller_view" app:useSimpleSummaryProvider="true" /> +