Publish curated LumaOps source from c85ee9ef8f1454f5c305398902afbb9e6738de40
Managed validation / full (push) Failing after 8s
Managed validation / full (push) Failing after 8s
This commit is contained in:
1 parent
91f8b3e3c1
commit
def7920856
2271 files changed
+501225
-501178
No files matched your search
@@ -1,53 +1,53 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| CougarControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Cougar devices |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "RGBController_CougarKeyboard.h"
|
||||
#include "RGBController_CougarRevengerST.h"
|
||||
|
||||
/*----------------------------------------------------------*\
|
||||
| Cougar vendor ID |
|
||||
\*----------------------------------------------------------*/
|
||||
#define COUGAR_VID 0x12CF
|
||||
#define COUGAR_VID_2 0x060B
|
||||
|
||||
/*----------------------------------------------------------*\
|
||||
| Product ID |
|
||||
\*----------------------------------------------------------*/
|
||||
#define COUGAR_700K_EVO_PID 0x7010
|
||||
#define COUGAR_REVENGER_ST_PID 0x0412
|
||||
|
||||
void DetectCougarRevengerSTControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
CougarRevengerSTController* controller = new CougarRevengerSTController(dev, *info, name);
|
||||
RGBController_CougarRevengerST* rgb_controller = new RGBController_CougarRevengerST(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void DetectCougar700kEvo(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if (dev)
|
||||
{
|
||||
CougarKeyboardController* controller = new CougarKeyboardController(dev, info->path, name);
|
||||
RGBController_CougarKeyboard* rgb_controller = new RGBController_CougarKeyboard(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU("Cougar 700K EVO Gaming Keyboard", DetectCougar700kEvo, COUGAR_VID_2, COUGAR_700K_EVO_PID, 3, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_IPU("Cougar Revenger ST", DetectCougarRevengerSTControllers, COUGAR_VID, COUGAR_REVENGER_ST_PID, 0, 0x0001, 2);
|
||||
/*---------------------------------------------------------*\
|
||||
| CougarControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Cougar devices |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "RGBController_CougarKeyboard.h"
|
||||
#include "RGBController_CougarRevengerST.h"
|
||||
|
||||
/*----------------------------------------------------------*\
|
||||
| Cougar vendor ID |
|
||||
\*----------------------------------------------------------*/
|
||||
#define COUGAR_VID 0x12CF
|
||||
#define COUGAR_VID_2 0x060B
|
||||
|
||||
/*----------------------------------------------------------*\
|
||||
| Product ID |
|
||||
\*----------------------------------------------------------*/
|
||||
#define COUGAR_700K_EVO_PID 0x7010
|
||||
#define COUGAR_REVENGER_ST_PID 0x0412
|
||||
|
||||
void DetectCougarRevengerSTControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
CougarRevengerSTController* controller = new CougarRevengerSTController(dev, *info, name);
|
||||
RGBController_CougarRevengerST* rgb_controller = new RGBController_CougarRevengerST(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
void DetectCougar700kEvo(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if (dev)
|
||||
{
|
||||
CougarKeyboardController* controller = new CougarKeyboardController(dev, info->path, name);
|
||||
RGBController_CougarKeyboard* rgb_controller = new RGBController_CougarKeyboard(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU("Cougar 700K EVO Gaming Keyboard", DetectCougar700kEvo, COUGAR_VID_2, COUGAR_700K_EVO_PID, 3, 0xFF00, 1);
|
||||
REGISTER_HID_DETECTOR_IPU("Cougar Revenger ST", DetectCougarRevengerSTControllers, COUGAR_VID, COUGAR_REVENGER_ST_PID, 0, 0x0001, 2);
|
||||
+216
-216
@@ -1,216 +1,216 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| CougarKeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Cougar keyboard |
|
||||
| |
|
||||
| Chris M (DrNo) 05 Apr 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "CougarKeyboardController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static uint8_t keyvalue_map[113] =
|
||||
{
|
||||
/*00 ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 */
|
||||
0, 9, 18, 27, 36, 45, 54, 63, 72, 81,
|
||||
|
||||
/*10 F10 F11 F12 PRT SLK PBK PLY VDN VUP MTE */
|
||||
90, 99, 108, 117, 126, 15, 135, 140, 141, 142,
|
||||
|
||||
/*20 ` 1 2 3 4 5 6 7 8 9 */
|
||||
1, 10, 19, 28, 37, 46, 55, 64, 73, 82,
|
||||
|
||||
/*30 0 - = BSP INS HME PUP NLK NM/ NM* */
|
||||
91, 100, 109, 127, 128, 24, 33, 42, 51, 60,
|
||||
|
||||
/*40 NM- TAB Q W E R T Y U I */
|
||||
69, 2, 11, 20, 29, 38, 47, 56, 65, 74,
|
||||
|
||||
/*50 O P [ ] \ DEL END PDN NM7 NM8 */
|
||||
83, 92, 101, 110, 119, 129, 78, 87, 96, 105,
|
||||
|
||||
/*60 NM9 NM+ CAP A S D F G H J */
|
||||
16, 25, 3, 12, 21, 30, 39, 48, 57, 66,
|
||||
|
||||
/*70 K L ; ' ENT NM4 NM5 NM6 LSH Z */
|
||||
75, 84, 93, 102, 120, 34, 43, 52, 4, 22,
|
||||
|
||||
/*80 X C V B N M , . / RSH */
|
||||
31, 40, 49, 58, 67, 76, 85, 94, 103, 121,
|
||||
|
||||
/*90 UP NM1 NM2 NM3 NETR LCTL LWIN LALT SPC RALT */
|
||||
130, 70, 79, 88, 106, 5, 14, 23, 50, 86,
|
||||
|
||||
/*100 RWIN RFNC RCTL LFT DWN RGT NM0 NM. G1 G2 */
|
||||
95, 104, 113, 122, 131, 132, 133, 97, 147, 148,
|
||||
|
||||
/*110 G3 G4 G5 */
|
||||
149, 150, 151
|
||||
};
|
||||
|
||||
CougarKeyboardController::CougarKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
CougarKeyboardController::~CougarKeyboardController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string CougarKeyboardController::GetDeviceName()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string CougarKeyboardController::GetSerial()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
std::string CougarKeyboardController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
void CougarKeyboardController::SetMode(uint8_t mode, uint8_t speed, uint8_t brightness, uint8_t direction, std::vector<RGBColor> colours, bool random_colours)
|
||||
{
|
||||
uint8_t buffer[COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE] = { 0x00, 0x14, 0x2C };
|
||||
|
||||
buffer[COUGARKEYBOARDCONTROLLER_MODE_BYTE] = mode;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_SPEED_BYTE] = speed;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_BRIGHTNESS_BYTE] = brightness;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_RANDOM_BYTE] = (random_colours) ? 1 : 0;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DIRECTION_BYTE] = direction;
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Off mode does not need any further settings & should |
|
||||
| skip the default case to avoid an indexing error |
|
||||
\*-----------------------------------------------------*/
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_OFF:
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Spectrum Cycle mode (Circle) always sets random |
|
||||
\*-----------------------------------------------------*/
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_CIRCLE:
|
||||
buffer[COUGARKEYBOARDCONTROLLER_RANDOM_BYTE] = 1;
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Wave mode does not have a true "random" colour and |
|
||||
| needs to set the "rainbow" mode (val = 2) instead |
|
||||
\*-----------------------------------------------------*/
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_WAVE:
|
||||
buffer[COUGARKEYBOARDCONTROLLER_RANDOM_BYTE] = (random_colours) ? 2 : 0;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DATA_BYTE] = 2;
|
||||
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_RIPPLE:
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_SCAN:
|
||||
{
|
||||
uint8_t count = (uint8_t)colours.size();
|
||||
uint8_t timer = 100 / count;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DATA_BYTE + 1] = count;
|
||||
|
||||
for(uint8_t i = 0; i < count; i++)
|
||||
{
|
||||
uint8_t offset = 11 + (i * 4);
|
||||
|
||||
buffer[offset] = (i + 1) * timer;
|
||||
buffer[offset + 1] = RGBGetRValue(colours[i]);
|
||||
buffer[offset + 2] = RGBGetGValue(colours[i]);
|
||||
buffer[offset + 3] = RGBGetBValue(colours[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_RHYTHM:
|
||||
buffer[COUGARKEYBOARDCONTROLLER_RANDOM_BYTE] = (random_colours) ? 2 : 0;
|
||||
|
||||
default:
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DATA_BYTE + 1] = RGBGetRValue(colours[0]);
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DATA_BYTE + 2] = RGBGetGValue(colours[0]);
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DATA_BYTE + 3] = RGBGetBValue(colours[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
hid_write(dev, buffer, COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE);
|
||||
}
|
||||
|
||||
void CougarKeyboardController::SetLedsDirect(std::vector<RGBColor> colours)
|
||||
{
|
||||
uint8_t max_leds = 14;
|
||||
uint8_t leds_remaining = (uint8_t)colours.size();
|
||||
uint8_t packet_flag = COUGARKEYBOARDCONTROLLER_DIRECTION_BYTE;
|
||||
uint8_t buffer[COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE] = { 0x00, 0x14, 0x2C, 0x0B, 0x00, 0xFF, 0x64, 0x00, 0x01 };
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Set up Direct packet |
|
||||
| keyvalue_map is the index of the Key from full_matrix_map |
|
||||
\*-----------------------------------------------------------------*/
|
||||
for(uint8_t leds2send = 0; leds2send < leds_remaining; leds2send += max_leds)
|
||||
{
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Check if there is enough leds for another pass |
|
||||
\*-----------------------------------------------------------------*/
|
||||
if(leds2send + max_leds > leds_remaining)
|
||||
{
|
||||
max_leds = leds_remaining - leds2send;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| The last packet flag should be 0x03 |
|
||||
\*-----------------------------------------------------------------*/
|
||||
buffer[packet_flag] = 3;
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < max_leds; i++)
|
||||
{
|
||||
uint8_t offset = COUGARKEYBOARDCONTROLLER_DATA_BYTE + (i * 4);
|
||||
uint8_t led_num = leds2send + i;
|
||||
|
||||
buffer[offset] = keyvalue_map[led_num];
|
||||
buffer[offset + 1] = RGBGetRValue(colours[led_num]);
|
||||
buffer[offset + 2] = RGBGetGValue(colours[led_num]);
|
||||
buffer[offset + 3] = RGBGetBValue(colours[led_num]);
|
||||
}
|
||||
hid_write(dev, buffer, COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| After the first packet the packet flag should be 0x02 |
|
||||
\*-----------------------------------------------------------------*/
|
||||
buffer[packet_flag] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void CougarKeyboardController::Save(uint8_t flag)
|
||||
{
|
||||
uint8_t buffer[COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE] = { 0x00, 0x12, flag, 0x00, 0x00 };
|
||||
|
||||
hid_write(dev, buffer, COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE);
|
||||
}
|
||||
|
||||
void CougarKeyboardController::SendProfile(uint8_t profile, uint8_t light)
|
||||
{
|
||||
uint8_t buffer[COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE] = { 0x00, 0x14, 0x00, 0x00, 0x00, profile, light, 0x00, 0x00};
|
||||
|
||||
hid_write(dev, buffer, COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE);
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| CougarKeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Cougar keyboard |
|
||||
| |
|
||||
| Chris M (DrNo) 05 Apr 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "CougarKeyboardController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static uint8_t keyvalue_map[113] =
|
||||
{
|
||||
/*00 ESC F1 F2 F3 F4 F5 F6 F7 F8 F9 */
|
||||
0, 9, 18, 27, 36, 45, 54, 63, 72, 81,
|
||||
|
||||
/*10 F10 F11 F12 PRT SLK PBK PLY VDN VUP MTE */
|
||||
90, 99, 108, 117, 126, 15, 135, 140, 141, 142,
|
||||
|
||||
/*20 ` 1 2 3 4 5 6 7 8 9 */
|
||||
1, 10, 19, 28, 37, 46, 55, 64, 73, 82,
|
||||
|
||||
/*30 0 - = BSP INS HME PUP NLK NM/ NM* */
|
||||
91, 100, 109, 127, 128, 24, 33, 42, 51, 60,
|
||||
|
||||
/*40 NM- TAB Q W E R T Y U I */
|
||||
69, 2, 11, 20, 29, 38, 47, 56, 65, 74,
|
||||
|
||||
/*50 O P [ ] \ DEL END PDN NM7 NM8 */
|
||||
83, 92, 101, 110, 119, 129, 78, 87, 96, 105,
|
||||
|
||||
/*60 NM9 NM+ CAP A S D F G H J */
|
||||
16, 25, 3, 12, 21, 30, 39, 48, 57, 66,
|
||||
|
||||
/*70 K L ; ' ENT NM4 NM5 NM6 LSH Z */
|
||||
75, 84, 93, 102, 120, 34, 43, 52, 4, 22,
|
||||
|
||||
/*80 X C V B N M , . / RSH */
|
||||
31, 40, 49, 58, 67, 76, 85, 94, 103, 121,
|
||||
|
||||
/*90 UP NM1 NM2 NM3 NETR LCTL LWIN LALT SPC RALT */
|
||||
130, 70, 79, 88, 106, 5, 14, 23, 50, 86,
|
||||
|
||||
/*100 RWIN RFNC RCTL LFT DWN RGT NM0 NM. G1 G2 */
|
||||
95, 104, 113, 122, 131, 132, 133, 97, 147, 148,
|
||||
|
||||
/*110 G3 G4 G5 */
|
||||
149, 150, 151
|
||||
};
|
||||
|
||||
CougarKeyboardController::CougarKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
CougarKeyboardController::~CougarKeyboardController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string CougarKeyboardController::GetDeviceName()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string CougarKeyboardController::GetSerial()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
std::string CougarKeyboardController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
void CougarKeyboardController::SetMode(uint8_t mode, uint8_t speed, uint8_t brightness, uint8_t direction, std::vector<RGBColor> colours, bool random_colours)
|
||||
{
|
||||
uint8_t buffer[COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE] = { 0x00, 0x14, 0x2C };
|
||||
|
||||
buffer[COUGARKEYBOARDCONTROLLER_MODE_BYTE] = mode;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_SPEED_BYTE] = speed;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_BRIGHTNESS_BYTE] = brightness;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_RANDOM_BYTE] = (random_colours) ? 1 : 0;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DIRECTION_BYTE] = direction;
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Off mode does not need any further settings & should |
|
||||
| skip the default case to avoid an indexing error |
|
||||
\*-----------------------------------------------------*/
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_OFF:
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Spectrum Cycle mode (Circle) always sets random |
|
||||
\*-----------------------------------------------------*/
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_CIRCLE:
|
||||
buffer[COUGARKEYBOARDCONTROLLER_RANDOM_BYTE] = 1;
|
||||
break;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Wave mode does not have a true "random" colour and |
|
||||
| needs to set the "rainbow" mode (val = 2) instead |
|
||||
\*-----------------------------------------------------*/
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_WAVE:
|
||||
buffer[COUGARKEYBOARDCONTROLLER_RANDOM_BYTE] = (random_colours) ? 2 : 0;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DATA_BYTE] = 2;
|
||||
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_RIPPLE:
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_SCAN:
|
||||
{
|
||||
uint8_t count = (uint8_t)colours.size();
|
||||
uint8_t timer = 100 / count;
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DATA_BYTE + 1] = count;
|
||||
|
||||
for(uint8_t i = 0; i < count; i++)
|
||||
{
|
||||
uint8_t offset = 11 + (i * 4);
|
||||
|
||||
buffer[offset] = (i + 1) * timer;
|
||||
buffer[offset + 1] = RGBGetRValue(colours[i]);
|
||||
buffer[offset + 2] = RGBGetGValue(colours[i]);
|
||||
buffer[offset + 3] = RGBGetBValue(colours[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case COUGARKEYBOARDCONTROLLER_MODE_RHYTHM:
|
||||
buffer[COUGARKEYBOARDCONTROLLER_RANDOM_BYTE] = (random_colours) ? 2 : 0;
|
||||
|
||||
default:
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DATA_BYTE + 1] = RGBGetRValue(colours[0]);
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DATA_BYTE + 2] = RGBGetGValue(colours[0]);
|
||||
buffer[COUGARKEYBOARDCONTROLLER_DATA_BYTE + 3] = RGBGetBValue(colours[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
hid_write(dev, buffer, COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE);
|
||||
}
|
||||
|
||||
void CougarKeyboardController::SetLedsDirect(std::vector<RGBColor> colours)
|
||||
{
|
||||
uint8_t max_leds = 14;
|
||||
uint8_t leds_remaining = (uint8_t)colours.size();
|
||||
uint8_t packet_flag = COUGARKEYBOARDCONTROLLER_DIRECTION_BYTE;
|
||||
uint8_t buffer[COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE] = { 0x00, 0x14, 0x2C, 0x0B, 0x00, 0xFF, 0x64, 0x00, 0x01 };
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Set up Direct packet |
|
||||
| keyvalue_map is the index of the Key from full_matrix_map |
|
||||
\*-----------------------------------------------------------------*/
|
||||
for(uint8_t leds2send = 0; leds2send < leds_remaining; leds2send += max_leds)
|
||||
{
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Check if there is enough leds for another pass |
|
||||
\*-----------------------------------------------------------------*/
|
||||
if(leds2send + max_leds > leds_remaining)
|
||||
{
|
||||
max_leds = leds_remaining - leds2send;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| The last packet flag should be 0x03 |
|
||||
\*-----------------------------------------------------------------*/
|
||||
buffer[packet_flag] = 3;
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < max_leds; i++)
|
||||
{
|
||||
uint8_t offset = COUGARKEYBOARDCONTROLLER_DATA_BYTE + (i * 4);
|
||||
uint8_t led_num = leds2send + i;
|
||||
|
||||
buffer[offset] = keyvalue_map[led_num];
|
||||
buffer[offset + 1] = RGBGetRValue(colours[led_num]);
|
||||
buffer[offset + 2] = RGBGetGValue(colours[led_num]);
|
||||
buffer[offset + 3] = RGBGetBValue(colours[led_num]);
|
||||
}
|
||||
hid_write(dev, buffer, COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| After the first packet the packet flag should be 0x02 |
|
||||
\*-----------------------------------------------------------------*/
|
||||
buffer[packet_flag] = 2;
|
||||
}
|
||||
}
|
||||
|
||||
void CougarKeyboardController::Save(uint8_t flag)
|
||||
{
|
||||
uint8_t buffer[COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE] = { 0x00, 0x12, flag, 0x00, 0x00 };
|
||||
|
||||
hid_write(dev, buffer, COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE);
|
||||
}
|
||||
|
||||
void CougarKeyboardController::SendProfile(uint8_t profile, uint8_t light)
|
||||
{
|
||||
uint8_t buffer[COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE] = { 0x00, 0x14, 0x00, 0x00, 0x00, profile, light, 0x00, 0x00};
|
||||
|
||||
hid_write(dev, buffer, COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE);
|
||||
}
|
||||
@@ -1,85 +1,85 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| CougarKeyboardController.h |
|
||||
| |
|
||||
| Driver for Cougar keyboard |
|
||||
| |
|
||||
| Chris M (DrNo) 05 Apr 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
|
||||
#define COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE 65 //Buffer requires a prepended ReportID hence + 1
|
||||
#define HID_MAX_STR 255
|
||||
|
||||
#define COUGARKEYBOARDCONTROLLER_BRIGHTNESS_MIN 0
|
||||
#define COUGARKEYBOARDCONTROLLER_BRIGHTNESS_MAX 100
|
||||
#define COUGARKEYBOARDCONTROLLER_MATRIX_WIDTH 23
|
||||
|
||||
static const uint8_t direction_map[6] =
|
||||
{
|
||||
4, 0, 6, 2, 11, 12 //Left, Right, Up, Down, Horizontal, Vertical
|
||||
};
|
||||
|
||||
enum Cougar_Keyboard_Controller_Modes
|
||||
{
|
||||
COUGARKEYBOARDCONTROLLER_MODE_OFF = 0x0C, //Turn off - All leds off
|
||||
COUGARKEYBOARDCONTROLLER_MODE_DIRECT = 0x0B, //Customize Mode
|
||||
COUGARKEYBOARDCONTROLLER_MODE_STATIC = 0x00, //Steady Mode
|
||||
COUGARKEYBOARDCONTROLLER_MODE_BREATHING = 0x01, //Breathing Mode - Fades between fully off and fully on.
|
||||
COUGARKEYBOARDCONTROLLER_MODE_CIRCLE = 0x02,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_REACTIVE = 0x03, //Click Mode
|
||||
COUGARKEYBOARDCONTROLLER_MODE_WAVE = 0x04,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_RIPPLE = 0x05,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_STAR = 0x06,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_SCAN = 0x07,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_RHYTHM = 0x08,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_RAIN = 0x09,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_SNAKE = 0x0A,
|
||||
};
|
||||
|
||||
enum Cougar_Keyboard_Controller_Byte_Map
|
||||
{
|
||||
COUGARKEYBOARDCONTROLLER_REPORT_BYTE = 1,
|
||||
COUGARKEYBOARDCONTROLLER_COMMAND_BYTE = 2,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_BYTE = 3,
|
||||
COUGARKEYBOARDCONTROLLER_SPEED_BYTE = 5,
|
||||
COUGARKEYBOARDCONTROLLER_BRIGHTNESS_BYTE = 6,
|
||||
COUGARKEYBOARDCONTROLLER_RANDOM_BYTE = 7,
|
||||
COUGARKEYBOARDCONTROLLER_DIRECTION_BYTE = 8,
|
||||
COUGARKEYBOARDCONTROLLER_DATA_BYTE = 9,
|
||||
};
|
||||
|
||||
enum Cougar_Keyboard_Controller_Speeds
|
||||
{
|
||||
COUGARKEYBOARDCONTROLLER_SPEED_SLOWEST = 0x0A, // Slowest speed
|
||||
COUGARKEYBOARDCONTROLLER_SPEED_NORMAL = 0x05, // Normal speed
|
||||
COUGARKEYBOARDCONTROLLER_SPEED_FASTEST = 0x01, // Fastest speed
|
||||
};
|
||||
|
||||
class CougarKeyboardController
|
||||
{
|
||||
public:
|
||||
CougarKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name);
|
||||
~CougarKeyboardController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
void SetMode(uint8_t mode, uint8_t speed, uint8_t brightness, uint8_t direction, std::vector<RGBColor> colours, bool random_colours);
|
||||
void SetLedsDirect(std::vector<RGBColor> colours);
|
||||
void Save(uint8_t flag);
|
||||
void SendProfile(uint8_t profile, uint8_t light);
|
||||
private:
|
||||
std::string serial;
|
||||
std::string location;
|
||||
std::string name;
|
||||
hid_device* dev;
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| CougarKeyboardController.h |
|
||||
| |
|
||||
| Driver for Cougar keyboard |
|
||||
| |
|
||||
| Chris M (DrNo) 05 Apr 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
|
||||
#define COUGARKEYBOARDCONTROLLER_WRITE_PACKET_SIZE 65 //Buffer requires a prepended ReportID hence + 1
|
||||
#define HID_MAX_STR 255
|
||||
|
||||
#define COUGARKEYBOARDCONTROLLER_BRIGHTNESS_MIN 0
|
||||
#define COUGARKEYBOARDCONTROLLER_BRIGHTNESS_MAX 100
|
||||
#define COUGARKEYBOARDCONTROLLER_MATRIX_WIDTH 23
|
||||
|
||||
static const uint8_t direction_map[6] =
|
||||
{
|
||||
4, 0, 6, 2, 11, 12 //Left, Right, Up, Down, Horizontal, Vertical
|
||||
};
|
||||
|
||||
enum Cougar_Keyboard_Controller_Modes
|
||||
{
|
||||
COUGARKEYBOARDCONTROLLER_MODE_OFF = 0x0C, //Turn off - All leds off
|
||||
COUGARKEYBOARDCONTROLLER_MODE_DIRECT = 0x0B, //Customize Mode
|
||||
COUGARKEYBOARDCONTROLLER_MODE_STATIC = 0x00, //Steady Mode
|
||||
COUGARKEYBOARDCONTROLLER_MODE_BREATHING = 0x01, //Breathing Mode - Fades between fully off and fully on.
|
||||
COUGARKEYBOARDCONTROLLER_MODE_CIRCLE = 0x02,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_REACTIVE = 0x03, //Click Mode
|
||||
COUGARKEYBOARDCONTROLLER_MODE_WAVE = 0x04,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_RIPPLE = 0x05,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_STAR = 0x06,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_SCAN = 0x07,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_RHYTHM = 0x08,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_RAIN = 0x09,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_SNAKE = 0x0A,
|
||||
};
|
||||
|
||||
enum Cougar_Keyboard_Controller_Byte_Map
|
||||
{
|
||||
COUGARKEYBOARDCONTROLLER_REPORT_BYTE = 1,
|
||||
COUGARKEYBOARDCONTROLLER_COMMAND_BYTE = 2,
|
||||
COUGARKEYBOARDCONTROLLER_MODE_BYTE = 3,
|
||||
COUGARKEYBOARDCONTROLLER_SPEED_BYTE = 5,
|
||||
COUGARKEYBOARDCONTROLLER_BRIGHTNESS_BYTE = 6,
|
||||
COUGARKEYBOARDCONTROLLER_RANDOM_BYTE = 7,
|
||||
COUGARKEYBOARDCONTROLLER_DIRECTION_BYTE = 8,
|
||||
COUGARKEYBOARDCONTROLLER_DATA_BYTE = 9,
|
||||
};
|
||||
|
||||
enum Cougar_Keyboard_Controller_Speeds
|
||||
{
|
||||
COUGARKEYBOARDCONTROLLER_SPEED_SLOWEST = 0x0A, // Slowest speed
|
||||
COUGARKEYBOARDCONTROLLER_SPEED_NORMAL = 0x05, // Normal speed
|
||||
COUGARKEYBOARDCONTROLLER_SPEED_FASTEST = 0x01, // Fastest speed
|
||||
};
|
||||
|
||||
class CougarKeyboardController
|
||||
{
|
||||
public:
|
||||
CougarKeyboardController(hid_device* dev_handle, const char* path, std::string dev_name);
|
||||
~CougarKeyboardController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
void SetMode(uint8_t mode, uint8_t speed, uint8_t brightness, uint8_t direction, std::vector<RGBColor> colours, bool random_colours);
|
||||
void SetLedsDirect(std::vector<RGBColor> colours);
|
||||
void Save(uint8_t flag);
|
||||
void SendProfile(uint8_t profile, uint8_t light);
|
||||
private:
|
||||
std::string serial;
|
||||
std::string location;
|
||||
std::string name;
|
||||
hid_device* dev;
|
||||
};
|
||||
+511
-511
File diff suppressed because it is too large.
Load diff
+40
-40
@@ -1,40 +1,40 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_CougarKeyboard.h |
|
||||
| |
|
||||
| RGBController for Cougar keyboard |
|
||||
| |
|
||||
| Chris M (DrNo) 05 Apr 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "LogManager.h"
|
||||
#include "RGBController.h"
|
||||
#include "CougarKeyboardController.h"
|
||||
|
||||
class RGBController_CougarKeyboard : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CougarKeyboard(CougarKeyboardController* controller_ptr);
|
||||
~RGBController_CougarKeyboard();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
int GetDeviceMode();
|
||||
int GetLED_Zone(int led_idx);
|
||||
|
||||
CougarKeyboardController* controller;
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_CougarKeyboard.h |
|
||||
| |
|
||||
| RGBController for Cougar keyboard |
|
||||
| |
|
||||
| Chris M (DrNo) 05 Apr 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "LogManager.h"
|
||||
#include "RGBController.h"
|
||||
#include "CougarKeyboardController.h"
|
||||
|
||||
class RGBController_CougarKeyboard : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CougarKeyboard(CougarKeyboardController* controller_ptr);
|
||||
~RGBController_CougarKeyboard();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
int GetDeviceMode();
|
||||
int GetLED_Zone(int led_idx);
|
||||
|
||||
CougarKeyboardController* controller;
|
||||
};
|
||||
+213
-213
@@ -1,213 +1,213 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| CougarRevengerSTController.cpp |
|
||||
| |
|
||||
| Driver for Cougar Revenger ST |
|
||||
| |
|
||||
| Morgan Guimard (morg) 17 Mar 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <string.h>
|
||||
#include "CougarRevengerSTController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
CougarRevengerSTController::CougarRevengerSTController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = info.path;
|
||||
name = dev_name;
|
||||
version = "";
|
||||
|
||||
ActivateMode(0, DIRECT_MODE_VALUE);
|
||||
ActivateMode(1, DIRECT_MODE_VALUE);
|
||||
ActivateMode(2, DIRECT_MODE_VALUE);
|
||||
}
|
||||
|
||||
CougarRevengerSTController::~CougarRevengerSTController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string CougarRevengerSTController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string CougarRevengerSTController::GetNameString()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string CougarRevengerSTController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
std::string CougarRevengerSTController::GetFirmwareVersion()
|
||||
{
|
||||
return(version);
|
||||
}
|
||||
|
||||
void CougarRevengerSTController::SetDirect(unsigned char zone, RGBColor color, unsigned char brightness)
|
||||
{
|
||||
const cougar_mode& m = modes_mapping.at(DIRECT_MODE_VALUE);
|
||||
|
||||
unsigned char usb_buf[PACKET_DATA_LENGTH];
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = ACTION_SET;
|
||||
usb_buf[0x05] = m.zone_mode_byte[zone];
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Set RGB Values |
|
||||
\*-----------------------------------------*/
|
||||
SendColourPacket(m.zone_rgb_mapping[zone], RGBGetRValue(color), usb_buf);
|
||||
SendColourPacket(m.zone_rgb_mapping[zone] + 1, RGBGetGValue(color), usb_buf);
|
||||
SendColourPacket(m.zone_rgb_mapping[zone] + 2, RGBGetBValue(color), usb_buf);
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Set Brightness |
|
||||
\*-----------------------------------------*/
|
||||
usb_buf[0x04] = m.zone_brightness_mapping[zone];
|
||||
usb_buf[0x06] = brightness;
|
||||
|
||||
hid_send_feature_report(dev,usb_buf, PACKET_DATA_LENGTH);
|
||||
}
|
||||
|
||||
void CougarRevengerSTController::SetModeData(unsigned char zone, unsigned char mode_value, std::vector<RGBColor> colors, unsigned char brightness, unsigned char speed)
|
||||
{
|
||||
unsigned char usb_buf[PACKET_DATA_LENGTH];
|
||||
|
||||
const cougar_mode& m = modes_mapping.at(mode_value);
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Define colors |
|
||||
\*-----------------------------------------*/
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = ACTION_SET;
|
||||
|
||||
unsigned char offset = m.zone_rgb_mapping[zone];
|
||||
|
||||
usb_buf[0x05] = m.zone_rgb_byte[zone];
|
||||
|
||||
for(unsigned int i = 0; i < COLORS_SIZE; i++)
|
||||
{
|
||||
if(mode_value == BREATHING_MODE_VALUE && i >= 3 && zone == 2)
|
||||
{
|
||||
usb_buf[0x05] = 0x01;
|
||||
}
|
||||
|
||||
SendColourPacket(offset, RGBGetRValue(colors[i]), usb_buf);
|
||||
SendColourPacket(offset + 1, RGBGetGValue(colors[i]), usb_buf);
|
||||
SendColourPacket(offset + 2, RGBGetBValue(colors[i]), usb_buf);
|
||||
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Define speed |
|
||||
\*-----------------------------------------*/
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = ACTION_SET;
|
||||
usb_buf[0x04] = m.zone_speed_mapping[zone];
|
||||
usb_buf[0x05] = m.zone_speed_byte[zone];
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Dirty hack here: |
|
||||
| The OEM app or firmware seems to be |
|
||||
| broken, at full speed it flashes on |
|
||||
| the bottom zone. Let's adjust a bit the |
|
||||
| value so it's almost consistent with |
|
||||
| the other zones at full speed. |
|
||||
\*-----------------------------------------*/
|
||||
if(mode_value == SWIFT_MODE_VALUE && zone == 0)
|
||||
{
|
||||
usb_buf[0x06] = (speed + 1) * 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
usb_buf[0x06] = speed;
|
||||
}
|
||||
|
||||
hid_send_feature_report(dev,usb_buf, PACKET_DATA_LENGTH);
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Define brightness |
|
||||
\*-----------------------------------------*/
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = ACTION_SET;
|
||||
|
||||
usb_buf[0x05] = m.zone_brightness_byte[zone];
|
||||
usb_buf[0x06] = brightness;
|
||||
|
||||
offset = m.zone_brightness_mapping[zone];
|
||||
|
||||
for(unsigned int i = 0; i < COLORS_SIZE; i++)
|
||||
{
|
||||
if(mode_value == BREATHING_MODE_VALUE && i >= 4 && zone == 2)
|
||||
{
|
||||
usb_buf[0x05] = 0x01;
|
||||
}
|
||||
|
||||
usb_buf[0x04] = offset;
|
||||
hid_send_feature_report(dev,usb_buf, PACKET_DATA_LENGTH);
|
||||
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
Apply();
|
||||
}
|
||||
|
||||
void CougarRevengerSTController::SendColourPacket(unsigned char address, unsigned char value, unsigned char *buffer)
|
||||
{
|
||||
buffer[0x04] = address;
|
||||
buffer[0x06] = value;
|
||||
|
||||
hid_send_feature_report(dev, buffer, PACKET_DATA_LENGTH);
|
||||
}
|
||||
|
||||
void CougarRevengerSTController::ActivateMode(unsigned char zone, unsigned char mode_value)
|
||||
{
|
||||
const cougar_mode& m = modes_mapping.at(mode_value);
|
||||
|
||||
unsigned char usb_buf[PACKET_DATA_LENGTH];
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = ACTION_SET;
|
||||
usb_buf[0x04] = m.zone_mode_mapping[zone]; // zone dependent?
|
||||
usb_buf[0x05] = m.zone_mode_byte[zone];
|
||||
usb_buf[0x06] = mode_value;
|
||||
|
||||
hid_send_feature_report(dev,usb_buf, PACKET_DATA_LENGTH);
|
||||
}
|
||||
|
||||
void CougarRevengerSTController::Apply()
|
||||
{
|
||||
unsigned char usb_buf[PACKET_DATA_LENGTH];
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = 0x03;
|
||||
usb_buf[0x03] = 0x03;
|
||||
usb_buf[0x04] = 0x03;
|
||||
|
||||
hid_send_feature_report(dev,usb_buf, PACKET_DATA_LENGTH);
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| CougarRevengerSTController.cpp |
|
||||
| |
|
||||
| Driver for Cougar Revenger ST |
|
||||
| |
|
||||
| Morgan Guimard (morg) 17 Mar 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <string.h>
|
||||
#include "CougarRevengerSTController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
CougarRevengerSTController::CougarRevengerSTController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = info.path;
|
||||
name = dev_name;
|
||||
version = "";
|
||||
|
||||
ActivateMode(0, DIRECT_MODE_VALUE);
|
||||
ActivateMode(1, DIRECT_MODE_VALUE);
|
||||
ActivateMode(2, DIRECT_MODE_VALUE);
|
||||
}
|
||||
|
||||
CougarRevengerSTController::~CougarRevengerSTController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string CougarRevengerSTController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string CougarRevengerSTController::GetNameString()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string CougarRevengerSTController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
std::string CougarRevengerSTController::GetFirmwareVersion()
|
||||
{
|
||||
return(version);
|
||||
}
|
||||
|
||||
void CougarRevengerSTController::SetDirect(unsigned char zone, RGBColor color, unsigned char brightness)
|
||||
{
|
||||
const cougar_mode& m = modes_mapping.at(DIRECT_MODE_VALUE);
|
||||
|
||||
unsigned char usb_buf[PACKET_DATA_LENGTH];
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = ACTION_SET;
|
||||
usb_buf[0x05] = m.zone_mode_byte[zone];
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Set RGB Values |
|
||||
\*-----------------------------------------*/
|
||||
SendColourPacket(m.zone_rgb_mapping[zone], RGBGetRValue(color), usb_buf);
|
||||
SendColourPacket(m.zone_rgb_mapping[zone] + 1, RGBGetGValue(color), usb_buf);
|
||||
SendColourPacket(m.zone_rgb_mapping[zone] + 2, RGBGetBValue(color), usb_buf);
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Set Brightness |
|
||||
\*-----------------------------------------*/
|
||||
usb_buf[0x04] = m.zone_brightness_mapping[zone];
|
||||
usb_buf[0x06] = brightness;
|
||||
|
||||
hid_send_feature_report(dev,usb_buf, PACKET_DATA_LENGTH);
|
||||
}
|
||||
|
||||
void CougarRevengerSTController::SetModeData(unsigned char zone, unsigned char mode_value, std::vector<RGBColor> colors, unsigned char brightness, unsigned char speed)
|
||||
{
|
||||
unsigned char usb_buf[PACKET_DATA_LENGTH];
|
||||
|
||||
const cougar_mode& m = modes_mapping.at(mode_value);
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Define colors |
|
||||
\*-----------------------------------------*/
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = ACTION_SET;
|
||||
|
||||
unsigned char offset = m.zone_rgb_mapping[zone];
|
||||
|
||||
usb_buf[0x05] = m.zone_rgb_byte[zone];
|
||||
|
||||
for(unsigned int i = 0; i < COLORS_SIZE; i++)
|
||||
{
|
||||
if(mode_value == BREATHING_MODE_VALUE && i >= 3 && zone == 2)
|
||||
{
|
||||
usb_buf[0x05] = 0x01;
|
||||
}
|
||||
|
||||
SendColourPacket(offset, RGBGetRValue(colors[i]), usb_buf);
|
||||
SendColourPacket(offset + 1, RGBGetGValue(colors[i]), usb_buf);
|
||||
SendColourPacket(offset + 2, RGBGetBValue(colors[i]), usb_buf);
|
||||
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Define speed |
|
||||
\*-----------------------------------------*/
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = ACTION_SET;
|
||||
usb_buf[0x04] = m.zone_speed_mapping[zone];
|
||||
usb_buf[0x05] = m.zone_speed_byte[zone];
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Dirty hack here: |
|
||||
| The OEM app or firmware seems to be |
|
||||
| broken, at full speed it flashes on |
|
||||
| the bottom zone. Let's adjust a bit the |
|
||||
| value so it's almost consistent with |
|
||||
| the other zones at full speed. |
|
||||
\*-----------------------------------------*/
|
||||
if(mode_value == SWIFT_MODE_VALUE && zone == 0)
|
||||
{
|
||||
usb_buf[0x06] = (speed + 1) * 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
usb_buf[0x06] = speed;
|
||||
}
|
||||
|
||||
hid_send_feature_report(dev,usb_buf, PACKET_DATA_LENGTH);
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Define brightness |
|
||||
\*-----------------------------------------*/
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = ACTION_SET;
|
||||
|
||||
usb_buf[0x05] = m.zone_brightness_byte[zone];
|
||||
usb_buf[0x06] = brightness;
|
||||
|
||||
offset = m.zone_brightness_mapping[zone];
|
||||
|
||||
for(unsigned int i = 0; i < COLORS_SIZE; i++)
|
||||
{
|
||||
if(mode_value == BREATHING_MODE_VALUE && i >= 4 && zone == 2)
|
||||
{
|
||||
usb_buf[0x05] = 0x01;
|
||||
}
|
||||
|
||||
usb_buf[0x04] = offset;
|
||||
hid_send_feature_report(dev,usb_buf, PACKET_DATA_LENGTH);
|
||||
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
Apply();
|
||||
}
|
||||
|
||||
void CougarRevengerSTController::SendColourPacket(unsigned char address, unsigned char value, unsigned char *buffer)
|
||||
{
|
||||
buffer[0x04] = address;
|
||||
buffer[0x06] = value;
|
||||
|
||||
hid_send_feature_report(dev, buffer, PACKET_DATA_LENGTH);
|
||||
}
|
||||
|
||||
void CougarRevengerSTController::ActivateMode(unsigned char zone, unsigned char mode_value)
|
||||
{
|
||||
const cougar_mode& m = modes_mapping.at(mode_value);
|
||||
|
||||
unsigned char usb_buf[PACKET_DATA_LENGTH];
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = ACTION_SET;
|
||||
usb_buf[0x04] = m.zone_mode_mapping[zone]; // zone dependent?
|
||||
usb_buf[0x05] = m.zone_mode_byte[zone];
|
||||
usb_buf[0x06] = mode_value;
|
||||
|
||||
hid_send_feature_report(dev,usb_buf, PACKET_DATA_LENGTH);
|
||||
}
|
||||
|
||||
void CougarRevengerSTController::Apply()
|
||||
{
|
||||
unsigned char usb_buf[PACKET_DATA_LENGTH];
|
||||
memset(usb_buf, 0x00, PACKET_DATA_LENGTH);
|
||||
|
||||
usb_buf[0x01] = PACKET_START;
|
||||
usb_buf[0x02] = 0x03;
|
||||
usb_buf[0x03] = 0x03;
|
||||
usb_buf[0x04] = 0x03;
|
||||
|
||||
hid_send_feature_report(dev,usb_buf, PACKET_DATA_LENGTH);
|
||||
}
|
||||
+251
-251
@@ -1,251 +1,251 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| CougarRevengerSTController.h |
|
||||
| |
|
||||
| Driver for Cougar Revenger ST |
|
||||
| |
|
||||
| Morgan Guimard (morg) 17 Mar 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
|
||||
#define PACKET_DATA_LENGTH 9
|
||||
|
||||
enum
|
||||
{
|
||||
PACKET_START = 0xC4,
|
||||
ACTION_SET = 0x0F
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MIN_BRIGHTNESS = 0x00,
|
||||
MAX_BRIGHTNESS = 0xFF,
|
||||
MIN_SPEED_SWIFT = 0x2F,
|
||||
MIN_SPEED = 0x0F,
|
||||
MAX_SPEED = 0x00,
|
||||
COLORS_SIZE = 0x07
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
OFF_MODE_VALUE = 0x00,
|
||||
DIRECT_MODE_VALUE = 0x01,
|
||||
BREATHING_MODE_VALUE = 0x02,
|
||||
FLOW_MODE_VALUE = 0x03,
|
||||
SWIFT_MODE_VALUE = 0x04,
|
||||
FLOW_LEFT_MODE_VALUE = 0x09,
|
||||
FLOW_RIGHT_MODE_VALUE = 0x0B
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char zone_mode_mapping[3];
|
||||
unsigned char zone_mode_byte[3];
|
||||
unsigned char zone_rgb_mapping[3];
|
||||
unsigned char zone_rgb_byte[3];
|
||||
unsigned char zone_brightness_mapping[3];
|
||||
unsigned char zone_brightness_byte[3];
|
||||
unsigned char zone_speed_mapping[3];
|
||||
unsigned char zone_speed_byte[3];
|
||||
} cougar_mode;
|
||||
|
||||
const cougar_mode DIRECT_MODE =
|
||||
{
|
||||
{
|
||||
0x77, 0x55, 0xE6
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x79, 0x57, 0xE8
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x78, 0x56, 0xE7
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
}
|
||||
};
|
||||
|
||||
const cougar_mode OFF_MODE =
|
||||
{
|
||||
{
|
||||
0x77, 0x55, 0xE6
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
}
|
||||
};
|
||||
|
||||
const cougar_mode BREATHING_MODE =
|
||||
{
|
||||
{
|
||||
0x77, 0x55, 0xE6
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x85, 0x63, 0xF4
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x84, 0x62, 0xF3
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x7C, 0x5A, 0xEB
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
}
|
||||
};
|
||||
|
||||
const cougar_mode SWIFT_MODE =
|
||||
{
|
||||
{
|
||||
0x77, 0x55, 0xE6
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0xB0, 0x8E, 0x1F
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
},
|
||||
{
|
||||
0xAF, 0x8D, 0x1E
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
},
|
||||
{
|
||||
0xAD, 0x8B, 0x1C
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
}
|
||||
};
|
||||
|
||||
const cougar_mode FLOW_MODE =
|
||||
{
|
||||
{
|
||||
0x77, 0x00, 0xE6
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0xB0, 0x00, 0x1F
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
},
|
||||
{
|
||||
0xAF, 0x00, 0x1E
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
},
|
||||
{
|
||||
0xAD, 0x00, 0x1C
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
}
|
||||
};
|
||||
|
||||
static const std::map<unsigned char, cougar_mode> modes_mapping =
|
||||
{
|
||||
{
|
||||
DIRECT_MODE_VALUE,
|
||||
DIRECT_MODE
|
||||
},
|
||||
{
|
||||
OFF_MODE_VALUE,
|
||||
OFF_MODE
|
||||
},
|
||||
{
|
||||
BREATHING_MODE_VALUE,
|
||||
BREATHING_MODE
|
||||
},
|
||||
{
|
||||
SWIFT_MODE_VALUE,
|
||||
SWIFT_MODE
|
||||
},
|
||||
{
|
||||
FLOW_LEFT_MODE_VALUE,
|
||||
FLOW_MODE
|
||||
},
|
||||
{
|
||||
FLOW_RIGHT_MODE_VALUE,
|
||||
FLOW_MODE
|
||||
}
|
||||
};
|
||||
|
||||
class CougarRevengerSTController
|
||||
{
|
||||
public:
|
||||
CougarRevengerSTController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
|
||||
~CougarRevengerSTController();
|
||||
|
||||
std::string GetSerialString();
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetFirmwareVersion();
|
||||
std::string GetNameString();
|
||||
|
||||
void ActivateMode(unsigned char zone, unsigned char mode_value);
|
||||
void SetDirect(unsigned char zone, RGBColor color, unsigned char brightness);
|
||||
void SetModeData(unsigned char zone, unsigned char mode_value, std::vector<RGBColor> colors, unsigned char brightness, unsigned char speed);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
std::string name;
|
||||
std::string version;
|
||||
|
||||
void Apply();
|
||||
void SendColourPacket(unsigned char address, unsigned char value, unsigned char * buffer);
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| CougarRevengerSTController.h |
|
||||
| |
|
||||
| Driver for Cougar Revenger ST |
|
||||
| |
|
||||
| Morgan Guimard (morg) 17 Mar 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
|
||||
#define PACKET_DATA_LENGTH 9
|
||||
|
||||
enum
|
||||
{
|
||||
PACKET_START = 0xC4,
|
||||
ACTION_SET = 0x0F
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
MIN_BRIGHTNESS = 0x00,
|
||||
MAX_BRIGHTNESS = 0xFF,
|
||||
MIN_SPEED_SWIFT = 0x2F,
|
||||
MIN_SPEED = 0x0F,
|
||||
MAX_SPEED = 0x00,
|
||||
COLORS_SIZE = 0x07
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
OFF_MODE_VALUE = 0x00,
|
||||
DIRECT_MODE_VALUE = 0x01,
|
||||
BREATHING_MODE_VALUE = 0x02,
|
||||
FLOW_MODE_VALUE = 0x03,
|
||||
SWIFT_MODE_VALUE = 0x04,
|
||||
FLOW_LEFT_MODE_VALUE = 0x09,
|
||||
FLOW_RIGHT_MODE_VALUE = 0x0B
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char zone_mode_mapping[3];
|
||||
unsigned char zone_mode_byte[3];
|
||||
unsigned char zone_rgb_mapping[3];
|
||||
unsigned char zone_rgb_byte[3];
|
||||
unsigned char zone_brightness_mapping[3];
|
||||
unsigned char zone_brightness_byte[3];
|
||||
unsigned char zone_speed_mapping[3];
|
||||
unsigned char zone_speed_byte[3];
|
||||
} cougar_mode;
|
||||
|
||||
const cougar_mode DIRECT_MODE =
|
||||
{
|
||||
{
|
||||
0x77, 0x55, 0xE6
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x79, 0x57, 0xE8
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x78, 0x56, 0xE7
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
}
|
||||
};
|
||||
|
||||
const cougar_mode OFF_MODE =
|
||||
{
|
||||
{
|
||||
0x77, 0x55, 0xE6
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x00, 0x00, 0x00
|
||||
}
|
||||
};
|
||||
|
||||
const cougar_mode BREATHING_MODE =
|
||||
{
|
||||
{
|
||||
0x77, 0x55, 0xE6
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x85, 0x63, 0xF4
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x84, 0x62, 0xF3
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0x7C, 0x5A, 0xEB
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
}
|
||||
};
|
||||
|
||||
const cougar_mode SWIFT_MODE =
|
||||
{
|
||||
{
|
||||
0x77, 0x55, 0xE6
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0xB0, 0x8E, 0x1F
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
},
|
||||
{
|
||||
0xAF, 0x8D, 0x1E
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
},
|
||||
{
|
||||
0xAD, 0x8B, 0x1C
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
}
|
||||
};
|
||||
|
||||
const cougar_mode FLOW_MODE =
|
||||
{
|
||||
{
|
||||
0x77, 0x00, 0xE6
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x00
|
||||
},
|
||||
{
|
||||
0xB0, 0x00, 0x1F
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
},
|
||||
{
|
||||
0xAF, 0x00, 0x1E
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
},
|
||||
{
|
||||
0xAD, 0x00, 0x1C
|
||||
},
|
||||
{
|
||||
0x01, 0x00, 0x01
|
||||
}
|
||||
};
|
||||
|
||||
static const std::map<unsigned char, cougar_mode> modes_mapping =
|
||||
{
|
||||
{
|
||||
DIRECT_MODE_VALUE,
|
||||
DIRECT_MODE
|
||||
},
|
||||
{
|
||||
OFF_MODE_VALUE,
|
||||
OFF_MODE
|
||||
},
|
||||
{
|
||||
BREATHING_MODE_VALUE,
|
||||
BREATHING_MODE
|
||||
},
|
||||
{
|
||||
SWIFT_MODE_VALUE,
|
||||
SWIFT_MODE
|
||||
},
|
||||
{
|
||||
FLOW_LEFT_MODE_VALUE,
|
||||
FLOW_MODE
|
||||
},
|
||||
{
|
||||
FLOW_RIGHT_MODE_VALUE,
|
||||
FLOW_MODE
|
||||
}
|
||||
};
|
||||
|
||||
class CougarRevengerSTController
|
||||
{
|
||||
public:
|
||||
CougarRevengerSTController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
|
||||
~CougarRevengerSTController();
|
||||
|
||||
std::string GetSerialString();
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetFirmwareVersion();
|
||||
std::string GetNameString();
|
||||
|
||||
void ActivateMode(unsigned char zone, unsigned char mode_value);
|
||||
void SetDirect(unsigned char zone, RGBColor color, unsigned char brightness);
|
||||
void SetModeData(unsigned char zone, unsigned char mode_value, std::vector<RGBColor> colors, unsigned char brightness, unsigned char speed);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
std::string name;
|
||||
std::string version;
|
||||
|
||||
void Apply();
|
||||
void SendColourPacket(unsigned char address, unsigned char value, unsigned char * buffer);
|
||||
};
|
||||
+199
-199
@@ -1,199 +1,199 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_CougarRevengerST.cpp |
|
||||
| |
|
||||
| RGBController for Cougar Revenger ST |
|
||||
| |
|
||||
| Morgan Guimard (morg) 17 Mar 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include "RGBController_CougarRevengerST.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Cougar Revenger ST
|
||||
@category Mouse
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectCougarRevengerSTControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_CougarRevengerST::RGBController_CougarRevengerST(CougarRevengerSTController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetNameString();
|
||||
vendor = "Cougar";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Cougar Revenger ST Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
version = controller->GetFirmwareVersion();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = DIRECT_MODE_VALUE;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.brightness_min = MIN_BRIGHTNESS;
|
||||
Direct.brightness_max = MAX_BRIGHTNESS;
|
||||
Direct.brightness = MAX_BRIGHTNESS;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = OFF_MODE_VALUE;
|
||||
Off.flags = MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = BREATHING_MODE_VALUE;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.brightness = MAX_BRIGHTNESS;
|
||||
Breathing.brightness_min = MIN_BRIGHTNESS;
|
||||
Breathing.brightness_max = MAX_BRIGHTNESS;
|
||||
Breathing.speed = MAX_SPEED;
|
||||
Breathing.speed_min = MIN_SPEED;
|
||||
Breathing.speed_max = MAX_SPEED;
|
||||
Breathing.colors_min = COLORS_SIZE;
|
||||
Breathing.colors_max = COLORS_SIZE;
|
||||
Breathing.colors.resize(COLORS_SIZE);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Swift;
|
||||
Swift.name = "Swift";
|
||||
Swift.value = SWIFT_MODE_VALUE;
|
||||
Swift.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Swift.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Swift.brightness = MAX_BRIGHTNESS;
|
||||
Swift.brightness_min = MIN_BRIGHTNESS;
|
||||
Swift.brightness_max = MAX_BRIGHTNESS;
|
||||
Swift.speed = MAX_SPEED;
|
||||
Swift.speed_min = MIN_SPEED_SWIFT;
|
||||
Swift.speed_max = MAX_SPEED;
|
||||
Swift.colors_min = COLORS_SIZE;
|
||||
Swift.colors_max = COLORS_SIZE;
|
||||
Swift.colors.resize(COLORS_SIZE);
|
||||
modes.push_back(Swift);
|
||||
|
||||
mode Flow;
|
||||
Flow.name = "Flow";
|
||||
Flow.value = FLOW_MODE_VALUE;
|
||||
Flow.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Flow.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Flow.brightness = MAX_BRIGHTNESS;
|
||||
Flow.brightness_min = MIN_BRIGHTNESS;
|
||||
Flow.brightness_max = MAX_BRIGHTNESS;
|
||||
Flow.speed = MAX_SPEED;
|
||||
Flow.speed_min = MIN_SPEED;
|
||||
Flow.speed_max = MAX_SPEED;
|
||||
Flow.colors_min = COLORS_SIZE;
|
||||
Flow.colors_max = COLORS_SIZE;
|
||||
Flow.direction = MODE_DIRECTION_LEFT;
|
||||
Flow.colors.resize(COLORS_SIZE);
|
||||
modes.push_back(Flow);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_CougarRevengerST::~RGBController_CougarRevengerST()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Bottom";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = 1;
|
||||
new_zone.leds_max = 1;
|
||||
new_zone.leds_count = 1;
|
||||
new_zone.matrix_map = nullptr;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
new_zone.name = "Mouse wheel";
|
||||
zones.push_back(new_zone);
|
||||
|
||||
new_zone.name = "Logo";
|
||||
zones.push_back(new_zone);
|
||||
|
||||
leds.resize(zones.size());
|
||||
|
||||
for(unsigned int i = 0; i < leds.size(); i++)
|
||||
{
|
||||
leds[i].name = "LED " + std::to_string(i+1);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::DeviceUpdateLEDs()
|
||||
{
|
||||
for(unsigned int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
UpdateZoneLEDs(i);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
controller->SetDirect(zone, colors[zone], modes[active_mode].brightness);
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::DeviceUpdateMode()
|
||||
{
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case DIRECT_MODE_VALUE:
|
||||
case OFF_MODE_VALUE:
|
||||
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
controller->ActivateMode(zone_idx, modes[active_mode].value);
|
||||
}
|
||||
break;
|
||||
case BREATHING_MODE_VALUE:
|
||||
case SWIFT_MODE_VALUE:
|
||||
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
controller->ActivateMode(zone_idx, modes[active_mode].value);
|
||||
controller->SetModeData(zone_idx, modes[active_mode].value, modes[active_mode].colors, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOW_MODE_VALUE:
|
||||
|
||||
unsigned char mode_value = modes[active_mode].direction == MODE_DIRECTION_LEFT ? FLOW_LEFT_MODE_VALUE : FLOW_RIGHT_MODE_VALUE;
|
||||
|
||||
controller->ActivateMode(0, mode_value);
|
||||
controller->ActivateMode(1, OFF_MODE_VALUE);
|
||||
controller->ActivateMode(2, mode_value);
|
||||
|
||||
controller->SetModeData(0, mode_value, modes[active_mode].colors, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
controller->SetModeData(2, mode_value, modes[active_mode].colors, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_CougarRevengerST.cpp |
|
||||
| |
|
||||
| RGBController for Cougar Revenger ST |
|
||||
| |
|
||||
| Morgan Guimard (morg) 17 Mar 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include "RGBController_CougarRevengerST.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Cougar Revenger ST
|
||||
@category Mouse
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectCougarRevengerSTControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_CougarRevengerST::RGBController_CougarRevengerST(CougarRevengerSTController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetNameString();
|
||||
vendor = "Cougar";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Cougar Revenger ST Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
version = controller->GetFirmwareVersion();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = DIRECT_MODE_VALUE;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.brightness_min = MIN_BRIGHTNESS;
|
||||
Direct.brightness_max = MAX_BRIGHTNESS;
|
||||
Direct.brightness = MAX_BRIGHTNESS;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = OFF_MODE_VALUE;
|
||||
Off.flags = MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = BREATHING_MODE_VALUE;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.brightness = MAX_BRIGHTNESS;
|
||||
Breathing.brightness_min = MIN_BRIGHTNESS;
|
||||
Breathing.brightness_max = MAX_BRIGHTNESS;
|
||||
Breathing.speed = MAX_SPEED;
|
||||
Breathing.speed_min = MIN_SPEED;
|
||||
Breathing.speed_max = MAX_SPEED;
|
||||
Breathing.colors_min = COLORS_SIZE;
|
||||
Breathing.colors_max = COLORS_SIZE;
|
||||
Breathing.colors.resize(COLORS_SIZE);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Swift;
|
||||
Swift.name = "Swift";
|
||||
Swift.value = SWIFT_MODE_VALUE;
|
||||
Swift.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Swift.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Swift.brightness = MAX_BRIGHTNESS;
|
||||
Swift.brightness_min = MIN_BRIGHTNESS;
|
||||
Swift.brightness_max = MAX_BRIGHTNESS;
|
||||
Swift.speed = MAX_SPEED;
|
||||
Swift.speed_min = MIN_SPEED_SWIFT;
|
||||
Swift.speed_max = MAX_SPEED;
|
||||
Swift.colors_min = COLORS_SIZE;
|
||||
Swift.colors_max = COLORS_SIZE;
|
||||
Swift.colors.resize(COLORS_SIZE);
|
||||
modes.push_back(Swift);
|
||||
|
||||
mode Flow;
|
||||
Flow.name = "Flow";
|
||||
Flow.value = FLOW_MODE_VALUE;
|
||||
Flow.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_DIRECTION_LR;
|
||||
Flow.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Flow.brightness = MAX_BRIGHTNESS;
|
||||
Flow.brightness_min = MIN_BRIGHTNESS;
|
||||
Flow.brightness_max = MAX_BRIGHTNESS;
|
||||
Flow.speed = MAX_SPEED;
|
||||
Flow.speed_min = MIN_SPEED;
|
||||
Flow.speed_max = MAX_SPEED;
|
||||
Flow.colors_min = COLORS_SIZE;
|
||||
Flow.colors_max = COLORS_SIZE;
|
||||
Flow.direction = MODE_DIRECTION_LEFT;
|
||||
Flow.colors.resize(COLORS_SIZE);
|
||||
modes.push_back(Flow);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_CougarRevengerST::~RGBController_CougarRevengerST()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Bottom";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = 1;
|
||||
new_zone.leds_max = 1;
|
||||
new_zone.leds_count = 1;
|
||||
new_zone.matrix_map = nullptr;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
new_zone.name = "Mouse wheel";
|
||||
zones.push_back(new_zone);
|
||||
|
||||
new_zone.name = "Logo";
|
||||
zones.push_back(new_zone);
|
||||
|
||||
leds.resize(zones.size());
|
||||
|
||||
for(unsigned int i = 0; i < leds.size(); i++)
|
||||
{
|
||||
leds[i].name = "LED " + std::to_string(i+1);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::DeviceUpdateLEDs()
|
||||
{
|
||||
for(unsigned int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
UpdateZoneLEDs(i);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::UpdateZoneLEDs(int zone)
|
||||
{
|
||||
controller->SetDirect(zone, colors[zone], modes[active_mode].brightness);
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::UpdateSingleLED(int led)
|
||||
{
|
||||
UpdateZoneLEDs(led);
|
||||
}
|
||||
|
||||
void RGBController_CougarRevengerST::DeviceUpdateMode()
|
||||
{
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case DIRECT_MODE_VALUE:
|
||||
case OFF_MODE_VALUE:
|
||||
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
controller->ActivateMode(zone_idx, modes[active_mode].value);
|
||||
}
|
||||
break;
|
||||
case BREATHING_MODE_VALUE:
|
||||
case SWIFT_MODE_VALUE:
|
||||
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||
{
|
||||
controller->ActivateMode(zone_idx, modes[active_mode].value);
|
||||
controller->SetModeData(zone_idx, modes[active_mode].value, modes[active_mode].colors, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
}
|
||||
break;
|
||||
|
||||
case FLOW_MODE_VALUE:
|
||||
|
||||
unsigned char mode_value = modes[active_mode].direction == MODE_DIRECTION_LEFT ? FLOW_LEFT_MODE_VALUE : FLOW_RIGHT_MODE_VALUE;
|
||||
|
||||
controller->ActivateMode(0, mode_value);
|
||||
controller->ActivateMode(1, OFF_MODE_VALUE);
|
||||
controller->ActivateMode(2, mode_value);
|
||||
|
||||
controller->SetModeData(0, mode_value, modes[active_mode].colors, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
controller->SetModeData(2, mode_value, modes[active_mode].colors, modes[active_mode].brightness, modes[active_mode].speed);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
+34
-34
@@ -1,34 +1,34 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_CougarRevengerST.h |
|
||||
| |
|
||||
| RGBController for Cougar Revenger ST |
|
||||
| |
|
||||
| Morgan Guimard (morg) 17 Mar 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "CougarRevengerSTController.h"
|
||||
|
||||
class RGBController_CougarRevengerST : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CougarRevengerST(CougarRevengerSTController* controller_ptr);
|
||||
~RGBController_CougarRevengerST();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
CougarRevengerSTController* controller;
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_CougarRevengerST.h |
|
||||
| |
|
||||
| RGBController for Cougar Revenger ST |
|
||||
| |
|
||||
| Morgan Guimard (morg) 17 Mar 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "CougarRevengerSTController.h"
|
||||
|
||||
class RGBController_CougarRevengerST : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CougarRevengerST(CougarRevengerSTController* controller_ptr);
|
||||
~RGBController_CougarRevengerST();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
CougarRevengerSTController* controller;
|
||||
};
|
||||
Reference in new issue
Block a user