diff --git a/Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp b/Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp new file mode 100644 index 00000000..12739844 --- /dev/null +++ b/Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp @@ -0,0 +1,118 @@ +/*-----------------------------------------*\ +| AMDWraithPrismController.h | +| | +| Driver for AMD Wraith Prism RGB lighting | +| controller | +| | +| Adam Honse (CalcProgrammer1) 12/6/2019 | +\*-----------------------------------------*/ + +#include "AMDWraithPrismController.h" +#include +#include +#include + +AMDWraithPrismController::AMDWraithPrismController(libusb_device_handle* dev_handle) +{ + dev = dev_handle; + + strcpy(device_name, "AMD Wraith Prism"); + + SendEnableCommand(); + SendRemapCommand(); + SendEffectCommand(); +} + +AMDWraithPrismController::~AMDWraithPrismController() +{ + +} + +char* AMDWraithPrismController::GetDeviceName() +{ + return device_name; +} + +void AMDWraithPrismController::SendEnableCommand() +{ + unsigned char usb_buf[] = + { + 0x41, 0x80, 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; + + libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0); +} + +void AMDWraithPrismController::SendRemapCommand() +{ + unsigned char usb_buf[] = + { + 0x51, 0xA0, 0x01, 0x00, + 0x00, 0x03, 0x00, 0x00, + 0x05, 0x06, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, + 0x07, 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; + + libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0); +} + +void AMDWraithPrismController::SendEffectCommand() +{ + 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; + + libusb_interrupt_transfer(dev, 0x04, usb_buf, 64, &actual, 0); + libusb_interrupt_transfer(dev, 0x83, usb_buf, 64, &actual, 0); +} diff --git a/Controllers/AMDWraithPrismController/AMDWraithPrismController.h b/Controllers/AMDWraithPrismController/AMDWraithPrismController.h new file mode 100644 index 00000000..a9c72dba --- /dev/null +++ b/Controllers/AMDWraithPrismController/AMDWraithPrismController.h @@ -0,0 +1,27 @@ +/*-----------------------------------------*\ +| AMDWraithPrismController.h | +| | +| Definitions and types for AMD Wraith | +| Prism lighting controller | +| | +| Adam Honse (CalcProgrammer1) 12/6/2019 | +\*-----------------------------------------*/ + +#include + +class AMDWraithPrismController +{ +public: + AMDWraithPrismController(libusb_device_handle* dev_handle); + ~AMDWraithPrismController(); + + char* GetDeviceName(); + + void SendEnableCommand(); + void SendRemapCommand(); + void SendEffectCommand(); + +private: + char device_name[32]; + libusb_device_handle* dev; +}; diff --git a/Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp b/Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp new file mode 100644 index 00000000..7d5cbf2e --- /dev/null +++ b/Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp @@ -0,0 +1,33 @@ +#include "AMDWraithPrismController.h" +#include "RGBController.h" +//#include "RGBController_AMDWraithPrism.h" +#include +#include + +#define AMD_WRAITH_PRISM_VID 0x2516 +#define AMD_WRAITH_PRISM_PID 0x0051 + +/******************************************************************************************\ +* * +* DetectAMDWraithPrismControllers * +* * +* Tests the USB address to see if an AMD Wraith Prism controller exists there. * +* * +\******************************************************************************************/ + +void DetectAMDWraithPrismControllers(std::vector& rgb_controllers) +{ + libusb_context * ctx; + libusb_init(&ctx); + + //Look for AMD Wraith Prism + libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, AMD_WRAITH_PRISM_VID, AMD_WRAITH_PRISM_PID); + + if( dev ) + { + libusb_detach_kernel_driver(dev, 1); + libusb_claim_interface(dev, 1); + + AMDWraithPrismController* controller = new AMDWraithPrismController(dev); + } +} diff --git a/OpenAuraSDK.cpp b/OpenAuraSDK.cpp index 0c4ab82c..9e948132 100644 --- a/OpenAuraSDK.cpp +++ b/OpenAuraSDK.cpp @@ -363,6 +363,7 @@ void DetectHuePlusControllers(std::vector &rgb_controllers); void DetectOpenRazerControllers(std::vector &rgb_controllers); void DetectRazerChromaSDKControllers(std::vector& rgb_controllers); void DetectE131Controllers(std::vector &rgb_controllers); +void DetectAMDWraithPrismControllers(std::vector& rgb_controllers); /******************************************************************************************\ * * @@ -384,6 +385,9 @@ void DetectRGBControllers(void) DetectLEDStripControllers(rgb_controllers); DetectHuePlusControllers(rgb_controllers); + + DetectAMDWraithPrismControllers(rgb_controllers); + #ifdef WIN32 DetectRazerChromaSDKControllers(rgb_controllers); #else diff --git a/OpenRGB.pro b/OpenRGB.pro index c02a6819..83ab87c3 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -1,5 +1,7 @@ QT += core gui +LIBS += -lusb-1.0 + greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = OpenRGB @@ -10,6 +12,7 @@ INCLUDEPATH += \ i2c_tools/ \ net_port/ \ serial_port/ \ + Controllers/AMDWraithPrismController/ \ Controllers/AuraController/ \ Controllers/CorsairController/ \ Controllers/CorsairProController/ \ @@ -34,6 +37,8 @@ SOURCES += \ qt/OpenRGBSystemInfoPage.cpp \ qt/hsv.cpp \ serial_port/serial_port.cpp \ + Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp \ + Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \ Controllers/AuraController/AuraController.cpp \ Controllers/AuraController/AuraControllerDetect.cpp \ Controllers/CorsairController/CorsairController.cpp \ @@ -68,6 +73,7 @@ HEADERS += \ qt/OpenRGBDialog2.h \ qt/OpenRGBSystemInfoPage.h \ serial_port/serial_port.h \ + Controllers/AMDWraithPrismController/AMDWraithPrismController.h \ Controllers/AuraController/AuraController.h \ Controllers/CorsairController/CorsairController.h \ Controllers/CorsairProController/CorsairProController.h \