• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 #pragma once
18 
19 #include <ftl/flags.h>
20 #include <input/DisplayViewport.h>
21 #include <input/InputDevice.h>
22 #include <input/PropertyMap.h>
23 
24 #include <cstdint>
25 #include <optional>
26 #include <unordered_map>
27 #include <vector>
28 
29 #include "EventHub.h"
30 #include "InputReaderBase.h"
31 #include "InputReaderContext.h"
32 #include "NotifyArgs.h"
33 
34 namespace android {
35 
36 class PeripheralController;
37 class PeripheralControllerInterface;
38 class InputDeviceContext;
39 class InputMapper;
40 
41 /* Represents the state of a single input device. */
42 class InputDevice {
43 public:
44     InputDevice(InputReaderContext* context, int32_t id, int32_t generation,
45                 const InputDeviceIdentifier& identifier);
46     virtual ~InputDevice();
47 
getContext()48     inline InputReaderContext* getContext() { return mContext; }
getId()49     inline int32_t getId() const { return mId; }
getControllerNumber()50     inline int32_t getControllerNumber() const { return mControllerNumber; }
getGeneration()51     inline virtual int32_t getGeneration() const { return mGeneration; }
getName()52     inline const std::string getName() const { return mIdentifier.name; }
getDescriptor()53     inline const std::string getDescriptor() { return mIdentifier.descriptor; }
getBluetoothAddress()54     inline std::optional<std::string> getBluetoothAddress() const {
55         return mIdentifier.bluetoothAddress;
56     }
getLocation()57     inline const std::string getLocation() const { return mIdentifier.location; }
getClasses()58     inline ftl::Flags<InputDeviceClass> getClasses() const { return mClasses; }
getSources()59     inline virtual uint32_t getSources() const { return mSources; }
hasEventHubDevices()60     inline bool hasEventHubDevices() const { return !mDevices.empty(); }
61 
isExternal()62     inline virtual bool isExternal() { return mIsExternal; }
getAssociatedDisplayPort()63     inline std::optional<uint8_t> getAssociatedDisplayPort() const {
64         return mAssociatedDisplayPort;
65     }
getAssociatedDisplayUniqueIdByPort()66     inline std::optional<std::string> getAssociatedDisplayUniqueIdByPort() const {
67         return mAssociatedDisplayUniqueIdByPort;
68     }
getAssociatedDisplayUniqueIdByDescriptor()69     inline std::optional<std::string> getAssociatedDisplayUniqueIdByDescriptor() const {
70         return mAssociatedDisplayUniqueIdByDescriptor;
71     }
getDeviceTypeAssociation()72     inline std::optional<std::string> getDeviceTypeAssociation() const {
73         return mAssociatedDeviceType;
74     }
getAssociatedViewport()75     inline virtual std::optional<DisplayViewport> getAssociatedViewport() const {
76         return mAssociatedViewport;
77     }
hasMic()78     inline bool hasMic() const { return mHasMic; }
79 
isIgnored()80     inline bool isIgnored() { return !getMapperCount() && !mController; }
81 
getKeyboardType()82     inline virtual KeyboardType getKeyboardType() const { return mKeyboardType; }
83 
getSysfsRootPath()84     inline std::filesystem::path getSysfsRootPath() const { return mSysfsRootPath; }
85 
86     bool isEnabled();
87 
88     void dump(std::string& dump, const std::string& eventHubDevStr);
89     void addEmptyEventHubDevice(int32_t eventHubId);
90     [[nodiscard]] std::list<NotifyArgs> addEventHubDevice(
91             nsecs_t when, int32_t eventHubId, const InputReaderConfiguration& readerConfig);
92     void removeEventHubDevice(int32_t eventHubId);
93     [[nodiscard]] std::list<NotifyArgs> configure(nsecs_t when,
94                                                   const InputReaderConfiguration& readerConfig,
95                                                   ConfigurationChanges changes);
96     [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when);
97     [[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvents, size_t count);
98     [[nodiscard]] std::list<NotifyArgs> timeoutExpired(nsecs_t when);
99     [[nodiscard]] std::list<NotifyArgs> updateExternalStylusState(const StylusState& state);
100 
101     InputDeviceInfo getDeviceInfo();
102     int32_t getKeyCodeState(uint32_t sourceMask, int32_t keyCode);
103     int32_t getScanCodeState(uint32_t sourceMask, int32_t scanCode);
104     int32_t getSwitchState(uint32_t sourceMask, int32_t switchCode);
105     int32_t getKeyCodeForKeyLocation(int32_t locationKeyCode) const;
106     bool markSupportedKeyCodes(uint32_t sourceMask, const std::vector<int32_t>& keyCodes,
107                                uint8_t* outFlags);
108     [[nodiscard]] std::list<NotifyArgs> vibrate(const VibrationSequence& sequence, ssize_t repeat,
109                                                 int32_t token);
110     [[nodiscard]] std::list<NotifyArgs> cancelVibrate(int32_t token);
111     bool isVibrating();
112     std::vector<int32_t> getVibratorIds();
113     [[nodiscard]] std::list<NotifyArgs> cancelTouch(nsecs_t when, nsecs_t readTime);
114     bool enableSensor(InputDeviceSensorType sensorType, std::chrono::microseconds samplingPeriod,
115                       std::chrono::microseconds maxBatchReportLatency);
116     void disableSensor(InputDeviceSensorType sensorType);
117     void flushSensor(InputDeviceSensorType sensorType);
118 
119     std::optional<int32_t> getBatteryEventHubId() const;
120 
121     bool setLightColor(int32_t lightId, int32_t color);
122     bool setLightPlayerId(int32_t lightId, int32_t playerId);
123     std::optional<int32_t> getLightColor(int32_t lightId);
124     std::optional<int32_t> getLightPlayerId(int32_t lightId);
125 
126     int32_t getMetaState();
127     void setKeyboardType(KeyboardType keyboardType);
128 
129     virtual void bumpGeneration();
130 
131     [[nodiscard]] NotifyDeviceResetArgs notifyReset(nsecs_t when);
132 
getConfiguration()133     inline virtual const PropertyMap& getConfiguration() const { return mConfiguration; }
getEventHub()134     inline EventHubInterface* getEventHub() { return mContext->getEventHub(); }
135 
136     std::optional<ui::LogicalDisplayId> getAssociatedDisplayId();
137 
138     void updateLedState(bool reset);
139 
140     size_t getMapperCount();
141 
142     std::optional<HardwareProperties> getTouchpadHardwareProperties();
143 
144     bool setKernelWakeEnabled(bool enabled);
145 
146     // construct and add a mapper to the input device
147     template <class T, typename... Args>
addMapper(int32_t eventHubId,Args...args)148     T& addMapper(int32_t eventHubId, Args... args) {
149         // ensure a device entry exists for this eventHubId
150         addEmptyEventHubDevice(eventHubId);
151 
152         // create mapper
153         auto& devicePair = mDevices[eventHubId];
154         auto& deviceContext = devicePair.first;
155         auto& mappers = devicePair.second;
156         T* mapper = new T(*deviceContext, args...);
157         mappers.emplace_back(mapper);
158         return *mapper;
159     }
160 
161     template <class T, typename... Args>
constructAndAddMapper(int32_t eventHubId,Args...args)162     T& constructAndAddMapper(int32_t eventHubId, Args... args) {
163         // create mapper
164         auto& devicePair = mDevices[eventHubId];
165         auto& deviceContext = devicePair.first;
166         auto& mappers = devicePair.second;
167         mappers.push_back(createInputMapper<T>(*deviceContext, args...));
168         return static_cast<T&>(*mappers.back());
169     }
170 
171     // construct and add a controller to the input device
172     template <class T>
addController(int32_t eventHubId)173     T& addController(int32_t eventHubId) {
174         // ensure a device entry exists for this eventHubId
175         addEmptyEventHubDevice(eventHubId);
176 
177         // create controller
178         auto& devicePair = mDevices[eventHubId];
179         auto& deviceContext = devicePair.first;
180 
181         mController = std::make_unique<T>(*deviceContext);
182         return *(reinterpret_cast<T*>(mController.get()));
183     }
184 
185 private:
186     InputReaderContext* mContext;
187     int32_t mId;
188     int32_t mGeneration;
189     int32_t mControllerNumber;
190     InputDeviceIdentifier mIdentifier;
191     std::string mAlias;
192     ftl::Flags<InputDeviceClass> mClasses;
193 
194     // map from eventHubId to device context and mappers
195     using MapperVector = std::vector<std::unique_ptr<InputMapper>>;
196     using DevicePair = std::pair<std::unique_ptr<InputDeviceContext>, MapperVector>;
197     // Map from EventHub ID to pair of device context and vector of mapper.
198     std::unordered_map<int32_t, DevicePair> mDevices;
199     // Misc devices controller for lights, battery, etc.
200     std::unique_ptr<PeripheralControllerInterface> mController;
201 
202     uint32_t mSources;
203     bool mIsWaking;
204     bool mIsExternal;
205     KeyboardType mKeyboardType = KeyboardType::NONE;
206     std::optional<uint8_t> mAssociatedDisplayPort;
207     std::optional<std::string> mAssociatedDisplayUniqueIdByPort;
208     std::optional<std::string> mAssociatedDisplayUniqueIdByDescriptor;
209     std::optional<std::string> mAssociatedDeviceType;
210     std::optional<DisplayViewport> mAssociatedViewport;
211     bool mHasMic;
212     bool mDropUntilNextSync;
213     std::optional<bool> mShouldSmoothScroll;
214     std::filesystem::path mSysfsRootPath;
215 
216     typedef int32_t (InputMapper::*GetStateFunc)(uint32_t sourceMask, int32_t code);
217     int32_t getState(uint32_t sourceMask, int32_t code, GetStateFunc getStateFunc);
218 
219     std::vector<std::unique_ptr<InputMapper>> createMappers(
220             InputDeviceContext& contextPtr, const InputReaderConfiguration& readerConfig);
221 
222     [[nodiscard]] std::list<NotifyArgs> configureInternal(
223             nsecs_t when, const InputReaderConfiguration& readerConfig,
224             ConfigurationChanges changes, bool forceEnable = false);
225 
226     [[nodiscard]] std::list<NotifyArgs> updateEnableState(
227             nsecs_t when, const InputReaderConfiguration& readerConfig, bool forceEnable = false);
228 
229     PropertyMap mConfiguration;
230 
231     // Runs logic post a `process` call. This can be used to update the generated `NotifyArgs` as
232     // per the properties of the InputDevice.
233     void postProcess(std::list<NotifyArgs>& args) const;
234 
235     // helpers to interate over the devices collection
236     // run a function against every mapper on every subdevice
for_each_mapper(std::function<void (InputMapper &)> f)237     inline void for_each_mapper(std::function<void(InputMapper&)> f) {
238         for (auto& deviceEntry : mDevices) {
239             auto& devicePair = deviceEntry.second;
240             auto& mappers = devicePair.second;
241             for (auto& mapperPtr : mappers) {
242                 f(*mapperPtr);
243             }
244         }
245     }
246 
247     // run a function against every mapper on a specific subdevice
for_each_mapper_in_subdevice(int32_t eventHubDevice,std::function<void (InputMapper &)> f)248     inline void for_each_mapper_in_subdevice(int32_t eventHubDevice,
249                                              std::function<void(InputMapper&)> f) {
250         auto deviceIt = mDevices.find(eventHubDevice);
251         if (deviceIt != mDevices.end()) {
252             auto& devicePair = deviceIt->second;
253             auto& mappers = devicePair.second;
254             for (auto& mapperPtr : mappers) {
255                 f(*mapperPtr);
256             }
257         }
258     }
259 
260     // run a function against every subdevice
for_each_subdevice(std::function<void (InputDeviceContext &)> f)261     inline void for_each_subdevice(std::function<void(InputDeviceContext&)> f) {
262         for (auto& deviceEntry : mDevices) {
263             auto& devicePair = deviceEntry.second;
264             auto& contextPtr = devicePair.first;
265             f(*contextPtr);
266         }
267     }
268 
269     // return the first value returned by a function over every mapper.
270     // if all mappers return nullopt, return nullopt.
271     template <typename T>
first_in_mappers(std::function<std::optional<T> (InputMapper &)> f)272     inline std::optional<T> first_in_mappers(
273             std::function<std::optional<T>(InputMapper&)> f) const {
274         for (auto& deviceEntry : mDevices) {
275             auto& devicePair = deviceEntry.second;
276             auto& mappers = devicePair.second;
277             for (auto& mapperPtr : mappers) {
278                 std::optional<T> ret = f(*mapperPtr);
279                 if (ret) {
280                     return ret;
281                 }
282             }
283         }
284         return std::nullopt;
285     }
286 };
287 
288 /* Provides access to EventHub methods, but limits access to the current InputDevice.
289  * Essentially an implementation of EventHubInterface, but for a specific device id.
290  * Helps hide implementation details of InputDevice and EventHub. Used by mappers to
291  * check the status of the associated hardware device
292  */
293 class InputDeviceContext {
294 public:
295     InputDeviceContext(InputDevice& device, int32_t eventHubId);
296     virtual ~InputDeviceContext();
297 
getContext()298     inline InputReaderContext* getContext() { return mContext; }
getId()299     inline int32_t getId() { return mDeviceId; }
getEventHubId()300     inline int32_t getEventHubId() { return mId; }
301 
getDeviceClasses()302     inline ftl::Flags<InputDeviceClass> getDeviceClasses() const {
303         return mEventHub->getDeviceClasses(mId);
304     }
getDeviceSources()305     inline uint32_t getDeviceSources() const { return mDevice.getSources(); }
getDeviceIdentifier()306     inline InputDeviceIdentifier getDeviceIdentifier() const {
307         return mEventHub->getDeviceIdentifier(mId);
308     }
getDeviceControllerNumber()309     inline int32_t getDeviceControllerNumber() const {
310         return mEventHub->getDeviceControllerNumber(mId);
311     }
getAbsoluteAxisInfo(int32_t code)312     inline std::optional<RawAbsoluteAxisInfo> getAbsoluteAxisInfo(int32_t code) const {
313         std::optional<RawAbsoluteAxisInfo> info = mEventHub->getAbsoluteAxisInfo(mId, code);
314 
315         // Validate axis info for InputDevice.
316         if (info && info->minValue == info->maxValue) {
317             // Historically, we deem axes with the same min and max values as invalid to avoid
318             // dividing by zero when scaling by max - min.
319             // TODO(b/291772515): Perform axis info validation on a per-axis basis when it is used.
320             return std::nullopt;
321         }
322         return info;
323     }
hasRelativeAxis(int32_t code)324     inline bool hasRelativeAxis(int32_t code) const {
325         return mEventHub->hasRelativeAxis(mId, code);
326     }
hasInputProperty(int32_t property)327     inline bool hasInputProperty(int32_t property) const {
328         return mEventHub->hasInputProperty(mId, property);
329     }
330 
hasMscEvent(int mscEvent)331     inline bool hasMscEvent(int mscEvent) const { return mEventHub->hasMscEvent(mId, mscEvent); }
332 
setKeyRemapping(const std::map<int32_t,int32_t> & keyRemapping)333     inline void setKeyRemapping(const std::map<int32_t, int32_t>& keyRemapping) const {
334         mEventHub->setKeyRemapping(mId, keyRemapping);
335     }
336 
mapKey(int32_t scanCode,int32_t usageCode,int32_t metaState,int32_t * outKeycode,int32_t * outMetaState,uint32_t * outFlags)337     inline status_t mapKey(int32_t scanCode, int32_t usageCode, int32_t metaState,
338                            int32_t* outKeycode, int32_t* outMetaState, uint32_t* outFlags) const {
339         return mEventHub->mapKey(mId, scanCode, usageCode, metaState, outKeycode, outMetaState,
340                                  outFlags);
341     }
mapAxis(int32_t scanCode,AxisInfo * outAxisInfo)342     inline status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const {
343         return mEventHub->mapAxis(mId, scanCode, outAxisInfo);
344     }
mapSensor(int32_t absCode)345     inline base::Result<std::pair<InputDeviceSensorType, int32_t>> mapSensor(int32_t absCode) {
346         return mEventHub->mapSensor(mId, absCode);
347     }
348 
getRawLightIds()349     inline const std::vector<int32_t> getRawLightIds() { return mEventHub->getRawLightIds(mId); }
350 
getRawLightInfo(int32_t lightId)351     inline std::optional<RawLightInfo> getRawLightInfo(int32_t lightId) {
352         return mEventHub->getRawLightInfo(mId, lightId);
353     }
354 
getLightBrightness(int32_t lightId)355     inline std::optional<int32_t> getLightBrightness(int32_t lightId) {
356         return mEventHub->getLightBrightness(mId, lightId);
357     }
358 
setLightBrightness(int32_t lightId,int32_t brightness)359     inline void setLightBrightness(int32_t lightId, int32_t brightness) {
360         return mEventHub->setLightBrightness(mId, lightId, brightness);
361     }
362 
getLightIntensities(int32_t lightId)363     inline std::optional<std::unordered_map<LightColor, int32_t>> getLightIntensities(
364             int32_t lightId) {
365         return mEventHub->getLightIntensities(mId, lightId);
366     }
367 
setLightIntensities(int32_t lightId,std::unordered_map<LightColor,int32_t> intensities)368     inline void setLightIntensities(int32_t lightId,
369                                     std::unordered_map<LightColor, int32_t> intensities) {
370         return mEventHub->setLightIntensities(mId, lightId, intensities);
371     }
372 
getVideoFrames()373     inline std::vector<TouchVideoFrame> getVideoFrames() { return mEventHub->getVideoFrames(mId); }
getScanCodeState(int32_t scanCode)374     inline int32_t getScanCodeState(int32_t scanCode) const {
375         return mEventHub->getScanCodeState(mId, scanCode);
376     }
getKeyCodeState(int32_t keyCode)377     inline int32_t getKeyCodeState(int32_t keyCode) const {
378         return mEventHub->getKeyCodeState(mId, keyCode);
379     }
getKeyCodeForKeyLocation(int32_t locationKeyCode)380     inline int32_t getKeyCodeForKeyLocation(int32_t locationKeyCode) const {
381         return mEventHub->getKeyCodeForKeyLocation(mId, locationKeyCode);
382     }
getSwitchState(int32_t sw)383     inline int32_t getSwitchState(int32_t sw) const { return mEventHub->getSwitchState(mId, sw); }
getAbsoluteAxisValue(int32_t code)384     inline std::optional<int32_t> getAbsoluteAxisValue(int32_t code) const {
385         return mEventHub->getAbsoluteAxisValue(mId, code);
386     }
getMtSlotValues(int32_t axis,size_t slotCount)387     inline base::Result<std::vector<int32_t>> getMtSlotValues(int32_t axis,
388                                                               size_t slotCount) const {
389         return mEventHub->getMtSlotValues(mId, axis, slotCount);
390     }
markSupportedKeyCodes(const std::vector<int32_t> & keyCodes,uint8_t * outFlags)391     inline bool markSupportedKeyCodes(const std::vector<int32_t>& keyCodes,
392                                       uint8_t* outFlags) const {
393         return mEventHub->markSupportedKeyCodes(mId, keyCodes, outFlags);
394     }
hasScanCode(int32_t scanCode)395     inline bool hasScanCode(int32_t scanCode) const {
396         return mEventHub->hasScanCode(mId, scanCode);
397     }
hasKeyCode(int32_t keyCode)398     inline bool hasKeyCode(int32_t keyCode) const { return mEventHub->hasKeyCode(mId, keyCode); }
hasLed(int32_t led)399     inline bool hasLed(int32_t led) const { return mEventHub->hasLed(mId, led); }
setLedState(int32_t led,bool on)400     inline void setLedState(int32_t led, bool on) { return mEventHub->setLedState(mId, led, on); }
getVirtualKeyDefinitions(std::vector<VirtualKeyDefinition> & outVirtualKeys)401     inline void getVirtualKeyDefinitions(std::vector<VirtualKeyDefinition>& outVirtualKeys) const {
402         return mEventHub->getVirtualKeyDefinitions(mId, outVirtualKeys);
403     }
getKeyCharacterMap()404     inline const std::shared_ptr<KeyCharacterMap> getKeyCharacterMap() const {
405         return mEventHub->getKeyCharacterMap(mId);
406     }
setKeyboardLayoutOverlay(std::shared_ptr<KeyCharacterMap> map)407     inline bool setKeyboardLayoutOverlay(std::shared_ptr<KeyCharacterMap> map) {
408         return mEventHub->setKeyboardLayoutOverlay(mId, map);
409     }
getRawLayoutInfo()410     inline const std::optional<RawLayoutInfo> getRawLayoutInfo() {
411         return mEventHub->getRawLayoutInfo(mId);
412     }
vibrate(const VibrationElement & element)413     inline void vibrate(const VibrationElement& element) {
414         return mEventHub->vibrate(mId, element);
415     }
cancelVibrate()416     inline void cancelVibrate() { return mEventHub->cancelVibrate(mId); }
417 
getVibratorIds()418     inline std::vector<int32_t> getVibratorIds() { return mEventHub->getVibratorIds(mId); }
419 
getRawBatteryIds()420     inline const std::vector<int32_t> getRawBatteryIds() {
421         return mEventHub->getRawBatteryIds(mId);
422     }
423 
getRawBatteryInfo(int32_t batteryId)424     inline std::optional<RawBatteryInfo> getRawBatteryInfo(int32_t batteryId) {
425         return mEventHub->getRawBatteryInfo(mId, batteryId);
426     }
427 
getBatteryCapacity(int32_t batteryId)428     inline std::optional<int32_t> getBatteryCapacity(int32_t batteryId) {
429         return mEventHub->getBatteryCapacity(mId, batteryId);
430     }
431 
getBatteryStatus(int32_t batteryId)432     inline std::optional<int32_t> getBatteryStatus(int32_t batteryId) {
433         return mEventHub->getBatteryStatus(mId, batteryId);
434     }
435 
hasAbsoluteAxis(int32_t code)436     inline bool hasAbsoluteAxis(int32_t code) const {
437         return mEventHub->getAbsoluteAxisInfo(mId, code).has_value();
438     }
isKeyPressed(int32_t scanCode)439     inline bool isKeyPressed(int32_t scanCode) const {
440         return mEventHub->getScanCodeState(mId, scanCode) == AKEY_STATE_DOWN;
441     }
isKeyCodePressed(int32_t keyCode)442     inline bool isKeyCodePressed(int32_t keyCode) const {
443         return mEventHub->getKeyCodeState(mId, keyCode) == AKEY_STATE_DOWN;
444     }
isDeviceEnabled()445     inline bool isDeviceEnabled() { return mEventHub->isDeviceEnabled(mId); }
enableDevice()446     inline status_t enableDevice() { return mEventHub->enableDevice(mId); }
disableDevice()447     inline status_t disableDevice() { return mEventHub->disableDevice(mId); }
448 
getName()449     inline const std::string getName() const { return mDevice.getName(); }
getDescriptor()450     inline const std::string getDescriptor() { return mDevice.getDescriptor(); }
getLocation()451     inline const std::string getLocation() { return mDevice.getLocation(); }
isExternal()452     inline bool isExternal() const { return mDevice.isExternal(); }
getAssociatedDisplayPort()453     inline std::optional<uint8_t> getAssociatedDisplayPort() const {
454         return mDevice.getAssociatedDisplayPort();
455     }
getAssociatedDisplayUniqueIdByPort()456     inline std::optional<std::string> getAssociatedDisplayUniqueIdByPort() const {
457         return mDevice.getAssociatedDisplayUniqueIdByPort();
458     }
getAssociatedDisplayUniqueIdByDescriptor()459     inline std::optional<std::string> getAssociatedDisplayUniqueIdByDescriptor() const {
460         return mDevice.getAssociatedDisplayUniqueIdByDescriptor();
461     }
getDeviceTypeAssociation()462     inline std::optional<std::string> getDeviceTypeAssociation() const {
463         return mDevice.getDeviceTypeAssociation();
464     }
getAssociatedViewport()465     virtual std::optional<DisplayViewport> getAssociatedViewport() const {
466         return mDevice.getAssociatedViewport();
467     }
cancelTouch(nsecs_t when,nsecs_t readTime)468     [[nodiscard]] inline std::list<NotifyArgs> cancelTouch(nsecs_t when, nsecs_t readTime) {
469         return mDevice.cancelTouch(when, readTime);
470     }
bumpGeneration()471     inline void bumpGeneration() { mDevice.bumpGeneration(); }
getConfiguration()472     inline const PropertyMap& getConfiguration() const { return mDevice.getConfiguration(); }
getKeyboardType()473     inline KeyboardType getKeyboardType() const { return mDevice.getKeyboardType(); }
setKeyboardType(KeyboardType keyboardType)474     inline void setKeyboardType(KeyboardType keyboardType) {
475         return mDevice.setKeyboardType(keyboardType);
476     }
getSysfsRootPath()477     inline std::filesystem::path getSysfsRootPath() const {
478         return mEventHub->getSysfsRootPath(mId);
479     }
setKernelWakeEnabled(bool enabled)480     inline bool setKernelWakeEnabled(bool enabled) {
481         return mEventHub->setKernelWakeEnabled(mId, enabled);
482     }
483 
484 private:
485     InputDevice& mDevice;
486     InputReaderContext* mContext;
487     EventHubInterface* mEventHub;
488     int32_t mId;
489     int32_t mDeviceId;
490 };
491 
492 } // namespace android
493