Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5f1c0864 authored by Jimmy's avatar Jimmy
Browse files

Mouse: Plumb reverse mouse vertical scroll settings

Bug: 359349392
Bug: 352598211
Test: Local DUT with aconfig flags enabled, verified settings
      appeared and affects mouse scroll direction.

Flag: com.android.hardware.input.mouse_reverse_vertical_scrolling

Change-Id: Ia2972e1bd21265d7303f6bdaf250e5cbc26c609d
parent 202605ec
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import static com.android.hardware.input.Flags.keyboardA11yBounceKeysFlag;
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.touchpadTapDragging;
import static com.android.hardware.input.Flags.touchpadVisualizer;
import static com.android.input.flags.Flags.enableInputFilterRustImpl;
@@ -362,6 +363,14 @@ public class InputSettings {
        return touchpadVisualizer();
    }

    /**
     * Returns true if the feature flag for mouse reverse vertical scrolling is enabled.
     * @hide
     */
    public static boolean isMouseReverseVerticalScrollingFeatureFlagEnabled() {
        return mouseReverseVerticalScrolling();
    }

    /**
     * Returns true if the touchpad visualizer is allowed to appear.
     *
@@ -500,6 +509,45 @@ public class InputSettings {
        return isStylusPointerIconEnabled(context, false /* forceReloadSetting */);
    }

    /**
     * Whether mouse vertical scrolling is enabled, this applies only to connected mice.
     *
     * @param context The application context.
     * @return Whether the mouse will have its vertical scrolling reversed
     * (scroll down to move up).
     *
     * @hide
     */
    public static boolean isMouseReverseVerticalScrollingEnabled(@NonNull Context context) {
        if (!isMouseReverseVerticalScrollingFeatureFlagEnabled()) {
            return false;
        }

        return Settings.System.getIntForUser(context.getContentResolver(),
                Settings.System.MOUSE_REVERSE_VERTICAL_SCROLLING, 0, UserHandle.USER_CURRENT)
                != 0;
    }

    /**
     * Sets whether the connected mouse will have its vertical scrolling reversed.
     *
     * @param context The application context.
     * @param reverseScrolling Whether reverse scrolling is enabled.
     *
     * @hide
     */
    @RequiresPermission(Manifest.permission.WRITE_SETTINGS)
    public static void setMouseReverseVerticalScrolling(@NonNull Context context,
            boolean reverseScrolling) {
        if (!isMouseReverseVerticalScrollingFeatureFlagEnabled()) {
            return;
        }

        Settings.System.putIntForUser(context.getContentResolver(),
                Settings.System.MOUSE_REVERSE_VERTICAL_SCROLLING, reverseScrolling ? 1 : 0,
                UserHandle.USER_CURRENT);
    }

    /**
     * Whether Accessibility bounce keys feature is enabled.
     *
+10 −0
Original line number Diff line number Diff line
@@ -6204,6 +6204,15 @@ public final class Settings {
         */
        public static final String TOUCHPAD_RIGHT_CLICK_ZONE = "touchpad_right_click_zone";
        /**
         * Whether to enable reversed vertical scrolling for connected mice.
         *
         * When enabled, scrolling down on the mouse wheel will move the screen up and vice versa.
         * @hide
         */
        public static final String MOUSE_REVERSE_VERTICAL_SCROLLING =
                "mouse_reverse_vertical_scrolling";
        /**
         * Pointer fill style, specified by
         * {@link android.view.PointerIcon.PointerIconVectorStyleFill} constants.
@@ -6442,6 +6451,7 @@ public final class Settings {
            PRIVATE_SETTINGS.add(SCREEN_FLASH_NOTIFICATION);
            PRIVATE_SETTINGS.add(SCREEN_FLASH_NOTIFICATION_COLOR);
            PRIVATE_SETTINGS.add(DEFAULT_DEVICE_FONT_SCALE);
            PRIVATE_SETTINGS.add(MOUSE_REVERSE_VERTICAL_SCROLLING);
        }
        /**
+9 −1
Original line number Diff line number Diff line
@@ -220,6 +220,14 @@ message SystemSettingsProto {
    }
    optional Touchpad touchpad = 36;

    message Mouse {
        option (android.msg_privacy).dest = DEST_EXPLICIT;

        optional SettingProto reverse_vertical_scrolling = 1 [ (android.privacy).dest = DEST_AUTOMATIC ];
    }

    optional Mouse mouse = 38;

    optional SettingProto tty_mode = 31 [ (android.privacy).dest = DEST_AUTOMATIC ];

    message Vibrate {
@@ -277,5 +285,5 @@ message SystemSettingsProto {

    // Please insert fields in alphabetical order and group them into messages
    // if possible (to avoid reaching the method limit).
    // Next tag = 38;
    // Next tag = 39;
}
+1 −0
Original line number Diff line number Diff line
@@ -106,6 +106,7 @@ public class SystemSettings {
                Settings.System.UNREAD_NOTIFICATION_DOT_INDICATOR,
                Settings.System.AUTO_LAUNCH_MEDIA_CONTROLS,
                Settings.System.LOCALE_PREFERENCES,
                Settings.System.MOUSE_REVERSE_VERTICAL_SCROLLING,
                Settings.System.TOUCHPAD_POINTER_SPEED,
                Settings.System.TOUCHPAD_NATURAL_SCROLLING,
                Settings.System.TOUCHPAD_TAP_TO_CLICK,
+1 −0
Original line number Diff line number Diff line
@@ -221,6 +221,7 @@ public class SystemSettingsValidators {
                        POINTER_ICON_VECTOR_STYLE_STROKE_END));
        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.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