mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-01 23:35:28 +00:00
Add options to control gamepad touchpad and motion and reorganize input settings
This commit is contained in:
parent
2b8a43ab13
commit
e6876926a4
@ -1477,6 +1477,11 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bail if the user wants gamepad touchpads to control the mouse
|
||||
if (prefConfig.gamepadTouchpadAsMouse) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only get a context if one already exists. We want to ensure we don't report non-gamepads.
|
||||
InputDeviceContext context = inputDeviceContexts.get(event.getDeviceId());
|
||||
if (context == null) {
|
||||
@ -1864,6 +1869,11 @@ public class ControllerHandler implements InputManager.InputDeviceListener, UsbD
|
||||
}
|
||||
|
||||
public void handleSetMotionEventState(final short controllerNumber, final byte motionType, short reportRateHz) {
|
||||
// Don't use motion sensors if the user turned them off
|
||||
if (!prefConfig.gamepadMotionSensors) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Report rate is restricted to <= 200 Hz without the HIGH_SAMPLING_RATE_SENSORS permission
|
||||
reportRateHz = (short) Math.min(200, reportRateHz);
|
||||
|
||||
|
@ -56,6 +56,8 @@ public class PreferenceConfiguration {
|
||||
private static final String ENABLE_AUDIO_FX_PREF_STRING = "checkbox_enable_audiofx";
|
||||
private static final String REDUCE_REFRESH_RATE_PREF_STRING = "checkbox_reduce_refresh_rate";
|
||||
private static final String FULL_RANGE_PREF_STRING = "checkbox_full_range";
|
||||
private static final String GAMEPAD_TOUCHPAD_AS_MOUSE_PREF_STRING = "checkbox_gamepad_touchpad_as_mouse";
|
||||
private static final String GAMEPAD_MOTION_SENSORS_PREF_STRING = "checkbox_gamepad_motion_sensors";
|
||||
|
||||
static final String DEFAULT_RESOLUTION = "1280x720";
|
||||
static final String DEFAULT_FPS = "60";
|
||||
@ -91,6 +93,8 @@ public class PreferenceConfiguration {
|
||||
private static final boolean DEFAULT_ENABLE_AUDIO_FX = false;
|
||||
private static final boolean DEFAULT_REDUCE_REFRESH_RATE = false;
|
||||
private static final boolean DEFAULT_FULL_RANGE = false;
|
||||
private static final boolean DEFAULT_GAMEPAD_TOUCHPAD_AS_MOUSE = true;
|
||||
private static final boolean DEFAULT_GAMEPAD_MOTION_SENSORS = true;
|
||||
|
||||
public static final int FRAME_PACING_MIN_LATENCY = 0;
|
||||
public static final int FRAME_PACING_BALANCED = 1;
|
||||
@ -133,6 +137,8 @@ public class PreferenceConfiguration {
|
||||
public boolean enableAudioFx;
|
||||
public boolean reduceRefreshRate;
|
||||
public boolean fullRange;
|
||||
public boolean gamepadMotionSensors;
|
||||
public boolean gamepadTouchpadAsMouse;
|
||||
|
||||
public static boolean isNativeResolution(int width, int height) {
|
||||
// It's not a native resolution if it matches an existing resolution option
|
||||
@ -537,6 +543,8 @@ public class PreferenceConfiguration {
|
||||
config.enableAudioFx = prefs.getBoolean(ENABLE_AUDIO_FX_PREF_STRING, DEFAULT_ENABLE_AUDIO_FX);
|
||||
config.reduceRefreshRate = prefs.getBoolean(REDUCE_REFRESH_RATE_PREF_STRING, DEFAULT_REDUCE_REFRESH_RATE);
|
||||
config.fullRange = prefs.getBoolean(FULL_RANGE_PREF_STRING, DEFAULT_FULL_RANGE);
|
||||
config.gamepadTouchpadAsMouse = prefs.getBoolean(GAMEPAD_TOUCHPAD_AS_MOUSE_PREF_STRING, DEFAULT_GAMEPAD_TOUCHPAD_AS_MOUSE);
|
||||
config.gamepadMotionSensors = prefs.getBoolean(GAMEPAD_MOTION_SENSORS_PREF_STRING, DEFAULT_GAMEPAD_MOTION_SENSORS);
|
||||
|
||||
return config;
|
||||
}
|
||||
|
@ -288,6 +288,14 @@ public class StreamSettings extends Activity {
|
||||
category.removePreference(findPreference("checkbox_absolute_mouse_mode"));
|
||||
}
|
||||
|
||||
// Hide gamepad motion sensor option when running on OSes before Android 12.
|
||||
// Support for motion, LED, battery, and other extensions were introduced in S.
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
|
||||
PreferenceCategory category =
|
||||
(PreferenceCategory) findPreference("category_gamepad_settings");
|
||||
category.removePreference(findPreference("checkbox_gamepad_motion_sensors"));
|
||||
}
|
||||
|
||||
// Remove PiP mode on devices pre-Oreo, where the feature is not available (some low RAM devices),
|
||||
// and on Fire OS where it violates the Amazon App Store guidelines for some reason.
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O ||
|
||||
@ -308,7 +316,7 @@ public class StreamSettings extends Activity {
|
||||
// Remove the vibration options if the device can't vibrate
|
||||
if (!((Vibrator)getActivity().getSystemService(Context.VIBRATOR_SERVICE)).hasVibrator()) {
|
||||
PreferenceCategory category =
|
||||
(PreferenceCategory) findPreference("category_input_settings");
|
||||
(PreferenceCategory) findPreference("category_gamepad_settings");
|
||||
category.removePreference(findPreference("checkbox_vibrate_fallback"));
|
||||
|
||||
// The entire OSC category may have already been removed by the touchscreen check above
|
||||
|
@ -167,9 +167,7 @@
|
||||
<string name="title_checkbox_enable_audiofx">Enable system equalizer support</string>
|
||||
<string name="summary_checkbox_enable_audiofx">Allows audio effects to function while streaming, but may increase audio latency</string>
|
||||
|
||||
<string name="category_input_settings">Input Settings</string>
|
||||
<string name="title_checkbox_touchscreen_trackpad">Use the touchscreen as a trackpad</string>
|
||||
<string name="summary_checkbox_touchscreen_trackpad">If enabled, the touchscreen acts like a trackpad. If disabled, the touchscreen directly controls the mouse cursor.</string>
|
||||
<string name="category_gamepad_settings">Gamepad Settings</string>
|
||||
<string name="title_checkbox_multi_controller">Automatic gamepad presence detection</string>
|
||||
<string name="summary_checkbox_multi_controller">Unchecking this option forces a gamepad to always be present</string>
|
||||
<string name="title_checkbox_vibrate_fallback">Emulate rumble support with vibration</string>
|
||||
@ -183,12 +181,20 @@
|
||||
<string name="summary_checkbox_usb_bind_all">Use Moonlight\'s USB driver for all supported gamepads, even if native Xbox controller support is present</string>
|
||||
<string name="title_checkbox_mouse_emulation">Mouse emulation via gamepad</string>
|
||||
<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">Switches the face buttons A/B and X/Y for gamepads and the on-screen controls</string>
|
||||
<string name="title_checkbox_gamepad_touchpad_as_mouse">Always control mouse with touchpad</string>
|
||||
<string name="summary_checkbox_gamepad_touchpad_as_mouse">Forces gamepad touchpad input to control the host mouse, even when emulating a gamepad with a touchpad.</string>
|
||||
<string name="title_checkbox_gamepad_motion_sensors">Allow use of gamepad motion sensors</string>
|
||||
<string name="summary_checkbox_gamepad_motion_sensors">Enables supported hosts to request motion sensor data when emulating a gamepad with motion sensors. Disabling may slightly reduce power and network usage if motion sensors are not being used in game.</string>
|
||||
|
||||
<string name="category_input_settings">Input Settings</string>
|
||||
<string name="title_checkbox_touchscreen_trackpad">Use the touchscreen as a trackpad</string>
|
||||
<string name="summary_checkbox_touchscreen_trackpad">If enabled, the touchscreen acts like a trackpad. If disabled, the touchscreen directly controls the mouse cursor.</string>
|
||||
<string name="title_checkbox_absolute_mouse_mode">Remote desktop mouse mode</string>
|
||||
<string name="summary_checkbox_absolute_mouse_mode">This can make mouse acceleration behave more naturally for remote desktop usage, but it is incompatible with many games.</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="category_on_screen_controls_settings">On-screen Controls Settings</string>
|
||||
<string name="title_checkbox_show_onscreen_controls">Show on-screen controls</string>
|
||||
|
@ -55,8 +55,8 @@
|
||||
android:summary="@string/summary_checkbox_enable_audiofx"
|
||||
android:defaultValue="false" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/category_input_settings"
|
||||
android:key="category_input_settings">
|
||||
<PreferenceCategory android:title="@string/category_gamepad_settings"
|
||||
android:key="category_gamepad_settings">
|
||||
<com.limelight.preferences.SeekBarPreference
|
||||
android:key="seekbar_deadzone"
|
||||
android:defaultValue="7"
|
||||
@ -64,21 +64,11 @@
|
||||
android:summary="@string/summary_seekbar_deadzone"
|
||||
android:text="@string/suffix_seekbar_deadzone"
|
||||
android:title="@string/title_seekbar_deadzone"/>
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_touchscreen_trackpad"
|
||||
android:title="@string/title_checkbox_touchscreen_trackpad"
|
||||
android:summary="@string/summary_checkbox_touchscreen_trackpad"
|
||||
android:defaultValue="true" />
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_multi_controller"
|
||||
android:title="@string/title_checkbox_multi_controller"
|
||||
android:summary="@string/summary_checkbox_multi_controller"
|
||||
android:defaultValue="true" />
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_mouse_nav_buttons"
|
||||
android:title="@string/title_checkbox_mouse_nav_buttons"
|
||||
android:summary="@string/summary_checkbox_mouse_nav_buttons"
|
||||
android:defaultValue="false" />
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_usb_driver"
|
||||
android:title="@string/title_checkbox_xb1_driver"
|
||||
@ -105,6 +95,30 @@
|
||||
android:title="@string/title_checkbox_flip_face_buttons"
|
||||
android:summary="@string/summary_checkbox_flip_face_buttons"
|
||||
android:defaultValue="false" />
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_gamepad_touchpad_as_mouse"
|
||||
android:title="@string/title_checkbox_gamepad_touchpad_as_mouse"
|
||||
android:summary="@string/summary_checkbox_gamepad_touchpad_as_mouse"
|
||||
android:defaultValue="true" />
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_gamepad_motion_sensors"
|
||||
android:title="@string/title_checkbox_gamepad_motion_sensors"
|
||||
android:summary="@string/summary_checkbox_gamepad_motion_sensors"
|
||||
android:defaultValue="true" />
|
||||
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="@string/category_input_settings"
|
||||
android:key="category_input_settings">
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_touchscreen_trackpad"
|
||||
android:title="@string/title_checkbox_touchscreen_trackpad"
|
||||
android:summary="@string/summary_checkbox_touchscreen_trackpad"
|
||||
android:defaultValue="true" />
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_mouse_nav_buttons"
|
||||
android:title="@string/title_checkbox_mouse_nav_buttons"
|
||||
android:summary="@string/summary_checkbox_mouse_nav_buttons"
|
||||
android:defaultValue="false" />
|
||||
<CheckBoxPreference
|
||||
android:key="checkbox_absolute_mouse_mode"
|
||||
android:title="@string/title_checkbox_absolute_mouse_mode"
|
||||
|
Loading…
x
Reference in New Issue
Block a user