Loading include/input/InputDevice.h +4 −1 Original line number Diff line number Diff line Loading @@ -282,7 +282,8 @@ public: void initialize(int32_t id, int32_t generation, int32_t controllerNumber, const InputDeviceIdentifier& identifier, const std::string& alias, bool isExternal, bool hasMic, ui::LogicalDisplayId associatedDisplayId, bool isExternal, bool isVirtualDevice, bool hasMic, ui::LogicalDisplayId associatedDisplayId, InputDeviceViewBehavior viewBehavior = {{}}, bool enabled = true); inline int32_t getId() const { return mId; } Loading @@ -294,6 +295,7 @@ public: return mAlias.empty() ? mIdentifier.name : mAlias; } inline bool isExternal() const { return mIsExternal; } inline bool isVirtualDevice() const { return mIsVirtualDevice; } inline bool hasMic() const { return mHasMic; } inline uint32_t getSources() const { return mSources; } Loading Loading @@ -357,6 +359,7 @@ private: InputDeviceIdentifier mIdentifier; std::string mAlias; bool mIsExternal; bool mIsVirtualDevice; bool mHasMic; std::optional<KeyboardLayoutInfo> mKeyboardLayoutInfo; uint32_t mSources; Loading libs/input/InputDevice.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -178,11 +178,11 @@ std::string InputDeviceIdentifier::getCanonicalName() const { return replacedName; } // --- InputDeviceInfo --- InputDeviceInfo::InputDeviceInfo() { initialize(-1, 0, -1, InputDeviceIdentifier(), "", false, false, ui::LogicalDisplayId::INVALID); initialize(/*id=*/-1, /*generation=*/0, /*controllerNumber=*/-1, InputDeviceIdentifier(), /*alias=*/"", /*isExternal=*/false, /*isVirtualDevice=*/false, /*hasMic=*/false, ui::LogicalDisplayId::INVALID); } InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) Loading @@ -192,6 +192,7 @@ InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) mIdentifier(other.mIdentifier), mAlias(other.mAlias), mIsExternal(other.mIsExternal), mIsVirtualDevice(other.mIsVirtualDevice), mHasMic(other.mHasMic), mKeyboardLayoutInfo(other.mKeyboardLayoutInfo), mSources(other.mSources), Loading @@ -217,6 +218,7 @@ InputDeviceInfo& InputDeviceInfo::operator=(const InputDeviceInfo& other) { mIdentifier = other.mIdentifier; mAlias = other.mAlias; mIsExternal = other.mIsExternal; mIsVirtualDevice = other.mIsVirtualDevice; mHasMic = other.mHasMic; mKeyboardLayoutInfo = other.mKeyboardLayoutInfo; mSources = other.mSources; Loading @@ -242,7 +244,7 @@ InputDeviceInfo::~InputDeviceInfo() { void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t controllerNumber, const InputDeviceIdentifier& identifier, const std::string& alias, bool isExternal, bool hasMic, bool isExternal, bool isVirtualDevice, bool hasMic, ui::LogicalDisplayId associatedDisplayId, InputDeviceViewBehavior viewBehavior, bool enabled) { mId = id; Loading @@ -251,6 +253,7 @@ void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t control mIdentifier = identifier; mAlias = alias; mIsExternal = isExternal; mIsVirtualDevice = isVirtualDevice; mHasMic = hasMic; mSources = 0; mKeyboardType = AINPUT_KEYBOARD_TYPE_NONE; Loading services/inputflinger/include/InputReaderBase.h +7 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,9 @@ struct InputReaderConfiguration { // primary button. MOUSE_SETTINGS = 1u << 15, // The virtual devices list is updated VIRTUAL_DEVICES = 1u << 16, // All devices must be reopened. MUST_REOPEN = 1u << 31, }; Loading Loading @@ -133,6 +136,10 @@ struct InputReaderConfiguration { // Can be used to determine the layout of the keyboard device. std::unordered_map<std::string, KeyboardLayoutInfo> keyboardLayoutAssociations; // List of input device physical port locations of devices that are marked as virtual and should // not be treated as physically connected peripheral (e.g. created using VDM in userspace) std::set<std::string> virtualDevicePorts; // The suggested display ID to show the cursor. ui::LogicalDisplayId defaultPointerDisplayId; Loading services/inputflinger/reader/InputDevice.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ InputDevice::InputDevice(InputReaderContext* context, int32_t id, int32_t genera mSources(0), mIsWaking(false), mIsExternal(false), mIsVirtualDevice(false), mHasMic(false), mDropUntilNextSync(false) {} Loading Loading @@ -136,6 +137,7 @@ void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) { dump += StringPrintf(INDENT "%s", eventHubDevStr.c_str()); dump += StringPrintf(INDENT2 "Generation: %d\n", mGeneration); dump += StringPrintf(INDENT2 "IsExternal: %s\n", toString(mIsExternal)); dump += StringPrintf(INDENT2 "IsVirtualDevice: %s\n", toString(mIsVirtualDevice)); dump += StringPrintf(INDENT2 "IsWaking: %s\n", toString(mIsWaking)); dump += StringPrintf(INDENT2 "AssociatedDisplayPort: "); if (mAssociatedDisplayPort) { Loading Loading @@ -287,6 +289,15 @@ std::list<NotifyArgs> InputDevice::configureInternal(nsecs_t when, mShouldSmoothScroll = mConfiguration.getBool("device.viewBehavior_smoothScroll"); } if (!changes.any() || changes.test(Change::VIRTUAL_DEVICES)) { const bool isVirtualDevice = readerConfig.virtualDevicePorts.contains(mIdentifier.location); if (mIsVirtualDevice != isVirtualDevice) { mIsVirtualDevice = isVirtualDevice; bumpGeneration(); } } if (!changes.any() || changes.test(Change::DEVICE_ALIAS)) { if (!(mClasses.test(InputDeviceClass::VIRTUAL))) { std::string alias = mContext->getPolicy()->getDeviceAlias(mIdentifier); Loading Loading @@ -481,7 +492,7 @@ std::list<NotifyArgs> InputDevice::updateExternalStylusState(const StylusState& InputDeviceInfo InputDevice::getDeviceInfo() { InputDeviceInfo outDeviceInfo; outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal, mHasMic, mIsVirtualDevice, mHasMic, getAssociatedDisplayId().value_or(ui::LogicalDisplayId::INVALID), {mShouldSmoothScroll}, isEnabled()); outDeviceInfo.setKeyboardType(static_cast<int32_t>(mKeyboardType)); Loading services/inputflinger/reader/include/InputDevice.h +3 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ public: inline bool hasEventHubDevices() const { return !mDevices.empty(); } inline virtual bool isExternal() { return mIsExternal; } inline virtual bool isVirtualDevice() const { return mIsVirtualDevice; } inline std::optional<uint8_t> getAssociatedDisplayPort() const { return mAssociatedDisplayPort; } Loading Loading @@ -210,6 +211,7 @@ private: uint32_t mSources; bool mIsWaking; bool mIsExternal; bool mIsVirtualDevice; KeyboardType mKeyboardType = KeyboardType::NONE; std::optional<uint8_t> mAssociatedDisplayPort; std::optional<std::string> mAssociatedDisplayUniqueIdByPort; Loading Loading @@ -458,6 +460,7 @@ public: inline const std::string getDescriptor() { return mDevice.getDescriptor(); } inline const std::string getLocation() { return mDevice.getLocation(); } inline bool isExternal() const { return mDevice.isExternal(); } inline bool isVirtualDevice() const { return mDevice.isVirtualDevice(); } inline std::optional<uint8_t> getAssociatedDisplayPort() const { return mDevice.getAssociatedDisplayPort(); } Loading Loading
include/input/InputDevice.h +4 −1 Original line number Diff line number Diff line Loading @@ -282,7 +282,8 @@ public: void initialize(int32_t id, int32_t generation, int32_t controllerNumber, const InputDeviceIdentifier& identifier, const std::string& alias, bool isExternal, bool hasMic, ui::LogicalDisplayId associatedDisplayId, bool isExternal, bool isVirtualDevice, bool hasMic, ui::LogicalDisplayId associatedDisplayId, InputDeviceViewBehavior viewBehavior = {{}}, bool enabled = true); inline int32_t getId() const { return mId; } Loading @@ -294,6 +295,7 @@ public: return mAlias.empty() ? mIdentifier.name : mAlias; } inline bool isExternal() const { return mIsExternal; } inline bool isVirtualDevice() const { return mIsVirtualDevice; } inline bool hasMic() const { return mHasMic; } inline uint32_t getSources() const { return mSources; } Loading Loading @@ -357,6 +359,7 @@ private: InputDeviceIdentifier mIdentifier; std::string mAlias; bool mIsExternal; bool mIsVirtualDevice; bool mHasMic; std::optional<KeyboardLayoutInfo> mKeyboardLayoutInfo; uint32_t mSources; Loading
libs/input/InputDevice.cpp +7 −4 Original line number Diff line number Diff line Loading @@ -178,11 +178,11 @@ std::string InputDeviceIdentifier::getCanonicalName() const { return replacedName; } // --- InputDeviceInfo --- InputDeviceInfo::InputDeviceInfo() { initialize(-1, 0, -1, InputDeviceIdentifier(), "", false, false, ui::LogicalDisplayId::INVALID); initialize(/*id=*/-1, /*generation=*/0, /*controllerNumber=*/-1, InputDeviceIdentifier(), /*alias=*/"", /*isExternal=*/false, /*isVirtualDevice=*/false, /*hasMic=*/false, ui::LogicalDisplayId::INVALID); } InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) Loading @@ -192,6 +192,7 @@ InputDeviceInfo::InputDeviceInfo(const InputDeviceInfo& other) mIdentifier(other.mIdentifier), mAlias(other.mAlias), mIsExternal(other.mIsExternal), mIsVirtualDevice(other.mIsVirtualDevice), mHasMic(other.mHasMic), mKeyboardLayoutInfo(other.mKeyboardLayoutInfo), mSources(other.mSources), Loading @@ -217,6 +218,7 @@ InputDeviceInfo& InputDeviceInfo::operator=(const InputDeviceInfo& other) { mIdentifier = other.mIdentifier; mAlias = other.mAlias; mIsExternal = other.mIsExternal; mIsVirtualDevice = other.mIsVirtualDevice; mHasMic = other.mHasMic; mKeyboardLayoutInfo = other.mKeyboardLayoutInfo; mSources = other.mSources; Loading @@ -242,7 +244,7 @@ InputDeviceInfo::~InputDeviceInfo() { void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t controllerNumber, const InputDeviceIdentifier& identifier, const std::string& alias, bool isExternal, bool hasMic, bool isExternal, bool isVirtualDevice, bool hasMic, ui::LogicalDisplayId associatedDisplayId, InputDeviceViewBehavior viewBehavior, bool enabled) { mId = id; Loading @@ -251,6 +253,7 @@ void InputDeviceInfo::initialize(int32_t id, int32_t generation, int32_t control mIdentifier = identifier; mAlias = alias; mIsExternal = isExternal; mIsVirtualDevice = isVirtualDevice; mHasMic = hasMic; mSources = 0; mKeyboardType = AINPUT_KEYBOARD_TYPE_NONE; Loading
services/inputflinger/include/InputReaderBase.h +7 −0 Original line number Diff line number Diff line Loading @@ -100,6 +100,9 @@ struct InputReaderConfiguration { // primary button. MOUSE_SETTINGS = 1u << 15, // The virtual devices list is updated VIRTUAL_DEVICES = 1u << 16, // All devices must be reopened. MUST_REOPEN = 1u << 31, }; Loading Loading @@ -133,6 +136,10 @@ struct InputReaderConfiguration { // Can be used to determine the layout of the keyboard device. std::unordered_map<std::string, KeyboardLayoutInfo> keyboardLayoutAssociations; // List of input device physical port locations of devices that are marked as virtual and should // not be treated as physically connected peripheral (e.g. created using VDM in userspace) std::set<std::string> virtualDevicePorts; // The suggested display ID to show the cursor. ui::LogicalDisplayId defaultPointerDisplayId; Loading
services/inputflinger/reader/InputDevice.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ InputDevice::InputDevice(InputReaderContext* context, int32_t id, int32_t genera mSources(0), mIsWaking(false), mIsExternal(false), mIsVirtualDevice(false), mHasMic(false), mDropUntilNextSync(false) {} Loading Loading @@ -136,6 +137,7 @@ void InputDevice::dump(std::string& dump, const std::string& eventHubDevStr) { dump += StringPrintf(INDENT "%s", eventHubDevStr.c_str()); dump += StringPrintf(INDENT2 "Generation: %d\n", mGeneration); dump += StringPrintf(INDENT2 "IsExternal: %s\n", toString(mIsExternal)); dump += StringPrintf(INDENT2 "IsVirtualDevice: %s\n", toString(mIsVirtualDevice)); dump += StringPrintf(INDENT2 "IsWaking: %s\n", toString(mIsWaking)); dump += StringPrintf(INDENT2 "AssociatedDisplayPort: "); if (mAssociatedDisplayPort) { Loading Loading @@ -287,6 +289,15 @@ std::list<NotifyArgs> InputDevice::configureInternal(nsecs_t when, mShouldSmoothScroll = mConfiguration.getBool("device.viewBehavior_smoothScroll"); } if (!changes.any() || changes.test(Change::VIRTUAL_DEVICES)) { const bool isVirtualDevice = readerConfig.virtualDevicePorts.contains(mIdentifier.location); if (mIsVirtualDevice != isVirtualDevice) { mIsVirtualDevice = isVirtualDevice; bumpGeneration(); } } if (!changes.any() || changes.test(Change::DEVICE_ALIAS)) { if (!(mClasses.test(InputDeviceClass::VIRTUAL))) { std::string alias = mContext->getPolicy()->getDeviceAlias(mIdentifier); Loading Loading @@ -481,7 +492,7 @@ std::list<NotifyArgs> InputDevice::updateExternalStylusState(const StylusState& InputDeviceInfo InputDevice::getDeviceInfo() { InputDeviceInfo outDeviceInfo; outDeviceInfo.initialize(mId, mGeneration, mControllerNumber, mIdentifier, mAlias, mIsExternal, mHasMic, mIsVirtualDevice, mHasMic, getAssociatedDisplayId().value_or(ui::LogicalDisplayId::INVALID), {mShouldSmoothScroll}, isEnabled()); outDeviceInfo.setKeyboardType(static_cast<int32_t>(mKeyboardType)); Loading
services/inputflinger/reader/include/InputDevice.h +3 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ public: inline bool hasEventHubDevices() const { return !mDevices.empty(); } inline virtual bool isExternal() { return mIsExternal; } inline virtual bool isVirtualDevice() const { return mIsVirtualDevice; } inline std::optional<uint8_t> getAssociatedDisplayPort() const { return mAssociatedDisplayPort; } Loading Loading @@ -210,6 +211,7 @@ private: uint32_t mSources; bool mIsWaking; bool mIsExternal; bool mIsVirtualDevice; KeyboardType mKeyboardType = KeyboardType::NONE; std::optional<uint8_t> mAssociatedDisplayPort; std::optional<std::string> mAssociatedDisplayUniqueIdByPort; Loading Loading @@ -458,6 +460,7 @@ public: inline const std::string getDescriptor() { return mDevice.getDescriptor(); } inline const std::string getLocation() { return mDevice.getLocation(); } inline bool isExternal() const { return mDevice.isExternal(); } inline bool isVirtualDevice() const { return mDevice.isVirtualDevice(); } inline std::optional<uint8_t> getAssociatedDisplayPort() const { return mDevice.getAssociatedDisplayPort(); } Loading