diff --git a/app/src/main/java/com/limelight/binding/input/ControllerHandler.java b/app/src/main/java/com/limelight/binding/input/ControllerHandler.java index 679e2a60..0e59e2f8 100644 --- a/app/src/main/java/com/limelight/binding/input/ControllerHandler.java +++ b/app/src/main/java/com/limelight/binding/input/ControllerHandler.java @@ -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); diff --git a/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java b/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java index 5b3d1881..16a1cffa 100644 --- a/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java +++ b/app/src/main/java/com/limelight/preferences/PreferenceConfiguration.java @@ -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; } diff --git a/app/src/main/java/com/limelight/preferences/StreamSettings.java b/app/src/main/java/com/limelight/preferences/StreamSettings.java index dee5d578..651a657a 100644 --- a/app/src/main/java/com/limelight/preferences/StreamSettings.java +++ b/app/src/main/java/com/limelight/preferences/StreamSettings.java @@ -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 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3deffe62..73afb81d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -167,9 +167,7 @@ Enable system equalizer support Allows audio effects to function while streaming, but may increase audio latency - Input Settings - Use the touchscreen as a trackpad - If enabled, the touchscreen acts like a trackpad. If disabled, the touchscreen directly controls the mouse cursor. + Gamepad Settings Automatic gamepad presence detection Unchecking this option forces a gamepad to always be present Emulate rumble support with vibration @@ -183,12 +181,20 @@ Use Moonlight\'s USB driver for all supported gamepads, even if native Xbox controller support is present Mouse emulation via gamepad Long pressing the Start button will switch the gamepad into mouse mode - Enable back and forward mouse buttons - Enabling this option may break right clicking on some buggy devices Flip face buttons Switches the face buttons A/B and X/Y for gamepads and the on-screen controls + Always control mouse with touchpad + Forces gamepad touchpad input to control the host mouse, even when emulating a gamepad with a touchpad. + Allow use of 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. + + Input Settings + Use the touchscreen as a trackpad + If enabled, the touchscreen acts like a trackpad. If disabled, the touchscreen directly controls the mouse cursor. Remote desktop mouse mode This can make mouse acceleration behave more naturally for remote desktop usage, but it is incompatible with many games. + Enable back and forward mouse buttons + Enabling this option may break right clicking on some buggy devices On-screen Controls Settings Show on-screen controls diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 25d68e90..65ed8a60 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -55,8 +55,8 @@ android:summary="@string/summary_checkbox_enable_audiofx" android:defaultValue="false" /> - + - - + + + + + + +