InputMapper refactor: Modify InputMapper constructor for configuration
We are refactoring Input-mapper(s) to ensure they are configured at the
time of initialisation.
In this CL we are changing InputMapper's constructor to accept the
reader configuration to facilitate initialisation.
Test: build, inputflinger_tests, presubmit checks
Bug: 256009910
Change-Id: I710b892f51268a001d076f387163ac3274f5b0d1
diff --git a/services/inputflinger/reader/include/InputDevice.h b/services/inputflinger/reader/include/InputDevice.h
index ad45cb1..2091e16 100644
--- a/services/inputflinger/reader/include/InputDevice.h
+++ b/services/inputflinger/reader/include/InputDevice.h
@@ -80,7 +80,8 @@
[[nodiscard]] std::list<NotifyArgs> setEnabled(bool enabled, nsecs_t when);
void dump(std::string& dump, const std::string& eventHubDevStr);
- void addEventHubDevice(int32_t eventHubId, bool populateMappers = true);
+ void addEmptyEventHubDevice(int32_t eventHubId);
+ void addEventHubDevice(int32_t eventHubId, const InputReaderConfiguration& readerConfig);
void removeEventHubDevice(int32_t eventHubId);
[[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
const InputReaderConfiguration& readerConfig,
@@ -137,7 +138,7 @@
template <class T, typename... Args>
T& addMapper(int32_t eventHubId, Args... args) {
// ensure a device entry exists for this eventHubId
- addEventHubDevice(eventHubId, false);
+ addEmptyEventHubDevice(eventHubId);
// create mapper
auto& devicePair = mDevices[eventHubId];
@@ -152,7 +153,7 @@
template <class T>
T& addController(int32_t eventHubId) {
// ensure a device entry exists for this eventHubId
- addEventHubDevice(eventHubId, false);
+ addEmptyEventHubDevice(eventHubId);
// create controller
auto& devicePair = mDevices[eventHubId];
@@ -191,6 +192,9 @@
typedef int32_t (InputMapper::*GetStateFunc)(uint32_t sourceMask, int32_t code);
int32_t getState(uint32_t sourceMask, int32_t code, GetStateFunc getStateFunc);
+ std::vector<std::unique_ptr<InputMapper>> createMappers(
+ InputDeviceContext& contextPtr, const InputReaderConfiguration& readerConfig);
+
PropertyMap mConfiguration;
// helpers to interate over the devices collection