From b35c900fae695dc9eb2ece882e71f9d1e29efc0f Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Tue, 24 Dec 2019 14:56:49 -0600 Subject: [PATCH] Add function to get effect string for a channel --- .../AMDWraithPrismController.cpp | 115 +++++++++++++++++- .../AMDWraithPrismController.h | 6 + 2 files changed, 120 insertions(+), 1 deletion(-) diff --git a/Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp b/Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp index 12739844..b9409871 100644 --- a/Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp +++ b/Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp @@ -12,6 +12,17 @@ #include #include +#ifdef WIN32 +#include +#else +#include + +static void Sleep(unsigned int milliseconds) +{ + usleep(1000 * milliseconds); +} +#endif + AMDWraithPrismController::AMDWraithPrismController(libusb_device_handle* dev_handle) { dev = dev_handle; @@ -20,7 +31,9 @@ AMDWraithPrismController::AMDWraithPrismController(libusb_device_handle* dev_han SendEnableCommand(); SendRemapCommand(); - SendEffectCommand(); + //SendEffectCommand(); + SetFanColor(0xFF, 0x00, 0xFF); + SetLogoColor(0x00, 0xFF, 0xFF); } AMDWraithPrismController::~AMDWraithPrismController() @@ -33,6 +46,106 @@ char* AMDWraithPrismController::GetDeviceName() return device_name; } +std::string AMDWraithPrismController::GetEffectChannelString(unsigned char channel) +{ + std::string ret_string = ""; + + unsigned char usb_buf[] = + { + 0x40, 0x21, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, + }; + + int actual; + + usb_buf[0x02] = channel; + + libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0); + + ret_string.append((char *)&usb_buf[0x08]); + + return(ret_string); +} + +void AMDWraithPrismController::SetFanColor(unsigned char red, unsigned char green, unsigned char blue) +{ + unsigned char usb_buf[] = + { + 0x51, 0x2C, 0x01, 0x00, + 0x06, 0xFF, 0x00, 0x01, + 0xFF, 0xFF, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF + }; + + int actual; + + usb_buf[0x0A] = red; + usb_buf[0x0B] = green; + usb_buf[0x0C] = blue; + + libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0); +} + +void AMDWraithPrismController::SetLogoColor(unsigned char red, unsigned char green, unsigned char blue) +{ + unsigned char usb_buf[] = + { + 0x51, 0x2C, 0x01, 0x00, + 0x05, 0xFF, 0x00, 0x01, + 0xFF, 0xFF, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF + }; + + int actual; + + usb_buf[0x0A] = red; + usb_buf[0x0B] = green; + usb_buf[0x0C] = blue; + + libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0); +} + void AMDWraithPrismController::SendEnableCommand() { unsigned char usb_buf[] = diff --git a/Controllers/AMDWraithPrismController/AMDWraithPrismController.h b/Controllers/AMDWraithPrismController/AMDWraithPrismController.h index a9c72dba..097e1f02 100644 --- a/Controllers/AMDWraithPrismController/AMDWraithPrismController.h +++ b/Controllers/AMDWraithPrismController/AMDWraithPrismController.h @@ -7,6 +7,7 @@ | Adam Honse (CalcProgrammer1) 12/6/2019 | \*-----------------------------------------*/ +#include #include class AMDWraithPrismController @@ -17,6 +18,11 @@ public: char* GetDeviceName(); + std::string GetEffectChannelString(unsigned char channel); + + void SetFanColor(unsigned char red, unsigned char green, unsigned char blue); + void SetLogoColor(unsigned char red, unsigned char green, unsigned char blue); + void SendEnableCommand(); void SendRemapCommand(); void SendEffectCommand();