Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions deepin-devicemanager/src/DeviceManager/DeviceAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ TomlFixMethod DeviceAudio::setInfoFromTomlOneByOne(const QMap<QString, QString>
{
qCDebug(appLog) << "DeviceAudio::setInfoFromTomlOneByOne started.";
TomlFixMethod ret = TOML_None;
// must cover the loadOtherDeviceInfo
// must cover the loadOtherDeviceInfo
// 添加基本信息
ret = setTomlAttribute(mapInfo, "SysFS_Path", m_SysPath);
ret = setTomlAttribute(mapInfo, "KernelModeDriver", m_Driver);
setTomlAttribute(mapInfo, "SysFS_Path", m_SysPath);
setTomlAttribute(mapInfo, "KernelModeDriver", m_Driver);
// 添加其他信息,成员变量
ret = setTomlAttribute(mapInfo, "Chip", m_Chip);
ret = setTomlAttribute(mapInfo, "Capabilities", m_Capabilities);
ret = setTomlAttribute(mapInfo, "Memory Address", m_Memory);
setTomlAttribute(mapInfo, "Chip", m_Chip);
setTomlAttribute(mapInfo, "Capabilities", m_Capabilities);
setTomlAttribute(mapInfo, "Memory Address", m_Memory);
ret = setTomlAttribute(mapInfo, "IRQ", m_Irq);
//3. 获取设备的其它信息
getOtherMapInfo(mapInfo);
Expand Down
4 changes: 2 additions & 2 deletions deepin-devicemanager/src/DeviceManager/DeviceBios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ TomlFixMethod DeviceBios::setInfoFromTomlOneByOne(const QMap<QString, QString> &
TomlFixMethod ret = TOML_None;

ret = setTomlAttribute(mapInfo, "Version", m_Version, true);
ret = setTomlAttribute(mapInfo, "Product Name", m_ProductName, true);
ret = setTomlAttribute(mapInfo, "Chipset", m_ChipsetFamily, true);
setTomlAttribute(mapInfo, "Product Name", m_ProductName, true);
setTomlAttribute(mapInfo, "Chipset", m_ChipsetFamily, true);
// ret = setTomlAttribute(mapInfo, "Vendor", m_Vendor,true);
// m_IsBoard = true;
qCDebug(appLog) << "Toml attributes set for Version, Product Name, Chipset.";
Expand Down
23 changes: 12 additions & 11 deletions deepin-devicemanager/src/DeviceManager/DeviceBluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,23 @@ TomlFixMethod DeviceBluetooth::setInfoFromTomlOneByOne(const QMap<QString, QStri
qCDebug(appLog) << "DeviceBluetooth::setInfoFromTomlOneByOne started.";
TomlFixMethod ret = TOML_None;
// 添加基本信息
ret = setTomlAttribute(mapInfo, "Model", m_Model);
ret = setTomlAttribute(mapInfo, "Name", m_Name);
ret = setTomlAttribute(mapInfo, "Vendor", m_Vendor);
ret = setTomlAttribute(mapInfo, "Version", m_Version);
setTomlAttribute(mapInfo, "Model", m_Model);
setTomlAttribute(mapInfo, "Name", m_Name);
setTomlAttribute(mapInfo, "Vendor", m_Vendor);
setTomlAttribute(mapInfo, "Version", m_Version);
qCDebug(appLog) << "Basic toml attributes set.";

// 添加其他信息,成员变量
ret = setTomlAttribute(mapInfo, "Speed", m_Speed);
ret = setTomlAttribute(mapInfo, "Maximum Power", m_MaximumPower);
ret = setTomlAttribute(mapInfo, "Driver Version", m_DriverVersion);
ret = setTomlAttribute(mapInfo, "Capabilities", m_Capabilities);
ret = setTomlAttribute(mapInfo, "Bus Info", m_BusInfo);
ret = setTomlAttribute(mapInfo, "Logical Name", m_LogicalName);
setTomlAttribute(mapInfo, "Speed", m_Speed);
setTomlAttribute(mapInfo, "Maximum Power", m_MaximumPower);
setTomlAttribute(mapInfo, "Driver Version", m_DriverVersion);
setTomlAttribute(mapInfo, "Capabilities", m_Capabilities);
setTomlAttribute(mapInfo, "Bus Info", m_BusInfo);
setTomlAttribute(mapInfo, "Logical Name", m_LogicalName);
ret = setTomlAttribute(mapInfo, "MAC Address", m_MAC);
qCDebug(appLog) << "Other toml attributes set.";
//3. 获取设备的其它信息

//3. 获取设备的其它信息
getOtherMapInfo(mapInfo);
qCDebug(appLog) << "DeviceBluetooth::setInfoFromTomlOneByOne finished, return: " << ret;
return ret;
Expand Down
8 changes: 4 additions & 4 deletions deepin-devicemanager/src/DeviceManager/DeviceCdrom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ TomlFixMethod DeviceCdrom::setInfoFromTomlOneByOne(const QMap<QString, QString>
{
qCDebug(appLog) << "DeviceCdrom::setInfoFromTomlOneByOne started.";
TomlFixMethod ret = TOML_None;
ret = setTomlAttribute(mapInfo, "Model", m_Type);
ret = setTomlAttribute(mapInfo, "Bus Info", m_BusInfo);
ret = setTomlAttribute(mapInfo, "Capabilities", m_Capabilities);
ret = setTomlAttribute(mapInfo, "Maximum Power", m_MaxPower);
setTomlAttribute(mapInfo, "Model", m_Type);
setTomlAttribute(mapInfo, "Bus Info", m_BusInfo);
setTomlAttribute(mapInfo, "Capabilities", m_Capabilities);
setTomlAttribute(mapInfo, "Maximum Power", m_MaxPower);
ret = setTomlAttribute(mapInfo, "Speed", m_Speed);
qCDebug(appLog) << "Toml attributes set.";
//3. 获取设备的其它信息
Expand Down
13 changes: 5 additions & 8 deletions deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

// 项目自身文件
#include "DeviceGpu.h"
#include "commondefine.h"

Check warning on line 7 in deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commondefine.h" not found.
#include "commonfunction.h"

Check warning on line 8 in deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commonfunction.h" not found.
#include "DDLog.h"

Check warning on line 9 in deepin-devicemanager/src/DeviceManager/DeviceGpu.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DDLog.h" not found.

// Qt库文件
#include<QLoggingCategory>
Expand Down Expand Up @@ -198,18 +199,14 @@
// qCDebug(appLog) << "Skipping empty item in gpu-info.";
continue;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QStringList items = allStr.split(":", QString::SkipEmptyParts);
#else
QStringList items = allStr.split(":", Qt::SkipEmptyParts);
#endif
if (items.size() != 2) {
QStringList tmpItems = allStr.split(":", QT_SKIP_EMPTY_PARTS);
if (tmpItems.size() != 2) {
// qCDebug(appLog) << "Skipping item with incorrect size in gpu-info: " << item;
continue;
}
if (items.first().trimmed() == "VRAM total size") {
if (tmpItems.first().trimmed() == "VRAM total size") {
bool ok;
quint64 vramSize = items.last().trimmed().toULong(&ok, 16);
quint64 vramSize = tmpItems.last().trimmed().toULong(&ok, 16);
if (ok && vramSize >= 1048576) {
// qCDebug(appLog) << "VRAM total size found and valid, converting.";
vramSize /= 1048576;
Expand Down
4 changes: 2 additions & 2 deletions deepin-devicemanager/src/DeviceManager/DeviceInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ TomlFixMethod DeviceBaseInfo::setInfoFromTomlBase(const QMap<QString, QString> &
return TOML_Del;
}

ret2 = setTomlAttribute(mapInfo, "Revision", m_Version);
ret2 = setTomlAttribute(mapInfo, "Description", m_Description);
setTomlAttribute(mapInfo, "Revision", m_Version);
setTomlAttribute(mapInfo, "Description", m_Description);
m_VID = m_VID.toLower();
m_PID = m_PID.toLower();
m_VID_PID = m_VID + m_PID.remove("0x");
Expand Down
101 changes: 100 additions & 1 deletion deepin-devicemanager/src/DeviceManager/DeviceInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
#include "DeviceInput.h"
#include "DeviceManager.h"
#include "DBusEnableInterface.h"
#include "DBusTouchPad.h"

Check warning on line 9 in deepin-devicemanager/src/DeviceManager/DeviceInput.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DBusTouchPad.h" not found.
#include "DBusWakeupInterface.h"

Check warning on line 10 in deepin-devicemanager/src/DeviceManager/DeviceInput.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DBusWakeupInterface.h" not found.
#include "DDLog.h"

Check warning on line 11 in deepin-devicemanager/src/DeviceManager/DeviceInput.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DDLog.h" not found.
#include "commondefine.h"

Check warning on line 12 in deepin-devicemanager/src/DeviceManager/DeviceInput.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "commondefine.h" not found.

// Qt库文件
#include <QLoggingCategory>

Check warning on line 15 in deepin-devicemanager/src/DeviceManager/DeviceInput.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QLoggingCategory> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QProcess>
#include <QRegularExpression>

Expand Down Expand Up @@ -67,6 +68,7 @@
qCDebug(appLog) << "Driver is empty and interface is PS/2, setting m_CanUninstall to false.";
m_CanUninstall = false;
}
getMouseInfoFromBusDevice();

// 获取其他设备信息
getOtherMapInfo(mapInfo);
Expand Down Expand Up @@ -177,6 +179,7 @@
setInfoFromBluetoothctl();
qCDebug(appLog) << "Info set from Bluetoothctl.";

getMouseInfoFromBusDevice();
// 获取其他设备信息
getOtherMapInfo(mapInfo);
qCDebug(appLog) << "Exiting setInfoFromHwinfo.";
Expand Down Expand Up @@ -361,7 +364,103 @@
return "";
}

InputDeviceBusInfo DeviceInput::getDetailBusInfo(const QString &busId)
{
InputDeviceBusInfo info;
info.busId = busId;

// 根据 Bus ID 查找对应的接口类型信息-只会使用 interfaceType,其他内容预留维护参考
static QMap<QString, InputDeviceBusInfo> busInfoMap = {
{"0000", {"0000", "UINPUT", "虚拟设备", "用于软件模拟输入"}},
{"0001", {"0001", "PCI", "特殊输入卡", "通过 PCI/PCIe 总线连接的设备"}},
{"0002", {"0002", "ISA", "古老 ISA 设备", "已淘汰的 ISA 接口设备"}},
{"0003", {"0003", "USB", "USB鼠标/键盘/手柄", "最常见的外设接口,设备路径含 usb"}},
{"0004", {"0004", "HIL", "HP-HIL终端设备", "历史遗留系统 (HP-HIL)"}},
{"0005", {"0005", "BLUETOOTH", "蓝牙鼠标/键盘", "设备名称含 bluetooth,需 rfkill 管理"}},
{"0006", {"0006", "VIRTUAL", "VMware/QEMU虚拟输入", "虚拟机中的输入设备"}},
{"0007", {"0007", "SERIAL)", "串口鼠标", "设备节点为 /dev/ttyS*"}},
{"0008", {"0008", "HOST", "内置键盘/触摸板", "通过主板直接连接的设备"}},
{"0009", {"0009", "Game Port", "游戏手柄", "15针 D-Sub 接口"}},
{"0010", {"0010", "PARALLEL", "老式输入设备", "/dev/parport*"}},
{"0011", {"0011", "PS/2", "PS/2鼠标/键盘", "圆形 6-pin 接口,设备节点为 /dev/psaux"}},
{"0012", {"0012", "RADIO", "无线接收器", "专用 2.4G 设备 (如罗技 Unifying)"}},
{"0013", {"0013", "J1939", "车载工业设备", "CAN 总线扩展"}},
{"0018", {"0018", "I2C", "高端触摸板/触控笔", "设备名称含 i2c,需 i2c-tools 调试"}},
{"0019", {"0019", "SPI", "嵌入式触控屏", "通过 SPI 总线通信"}},
{"001a", {"001A", "ILLUMINANCE", "环境光传感器", "部分笔记本的自动亮度调节"}},
{"001b", {"001B", "GDIX", "Surface Dial", "微软 Surface Dial 特殊旋转输入设备"}},
{"001c", {"001C", "WACOM", "数位板/绘图屏", "设备名含 wacom"}},
{"001d", {"001D", "UCSI", "USB Type-C输入", "新式笔记本的 USB-C 扩展设备"}}
};

// 查找匹配的 Bus ID (不区分大小写)
QString lowerBusId = busId.toLower();
if (busInfoMap.contains(lowerBusId)) {
return busInfoMap.value(lowerBusId);
}

// 如果没有找到匹配的,返回未知类型
info.interfaceType = "Unknown";
info.typicalDevices = "UnKnown Device";
info.description = QString("Unrecognized Bus ID: %1").arg(busId);

return info;
}

void DeviceInput::getMouseInfoFromBusDevice()
{
QProcess process;
process.start("cat", QStringList() << "/proc/bus/input/devices");
process.waitForFinished(10000);
QString rawContent = process.readAllStandardOutput();

QMap<QString, QString> nameToBusMap;

if (rawContent.isEmpty()) {
return ;
}

QStringList deviceBlocks = rawContent.split("\n\n", QT_SKIP_EMPTY_PARTS);

for (const QString &block : deviceBlocks) {
QString bus, name;
QStringList lines = block.split("\n", QT_SKIP_EMPTY_PARTS);

for (const QString &line : lines) {
QString trimmedLine = line.trimmed();

// 提取 Bus 信息 (I: Bus=0019 ...)
if (trimmedLine.startsWith("I:") && trimmedLine.contains("Bus=")) {
QRegularExpression busRegex("Bus=([0-9a-fA-F]+)");
QRegularExpressionMatch match = busRegex.match(trimmedLine);
if (match.hasMatch()) {
bus = match.captured(1);
}
}

// 提取 Name 信息 (N: Name="Sleep Button")
if (trimmedLine.startsWith("N:") && trimmedLine.contains("Name=")) {
QRegularExpression nameRegex("Name=\"([^\"]+)\"");
QRegularExpressionMatch match = nameRegex.match(trimmedLine);
if (match.hasMatch()) {
name = match.captured(1);
}
}
}

// 如果同时找到了 name 和 bus,则添加到映射中
if (!name.isEmpty() && !bus.isEmpty()) {
nameToBusMap.insert(name, bus);
}
}

if (nameToBusMap.contains(m_Name)) {
QString busID = nameToBusMap.value(m_Name);
m_Interface = getDetailBusInfo(busID).interfaceType;
}
}

QString DeviceInput::getBusInfo() const

Check warning on line 463 in deepin-devicemanager/src/DeviceManager/DeviceInput.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'getBusInfo' is never used.
{
return m_SysPath;
}
Expand Down Expand Up @@ -397,7 +496,7 @@
// qCDebug(appLog) << "driver is empty";
m_Available = false;
}
if ("PS/2" == m_Interface || "Bluetooth" == m_Interface) {
if ("PS/2" == m_Interface || "Bluetooth" == m_Interface || "I2C" == m_Interface) {
// qCDebug(appLog) << "interface is PS/2 or Bluetooth";
m_Available = true;
}
Expand Down
23 changes: 23 additions & 0 deletions deepin-devicemanager/src/DeviceManager/DeviceInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@

#include "DeviceInfo.h"

/**
* @brief The InputDeviceBusInfo class
* 描述InputDevice设备的Bus信息
*/
struct InputDeviceBusInfo {
QString busId;
QString interfaceType;
QString typicalDevices;
QString description;
};

/**
* @brief The DeviceInput class
* 用来描述输入设备的类
Expand Down Expand Up @@ -171,6 +182,18 @@ class DeviceInput : public DeviceBaseInfo
*/
QString eventStrFromDeviceFiles(const QString &dfs);

/**
* @brief getDetailBusInfo
* @param busId Bus ID类别号
* @return
*/
InputDeviceBusInfo getDetailBusInfo(const QString &busId);

/**
* @brief getMouseInfoFromBusDevice
* 实时从/proc/bus/input/devices获取设备接口信息
*/
void getMouseInfoFromBusDevice();
private:

QString m_Model; //<! 【型号】
Expand Down
Loading