Add controller flags field with flags for controller location and update behavior
This commit is contained in:
parent
1967ec9526
commit
bb79fbfc07
5 changed files with 75 additions and 5 deletions
|
|
@ -593,6 +593,12 @@ void NetworkClient::ProcessReply_ControllerData(unsigned int data_size, char * d
|
||||||
|
|
||||||
new_controller->ReadDeviceDescription((unsigned char *)data, GetProtocolVersion());
|
new_controller->ReadDeviceDescription((unsigned char *)data, GetProtocolVersion());
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Mark this controller as remote owned |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
new_controller->flags &= ~CONTROLLER_FLAG_LOCAL;
|
||||||
|
new_controller->flags |= CONTROLLER_FLAG_REMOTE;
|
||||||
|
|
||||||
ControllerListMutex.lock();
|
ControllerListMutex.lock();
|
||||||
|
|
||||||
if(dev_idx >= server_controllers.size())
|
if(dev_idx >= server_controllers.size())
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@
|
||||||
| 2: Add profile controls (Release 0.6) |
|
| 2: Add profile controls (Release 0.6) |
|
||||||
| 3: Add brightness field to modes (Release 0.7) |
|
| 3: Add brightness field to modes (Release 0.7) |
|
||||||
| 4: Add segments field to zones, network plugins (Release 0.9) |
|
| 4: Add segments field to zones, network plugins (Release 0.9) |
|
||||||
| 5: Zone flags, resizable effects-only zones (Release 1.0) |
|
| 5: Zone flags, controller flags, resizable effects-only zones |
|
||||||
|
(Release 1.0) |
|
||||||
\*---------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------*/
|
||||||
#define OPENRGB_SDK_PROTOCOL_VERSION 5
|
#define OPENRGB_SDK_PROTOCOL_VERSION 5
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ zone::~zone()
|
||||||
|
|
||||||
RGBController::RGBController()
|
RGBController::RGBController()
|
||||||
{
|
{
|
||||||
|
flags = 0;
|
||||||
DeviceThreadRunning = true;
|
DeviceThreadRunning = true;
|
||||||
DeviceCallThread = new std::thread(&RGBController::DeviceCallThreadFunction, this);
|
DeviceCallThread = new std::thread(&RGBController::DeviceCallThreadFunction, this);
|
||||||
}
|
}
|
||||||
|
|
@ -288,6 +289,14 @@ unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_versio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Controller flags |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
if(protocol_version >= 5)
|
||||||
|
{
|
||||||
|
data_size += sizeof(flags);
|
||||||
|
}
|
||||||
|
|
||||||
data_size += sizeof(num_colors);
|
data_size += sizeof(num_colors);
|
||||||
data_size += num_colors * sizeof(RGBColor);
|
data_size += num_colors * sizeof(RGBColor);
|
||||||
|
|
||||||
|
|
@ -731,6 +740,15 @@ unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_versio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Controller flags data |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
if(protocol_version >= 5)
|
||||||
|
{
|
||||||
|
memcpy(&data_buf[data_ptr], &flags, sizeof(flags));
|
||||||
|
data_ptr += sizeof(flags);
|
||||||
|
}
|
||||||
|
|
||||||
delete[] mode_name_len;
|
delete[] mode_name_len;
|
||||||
delete[] zone_name_len;
|
delete[] zone_name_len;
|
||||||
delete[] led_name_len;
|
delete[] led_name_len;
|
||||||
|
|
@ -1188,6 +1206,15 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf, unsigned int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Copy in controller flags data |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
if(protocol_version >= 5)
|
||||||
|
{
|
||||||
|
memcpy(&flags, &data_buf[data_ptr], sizeof(flags));
|
||||||
|
data_ptr += sizeof(flags);
|
||||||
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------*\
|
/*---------------------------------------------------------*\
|
||||||
| Setup colors |
|
| Setup colors |
|
||||||
\*---------------------------------------------------------*/
|
\*---------------------------------------------------------*/
|
||||||
|
|
@ -2090,13 +2117,29 @@ void RGBController::DeviceCallThreadFunction()
|
||||||
{
|
{
|
||||||
if(CallFlag_UpdateMode.load() == true)
|
if(CallFlag_UpdateMode.load() == true)
|
||||||
{
|
{
|
||||||
DeviceUpdateMode();
|
if(flags & CONTROLLER_FLAG_RESET_BEFORE_UPDATE)
|
||||||
CallFlag_UpdateMode = false;
|
{
|
||||||
|
CallFlag_UpdateMode = false;
|
||||||
|
DeviceUpdateMode();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DeviceUpdateMode();
|
||||||
|
CallFlag_UpdateMode = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(CallFlag_UpdateLEDs.load() == true)
|
if(CallFlag_UpdateLEDs.load() == true)
|
||||||
{
|
{
|
||||||
DeviceUpdateLEDs();
|
if(flags & CONTROLLER_FLAG_RESET_BEFORE_UPDATE)
|
||||||
CallFlag_UpdateLEDs = false;
|
{
|
||||||
|
CallFlag_UpdateLEDs = false;
|
||||||
|
DeviceUpdateLEDs();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DeviceUpdateLEDs();
|
||||||
|
CallFlag_UpdateLEDs = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -215,6 +215,19 @@ enum
|
||||||
DEVICE_TYPE_UNKNOWN,
|
DEVICE_TYPE_UNKNOWN,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------*\
|
||||||
|
| Controller Flags |
|
||||||
|
\*------------------------------------------------------------------*/
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CONTROLLER_FLAG_LOCAL = (1 << 0), /* Device is local to this instance */
|
||||||
|
CONTROLLER_FLAG_REMOTE = (1 << 1), /* Device is on a remote instance */
|
||||||
|
CONTROLLER_FLAG_VIRTUAL = (1 << 2), /* Device is a virtual device */
|
||||||
|
|
||||||
|
CONTROLLER_FLAG_RESET_BEFORE_UPDATE = (1 << 8), /* Device resets update flag before */
|
||||||
|
/* calling update function */
|
||||||
|
};
|
||||||
|
|
||||||
/*------------------------------------------------------------------*\
|
/*------------------------------------------------------------------*\
|
||||||
| RGBController Callback Types |
|
| RGBController Callback Types |
|
||||||
\*------------------------------------------------------------------*/
|
\*------------------------------------------------------------------*/
|
||||||
|
|
@ -313,6 +326,7 @@ public:
|
||||||
int active_mode = 0;/* active mode */
|
int active_mode = 0;/* active mode */
|
||||||
std::vector<std::string>
|
std::vector<std::string>
|
||||||
led_alt_names; /* alternate LED names */
|
led_alt_names; /* alternate LED names */
|
||||||
|
unsigned int flags; /* controller flags */
|
||||||
|
|
||||||
/*---------------------------------------------------------*\
|
/*---------------------------------------------------------*\
|
||||||
| RGBController base class constructor |
|
| RGBController base class constructor |
|
||||||
|
|
|
||||||
|
|
@ -255,6 +255,12 @@ std::vector<i2c_smbus_interface*> & ResourceManager::GetI2CBusses()
|
||||||
|
|
||||||
void ResourceManager::RegisterRGBController(RGBController *rgb_controller)
|
void ResourceManager::RegisterRGBController(RGBController *rgb_controller)
|
||||||
{
|
{
|
||||||
|
/*-------------------------------------------------*\
|
||||||
|
| Mark this controller as locally owned |
|
||||||
|
\*-------------------------------------------------*/
|
||||||
|
rgb_controller->flags &= ~CONTROLLER_FLAG_REMOTE;
|
||||||
|
rgb_controller->flags |= CONTROLLER_FLAG_LOCAL;
|
||||||
|
|
||||||
LOG_INFO("[%s] Registering RGB controller", rgb_controller->name.c_str());
|
LOG_INFO("[%s] Registering RGB controller", rgb_controller->name.c_str());
|
||||||
rgb_controllers_hw.push_back(rgb_controller);
|
rgb_controllers_hw.push_back(rgb_controller);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue