mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-03-08 00:00:22 -05:00
Initial development for Translations suppport in RGBController API
This commit is contained in:
@@ -58,6 +58,7 @@ zone::~zone()
|
||||
|
||||
RGBController::RGBController()
|
||||
{
|
||||
translation = NULL;
|
||||
DeviceThreadRunning = true;
|
||||
DeviceCallThread = new std::thread(&RGBController::DeviceCallThreadFunction, this);
|
||||
}
|
||||
@@ -74,6 +75,123 @@ RGBController::~RGBController()
|
||||
modes.clear();
|
||||
}
|
||||
|
||||
std::string RGBController::GetName()
|
||||
{
|
||||
if(translation != NULL)
|
||||
{
|
||||
if(translation->name != "")
|
||||
{
|
||||
return(translation->name);
|
||||
}
|
||||
}
|
||||
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string RGBController::GetVendor()
|
||||
{
|
||||
if(translation != NULL)
|
||||
{
|
||||
if(translation->vendor != "")
|
||||
{
|
||||
return(translation->vendor);
|
||||
}
|
||||
}
|
||||
|
||||
return(vendor);
|
||||
}
|
||||
|
||||
std::string RGBController::GetDescription()
|
||||
{
|
||||
if(translation != NULL)
|
||||
{
|
||||
if(translation->description != "")
|
||||
{
|
||||
return(translation->description);
|
||||
}
|
||||
}
|
||||
|
||||
return(description);
|
||||
}
|
||||
|
||||
std::string RGBController::GetVersion()
|
||||
{
|
||||
if(translation != NULL)
|
||||
{
|
||||
if(translation->version != "")
|
||||
{
|
||||
return(translation->version);
|
||||
}
|
||||
}
|
||||
|
||||
return(version);
|
||||
}
|
||||
|
||||
std::string RGBController::GetSerial()
|
||||
{
|
||||
if(translation != NULL)
|
||||
{
|
||||
if(translation->serial != "")
|
||||
{
|
||||
return(translation->serial);
|
||||
}
|
||||
}
|
||||
|
||||
return(serial);
|
||||
}
|
||||
|
||||
std::string RGBController::GetLocation()
|
||||
{
|
||||
if(translation != NULL)
|
||||
{
|
||||
if(translation->location != "")
|
||||
{
|
||||
return(translation->location);
|
||||
}
|
||||
}
|
||||
|
||||
return(location);
|
||||
}
|
||||
|
||||
std::string RGBController::GetModeName(unsigned int mode)
|
||||
{
|
||||
if(translation != NULL)
|
||||
{
|
||||
if(translation->modes[mode] != "")
|
||||
{
|
||||
return(translation->modes[mode]);
|
||||
}
|
||||
}
|
||||
|
||||
return(modes[mode].name);
|
||||
}
|
||||
|
||||
std::string RGBController::GetZoneName(unsigned int zone)
|
||||
{
|
||||
if(translation != NULL)
|
||||
{
|
||||
if(translation->zones[zone] != "")
|
||||
{
|
||||
return(translation->zones[zone]);
|
||||
}
|
||||
}
|
||||
|
||||
return(zones[zone].name);
|
||||
}
|
||||
|
||||
std::string RGBController::GetLEDName(unsigned int led)
|
||||
{
|
||||
if(translation != NULL)
|
||||
{
|
||||
if(translation->leds[led] != "")
|
||||
{
|
||||
return(translation->leds[led]);
|
||||
}
|
||||
}
|
||||
|
||||
return(leds[led].name);
|
||||
}
|
||||
|
||||
unsigned char * RGBController::GetDeviceDescription(unsigned int protocol_version)
|
||||
{
|
||||
unsigned int data_ptr = 0;
|
||||
|
||||
@@ -215,6 +215,26 @@ enum
|
||||
DEVICE_TYPE_UNKNOWN,
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
| Translation Data Struct |
|
||||
| Leave string empty if no translation provided |
|
||||
| If translation data is used, modes/zones/leds vectors must be |
|
||||
| resized to match the modes/zones/leds vectors in the main class |
|
||||
\*------------------------------------------------------------------*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name; /* controller name */
|
||||
std::string vendor; /* controller vendor */
|
||||
std::string description;/* controller description */
|
||||
std::string version; /* controller version */
|
||||
std::string serial; /* controller serial number */
|
||||
std::string location; /* controller location */
|
||||
std::vector<std::string> modes; /* mode names */
|
||||
std::vector<std::string> zones; /* zone names */
|
||||
std::vector<std::string> leds; /* led names */
|
||||
} translation_data;
|
||||
|
||||
/*------------------------------------------------------------------*\
|
||||
| RGBController Callback Types |
|
||||
\*------------------------------------------------------------------*/
|
||||
@@ -228,6 +248,16 @@ public:
|
||||
virtual void SetupColors() = 0;
|
||||
|
||||
virtual unsigned int GetLEDsInZone(unsigned int zone) = 0;
|
||||
virtual std::string GetName() = 0;
|
||||
virtual std::string GetVendor() = 0;
|
||||
virtual std::string GetDescription() = 0;
|
||||
virtual std::string GetVersion() = 0;
|
||||
virtual std::string GetSerial() = 0;
|
||||
virtual std::string GetLocation() = 0;
|
||||
|
||||
virtual std::string GetModeName(unsigned int mode) = 0;
|
||||
virtual std::string GetZoneName(unsigned int zone) = 0;
|
||||
virtual std::string GetLEDName(unsigned int led) = 0;
|
||||
|
||||
virtual RGBColor GetLED(unsigned int led) = 0;
|
||||
virtual void SetLED(unsigned int led, RGBColor color) = 0;
|
||||
@@ -298,6 +328,7 @@ public:
|
||||
std::vector<RGBColor> colors; /* Color buffer */
|
||||
device_type type; /* device type */
|
||||
int active_mode = 0;/* active mode */
|
||||
translation_data* translation; /* optional translation data*/
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController base class constructor |
|
||||
@@ -311,6 +342,16 @@ public:
|
||||
void SetupColors();
|
||||
|
||||
unsigned int GetLEDsInZone(unsigned int zone);
|
||||
std::string GetName();
|
||||
std::string GetVendor();
|
||||
std::string GetDescription();
|
||||
std::string GetVersion();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
std::string GetModeName(unsigned int mode);
|
||||
std::string GetZoneName(unsigned int zone);
|
||||
std::string GetLEDName(unsigned int led);
|
||||
|
||||
RGBColor GetLED(unsigned int led);
|
||||
void SetLED(unsigned int led, RGBColor color);
|
||||
|
||||
Reference in New Issue
Block a user