Loading services/inputflinger/reader/InputDevice.cpp +26 −15 Original line number Diff line number Diff line Loading @@ -43,12 +43,14 @@ InputDevice::InputDevice(InputReaderContext* context, int32_t id, int32_t genera mSources(0), mIsExternal(false), mHasMic(false), mDropUntilNextSync(false) {} mDropUntilNextSync(false) { mDeviceContext = std::make_unique<InputDeviceContext>(*this); } InputDevice::~InputDevice() {} bool InputDevice::isEnabled() { return getEventHub()->isDeviceEnabled(mId); return mDeviceContext->isDeviceEnabled(); } void InputDevice::setEnabled(bool enabled, nsecs_t when) { Loading @@ -64,11 +66,11 @@ void InputDevice::setEnabled(bool enabled, nsecs_t when) { } if (enabled) { getEventHub()->enableDevice(mId); mDeviceContext->enableDevice(); reset(when); } else { reset(when); getEventHub()->disableDevice(mId); mDeviceContext->disableDevice(); } // Must change generation to flag this device as changed bumpGeneration(); Loading Loading @@ -119,6 +121,7 @@ void InputDevice::dump(std::string& dump) { void InputDevice::populateMappers() { uint32_t classes = mClasses; std::vector<std::unique_ptr<InputMapper>>& mappers = mMappers; std::unique_ptr<InputDeviceContext>& contextPtr = mDeviceContext; // External devices. if (classes & INPUT_DEVICE_CLASS_EXTERNAL) { Loading @@ -132,17 +135,17 @@ void InputDevice::populateMappers() { // Switch-like devices. if (classes & INPUT_DEVICE_CLASS_SWITCH) { mappers.push_back(std::make_unique<SwitchInputMapper>(this)); mappers.push_back(std::make_unique<SwitchInputMapper>(*contextPtr)); } // Scroll wheel-like devices. if (classes & INPUT_DEVICE_CLASS_ROTARY_ENCODER) { mappers.push_back(std::make_unique<RotaryEncoderInputMapper>(this)); mappers.push_back(std::make_unique<RotaryEncoderInputMapper>(*contextPtr)); } // Vibrator-like devices. if (classes & INPUT_DEVICE_CLASS_VIBRATOR) { mappers.push_back(std::make_unique<VibratorInputMapper>(this)); mappers.push_back(std::make_unique<VibratorInputMapper>(*contextPtr)); } // Keyboard-like devices. Loading @@ -163,29 +166,29 @@ void InputDevice::populateMappers() { if (keyboardSource != 0) { mappers.push_back( std::make_unique<KeyboardInputMapper>(this, keyboardSource, keyboardType)); std::make_unique<KeyboardInputMapper>(*contextPtr, keyboardSource, keyboardType)); } // Cursor-like devices. if (classes & INPUT_DEVICE_CLASS_CURSOR) { mappers.push_back(std::make_unique<CursorInputMapper>(this)); mappers.push_back(std::make_unique<CursorInputMapper>(*contextPtr)); } // Touchscreens and touchpad devices. if (classes & INPUT_DEVICE_CLASS_TOUCH_MT) { mappers.push_back(std::make_unique<MultiTouchInputMapper>(this)); mappers.push_back(std::make_unique<MultiTouchInputMapper>(*contextPtr)); } else if (classes & INPUT_DEVICE_CLASS_TOUCH) { mappers.push_back(std::make_unique<SingleTouchInputMapper>(this)); mappers.push_back(std::make_unique<SingleTouchInputMapper>(*contextPtr)); } // Joystick-like devices. if (classes & INPUT_DEVICE_CLASS_JOYSTICK) { mappers.push_back(std::make_unique<JoystickInputMapper>(this)); mappers.push_back(std::make_unique<JoystickInputMapper>(*contextPtr)); } // External stylus-like devices. if (classes & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) { mappers.push_back(std::make_unique<ExternalStylusInputMapper>(this)); mappers.push_back(std::make_unique<ExternalStylusInputMapper>(*contextPtr)); } } Loading @@ -195,14 +198,14 @@ void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config if (!isIgnored()) { if (!changes) { // first time only mContext->getEventHub()->getConfiguration(mId, &mConfiguration); mDeviceContext->getConfiguration(&mConfiguration); } if (!changes || (changes & InputReaderConfiguration::CHANGE_KEYBOARD_LAYOUTS)) { if (!(mClasses & INPUT_DEVICE_CLASS_VIRTUAL)) { sp<KeyCharacterMap> keyboardLayout = mContext->getPolicy()->getKeyboardLayoutOverlay(mIdentifier); if (mContext->getEventHub()->setKeyboardLayoutOverlay(mId, keyboardLayout)) { if (mDeviceContext->setKeyboardLayoutOverlay(keyboardLayout)) { bumpGeneration(); } } Loading Loading @@ -421,4 +424,12 @@ std::optional<int32_t> InputDevice::getAssociatedDisplayId() { [](InputMapper& mapper) { return mapper.getAssociatedDisplayId(); }); } InputDeviceContext::InputDeviceContext(InputDevice& device) : mDevice(device), mContext(device.getContext()), mEventHub(device.getContext()->getEventHub()), mId(device.getId()) {} InputDeviceContext::~InputDeviceContext() {} } // namespace android services/inputflinger/reader/InputReader.cpp +6 −8 Original line number Diff line number Diff line Loading @@ -348,13 +348,11 @@ void InputReader::disableVirtualKeysUntilLocked(nsecs_t time) { mDisableVirtualKeysTimeout = time; } bool InputReader::shouldDropVirtualKeyLocked(nsecs_t now, InputDevice* device, int32_t keyCode, int32_t scanCode) { bool InputReader::shouldDropVirtualKeyLocked(nsecs_t now, int32_t keyCode, int32_t scanCode) { if (now < mDisableVirtualKeysTimeout) { ALOGI("Dropping virtual key from device %s because virtual keys are " ALOGI("Dropping virtual key from device because virtual keys are " "temporarily disabled for the next %0.3fms. keyCode=%d, scanCode=%d", device->getName().c_str(), (mDisableVirtualKeysTimeout - now) * 0.000001, keyCode, scanCode); (mDisableVirtualKeysTimeout - now) * 0.000001, keyCode, scanCode); return true; } else { return false; Loading Loading @@ -662,10 +660,10 @@ void InputReader::ContextImpl::disableVirtualKeysUntil(nsecs_t time) { mReader->disableVirtualKeysUntilLocked(time); } bool InputReader::ContextImpl::shouldDropVirtualKey(nsecs_t now, InputDevice* device, int32_t keyCode, int32_t scanCode) { bool InputReader::ContextImpl::shouldDropVirtualKey(nsecs_t now, int32_t keyCode, int32_t scanCode) { // lock is already held by the input loop return mReader->shouldDropVirtualKeyLocked(now, device, keyCode, scanCode); return mReader->shouldDropVirtualKeyLocked(now, keyCode, scanCode); } void InputReader::ContextImpl::fadePointer() { Loading services/inputflinger/reader/include/InputDevice.h +112 −19 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ namespace android { class InputDeviceContext; class InputMapper; /* Represents the state of a single input device. */ Loading Loading @@ -96,30 +97,12 @@ public: inline const PropertyMap& getConfiguration() { return mConfiguration; } inline EventHubInterface* getEventHub() { return mContext->getEventHub(); } bool hasKey(int32_t code) { return getEventHub()->hasScanCode(mId, code); } bool hasAbsoluteAxis(int32_t code) { RawAbsoluteAxisInfo info; getEventHub()->getAbsoluteAxisInfo(mId, code, &info); return info.valid; } bool isKeyPressed(int32_t code) { return getEventHub()->getScanCodeState(mId, code) == AKEY_STATE_DOWN; } int32_t getAbsoluteAxisValue(int32_t code) { int32_t value; getEventHub()->getAbsoluteAxisValue(mId, code, &value); return value; } std::optional<int32_t> getAssociatedDisplayId(); // construct and add a mapper to the input device template <class T, typename... Args> T& addMapper(Args... args) { T* mapper = new T(this, args...); T* mapper = new T(*mDeviceContext, args...); mMappers.emplace_back(mapper); return *mapper; } Loading @@ -133,6 +116,7 @@ private: std::string mAlias; uint32_t mClasses; std::unique_ptr<InputDeviceContext> mDeviceContext; std::vector<std::unique_ptr<InputMapper>> mMappers; uint32_t mSources; Loading Loading @@ -168,6 +152,115 @@ private: } }; /* Provides access to EventHub methods, but limits access to the current InputDevice. * Essentially an implementation of EventHubInterface, but for a specific device id. * Helps hide implementation details of InputDevice and EventHub. Used by mappers to * check the status of the associated hardware device */ class InputDeviceContext { public: InputDeviceContext(InputDevice& device); ~InputDeviceContext(); inline InputReaderContext* getContext() { return mContext; } inline int32_t getId() { return mId; } inline uint32_t getDeviceClasses() const { return mEventHub->getDeviceClasses(mId); } inline InputDeviceIdentifier getDeviceIdentifier() const { return mEventHub->getDeviceIdentifier(mId); } inline int32_t getDeviceControllerNumber() const { return mEventHub->getDeviceControllerNumber(mId); } inline void getConfiguration(PropertyMap* outConfiguration) const { return mEventHub->getConfiguration(mId, outConfiguration); } inline status_t getAbsoluteAxisInfo(int32_t code, RawAbsoluteAxisInfo* axisInfo) const { return mEventHub->getAbsoluteAxisInfo(mId, code, axisInfo); } inline bool hasRelativeAxis(int32_t code) const { return mEventHub->hasRelativeAxis(mId, code); } inline bool hasInputProperty(int property) const { return mEventHub->hasInputProperty(mId, property); } inline status_t mapKey(int32_t scanCode, int32_t usageCode, int32_t metaState, int32_t* outKeycode, int32_t* outMetaState, uint32_t* outFlags) const { return mEventHub->mapKey(mId, scanCode, usageCode, metaState, outKeycode, outMetaState, outFlags); } inline status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const { return mEventHub->mapAxis(mId, scanCode, outAxisInfo); } inline std::vector<TouchVideoFrame> getVideoFrames() { return mEventHub->getVideoFrames(mId); } inline int32_t getScanCodeState(int32_t scanCode) const { return mEventHub->getScanCodeState(mId, scanCode); } inline int32_t getKeyCodeState(int32_t keyCode) const { return mEventHub->getKeyCodeState(mId, keyCode); } inline int32_t getSwitchState(int32_t sw) const { return mEventHub->getSwitchState(mId, sw); } inline status_t getAbsoluteAxisValue(int32_t code, int32_t* outValue) const { return mEventHub->getAbsoluteAxisValue(mId, code, outValue); } inline bool markSupportedKeyCodes(size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) const { return mEventHub->markSupportedKeyCodes(mId, numCodes, keyCodes, outFlags); } inline bool hasScanCode(int32_t scanCode) const { return mEventHub->hasScanCode(mId, scanCode); } inline bool hasLed(int32_t led) const { return mEventHub->hasLed(mId, led); } inline void setLedState(int32_t led, bool on) { return mEventHub->setLedState(mId, led, on); } inline void getVirtualKeyDefinitions(std::vector<VirtualKeyDefinition>& outVirtualKeys) const { return mEventHub->getVirtualKeyDefinitions(mId, outVirtualKeys); } inline sp<KeyCharacterMap> getKeyCharacterMap() const { return mEventHub->getKeyCharacterMap(mId); } inline bool setKeyboardLayoutOverlay(const sp<KeyCharacterMap>& map) { return mEventHub->setKeyboardLayoutOverlay(mId, map); } inline void vibrate(nsecs_t duration) { return mEventHub->vibrate(mId, duration); } inline void cancelVibrate() { return mEventHub->cancelVibrate(mId); } inline bool hasAbsoluteAxis(int32_t code) const { RawAbsoluteAxisInfo info; mEventHub->getAbsoluteAxisInfo(mId, code, &info); return info.valid; } inline bool isKeyPressed(int32_t code) const { return mEventHub->getScanCodeState(mId, code) == AKEY_STATE_DOWN; } inline int32_t getAbsoluteAxisValue(int32_t code) const { int32_t value; mEventHub->getAbsoluteAxisValue(mId, code, &value); return value; } inline bool isDeviceEnabled() { return mEventHub->isDeviceEnabled(mId); } inline status_t enableDevice() { return mEventHub->enableDevice(mId); } inline status_t disableDevice() { return mEventHub->disableDevice(mId); } inline const std::string getName() { return mDevice.getName(); } inline const std::string getDescriptor() { return mDevice.getDescriptor(); } inline bool isExternal() { return mDevice.isExternal(); } inline std::optional<uint8_t> getAssociatedDisplayPort() const { return mDevice.getAssociatedDisplayPort(); } inline std::optional<DisplayViewport> getAssociatedViewport() const { return mDevice.getAssociatedViewport(); } inline void cancelTouch(nsecs_t when) { mDevice.cancelTouch(when); } inline void bumpGeneration() { mDevice.bumpGeneration(); } inline const PropertyMap& getConfiguration() { return mDevice.getConfiguration(); } private: InputDevice& mDevice; InputReaderContext* mContext; EventHubInterface* mEventHub; int32_t mId; }; } // namespace android #endif //_UI_INPUTREADER_INPUT_DEVICE_H services/inputflinger/reader/include/InputReader.h +2 −4 Original line number Diff line number Diff line Loading @@ -101,8 +101,7 @@ protected: virtual void updateGlobalMetaState() override; virtual int32_t getGlobalMetaState() override; virtual void disableVirtualKeysUntil(nsecs_t time) override; virtual bool shouldDropVirtualKey(nsecs_t now, InputDevice* device, int32_t keyCode, int32_t scanCode) override; virtual bool shouldDropVirtualKey(nsecs_t now, int32_t keyCode, int32_t scanCode) override; virtual void fadePointer() override; virtual void requestTimeoutAtTime(nsecs_t when) override; virtual int32_t bumpGeneration() override; Loading Loading @@ -168,8 +167,7 @@ private: nsecs_t mDisableVirtualKeysTimeout; void disableVirtualKeysUntilLocked(nsecs_t time); bool shouldDropVirtualKeyLocked(nsecs_t now, InputDevice* device, int32_t keyCode, int32_t scanCode); bool shouldDropVirtualKeyLocked(nsecs_t now, int32_t keyCode, int32_t scanCode); nsecs_t mNextTimeout; void requestTimeoutAtTimeLocked(nsecs_t when); Loading services/inputflinger/reader/include/InputReaderContext.h +1 −2 Original line number Diff line number Diff line Loading @@ -42,8 +42,7 @@ public: virtual int32_t getGlobalMetaState() = 0; virtual void disableVirtualKeysUntil(nsecs_t time) = 0; virtual bool shouldDropVirtualKey(nsecs_t now, InputDevice* device, int32_t keyCode, int32_t scanCode) = 0; virtual bool shouldDropVirtualKey(nsecs_t now, int32_t keyCode, int32_t scanCode) = 0; virtual void fadePointer() = 0; Loading Loading
services/inputflinger/reader/InputDevice.cpp +26 −15 Original line number Diff line number Diff line Loading @@ -43,12 +43,14 @@ InputDevice::InputDevice(InputReaderContext* context, int32_t id, int32_t genera mSources(0), mIsExternal(false), mHasMic(false), mDropUntilNextSync(false) {} mDropUntilNextSync(false) { mDeviceContext = std::make_unique<InputDeviceContext>(*this); } InputDevice::~InputDevice() {} bool InputDevice::isEnabled() { return getEventHub()->isDeviceEnabled(mId); return mDeviceContext->isDeviceEnabled(); } void InputDevice::setEnabled(bool enabled, nsecs_t when) { Loading @@ -64,11 +66,11 @@ void InputDevice::setEnabled(bool enabled, nsecs_t when) { } if (enabled) { getEventHub()->enableDevice(mId); mDeviceContext->enableDevice(); reset(when); } else { reset(when); getEventHub()->disableDevice(mId); mDeviceContext->disableDevice(); } // Must change generation to flag this device as changed bumpGeneration(); Loading Loading @@ -119,6 +121,7 @@ void InputDevice::dump(std::string& dump) { void InputDevice::populateMappers() { uint32_t classes = mClasses; std::vector<std::unique_ptr<InputMapper>>& mappers = mMappers; std::unique_ptr<InputDeviceContext>& contextPtr = mDeviceContext; // External devices. if (classes & INPUT_DEVICE_CLASS_EXTERNAL) { Loading @@ -132,17 +135,17 @@ void InputDevice::populateMappers() { // Switch-like devices. if (classes & INPUT_DEVICE_CLASS_SWITCH) { mappers.push_back(std::make_unique<SwitchInputMapper>(this)); mappers.push_back(std::make_unique<SwitchInputMapper>(*contextPtr)); } // Scroll wheel-like devices. if (classes & INPUT_DEVICE_CLASS_ROTARY_ENCODER) { mappers.push_back(std::make_unique<RotaryEncoderInputMapper>(this)); mappers.push_back(std::make_unique<RotaryEncoderInputMapper>(*contextPtr)); } // Vibrator-like devices. if (classes & INPUT_DEVICE_CLASS_VIBRATOR) { mappers.push_back(std::make_unique<VibratorInputMapper>(this)); mappers.push_back(std::make_unique<VibratorInputMapper>(*contextPtr)); } // Keyboard-like devices. Loading @@ -163,29 +166,29 @@ void InputDevice::populateMappers() { if (keyboardSource != 0) { mappers.push_back( std::make_unique<KeyboardInputMapper>(this, keyboardSource, keyboardType)); std::make_unique<KeyboardInputMapper>(*contextPtr, keyboardSource, keyboardType)); } // Cursor-like devices. if (classes & INPUT_DEVICE_CLASS_CURSOR) { mappers.push_back(std::make_unique<CursorInputMapper>(this)); mappers.push_back(std::make_unique<CursorInputMapper>(*contextPtr)); } // Touchscreens and touchpad devices. if (classes & INPUT_DEVICE_CLASS_TOUCH_MT) { mappers.push_back(std::make_unique<MultiTouchInputMapper>(this)); mappers.push_back(std::make_unique<MultiTouchInputMapper>(*contextPtr)); } else if (classes & INPUT_DEVICE_CLASS_TOUCH) { mappers.push_back(std::make_unique<SingleTouchInputMapper>(this)); mappers.push_back(std::make_unique<SingleTouchInputMapper>(*contextPtr)); } // Joystick-like devices. if (classes & INPUT_DEVICE_CLASS_JOYSTICK) { mappers.push_back(std::make_unique<JoystickInputMapper>(this)); mappers.push_back(std::make_unique<JoystickInputMapper>(*contextPtr)); } // External stylus-like devices. if (classes & INPUT_DEVICE_CLASS_EXTERNAL_STYLUS) { mappers.push_back(std::make_unique<ExternalStylusInputMapper>(this)); mappers.push_back(std::make_unique<ExternalStylusInputMapper>(*contextPtr)); } } Loading @@ -195,14 +198,14 @@ void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config if (!isIgnored()) { if (!changes) { // first time only mContext->getEventHub()->getConfiguration(mId, &mConfiguration); mDeviceContext->getConfiguration(&mConfiguration); } if (!changes || (changes & InputReaderConfiguration::CHANGE_KEYBOARD_LAYOUTS)) { if (!(mClasses & INPUT_DEVICE_CLASS_VIRTUAL)) { sp<KeyCharacterMap> keyboardLayout = mContext->getPolicy()->getKeyboardLayoutOverlay(mIdentifier); if (mContext->getEventHub()->setKeyboardLayoutOverlay(mId, keyboardLayout)) { if (mDeviceContext->setKeyboardLayoutOverlay(keyboardLayout)) { bumpGeneration(); } } Loading Loading @@ -421,4 +424,12 @@ std::optional<int32_t> InputDevice::getAssociatedDisplayId() { [](InputMapper& mapper) { return mapper.getAssociatedDisplayId(); }); } InputDeviceContext::InputDeviceContext(InputDevice& device) : mDevice(device), mContext(device.getContext()), mEventHub(device.getContext()->getEventHub()), mId(device.getId()) {} InputDeviceContext::~InputDeviceContext() {} } // namespace android
services/inputflinger/reader/InputReader.cpp +6 −8 Original line number Diff line number Diff line Loading @@ -348,13 +348,11 @@ void InputReader::disableVirtualKeysUntilLocked(nsecs_t time) { mDisableVirtualKeysTimeout = time; } bool InputReader::shouldDropVirtualKeyLocked(nsecs_t now, InputDevice* device, int32_t keyCode, int32_t scanCode) { bool InputReader::shouldDropVirtualKeyLocked(nsecs_t now, int32_t keyCode, int32_t scanCode) { if (now < mDisableVirtualKeysTimeout) { ALOGI("Dropping virtual key from device %s because virtual keys are " ALOGI("Dropping virtual key from device because virtual keys are " "temporarily disabled for the next %0.3fms. keyCode=%d, scanCode=%d", device->getName().c_str(), (mDisableVirtualKeysTimeout - now) * 0.000001, keyCode, scanCode); (mDisableVirtualKeysTimeout - now) * 0.000001, keyCode, scanCode); return true; } else { return false; Loading Loading @@ -662,10 +660,10 @@ void InputReader::ContextImpl::disableVirtualKeysUntil(nsecs_t time) { mReader->disableVirtualKeysUntilLocked(time); } bool InputReader::ContextImpl::shouldDropVirtualKey(nsecs_t now, InputDevice* device, int32_t keyCode, int32_t scanCode) { bool InputReader::ContextImpl::shouldDropVirtualKey(nsecs_t now, int32_t keyCode, int32_t scanCode) { // lock is already held by the input loop return mReader->shouldDropVirtualKeyLocked(now, device, keyCode, scanCode); return mReader->shouldDropVirtualKeyLocked(now, keyCode, scanCode); } void InputReader::ContextImpl::fadePointer() { Loading
services/inputflinger/reader/include/InputDevice.h +112 −19 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ namespace android { class InputDeviceContext; class InputMapper; /* Represents the state of a single input device. */ Loading Loading @@ -96,30 +97,12 @@ public: inline const PropertyMap& getConfiguration() { return mConfiguration; } inline EventHubInterface* getEventHub() { return mContext->getEventHub(); } bool hasKey(int32_t code) { return getEventHub()->hasScanCode(mId, code); } bool hasAbsoluteAxis(int32_t code) { RawAbsoluteAxisInfo info; getEventHub()->getAbsoluteAxisInfo(mId, code, &info); return info.valid; } bool isKeyPressed(int32_t code) { return getEventHub()->getScanCodeState(mId, code) == AKEY_STATE_DOWN; } int32_t getAbsoluteAxisValue(int32_t code) { int32_t value; getEventHub()->getAbsoluteAxisValue(mId, code, &value); return value; } std::optional<int32_t> getAssociatedDisplayId(); // construct and add a mapper to the input device template <class T, typename... Args> T& addMapper(Args... args) { T* mapper = new T(this, args...); T* mapper = new T(*mDeviceContext, args...); mMappers.emplace_back(mapper); return *mapper; } Loading @@ -133,6 +116,7 @@ private: std::string mAlias; uint32_t mClasses; std::unique_ptr<InputDeviceContext> mDeviceContext; std::vector<std::unique_ptr<InputMapper>> mMappers; uint32_t mSources; Loading Loading @@ -168,6 +152,115 @@ private: } }; /* Provides access to EventHub methods, but limits access to the current InputDevice. * Essentially an implementation of EventHubInterface, but for a specific device id. * Helps hide implementation details of InputDevice and EventHub. Used by mappers to * check the status of the associated hardware device */ class InputDeviceContext { public: InputDeviceContext(InputDevice& device); ~InputDeviceContext(); inline InputReaderContext* getContext() { return mContext; } inline int32_t getId() { return mId; } inline uint32_t getDeviceClasses() const { return mEventHub->getDeviceClasses(mId); } inline InputDeviceIdentifier getDeviceIdentifier() const { return mEventHub->getDeviceIdentifier(mId); } inline int32_t getDeviceControllerNumber() const { return mEventHub->getDeviceControllerNumber(mId); } inline void getConfiguration(PropertyMap* outConfiguration) const { return mEventHub->getConfiguration(mId, outConfiguration); } inline status_t getAbsoluteAxisInfo(int32_t code, RawAbsoluteAxisInfo* axisInfo) const { return mEventHub->getAbsoluteAxisInfo(mId, code, axisInfo); } inline bool hasRelativeAxis(int32_t code) const { return mEventHub->hasRelativeAxis(mId, code); } inline bool hasInputProperty(int property) const { return mEventHub->hasInputProperty(mId, property); } inline status_t mapKey(int32_t scanCode, int32_t usageCode, int32_t metaState, int32_t* outKeycode, int32_t* outMetaState, uint32_t* outFlags) const { return mEventHub->mapKey(mId, scanCode, usageCode, metaState, outKeycode, outMetaState, outFlags); } inline status_t mapAxis(int32_t scanCode, AxisInfo* outAxisInfo) const { return mEventHub->mapAxis(mId, scanCode, outAxisInfo); } inline std::vector<TouchVideoFrame> getVideoFrames() { return mEventHub->getVideoFrames(mId); } inline int32_t getScanCodeState(int32_t scanCode) const { return mEventHub->getScanCodeState(mId, scanCode); } inline int32_t getKeyCodeState(int32_t keyCode) const { return mEventHub->getKeyCodeState(mId, keyCode); } inline int32_t getSwitchState(int32_t sw) const { return mEventHub->getSwitchState(mId, sw); } inline status_t getAbsoluteAxisValue(int32_t code, int32_t* outValue) const { return mEventHub->getAbsoluteAxisValue(mId, code, outValue); } inline bool markSupportedKeyCodes(size_t numCodes, const int32_t* keyCodes, uint8_t* outFlags) const { return mEventHub->markSupportedKeyCodes(mId, numCodes, keyCodes, outFlags); } inline bool hasScanCode(int32_t scanCode) const { return mEventHub->hasScanCode(mId, scanCode); } inline bool hasLed(int32_t led) const { return mEventHub->hasLed(mId, led); } inline void setLedState(int32_t led, bool on) { return mEventHub->setLedState(mId, led, on); } inline void getVirtualKeyDefinitions(std::vector<VirtualKeyDefinition>& outVirtualKeys) const { return mEventHub->getVirtualKeyDefinitions(mId, outVirtualKeys); } inline sp<KeyCharacterMap> getKeyCharacterMap() const { return mEventHub->getKeyCharacterMap(mId); } inline bool setKeyboardLayoutOverlay(const sp<KeyCharacterMap>& map) { return mEventHub->setKeyboardLayoutOverlay(mId, map); } inline void vibrate(nsecs_t duration) { return mEventHub->vibrate(mId, duration); } inline void cancelVibrate() { return mEventHub->cancelVibrate(mId); } inline bool hasAbsoluteAxis(int32_t code) const { RawAbsoluteAxisInfo info; mEventHub->getAbsoluteAxisInfo(mId, code, &info); return info.valid; } inline bool isKeyPressed(int32_t code) const { return mEventHub->getScanCodeState(mId, code) == AKEY_STATE_DOWN; } inline int32_t getAbsoluteAxisValue(int32_t code) const { int32_t value; mEventHub->getAbsoluteAxisValue(mId, code, &value); return value; } inline bool isDeviceEnabled() { return mEventHub->isDeviceEnabled(mId); } inline status_t enableDevice() { return mEventHub->enableDevice(mId); } inline status_t disableDevice() { return mEventHub->disableDevice(mId); } inline const std::string getName() { return mDevice.getName(); } inline const std::string getDescriptor() { return mDevice.getDescriptor(); } inline bool isExternal() { return mDevice.isExternal(); } inline std::optional<uint8_t> getAssociatedDisplayPort() const { return mDevice.getAssociatedDisplayPort(); } inline std::optional<DisplayViewport> getAssociatedViewport() const { return mDevice.getAssociatedViewport(); } inline void cancelTouch(nsecs_t when) { mDevice.cancelTouch(when); } inline void bumpGeneration() { mDevice.bumpGeneration(); } inline const PropertyMap& getConfiguration() { return mDevice.getConfiguration(); } private: InputDevice& mDevice; InputReaderContext* mContext; EventHubInterface* mEventHub; int32_t mId; }; } // namespace android #endif //_UI_INPUTREADER_INPUT_DEVICE_H
services/inputflinger/reader/include/InputReader.h +2 −4 Original line number Diff line number Diff line Loading @@ -101,8 +101,7 @@ protected: virtual void updateGlobalMetaState() override; virtual int32_t getGlobalMetaState() override; virtual void disableVirtualKeysUntil(nsecs_t time) override; virtual bool shouldDropVirtualKey(nsecs_t now, InputDevice* device, int32_t keyCode, int32_t scanCode) override; virtual bool shouldDropVirtualKey(nsecs_t now, int32_t keyCode, int32_t scanCode) override; virtual void fadePointer() override; virtual void requestTimeoutAtTime(nsecs_t when) override; virtual int32_t bumpGeneration() override; Loading Loading @@ -168,8 +167,7 @@ private: nsecs_t mDisableVirtualKeysTimeout; void disableVirtualKeysUntilLocked(nsecs_t time); bool shouldDropVirtualKeyLocked(nsecs_t now, InputDevice* device, int32_t keyCode, int32_t scanCode); bool shouldDropVirtualKeyLocked(nsecs_t now, int32_t keyCode, int32_t scanCode); nsecs_t mNextTimeout; void requestTimeoutAtTimeLocked(nsecs_t when); Loading
services/inputflinger/reader/include/InputReaderContext.h +1 −2 Original line number Diff line number Diff line Loading @@ -42,8 +42,7 @@ public: virtual int32_t getGlobalMetaState() = 0; virtual void disableVirtualKeysUntil(nsecs_t time) = 0; virtual bool shouldDropVirtualKey(nsecs_t now, InputDevice* device, int32_t keyCode, int32_t scanCode) = 0; virtual bool shouldDropVirtualKey(nsecs_t now, int32_t keyCode, int32_t scanCode) = 0; virtual void fadePointer() = 0; Loading