Initial commit for dmiinfo.cpp
- Tested working for Linux - Implemented in Fusion2USB controller and the motherboard name will populate the controller name in the GUI / CLI
This commit is contained in:
parent
47baeb6b6b
commit
12442046e2
7 changed files with 153 additions and 5 deletions
|
|
@ -27,7 +27,7 @@ static LEDCount LedCountToEnum(unsigned int c)
|
|||
return(LEDS_1024);
|
||||
}
|
||||
|
||||
RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char *path) : dev(handle)
|
||||
RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char *path, std::string mb_name) : dev(handle)
|
||||
{
|
||||
int res = 0;
|
||||
char text[64] {};
|
||||
|
|
@ -48,6 +48,7 @@ RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char
|
|||
|
||||
name = std::string(report.str_product, 32);
|
||||
name.erase(std::find(name.begin(), name.end(), '\0'), name.end());
|
||||
description = mb_name;
|
||||
|
||||
snprintf(text, 11, "0x%08X", report.fw_ver);
|
||||
version = text;
|
||||
|
|
@ -135,6 +136,11 @@ std::string RGBFusion2USBController::GetDeviceName()
|
|||
return(name);
|
||||
}
|
||||
|
||||
std::string RGBFusion2USBController::GetDeviceDescription()
|
||||
{
|
||||
return(description);
|
||||
}
|
||||
|
||||
std::string RGBFusion2USBController::GetFWVersion()
|
||||
{
|
||||
return(version);
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ struct IT8297Report
|
|||
class RGBFusion2USBController
|
||||
{
|
||||
public:
|
||||
RGBFusion2USBController(hid_device* handle, const char *path);
|
||||
RGBFusion2USBController(hid_device* handle, const char *path, std::string mb_name);
|
||||
~RGBFusion2USBController();
|
||||
|
||||
void SetStripColors
|
||||
|
|
@ -175,6 +175,7 @@ public:
|
|||
bool DisableBuiltinEffect(int enable_bit, int mask);
|
||||
void SetCalibration();
|
||||
std::string GetDeviceName();
|
||||
std::string GetDeviceDescription();
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetFWVersion();
|
||||
std::string GetSerial();
|
||||
|
|
@ -188,6 +189,7 @@ private:
|
|||
int mode;
|
||||
IT8297Report report;
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::string loc;
|
||||
std::string version;
|
||||
std::string chip_id;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "RGBFusion2USBController.h"
|
||||
#include "RGBController_RGBFusion2USB.h"
|
||||
#include "dependencies/dmiinfo.h"
|
||||
|
||||
#define IT8297_VID 0x048D
|
||||
#define IT8297_PID 0x8297
|
||||
|
|
@ -14,19 +15,28 @@
|
|||
|
||||
void DetectRGBFusion2USBControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
DMIInfo info;
|
||||
|
||||
if (hid_init() < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hid_device_info * device_list = hid_enumerate(IT8297_VID, IT8297_PID);
|
||||
|
||||
if (!device_list)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
hid_device_info * device = device_list;
|
||||
|
||||
while (device)
|
||||
{
|
||||
hid_device * dev = hid_open_path(device->path);
|
||||
if (dev) {
|
||||
RGBFusion2USBController * controller = new RGBFusion2USBController(dev, device_list->path);
|
||||
if (dev)
|
||||
{
|
||||
RGBFusion2USBController * controller = new RGBFusion2USBController(dev, device_list->path, info.getMainboard());
|
||||
RGBController_RGBFusion2USB * rgb_controller = new RGBController_RGBFusion2USB(controller);
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ INCLUDEPATH += \
|
|||
qt/
|
||||
|
||||
HEADERS += \
|
||||
dependencies/dmiinfo.h \
|
||||
dependencies/ColorWheel/ColorWheel.h \
|
||||
NetworkClient.h \
|
||||
NetworkProtocol.h \
|
||||
|
|
@ -192,6 +193,7 @@ HEADERS += \
|
|||
RGBController/RGBController_ThermaltakeRiing.h \
|
||||
|
||||
SOURCES += \
|
||||
dependencies/dmiinfo.cpp \
|
||||
dependencies/ColorWheel/ColorWheel.cpp \
|
||||
dependencies/libe131/src/e131.c \
|
||||
main.cpp \
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
|
|||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "RGB Fusion 2 Controller";
|
||||
name = controller->GetDeviceDescription();
|
||||
type = DEVICE_TYPE_MOTHERBOARD;
|
||||
description = controller->GetDeviceName();
|
||||
version = controller->GetFWVersion();
|
||||
|
|
|
|||
91
dependencies/dmiinfo.cpp
vendored
Normal file
91
dependencies/dmiinfo.cpp
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| dmiinfo.cpp |
|
||||
| |
|
||||
| Read DMI information for motherboard vendor and name |
|
||||
| |
|
||||
| Chris M (Dr_No) 30th Jun 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "dmiinfo.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include "wmi.h"
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DMIInfo (Windows) *
|
||||
* *
|
||||
* Implementing way to read motherboard vendor and name based on *
|
||||
* the win32_baseboard WMI query *
|
||||
* https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-baseboard *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
DMIInfo::DMIInfo()
|
||||
{
|
||||
mainboard = "";
|
||||
manufacturer = "";
|
||||
HRESULT hres;
|
||||
Wmi wmi;
|
||||
wmi.init();
|
||||
|
||||
// Query WMI for Win32_PnPSignedDriver entries with names matching "SMBUS" or "SM BUS"
|
||||
// These devices may be browsed under Device Manager -> System Devices
|
||||
std::vector<QueryObj> q_res_BaseBoard;
|
||||
hres = wmi.query("SELECT * FROM Win32_BaseBoard", q_res_BaseBoard);
|
||||
|
||||
if (hres)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (QueryObj &i : q_res_BaseBoard)
|
||||
{
|
||||
manufacturer = i["Manufacturer"].c_str();
|
||||
mainboard = i["Model"].c_str();
|
||||
}
|
||||
}
|
||||
#else /* WIN32 */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DMIInfo (Linux) *
|
||||
* *
|
||||
* Implementing way to read motherboard vendor and name based on *
|
||||
* the Linux DMIDecode which is read only for users in the sysfs @ *
|
||||
* /sys/devices/virtual/dmi/id/ *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
DMIInfo::DMIInfo()
|
||||
{
|
||||
mainboard = "";
|
||||
manufacturer = "";
|
||||
|
||||
if ((access(SYSFSDMI "/board_vendor", R_OK)!=0) && (access(SYSFSDMI "/board_name", R_OK)!=0))
|
||||
return;
|
||||
|
||||
std::ifstream mftr(SYSFSDMI "/board_vendor", std::ifstream::in);
|
||||
getline(mftr, manufacturer);
|
||||
mftr.close();
|
||||
|
||||
std::ifstream prdt(SYSFSDMI "/board_name", std::ifstream::in);
|
||||
getline(prdt, mainboard);
|
||||
prdt.close();
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
|
||||
DMIInfo::~DMIInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string DMIInfo::getMainboard()
|
||||
{
|
||||
return mainboard;
|
||||
}
|
||||
|
||||
std::string DMIInfo::getManufacturer()
|
||||
{
|
||||
return manufacturer;
|
||||
}
|
||||
37
dependencies/dmiinfo.h
vendored
Normal file
37
dependencies/dmiinfo.h
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/*-------------------------------------------------------------------*\
|
||||
| dmiinfo.h |
|
||||
| |
|
||||
| Read DMI information for motherboard vendor and name |
|
||||
| |
|
||||
| Chris M (Dr_No) 30th Jun 2020 |
|
||||
| |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#ifndef DMIINFO_H
|
||||
#define DMIINFO_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef WIN32
|
||||
#include "wmi.h"
|
||||
#else
|
||||
#include <unistd.h> //Linux specific filesystem operation
|
||||
#include <fstream>
|
||||
|
||||
#define SYSFSDMI "/sys/devices/virtual/dmi/id/" //Linux specific file path
|
||||
#endif
|
||||
|
||||
class DMIInfo
|
||||
{
|
||||
public:
|
||||
DMIInfo();
|
||||
~DMIInfo();
|
||||
|
||||
std::string getMainboard();
|
||||
std::string getManufacturer();
|
||||
private:
|
||||
std::string mainboard;
|
||||
std::string manufacturer;
|
||||
};
|
||||
|
||||
#endif // DMIINFO_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue