From 64dad049f9b19622c0e6753d4f3236b97cd009a3 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Thu, 5 Mar 2020 22:04:30 -0600 Subject: [PATCH] Set endpoint based on Corsair Lighting Node device table --- .../CorsairNodeProController.cpp | 16 +++++++++------- .../CorsairNodeProController.h | 3 ++- .../CorsairNodeProControllerDetect.cpp | 10 +++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Controllers/CorsairNodeProController/CorsairNodeProController.cpp b/Controllers/CorsairNodeProController/CorsairNodeProController.cpp index 3e1aab53..1ca87e01 100644 --- a/Controllers/CorsairNodeProController/CorsairNodeProController.cpp +++ b/Controllers/CorsairNodeProController/CorsairNodeProController.cpp @@ -46,9 +46,11 @@ THREAD keepalive_thread(void *param) THREADRETURN } -CorsairNodeProController::CorsairNodeProController(libusb_device_handle* dev_handle) +CorsairNodeProController::CorsairNodeProController(libusb_device_handle* dev_handle, unsigned int dev_endpoint) { dev = dev_handle; + endpoint = dev_endpoint; + channel_leds[0] = 60; channel_leds[1] = 60; @@ -308,7 +310,7 @@ void CorsairNodeProController::SendDirect /*-----------------------------------------------------*\ | Send packet | \*-----------------------------------------------------*/ - libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0); } void CorsairNodeProController::SendCommit() @@ -330,7 +332,7 @@ void CorsairNodeProController::SendCommit() /*-----------------------------------------------------*\ | Send packet | \*-----------------------------------------------------*/ - libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0); } void CorsairNodeProController::SendBegin @@ -355,7 +357,7 @@ void CorsairNodeProController::SendBegin /*-----------------------------------------------------*\ | Send packet | \*-----------------------------------------------------*/ - libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0); } void CorsairNodeProController::SendEffectConfig @@ -432,7 +434,7 @@ void CorsairNodeProController::SendEffectConfig /*-----------------------------------------------------*\ | Send packet | \*-----------------------------------------------------*/ - libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0); } void CorsairNodeProController::SendTemperature() @@ -462,7 +464,7 @@ void CorsairNodeProController::SendReset /*-----------------------------------------------------*\ | Send packet | \*-----------------------------------------------------*/ - libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0); } void CorsairNodeProController::SendPortState @@ -489,7 +491,7 @@ void CorsairNodeProController::SendPortState /*-----------------------------------------------------*\ | Send packet | \*-----------------------------------------------------*/ - libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0); } void CorsairNodeProController::SendBrightness() diff --git a/Controllers/CorsairNodeProController/CorsairNodeProController.h b/Controllers/CorsairNodeProController/CorsairNodeProController.h index 65962d00..b5045d2a 100644 --- a/Controllers/CorsairNodeProController/CorsairNodeProController.h +++ b/Controllers/CorsairNodeProController/CorsairNodeProController.h @@ -84,7 +84,7 @@ enum class CorsairNodeProController { public: - CorsairNodeProController(libusb_device_handle* dev_handle); + CorsairNodeProController(libusb_device_handle* dev_handle, unsigned int dev_endpoint); ~CorsairNodeProController(); unsigned int GetStripsOnChannel(unsigned int channel); @@ -113,6 +113,7 @@ public: private: libusb_device_handle* dev; + unsigned int endpoint; void SendDirect ( diff --git a/Controllers/CorsairNodeProController/CorsairNodeProControllerDetect.cpp b/Controllers/CorsairNodeProController/CorsairNodeProControllerDetect.cpp index e9221868..2e267970 100644 --- a/Controllers/CorsairNodeProController/CorsairNodeProControllerDetect.cpp +++ b/Controllers/CorsairNodeProController/CorsairNodeProControllerDetect.cpp @@ -23,12 +23,12 @@ typedef struct static const corsair_node_device device_list[6] = { - { CORSAIR_VID, CORSAIR_LIGHTING_NODE_CORE_PID, 0, 1, "Corsair Lighting Node Core" }, - { CORSAIR_VID, CORSAIR_LIGHTING_NODE_PRO_PID, 0, 2, "Corsair Lighting Node Pro" }, + { CORSAIR_VID, CORSAIR_LIGHTING_NODE_CORE_PID, 1, 1, "Corsair Lighting Node Core" }, + { CORSAIR_VID, CORSAIR_LIGHTING_NODE_PRO_PID, 1, 2, "Corsair Lighting Node Pro" }, { CORSAIR_VID, CORSAIR_COMMANDER_PRO_PID, 2, 2, "Corsair Commander Pro" }, - { CORSAIR_VID, CORSAIR_LS100_PID, 0, 1, "Corsair LS100 Lighting Kit" }, + { CORSAIR_VID, CORSAIR_LS100_PID, 1, 1, "Corsair LS100 Lighting Kit" }, { CORSAIR_VID, CORSAIR_1000D_OBSIDIAN_PID, 2, 2, "Corsair 1000D Obsidian" }, - { CORSAIR_VID, CORSAIR_SPEC_OMEGA_RGB_PID, 0, 2, "Corsair SPEC OMEGA RGB" } + { CORSAIR_VID, CORSAIR_SPEC_OMEGA_RGB_PID, 1, 2, "Corsair SPEC OMEGA RGB" } }; @@ -55,7 +55,7 @@ void DetectCorsairNodeProControllers(std::vector &rgb_controller libusb_detach_kernel_driver(dev, 0); libusb_claim_interface(dev, 0); - CorsairNodeProController* controller = new CorsairNodeProController(dev); + CorsairNodeProController* controller = new CorsairNodeProController(dev, device_list[device_idx].usb_endpoint); RGBController_CorsairNodePro* rgb_controller = new RGBController_CorsairNodePro(controller);