diff --git a/Controllers/MSI3ZoneController/MSI3ZoneController.cpp b/Controllers/MSI3ZoneController/MSI3ZoneController.cpp index 6ea7e199..fe193666 100644 --- a/Controllers/MSI3ZoneController/MSI3ZoneController.cpp +++ b/Controllers/MSI3ZoneController/MSI3ZoneController.cpp @@ -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 colors) { //Shout out to bparker06 for reverse engineering the MSI keyboard USB protocol! diff --git a/Controllers/MSI3ZoneController/MSI3ZoneController.h b/Controllers/MSI3ZoneController/MSI3ZoneController.h index e3bcf183..d50892b4 100644 --- a/Controllers/MSI3ZoneController/MSI3ZoneController.h +++ b/Controllers/MSI3ZoneController/MSI3ZoneController.h @@ -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 colors); private: char device_name[32]; hid_device* dev; + std::string location; }; diff --git a/Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp b/Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp index 9c05ac8a..9c7890dd 100644 --- a/Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp +++ b/Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp @@ -19,20 +19,32 @@ void DetectMSI3ZoneControllers(std::vector& 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() */ diff --git a/Controllers/MSI3ZoneController/RGBController_MSI3Zone.cpp b/Controllers/MSI3ZoneController/RGBController_MSI3Zone.cpp index 90334490..3c2455d6 100644 --- a/Controllers/MSI3ZoneController/RGBController_MSI3Zone.cpp +++ b/Controllers/MSI3ZoneController/RGBController_MSI3Zone.cpp @@ -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";