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

Commit d047bdb2 authored by Arpit Singh's avatar Arpit Singh Committed by Android (Google) Code Review
Browse files

Merge "InputMapper refactor: SensorInputMapper" into udc-dev

parents 315eb8c9 61dd33e2
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -515,7 +515,7 @@ std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers(


    // Motion sensor enabled devices.
    // Motion sensor enabled devices.
    if (classes.test(InputDeviceClass::SENSOR)) {
    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.
    // External stylus-like devices.
+7 −2
Original line number Original line Diff line number Diff line
@@ -27,8 +27,10 @@ static constexpr ssize_t SENSOR_VEC_LEN = 3;


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


    uint32_t getSources() const override;
    uint32_t getSources() const override;
@@ -106,6 +108,9 @@ private:
        }
        }
    };
    };


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

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


    // Axes indexed by raw ABS_* axis index.
    // Axes indexed by raw ABS_* axis index.
+3 −3
Original line number Original line Diff line number Diff line
@@ -2784,7 +2784,7 @@ void SensorInputMapperTest::setGyroProperties() {
}
}
TEST_F(SensorInputMapperTest, GetSources) {
TEST_F(SensorInputMapperTest, GetSources) {
    SensorInputMapper& mapper = addMapperAndConfigure<SensorInputMapper>();
    SensorInputMapper& mapper = constructAndAddMapper<SensorInputMapper>();
    ASSERT_EQ(static_cast<uint32_t>(AINPUT_SOURCE_SENSOR), mapper.getSources());
    ASSERT_EQ(static_cast<uint32_t>(AINPUT_SOURCE_SENSOR), mapper.getSources());
}
}
@@ -2792,7 +2792,7 @@ TEST_F(SensorInputMapperTest, GetSources) {
TEST_F(SensorInputMapperTest, ProcessAccelerometerSensor) {
TEST_F(SensorInputMapperTest, ProcessAccelerometerSensor) {
    setAccelProperties();
    setAccelProperties();
    prepareAccelAxes();
    prepareAccelAxes();
    SensorInputMapper& mapper = addMapperAndConfigure<SensorInputMapper>();
    SensorInputMapper& mapper = constructAndAddMapper<SensorInputMapper>();
    ASSERT_TRUE(mapper.enableSensor(InputDeviceSensorType::ACCELEROMETER,
    ASSERT_TRUE(mapper.enableSensor(InputDeviceSensorType::ACCELEROMETER,
                                    std::chrono::microseconds(10000),
                                    std::chrono::microseconds(10000),
@@ -2822,7 +2822,7 @@ TEST_F(SensorInputMapperTest, ProcessAccelerometerSensor) {
TEST_F(SensorInputMapperTest, ProcessGyroscopeSensor) {
TEST_F(SensorInputMapperTest, ProcessGyroscopeSensor) {
    setGyroProperties();
    setGyroProperties();
    prepareGyroAxes();
    prepareGyroAxes();
    SensorInputMapper& mapper = addMapperAndConfigure<SensorInputMapper>();
    SensorInputMapper& mapper = constructAndAddMapper<SensorInputMapper>();
    ASSERT_TRUE(mapper.enableSensor(InputDeviceSensorType::GYROSCOPE,
    ASSERT_TRUE(mapper.enableSensor(InputDeviceSensorType::GYROSCOPE,
                                    std::chrono::microseconds(10000),
                                    std::chrono::microseconds(10000),