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

Commit 0a5f63f8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clean up feature flag for new mouse pointer ballistics" into main

parents b6f8de8f 62d0bd72
Loading
Loading
Loading
Loading
+0 −7
Original line number Original line Diff line number Diff line
@@ -93,13 +93,6 @@ flag {
  bug: "309018874"
  bug: "309018874"
}
}


flag {
  name: "enable_new_mouse_pointer_ballistics"
  namespace: "input"
  description: "Change the acceleration curves for mouse pointer movements to match the touchpad ones"
  bug: "315313622"
}

flag {
flag {
  name: "rate_limit_user_activity_poke_in_dispatcher"
  name: "rate_limit_user_activity_poke_in_dispatcher"
  namespace: "input"
  namespace: "input"
+6 −7
Original line number Original line Diff line number Diff line
@@ -137,19 +137,18 @@ struct InputReaderConfiguration {
    ui::LogicalDisplayId defaultPointerDisplayId;
    ui::LogicalDisplayId defaultPointerDisplayId;


    // The mouse pointer speed, as a number from -7 (slowest) to 7 (fastest).
    // The mouse pointer speed, as a number from -7 (slowest) to 7 (fastest).
    //
    // Currently only used when the enable_new_mouse_pointer_ballistics flag is enabled.
    int32_t mousePointerSpeed;
    int32_t mousePointerSpeed;


    // Displays on which an acceleration curve shouldn't be applied for pointer movements from mice.
    // Displays on which an acceleration curve shouldn't be applied for pointer movements from mice.
    //
    // Currently only used when the enable_new_mouse_pointer_ballistics flag is enabled.
    std::set<ui::LogicalDisplayId> displaysWithMousePointerAccelerationDisabled;
    std::set<ui::LogicalDisplayId> displaysWithMousePointerAccelerationDisabled;


    // Velocity control parameters for mouse pointer movements.
    // Velocity control parameters for touchpad pointer movements on the old touchpad stack (based
    // on TouchInputMapper).
    //
    // For mice, these are ignored and the values of mousePointerSpeed and
    // mousePointerAccelerationEnabled used instead.
    //
    //
    // If the enable_new_mouse_pointer_ballistics flag is enabled, these are ignored and the values
    // TODO(b/281840344): remove this.
    // of mousePointerSpeed and mousePointerAccelerationEnabled used instead.
    VelocityControlParameters pointerVelocityControlParameters;
    VelocityControlParameters pointerVelocityControlParameters;


    // Velocity control parameters for mouse wheel movements.
    // Velocity control parameters for mouse wheel movements.
+9 −29
Original line number Original line Diff line number Diff line
@@ -33,8 +33,6 @@


#include "input/PrintTools.h"
#include "input/PrintTools.h"


namespace input_flags = com::android::input::flags;

namespace android {
namespace android {


// The default velocity control parameters that has no effect.
// The default velocity control parameters that has no effect.
@@ -77,8 +75,7 @@ void CursorMotionAccumulator::finishSync() {
CursorInputMapper::CursorInputMapper(InputDeviceContext& deviceContext,
CursorInputMapper::CursorInputMapper(InputDeviceContext& deviceContext,
                                     const InputReaderConfiguration& readerConfig)
                                     const InputReaderConfiguration& readerConfig)
      : InputMapper(deviceContext, readerConfig),
      : InputMapper(deviceContext, readerConfig),
        mLastEventTime(std::numeric_limits<nsecs_t>::min()),
        mLastEventTime(std::numeric_limits<nsecs_t>::min()) {}
        mEnableNewMousePointerBallistics(input_flags::enable_new_mouse_pointer_ballistics()) {}


uint32_t CursorInputMapper::getSources() const {
uint32_t CursorInputMapper::getSources() const {
    return mSource;
    return mSource;
@@ -207,8 +204,7 @@ std::list<NotifyArgs> CursorInputMapper::reset(nsecs_t when) {
    mDownTime = 0;
    mDownTime = 0;
    mLastEventTime = std::numeric_limits<nsecs_t>::min();
    mLastEventTime = std::numeric_limits<nsecs_t>::min();


    mOldPointerVelocityControl.reset();
    mPointerVelocityControl.reset();
    mNewPointerVelocityControl.reset();
    mWheelXVelocityControl.reset();
    mWheelXVelocityControl.reset();
    mWheelYVelocityControl.reset();
    mWheelYVelocityControl.reset();


@@ -291,11 +287,7 @@ std::list<NotifyArgs> CursorInputMapper::sync(nsecs_t when, nsecs_t readTime) {
    mWheelYVelocityControl.move(when, nullptr, &vscroll);
    mWheelYVelocityControl.move(when, nullptr, &vscroll);
    mWheelXVelocityControl.move(when, &hscroll, nullptr);
    mWheelXVelocityControl.move(when, &hscroll, nullptr);


    if (mEnableNewMousePointerBallistics) {
    mPointerVelocityControl.move(when, &deltaX, &deltaY);
        mNewPointerVelocityControl.move(when, &deltaX, &deltaY);
    } else {
        mOldPointerVelocityControl.move(when, &deltaX, &deltaY);
    }


    float xCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION;
    float xCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION;
    float yCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION;
    float yCursorPosition = AMOTION_EVENT_INVALID_CURSOR_POSITION;
@@ -486,27 +478,15 @@ void CursorInputMapper::configureOnPointerCapture(const InputReaderConfiguration
void CursorInputMapper::configureOnChangePointerSpeed(const InputReaderConfiguration& config) {
void CursorInputMapper::configureOnChangePointerSpeed(const InputReaderConfiguration& config) {
    if (mParameters.mode == Parameters::Mode::POINTER_RELATIVE) {
    if (mParameters.mode == Parameters::Mode::POINTER_RELATIVE) {
        // Disable any acceleration or scaling for the pointer when Pointer Capture is enabled.
        // Disable any acceleration or scaling for the pointer when Pointer Capture is enabled.
        if (mEnableNewMousePointerBallistics) {
        mPointerVelocityControl.setAccelerationEnabled(false);
            mNewPointerVelocityControl.setAccelerationEnabled(false);
        } else {
            mOldPointerVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS);
        }
        mWheelXVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS);
        mWheelXVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS);
        mWheelYVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS);
        mWheelYVelocityControl.setParameters(FLAT_VELOCITY_CONTROL_PARAMS);
    } else {
    } else {
        if (mEnableNewMousePointerBallistics) {
        mPointerVelocityControl.setAccelerationEnabled(
            mNewPointerVelocityControl.setAccelerationEnabled(
                config.displaysWithMousePointerAccelerationDisabled.count(
                config.displaysWithMousePointerAccelerationDisabled.count(
                        mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) == 0);
                        mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) == 0);
            mNewPointerVelocityControl.setCurve(
        mPointerVelocityControl.setCurve(
                createAccelerationCurveForPointerSensitivity(config.mousePointerSpeed));
                createAccelerationCurveForPointerSensitivity(config.mousePointerSpeed));
        } else {
            mOldPointerVelocityControl.setParameters(
                    (config.displaysWithMousePointerAccelerationDisabled.count(
                             mDisplayId.value_or(ui::LogicalDisplayId::INVALID)) == 0)
                            ? config.pointerVelocityControlParameters
                            : FLAT_VELOCITY_CONTROL_PARAMS);
        }
        mWheelXVelocityControl.setParameters(config.wheelVelocityControlParameters);
        mWheelXVelocityControl.setParameters(config.wheelVelocityControlParameters);
        mWheelYVelocityControl.setParameters(config.wheelVelocityControlParameters);
        mWheelYVelocityControl.setParameters(config.wheelVelocityControlParameters);
    }
    }
+1 −3
Original line number Original line Diff line number Diff line
@@ -104,8 +104,7 @@ private:


    // Velocity controls for mouse pointer and wheel movements.
    // Velocity controls for mouse pointer and wheel movements.
    // The controls for X and Y wheel movements are separate to keep them decoupled.
    // The controls for X and Y wheel movements are separate to keep them decoupled.
    SimpleVelocityControl mOldPointerVelocityControl;
    CurvedVelocityControl mPointerVelocityControl;
    CurvedVelocityControl mNewPointerVelocityControl;
    SimpleVelocityControl mWheelXVelocityControl;
    SimpleVelocityControl mWheelXVelocityControl;
    SimpleVelocityControl mWheelYVelocityControl;
    SimpleVelocityControl mWheelYVelocityControl;


@@ -120,7 +119,6 @@ private:
    nsecs_t mDownTime;
    nsecs_t mDownTime;
    nsecs_t mLastEventTime;
    nsecs_t mLastEventTime;


    const bool mEnableNewMousePointerBallistics;
    bool mMouseReverseVerticalScrolling = false;
    bool mMouseReverseVerticalScrolling = false;


    explicit CursorInputMapper(InputDeviceContext& deviceContext,
    explicit CursorInputMapper(InputDeviceContext& deviceContext,
Loading