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

Commit 3dee0d02 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 10113759 from a04c0f68 to udc-release

Change-Id: I1259054dcd0da515f666c55129c6634075f56a5c
parents 927c3e15 a04c0f68
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -49,11 +49,10 @@ bool VirtualInputDevice::writeInputEvent(uint16_t type, uint16_t code, int32_t v
    std::chrono::seconds seconds = std::chrono::duration_cast<std::chrono::seconds>(eventTime);
    std::chrono::microseconds microseconds =
            std::chrono::duration_cast<std::chrono::microseconds>(eventTime - seconds);
    struct input_event ev = {.type = type,
                             .code = code,
                             .value = value,
                             .input_event_sec = static_cast<time_t>(seconds.count()),
                             .input_event_usec = static_cast<suseconds_t>(microseconds.count())};
    struct input_event ev = {.type = type, .code = code, .value = value};
    ev.input_event_sec = static_cast<decltype(ev.input_event_sec)>(seconds.count());
    ev.input_event_usec = static_cast<decltype(ev.input_event_usec)>(microseconds.count());

    return TEMP_FAILURE_RETRY(write(mFd, &ev, sizeof(struct input_event))) == sizeof(ev);
}

+7 −7
Original line number Diff line number Diff line
@@ -446,17 +446,17 @@ std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers(

    // Switch-like devices.
    if (classes.test(InputDeviceClass::SWITCH)) {
        mappers.push_back(std::make_unique<SwitchInputMapper>(contextPtr, readerConfig));
        mappers.push_back(createInputMapper<SwitchInputMapper>(contextPtr, readerConfig));
    }

    // Scroll wheel-like devices.
    if (classes.test(InputDeviceClass::ROTARY_ENCODER)) {
        mappers.push_back(std::make_unique<RotaryEncoderInputMapper>(contextPtr, readerConfig));
        mappers.push_back(createInputMapper<RotaryEncoderInputMapper>(contextPtr, readerConfig));
    }

    // Vibrator-like devices.
    if (classes.test(InputDeviceClass::VIBRATOR)) {
        mappers.push_back(std::make_unique<VibratorInputMapper>(contextPtr, readerConfig));
        mappers.push_back(createInputMapper<VibratorInputMapper>(contextPtr, readerConfig));
    }

    // Battery-like devices or light-containing devices.
@@ -488,7 +488,7 @@ std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers(

    // Cursor-like devices.
    if (classes.test(InputDeviceClass::CURSOR)) {
        mappers.push_back(std::make_unique<CursorInputMapper>(contextPtr, readerConfig));
        mappers.push_back(createInputMapper<CursorInputMapper>(contextPtr, readerConfig));
    }

    // Touchscreens and touchpad devices.
@@ -501,7 +501,7 @@ std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers(
            (identifier.product == 0x05c4 || identifier.product == 0x09cc);
    if (ENABLE_TOUCHPAD_GESTURES_LIBRARY && classes.test(InputDeviceClass::TOUCHPAD) &&
        classes.test(InputDeviceClass::TOUCH_MT) && !isSonyDualShock4Touchpad) {
        mappers.push_back(std::make_unique<TouchpadInputMapper>(contextPtr, readerConfig));
        mappers.push_back(createInputMapper<TouchpadInputMapper>(contextPtr, readerConfig));
    } else if (classes.test(InputDeviceClass::TOUCH_MT)) {
        mappers.push_back(createInputMapper<MultiTouchInputMapper>(contextPtr, readerConfig));
    } else if (classes.test(InputDeviceClass::TOUCH)) {
@@ -510,12 +510,12 @@ std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers(

    // Joystick-like devices.
    if (classes.test(InputDeviceClass::JOYSTICK)) {
        mappers.push_back(std::make_unique<JoystickInputMapper>(contextPtr, readerConfig));
        mappers.push_back(createInputMapper<JoystickInputMapper>(contextPtr, readerConfig));
    }

    // Motion sensor enabled devices.
    if (classes.test(InputDeviceClass::SENSOR)) {
        mappers.push_back(std::make_unique<SensorInputMapper>(contextPtr, readerConfig));
        mappers.push_back(createInputMapper<SensorInputMapper>(contextPtr, readerConfig));
    }

    // External stylus-like devices.
+22 −30
Original line number Diff line number Diff line
@@ -71,9 +71,7 @@ void CursorMotionAccumulator::finishSync() {
CursorInputMapper::CursorInputMapper(InputDeviceContext& deviceContext,
                                     const InputReaderConfiguration& readerConfig)
      : InputMapper(deviceContext, readerConfig),
        mLastEventTime(std::numeric_limits<nsecs_t>::min()) {
    configureWithZeroChanges(readerConfig);
}
        mLastEventTime(std::numeric_limits<nsecs_t>::min()) {}

CursorInputMapper::~CursorInputMapper() {
    if (mPointerController != nullptr) {
@@ -142,46 +140,51 @@ std::list<NotifyArgs> CursorInputMapper::reconfigure(nsecs_t when,
                                                     ConfigurationChanges changes) {
    std::list<NotifyArgs> out = InputMapper::reconfigure(when, readerConfig, changes);

    if (!changes.any()) {
        configureWithZeroChanges(readerConfig);
        return out;
    if (!changes.any()) { // first time only
        configureBasicParams();
    }

    const bool configurePointerCapture = mParameters.mode != Parameters::Mode::NAVIGATION &&
            changes.test(InputReaderConfiguration::Change::POINTER_CAPTURE);
    const bool configurePointerCapture = !changes.any() ||
            (mParameters.mode != Parameters::Mode::NAVIGATION &&
             changes.test(InputReaderConfiguration::Change::POINTER_CAPTURE));
    if (configurePointerCapture) {
        configureOnPointerCapture(readerConfig);
        out.push_back(NotifyDeviceResetArgs(getContext()->getNextId(), when, getDeviceId()));
    }

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

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

void CursorInputMapper::configureParameters() {
    mParameters.mode = Parameters::Mode::POINTER;
    const PropertyMap& config = getDeviceContext().getConfiguration();
CursorInputMapper::Parameters CursorInputMapper::computeParameters(
        const InputDeviceContext& deviceContext) {
    Parameters parameters;
    parameters.mode = Parameters::Mode::POINTER;
    const PropertyMap& config = deviceContext.getConfiguration();
    std::optional<std::string> cursorModeString = config.getString("cursor.mode");
    if (cursorModeString.has_value()) {
        if (*cursorModeString == "navigation") {
            mParameters.mode = Parameters::Mode::NAVIGATION;
            parameters.mode = Parameters::Mode::NAVIGATION;
        } else if (*cursorModeString != "pointer" && *cursorModeString != "default") {
            ALOGW("Invalid value for cursor.mode: '%s'", cursorModeString->c_str());
        }
    }

    mParameters.orientationAware = config.getBool("cursor.orientationAware").value_or(false);
    parameters.orientationAware = config.getBool("cursor.orientationAware").value_or(false);

    mParameters.hasAssociatedDisplay = false;
    if (mParameters.mode == Parameters::Mode::POINTER || mParameters.orientationAware) {
        mParameters.hasAssociatedDisplay = true;
    parameters.hasAssociatedDisplay = false;
    if (parameters.mode == Parameters::Mode::POINTER || parameters.orientationAware) {
        parameters.hasAssociatedDisplay = true;
    }
    return parameters;
}

void CursorInputMapper::dumpParameters(std::string& dump) {
@@ -424,22 +427,11 @@ std::optional<int32_t> CursorInputMapper::getAssociatedDisplayId() {
    return mDisplayId;
}

void CursorInputMapper::configureWithZeroChanges(const InputReaderConfiguration& readerConfig) {
    // Configuration with zero changes
    configureBasicParams();
    if (mParameters.mode != Parameters::Mode::NAVIGATION &&
        readerConfig.pointerCaptureRequest.enable) {
        configureOnPointerCapture(readerConfig);
    }
    configureOnChangePointerSpeed(readerConfig);
    configureOnChangeDisplayInfo(readerConfig);
}

void CursorInputMapper::configureBasicParams() {
    mCursorScrollAccumulator.configure(getDeviceContext());

    // Configure basic parameters.
    configureParameters();
    mParameters = computeParameters(getDeviceContext());

    // Configure device mode.
    switch (mParameters.mode) {
+8 −4
Original line number Diff line number Diff line
@@ -53,8 +53,10 @@ private:

class CursorInputMapper : public InputMapper {
public:
    explicit CursorInputMapper(InputDeviceContext& deviceContext,
                               const InputReaderConfiguration& readerConfig);
    template <class T, class... Args>
    friend std::unique_ptr<T> createInputMapper(InputDeviceContext& deviceContext,
                                                const InputReaderConfiguration& readerConfig,
                                                Args... args);
    virtual ~CursorInputMapper();

    virtual uint32_t getSources() const override;
@@ -125,15 +127,17 @@ private:
    nsecs_t mDownTime;
    nsecs_t mLastEventTime;

    void configureParameters();
    explicit CursorInputMapper(InputDeviceContext& deviceContext,
                               const InputReaderConfiguration& readerConfig);
    void dumpParameters(std::string& dump);
    void configureWithZeroChanges(const InputReaderConfiguration& readerConfig);
    void configureBasicParams();
    void configureOnPointerCapture(const InputReaderConfiguration& config);
    void configureOnChangePointerSpeed(const InputReaderConfiguration& config);
    void configureOnChangeDisplayInfo(const InputReaderConfiguration& config);

    [[nodiscard]] std::list<NotifyArgs> sync(nsecs_t when, nsecs_t readTime);

    static Parameters computeParameters(const InputDeviceContext& deviceContext);
};

} // namespace android
+7 −2
Original line number Diff line number Diff line
@@ -22,8 +22,10 @@ namespace android {

class JoystickInputMapper : public InputMapper {
public:
    explicit JoystickInputMapper(InputDeviceContext& deviceContext,
                                 const InputReaderConfiguration& readerConfig);
    template <class T, class... Args>
    friend std::unique_ptr<T> createInputMapper(InputDeviceContext& deviceContext,
                                                const InputReaderConfiguration& readerConfig,
                                                Args... args);
    virtual ~JoystickInputMapper();

    virtual uint32_t getSources() const override;
@@ -87,6 +89,9 @@ private:
        }
    };

    explicit JoystickInputMapper(InputDeviceContext& deviceContext,
                                 const InputReaderConfiguration& readerConfig);

    static Axis createAxis(const AxisInfo& AxisInfo, const RawAbsoluteAxisInfo& rawAxisInfo,
                           bool explicitlyMapped);

Loading