Added brightness to profile loading and saving
* Bumped profile version to 3 * Loading a v1/v2 profile onto a device with brightness will work * Loading a v3 profile onto a device without brightness also works * Add profile version parameter to Get/SetModeDescription Commit amended for code style and to update versioning by Adam Honse <calcprogrammer1@gmail.com>
This commit is contained in:
parent
6fd2ea9276
commit
a46eccef3c
6 changed files with 130 additions and 20 deletions
|
|
@ -14,8 +14,9 @@
|
|||
| 0: Initial (unversioned) protocol |
|
||||
| 1: Add versioning, vendor string (Release 0.5) |
|
||||
| 2: Add profile controls (Release 0.6) |
|
||||
| 3: Add brightness field to modes (Release 0.7) |
|
||||
\*-----------------------------------------------------*/
|
||||
#define OPENRGB_SDK_PROTOCOL_VERSION 2
|
||||
#define OPENRGB_SDK_PROTOCOL_VERSION 3
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Default OpenRGB SDK port is 6742 |
|
||||
|
|
|
|||
|
|
@ -685,7 +685,7 @@ void NetworkServer::ListenThreadFunction(NetworkClientInfo * client_info)
|
|||
|
||||
if(header.pkt_dev_idx < controllers.size())
|
||||
{
|
||||
controllers[header.pkt_dev_idx]->SetModeDescription((unsigned char *)data);
|
||||
controllers[header.pkt_dev_idx]->SetModeDescription((unsigned char *)data, client_info->client_protocol_version);
|
||||
controllers[header.pkt_dev_idx]->UpdateMode();
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -278,10 +278,13 @@ bool ProfileManager::LoadDeviceFromListWithOptions
|
|||
&&(temp_controller->modes[mode_index].flags == load_controller->modes[mode_index].flags )
|
||||
&&(temp_controller->modes[mode_index].speed_min == load_controller->modes[mode_index].speed_min )
|
||||
&&(temp_controller->modes[mode_index].speed_max == load_controller->modes[mode_index].speed_max )
|
||||
&&(temp_controller->modes[mode_index].colors_min == load_controller->modes[mode_index].colors_min)
|
||||
&&(temp_controller->modes[mode_index].colors_max == load_controller->modes[mode_index].colors_max))
|
||||
//&&(temp_controller->modes[mode_index].brightness_min == load_controller->modes[mode_index].brightness_min)
|
||||
//&&(temp_controller->modes[mode_index].brightness_max == load_controller->modes[mode_index].brightness_max)
|
||||
&&(temp_controller->modes[mode_index].colors_min == load_controller->modes[mode_index].colors_min )
|
||||
&&(temp_controller->modes[mode_index].colors_max == load_controller->modes[mode_index].colors_max ))
|
||||
{
|
||||
load_controller->modes[mode_index].speed = temp_controller->modes[mode_index].speed;
|
||||
load_controller->modes[mode_index].brightness = temp_controller->modes[mode_index].brightness;
|
||||
load_controller->modes[mode_index].direction = temp_controller->modes[mode_index].direction;
|
||||
load_controller->modes[mode_index].color_mode = temp_controller->modes[mode_index].color_mode;
|
||||
|
||||
|
|
|
|||
|
|
@ -90,9 +90,18 @@ unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_versio
|
|||
data_size += sizeof(modes[mode_index].flags);
|
||||
data_size += sizeof(modes[mode_index].speed_min);
|
||||
data_size += sizeof(modes[mode_index].speed_max);
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
data_size += sizeof(modes[mode_index].brightness_min);
|
||||
data_size += sizeof(modes[mode_index].brightness_max);
|
||||
}
|
||||
data_size += sizeof(modes[mode_index].colors_min);
|
||||
data_size += sizeof(modes[mode_index].colors_max);
|
||||
data_size += sizeof(modes[mode_index].speed);
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
data_size += sizeof(modes[mode_index].brightness);
|
||||
}
|
||||
data_size += sizeof(modes[mode_index].direction);
|
||||
data_size += sizeof(modes[mode_index].color_mode);
|
||||
data_size += sizeof(mode_num_colors[mode_index]);
|
||||
|
|
@ -262,6 +271,19 @@ unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_versio
|
|||
memcpy(&data_buf[data_ptr], &modes[mode_index].speed_max, sizeof(modes[mode_index].speed_max));
|
||||
data_ptr += sizeof(modes[mode_index].speed_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness_min and brightness_max (data) if |
|
||||
| protocol 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&data_buf[data_ptr], &modes[mode_index].brightness_min, sizeof(modes[mode_index].brightness_min));
|
||||
data_ptr += sizeof(modes[mode_index].brightness_min);
|
||||
|
||||
memcpy(&data_buf[data_ptr], &modes[mode_index].brightness_max, sizeof(modes[mode_index].brightness_max));
|
||||
data_ptr += sizeof(modes[mode_index].brightness_max);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -280,6 +302,15 @@ unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_versio
|
|||
memcpy(&data_buf[data_ptr], &modes[mode_index].speed, sizeof(modes[mode_index].speed));
|
||||
data_ptr += sizeof(modes[mode_index].speed);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness (data) if protocol 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&data_buf[data_ptr], &modes[mode_index].brightness, sizeof(modes[mode_index].brightness));
|
||||
data_ptr += sizeof(modes[mode_index].brightness);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode direction (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -468,7 +499,7 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf, unsigned int
|
|||
data_ptr += name_len;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in vendor if profile version is 1 or higher |
|
||||
| Copy in vendor if protocol version is 1 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 1)
|
||||
{
|
||||
|
|
@ -574,6 +605,19 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf, unsigned int
|
|||
memcpy(&new_mode.speed_max, &data_buf[data_ptr], sizeof(new_mode.speed_max));
|
||||
data_ptr += sizeof(new_mode.speed_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness min and max if protocol version |
|
||||
| is 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&new_mode.brightness_min, &data_buf[data_ptr], sizeof(new_mode.brightness_min));
|
||||
data_ptr += sizeof(new_mode.brightness_min);
|
||||
|
||||
memcpy(&new_mode.brightness_max, &data_buf[data_ptr], sizeof(new_mode.brightness_max));
|
||||
data_ptr += sizeof(new_mode.brightness_max);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -592,6 +636,15 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf, unsigned int
|
|||
memcpy(&new_mode.speed, &data_buf[data_ptr], sizeof(new_mode.speed));
|
||||
data_ptr += sizeof(new_mode.speed);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness if protocol version is 3 or higher|
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&new_mode.brightness, &data_buf[data_ptr], sizeof(new_mode.brightness));
|
||||
data_ptr += sizeof(new_mode.brightness);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode direction (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -790,7 +843,7 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf, unsigned int
|
|||
SetupColors();
|
||||
}
|
||||
|
||||
unsigned char * RGBController::GetModeDescription(int mode)
|
||||
unsigned char * RGBController::GetModeDescription(int mode, unsigned int protocol_version)
|
||||
{
|
||||
unsigned int data_ptr = 0;
|
||||
unsigned int data_size = 0;
|
||||
|
|
@ -812,9 +865,18 @@ unsigned char * RGBController::GetModeDescription(int mode)
|
|||
data_size += sizeof(modes[mode].flags);
|
||||
data_size += sizeof(modes[mode].speed_min);
|
||||
data_size += sizeof(modes[mode].speed_max);
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
data_size += sizeof(modes[mode].brightness_min);
|
||||
data_size += sizeof(modes[mode].brightness_max);
|
||||
}
|
||||
data_size += sizeof(modes[mode].colors_min);
|
||||
data_size += sizeof(modes[mode].colors_max);
|
||||
data_size += sizeof(modes[mode].speed);
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
data_size += sizeof(modes[mode].brightness);
|
||||
}
|
||||
data_size += sizeof(modes[mode].direction);
|
||||
data_size += sizeof(modes[mode].color_mode);
|
||||
data_size += sizeof(mode_num_colors);
|
||||
|
|
@ -870,6 +932,19 @@ unsigned char * RGBController::GetModeDescription(int mode)
|
|||
memcpy(&data_buf[data_ptr], &modes[mode].speed_max, sizeof(modes[mode].speed_max));
|
||||
data_ptr += sizeof(modes[mode].speed_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness min and max if protocol version |
|
||||
| is 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].brightness_min, sizeof(modes[mode].brightness_min));
|
||||
data_ptr += sizeof(modes[mode].brightness_min);
|
||||
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].brightness_max, sizeof(modes[mode].brightness_max));
|
||||
data_ptr += sizeof(modes[mode].brightness_max);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -888,6 +963,15 @@ unsigned char * RGBController::GetModeDescription(int mode)
|
|||
memcpy(&data_buf[data_ptr], &modes[mode].speed, sizeof(modes[mode].speed));
|
||||
data_ptr += sizeof(modes[mode].speed);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness if protocol version is 3 or higher|
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&data_buf[data_ptr], &modes[mode].brightness, sizeof(modes[mode].brightness));
|
||||
data_ptr += sizeof(modes[mode].brightness);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode direction (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -921,7 +1005,7 @@ unsigned char * RGBController::GetModeDescription(int mode)
|
|||
return(data_buf);
|
||||
}
|
||||
|
||||
void RGBController::SetModeDescription(unsigned char* data_buf)
|
||||
void RGBController::SetModeDescription(unsigned char* data_buf, unsigned int protocol_version)
|
||||
{
|
||||
int mode_idx;
|
||||
unsigned int data_ptr = sizeof(unsigned int);
|
||||
|
|
@ -984,6 +1068,19 @@ void RGBController::SetModeDescription(unsigned char* data_buf)
|
|||
memcpy(&new_mode->speed_max, &data_buf[data_ptr], sizeof(new_mode->speed_max));
|
||||
data_ptr += sizeof(new_mode->speed_max);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness_min and brightness_max (data) if |
|
||||
| protocol 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&new_mode->brightness_min, &data_buf[data_ptr], sizeof(new_mode->brightness_min));
|
||||
data_ptr += sizeof(new_mode->brightness_min);
|
||||
|
||||
memcpy(&new_mode->brightness_max, &data_buf[data_ptr], sizeof(new_mode->brightness_max));
|
||||
data_ptr += sizeof(new_mode->brightness_max);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode colors_min (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
@ -1002,6 +1099,15 @@ void RGBController::SetModeDescription(unsigned char* data_buf)
|
|||
memcpy(&new_mode->speed, &data_buf[data_ptr], sizeof(new_mode->speed));
|
||||
data_ptr += sizeof(new_mode->speed);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode brightness (data) if protocol 3 or higher |
|
||||
\*---------------------------------------------------------*/
|
||||
if(protocol_version >= 3)
|
||||
{
|
||||
memcpy(&new_mode->brightness, &data_buf[data_ptr], sizeof(new_mode->brightness));
|
||||
data_ptr += sizeof(new_mode->brightness);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in mode direction (data) |
|
||||
\*---------------------------------------------------------*/
|
||||
|
|
|
|||
|
|
@ -172,8 +172,8 @@ public:
|
|||
virtual unsigned char * GetDeviceDescription(unsigned int protocol_version) = 0;
|
||||
virtual void ReadDeviceDescription(unsigned char* data_buf, unsigned int protocol_version) = 0;
|
||||
|
||||
virtual unsigned char * GetModeDescription(int mode) = 0;
|
||||
virtual void SetModeDescription(unsigned char* data_buf) = 0;
|
||||
virtual unsigned char * GetModeDescription(int mode, unsigned int protocol_version) = 0;
|
||||
virtual void SetModeDescription(unsigned char* data_buf, unsigned int protocol_version) = 0;
|
||||
|
||||
virtual unsigned char * GetColorDescription() = 0;
|
||||
virtual void SetColorDescription(unsigned char* data_buf) = 0;
|
||||
|
|
@ -251,8 +251,8 @@ public:
|
|||
unsigned char * GetDeviceDescription(unsigned int protocol_version);
|
||||
void ReadDeviceDescription(unsigned char* data_buf, unsigned int protocol_version);
|
||||
|
||||
unsigned char * GetModeDescription(int mode);
|
||||
void SetModeDescription(unsigned char* data_buf);
|
||||
unsigned char * GetModeDescription(int mode, unsigned int protocol_version);
|
||||
void SetModeDescription(unsigned char* data_buf, unsigned int protocol_version);
|
||||
|
||||
unsigned char * GetColorDescription();
|
||||
void SetColorDescription(unsigned char* data_buf);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ void RGBController_Network::SetCustomMode()
|
|||
|
||||
void RGBController_Network::DeviceUpdateMode()
|
||||
{
|
||||
unsigned char * data = GetModeDescription(active_mode);
|
||||
unsigned char * data = GetModeDescription(active_mode, client->GetProtocolVersion());
|
||||
unsigned int size;
|
||||
|
||||
memcpy(&size, &data[0], sizeof(unsigned int));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue