Add serial implementation of HYTE CNVS mousemat controller for Windows and leave libusb implementation for Linux
This commit is contained in:
parent
1b7cff78eb
commit
0b787ebb3c
7 changed files with 198 additions and 10 deletions
|
|
@ -0,0 +1,90 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| HYTEMousematController.cpp |
|
||||
| |
|
||||
| Driver for HYTE CNVS RGB mousemat controller |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com), 7/18/2023 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "HYTEMousematController.h"
|
||||
|
||||
HYTEMousematController::HYTEMousematController(char* port)
|
||||
{
|
||||
port_name = port;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Open the port |
|
||||
| Baud rate doesn't matter for ACM device |
|
||||
\*-----------------------------------------------------*/
|
||||
serialport = new serial_port(port_name.c_str(), 2000000);
|
||||
}
|
||||
|
||||
HYTEMousematController::~HYTEMousematController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string HYTEMousematController::GetLocation()
|
||||
{
|
||||
return(port_name);
|
||||
}
|
||||
|
||||
void HYTEMousematController::FirmwareAnimationControl(bool enabled)
|
||||
{
|
||||
unsigned char serial_buf[4];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(serial_buf, 0, sizeof(serial_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Firmware Animation Control packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0] = 0xFF;
|
||||
serial_buf[1] = 0xDC;
|
||||
serial_buf[2] = 0x05;
|
||||
serial_buf[3] = enabled;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serialport->serial_write((char *)serial_buf, sizeof(serial_buf));
|
||||
}
|
||||
|
||||
void HYTEMousematController::StreamingCommand(RGBColor* colors)
|
||||
{
|
||||
unsigned char serial_buf[157];
|
||||
unsigned int max_brightness = 72;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(serial_buf, 0, sizeof(serial_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Streaming packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serial_buf[0] = 0xFF;
|
||||
serial_buf[1] = 0xEE;
|
||||
serial_buf[2] = 0x02;
|
||||
serial_buf[3] = 0x01;
|
||||
serial_buf[4] = 0x00;
|
||||
serial_buf[5] = 0x32;
|
||||
serial_buf[6] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in colors |
|
||||
\*-----------------------------------------------------*/
|
||||
for(unsigned int color_idx = 0; color_idx < 50; color_idx++)
|
||||
{
|
||||
serial_buf[7 + (color_idx * 3)] = ( max_brightness * RGBGetGValue(colors[color_idx]) ) / 100;
|
||||
serial_buf[8 + (color_idx * 3)] = ( max_brightness * RGBGetRValue(colors[color_idx]) ) / 100;
|
||||
serial_buf[9 + (color_idx * 3)] = ( max_brightness * RGBGetBValue(colors[color_idx]) ) / 100;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
serialport->serial_write((char *)serial_buf, sizeof(serial_buf));
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/*---------------------------------------------------------*\
|
||||
| HYTEMousematController.h |
|
||||
| |
|
||||
| Definitions for HYTE CNVS RGB mousemat controller |
|
||||
| |
|
||||
| Adam Honse (calcprogrammer1@gmail.com), 7/18/2023 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "serial_port.h"
|
||||
#include <vector>
|
||||
|
||||
class HYTEMousematController
|
||||
{
|
||||
public:
|
||||
HYTEMousematController(char* port);
|
||||
~HYTEMousematController();
|
||||
|
||||
std::string GetLocation();
|
||||
|
||||
void FirmwareAnimationControl(bool enabled);
|
||||
void StreamingCommand(RGBColor* colors);
|
||||
|
||||
private:
|
||||
std::string port_name;
|
||||
serial_port * serialport = nullptr;
|
||||
};
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
#include "Detector.h"
|
||||
#include "HYTEMousematController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_HYTEMousemat.h"
|
||||
#include "find_usb_serial_port.h"
|
||||
#include <vector>
|
||||
|
||||
#define HYTE_VID 0x3402
|
||||
|
||||
#define HYTE_CNVS_HW_VER_1_PID 0x0B00
|
||||
#define HYTE_CNVS_HW_VER_2_PID 0x0B01
|
||||
|
||||
struct hyte_mousemat_type
|
||||
{
|
||||
unsigned short vid;
|
||||
unsigned short pid;
|
||||
const char * name;
|
||||
};
|
||||
|
||||
#define HYTE_MOUSEMAT_NUM_DEVICES 2
|
||||
|
||||
static const hyte_mousemat_type hyte_mousemat_devices[] =
|
||||
{
|
||||
{ HYTE_VID, HYTE_CNVS_HW_VER_1_PID, "HYTE CNVS" },
|
||||
{ HYTE_VID, HYTE_CNVS_HW_VER_2_PID, "HYTE CNVS" },
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHYTEMousematControllers *
|
||||
* *
|
||||
* Detect devices supported by the HyteMousemat driver *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHYTEMousematControllers()
|
||||
{
|
||||
for(unsigned int device_id = 0; device_id < HYTE_MOUSEMAT_NUM_DEVICES; device_id++)
|
||||
{
|
||||
std::vector<std::string *> ports = find_usb_serial_port(hyte_mousemat_devices[device_id].vid, hyte_mousemat_devices[device_id].pid);
|
||||
|
||||
for(unsigned int i = 0; i < ports.size(); i++)
|
||||
{
|
||||
if(*ports[i] != "")
|
||||
{
|
||||
HYTEMousematController * controller = new HYTEMousematController((char *)ports[i]->c_str());
|
||||
RGBController_HYTEMousemat * rgb_controller = new RGBController_HYTEMousemat(controller);
|
||||
rgb_controller->name = hyte_mousemat_devices[device_id].name;
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
} /* DetectHYTEMousematControllers() */
|
||||
|
||||
REGISTER_DETECTOR("HYTE Mousemat", DetectHYTEMousematControllers);
|
||||
/*---------------------------------------------------------------------------------------------------------*\
|
||||
| Entries for dynamic UDEV rules |
|
||||
| |
|
||||
| DUMMY_DEVICE_DETECTOR("HYTE Mousemat", DetectHYTEMousematControllers, 0x3402, 0x0B00 ) |
|
||||
| DUMMY_DEVICE_DETECTOR("HYTE Mousemat", DetectHYTEMousematControllers, 0x3402, 0x0B01 ) |
|
||||
\*---------------------------------------------------------------------------------------------------------*/
|
||||
27
OpenRGB.pro
27
OpenRGB.pro
|
|
@ -564,8 +564,6 @@ HEADERS +=
|
|||
Controllers/HyperXMouseController/RGBController_HyperXPulsefireRaid.h \
|
||||
Controllers/HyperXMousematController/HyperXMousematController.h \
|
||||
Controllers/HyperXMousematController/RGBController_HyperXMousemat.h \
|
||||
Controllers/HYTEMousematController/HYTEMousematController.h \
|
||||
Controllers/HYTEMousematController/RGBController_HYTEMousemat.h \
|
||||
Controllers/IntelArcA770LEController/IntelArcA770LEController.h \
|
||||
Controllers/IntelArcA770LEController/RGBController_IntelArcA770LE.h \
|
||||
Controllers/IonicoController/IonicoController.h \
|
||||
|
|
@ -1239,9 +1237,6 @@ SOURCES +=
|
|||
Controllers/HyperXMousematController/HyperXMousematController.cpp \
|
||||
Controllers/HyperXMousematController/HyperXMousematControllerDetect.cpp \
|
||||
Controllers/HyperXMousematController/RGBController_HyperXMousemat.cpp \
|
||||
Controllers/HYTEMousematController/HYTEMousematController.cpp \
|
||||
Controllers/HYTEMousematController/HYTEMousematControllerDetect.cpp \
|
||||
Controllers/HYTEMousematController/RGBController_HYTEMousemat.cpp \
|
||||
Controllers/IntelArcA770LEController/IntelArcA770LEController.cpp \
|
||||
Controllers/IntelArcA770LEController/IntelArcA770LEControllerDetect.cpp \
|
||||
Controllers/IonicoController/IonicoController.cpp \
|
||||
|
|
@ -1630,6 +1625,7 @@ win32:INCLUDEPATH +=
|
|||
dependencies/openrazer-win32 \
|
||||
wmi/ \
|
||||
Controllers/AsusTUFLaptopController \
|
||||
Controllers/HYTEMousematController/HYTEMousematController_serial \
|
||||
Controllers/NVIDIAIlluminationController \
|
||||
|
||||
win32:SOURCES += \
|
||||
|
|
@ -1734,6 +1730,9 @@ win32:SOURCES +=
|
|||
Controllers/AsusTUFLaptopController/RGBController_AsusTUFLaptopWMI.cpp \
|
||||
Controllers/ENESMBusController/XPGSpectrixS40GDetect_Windows.cpp \
|
||||
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_SpectrixS40G_Windows.cpp \
|
||||
Controllers/HYTEMousematController/HYTEMousematController_serial/HYTEMousematController.cpp \
|
||||
Controllers/HYTEMousematController/HYTEMousematController_serial/HYTEMousematControllerDetect.cpp \
|
||||
Controllers/HYTEMousematController/RGBController_HYTEMousemat.cpp \
|
||||
Controllers/NVIDIAIlluminationController/nvapi_accessor.cpp \
|
||||
Controllers/NVIDIAIlluminationController/NVIDIAIlluminationV1Controller.cpp \
|
||||
Controllers/NVIDIAIlluminationController/NVIDIAIlluminationControllerDetect.cpp \
|
||||
|
|
@ -1756,6 +1755,8 @@ win32:HEADERS +=
|
|||
Controllers/AsusTUFLaptopController/AsusTUFLaptopController.h \
|
||||
Controllers/AsusTUFLaptopController/RGBController_AsusTUFLaptopWMI.h \
|
||||
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_SpectrixS40G_Windows.h \
|
||||
Controllers/HYTEMousematController/HYTEMousematController_serial/HYTEMousematController.h \
|
||||
Controllers/HYTEMousematController/RGBController_HYTEMousemat.h \
|
||||
Controllers/NVIDIAIlluminationController/nvapi_accessor.h \
|
||||
Controllers/NVIDIAIlluminationController/NVIDIAIlluminationV1Controller.h \
|
||||
Controllers/NVIDIAIlluminationController/RGBController_NVIDIAIllumination.h \
|
||||
|
|
@ -1847,15 +1848,18 @@ contains(QMAKE_PLATFORM, linux) {
|
|||
|
||||
INCLUDEPATH += \
|
||||
Controllers/FaustusController \
|
||||
Controllers/HYTEMousematController/HYTEMousematController_libusb \
|
||||
Controllers/LinuxLEDController \
|
||||
|
||||
HEADERS += \
|
||||
i2c_smbus/i2c_smbus_linux.h \
|
||||
AutoStart/AutoStart-Linux.h \
|
||||
Controllers/AsusTUFLaptopController/AsusTUFLaptopLinuxController.h \
|
||||
Controllers/AsusTUFLaptopController/RGBController_AsusTUFLaptopLinux.h \
|
||||
Controllers/AsusTUFLaptopController/AsusTUFLaptopLinuxController.h \
|
||||
Controllers/AsusTUFLaptopController/RGBController_AsusTUFLaptopLinux.h \
|
||||
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_SpectrixS40G.h \
|
||||
Controllers/FaustusController/RGBController_Faustus.h \
|
||||
Controllers/HYTEMousematController/HYTEMousematController_libusb/HYTEMousematController.h \
|
||||
Controllers/HYTEMousematController/RGBController_HYTEMousemat.h \
|
||||
Controllers/LinuxLEDController/LinuxLEDController.h \
|
||||
Controllers/LinuxLEDController/RGBController_LinuxLED.h \
|
||||
Controllers/OpenRazerController/RGBController_OpenRazer.h \
|
||||
|
|
@ -1903,12 +1907,15 @@ contains(QMAKE_PLATFORM, linux) {
|
|||
scsiapi/scsiapi_linux.c \
|
||||
serial_port/find_usb_serial_port_linux.cpp \
|
||||
AutoStart/AutoStart-Linux.cpp \
|
||||
Controllers/AsusTUFLaptopController/AsusTUFLaptopLinuxController.cpp \
|
||||
Controllers/AsusTUFLaptopController/AsusTUFLaptopLinuxDetect.cpp \
|
||||
Controllers/AsusTUFLaptopController/RGBController_AsusTUFLaptopLinux.cpp \
|
||||
Controllers/AsusTUFLaptopController/AsusTUFLaptopLinuxController.cpp \
|
||||
Controllers/AsusTUFLaptopController/AsusTUFLaptopLinuxDetect.cpp \
|
||||
Controllers/AsusTUFLaptopController/RGBController_AsusTUFLaptopLinux.cpp \
|
||||
Controllers/ENESMBusController/XPGSpectrixS40GDetect.cpp \
|
||||
Controllers/ENESMBusController/ENESMBusInterface/ENESMBusInterface_SpectrixS40G.cpp \
|
||||
Controllers/FaustusController/RGBController_Faustus.cpp \
|
||||
Controllers/HYTEMousematController/HYTEMousematController_libusb/HYTEMousematController.cpp \
|
||||
Controllers/HYTEMousematController/HYTEMousematController_libusb/HYTEMousematControllerDetect.cpp \
|
||||
Controllers/HYTEMousematController/RGBController_HYTEMousemat.cpp \
|
||||
Controllers/LinuxLEDController/LinuxLEDController.cpp \
|
||||
Controllers/LinuxLEDController/LinuxLEDControllerDetect.cpp \
|
||||
Controllers/LinuxLEDController/RGBController_LinuxLED.cpp \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue