fix: add non-USB keyboard directly without VID/PID check - #716
Conversation
PS/2 and I2C keyboards in hwinfo use single-token Vendor/Device format (e.g. "Vendor: 0x0001") which cannot be parsed into VID/PID, causing addKeyboardDevice to drop them. Gate the VID/PID+lsusb verification to USB keyboards only; non-USB keyboards are appended directly. PS/2、I2C 等内置键盘的 hwinfo 信息为 "Vendor: 0xNNNN" 单段格式, 无法解析出 VID/PID,导致 addKeyboardDevice 误删除。将 VID/PID+lsusb 校验限定为仅 USB 键盘,非 USB 键盘直接添加。 Log: 修复非USB键盘因缺少VID/PID无法显示的问题 PMS: BUG-368071 Influence: PS/2、I2C、蓝牙等内置键盘现在能正常显示在设备管理器中
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR ensures that only USB keyboards undergo VID/PID + lsusb verification, while non-USB keyboards (e.g., PS/2, I2C, Bluetooth) are appended directly, preventing them from being incorrectly dropped due to missing VID/PID information. Sequence diagram for updated keyboard addition logicsequenceDiagram
participant DeviceManager
participant DeviceInput
DeviceManager->>DeviceInput: getInterface()
DeviceInput-->>DeviceManager: interface
alt [interface does not contain USB]
DeviceManager->>DeviceManager: m_ListDeviceKeyboard.append(device)
DeviceManager->>DeviceInput: qCDebug(appLog)
DeviceManager->>DeviceInput: return
else [interface contains USB]
DeviceManager->>DeviceInput: getVID()
DeviceInput-->>DeviceManager: vid
DeviceManager->>DeviceInput: getPID()
DeviceInput-->>DeviceManager: pid
alt [vid.isEmpty() or pid.isEmpty()]
DeviceManager->>DeviceInput: qCDebug(appLog)
DeviceManager->>DeviceInput: deleteLater()
else [valid VID/PID]
DeviceManager->>DeviceManager: lsusb verification and append
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
interfacegate treats any device whose interface string is empty or does not containUSBas a non-USB keyboard; consider explicitly handling empty/unknown interfaces to avoid mistakenly adding ghost or misclassified devices. - Previously USB keyboards with empty VID/PID were still added with a debug note, but now they are dropped; double-check whether this behavior change is intentional and, if so, whether there are known USB devices that legitimately lack VID/PID and should be handled differently.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `interface` gate treats any device whose interface string is empty or does not contain `USB` as a non-USB keyboard; consider explicitly handling empty/unknown interfaces to avoid mistakenly adding ghost or misclassified devices.
- Previously USB keyboards with empty VID/PID were still added with a debug note, but now they are dropped; double-check whether this behavior change is intentional and, if so, whether there are known USB devices that legitimately lack VID/PID and should be handled differently.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已足够完善,无需额外修复,保持原样即可。
void DeviceManager::addKeyboardDevice(DeviceInput *const device)
{
QString vid = device->getVID();
QString pid = device->getPID();
QString interface = device->getInterface();
// 仅USB键盘具备有效的VID/PID,需要通过lsusb校验以过滤无效/幽灵USB设备。
// PS/2、I2C、蓝牙等内置键盘没有VID/PID(hwinfo中为 "Vendor: 0xNNNN" 单段格式,
// 无法解析出VID/PID),应直接添加,避免被误删导致键盘无法显示。
if (!interface.contains("USB", Qt::CaseInsensitive)) {
m_ListDeviceKeyboard.append(device);
qCDebug(appLog) << "Non-USB keyboard added directly, interface:" << interface;
return;
}
if (vid.isEmpty() || pid.isEmpty()) {
qCDebug(appLog) << "USB keyboard VID or PID is empty, device not added";
device->deleteLater();
return;
}
// ... 后续逻辑
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
PS/2 and I2C keyboards in hwinfo use single-token Vendor/Device format (e.g. "Vendor: 0x0001") which cannot be parsed into VID/PID, causing addKeyboardDevice to drop them. Gate the VID/PID+lsusb verification to USB keyboards only; non-USB keyboards are appended directly.
PS/2、I2C 等内置键盘的 hwinfo 信息为 "Vendor: 0xNNNN" 单段格式,
无法解析出 VID/PID,导致 addKeyboardDevice 误删除。将 VID/PID+lsusb 校验限定为仅 USB 键盘,非 USB 键盘直接添加。
Log: 修复非USB键盘因缺少VID/PID无法显示的问题
PMS: BUG-368071
Influence: PS/2、I2C、蓝牙等内置键盘现在能正常显示在设备管理器中
Summary by Sourcery
Bug Fixes: