Add support for Hyperx duocast

This commit is contained in:
morg 2023-03-15 17:37:55 +00:00 committed by Adam Honse
parent bf51d4d82b
commit f579b1cd15
6 changed files with 75 additions and 72 deletions

View file

@ -1,5 +1,5 @@
/*-----------------------------------------*\
| HyperXQuadcastSController.cpp |
| HyperXMicrophoneController.cpp |
| |
| Implementation for the HyperX |
| Quadcast S RGB microphone |
@ -7,11 +7,12 @@
| Matt Silva (thesilvanator) 2022 |
\*-----------------------------------------*/
#include "HyperXQuadcastSController.h"
#include "HyperXMicrophoneController.h"
#include <cstring>
using namespace std::chrono_literals;
HyperXQuadcastSController::HyperXQuadcastSController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, std::string path)
HyperXMicrophoneController::HyperXMicrophoneController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, std::string path)
{
wrapper = hid_wrapper;
dev = dev_handle;
@ -31,7 +32,7 @@ HyperXQuadcastSController::HyperXQuadcastSController(hidapi_wrapper hid_wrapper,
}
}
HyperXQuadcastSController::~HyperXQuadcastSController()
HyperXMicrophoneController::~HyperXMicrophoneController()
{
if(dev)
{
@ -39,17 +40,17 @@ HyperXQuadcastSController::~HyperXQuadcastSController()
}
}
std::string HyperXQuadcastSController::GetDeviceLocation()
std::string HyperXMicrophoneController::GetDeviceLocation()
{
return location;
}
std::string HyperXQuadcastSController::GetSerialString()
std::string HyperXMicrophoneController::GetSerialString()
{
return serial_number;
}
void HyperXQuadcastSController::SaveColors(std::vector<RGBColor> colors, unsigned int num_frames)
void HyperXMicrophoneController::SaveColors(std::vector<RGBColor> colors, unsigned int num_frames)
{
unsigned int num_color_packets = 0;
unsigned int frame = 0;
@ -126,7 +127,7 @@ void HyperXQuadcastSController::SaveColors(std::vector<RGBColor> colors, unsigne
SendDirect(colors);
}
void HyperXQuadcastSController::SendDirect(std::vector<RGBColor> colors)
void HyperXMicrophoneController::SendDirect(std::vector<RGBColor> colors)
{
/*---------------------------------------------------------*\
| Verify colors size |
@ -164,7 +165,7 @@ void HyperXQuadcastSController::SendDirect(std::vector<RGBColor> colors)
lock.unlock();
}
void HyperXQuadcastSController::SendEOT(uint8_t frame_count)
void HyperXMicrophoneController::SendEOT(uint8_t frame_count)
{
uint8_t buffer[HYPERX_QUADCAST_S_PACKET_SIZE];
@ -181,7 +182,7 @@ void HyperXQuadcastSController::SendEOT(uint8_t frame_count)
std::this_thread::sleep_for(15ms);
}
void HyperXQuadcastSController::SendToRegister(uint8_t reg, uint8_t param1, uint8_t param2)
void HyperXMicrophoneController::SendToRegister(uint8_t reg, uint8_t param1, uint8_t param2)
{
uint8_t buffer[HYPERX_QUADCAST_S_PACKET_SIZE];

View file

@ -1,5 +1,5 @@
/*-----------------------------------------*\
| HyperXQuadcastSController.h |
| HyperXMicrophoneController.h |
| |
| Implementation for the HyperX |
| Quadcast S RGB microphone |
@ -10,17 +10,16 @@
#include <string>
#include "hidapi_wrapper.h"
#include "LogManager.h"
#include "RGBController.h"
#define HYPERX_QUADCAST_S_PACKET_SIZE 64 + 1
#define HYPERX_QUADCAST_S_FRAME_SIZE 8
class HyperXQuadcastSController
class HyperXMicrophoneController
{
public:
HyperXQuadcastSController(hidapi_wrapper hid_wrapper, hid_device* dev, std::string path);
~HyperXQuadcastSController();
HyperXMicrophoneController(hidapi_wrapper hid_wrapper, hid_device* dev, std::string path);
~HyperXMicrophoneController();
std::string GetDeviceLocation();
std::string GetSerialString();

View file

@ -1,5 +1,5 @@
/*-----------------------------------------*\
| HyperXQuadcastSControllerDetect.cpp |
| HyperXMicrophoneControllerDetect.cpp |
| |
| Implementation for the HyperX |
| Quadcast S RGB microphone |
@ -8,9 +8,9 @@
\*-----------------------------------------*/
#include "Detector.h"
#include "HyperXQuadcastSController.h"
#include "HyperXMicrophoneController.h"
#include "RGBController.h"
#include "RGBController_HyperXQuadcastS.h"
#include "RGBController_HyperXMicrophone.h"
#include <vector>
#include <LogManager.h>
@ -27,20 +27,23 @@
#define HYPERX_QS_PID_HP_1 0x0F8B
#define HYPERX_QS_PID_HP_2 0x068C
void DetectHyperXQuadcastSControllers(hidapi_wrapper wrapper, hid_device_info* info, const std::string& name)
#define HYPERX_DUOCAST_PID 0x098C
void DetectHyperXMicrophoneControllers(hidapi_wrapper wrapper, hid_device_info* info, const std::string& name)
{
hid_device* dev = wrapper.hid_open_path(info->path);
if(dev)
{
HyperXQuadcastSController* controller = new HyperXQuadcastSController(wrapper, dev, info->path);
RGBController_HyperXQuadcastS *rgb_controller = new RGBController_HyperXQuadcastS(controller);
HyperXMicrophoneController* controller = new HyperXMicrophoneController(wrapper, dev, info->path);
RGBController_HyperXMicrophone *rgb_controller = new RGBController_HyperXMicrophone(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_WRAPPED_DETECTOR_I("HyperX Quadcast S", DetectHyperXQuadcastSControllers, HYPERX_VID, HYPERX_QS_PID, 0);//, 0xFF90, 0xFF00);
REGISTER_HID_WRAPPED_DETECTOR_I("HyperX Quadcast S", DetectHyperXQuadcastSControllers, HYPERX_HP_VID, HYPERX_QS_PID_HP_1, 0);//, 0xFF90, 0xFF00);
REGISTER_HID_WRAPPED_DETECTOR_I("HyperX Quadcast S", DetectHyperXQuadcastSControllers, HYPERX_HP_VID, HYPERX_QS_PID_HP_2, 0);//, 0xFF90, 0xFF00);
REGISTER_HID_WRAPPED_DETECTOR_I("HyperX Quadcast S", DetectHyperXMicrophoneControllers, HYPERX_VID, HYPERX_QS_PID, 0);//, 0xFF90, 0xFF00);
REGISTER_HID_WRAPPED_DETECTOR_I("HyperX Quadcast S", DetectHyperXMicrophoneControllers, HYPERX_HP_VID, HYPERX_QS_PID_HP_1, 0);//, 0xFF90, 0xFF00);
REGISTER_HID_WRAPPED_DETECTOR_I("HyperX Quadcast S", DetectHyperXMicrophoneControllers, HYPERX_HP_VID, HYPERX_QS_PID_HP_2, 0);//, 0xFF90, 0xFF00);
REGISTER_HID_WRAPPED_DETECTOR_I("HyperX DuoCast", DetectHyperXMicrophoneControllers, HYPERX_HP_VID, HYPERX_DUOCAST_PID, 0);//, 0xFF90, 0xFF00);

View file

@ -1,5 +1,5 @@
/*-----------------------------------------*\
| RGBController_HyperXQuadcastS.cpp |
| RGBController_HyperXMicrophone.cpp |
| |
| Implementation for the HyperX |
| Quadcast S RGB microphone |
@ -13,7 +13,7 @@
@save :white_check_mark:
@direct :white_check_mark:
@effects :x:
@detectors DetectHyperXQuadcastSControllers
@detectors DetectHyperXMicrophoneControllers
@comment The HyperX Quadcast S has a manufacturer issue
with the interface it uses (0) for controlling its RGB.
HID requires that any HID interface have at least one
@ -46,37 +46,34 @@
program session.
\*-------------------------------------------------------------------*/
#include "RGBController_HyperXQuadcastS.h"
#include "RGBController_HyperXMicrophone.h"
#include <LogManager.h>
using namespace std::chrono_literals;
RGBController_HyperXQuadcastS::RGBController_HyperXQuadcastS(HyperXQuadcastSController* controller_ptr)
RGBController_HyperXMicrophone::RGBController_HyperXMicrophone(HyperXMicrophoneController* controller_ptr)
{
controller = controller_ptr;
name = "HyperX QuadcastS Device";
vendor = "HyperX";
type = DEVICE_TYPE_MICROPHONE;
description = "HyperX QuadcastS Device";
description = "HyperX Microphone Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";
Direct.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_MANUAL_SAVE;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_MANUAL_SAVE;
Direct.color_mode = MODE_COLORS_PER_LED;
Direct.brightness_min = 0;
Direct.brightness_max = 100;
modes.push_back(Direct);
SetupZones();
keepalive_thread_run = 1;
keepalive_thread = new std::thread(&RGBController_HyperXQuadcastS::KeepaliveThread, this);
keepalive_thread = new std::thread(&RGBController_HyperXMicrophone::KeepaliveThread, this);
};
RGBController_HyperXQuadcastS::~RGBController_HyperXQuadcastS()
RGBController_HyperXMicrophone::~RGBController_HyperXMicrophone()
{
keepalive_thread_run = 0;
keepalive_thread->join();
@ -85,61 +82,64 @@ RGBController_HyperXQuadcastS::~RGBController_HyperXQuadcastS()
delete controller;
}
void RGBController_HyperXQuadcastS::SetupZones()
void RGBController_HyperXMicrophone::SetupZones()
{
led* Top = new led();
led* Bot = new led();
Top->name = std::string("Top");
Top->value = 0;
Bot->name = std::string("Bottom");
Bot->value = 1;
leds.push_back(*Top);
leds.push_back(*Bot);
led Top;
Top.name = "Top";
Top.value = 0;
zone* Mic = new zone();
Mic->name = std::string("Microphone");
Mic->type = ZONE_TYPE_LINEAR;
Mic->leds_min = 2;
Mic->leds_max = 2;
Mic->leds_count = 2;
Mic->matrix_map = NULL;
zones.push_back(*Mic);
led Bot;
Bot.name = "Bottom";
Bot.value = 1;
leds.push_back(Top);
leds.push_back(Bot);
zone Mic;
Mic.name = "Microphone";
Mic.type = ZONE_TYPE_LINEAR;
Mic.leds_min = 2;
Mic.leds_max = 2;
Mic.leds_count = 2;
Mic.matrix_map = nullptr;
zones.push_back(Mic);
SetupColors();
}
void RGBController_HyperXQuadcastS::ResizeZone(int /*zone*/, int /*new_size*/)
void RGBController_HyperXMicrophone::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HyperXQuadcastS::DeviceUpdateLEDs()
void RGBController_HyperXMicrophone::DeviceUpdateLEDs()
{
last_update_time = std::chrono::steady_clock::now();
controller->SendDirect(colors);
}
void RGBController_HyperXQuadcastS::UpdateZoneLEDs(int /*zone*/)
void RGBController_HyperXMicrophone::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXQuadcastS::UpdateSingleLED(int /*led*/)
void RGBController_HyperXMicrophone::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_HyperXQuadcastS::DeviceUpdateMode()
void RGBController_HyperXMicrophone::DeviceUpdateMode()
{
DeviceUpdateLEDs();
}
void RGBController_HyperXQuadcastS::DeviceSaveMode()
void RGBController_HyperXMicrophone::DeviceSaveMode()
{
LOG_DEBUG("[%s] Saving current direct colors to device", name.c_str());
controller->SaveColors(colors,1);
controller->SaveColors(colors, 1);
}
void RGBController_HyperXQuadcastS::KeepaliveThread()
void RGBController_HyperXMicrophone::KeepaliveThread()
{
while(keepalive_thread_run.load())
{

View file

@ -1,5 +1,5 @@
/*-----------------------------------------*\
| RGBController_HyperXQuadcastS.h |
| RGBController_HyperXMicrophone.h |
| |
| Implementation for the HyperX |
| Quadcast S RGB microphone |
@ -11,13 +11,13 @@
#include <chrono>
#include "RGBController.h"
#include "HyperXQuadcastSController.h"
#include "HyperXMicrophoneController.h"
class RGBController_HyperXQuadcastS : public RGBController
class RGBController_HyperXMicrophone : public RGBController
{
public:
RGBController_HyperXQuadcastS(HyperXQuadcastSController* controller_ptr);
~RGBController_HyperXQuadcastS();
RGBController_HyperXMicrophone(HyperXMicrophoneController* controller_ptr);
~RGBController_HyperXMicrophone();
void SetupZones();
@ -33,7 +33,7 @@ public:
void KeepaliveThread();
private:
HyperXQuadcastSController* controller;
HyperXMicrophoneController* controller;
std::thread* keepalive_thread;
std::atomic<bool> keepalive_thread_run;
std::chrono::time_point<std::chrono::steady_clock> last_update_time;

View file

@ -133,9 +133,9 @@ INCLUDEPATH +=
Controllers/HPOmen30LController/ \
Controllers/HyperXDRAMController/ \
Controllers/HyperXKeyboardController/ \
Controllers/HyperXMicrophoneController/ \
Controllers/HyperXMouseController/ \
Controllers/HyperXMousematController/ \
Controllers/HyperXQuadcastController/ \
Controllers/IntelArcA770LEController/ \
Controllers/IonicoController/ \
Controllers/LEDStripController/ \
@ -455,6 +455,8 @@ HEADERS +=
Controllers/HyperXKeyboardController/RGBController_HyperXAlloyOrigins.h \
Controllers/HyperXKeyboardController/RGBController_HyperXAlloyOrigins60.h \
Controllers/HyperXKeyboardController/RGBController_HyperXAlloyOriginsCore.h \
Controllers/HyperXMicrophoneController/HyperXMicrophoneController.h \
Controllers/HyperXMicrophoneController/RGBController_HyperXMicrophone.h \
Controllers/HyperXMouseController/HyperXPulsefireFPSProController.h \
Controllers/HyperXMouseController/HyperXPulsefireHasteController.h \
Controllers/HyperXMouseController/HyperXPulsefireSurgeController.h \
@ -467,8 +469,6 @@ HEADERS +=
Controllers/HyperXMouseController/RGBController_HyperXPulsefireRaid.h \
Controllers/HyperXMousematController/HyperXMousematController.h \
Controllers/HyperXMousematController/RGBController_HyperXMousemat.h \
Controllers/HyperXQuadcastController/HyperXQuadcastSController.h \
Controllers/HyperXQuadcastController/RGBController_HyperXQuadcastS.h \
Controllers/IntelArcA770LEController/IntelArcA770LEController.h \
Controllers/IntelArcA770LEController/RGBController_IntelArcA770LE.h \
Controllers/IonicoController/IonicoController.h \
@ -1049,6 +1049,9 @@ SOURCES +=
Controllers/HyperXKeyboardController/RGBController_HyperXAlloyOrigins.cpp \
Controllers/HyperXKeyboardController/RGBController_HyperXAlloyOrigins60.cpp \
Controllers/HyperXKeyboardController/RGBController_HyperXAlloyOriginsCore.cpp \
Controllers/HyperXMicrophoneController/HyperXMicrophoneController.cpp \
Controllers/HyperXMicrophoneController/HyperXMicrophoneControllerDetect.cpp \
Controllers/HyperXMicrophoneController/RGBController_HyperXMicrophone.cpp \
Controllers/HyperXMouseController/HyperXMouseControllerDetect.cpp \
Controllers/HyperXMouseController/HyperXPulsefireFPSProController.cpp \
Controllers/HyperXMouseController/HyperXPulsefireHasteController.cpp \
@ -1063,9 +1066,6 @@ SOURCES +=
Controllers/HyperXMousematController/HyperXMousematController.cpp \
Controllers/HyperXMousematController/HyperXMousematControllerDetect.cpp \
Controllers/HyperXMousematController/RGBController_HyperXMousemat.cpp \
Controllers/HyperXQuadcastController/HyperXQuadcastSController.cpp \
Controllers/HyperXQuadcastController/HyperXQuadcastSControllerDetect.cpp \
Controllers/HyperXQuadcastController/RGBController_HyperXQuadcastS.cpp \
Controllers/IntelArcA770LEController/IntelArcA770LEController.cpp \
Controllers/IntelArcA770LEController/IntelArcA770LEControllerDetect.cpp \
Controllers/IonicoController/IonicoController.cpp \