Android: Add touchscreen controller port option
This commit is contained in:
parent
052721fffc
commit
f8bbade9bf
|
@ -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)
|
||||
|
|
|
@ -488,4 +488,24 @@
|
|||
<item>Copy Save</item>
|
||||
<item>Delete Save</item>
|
||||
</string-array>
|
||||
<string-array name="settings_touchscreen_controller_port_entries">
|
||||
<item>Port 1</item>
|
||||
<item>Port 2</item>
|
||||
<item>Multitap 3</item>
|
||||
<item>Multitap 4</item>
|
||||
<item>Multitap 5</item>
|
||||
<item>Multitap 6</item>
|
||||
<item>Multitap 7</item>
|
||||
<item>Multitap 8</item>
|
||||
</string-array>
|
||||
<string-array name="settings_touchscreen_controller_port_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
<item>6</item>
|
||||
<item>7</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
|
|
@ -335,4 +335,5 @@
|
|||
<string name="settings_achievements_global_settings">Global Settings</string>
|
||||
<string name="settings_category_achievements">Achievement Settings</string>
|
||||
<string name="settings_multitap_mode">Multitap Mode</string>
|
||||
<string name="settings_touchscreen_controller_port">Touchscreen Controller Port</string>
|
||||
</resources>
|
||||
|
|
|
@ -27,6 +27,14 @@
|
|||
app:key="Controller1/TouchscreenControllerView"
|
||||
app:title="@string/settings_touchscreen_controller_view"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<ListPreference
|
||||
app:defaultValue="0"
|
||||
app:entries="@array/settings_touchscreen_controller_port_entries"
|
||||
app:entryValues="@array/settings_touchscreen_controller_port_values"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="TouchscreenController/PortIndex"
|
||||
app:title="@string/settings_touchscreen_controller_port"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
|
|
Loading…
Reference in New Issue