summaryrefslogtreecommitdiff
path: root/modules/input/evdev/EvdevModule.cpp
diff options
context:
space:
mode:
authorTim Kilbourn <tkilbourn@google.com>2015-05-04 17:26:30 -0700
committerTim Kilbourn <tkilbourn@google.com>2015-06-09 11:16:04 -0700
commit4f3145d75f5dfc87f07f8ddf6143ba77966f35e4 (patch)
tree11169268d5ca497a874df298b5ecb85d5605cf0d /modules/input/evdev/EvdevModule.cpp
parent61809ac218b9598fc2a540e235f6d4787604938f (diff)
Initial InputMappers for evdev input HAL.
The previous design of the InputHost wrapper classes made it very painful to do testing, so this change also reverts to a more classical C++ pattern for non-copyable objects. The InputHost classes still simply call through to the input_host_t and callbacks as before. Updated unittests to use gmock for mocking the InputHost interactions. Change-Id: I4b70df2c89ed48af77446b8f5b87a4bde94510bf
Diffstat (limited to 'modules/input/evdev/EvdevModule.cpp')
-rw-r--r--modules/input/evdev/EvdevModule.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/modules/input/evdev/EvdevModule.cpp b/modules/input/evdev/EvdevModule.cpp
index 1171a1a2..93ccd354 100644
--- a/modules/input/evdev/EvdevModule.cpp
+++ b/modules/input/evdev/EvdevModule.cpp
@@ -37,7 +37,8 @@ static const char kDevInput[] = "/dev/input";
class EvdevModule {
public:
- explicit EvdevModule(InputHost inputHost);
+ // Takes ownership of the InputHostInterface
+ explicit EvdevModule(InputHostInterface* inputHost);
void init();
void notifyReport(input_report_t* r);
@@ -45,7 +46,7 @@ public:
private:
void loop();
- InputHost mInputHost;
+ std::unique_ptr<InputHostInterface> mInputHost;
std::shared_ptr<InputDeviceManager> mDeviceManager;
std::unique_ptr<InputHub> mInputHub;
std::thread mPollThread;
@@ -53,9 +54,9 @@ private:
static std::unique_ptr<EvdevModule> gEvdevModule;
-EvdevModule::EvdevModule(InputHost inputHost) :
+EvdevModule::EvdevModule(InputHostInterface* inputHost) :
mInputHost(inputHost),
- mDeviceManager(std::make_shared<InputDeviceManager>(mInputHost)),
+ mDeviceManager(std::make_shared<InputDeviceManager>(mInputHost.get())),
mInputHub(std::make_unique<InputHub>(mDeviceManager)) {}
void EvdevModule::init() {
@@ -97,7 +98,7 @@ static int dummy_open(const hw_module_t __unused *module, const char __unused *i
static void input_init(const input_module_t* module,
input_host_t* host, input_host_callbacks_t cb) {
LOG_ALWAYS_FATAL_IF(strcmp(module->common.id, INPUT_HARDWARE_MODULE_ID) != 0);
- InputHost inputHost = {host, cb};
+ auto inputHost = new InputHost(host, cb);
gEvdevModule = std::make_unique<EvdevModule>(inputHost);
gEvdevModule->init();
}