Fix multiply defined warnings in CorsairPeripheralV2Devices controller

This commit is contained in:
Adam Honse 2022-09-19 23:14:02 -05:00
parent 91879cd063
commit e51b4ce324
6 changed files with 150 additions and 141 deletions

View file

@ -25,15 +25,15 @@ CorsairPeripheralV2Controller::CorsairPeripheralV2Controller(hid_device* dev_han
wName = std::wstring(tmp);
device_name.append(" ").append(std::string(wName.begin(), wName.end()));
for(size_t i = 0; i < CORSAIR_DEVICE_COUNT; i++)
for(size_t i = 0; i < CORSAIR_V2_DEVICE_COUNT; i++)
{
if(device_list[i]->pid == pid)
if(corsair_v2_device_list[i]->pid == pid)
{
/*---------------------------------------------------------*\
| Set device ID |
\*---------------------------------------------------------*/
device_index = i;
write_cmd = CORSAIR_V2_WRITE_ID + device_list[device_index]->wireless;
write_cmd = CORSAIR_V2_WRITE_ID + corsair_v2_device_list[device_index]->wireless;
}
}
@ -48,9 +48,9 @@ CorsairPeripheralV2Controller::~CorsairPeripheralV2Controller()
hid_close(dev);
}
const corsair_device* CorsairPeripheralV2Controller::GetDeviceData()
const corsair_v2_device* CorsairPeripheralV2Controller::GetDeviceData()
{
return device_list[device_index];
return corsair_v2_device_list[device_index];
}
std::string CorsairPeripheralV2Controller::GetDeviceLocation()

View file

@ -71,7 +71,7 @@ public:
std::string GetFirmwareString();
std::string GetName();
std::string GetSerialString();
const corsair_device* GetDeviceData();
const corsair_v2_device* GetDeviceData();
void SetRenderMode(corsair_v2_device_mode mode);
void LightingControl(uint8_t opt1, uint8_t opt2);

View file

@ -0,0 +1,107 @@
#include "CorsairPeripheralV2Devices.h"
/*-------------------------------------------------------------*\
| Corsair K55 RGB Pro 1B1C:1BA4 |
| |
| Zone "Keyboard" |
| Linear |
| 1 Row, 6 Columns |
\*-------------------------------------------------------------*/
static const corsair_v2_zone k55_rgb_pro_zone =
{
ZONE_EN_KEYBOARD,
ZONE_TYPE_LINEAR,
1,
6
};
static const corsair_v2_device k55_rgb_pro_device =
{
CORSAIR_K55_RGB_PRO_PID,
false,
DEVICE_TYPE_KEYBOARD,
CORSAIR_V2_MODE_SW,
1,
6,
{
&k55_rgb_pro_zone,
nullptr,
nullptr,
nullptr,
nullptr
},
nullptr,
0
};
/*-------------------------------------------------------------*\
| Corsair MM700 1B1C:1B9B |
| |
| Zone "Logo" |
| Single |
| |
| Zone "Edge" |
| Linear |
| 1 Row, 2 Columns |
\*-------------------------------------------------------------*/
static const corsair_v2_zone mm700_right_zone =
{
"Right",
ZONE_TYPE_SINGLE,
1,
1
};
static const corsair_v2_zone mm700_logo_zone =
{
"Logo",
ZONE_TYPE_SINGLE,
1,
1
};
static const corsair_v2_zone mm700_left_zone =
{
"Left",
ZONE_TYPE_SINGLE,
1,
1
};
static const corsair_v2_device mm700_device =
{
CORSAIR_MM700_PID,
false,
DEVICE_TYPE_MOUSEMAT,
CORSAIR_V2_MODE_SW,
1,
3,
{
&mm700_left_zone,
&mm700_right_zone,
&mm700_logo_zone,
nullptr,
nullptr
},
nullptr,
0
};
/*-------------------------------------------------------------------------*\
| DEVICE MASTER LIST |
\*-------------------------------------------------------------------------*/
const corsair_v2_device* corsair_v2_device_list_data[] =
{
/*-----------------------------------------------------------------*\
| KEYBOARDS |
\*-----------------------------------------------------------------*/
&k55_rgb_pro_device,
/*-----------------------------------------------------------------*\
| MOUSEMATS |
\*-----------------------------------------------------------------*/
&mm700_device,
};
const unsigned int CORSAIR_V2_DEVICE_COUNT = (sizeof(corsair_v2_device_list) / sizeof(corsair_v2_device_list[ 0 ]));
const corsair_v2_device** corsair_v2_device_list = corsair_v2_device_list_data;

