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