Skip to content

fix(input): check device availability#614

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom
add-uos:develop/eagle
Mar 5, 2026
Merged

fix(input): check device availability#614
deepin-bot[bot] merged 1 commit intolinuxdeepin:develop/eaglefrom
add-uos:develop/eagle

Conversation

@add-uos
Copy link
Contributor

@add-uos add-uos commented Mar 5, 2026

enable UINPUT device in input device.

log: cenable UINPUT device in input device.
bug: https://pms.uniontech.com/bug-view-347463.html

Summary by Sourcery

New Features:

  • Recognize and handle input devices that use the UINPUT interface.

enable UINPUT device in input device.

log: cenable UINPUT device in input device.
bug: https://pms.uniontech.com/bug-view-347463.html
@deepin-ci-robot
Copy link

deepin pr auto review

这段代码修改主要是向静态成员变量 m_supportInterfaces 中添加了一个新的字符串元素 "UINPUT"。以下是对这段修改的详细审查意见:

1. 语法逻辑

  • 审查结果:通过。
  • 分析:语法符合 C++11 的初始化列表标准,QStringList 支持这种初始化方式。逻辑上,向支持的接口列表中添加一个新的接口类型是合理的。

2. 代码质量

  • 审查结果:需改进。
  • 分析
    • 硬编码m_supportInterfaces 是一个静态成员变量,直接在源文件中硬编码初始化。如果未来需要动态加载支持的接口,或者需要通过配置文件修改,这种方式缺乏灵活性。
    • 命名规范m_supportInterfaces 命名清晰,符合常见的成员变量命名规范(m_ 前缀)。
    • 建议:虽然目前的改动是正确的,但建议检查 "UINPUT" 是否为该类唯一需要添加的接口。如果接口类型可能扩展,建议考虑将此类数据与代码逻辑分离,例如使用配置文件或常量定义文件管理。

3. 代码性能

  • 审查结果:无影响。
  • 分析:这是一个静态变量的初始化,仅在程序启动时执行一次。增加一个字符串常量对内存占用和运行时性能的影响微乎其微,可以忽略不计。

4. 代码安全

  • 审查结果:需注意。
  • 分析
    • 输入验证m_supportInterfaces 通常用于后续的字符串比较(如 contains())。添加 "UINPUT" 后,需确保代码库中所有依赖此列表进行逻辑判断的地方都能正确处理 "UINPUT" 这种类型的设备,避免因逻辑遗漏导致某些设备被错误过滤或处理。
    • 大小写敏感:字符串列表中的内容是大写混合(如 "PS/2", "USB"),而 "UINPUT" 是全大写。需要确保从系统获取设备信息时,字符串的大小写格式与此列表一致,或者在比较时统一进行大小写转换(如 toUpper()),否则可能导致匹配失败。

改进建议

  1. 使用常量定义
    为了避免魔法字符串散落在代码中,建议将 "UINPUT" 定义为常量,或者至少确保其拼写在整个项目中保持一致。

  2. 大小写处理
    如果从 /sys/class/input 或其他系统接口读取的设备接口名称大小写不固定,建议在初始化列表时统一转为大写或小写,或者在比较时忽略大小写。

    // 示例:如果需要忽略大小写比较
    bool isSupported = m_supportInterfaces.contains(deviceInterface, Qt::CaseInsensitive);
  3. 完整性检查
    既然添加了对 UINPUT 的支持,请务必检查 DeviceInput 类中是否有其他逻辑(例如设备信息获取、驱动匹配等)需要针对 UINPUT 设备做特殊处理。UINPUT 通常是虚拟输入设备,其属性可能与物理设备(USB, PS/2)有所不同。

总结:该 diff 修改本身语法正确且无性能问题,但为了代码的健壮性,建议确认后续逻辑对 UINPUT 的兼容性,并注意字符串匹配时的格式统一。

@sourcery-ai
Copy link

sourcery-ai bot commented Mar 5, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Extend the list of supported input device interfaces to include UINPUT so that these devices are recognized and handled by DeviceInput.

File-Level Changes

Change Details Files
Extend supported input interfaces to recognize UINPUT devices.
  • Update the static m_supportInterfaces list to append the "UINPUT" interface type so that UINPUT devices are treated as supported input devices by DeviceInput logic.
deepin-devicemanager/src/DeviceManager/DeviceInput.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos, max-lvs

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@add-uos
Copy link
Contributor Author

add-uos commented Mar 5, 2026

/forcemerge

@deepin-bot
Copy link
Contributor

deepin-bot bot commented Mar 5, 2026

This pr force merged! (status: unstable)

@deepin-bot deepin-bot bot merged commit 322f0e9 into linuxdeepin:develop/eagle Mar 5, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants