From d6350c8504d20874c71bc07a2ef2e2a640a905fd Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Fri, 2 Oct 2020 12:28:09 -0500 Subject: [PATCH] Use HID path for Location on HyperX Keyboard controller --- .../HyperXKeyboardController.cpp | 10 ++++++++-- .../HyperXKeyboardController.h | 5 ++++- .../HyperXKeyboardControllerDetect.cpp | 2 +- .../RGBController_HyperXKeyboard.cpp | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp b/Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp index 18082f39..c06f1935 100644 --- a/Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp +++ b/Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp @@ -27,9 +27,10 @@ static unsigned int extended_red[] = {0x08, 0x48, 0x88, 0x09, 0x89, 0x0A, 0x8A, static unsigned int extended_grn[] = {0x29, 0x28, 0x78, 0x19, 0x79, 0x1A, 0x7A, 0x1B, 0x7B, 0x1C, 0x7C, 0x1D, 0x7D, 0x1E, 0x6E, 0x7E, 0x1F, 0x6F, 0x82, 0x23, 0x83, 0x22 }; static unsigned int extended_blu[] = {0x39, 0x38, 0x68, 0x3A, 0x69, 0x2A, 0x6A, 0x2B, 0x6B, 0x2C, 0x6C, 0x2D, 0x6D, 0x2E, 0x5E, 0x5D, 0x2F, 0x5F, 0x72, 0x33, 0x73, 0x32 }; -HyperXKeyboardController::HyperXKeyboardController(hid_device* dev_handle) +HyperXKeyboardController::HyperXKeyboardController(hid_device* dev_handle, const char* path) { - dev = dev_handle; + dev = dev_handle; + location = path; } HyperXKeyboardController::~HyperXKeyboardController() @@ -37,6 +38,11 @@ HyperXKeyboardController::~HyperXKeyboardController() } +std::string HyperXKeyboardController::GetDeviceLocation() +{ + return(location); +} + void HyperXKeyboardController::SetMode ( unsigned char mode, diff --git a/Controllers/HyperXKeyboardController/HyperXKeyboardController.h b/Controllers/HyperXKeyboardController/HyperXKeyboardController.h index 0176a2ea..5110e2a4 100644 --- a/Controllers/HyperXKeyboardController/HyperXKeyboardController.h +++ b/Controllers/HyperXKeyboardController/HyperXKeyboardController.h @@ -65,9 +65,11 @@ enum class HyperXKeyboardController { public: - HyperXKeyboardController(hid_device* dev_handle); + HyperXKeyboardController(hid_device* dev_handle, const char* path); ~HyperXKeyboardController(); + std::string GetDeviceLocation(); + void SetMode ( unsigned char mode, @@ -84,6 +86,7 @@ private: unsigned char active_mode; unsigned char active_direction; unsigned char active_speed; + std::string location; void SelectProfile ( diff --git a/Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp b/Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp index 51547015..00eaa2b9 100644 --- a/Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp +++ b/Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp @@ -75,7 +75,7 @@ void DetectHyperXKeyboardControllers(std::vector& rgb_controller if( dev ) { - HyperXKeyboardController* controller = new HyperXKeyboardController(dev); + HyperXKeyboardController* controller = new HyperXKeyboardController(dev, info->path); RGBController_HyperXKeyboard* rgb_controller = new RGBController_HyperXKeyboard(controller); diff --git a/Controllers/HyperXKeyboardController/RGBController_HyperXKeyboard.cpp b/Controllers/HyperXKeyboardController/RGBController_HyperXKeyboard.cpp index b4c9a390..8bb72739 100644 --- a/Controllers/HyperXKeyboardController/RGBController_HyperXKeyboard.cpp +++ b/Controllers/HyperXKeyboardController/RGBController_HyperXKeyboard.cpp @@ -182,6 +182,7 @@ RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardControl name = "HyperX RGB Keyboard"; type = DEVICE_TYPE_KEYBOARD; description = "HyperX RGB Keyboard Device"; + location = hyperx->GetDeviceLocation(); mode Direct; Direct.name = "Direct";