Loading core/java/android/hardware/input/InputSettings.java +50 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static com.android.hardware.input.Flags.keyboardA11ySlowKeysFlag; import static com.android.hardware.input.Flags.keyboardA11yStickyKeysFlag; import static com.android.hardware.input.Flags.keyboardA11yMouseKeys; import static com.android.hardware.input.Flags.mouseReverseVerticalScrolling; import static com.android.hardware.input.Flags.mouseSwapPrimaryButton; import static com.android.hardware.input.Flags.touchpadTapDragging; import static com.android.hardware.input.Flags.touchpadVisualizer; import static com.android.input.flags.Flags.enableInputFilterRustImpl; Loading Loading @@ -371,6 +372,14 @@ public class InputSettings { return mouseReverseVerticalScrolling(); } /** * Returns true if the feature flag for mouse swap primary button is enabled. * @hide */ public static boolean isMouseSwapPrimaryButtonFeatureFlagEnabled() { return mouseSwapPrimaryButton(); } /** * Returns true if the touchpad visualizer is allowed to appear. * Loading Loading @@ -548,6 +557,47 @@ public class InputSettings { UserHandle.USER_CURRENT); } /** * Whether the primary mouse button is swapped on connected mice. * * @param context The application context. * @return Whether mice will have their primary buttons swapped, so that left clicking will * perform the secondary action (e.g. show menu) and right clicking will perform the primary * action. * * @hide */ public static boolean isMouseSwapPrimaryButtonEnabled(@NonNull Context context) { if (!isMouseSwapPrimaryButtonFeatureFlagEnabled()) { return false; } return Settings.System.getIntForUser(context.getContentResolver(), Settings.System.MOUSE_SWAP_PRIMARY_BUTTON, 0, UserHandle.USER_CURRENT) != 0; } /** * Sets whether mice will have their primary buttons swapped between left and right * clicks. * * @param context The application context. * @param swapPrimaryButton Whether swapping the primary button is enabled. * * @hide */ @RequiresPermission(Manifest.permission.WRITE_SETTINGS) public static void setMouseSwapPrimaryButton(@NonNull Context context, boolean swapPrimaryButton) { if (!isMouseSwapPrimaryButtonFeatureFlagEnabled()) { return; } Settings.System.putIntForUser(context.getContentResolver(), Settings.System.MOUSE_SWAP_PRIMARY_BUTTON, swapPrimaryButton ? 1 : 0, UserHandle.USER_CURRENT); } /** * Whether Accessibility bounce keys feature is enabled. * Loading core/java/android/provider/Settings.java +11 −0 Original line number Diff line number Diff line Loading @@ -6218,6 +6218,16 @@ public final class Settings { public static final String MOUSE_REVERSE_VERTICAL_SCROLLING = "mouse_reverse_vertical_scrolling"; /** * Whether to enable swapping the primary button for connected mice. * * When enabled, right clicking will be the primary button and left clicking will be the * secondary button (e.g. show menu). * @hide */ public static final String MOUSE_SWAP_PRIMARY_BUTTON = "mouse_swap_primary_button"; /** * Pointer fill style, specified by * {@link android.view.PointerIcon.PointerIconVectorStyleFill} constants. Loading Loading @@ -6457,6 +6467,7 @@ public final class Settings { PRIVATE_SETTINGS.add(SCREEN_FLASH_NOTIFICATION_COLOR); PRIVATE_SETTINGS.add(DEFAULT_DEVICE_FONT_SCALE); PRIVATE_SETTINGS.add(MOUSE_REVERSE_VERTICAL_SCROLLING); PRIVATE_SETTINGS.add(MOUSE_SWAP_PRIMARY_BUTTON); } /** Loading core/proto/android/providers/settings/system.proto +1 −0 Original line number Diff line number Diff line Loading @@ -224,6 +224,7 @@ message SystemSettingsProto { option (android.msg_privacy).dest = DEST_EXPLICIT; optional SettingProto reverse_vertical_scrolling = 1 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto swap_primary_button = 2 [ (android.privacy).dest = DEST_AUTOMATIC ]; } optional Mouse mouse = 38; Loading packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java +1 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ public class SystemSettings { Settings.System.AUTO_LAUNCH_MEDIA_CONTROLS, Settings.System.LOCALE_PREFERENCES, Settings.System.MOUSE_REVERSE_VERTICAL_SCROLLING, Settings.System.MOUSE_SWAP_PRIMARY_BUTTON, Settings.System.TOUCHPAD_POINTER_SPEED, Settings.System.TOUCHPAD_NATURAL_SCROLLING, Settings.System.TOUCHPAD_TAP_TO_CLICK, Loading packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java +1 −0 Original line number Diff line number Diff line Loading @@ -222,6 +222,7 @@ public class SystemSettingsValidators { VALIDATORS.put(System.POINTER_SCALE, new InclusiveFloatRangeValidator(DEFAULT_POINTER_SCALE, LARGE_POINTER_SCALE)); VALIDATORS.put(System.MOUSE_REVERSE_VERTICAL_SCROLLING, BOOLEAN_VALIDATOR); VALIDATORS.put(System.MOUSE_SWAP_PRIMARY_BUTTON, BOOLEAN_VALIDATOR); VALIDATORS.put(System.TOUCHPAD_POINTER_SPEED, new InclusiveIntegerRangeValidator(-7, 7)); VALIDATORS.put(System.TOUCHPAD_NATURAL_SCROLLING, BOOLEAN_VALIDATOR); VALIDATORS.put(System.TOUCHPAD_TAP_TO_CLICK, BOOLEAN_VALIDATOR); Loading Loading
core/java/android/hardware/input/InputSettings.java +50 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ import static com.android.hardware.input.Flags.keyboardA11ySlowKeysFlag; import static com.android.hardware.input.Flags.keyboardA11yStickyKeysFlag; import static com.android.hardware.input.Flags.keyboardA11yMouseKeys; import static com.android.hardware.input.Flags.mouseReverseVerticalScrolling; import static com.android.hardware.input.Flags.mouseSwapPrimaryButton; import static com.android.hardware.input.Flags.touchpadTapDragging; import static com.android.hardware.input.Flags.touchpadVisualizer; import static com.android.input.flags.Flags.enableInputFilterRustImpl; Loading Loading @@ -371,6 +372,14 @@ public class InputSettings { return mouseReverseVerticalScrolling(); } /** * Returns true if the feature flag for mouse swap primary button is enabled. * @hide */ public static boolean isMouseSwapPrimaryButtonFeatureFlagEnabled() { return mouseSwapPrimaryButton(); } /** * Returns true if the touchpad visualizer is allowed to appear. * Loading Loading @@ -548,6 +557,47 @@ public class InputSettings { UserHandle.USER_CURRENT); } /** * Whether the primary mouse button is swapped on connected mice. * * @param context The application context. * @return Whether mice will have their primary buttons swapped, so that left clicking will * perform the secondary action (e.g. show menu) and right clicking will perform the primary * action. * * @hide */ public static boolean isMouseSwapPrimaryButtonEnabled(@NonNull Context context) { if (!isMouseSwapPrimaryButtonFeatureFlagEnabled()) { return false; } return Settings.System.getIntForUser(context.getContentResolver(), Settings.System.MOUSE_SWAP_PRIMARY_BUTTON, 0, UserHandle.USER_CURRENT) != 0; } /** * Sets whether mice will have their primary buttons swapped between left and right * clicks. * * @param context The application context. * @param swapPrimaryButton Whether swapping the primary button is enabled. * * @hide */ @RequiresPermission(Manifest.permission.WRITE_SETTINGS) public static void setMouseSwapPrimaryButton(@NonNull Context context, boolean swapPrimaryButton) { if (!isMouseSwapPrimaryButtonFeatureFlagEnabled()) { return; } Settings.System.putIntForUser(context.getContentResolver(), Settings.System.MOUSE_SWAP_PRIMARY_BUTTON, swapPrimaryButton ? 1 : 0, UserHandle.USER_CURRENT); } /** * Whether Accessibility bounce keys feature is enabled. * Loading
core/java/android/provider/Settings.java +11 −0 Original line number Diff line number Diff line Loading @@ -6218,6 +6218,16 @@ public final class Settings { public static final String MOUSE_REVERSE_VERTICAL_SCROLLING = "mouse_reverse_vertical_scrolling"; /** * Whether to enable swapping the primary button for connected mice. * * When enabled, right clicking will be the primary button and left clicking will be the * secondary button (e.g. show menu). * @hide */ public static final String MOUSE_SWAP_PRIMARY_BUTTON = "mouse_swap_primary_button"; /** * Pointer fill style, specified by * {@link android.view.PointerIcon.PointerIconVectorStyleFill} constants. Loading Loading @@ -6457,6 +6467,7 @@ public final class Settings { PRIVATE_SETTINGS.add(SCREEN_FLASH_NOTIFICATION_COLOR); PRIVATE_SETTINGS.add(DEFAULT_DEVICE_FONT_SCALE); PRIVATE_SETTINGS.add(MOUSE_REVERSE_VERTICAL_SCROLLING); PRIVATE_SETTINGS.add(MOUSE_SWAP_PRIMARY_BUTTON); } /** Loading
core/proto/android/providers/settings/system.proto +1 −0 Original line number Diff line number Diff line Loading @@ -224,6 +224,7 @@ message SystemSettingsProto { option (android.msg_privacy).dest = DEST_EXPLICIT; optional SettingProto reverse_vertical_scrolling = 1 [ (android.privacy).dest = DEST_AUTOMATIC ]; optional SettingProto swap_primary_button = 2 [ (android.privacy).dest = DEST_AUTOMATIC ]; } optional Mouse mouse = 38; Loading
packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java +1 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ public class SystemSettings { Settings.System.AUTO_LAUNCH_MEDIA_CONTROLS, Settings.System.LOCALE_PREFERENCES, Settings.System.MOUSE_REVERSE_VERTICAL_SCROLLING, Settings.System.MOUSE_SWAP_PRIMARY_BUTTON, Settings.System.TOUCHPAD_POINTER_SPEED, Settings.System.TOUCHPAD_NATURAL_SCROLLING, Settings.System.TOUCHPAD_TAP_TO_CLICK, Loading
packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java +1 −0 Original line number Diff line number Diff line Loading @@ -222,6 +222,7 @@ public class SystemSettingsValidators { VALIDATORS.put(System.POINTER_SCALE, new InclusiveFloatRangeValidator(DEFAULT_POINTER_SCALE, LARGE_POINTER_SCALE)); VALIDATORS.put(System.MOUSE_REVERSE_VERTICAL_SCROLLING, BOOLEAN_VALIDATOR); VALIDATORS.put(System.MOUSE_SWAP_PRIMARY_BUTTON, BOOLEAN_VALIDATOR); VALIDATORS.put(System.TOUCHPAD_POINTER_SPEED, new InclusiveIntegerRangeValidator(-7, 7)); VALIDATORS.put(System.TOUCHPAD_NATURAL_SCROLLING, BOOLEAN_VALIDATOR); VALIDATORS.put(System.TOUCHPAD_TAP_TO_CLICK, BOOLEAN_VALIDATOR); Loading