View file

@ -18,7 +18,7 @@ typedef struct
zone_type type;
uint8_t rows;
uint8_t cols;
} corsair_zone;
} corsair_v2_zone;
typedef struct
{
@ -26,7 +26,7 @@ typedef struct
uint8_t row;
uint8_t col;
const char* name;
} corsair_led;
} corsair_v2_led;
typedef struct
{
@ -36,10 +36,10 @@ typedef struct
uint8_t supports;
uint8_t rows;
uint8_t cols;
const corsair_zone* zones[CORSAIR_ZONES_MAX];
const corsair_led* layout;
const corsair_v2_zone* zones[CORSAIR_ZONES_MAX];
const corsair_v2_led* layout;
uint16_t layout_size;
} corsair_device;
} corsair_v2_device;
/*-----------------------------------------------------*\
| Corsair V2 Protocol Keyboards |
@ -51,109 +51,9 @@ typedef struct
\*-----------------------------------------------------*/
#define CORSAIR_MM700_PID 0x1B9B
/*-------------------------------------------------------------*\
| Corsair K55 RGB Pro 1B1C:1BA4 |
| |
| Zone "Keyboard" |
| Linear |
| 1 Row, 6 Columns |
\*-------------------------------------------------------------*/
static const corsair_zone k55_rgb_pro_zone =
{
ZONE_EN_KEYBOARD,
ZONE_TYPE_LINEAR,
1,
6
};
static const corsair_device k55_rgb_pro_device =
{
CORSAIR_K55_RGB_PRO_PID,
false,
DEVICE_TYPE_KEYBOARD,
CORSAIR_V2_MODE_SW,
1,
6,
{
&k55_rgb_pro_zone,
nullptr,
nullptr,
nullptr,
nullptr
},
nullptr,
0
};
/*-------------------------------------------------------------*\
| Corsair MM700 1B1C:1B9B |
| |
| Zone "Logo" |
| Single |
| |
| Zone "Edge" |
| Linear |
| 1 Row, 2 Columns |
\*-------------------------------------------------------------*/
static const corsair_zone mm700_right_zone =
{
"Right",
ZONE_TYPE_SINGLE,
1,
1
};
static const corsair_zone mm700_logo_zone =
{
"Logo",
ZONE_TYPE_SINGLE,
1,
1
};
static const corsair_zone mm700_left_zone =
{
"Left",
ZONE_TYPE_SINGLE,
1,
1
};
static const corsair_device mm700_device =
{
CORSAIR_MM700_PID,
false,
DEVICE_TYPE_MOUSEMAT,
CORSAIR_V2_MODE_SW,
1,
3,
{
&mm700_left_zone,
&mm700_right_zone,
&mm700_logo_zone,
nullptr,
nullptr
},
nullptr,
0
};
/*-------------------------------------------------------------------------*\
| DEVICE MASTER LIST |
\*-------------------------------------------------------------------------*/
#define CORSAIR_DEVICE_COUNT (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const corsair_device* device_list[] =
{
/*-----------------------------------------------------------------*\
| KEYBOARDS |
\*-----------------------------------------------------------------*/
&k55_rgb_pro_device,
/*-----------------------------------------------------------------*\
| MOUSEMATS |
\*-----------------------------------------------------------------*/
&mm700_device,
};
/*-----------------------------------------------------*\
| These constant values are defined in |
| CorsairPeripheralV2Devices.cpp |
\*-----------------------------------------------------*/
extern const unsigned int CORSAIR_V2_DEVICE_COUNT;
extern const corsair_v2_device** corsair_v2_device_list;

