mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-02-16 10:31:07 +00:00
Add option to invert A/B X/Y (#824)
* Add option to invert A/B X/Y * Remove redundant prefConfig
This commit is contained in:
@@ -991,6 +991,21 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
||||
return keyCode;
|
||||
}
|
||||
|
||||
private int handleFlipFaceButtons(int keyCode) {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.KEYCODE_BUTTON_A:
|
||||
return KeyEvent.KEYCODE_BUTTON_B;
|
||||
case KeyEvent.KEYCODE_BUTTON_B:
|
||||
return KeyEvent.KEYCODE_BUTTON_A;
|
||||
case KeyEvent.KEYCODE_BUTTON_X:
|
||||
return KeyEvent.KEYCODE_BUTTON_Y;
|
||||
case KeyEvent.KEYCODE_BUTTON_Y:
|
||||
return KeyEvent.KEYCODE_BUTTON_X;
|
||||
default:
|
||||
return keyCode;
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2d populateCachedVector(float x, float y) {
|
||||
// Reinitialize our cached Vector2d object
|
||||
inputVector.initialize(x, y);
|
||||
@@ -1256,6 +1271,11 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
||||
}
|
||||
|
||||
int keyCode = handleRemapping(context, event);
|
||||
|
||||
if (prefConfig.flipFaceButtons) {
|
||||
keyCode = handleFlipFaceButtons(keyCode);
|
||||
}
|
||||
|
||||
if (keyCode == 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -1417,6 +1437,11 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
||||
}
|
||||
|
||||
int keyCode = handleRemapping(context, event);
|
||||
|
||||
if (prefConfig.flipFaceButtons) {
|
||||
keyCode = handleFlipFaceButtons(keyCode);
|
||||
}
|
||||
|
||||
if (keyCode == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ public class PreferenceConfiguration {
|
||||
static final String UNLOCK_FPS_STRING = "checkbox_unlock_fps";
|
||||
private static final String VIBRATE_OSC_PREF_STRING = "checkbox_vibrate_osc";
|
||||
private static final String VIBRATE_FALLBACK_PREF_STRING = "checkbox_vibrate_fallback";
|
||||
private static final String FLIP_FACE_BUTTONS_PERF_STRING = "checkbox_flip_face_buttons";
|
||||
|
||||
static final String DEFAULT_RESOLUTION = "720p";
|
||||
static final String DEFAULT_FPS = "60";
|
||||
@@ -67,6 +68,7 @@ public class PreferenceConfiguration {
|
||||
private static final boolean DEFAULT_UNLOCK_FPS = false;
|
||||
private static final boolean DEFAULT_VIBRATE_OSC = true;
|
||||
private static final boolean DEFAULT_VIBRATE_FALLBACK = false;
|
||||
private static final boolean DEFAULT_FLIP_FACE_BUTTONS = false;
|
||||
private static final String DEFAULT_AUDIO_CONFIG = "2"; // Stereo
|
||||
|
||||
public static final int FORCE_H265_ON = -1;
|
||||
@@ -80,7 +82,7 @@ public class PreferenceConfiguration {
|
||||
public int oscOpacity;
|
||||
public boolean stretchVideo, enableSops, playHostAudio, disableWarnings;
|
||||
public String language;
|
||||
public boolean listMode, smallIconMode, multiController, usbDriver;
|
||||
public boolean listMode, smallIconMode, multiController, usbDriver, flipFaceButtons;
|
||||
public boolean onscreenController;
|
||||
public boolean onlyL3R3;
|
||||
public boolean disableFrameDrop;
|
||||
@@ -368,6 +370,7 @@ public class PreferenceConfiguration {
|
||||
config.unlockFps = prefs.getBoolean(UNLOCK_FPS_STRING, DEFAULT_UNLOCK_FPS);
|
||||
config.vibrateOsc = prefs.getBoolean(VIBRATE_OSC_PREF_STRING, DEFAULT_VIBRATE_OSC);
|
||||
config.vibrateFallbackToDevice = prefs.getBoolean(VIBRATE_FALLBACK_PREF_STRING, DEFAULT_VIBRATE_FALLBACK);
|
||||
config.flipFaceButtons = prefs.getBoolean(FLIP_FACE_BUTTONS_PERF_STRING, DEFAULT_FLIP_FACE_BUTTONS);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -154,6 +154,8 @@
|
||||
<string name="summary_checkbox_mouse_emulation">Long pressing the Start button will switch the gamepad into mouse mode</string>
|
||||
<string name="title_checkbox_mouse_nav_buttons">Enable back and forward mouse buttons</string>
|
||||
<string name="summary_checkbox_mouse_nav_buttons">Enabling this option may break right clicking on some buggy devices</string>
|
||||
<string name="title_checkbox_flip_face_buttons">Flip face buttons</string>
|
||||
<string name="summary_checkbox_flip_face_buttons">Checking this inverts the face buttons A/B and X/Y</string>
|
||||
|
||||
<string name="category_on_screen_controls_settings">On-screen Controls Settings</string>
|
||||
<string name="title_checkbox_show_onscreen_controls">Show on-screen controls</string>
|
||||
|
||||
@@ -89,6 +89,11 @@
|
||||
android:title="@string/title_checkbox_vibrate_fallback"
|
||||
android:summary="@string/summary_checkbox_vibrate_fallback"
|
||||
android:defaultValue="false" />
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_flip_face_buttons"
|
||||
android:title="@string/title_checkbox_flip_face_buttons"
|
||||
android:summary="@string/summary_checkbox_flip_face_buttons"
|
||||
android:defaultValue="false" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/category_on_screen_controls_settings"
|
||||
android:key="category_onscreen_controls">
|
||||
|
||||
Reference in New Issue
Block a user