From 00cc6978a21dd37dba41bb83b435c038cc9800e0 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Tue, 28 Jul 2020 20:37:12 -0500 Subject: [PATCH] Initial HyperX Pulsefire Surge controller --- .../HyperXMouseControllerDetect.cpp | 7 +- .../HyperXPulsefireSurgeController.cpp | 267 +++++++++++++++++- .../HyperXPulsefireSurgeController.h | 9 +- OpenRGB.cpp | 2 +- .../RGBController_HyperXPulsefireSurge.cpp | 37 ++- 5 files changed, 316 insertions(+), 6 deletions(-) diff --git a/Controllers/HyperXMouseController/HyperXMouseControllerDetect.cpp b/Controllers/HyperXMouseController/HyperXMouseControllerDetect.cpp index cafe70b2..41b2126e 100644 --- a/Controllers/HyperXMouseController/HyperXMouseControllerDetect.cpp +++ b/Controllers/HyperXMouseController/HyperXMouseControllerDetect.cpp @@ -54,7 +54,12 @@ void DetectHyperXMouseControllers(std::vector& rgb_controllers) { if((info->vendor_id == device_list[device_idx].usb_vid) &&(info->product_id == device_list[device_idx].usb_pid) - &&(info->interface_number == device_list[device_idx].usb_interface)) + #ifdef USE_HID_USAGE + &&(info->interface_number == device_list[device_idx].usb_interface) + &&(info->usage_page == 0xFF01)) + #else + &&(info->interface_number == device_list[device_idx].usb_interface)) + #endif { dev = hid_open_path(info->path); diff --git a/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.cpp b/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.cpp index ab2dbacf..cfb13591 100644 --- a/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.cpp +++ b/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.cpp @@ -14,9 +14,274 @@ HyperXPulsefireSurgeController::HyperXPulsefireSurgeController(hid_device* dev_handle) { dev = dev_handle; + + SendWakeup(); } HyperXPulsefireSurgeController::~HyperXPulsefireSurgeController() { -} \ No newline at end of file +} + +/*-------------------------------------------------------------------------------------------------*\ +| Private packet sending functions. | +\*-------------------------------------------------------------------------------------------------*/ + +void HyperXPulsefireSurgeController::SendWakeup() +{ + unsigned char buf[264]; + + /*-----------------------------------------------------*\ + | Zero out buffer | + \*-----------------------------------------------------*/ + memset(buf, 0x00, sizeof(buf)); + + /*-----------------------------------------------------*\ + | Set up Wakeup packet | + \*-----------------------------------------------------*/ + buf[0x00] = 0x07; + buf[0x01] = 0x03; + buf[0x02] = 0x04; + buf[0x03] = 0x01; + buf[0x04] = 0x01; + buf[0x05] = 0x01; + buf[0x06] = 0x03; + + /*-----------------------------------------------------*\ + | Send packet | + \*-----------------------------------------------------*/ + hid_send_feature_report(dev, buf, 264); + + /*-----------------------------------------------------*\ + | Zero out buffer | + \*-----------------------------------------------------*/ + memset(buf, 0x00, sizeof(buf)); + + /*-----------------------------------------------------*\ + | Set up Wakeup packet | + \*-----------------------------------------------------*/ + buf[0x00] = 0x07; + buf[0x01] = 0x04; + buf[0x02] = 0x04; + + buf[0x0B] = 0x02; + buf[0x0C] = 0x02; + buf[0x0D] = 0x02; + buf[0x0E] = 0x0A; + buf[0x0F] = 0x0A; + buf[0x10] = 0x0A; + buf[0x11] = 0x0A; + buf[0x12] = 0x16; + buf[0x13] = 0x16; + buf[0x14] = 0x16; + buf[0x15] = 0x28; + buf[0x16] = 0x28; + buf[0x17] = 0x28; + buf[0x18] = 0x28; + buf[0x19] = 0x3F; + buf[0x1A] = 0x3F; + buf[0x1B] = 0x3F; + buf[0x1C] = 0x3F; + buf[0x1D] = 0x5B; + buf[0x1E] = 0x5B; + buf[0x1F] = 0x5B; + buf[0x20] = 0x5B; + buf[0x21] = 0x5B; + buf[0x22] = 0x7B; + buf[0x23] = 0x7B; + buf[0x24] = 0x7B; + buf[0x25] = 0xA2; + buf[0x26] = 0xA2; + buf[0x27] = 0xA2; + + buf[0x68] = 0xFE; + buf[0x69] = 0xFE; + buf[0x6A] = 0xFE; + buf[0x6B] = 0xFE; + buf[0x6C] = 0xFE; + buf[0x6D] = 0xFE; + buf[0x6E] = 0xFE; + buf[0x6F] = 0xFE; + buf[0x70] = 0xFE; + buf[0x71] = 0xFE; + buf[0x72] = 0xFE; + buf[0x73] = 0xFE; + buf[0x74] = 0xFE; + buf[0x75] = 0xFE; + buf[0x76] = 0xFE; + buf[0x77] = 0xFE; + buf[0x78] = 0xFE; + buf[0x79] = 0xFE; + buf[0x7A] = 0xFE; + buf[0x7B] = 0xFE; + buf[0x7C] = 0xFE; + buf[0x7D] = 0xFE; + buf[0x7E] = 0xFE; + buf[0x7F] = 0xFE; + buf[0x80] = 0xFE; + buf[0x81] = 0xFE; + buf[0x82] = 0xFE; + buf[0x83] = 0xFE; + buf[0x84] = 0xFE; + buf[0x85] = 0xFE; + buf[0x86] = 0xFE; + buf[0x87] = 0xFE; + + buf[0xC9] = 0xFF; + buf[0xCA] = 0x0E; + buf[0xCB] = 0xFF; + buf[0xCC] = 0xFF; + buf[0xCD] = 0x24; + buf[0xCE] = 0xD8; + buf[0xCF] = 0x8D; + buf[0xD0] = 0xFF; + buf[0xD1] = 0xFF; + buf[0xD2] = 0xFF; + buf[0xD4] = 0x0A; + buf[0xD5] = 0xFF; + buf[0xD6] = 0xFF; + + /*-----------------------------------------------------*\ + | Send packet | + \*-----------------------------------------------------*/ + hid_send_feature_report(dev, buf, 264); +} + +void HyperXPulsefireSurgeController::SendData + ( + RGBColor* color_data + ) +{ + unsigned char buf[264]; + + unsigned char dpi_1 = 100; + unsigned char dpi_2 = 100; + unsigned char dpi_3 = 100; + unsigned char effect = 0; + unsigned char dpi_r = 255; + unsigned char dpi_g = 255; + unsigned char dpi_b = 255; + + unsigned char rgb1_r = 255; + unsigned char rgb1_g = 255; + unsigned char rgb1_b = 255; + unsigned char rgb2_r = 255; + unsigned char rgb2_g = 255; + unsigned char rgb2_b = 255; + unsigned char rgb3_r = 255; + unsigned char rgb3_g = 255; + unsigned char rgb3_b = 255; + + /*-----------------------------------------------------*\ + | Zero out buffer | + \*-----------------------------------------------------*/ + memset(buf, 0x00, sizeof(buf)); + + /*-----------------------------------------------------*\ + | Set up Select Profile packet | + \*-----------------------------------------------------*/ + buf[0x00] = 0x07; + buf[0x01] = 0x01; + buf[0x02] = 0x04; + + /*-----------------------------------------------------*\ + | DPI settings | + \*-----------------------------------------------------*/ + buf[0x08] = dpi_1; + buf[0x09] = dpi_1; + buf[0x0A] = dpi_2; + buf[0x0B] = dpi_2; + buf[0x0C] = dpi_3; + buf[0x0D] = dpi_3; + + + buf[0x0E] = 0x80; + buf[0x10] = 0x40; + buf[0x12] = 0x01; + buf[0x13] = 0x08; + + /*-----------------------------------------------------*\ + | DPI settings | + \*-----------------------------------------------------*/ + buf[0x14] = dpi_1; + buf[0x15] = dpi_1; + buf[0x16] = dpi_2; + buf[0x17] = dpi_2; + buf[0x18] = dpi_3; + buf[0x19] = dpi_3; + + buf[0x1A] = 0x80; + buf[0x1C] = 0x40; + buf[0x1D] = 0x01; + buf[0x1E] = 0x08; + + buf[0x20] = 0x01; + buf[0x21] = 0x01; + buf[0x22] = 0x01; + buf[0x25] = 0x02; + buf[0x26] = 0xF0; + buf[0x29] = 0x02; + buf[0x2A] = 0xF1; + buf[0x2D] = 0x02; + buf[0x2E] = 0xF2; + + buf[0x31] = 0x71; + buf[0x32] = 0xF0; + buf[0x35] = 0x02; + buf[0x36] = 0xF9; + buf[0x39] = 0x02; + buf[0x3A] = 0xF8; + buf[0x3D] = 0x02; + buf[0x3E] = 0xF4; + buf[0x41] = 0x02; + buf[0x42] = 0xF3; + + buf[0x4E] = 0x01; + buf[0x50] = 0x01; + + buf[0x51] = effect; + buf[0x52] = 0x03; + buf[0x53] = 0x03; + buf[0x54] = 0x03; + + buf[0x56] = 0x28; + buf[0x58] = 0x28; + buf[0x5A] = 0x28; + buf[0x5C] = 0x28; + buf[0x5D] = 0x28; + buf[0x60] = 0xF0; + buf[0x62] = 0xF0; + + buf[0x64] = dpi_r; + buf[0x65] = dpi_g; + buf[0x66] = dpi_b; + + buf[0x6D] = rgb1_r; + buf[0x70] = rgb1_g; + buf[0x73] = rgb1_b; + + /*-----------------------------------------------------*\ + | Copy in direct color data | + | Red starts at 0x76 | + | Green starts at 0x96 | + | Blue starts at 0xB6 | + \*-----------------------------------------------------*/ + for(int color_idx = 0; color_idx < 0x20; color_idx++) + { + buf[0x76 + color_idx] = RGBGetRValue(color_data[color_idx]); + buf[0x96 + color_idx] = RGBGetGValue(color_data[color_idx]); + buf[0xB6 + color_idx] = RGBGetBValue(color_data[color_idx]); + } + + buf[0xDC] = rgb2_r; + buf[0xDF] = rgb2_g; + buf[0xE2] = rgb2_b; + buf[0xE6] = rgb3_r; + buf[0xE9] = rgb3_g; + buf[0xEC] = rgb3_b; + + /*-----------------------------------------------------*\ + | Send packet | + \*-----------------------------------------------------*/ + hid_send_feature_report(dev, buf, 264); +} diff --git a/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.h b/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.h index ddb50537..9035da2e 100644 --- a/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.h +++ b/Controllers/HyperXMouseController/HyperXPulsefireSurgeController.h @@ -20,6 +20,13 @@ public: HyperXPulsefireSurgeController(hid_device* dev_handle); ~HyperXPulsefireSurgeController(); + void SendData + ( + RGBColor* color_data + ); + private: hid_device* dev; -}; \ No newline at end of file + + void SendWakeup(); +}; diff --git a/OpenRGB.cpp b/OpenRGB.cpp index e04cb1ec..071f9aa0 100644 --- a/OpenRGB.cpp +++ b/OpenRGB.cpp @@ -498,7 +498,7 @@ void DetectRGBControllers(void) DetectMSI3ZoneControllers(rgb_controllers); DetectPoseidonZRGBControllers(rgb_controllers); DetectHyperXKeyboardControllers(rgb_controllers); - //DetectHyperXMouseControllers(rgb_controllers); + DetectHyperXMouseControllers(rgb_controllers); DetectCorsairPeripheralControllers(rgb_controllers); DetectCorsairLightingNodeControllers(rgb_controllers); DetectThermaltakeRiingControllers(rgb_controllers); diff --git a/RGBController/RGBController_HyperXPulsefireSurge.cpp b/RGBController/RGBController_HyperXPulsefireSurge.cpp index 2a0e9f66..a59fce9e 100644 --- a/RGBController/RGBController_HyperXPulsefireSurge.cpp +++ b/RGBController/RGBController_HyperXPulsefireSurge.cpp @@ -17,6 +17,13 @@ RGBController_HyperXPulsefireSurge::RGBController_HyperXPulsefireSurge(HyperXPul type = DEVICE_TYPE_MOUSE; description = "HyperX Pulsefire Surge Device"; + mode Direct; + Direct.name = "Direct"; + Direct.value = 0; + Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; + Direct.color_mode = MODE_COLORS_PER_LED; + modes.push_back(Direct); + SetupZones(); }; @@ -27,6 +34,32 @@ RGBController_HyperXPulsefireSurge::~RGBController_HyperXPulsefireSurge() void RGBController_HyperXPulsefireSurge::SetupZones() { + zone led_strip; + led_strip.name = "LED Strip"; + led_strip.type = ZONE_TYPE_LINEAR; + led_strip.leds_min = 31; + led_strip.leds_max = 31; + led_strip.leds_count = 31; + zones.push_back(led_strip); + + zone logo; + logo.name = "Logo"; + logo.type = ZONE_TYPE_SINGLE; + logo.leds_min = 1; + logo.leds_max = 1; + logo.leds_count = 1; + zones.push_back(logo); + + for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++) + { + for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++) + { + led new_led; + new_led.name = zones[zone_idx].name + " LED"; + leds.push_back(new_led); + } + } + SetupColors(); } @@ -39,7 +72,7 @@ void RGBController_HyperXPulsefireSurge::ResizeZone(int /*zone*/, int /*new_size void RGBController_HyperXPulsefireSurge::DeviceUpdateLEDs() { - + hyperx->SendData(&colors[0]); } void RGBController_HyperXPulsefireSurge::UpdateZoneLEDs(int /*zone*/) @@ -65,4 +98,4 @@ void RGBController_HyperXPulsefireSurge::DeviceUpdateMode() void RGBController_HyperXPulsefireSurge::KeepaliveThread() { -} \ No newline at end of file +}