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

Commit f1d4eb95 authored by Harry Cutts's avatar Harry Cutts Committed by Android (Google) Code Review
Browse files

Merge "input: replace pointer acceleration factor with a boolean" into main

parents 323b6a27 6b81f535
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -245,8 +245,8 @@ class InputController {
        mInputManagerInternal.setPointerIconVisible(visible, displayId);
    }

    void setPointerAcceleration(float pointerAcceleration, int displayId) {
        mInputManagerInternal.setPointerAcceleration(pointerAcceleration, displayId);
    void setMousePointerAccelerationEnabled(boolean enabled, int displayId) {
        mInputManagerInternal.setMousePointerAccelerationEnabled(enabled, displayId);
    }

    void setDisplayEligibilityForPointerCapture(boolean isEligible, int displayId) {
+1 −1
Original line number Diff line number Diff line
@@ -1110,7 +1110,7 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub
        final long token = Binder.clearCallingIdentity();
        try {
            mInputController.setShowPointerIcon(showPointer, displayId);
            mInputController.setPointerAcceleration(1f, displayId);
            mInputController.setMousePointerAccelerationEnabled(false, displayId);
            mInputController.setDisplayEligibilityForPointerCapture(/* isEligible= */ false,
                    displayId);
            // WM throws a SecurityException if the display is untrusted.
+6 −3
Original line number Diff line number Diff line
@@ -104,10 +104,13 @@ public abstract class InputManagerInternal {
    public abstract PointF getCursorPosition();

    /**
     * Sets the pointer acceleration.
     * See {@code frameworks/native/include/input/VelocityControl.h#VelocityControlParameters}.
     * Enables or disables pointer acceleration for mouse movements.
     *
     * Note that this only affects pointer movements from mice (that is, pointing devices which send
     * relative motions, including trackballs and pointing sticks), not from other pointer devices
     * such as touchpads and styluses.
     */
    public abstract void setPointerAcceleration(float acceleration, int displayId);
    public abstract void setMousePointerAccelerationEnabled(boolean enabled, int displayId);

    /**
     * Sets the eligibility of windows on a given display for pointer capture. If a display is
+21 −15
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ import android.os.CombinedVibration;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.IInputConstants;
import android.os.IVibratorStateListener;
import android.os.InputEventInjectionResult;
import android.os.InputEventInjectionSync;
@@ -1372,9 +1371,9 @@ public class InputManagerService extends IInputManager.Stub
        mNative.setPointerSpeed(speed);
    }

    private void setPointerAcceleration(float acceleration, int displayId) {
    private void setMousePointerAccelerationEnabled(boolean enabled, int displayId) {
        updateAdditionalDisplayInputProperties(displayId,
                properties -> properties.pointerAcceleration = acceleration);
                properties -> properties.mousePointerAccelerationEnabled = enabled);
    }

    private void setPointerIconVisible(boolean visible, int displayId) {
@@ -2261,7 +2260,8 @@ public class InputManagerService extends IInputManager.Stub
                            + mAdditionalDisplayInputProperties.keyAt(i));
                    final AdditionalDisplayInputProperties properties =
                            mAdditionalDisplayInputProperties.valueAt(i);
                    pw.println("pointerAcceleration: " + properties.pointerAcceleration);
                    pw.println("mousePointerAccelerationEnabled: "
                            + properties.mousePointerAccelerationEnabled);
                    pw.println("pointerIconVisible: " + properties.pointerIconVisible);
                }
                pw.decreaseIndent();
@@ -3289,8 +3289,8 @@ public class InputManagerService extends IInputManager.Stub
        }

        @Override
        public void setPointerAcceleration(float acceleration, int displayId) {
            InputManagerService.this.setPointerAcceleration(acceleration, displayId);
        public void setMousePointerAccelerationEnabled(boolean enabled, int displayId) {
            InputManagerService.this.setMousePointerAccelerationEnabled(enabled, displayId);
        }

        @Override
@@ -3382,11 +3382,15 @@ public class InputManagerService extends IInputManager.Stub
    private static class AdditionalDisplayInputProperties {

        static final boolean DEFAULT_POINTER_ICON_VISIBLE = true;
        static final float DEFAULT_POINTER_ACCELERATION =
                (float) IInputConstants.DEFAULT_POINTER_ACCELERATION;
        static final boolean DEFAULT_MOUSE_POINTER_ACCELERATION_ENABLED = true;

        // The pointer acceleration for this display.
        public float pointerAcceleration;
        /**
         * Whether to enable mouse pointer acceleration on this display. Note that this only affects
         * pointer movements from mice (that is, pointing devices which send relative motions,
         * including trackballs and pointing sticks), not from other pointer devices such as
         * touchpads and styluses.
         */
        public boolean mousePointerAccelerationEnabled;

        // Whether the pointer icon should be visible or hidden on this display.
        public boolean pointerIconVisible;
@@ -3396,12 +3400,12 @@ public class InputManagerService extends IInputManager.Stub
        }

        public boolean allDefaults() {
            return Float.compare(pointerAcceleration, DEFAULT_POINTER_ACCELERATION) == 0
            return mousePointerAccelerationEnabled == DEFAULT_MOUSE_POINTER_ACCELERATION_ENABLED
                    && pointerIconVisible == DEFAULT_POINTER_ICON_VISIBLE;
        }

        public void reset() {
            pointerAcceleration = DEFAULT_POINTER_ACCELERATION;
            mousePointerAccelerationEnabled = DEFAULT_MOUSE_POINTER_ACCELERATION_ENABLED;
            pointerIconVisible = DEFAULT_POINTER_ICON_VISIBLE;
        }
    }
@@ -3433,9 +3437,11 @@ public class InputManagerService extends IInputManager.Stub
            }
        }

        if (properties.pointerAcceleration != mCurrentDisplayProperties.pointerAcceleration) {
            mCurrentDisplayProperties.pointerAcceleration = properties.pointerAcceleration;
            mNative.setPointerAcceleration(properties.pointerAcceleration);
        if (properties.mousePointerAccelerationEnabled
                != mCurrentDisplayProperties.mousePointerAccelerationEnabled) {
            mCurrentDisplayProperties.mousePointerAccelerationEnabled =
                    properties.mousePointerAccelerationEnabled;
            mNative.setMousePointerAccelerationEnabled(properties.mousePointerAccelerationEnabled);
        }
    }

+2 −2
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ interface NativeInputManagerService {

    void setPointerSpeed(int speed);

    void setPointerAcceleration(float acceleration);
    void setMousePointerAccelerationEnabled(boolean enabled);

    void setTouchpadPointerSpeed(int speed);

@@ -351,7 +351,7 @@ interface NativeInputManagerService {
        public native void setPointerSpeed(int speed);

        @Override
        public native void setPointerAcceleration(float acceleration);
        public native void setMousePointerAccelerationEnabled(boolean enabled);

        @Override
        public native void setTouchpadPointerSpeed(int speed);
Loading