From 935ccd53adf7ea7e9958e5118120c2700b6a0df4 Mon Sep 17 00:00:00 2001 From: zhanghongyuan Date: Wed, 27 Aug 2025 13:59:24 +0800 Subject: [PATCH] fix: Improve input device Bus interface detection - Use case-insensitive contains matching instead of exact string comparison - Support interface name variations like 'ps/2', 'bluetooth low energy', etc. - Refactor hardcoded interface checks to use static list and loop - Fix device availability detection for input devices with non-standard interface names Log: Improve input device Bus interface detection Bug: https://pms.uniontech.com/bug-view-331181.html Change-Id: Ifbc7c40f44f45e146f07fe101ed3fc960e945459 --- deepin-devicemanager/src/DeviceManager/DeviceInput.cpp | 8 +++++--- deepin-devicemanager/src/DeviceManager/DeviceInput.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp b/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp index 9e03227a..f3215460 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp +++ b/deepin-devicemanager/src/DeviceManager/DeviceInput.cpp @@ -13,6 +13,8 @@ #include #include +QStringList DeviceInput::m_supportInterfaces= {"PS/2", "Bluetooth", "I2C"}; + DeviceInput::DeviceInput() : DeviceBaseInfo() , m_Model("") @@ -387,9 +389,9 @@ bool DeviceInput::available() if (driver().isEmpty()) { m_Available = false; } - if ("PS/2" == m_Interface || "Bluetooth" == m_Interface || "I2C" == m_Interface) { - m_Available = true; - } + + m_Available = m_supportInterfaces.contains(m_Interface, Qt::CaseInsensitive); + return m_forcedDisplay ? m_forcedDisplay : m_Available; } diff --git a/deepin-devicemanager/src/DeviceManager/DeviceInput.h b/deepin-devicemanager/src/DeviceManager/DeviceInput.h index 35e776f9..69bfd819 100644 --- a/deepin-devicemanager/src/DeviceManager/DeviceInput.h +++ b/deepin-devicemanager/src/DeviceManager/DeviceInput.h @@ -208,6 +208,8 @@ class DeviceInput : public DeviceBaseInfo bool m_wakeupChanged = true; //