View file

@ -25,39 +25,39 @@ using namespace std::chrono_literals;
RGBController_CorsairV2SW::RGBController_CorsairV2SW(CorsairPeripheralV2Controller *controller_ptr)
{
controller = controller_ptr;
const corsair_device* corsair = controller->GetDeviceData();
controller = controller_ptr;
const corsair_v2_device* corsair = controller->GetDeviceData();
vendor = "Corsair";
description = controller->GetName();
type = corsair->type;
version = controller->GetFirmwareString();
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
vendor = "Corsair";
description = controller->GetName();
type = corsair->type;
version = controller->GetFirmwareString();
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
if(corsair->supports & CORSAIR_V2_MODE_SW)
{
mode Direct;
Direct.name = "Direct";
Direct.value = CORSAIR_V2_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
Direct.name = "Direct";
Direct.value = CORSAIR_V2_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
}
if(corsair->supports & CORSAIR_V2_MODE_HW)
{
mode Static;
Static.name = "Static";
Static.value = CORSAIR_V2_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Static.colors_min = 1;
Static.colors_max = 1;
Static.name = "Static";
Static.value = CORSAIR_V2_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Static.colors_min = 1;
Static.colors_max = 1;
Static.colors.resize(Static.colors_max);
Static.brightness_min = CORSAIR_V2_BRIGHTNESS_MIN;
Static.brightness_max = CORSAIR_V2_BRIGHTNESS_MAX;
Static.brightness = CORSAIR_V2_BRIGHTNESS_MAX;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.brightness_min = CORSAIR_V2_BRIGHTNESS_MIN;
Static.brightness_max = CORSAIR_V2_BRIGHTNESS_MAX;
Static.brightness = CORSAIR_V2_BRIGHTNESS_MAX;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
modes.push_back(Static);
}
@ -68,8 +68,8 @@ RGBController_CorsairV2SW::RGBController_CorsairV2SW(CorsairPeripheralV2Controll
| to not revert back into rainbow mode. Start a thread |
| to continuously send a keepalive packet every 50 sec |
\*-----------------------------------------------------*/
keepalive_thread_run = true;
keepalive_thread = new std::thread(&RGBController_CorsairV2SW::KeepaliveThread, this);
keepalive_thread_run = true;
keepalive_thread = new std::thread(&RGBController_CorsairV2SW::KeepaliveThread, this);
}
RGBController_CorsairV2SW::~RGBController_CorsairV2SW()
@ -97,7 +97,7 @@ RGBController_CorsairV2SW::~RGBController_CorsairV2SW()
void RGBController_CorsairV2SW::SetupZones()
{
const corsair_device* corsair = controller->GetDeviceData();
const corsair_v2_device* corsair = controller->GetDeviceData();
/*---------------------------------------------------------*\
| Fill in zones from the device data |

View file

@ -90,6 +90,7 @@ INCLUDEPATH +=
Controllers/CorsairHydroController/ \
Controllers/CorsairHydroPlatinumController/ \
Controllers/CorsairPeripheralController/ \
Controllers/CorsairPeripheralV2Controller/ \
Controllers/CorsairLightingNodeController/ \
Controllers/CorsairVengeanceController/ \
Controllers/CorsairVengeanceProController/ \
@ -824,6 +825,7 @@ SOURCES +=
Controllers/CorsairPeripheralController/RGBController_CorsairK55RGBPROXT.cpp \
Controllers/CorsairPeripheralController/RGBController_CorsairK65Mini.cpp \
Controllers/CorsairPeripheralController/RGBController_CorsairK95PlatinumXT.cpp \
Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Devices.cpp \
Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2Controller.cpp \
Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2ControllerDetect.cpp \
Controllers/CorsairPeripheralV2Controller/CorsairPeripheralV2SoftwareController.cpp \