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

Commit 777245c1 authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Pointer Icon Refactor: Integrate mouse pointer acceleration

Before the refactoring, there could only be one mouse pointer globally,
so we only needed a boolean toggle for controlling pointer acceleration.

Now, since we can have multiple mouse pointers on different displays, we
need to be able to configure pointer acceleration on a per-display
basis.

Bug: 311651709
Test: atest inputflinger_tests
Change-Id: I6a85fe18dc0a5ea8fc5d41829e95a7c89c11a0a0
parent 502ddbdb
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -131,10 +131,10 @@ struct InputReaderConfiguration {
    // Currently only used when the enable_new_mouse_pointer_ballistics flag is enabled.
    int32_t mousePointerSpeed;

    // Whether to apply an acceleration curve to 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.
    bool mousePointerAccelerationEnabled;
    std::set<int32_t> displaysWithMousePointerAccelerationDisabled;

    // Velocity control parameters for mouse pointer movements.
    //
@@ -243,7 +243,7 @@ struct InputReaderConfiguration {
    InputReaderConfiguration()
          : virtualKeyQuietTime(0),
            mousePointerSpeed(0),
            mousePointerAccelerationEnabled(true),
            displaysWithMousePointerAccelerationDisabled(),
            pointerVelocityControlParameters(1.0f, 500.0f, 3000.0f,
                                             static_cast<float>(
                                                     android::os::IInputConstants::
+6 −5
Original line number Diff line number Diff line
@@ -159,14 +159,14 @@ std::list<NotifyArgs> CursorInputMapper::reconfigure(nsecs_t when,
        out.push_back(NotifyDeviceResetArgs(getContext()->getNextId(), when, getDeviceId()));
    }

    if (!changes.any() || changes.test(InputReaderConfiguration::Change::POINTER_SPEED) ||
    if (!changes.any() || changes.test(InputReaderConfiguration::Change::DISPLAY_INFO) ||
        configurePointerCapture) {
        configureOnChangePointerSpeed(readerConfig);
        configureOnChangeDisplayInfo(readerConfig);
    }

    if (!changes.any() || changes.test(InputReaderConfiguration::Change::DISPLAY_INFO) ||
    if (!changes.any() || changes.test(InputReaderConfiguration::Change::POINTER_SPEED) ||
        configurePointerCapture) {
        configureOnChangeDisplayInfo(readerConfig);
        configureOnChangePointerSpeed(readerConfig);
    }
    return out;
}
@@ -510,7 +510,8 @@ void CursorInputMapper::configureOnChangePointerSpeed(const InputReaderConfigura
    } else {
        if (mEnableNewMousePointerBallistics) {
            mNewPointerVelocityControl.setAccelerationEnabled(
                    config.mousePointerAccelerationEnabled);
                    config.displaysWithMousePointerAccelerationDisabled.count(
                            mDisplayId.value_or(ADISPLAY_ID_NONE)) == 0);
            mNewPointerVelocityControl.setCurve(
                    createAccelerationCurveForPointerSensitivity(config.mousePointerSpeed));
        } else {