blob: 2aaddf59bb948244124461bb8f619cfbe56929d9 [file] [log] [blame]
Prabir Pradhanbaa5c822019-08-30 15:27:05 -07001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "Macros.h"
18
19#include "InputDevice.h"
20
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080021#include <algorithm>
22
Harry Cutts89844622022-12-02 15:02:26 +000023#include <android/sysprop/InputProperties.sysprop.h>
Dominik Laskowski2f01d772022-03-23 16:01:29 -070024#include <ftl/flags.h>
25
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -080026#include "CursorInputMapper.h"
27#include "ExternalStylusInputMapper.h"
28#include "InputReaderContext.h"
29#include "JoystickInputMapper.h"
30#include "KeyboardInputMapper.h"
31#include "MultiTouchInputMapper.h"
Chris Ye1dd2e5c2021-04-04 23:12:41 -070032#include "PeripheralController.h"
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -080033#include "RotaryEncoderInputMapper.h"
Chris Yef59a2f42020-10-16 12:55:26 -070034#include "SensorInputMapper.h"
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -080035#include "SingleTouchInputMapper.h"
36#include "SwitchInputMapper.h"
Harry Cutts79cc9fa2022-10-28 15:32:39 +000037#include "TouchpadInputMapper.h"
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -080038#include "VibratorInputMapper.h"
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070039
40namespace android {
41
42InputDevice::InputDevice(InputReaderContext* context, int32_t id, int32_t generation,
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080043 const InputDeviceIdentifier& identifier)
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070044 : mContext(context),
45 mId(id),
46 mGeneration(generation),
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080047 mControllerNumber(0),
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070048 mIdentifier(identifier),
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080049 mClasses(0),
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070050 mSources(0),
Yeabkal Wubshite03e8b12023-06-27 16:23:12 -070051 mIsWaking(false),
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070052 mIsExternal(false),
53 mHasMic(false),
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080054 mDropUntilNextSync(false) {}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070055
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -080056InputDevice::~InputDevice() {}
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070057
58bool InputDevice::isEnabled() {
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080059 if (!hasEventHubDevices()) {
60 return false;
61 }
Chris Yee14523a2020-12-19 13:46:00 -080062 // An input device composed of sub devices can be individually enabled or disabled.
63 // If any of the sub device is enabled then the input device is considered as enabled.
64 bool enabled = false;
65 for_each_subdevice([&enabled](auto& context) { enabled |= context.isDeviceEnabled(); });
66 return enabled;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070067}
68
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070069std::list<NotifyArgs> InputDevice::setEnabled(bool enabled, nsecs_t when) {
70 std::list<NotifyArgs> out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070071 if (enabled && mAssociatedDisplayPort && !mAssociatedViewport) {
72 ALOGW("Cannot enable input device %s because it is associated with port %" PRIu8 ", "
73 "but the corresponding viewport is not found",
74 getName().c_str(), *mAssociatedDisplayPort);
75 enabled = false;
76 }
77
78 if (isEnabled() == enabled) {
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070079 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070080 }
81
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080082 // When resetting some devices, the driver needs to be queried to ensure that a proper reset is
83 // performed. The querying must happen when the device is enabled, so we reset after enabling
84 // but before disabling the device. See MultiTouchMotionAccumulator::reset for more information.
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070085 if (enabled) {
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080086 for_each_subdevice([](auto& context) { context.enableDevice(); });
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070087 out += reset(when);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070088 } else {
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070089 out += reset(when);
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -080090 for_each_subdevice([](auto& context) { context.disableDevice(); });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070091 }
92 // Must change generation to flag this device as changed
93 bumpGeneration();
Siarhei Vishniakou2935db72022-09-22 13:35:22 -070094 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070095}
96
Chris Yee7310032020-09-22 15:36:28 -070097void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) {
Siarhei Vishniakou1983a712021-06-04 19:27:09 +000098 InputDeviceInfo deviceInfo = getDeviceInfo();
Prabir Pradhanbaa5c822019-08-30 15:27:05 -070099
100 dump += StringPrintf(INDENT "Device %d: %s\n", deviceInfo.getId(),
101 deviceInfo.getDisplayName().c_str());
Chris Yee7310032020-09-22 15:36:28 -0700102 dump += StringPrintf(INDENT "%s", eventHubDevStr.c_str());
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700103 dump += StringPrintf(INDENT2 "Generation: %d\n", mGeneration);
104 dump += StringPrintf(INDENT2 "IsExternal: %s\n", toString(mIsExternal));
Yeabkal Wubshite03e8b12023-06-27 16:23:12 -0700105 dump += StringPrintf(INDENT2 "IsWaking: %s\n", toString(mIsWaking));
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700106 dump += StringPrintf(INDENT2 "AssociatedDisplayPort: ");
107 if (mAssociatedDisplayPort) {
108 dump += StringPrintf("%" PRIu8 "\n", *mAssociatedDisplayPort);
109 } else {
110 dump += "<none>\n";
111 }
Christine Franks1ba71cc2021-04-07 14:37:42 -0700112 dump += StringPrintf(INDENT2 "AssociatedDisplayUniqueId: ");
113 if (mAssociatedDisplayUniqueId) {
114 dump += StringPrintf("%s\n", mAssociatedDisplayUniqueId->c_str());
115 } else {
116 dump += "<none>\n";
117 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700118 dump += StringPrintf(INDENT2 "HasMic: %s\n", toString(mHasMic));
Siarhei Vishniakou88151b82022-08-11 00:53:38 +0000119 dump += StringPrintf(INDENT2 "Sources: %s\n",
120 inputEventSourceToString(deviceInfo.getSources()).c_str());
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700121 dump += StringPrintf(INDENT2 "KeyboardType: %d\n", deviceInfo.getKeyboardType());
Chris Yee7310032020-09-22 15:36:28 -0700122 dump += StringPrintf(INDENT2 "ControllerNum: %d\n", deviceInfo.getControllerNumber());
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700123
124 const std::vector<InputDeviceInfo::MotionRange>& ranges = deviceInfo.getMotionRanges();
125 if (!ranges.empty()) {
126 dump += INDENT2 "Motion Ranges:\n";
127 for (size_t i = 0; i < ranges.size(); i++) {
128 const InputDeviceInfo::MotionRange& range = ranges[i];
Chris Ye4958d062020-08-20 13:21:10 -0700129 const char* label = InputEventLookup::getAxisLabel(range.axis);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700130 char name[32];
131 if (label) {
132 strncpy(name, label, sizeof(name));
133 name[sizeof(name) - 1] = '\0';
134 } else {
135 snprintf(name, sizeof(name), "%d", range.axis);
136 }
137 dump += StringPrintf(INDENT3
Siarhei Vishniakou88151b82022-08-11 00:53:38 +0000138 "%s: source=%s, "
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700139 "min=%0.3f, max=%0.3f, flat=%0.3f, fuzz=%0.3f, resolution=%0.3f\n",
Siarhei Vishniakou88151b82022-08-11 00:53:38 +0000140 name, inputEventSourceToString(range.source).c_str(), range.min,
141 range.max, range.flat, range.fuzz, range.resolution);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700142 }
143 }
144
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800145 for_each_mapper([&dump](InputMapper& mapper) { mapper.dump(dump); });
Chris Yee2b1e5c2021-03-10 22:45:12 -0800146 if (mController) {
147 mController->dump(dump);
148 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700149}
150
Arpit Singh8e6fb252023-04-06 11:49:17 +0000151void InputDevice::addEmptyEventHubDevice(int32_t eventHubId) {
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800152 if (mDevices.find(eventHubId) != mDevices.end()) {
153 return;
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800154 }
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800155 std::unique_ptr<InputDeviceContext> contextPtr(new InputDeviceContext(*this, eventHubId));
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000156 std::vector<std::unique_ptr<InputMapper>> mappers;
157
158 mDevices.insert({eventHubId, std::make_pair(std::move(contextPtr), std::move(mappers))});
Arpit Singh8e6fb252023-04-06 11:49:17 +0000159}
160
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000161void InputDevice::addEventHubDevice(int32_t eventHubId,
162 const InputReaderConfiguration& readerConfig) {
163 if (mDevices.find(eventHubId) != mDevices.end()) {
164 return;
165 }
166 std::unique_ptr<InputDeviceContext> contextPtr(new InputDeviceContext(*this, eventHubId));
167 std::vector<std::unique_ptr<InputMapper>> mappers = createMappers(*contextPtr, readerConfig);
168
169 // insert the context into the devices set
170 mDevices.insert({eventHubId, std::make_pair(std::move(contextPtr), std::move(mappers))});
Chris Yee7310032020-09-22 15:36:28 -0700171 // Must change generation to flag this device as changed
172 bumpGeneration();
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800173}
174
175void InputDevice::removeEventHubDevice(int32_t eventHubId) {
Siarhei Vishniakou30feb8c2022-09-28 10:48:29 -0700176 if (mController != nullptr && mController->getEventHubId() == eventHubId) {
177 // Delete mController, since the corresponding eventhub device is going away
178 mController = nullptr;
179 }
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800180 mDevices.erase(eventHubId);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700181}
182
Arpit Singhed6c3de2023-04-05 19:24:37 +0000183std::list<NotifyArgs> InputDevice::configure(nsecs_t when,
184 const InputReaderConfiguration& readerConfig,
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000185 ConfigurationChanges changes) {
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700186 std::list<NotifyArgs> out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700187 mSources = 0;
Dominik Laskowski2f01d772022-03-23 16:01:29 -0700188 mClasses = ftl::Flags<InputDeviceClass>(0);
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800189 mControllerNumber = 0;
190
191 for_each_subdevice([this](InputDeviceContext& context) {
192 mClasses |= context.getDeviceClasses();
193 int32_t controllerNumber = context.getDeviceControllerNumber();
194 if (controllerNumber > 0) {
195 if (mControllerNumber && mControllerNumber != controllerNumber) {
196 ALOGW("InputDevice::configure(): composite device contains multiple unique "
197 "controller numbers");
198 }
199 mControllerNumber = controllerNumber;
200 }
201 });
202
Chris Ye1b0c7342020-07-28 21:57:03 -0700203 mIsExternal = mClasses.test(InputDeviceClass::EXTERNAL);
204 mHasMic = mClasses.test(InputDeviceClass::MIC);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700205
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000206 using Change = InputReaderConfiguration::Change;
207
Arpit Singh56adebc2023-04-25 13:56:05 +0000208 if (!changes.any() || !isIgnored()) {
Ambrus Weisz7b6e16b2022-12-16 17:54:57 +0000209 // Full configuration should happen the first time configure is called
210 // and when the device type is changed. Changing a device type can
211 // affect various other parameters so should result in a
212 // reconfiguration.
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000213 if (!changes.any() || changes.test(Change::DEVICE_TYPE)) {
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800214 mConfiguration.clear();
215 for_each_subdevice([this](InputDeviceContext& context) {
Harry Cuttsc34f7582023-03-07 16:23:30 +0000216 std::optional<PropertyMap> configuration =
217 getEventHub()->getConfiguration(context.getEventHubId());
218 if (configuration) {
219 mConfiguration.addAll(&(*configuration));
220 }
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800221 });
Ambrus Weisz7bc23bf2022-10-04 13:13:07 +0000222
223 mAssociatedDeviceType =
Arpit Singhed6c3de2023-04-05 19:24:37 +0000224 getValueByKey(readerConfig.deviceTypeAssociations, mIdentifier.location);
Yeabkal Wubshite03e8b12023-06-27 16:23:12 -0700225 mIsWaking = mConfiguration.getBool("device.wake").value_or(false);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700226 }
227
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000228 if (!changes.any() || changes.test(Change::KEYBOARD_LAYOUTS)) {
Chris Ye1b0c7342020-07-28 21:57:03 -0700229 if (!mClasses.test(InputDeviceClass::VIRTUAL)) {
Chris Ye3a1e4462020-08-12 10:13:15 -0700230 std::shared_ptr<KeyCharacterMap> keyboardLayout =
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700231 mContext->getPolicy()->getKeyboardLayoutOverlay(mIdentifier);
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800232 bool shouldBumpGeneration = false;
233 for_each_subdevice(
234 [&keyboardLayout, &shouldBumpGeneration](InputDeviceContext& context) {
235 if (context.setKeyboardLayoutOverlay(keyboardLayout)) {
236 shouldBumpGeneration = true;
237 }
238 });
239 if (shouldBumpGeneration) {
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700240 bumpGeneration();
241 }
242 }
243 }
244
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000245 if (!changes.any() || changes.test(Change::DEVICE_ALIAS)) {
Chris Ye1b0c7342020-07-28 21:57:03 -0700246 if (!(mClasses.test(InputDeviceClass::VIRTUAL))) {
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700247 std::string alias = mContext->getPolicy()->getDeviceAlias(mIdentifier);
248 if (mAlias != alias) {
249 mAlias = alias;
250 bumpGeneration();
251 }
252 }
253 }
254
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000255 if (changes.test(Change::ENABLED_STATE)) {
Siarhei Vishniakou21e96e62022-10-27 10:23:37 -0700256 // Do not execute this code on the first configure, because 'setEnabled' would call
257 // InputMapper::reset, and you can't reset a mapper before it has been configured.
258 // The mappers are configured for the first time at the bottom of this function.
Arpit Singhed6c3de2023-04-05 19:24:37 +0000259 auto it = readerConfig.disabledDevices.find(mId);
260 bool enabled = it == readerConfig.disabledDevices.end();
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700261 out += setEnabled(enabled, when);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700262 }
263
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000264 if (!changes.any() || changes.test(Change::DISPLAY_INFO)) {
Christine Franks1ba71cc2021-04-07 14:37:42 -0700265 // In most situations, no port or name will be specified.
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700266 mAssociatedDisplayPort = std::nullopt;
Christine Franks1ba71cc2021-04-07 14:37:42 -0700267 mAssociatedDisplayUniqueId = std::nullopt;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700268 mAssociatedViewport = std::nullopt;
269 // Find the display port that corresponds to the current input port.
270 const std::string& inputPort = mIdentifier.location;
271 if (!inputPort.empty()) {
Arpit Singhed6c3de2023-04-05 19:24:37 +0000272 const std::unordered_map<std::string, uint8_t>& ports =
273 readerConfig.portAssociations;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700274 const auto& displayPort = ports.find(inputPort);
275 if (displayPort != ports.end()) {
276 mAssociatedDisplayPort = std::make_optional(displayPort->second);
Christine Franks2a2293c2022-01-18 11:51:16 -0800277 } else {
278 const std::unordered_map<std::string, std::string>& displayUniqueIds =
Arpit Singhed6c3de2023-04-05 19:24:37 +0000279 readerConfig.uniqueIdAssociations;
Christine Franks2a2293c2022-01-18 11:51:16 -0800280 const auto& displayUniqueId = displayUniqueIds.find(inputPort);
281 if (displayUniqueId != displayUniqueIds.end()) {
282 mAssociatedDisplayUniqueId = displayUniqueId->second;
283 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700284 }
285 }
286
287 // If the device was explicitly disabled by the user, it would be present in the
288 // "disabledDevices" list. If it is associated with a specific display, and it was not
289 // explicitly disabled, then enable/disable the device based on whether we can find the
290 // corresponding viewport.
Arpit Singhed6c3de2023-04-05 19:24:37 +0000291 bool enabled =
292 (readerConfig.disabledDevices.find(mId) == readerConfig.disabledDevices.end());
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700293 if (mAssociatedDisplayPort) {
Arpit Singhed6c3de2023-04-05 19:24:37 +0000294 mAssociatedViewport =
295 readerConfig.getDisplayViewportByPort(*mAssociatedDisplayPort);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700296 if (!mAssociatedViewport) {
297 ALOGW("Input device %s should be associated with display on port %" PRIu8 ", "
298 "but the corresponding viewport is not found.",
299 getName().c_str(), *mAssociatedDisplayPort);
300 enabled = false;
301 }
Christine Franks1ba71cc2021-04-07 14:37:42 -0700302 } else if (mAssociatedDisplayUniqueId != std::nullopt) {
303 mAssociatedViewport =
Arpit Singhed6c3de2023-04-05 19:24:37 +0000304 readerConfig.getDisplayViewportByUniqueId(*mAssociatedDisplayUniqueId);
Christine Franks1ba71cc2021-04-07 14:37:42 -0700305 if (!mAssociatedViewport) {
306 ALOGW("Input device %s should be associated with display %s but the "
307 "corresponding viewport cannot be found",
Christine Franks2a2293c2022-01-18 11:51:16 -0800308 getName().c_str(), mAssociatedDisplayUniqueId->c_str());
Christine Franks1ba71cc2021-04-07 14:37:42 -0700309 enabled = false;
310 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700311 }
312
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000313 if (changes.any()) {
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700314 // For first-time configuration, only allow device to be disabled after mappers have
315 // finished configuring. This is because we need to read some of the properties from
316 // the device's open fd.
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700317 out += setEnabled(enabled, when);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700318 }
319 }
320
Arpit Singhed6c3de2023-04-05 19:24:37 +0000321 for_each_mapper([this, when, &readerConfig, changes, &out](InputMapper& mapper) {
322 out += mapper.reconfigure(when, readerConfig, changes);
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800323 mSources |= mapper.getSources();
324 });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700325
326 // If a device is just plugged but it might be disabled, we need to update some info like
327 // axis range of touch from each InputMapper first, then disable it.
Prabir Pradhan4bf6d452023-04-18 21:26:56 +0000328 if (!changes.any()) {
Arpit Singhed6c3de2023-04-05 19:24:37 +0000329 out += setEnabled(readerConfig.disabledDevices.find(mId) ==
330 readerConfig.disabledDevices.end(),
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700331 when);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700332 }
333 }
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700334 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700335}
336
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700337std::list<NotifyArgs> InputDevice::reset(nsecs_t when) {
338 std::list<NotifyArgs> out;
339 for_each_mapper([&](InputMapper& mapper) { out += mapper.reset(when); });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700340
341 mContext->updateGlobalMetaState();
342
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700343 out.push_back(notifyReset(when));
344 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700345}
346
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700347std::list<NotifyArgs> InputDevice::process(const RawEvent* rawEvents, size_t count) {
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700348 // Process all of the events in order for each mapper.
349 // We cannot simply ask each mapper to process them in bulk because mappers may
350 // have side-effects that must be interleaved. For example, joystick movement events and
351 // gamepad button presses are handled by different mappers but they should be dispatched
352 // in the order received.
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700353 std::list<NotifyArgs> out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700354 for (const RawEvent* rawEvent = rawEvents; count != 0; rawEvent++) {
Prabir Pradhan011ca3d2023-02-22 21:31:39 +0000355 if (debugRawEvents()) {
Prabir Pradhan1e63fc22023-02-23 19:03:03 +0000356 const auto [type, code, value] =
357 InputEventLookup::getLinuxEvdevLabel(rawEvent->type, rawEvent->code,
358 rawEvent->value);
359 ALOGD("Input event: eventHubDevice=%d type=%s code=%s value=%s when=%" PRId64,
360 rawEvent->deviceId, type.c_str(), code.c_str(), value.c_str(), rawEvent->when);
Siarhei Vishniakou465e1c02021-12-09 10:47:29 -0800361 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700362
363 if (mDropUntilNextSync) {
364 if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) {
365 mDropUntilNextSync = false;
Prabir Pradhan1e63fc22023-02-23 19:03:03 +0000366 ALOGD_IF(debugRawEvents(), "Recovered from input event buffer overrun.");
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700367 } else {
Prabir Pradhan1e63fc22023-02-23 19:03:03 +0000368 ALOGD_IF(debugRawEvents(),
369 "Dropped input event while waiting for next input sync.");
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700370 }
371 } else if (rawEvent->type == EV_SYN && rawEvent->code == SYN_DROPPED) {
372 ALOGI("Detected input event buffer overrun for device %s.", getName().c_str());
373 mDropUntilNextSync = true;
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700374 out += reset(rawEvent->when);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700375 } else {
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700376 for_each_mapper_in_subdevice(rawEvent->deviceId, [&](InputMapper& mapper) {
377 out += mapper.process(rawEvent);
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800378 });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700379 }
380 --count;
381 }
Yeabkal Wubshite03e8b12023-06-27 16:23:12 -0700382 postProcess(out);
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700383 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700384}
385
Yeabkal Wubshite03e8b12023-06-27 16:23:12 -0700386void InputDevice::postProcess(std::list<NotifyArgs>& args) const {
387 if (mIsWaking) {
388 // Update policy flags to request wake for the `NotifyArgs` that come from waking devices.
389 for (auto& arg : args) {
390 if (const auto notifyMotionArgs = std::get_if<NotifyMotionArgs>(&arg)) {
391 notifyMotionArgs->policyFlags |= POLICY_FLAG_WAKE;
392 } else if (const auto notifySwitchArgs = std::get_if<NotifySwitchArgs>(&arg)) {
393 notifySwitchArgs->policyFlags |= POLICY_FLAG_WAKE;
394 } else if (const auto notifyKeyArgs = std::get_if<NotifyKeyArgs>(&arg)) {
395 notifyKeyArgs->policyFlags |= POLICY_FLAG_WAKE;
396 }
397 }
398 }
399}
400
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700401std::list<NotifyArgs> InputDevice::timeoutExpired(nsecs_t when) {
402 std::list<NotifyArgs> out;
403 for_each_mapper([&](InputMapper& mapper) { out += mapper.timeoutExpired(when); });
404 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700405}
406
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700407std::list<NotifyArgs> InputDevice::updateExternalStylusState(const StylusState& state) {
408 std::list<NotifyArgs> out;
409 for_each_mapper([&](InputMapper& mapper) { out += mapper.updateExternalStylusState(state); });
410 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700411}
412
Siarhei Vishniakou1983a712021-06-04 19:27:09 +0000413InputDeviceInfo InputDevice::getDeviceInfo() {
414 InputDeviceInfo outDeviceInfo;
415 outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal,
Prabir Pradhane04ffaa2022-12-13 23:04:04 +0000416 mHasMic, getAssociatedDisplayId().value_or(ADISPLAY_ID_NONE));
417
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800418 for_each_mapper(
Harry Cuttsd02ea102023-03-17 18:21:30 +0000419 [&outDeviceInfo](InputMapper& mapper) { mapper.populateDeviceInfo(outDeviceInfo); });
Chris Yee2b1e5c2021-03-10 22:45:12 -0800420
421 if (mController) {
Siarhei Vishniakou1983a712021-06-04 19:27:09 +0000422 mController->populateDeviceInfo(&outDeviceInfo);
Chris Yee2b1e5c2021-03-10 22:45:12 -0800423 }
Siarhei Vishniakou1983a712021-06-04 19:27:09 +0000424 return outDeviceInfo;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700425}
426
427int32_t InputDevice::getKeyCodeState(uint32_t sourceMask, int32_t keyCode) {
428 return getState(sourceMask, keyCode, &InputMapper::getKeyCodeState);
429}
430
431int32_t InputDevice::getScanCodeState(uint32_t sourceMask, int32_t scanCode) {
432 return getState(sourceMask, scanCode, &InputMapper::getScanCodeState);
433}
434
435int32_t InputDevice::getSwitchState(uint32_t sourceMask, int32_t switchCode) {
436 return getState(sourceMask, switchCode, &InputMapper::getSwitchState);
437}
438
439int32_t InputDevice::getState(uint32_t sourceMask, int32_t code, GetStateFunc getStateFunc) {
440 int32_t result = AKEY_STATE_UNKNOWN;
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800441 for (auto& deviceEntry : mDevices) {
442 auto& devicePair = deviceEntry.second;
443 auto& mappers = devicePair.second;
444 for (auto& mapperPtr : mappers) {
445 InputMapper& mapper = *mapperPtr;
446 if (sourcesMatchMask(mapper.getSources(), sourceMask)) {
447 // If any mapper reports AKEY_STATE_DOWN or AKEY_STATE_VIRTUAL, return that
448 // value. Otherwise, return AKEY_STATE_UP as long as one mapper reports it.
449 int32_t currentResult = (mapper.*getStateFunc)(sourceMask, code);
450 if (currentResult >= AKEY_STATE_DOWN) {
451 return currentResult;
452 } else if (currentResult == AKEY_STATE_UP) {
453 result = currentResult;
454 }
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700455 }
456 }
457 }
458 return result;
459}
460
Arpit Singh8e6fb252023-04-06 11:49:17 +0000461std::vector<std::unique_ptr<InputMapper>> InputDevice::createMappers(
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000462 InputDeviceContext& contextPtr, const InputReaderConfiguration& readerConfig) {
463 ftl::Flags<InputDeviceClass> classes = contextPtr.getDeviceClasses();
Arpit Singh8e6fb252023-04-06 11:49:17 +0000464 std::vector<std::unique_ptr<InputMapper>> mappers;
465
466 // Switch-like devices.
467 if (classes.test(InputDeviceClass::SWITCH)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000468 mappers.push_back(createInputMapper<SwitchInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000469 }
470
471 // Scroll wheel-like devices.
472 if (classes.test(InputDeviceClass::ROTARY_ENCODER)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000473 mappers.push_back(createInputMapper<RotaryEncoderInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000474 }
475
476 // Vibrator-like devices.
477 if (classes.test(InputDeviceClass::VIBRATOR)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000478 mappers.push_back(createInputMapper<VibratorInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000479 }
480
481 // Battery-like devices or light-containing devices.
482 // PeripheralController will be created with associated EventHub device.
483 if (classes.test(InputDeviceClass::BATTERY) || classes.test(InputDeviceClass::LIGHT)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000484 mController = std::make_unique<PeripheralController>(contextPtr);
Arpit Singh8e6fb252023-04-06 11:49:17 +0000485 }
486
487 // Keyboard-like devices.
488 uint32_t keyboardSource = 0;
489 int32_t keyboardType = AINPUT_KEYBOARD_TYPE_NON_ALPHABETIC;
490 if (classes.test(InputDeviceClass::KEYBOARD)) {
491 keyboardSource |= AINPUT_SOURCE_KEYBOARD;
492 }
493 if (classes.test(InputDeviceClass::ALPHAKEY)) {
494 keyboardType = AINPUT_KEYBOARD_TYPE_ALPHABETIC;
495 }
496 if (classes.test(InputDeviceClass::DPAD)) {
497 keyboardSource |= AINPUT_SOURCE_DPAD;
498 }
499 if (classes.test(InputDeviceClass::GAMEPAD)) {
500 keyboardSource |= AINPUT_SOURCE_GAMEPAD;
501 }
502
503 if (keyboardSource != 0) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000504 mappers.push_back(createInputMapper<KeyboardInputMapper>(contextPtr, readerConfig,
Arpit Singh033e3ec2023-04-26 14:43:16 +0000505 keyboardSource, keyboardType));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000506 }
507
508 // Cursor-like devices.
509 if (classes.test(InputDeviceClass::CURSOR)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000510 mappers.push_back(createInputMapper<CursorInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000511 }
512
513 // Touchscreens and touchpad devices.
514 static const bool ENABLE_TOUCHPAD_GESTURES_LIBRARY =
515 sysprop::InputProperties::enable_touchpad_gestures_library().value_or(true);
516 // TODO(b/272518665): Fix the new touchpad stack for Sony DualShock 4 (5c4, 9cc) touchpads, or
517 // at least load this setting from the IDC file.
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000518 const InputDeviceIdentifier identifier = contextPtr.getDeviceIdentifier();
Arpit Singh8e6fb252023-04-06 11:49:17 +0000519 const bool isSonyDualShock4Touchpad = identifier.vendor == 0x054c &&
520 (identifier.product == 0x05c4 || identifier.product == 0x09cc);
521 if (ENABLE_TOUCHPAD_GESTURES_LIBRARY && classes.test(InputDeviceClass::TOUCHPAD) &&
522 classes.test(InputDeviceClass::TOUCH_MT) && !isSonyDualShock4Touchpad) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000523 mappers.push_back(createInputMapper<TouchpadInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000524 } else if (classes.test(InputDeviceClass::TOUCH_MT)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000525 mappers.push_back(std::make_unique<MultiTouchInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000526 } else if (classes.test(InputDeviceClass::TOUCH)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000527 mappers.push_back(std::make_unique<SingleTouchInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000528 }
529
530 // Joystick-like devices.
531 if (classes.test(InputDeviceClass::JOYSTICK)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000532 mappers.push_back(createInputMapper<JoystickInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000533 }
534
535 // Motion sensor enabled devices.
536 if (classes.test(InputDeviceClass::SENSOR)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000537 mappers.push_back(createInputMapper<SensorInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000538 }
539
540 // External stylus-like devices.
541 if (classes.test(InputDeviceClass::EXTERNAL_STYLUS)) {
Siarhei Vishniakouc96ed752023-05-25 00:12:00 +0000542 mappers.push_back(createInputMapper<ExternalStylusInputMapper>(contextPtr, readerConfig));
Arpit Singh8e6fb252023-04-06 11:49:17 +0000543 }
544 return mappers;
545}
546
Siarhei Vishniakou74007942022-06-13 13:57:47 -0700547bool InputDevice::markSupportedKeyCodes(uint32_t sourceMask, const std::vector<int32_t>& keyCodes,
548 uint8_t* outFlags) {
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700549 bool result = false;
Siarhei Vishniakou74007942022-06-13 13:57:47 -0700550 for_each_mapper([&result, sourceMask, keyCodes, outFlags](InputMapper& mapper) {
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800551 if (sourcesMatchMask(mapper.getSources(), sourceMask)) {
Siarhei Vishniakou74007942022-06-13 13:57:47 -0700552 result |= mapper.markSupportedKeyCodes(sourceMask, keyCodes, outFlags);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700553 }
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800554 });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700555 return result;
556}
557
Philip Junker4af3b3d2021-12-14 10:36:55 +0100558int32_t InputDevice::getKeyCodeForKeyLocation(int32_t locationKeyCode) const {
559 std::optional<int32_t> result = first_in_mappers<int32_t>(
560 [locationKeyCode](const InputMapper& mapper) -> std::optional<int32_t> const {
561 if (sourcesMatchMask(mapper.getSources(), AINPUT_SOURCE_KEYBOARD)) {
562 return std::make_optional(mapper.getKeyCodeForKeyLocation(locationKeyCode));
563 }
564 return std::nullopt;
565 });
566 if (!result) {
567 ALOGE("Failed to get key code for key location: No matching InputMapper with source mask "
568 "KEYBOARD found. The provided input device with id %d has sources %s.",
569 getId(), inputEventSourceToString(getSources()).c_str());
570 return AKEYCODE_UNKNOWN;
571 }
572 return *result;
573}
574
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700575std::list<NotifyArgs> InputDevice::vibrate(const VibrationSequence& sequence, ssize_t repeat,
576 int32_t token) {
577 std::list<NotifyArgs> out;
578 for_each_mapper([&](InputMapper& mapper) { out += mapper.vibrate(sequence, repeat, token); });
579 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700580}
581
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700582std::list<NotifyArgs> InputDevice::cancelVibrate(int32_t token) {
583 std::list<NotifyArgs> out;
584 for_each_mapper([&](InputMapper& mapper) { out += mapper.cancelVibrate(token); });
585 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700586}
587
Chris Ye87143712020-11-10 05:05:58 +0000588bool InputDevice::isVibrating() {
589 bool vibrating = false;
590 for_each_mapper([&vibrating](InputMapper& mapper) { vibrating |= mapper.isVibrating(); });
591 return vibrating;
592}
593
594/* There's no guarantee the IDs provided by the different mappers are unique, so if we have two
595 * different vibration mappers then we could have duplicate IDs.
596 * Alternatively, if we have a merged device that has multiple evdev nodes with FF_* capabilities,
597 * we would definitely have duplicate IDs.
598 */
599std::vector<int32_t> InputDevice::getVibratorIds() {
600 std::vector<int32_t> vibrators;
601 for_each_mapper([&vibrators](InputMapper& mapper) {
602 std::vector<int32_t> devVibs = mapper.getVibratorIds();
603 vibrators.reserve(vibrators.size() + devVibs.size());
604 vibrators.insert(vibrators.end(), devVibs.begin(), devVibs.end());
605 });
606 return vibrators;
607}
608
Chris Yef59a2f42020-10-16 12:55:26 -0700609bool InputDevice::enableSensor(InputDeviceSensorType sensorType,
610 std::chrono::microseconds samplingPeriod,
611 std::chrono::microseconds maxBatchReportLatency) {
612 bool success = true;
613 for_each_mapper(
614 [&success, sensorType, samplingPeriod, maxBatchReportLatency](InputMapper& mapper) {
615 success &= mapper.enableSensor(sensorType, samplingPeriod, maxBatchReportLatency);
616 });
617 return success;
618}
619
620void InputDevice::disableSensor(InputDeviceSensorType sensorType) {
621 for_each_mapper([sensorType](InputMapper& mapper) { mapper.disableSensor(sensorType); });
622}
623
624void InputDevice::flushSensor(InputDeviceSensorType sensorType) {
625 for_each_mapper([sensorType](InputMapper& mapper) { mapper.flushSensor(sensorType); });
626}
627
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700628std::list<NotifyArgs> InputDevice::cancelTouch(nsecs_t when, nsecs_t readTime) {
629 std::list<NotifyArgs> out;
630 for_each_mapper([&](InputMapper& mapper) { out += mapper.cancelTouch(when, readTime); });
631 return out;
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700632}
633
Chris Ye3fdbfef2021-01-06 18:45:18 -0800634bool InputDevice::setLightColor(int32_t lightId, int32_t color) {
Chris Yee2b1e5c2021-03-10 22:45:12 -0800635 return mController ? mController->setLightColor(lightId, color) : false;
Chris Ye3fdbfef2021-01-06 18:45:18 -0800636}
637
638bool InputDevice::setLightPlayerId(int32_t lightId, int32_t playerId) {
Chris Yee2b1e5c2021-03-10 22:45:12 -0800639 return mController ? mController->setLightPlayerId(lightId, playerId) : false;
Chris Ye3fdbfef2021-01-06 18:45:18 -0800640}
641
642std::optional<int32_t> InputDevice::getLightColor(int32_t lightId) {
Chris Yee2b1e5c2021-03-10 22:45:12 -0800643 return mController ? mController->getLightColor(lightId) : std::nullopt;
Chris Ye3fdbfef2021-01-06 18:45:18 -0800644}
645
646std::optional<int32_t> InputDevice::getLightPlayerId(int32_t lightId) {
Chris Yee2b1e5c2021-03-10 22:45:12 -0800647 return mController ? mController->getLightPlayerId(lightId) : std::nullopt;
Chris Ye3fdbfef2021-01-06 18:45:18 -0800648}
649
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700650int32_t InputDevice::getMetaState() {
651 int32_t result = 0;
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800652 for_each_mapper([&result](InputMapper& mapper) { result |= mapper.getMetaState(); });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700653 return result;
654}
655
656void InputDevice::updateMetaState(int32_t keyCode) {
Arthur Hungcb40a002021-08-03 14:31:01 +0000657 first_in_mappers<bool>([keyCode](InputMapper& mapper) {
658 if (sourcesMatchMask(mapper.getSources(), AINPUT_SOURCE_KEYBOARD) &&
659 mapper.updateMetaState(keyCode)) {
660 return std::make_optional(true);
661 }
662 return std::optional<bool>();
663 });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700664}
665
Vaibhav Devmuraricbba14c2022-10-10 16:54:49 +0000666void InputDevice::addKeyRemapping(int32_t fromKeyCode, int32_t toKeyCode) {
667 for_each_subdevice([fromKeyCode, toKeyCode](auto& context) {
668 context.addKeyRemapping(fromKeyCode, toKeyCode);
669 });
670}
671
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700672void InputDevice::bumpGeneration() {
673 mGeneration = mContext->bumpGeneration();
674}
675
Siarhei Vishniakou2935db72022-09-22 13:35:22 -0700676NotifyDeviceResetArgs InputDevice::notifyReset(nsecs_t when) {
677 return NotifyDeviceResetArgs(mContext->getNextId(), when, mId);
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700678}
679
680std::optional<int32_t> InputDevice::getAssociatedDisplayId() {
681 // Check if we had associated to the specific display.
682 if (mAssociatedViewport) {
683 return mAssociatedViewport->displayId;
684 }
685
686 // No associated display port, check if some InputMapper is associated.
Nathaniel R. Lewisf4916ef2020-01-14 11:57:18 -0800687 return first_in_mappers<int32_t>(
688 [](InputMapper& mapper) { return mapper.getAssociatedDisplayId(); });
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700689}
690
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800691// returns the number of mappers associated with the device
692size_t InputDevice::getMapperCount() {
693 size_t count = 0;
694 for (auto& deviceEntry : mDevices) {
695 auto& devicePair = deviceEntry.second;
696 auto& mappers = devicePair.second;
697 count += mappers.size();
698 }
699 return count;
700}
701
arthurhungc903df12020-08-11 15:08:42 +0800702void InputDevice::updateLedState(bool reset) {
703 for_each_mapper([reset](InputMapper& mapper) { mapper.updateLedState(reset); });
704}
705
Andy Chenf9f1a022022-08-29 20:07:10 -0400706std::optional<int32_t> InputDevice::getBatteryEventHubId() const {
707 return mController ? std::make_optional(mController->getEventHubId()) : std::nullopt;
708}
709
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800710InputDeviceContext::InputDeviceContext(InputDevice& device, int32_t eventHubId)
Nathaniel R. Lewis26ec2222020-01-10 16:30:54 -0800711 : mDevice(device),
712 mContext(device.getContext()),
713 mEventHub(device.getContext()->getEventHub()),
Nathaniel R. Lewisa7b82e12020-02-12 15:40:45 -0800714 mId(eventHubId),
715 mDeviceId(device.getId()) {}
Nathaniel R. Lewis26ec2222020-01-10 16:30:54 -0800716
717InputDeviceContext::~InputDeviceContext() {}
718
Prabir Pradhanbaa5c822019-08-30 15:27:05 -0700719} // namespace android