Loading OpenRGBPluginAPI.cpp +87 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ \*---------------------------------------------------------*/ #include "OpenRGBPluginAPI.h" #include "RGBController_Dummy.h" #include "RGBController_Virtual.h" OpenRGBPluginAPI::OpenRGBPluginAPI() Loading Loading @@ -185,6 +186,11 @@ bool OpenRGBPluginAPI::LoadProfile(std::string profile_name) return(profile_manager->LoadProfile(profile_name)); } bool OpenRGBPluginAPI::SaveProfileFromPlugin(std::string profile_name, std::string plugin_name, nlohmann::json plugin_data) { return(profile_manager->SaveProfileFromPlugin(profile_name, plugin_name, plugin_data)); } /*---------------------------------------------------------*\ | ResourceManager APIs | \*---------------------------------------------------------*/ Loading Loading @@ -223,6 +229,87 @@ std::vector<RGBControllerInterface*> OpenRGBPluginAPI::GetRGBControllers() return(resource_manager->GetRGBControllerInterfaces()); } /*---------------------------------------------------------*\ | RGBController APIs | \*---------------------------------------------------------*/ nlohmann::json OpenRGBPluginAPI::GetDeviceDescriptionJSON(RGBControllerInterface* controller) { return(RGBController::GetDeviceDescriptionJSON((RGBController*)controller)); } nlohmann::json OpenRGBPluginAPI::GetLEDDescriptionJSON(led led) { return(RGBController::GetLEDDescriptionJSON(led)); } nlohmann::json OpenRGBPluginAPI::GetMatrixMapDescriptionJSON(matrix_map_type matrix_map) { return(RGBController::GetMatrixMapDescriptionJSON(matrix_map)); } nlohmann::json OpenRGBPluginAPI::GetModeDescriptionJSON(mode mode) { return(RGBController::GetModeDescriptionJSON(mode)); } nlohmann::json OpenRGBPluginAPI::GetSegmentDescriptionJSON(segment segment) { return(RGBController::GetSegmentDescriptionJSON(segment)); } nlohmann::json OpenRGBPluginAPI::GetZoneDescriptionJSON(zone zone) { return(RGBController::GetZoneDescriptionJSON(zone)); } RGBControllerInterface* OpenRGBPluginAPI::SetDeviceDescriptionJSON(nlohmann::json controller_json) { RGBController_Dummy* new_controller = new RGBController_Dummy(); RGBController::SetDeviceDescriptionJSON(controller_json, (RGBController*)new_controller); return(new_controller); } led OpenRGBPluginAPI::SetLEDDescriptionJSON(nlohmann::json led_json) { return(RGBController::SetLEDDescriptionJSON(led_json)); } matrix_map_type OpenRGBPluginAPI::SetMatrixMapDescriptionJSON(nlohmann::json matrix_map_json) { return(RGBController::SetMatrixMapDescriptionJSON(matrix_map_json)); } mode OpenRGBPluginAPI::SetModeDescriptionJSON(nlohmann::json mode_json) { return(RGBController::SetModeDescriptionJSON(mode_json)); } segment OpenRGBPluginAPI::SetSegmentDescriptionJSON(nlohmann::json segment_json) { return(RGBController::SetSegmentDescriptionJSON(segment_json)); } zone OpenRGBPluginAPI::SetZoneDescriptionJSON(nlohmann::json zone_json) { return(RGBController::SetZoneDescriptionJSON(zone_json)); } bool OpenRGBPluginAPI::CompareControllers(RGBControllerInterface* controller_1, RGBControllerInterface* controller_2) { return(RGBController::CompareControllers((RGBController*)controller_1, (RGBController*)controller_2)); } std::string OpenRGBPluginAPI::DeviceTypeToString(device_type type) { return(RGBController::DeviceTypeToString(type)); } bool OpenRGBPluginAPI::SetModeValuesFromMode(mode& destination, mode& source) { return(RGBController::SetModeValuesFromMode(destination, source)); } /*---------------------------------------------------------*\ | SettingsManager APIs | \*---------------------------------------------------------*/ Loading OpenRGBPluginAPI.h +22 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ public: void ClearActiveProfile(); std::vector<std::string> GetProfileList(); bool LoadProfile(std::string profile_name); bool SaveProfileFromPlugin(std::string profile_name, std::string plugin_name, nlohmann::json plugin_data); /*-----------------------------------------------------*\ | ResourceManager APIs | Loading @@ -57,6 +58,27 @@ public: void WaitForDetection(); std::vector<RGBControllerInterface*> GetRGBControllers(); /*-----------------------------------------------------*\ | RGBController APIs | \*-----------------------------------------------------*/ nlohmann::json GetDeviceDescriptionJSON(RGBControllerInterface* controller); nlohmann::json GetLEDDescriptionJSON(led led); nlohmann::json GetMatrixMapDescriptionJSON(matrix_map_type matrix_map); nlohmann::json GetModeDescriptionJSON(mode mode); nlohmann::json GetSegmentDescriptionJSON(segment segment); nlohmann::json GetZoneDescriptionJSON(zone zone); RGBControllerInterface* SetDeviceDescriptionJSON(nlohmann::json controller_json); led SetLEDDescriptionJSON(nlohmann::json led_json); matrix_map_type SetMatrixMapDescriptionJSON(nlohmann::json matrix_map_json); mode SetModeDescriptionJSON(nlohmann::json mode_json); segment SetSegmentDescriptionJSON(nlohmann::json segment_json); zone SetZoneDescriptionJSON(nlohmann::json zone_json); bool CompareControllers(RGBControllerInterface* controller_1, RGBControllerInterface* controller_2); std::string DeviceTypeToString(device_type type); bool SetModeValuesFromMode(mode& destination, mode& source); /*-----------------------------------------------------*\ | SettingsManager APIs | \*-----------------------------------------------------*/ Loading OpenRGBPluginInterface.h +22 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ public: virtual void ClearActiveProfile() = 0; virtual std::vector<std::string> GetProfileList() = 0; virtual bool LoadProfile(std::string profile_name) = 0; virtual bool SaveProfileFromPlugin(std::string profile_name, std::string plugin_name, nlohmann::json plugin_data) = 0; /*-----------------------------------------------------*\ | ResourceManager APIs | Loading @@ -108,6 +109,27 @@ public: virtual void WaitForDetection() = 0; virtual std::vector<RGBControllerInterface*> GetRGBControllers() = 0; /*-----------------------------------------------------*\ | RGBController APIs | \*-----------------------------------------------------*/ virtual nlohmann::json GetDeviceDescriptionJSON(RGBControllerInterface* controller) = 0; virtual nlohmann::json GetLEDDescriptionJSON(led led) = 0; virtual nlohmann::json GetMatrixMapDescriptionJSON(matrix_map_type matrix_map) = 0; virtual nlohmann::json GetModeDescriptionJSON(mode mode) = 0; virtual nlohmann::json GetSegmentDescriptionJSON(segment segment) = 0; virtual nlohmann::json GetZoneDescriptionJSON(zone zone) = 0; virtual RGBControllerInterface* SetDeviceDescriptionJSON(nlohmann::json controller_json) = 0; virtual led SetLEDDescriptionJSON(nlohmann::json led_json) = 0; virtual matrix_map_type SetMatrixMapDescriptionJSON(nlohmann::json matrix_map_json) = 0; virtual mode SetModeDescriptionJSON(nlohmann::json mode_json) = 0; virtual segment SetSegmentDescriptionJSON(nlohmann::json segment_json) = 0; virtual zone SetZoneDescriptionJSON(nlohmann::json zone_json) = 0; virtual bool CompareControllers(RGBControllerInterface* controller_1, RGBControllerInterface* controller_2) = 0; virtual std::string DeviceTypeToString(device_type type) = 0; virtual bool SetModeValuesFromMode(mode& destination, mode& source) = 0; /*-----------------------------------------------------*\ | SettingsManager APIs | \*-----------------------------------------------------*/ Loading ProfileManager.cpp +39 −0 Original line number Diff line number Diff line Loading @@ -789,6 +789,45 @@ bool ProfileManager::SaveProfileFromJSON(nlohmann::json profile_json) } } bool ProfileManager::SaveProfileFromPlugin(std::string profile_name, std::string plugin_name, nlohmann::json plugin_data) { /*-----------------------------------------------------*\ | If a name was entered, save the profile file | \*-----------------------------------------------------*/ if(profile_name != "") { /*-------------------------------------------------*\ | Start filling in profile json data | \*-------------------------------------------------*/ nlohmann::json profile_json; profile_json["profile_version"] = OPENRGB_PROFILE_VERSION; profile_json["profile_name"] = profile_name; profile_json["plugins"][plugin_name] = plugin_data; if(ResourceManager::get()->IsLocalClient() && (ResourceManager::get()->GetLocalClient()->GetSupportsProfileManagerAPI())) { /*---------------------------------------------*\ | Upload the profile to the server | \*---------------------------------------------*/ ResourceManager::get()->GetLocalClient()->ProfileManager_UploadProfile(profile_json.dump()); } else { /*---------------------------------------------*\ | Save the profile to file from the JSON | \*---------------------------------------------*/ SaveProfileFromJSON(profile_json); } return(true); } else { return(false); } } bool ProfileManager::SaveConfiguration() { /*-----------------------------------------------------*\ Loading ProfileManager.h +1 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,7 @@ public: bool SaveProfile(std::string profile_name); bool SaveProfileCustom(std::string profile_name, std::vector<RGBController*> controllers, RGBColor base_color, bool base_color_enabled, std::vector<std::string> enabled_plugins); bool SaveProfileFromJSON(nlohmann::json profile_json); bool SaveProfileFromPlugin(std::string profile_name, std::string plugin_name, nlohmann::json plugin_data); bool SaveConfiguration(); void SetActiveProfile(std::string profile_name); Loading Loading
OpenRGBPluginAPI.cpp +87 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ \*---------------------------------------------------------*/ #include "OpenRGBPluginAPI.h" #include "RGBController_Dummy.h" #include "RGBController_Virtual.h" OpenRGBPluginAPI::OpenRGBPluginAPI() Loading Loading @@ -185,6 +186,11 @@ bool OpenRGBPluginAPI::LoadProfile(std::string profile_name) return(profile_manager->LoadProfile(profile_name)); } bool OpenRGBPluginAPI::SaveProfileFromPlugin(std::string profile_name, std::string plugin_name, nlohmann::json plugin_data) { return(profile_manager->SaveProfileFromPlugin(profile_name, plugin_name, plugin_data)); } /*---------------------------------------------------------*\ | ResourceManager APIs | \*---------------------------------------------------------*/ Loading Loading @@ -223,6 +229,87 @@ std::vector<RGBControllerInterface*> OpenRGBPluginAPI::GetRGBControllers() return(resource_manager->GetRGBControllerInterfaces()); } /*---------------------------------------------------------*\ | RGBController APIs | \*---------------------------------------------------------*/ nlohmann::json OpenRGBPluginAPI::GetDeviceDescriptionJSON(RGBControllerInterface* controller) { return(RGBController::GetDeviceDescriptionJSON((RGBController*)controller)); } nlohmann::json OpenRGBPluginAPI::GetLEDDescriptionJSON(led led) { return(RGBController::GetLEDDescriptionJSON(led)); } nlohmann::json OpenRGBPluginAPI::GetMatrixMapDescriptionJSON(matrix_map_type matrix_map) { return(RGBController::GetMatrixMapDescriptionJSON(matrix_map)); } nlohmann::json OpenRGBPluginAPI::GetModeDescriptionJSON(mode mode) { return(RGBController::GetModeDescriptionJSON(mode)); } nlohmann::json OpenRGBPluginAPI::GetSegmentDescriptionJSON(segment segment) { return(RGBController::GetSegmentDescriptionJSON(segment)); } nlohmann::json OpenRGBPluginAPI::GetZoneDescriptionJSON(zone zone) { return(RGBController::GetZoneDescriptionJSON(zone)); } RGBControllerInterface* OpenRGBPluginAPI::SetDeviceDescriptionJSON(nlohmann::json controller_json) { RGBController_Dummy* new_controller = new RGBController_Dummy(); RGBController::SetDeviceDescriptionJSON(controller_json, (RGBController*)new_controller); return(new_controller); } led OpenRGBPluginAPI::SetLEDDescriptionJSON(nlohmann::json led_json) { return(RGBController::SetLEDDescriptionJSON(led_json)); } matrix_map_type OpenRGBPluginAPI::SetMatrixMapDescriptionJSON(nlohmann::json matrix_map_json) { return(RGBController::SetMatrixMapDescriptionJSON(matrix_map_json)); } mode OpenRGBPluginAPI::SetModeDescriptionJSON(nlohmann::json mode_json) { return(RGBController::SetModeDescriptionJSON(mode_json)); } segment OpenRGBPluginAPI::SetSegmentDescriptionJSON(nlohmann::json segment_json) { return(RGBController::SetSegmentDescriptionJSON(segment_json)); } zone OpenRGBPluginAPI::SetZoneDescriptionJSON(nlohmann::json zone_json) { return(RGBController::SetZoneDescriptionJSON(zone_json)); } bool OpenRGBPluginAPI::CompareControllers(RGBControllerInterface* controller_1, RGBControllerInterface* controller_2) { return(RGBController::CompareControllers((RGBController*)controller_1, (RGBController*)controller_2)); } std::string OpenRGBPluginAPI::DeviceTypeToString(device_type type) { return(RGBController::DeviceTypeToString(type)); } bool OpenRGBPluginAPI::SetModeValuesFromMode(mode& destination, mode& source) { return(RGBController::SetModeValuesFromMode(destination, source)); } /*---------------------------------------------------------*\ | SettingsManager APIs | \*---------------------------------------------------------*/ Loading
OpenRGBPluginAPI.h +22 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,7 @@ public: void ClearActiveProfile(); std::vector<std::string> GetProfileList(); bool LoadProfile(std::string profile_name); bool SaveProfileFromPlugin(std::string profile_name, std::string plugin_name, nlohmann::json plugin_data); /*-----------------------------------------------------*\ | ResourceManager APIs | Loading @@ -57,6 +58,27 @@ public: void WaitForDetection(); std::vector<RGBControllerInterface*> GetRGBControllers(); /*-----------------------------------------------------*\ | RGBController APIs | \*-----------------------------------------------------*/ nlohmann::json GetDeviceDescriptionJSON(RGBControllerInterface* controller); nlohmann::json GetLEDDescriptionJSON(led led); nlohmann::json GetMatrixMapDescriptionJSON(matrix_map_type matrix_map); nlohmann::json GetModeDescriptionJSON(mode mode); nlohmann::json GetSegmentDescriptionJSON(segment segment); nlohmann::json GetZoneDescriptionJSON(zone zone); RGBControllerInterface* SetDeviceDescriptionJSON(nlohmann::json controller_json); led SetLEDDescriptionJSON(nlohmann::json led_json); matrix_map_type SetMatrixMapDescriptionJSON(nlohmann::json matrix_map_json); mode SetModeDescriptionJSON(nlohmann::json mode_json); segment SetSegmentDescriptionJSON(nlohmann::json segment_json); zone SetZoneDescriptionJSON(nlohmann::json zone_json); bool CompareControllers(RGBControllerInterface* controller_1, RGBControllerInterface* controller_2); std::string DeviceTypeToString(device_type type); bool SetModeValuesFromMode(mode& destination, mode& source); /*-----------------------------------------------------*\ | SettingsManager APIs | \*-----------------------------------------------------*/ Loading
OpenRGBPluginInterface.h +22 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,7 @@ public: virtual void ClearActiveProfile() = 0; virtual std::vector<std::string> GetProfileList() = 0; virtual bool LoadProfile(std::string profile_name) = 0; virtual bool SaveProfileFromPlugin(std::string profile_name, std::string plugin_name, nlohmann::json plugin_data) = 0; /*-----------------------------------------------------*\ | ResourceManager APIs | Loading @@ -108,6 +109,27 @@ public: virtual void WaitForDetection() = 0; virtual std::vector<RGBControllerInterface*> GetRGBControllers() = 0; /*-----------------------------------------------------*\ | RGBController APIs | \*-----------------------------------------------------*/ virtual nlohmann::json GetDeviceDescriptionJSON(RGBControllerInterface* controller) = 0; virtual nlohmann::json GetLEDDescriptionJSON(led led) = 0; virtual nlohmann::json GetMatrixMapDescriptionJSON(matrix_map_type matrix_map) = 0; virtual nlohmann::json GetModeDescriptionJSON(mode mode) = 0; virtual nlohmann::json GetSegmentDescriptionJSON(segment segment) = 0; virtual nlohmann::json GetZoneDescriptionJSON(zone zone) = 0; virtual RGBControllerInterface* SetDeviceDescriptionJSON(nlohmann::json controller_json) = 0; virtual led SetLEDDescriptionJSON(nlohmann::json led_json) = 0; virtual matrix_map_type SetMatrixMapDescriptionJSON(nlohmann::json matrix_map_json) = 0; virtual mode SetModeDescriptionJSON(nlohmann::json mode_json) = 0; virtual segment SetSegmentDescriptionJSON(nlohmann::json segment_json) = 0; virtual zone SetZoneDescriptionJSON(nlohmann::json zone_json) = 0; virtual bool CompareControllers(RGBControllerInterface* controller_1, RGBControllerInterface* controller_2) = 0; virtual std::string DeviceTypeToString(device_type type) = 0; virtual bool SetModeValuesFromMode(mode& destination, mode& source) = 0; /*-----------------------------------------------------*\ | SettingsManager APIs | \*-----------------------------------------------------*/ Loading
ProfileManager.cpp +39 −0 Original line number Diff line number Diff line Loading @@ -789,6 +789,45 @@ bool ProfileManager::SaveProfileFromJSON(nlohmann::json profile_json) } } bool ProfileManager::SaveProfileFromPlugin(std::string profile_name, std::string plugin_name, nlohmann::json plugin_data) { /*-----------------------------------------------------*\ | If a name was entered, save the profile file | \*-----------------------------------------------------*/ if(profile_name != "") { /*-------------------------------------------------*\ | Start filling in profile json data | \*-------------------------------------------------*/ nlohmann::json profile_json; profile_json["profile_version"] = OPENRGB_PROFILE_VERSION; profile_json["profile_name"] = profile_name; profile_json["plugins"][plugin_name] = plugin_data; if(ResourceManager::get()->IsLocalClient() && (ResourceManager::get()->GetLocalClient()->GetSupportsProfileManagerAPI())) { /*---------------------------------------------*\ | Upload the profile to the server | \*---------------------------------------------*/ ResourceManager::get()->GetLocalClient()->ProfileManager_UploadProfile(profile_json.dump()); } else { /*---------------------------------------------*\ | Save the profile to file from the JSON | \*---------------------------------------------*/ SaveProfileFromJSON(profile_json); } return(true); } else { return(false); } } bool ProfileManager::SaveConfiguration() { /*-----------------------------------------------------*\ Loading
ProfileManager.h +1 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,7 @@ public: bool SaveProfile(std::string profile_name); bool SaveProfileCustom(std::string profile_name, std::vector<RGBController*> controllers, RGBColor base_color, bool base_color_enabled, std::vector<std::string> enabled_plugins); bool SaveProfileFromJSON(nlohmann::json profile_json); bool SaveProfileFromPlugin(std::string profile_name, std::string plugin_name, nlohmann::json plugin_data); bool SaveConfiguration(); void SetActiveProfile(std::string profile_name); Loading