Use HID path for Location on MSI 3 Zone controller

This commit is contained in:
Adam Honse
2020-10-04 18:38:56 -05:00
parent 43cea0a1b2
commit acced4d036
4 changed files with 31 additions and 10 deletions

View File

@@ -9,9 +9,10 @@
#include "MSI3ZoneController.h"
MSI3ZoneController::MSI3ZoneController(hid_device* dev_handle)
MSI3ZoneController::MSI3ZoneController(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
dev = dev_handle;
location = path;
//strcpy(device_name, "MSI 3-Zone Keyboard");
}
@@ -26,6 +27,11 @@ char* MSI3ZoneController::GetDeviceName()
return device_name;
}
std::string MSI3ZoneController::GetDeviceLocation()
{
return(location);
}
void MSI3ZoneController::SetLEDs(std::vector<RGBColor> colors)
{
//Shout out to bparker06 for reverse engineering the MSI keyboard USB protocol!

View File

@@ -17,14 +17,16 @@
class MSI3ZoneController
{
public:
MSI3ZoneController(hid_device* dev_handle);
MSI3ZoneController(hid_device* dev_handle, const char* path);
~MSI3ZoneController();
char* GetDeviceName();
std::string GetDeviceLocation();
void SetLEDs(std::vector<RGBColor> colors);
private:
char device_name[32];
hid_device* dev;
std::string location;
};

View File

@@ -19,20 +19,32 @@
void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device* dev;
hid_device_info* info;
hid_device* dev = NULL;
//Look for MSI/Steelseries 3-zone Keyboard
hid_init();
dev = hid_open(MSI_3_ZONE_KEYBOARD_VID, MSI_3_ZONE_KEYBOARD_PID, 0);
info = hid_enumerate(MSI_3_ZONE_KEYBOARD_VID, MSI_3_ZONE_KEYBOARD_PID);
if( dev )
//Look for MSI/Steelseries 3-zone Keyboard
while(info)
{
MSI3ZoneController* controller = new MSI3ZoneController(dev);
if((info->vendor_id == MSI_3_ZONE_KEYBOARD_VID)
&&(info->product_id == MSI_3_ZONE_KEYBOARD_PID))
{
dev = hid_open_path(info->path);
RGBController_MSI3Zone* rgb_controller = new RGBController_MSI3Zone(controller);
if( dev )
{
MSI3ZoneController* controller = new MSI3ZoneController(dev, info->path);
rgb_controllers.push_back(rgb_controller);
RGBController_MSI3Zone* rgb_controller = new RGBController_MSI3Zone(controller);
rgb_controllers.push_back(rgb_controller);
}
}
info = info->next;
}
} /* DetectMSI3ZoneControllers() */

View File

@@ -16,6 +16,7 @@ RGBController_MSI3Zone::RGBController_MSI3Zone(MSI3ZoneController* msi_ptr)
name = "MSI 3-Zone Keyboard";
type = DEVICE_TYPE_KEYBOARD;
description = "MSI 3-Zone Keyboard Device";
location = msi->GetDeviceLocation();
mode Direct;
Direct.name = "Direct";