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

Commit dc51fa8d authored by Arpit Singh's avatar Arpit Singh Committed by Automerger Merge Worker
Browse files

Merge changes from topic "inputmapper-refactor-udc-dev" into udc-dev am: 50fe0d96 am: e3783a8b

parents 0a7e0da8 e3783a8b
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -203,7 +203,7 @@ std::list<NotifyArgs> InputDevice::configure(nsecs_t when,

    using Change = InputReaderConfiguration::Change;

    if (!isIgnored()) {
    if (!changes.any() || !isIgnored()) {
        // Full configuration should happen the first time configure is called
        // and when the device type is changed. Changing a device type can
        // affect various other parameters so should result in a
@@ -503,9 +503,9 @@ std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers(
        classes.test(InputDeviceClass::TOUCH_MT) && !isSonyDualShock4Touchpad) {
        mappers.push_back(std::make_unique<TouchpadInputMapper>(contextPtr, readerConfig));
    } else if (classes.test(InputDeviceClass::TOUCH_MT)) {
        mappers.push_back(std::make_unique<MultiTouchInputMapper>(contextPtr, readerConfig));
        mappers.push_back(createInputMapper<MultiTouchInputMapper>(contextPtr, readerConfig));
    } else if (classes.test(InputDeviceClass::TOUCH)) {
        mappers.push_back(std::make_unique<SingleTouchInputMapper>(contextPtr, readerConfig));
        mappers.push_back(createInputMapper<SingleTouchInputMapper>(contextPtr, readerConfig));
    }

    // Joystick-like devices.
@@ -520,7 +520,7 @@ std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers(

    // External stylus-like devices.
    if (classes.test(InputDeviceClass::EXTERNAL_STYLUS)) {
        mappers.push_back(std::make_unique<ExternalStylusInputMapper>(contextPtr, readerConfig));
        mappers.push_back(createInputMapper<ExternalStylusInputMapper>(contextPtr, readerConfig));
    }
    return mappers;
}
+10 −0
Original line number Diff line number Diff line
@@ -149,6 +149,16 @@ public:
        return *mapper;
    }

    template <class T, typename... Args>
    T& constructAndAddMapper(int32_t eventHubId, Args... args) {
        // create mapper
        auto& devicePair = mDevices[eventHubId];
        auto& deviceContext = devicePair.first;
        auto& mappers = devicePair.second;
        mappers.push_back(createInputMapper<T>(*deviceContext, args...));
        return static_cast<T&>(*mappers.back());
    }

    // construct and add a controller to the input device
    template <class T>
    T& addController(int32_t eventHubId) {
+6 −2
Original line number Diff line number Diff line
@@ -26,8 +26,10 @@ namespace android {

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

    uint32_t getSources() const override;
@@ -46,6 +48,8 @@ private:

    StylusState mStylusState;

    explicit ExternalStylusInputMapper(InputDeviceContext& deviceContext,
                                       const InputReaderConfiguration& readerConfig);
    [[nodiscard]] std::list<NotifyArgs> sync(nsecs_t when);
};

+26 −2
Original line number Diff line number Diff line
@@ -25,6 +25,20 @@
#include "VibrationElement.h"

namespace android {
/**
 * This is the factory method that must be used to create any InputMapper
 */
template <class T, class... Args>
std::unique_ptr<T> createInputMapper(InputDeviceContext& deviceContext,
                                     const InputReaderConfiguration& readerConfig, Args... args) {
    // Using `new` to access non-public constructors.
    std::unique_ptr<T> mapper(new T(deviceContext, readerConfig, args...));
    // We need to reset and configure the mapper to ensure it is ready to process event
    nsecs_t now = systemTime(SYSTEM_TIME_MONOTONIC);
    std::list<NotifyArgs> unused = mapper->reset(now);
    unused += mapper->reconfigure(now, readerConfig, /*changes=*/{});
    return mapper;
}

/* An input mapper transforms raw input events into cooked event data.
 * A single input device can have multiple associated input mappers in order to interpret
@@ -39,8 +53,15 @@ namespace android {
 */
class InputMapper {
public:
    explicit InputMapper(InputDeviceContext& deviceContext,
                         const InputReaderConfiguration& readerConfig);
    /**
     * Subclasses must either provide a public constructor
     * or must be-friend the factory method.
     */
    template <class T, class... Args>
    friend std::unique_ptr<T> createInputMapper(InputDeviceContext& deviceContext,
                                                const InputReaderConfiguration& readerConfig,
                                                Args... args);

    virtual ~InputMapper();

    inline int32_t getDeviceId() { return mDeviceContext.getId(); }
@@ -102,6 +123,9 @@ public:
protected:
    InputDeviceContext& mDeviceContext;

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

    status_t getAbsoluteAxisInfo(int32_t axis, RawAbsoluteAxisInfo* axisInfo);
    void bumpGeneration();

+7 −2
Original line number Diff line number Diff line
@@ -23,8 +23,11 @@ namespace android {

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

    ~MultiTouchInputMapper() override;

    [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
@@ -36,6 +39,8 @@ protected:
    bool hasStylus() const override;

private:
    explicit MultiTouchInputMapper(InputDeviceContext& deviceContext,
                                   const InputReaderConfiguration& readerConfig);
    // simulate_stylus_with_touch is a debug mode that converts all finger pointers reported by this
    // mapper's touchscreen into stylus pointers, and adds SOURCE_STYLUS to the input device.
    // It is used to simulate stylus events for debugging and testing on a device that does not
Loading