Loading services/inputflinger/reader/InputDevice.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -446,7 +446,7 @@ std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers( // Switch-like devices. // Switch-like devices. if (classes.test(InputDeviceClass::SWITCH)) { 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. // Scroll wheel-like devices. Loading services/inputflinger/reader/mapper/SwitchInputMapper.h +6 −2 Original line number Original line Diff line number Diff line Loading @@ -22,8 +22,10 @@ namespace android { class SwitchInputMapper : public InputMapper { class SwitchInputMapper : public InputMapper { public: public: explicit SwitchInputMapper(InputDeviceContext& deviceContext, template <class T, class... Args> const InputReaderConfiguration& readerConfig); friend std::unique_ptr<T> createInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig, Args... args); virtual ~SwitchInputMapper(); virtual ~SwitchInputMapper(); virtual uint32_t getSources() const override; virtual uint32_t getSources() const override; Loading @@ -36,6 +38,8 @@ private: uint32_t mSwitchValues; uint32_t mSwitchValues; uint32_t mUpdatedSwitchMask; uint32_t mUpdatedSwitchMask; explicit SwitchInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig); void processSwitch(int32_t switchCode, int32_t switchValue); void processSwitch(int32_t switchCode, int32_t switchValue); [[nodiscard]] std::list<NotifyArgs> sync(nsecs_t when); [[nodiscard]] std::list<NotifyArgs> sync(nsecs_t when); }; }; Loading services/inputflinger/tests/InputReader_test.cpp +3 −3 Original line number Original line Diff line number Diff line Loading @@ -2603,13 +2603,13 @@ protected: }; }; TEST_F(SwitchInputMapperTest, GetSources) { TEST_F(SwitchInputMapperTest, GetSources) { SwitchInputMapper& mapper = addMapperAndConfigure<SwitchInputMapper>(); SwitchInputMapper& mapper = constructAndAddMapper<SwitchInputMapper>(); ASSERT_EQ(uint32_t(AINPUT_SOURCE_SWITCH), mapper.getSources()); ASSERT_EQ(uint32_t(AINPUT_SOURCE_SWITCH), mapper.getSources()); } } TEST_F(SwitchInputMapperTest, GetSwitchState) { TEST_F(SwitchInputMapperTest, GetSwitchState) { SwitchInputMapper& mapper = addMapperAndConfigure<SwitchInputMapper>(); SwitchInputMapper& mapper = constructAndAddMapper<SwitchInputMapper>(); mFakeEventHub->setSwitchState(EVENTHUB_ID, SW_LID, 1); mFakeEventHub->setSwitchState(EVENTHUB_ID, SW_LID, 1); ASSERT_EQ(1, mapper.getSwitchState(AINPUT_SOURCE_ANY, SW_LID)); ASSERT_EQ(1, mapper.getSwitchState(AINPUT_SOURCE_ANY, SW_LID)); Loading @@ -2619,7 +2619,7 @@ TEST_F(SwitchInputMapperTest, GetSwitchState) { } } TEST_F(SwitchInputMapperTest, Process) { TEST_F(SwitchInputMapperTest, Process) { SwitchInputMapper& mapper = addMapperAndConfigure<SwitchInputMapper>(); SwitchInputMapper& mapper = constructAndAddMapper<SwitchInputMapper>(); std::list<NotifyArgs> out; std::list<NotifyArgs> out; out = process(mapper, ARBITRARY_TIME, READ_TIME, EV_SW, SW_LID, 1); out = process(mapper, ARBITRARY_TIME, READ_TIME, EV_SW, SW_LID, 1); ASSERT_TRUE(out.empty()); ASSERT_TRUE(out.empty()); Loading Loading
services/inputflinger/reader/InputDevice.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -446,7 +446,7 @@ std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers( // Switch-like devices. // Switch-like devices. if (classes.test(InputDeviceClass::SWITCH)) { 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. // Scroll wheel-like devices. Loading
services/inputflinger/reader/mapper/SwitchInputMapper.h +6 −2 Original line number Original line Diff line number Diff line Loading @@ -22,8 +22,10 @@ namespace android { class SwitchInputMapper : public InputMapper { class SwitchInputMapper : public InputMapper { public: public: explicit SwitchInputMapper(InputDeviceContext& deviceContext, template <class T, class... Args> const InputReaderConfiguration& readerConfig); friend std::unique_ptr<T> createInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig, Args... args); virtual ~SwitchInputMapper(); virtual ~SwitchInputMapper(); virtual uint32_t getSources() const override; virtual uint32_t getSources() const override; Loading @@ -36,6 +38,8 @@ private: uint32_t mSwitchValues; uint32_t mSwitchValues; uint32_t mUpdatedSwitchMask; uint32_t mUpdatedSwitchMask; explicit SwitchInputMapper(InputDeviceContext& deviceContext, const InputReaderConfiguration& readerConfig); void processSwitch(int32_t switchCode, int32_t switchValue); void processSwitch(int32_t switchCode, int32_t switchValue); [[nodiscard]] std::list<NotifyArgs> sync(nsecs_t when); [[nodiscard]] std::list<NotifyArgs> sync(nsecs_t when); }; }; Loading
services/inputflinger/tests/InputReader_test.cpp +3 −3 Original line number Original line Diff line number Diff line Loading @@ -2603,13 +2603,13 @@ protected: }; }; TEST_F(SwitchInputMapperTest, GetSources) { TEST_F(SwitchInputMapperTest, GetSources) { SwitchInputMapper& mapper = addMapperAndConfigure<SwitchInputMapper>(); SwitchInputMapper& mapper = constructAndAddMapper<SwitchInputMapper>(); ASSERT_EQ(uint32_t(AINPUT_SOURCE_SWITCH), mapper.getSources()); ASSERT_EQ(uint32_t(AINPUT_SOURCE_SWITCH), mapper.getSources()); } } TEST_F(SwitchInputMapperTest, GetSwitchState) { TEST_F(SwitchInputMapperTest, GetSwitchState) { SwitchInputMapper& mapper = addMapperAndConfigure<SwitchInputMapper>(); SwitchInputMapper& mapper = constructAndAddMapper<SwitchInputMapper>(); mFakeEventHub->setSwitchState(EVENTHUB_ID, SW_LID, 1); mFakeEventHub->setSwitchState(EVENTHUB_ID, SW_LID, 1); ASSERT_EQ(1, mapper.getSwitchState(AINPUT_SOURCE_ANY, SW_LID)); ASSERT_EQ(1, mapper.getSwitchState(AINPUT_SOURCE_ANY, SW_LID)); Loading @@ -2619,7 +2619,7 @@ TEST_F(SwitchInputMapperTest, GetSwitchState) { } } TEST_F(SwitchInputMapperTest, Process) { TEST_F(SwitchInputMapperTest, Process) { SwitchInputMapper& mapper = addMapperAndConfigure<SwitchInputMapper>(); SwitchInputMapper& mapper = constructAndAddMapper<SwitchInputMapper>(); std::list<NotifyArgs> out; std::list<NotifyArgs> out; out = process(mapper, ARBITRARY_TIME, READ_TIME, EV_SW, SW_LID, 1); out = process(mapper, ARBITRARY_TIME, READ_TIME, EV_SW, SW_LID, 1); ASSERT_TRUE(out.empty()); ASSERT_TRUE(out.empty()); Loading