mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-02-12 00:01:14 -05:00
Rework API interface passed into plugins from ResourceManagerInterface to OpenRGBPluginAPIInterface
This commit is contained in:
@@ -239,8 +239,10 @@ void LogManager::flush()
|
||||
_flush();
|
||||
}
|
||||
|
||||
void LogManager::_append(const char* filename, int line, unsigned int level, const char* fmt, va_list va)
|
||||
void LogManager::append_va(const char* filename, int line, unsigned int level, const char* fmt, va_list va)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> grd(entry_mutex);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| If a critical message occurs, enable source |
|
||||
| printing and set loglevel and verbosity to highest |
|
||||
@@ -333,8 +335,7 @@ void LogManager::append(const char* filename, int line, unsigned int level, cons
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
|
||||
std::lock_guard<std::recursive_mutex> grd(entry_mutex);
|
||||
_append(filename, line, level, fmt, va);
|
||||
append_va(filename, line, level, fmt, va);
|
||||
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
@@ -85,9 +85,6 @@ private:
|
||||
//Clock from LogManager creation
|
||||
std::chrono::time_point<std::chrono::steady_clock> base_clock;
|
||||
|
||||
// A non-guarded append()
|
||||
void _append(const char* filename, int line, unsigned int level, const char* fmt, va_list va);
|
||||
|
||||
// A non-guarded flush()
|
||||
void _flush();
|
||||
|
||||
@@ -98,6 +95,7 @@ public:
|
||||
void configure(json config, const filesystem::path & defaultDir);
|
||||
void flush();
|
||||
void append(const char* filename, int line, unsigned int level, const char* fmt, ...);
|
||||
void append_va(const char* filename, int line, unsigned int level, const char* fmt, va_list va);
|
||||
void setLoglevel(unsigned int);
|
||||
void setVerbosity(unsigned int);
|
||||
void setPrintSource(bool);
|
||||
|
||||
@@ -242,6 +242,7 @@ SOURCES +=
|
||||
NetworkClient.cpp \
|
||||
NetworkProtocol.cpp \
|
||||
NetworkServer.cpp \
|
||||
OpenRGBPluginAPI.cpp \
|
||||
PluginManager.cpp \
|
||||
ProfileManager.cpp \
|
||||
ResourceManager.cpp \
|
||||
|
||||
134
OpenRGBPluginAPI.cpp
Normal file
134
OpenRGBPluginAPI.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| OpenRGBPluginAPI.cpp |
|
||||
| |
|
||||
| Interface for OpenRGB plugins to call OpenRGB functions |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 08 Feb 2026 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "OpenRGBPluginAPI.h"
|
||||
|
||||
OpenRGBPluginAPI::OpenRGBPluginAPI(std::vector<RGBController> & rgb_controllers_ref) : rgb_controllers(rgb_controllers_ref)
|
||||
{
|
||||
log_manager = ResourceManager::get()->GetLogManager();
|
||||
plugin_manager = ResourceManager::get()->GetPluginManager();
|
||||
profile_manager = ResourceManager::get()->GetProfileManager();
|
||||
resource_manager = ResourceManager::get();
|
||||
settings_manager = ResourceManager::get()->GetSettingsManager();
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| LogManager APIs |
|
||||
\*---------------------------------------------------------*/
|
||||
void OpenRGBPluginAPI::append(const char* filename, int line, unsigned int level, const char* fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, fmt);
|
||||
|
||||
log_manager->append_va(filename, line, level, fmt, va);
|
||||
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| PluginManager APIs |
|
||||
\*---------------------------------------------------------*/
|
||||
void OpenRGBPluginAPI::RegisterRGBController(RGBController * rgb_controller)
|
||||
{
|
||||
LOG_INFO("[PluginManager] Registering RGB controller %s", rgb_controller->GetName().c_str());
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Mark this controller as locally owned |
|
||||
\*-----------------------------------------------------*/
|
||||
rgb_controller->flags &= ~CONTROLLER_FLAG_REMOTE;
|
||||
rgb_controller->flags |= CONTROLLER_FLAG_LOCAL;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Add the new controller to the list |
|
||||
\*-----------------------------------------------------*/
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
|
||||
}
|
||||
|
||||
void OpenRGBPluginAPI::UnregisterRGBController(RGBController * rgb_controller)
|
||||
{
|
||||
LOG_INFO("[PluginManager] Unregistering RGB controller %s", rgb_controller->GetName().c_str());
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Clear callbacks from the controller before removal |
|
||||
\*-----------------------------------------------------*/
|
||||
rgb_controller->ClearCallbacks();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Find the controller to remove and remove it from the |
|
||||
| master list |
|
||||
\*-----------------------------------------------------*/
|
||||
std::vector<RGBController*>::iterator rgb_it = std::find(rgb_controllers.begin(), rgb_controllers.end(), rgb_controller);
|
||||
|
||||
if(rgb_it != rgb_controllers.end())
|
||||
{
|
||||
rgb_controllers.erase(rgb_it);
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| ProfileManager APIs |
|
||||
\*---------------------------------------------------------*/
|
||||
void OpenRGBPluginAPI::ClearActiveProfile()
|
||||
{
|
||||
profile_manager->ClearActiveProfile();
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| ResourceManager APIs |
|
||||
\*---------------------------------------------------------*/
|
||||
filesystem::path OpenRGBPluginAPI::GetConfigurationDirectory()
|
||||
{
|
||||
return(resource_manager->GetConfigurationDirectory());
|
||||
}
|
||||
|
||||
bool OpenRGBPluginAPI::GetDetectionEnabled()
|
||||
{
|
||||
return(resource_manager->GetDetectionEnabled());
|
||||
}
|
||||
|
||||
unsigned int OpenRGBPluginAPI::GetDetectionPercent()
|
||||
{
|
||||
return(resource_manager->GetDetectionPercent());
|
||||
}
|
||||
|
||||
std::string OpenRGBPluginAPI::GetDetectionString()
|
||||
{
|
||||
return(resource_manager->GetDetectionString());
|
||||
}
|
||||
|
||||
void OpenRGBPluginAPI::WaitForDetection()
|
||||
{
|
||||
resource_manager->WaitForDetection();
|
||||
}
|
||||
|
||||
std::vector<RGBController*> & OpenRGBPluginAPI::GetRGBControllers()
|
||||
{
|
||||
return(resource_manager->GetRGBControllers());
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| SettingsManager APIs |
|
||||
\*---------------------------------------------------------*/
|
||||
nlohmann::json OpenRGBPluginAPI::GetSettings(std::string settings_key)
|
||||
{
|
||||
return(settings_manager->GetSettings(settings_key));
|
||||
}
|
||||
|
||||
void OpenRGBPluginAPI::SaveSettings()
|
||||
{
|
||||
settings_manager->SaveSettings();
|
||||
}
|
||||
|
||||
void OpenRGBPluginAPI::SetSettings(std::string settings_key, nlohmann::json new_settings)
|
||||
{
|
||||
settings_manager->SetSettings(settings_key, new_settings);
|
||||
}
|
||||
66
OpenRGBPluginAPI.h
Normal file
66
OpenRGBPluginAPI.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| OpenRGBPluginAPI.h |
|
||||
| |
|
||||
| Interface for OpenRGB plugins to call OpenRGB functions |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 08 Feb 2026 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "LogManager.h"
|
||||
#include "OpenRGBPluginInterface.h"
|
||||
#include "PluginManagerInterface.h"
|
||||
#include "ProfileManager.h"
|
||||
#include "ResourceManager.h"
|
||||
#include "SettingsManager.h"
|
||||
|
||||
class OpenRGBPluginAPI : public OpenRGBPluginAPIInterface
|
||||
{
|
||||
public:
|
||||
OpenRGBPluginAPI(std::vector<RGBController> & rgb_controllers_ref);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| LogManager APIs |
|
||||
\*-----------------------------------------------------*/
|
||||
void append(const char* filename, int line, unsigned int level, const char* fmt, ...);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| PluginManager APIs |
|
||||
\*-----------------------------------------------------*/
|
||||
void RegisterRGBController(RGBController * rgb_controller);
|
||||
void UnregisterRGBController(RGBController * rgb_controller);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| ProfileManager APIs |
|
||||
\*-----------------------------------------------------*/
|
||||
void ClearActiveProfile();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| ResourceManager APIs |
|
||||
\*-----------------------------------------------------*/
|
||||
filesystem::path GetConfigurationDirectory();
|
||||
bool GetDetectionEnabled();
|
||||
unsigned int GetDetectionPercent();
|
||||
std::string GetDetectionString();
|
||||
void WaitForDetection();
|
||||
std::vector<RGBController*> & GetRGBControllers();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| SettingsManager APIs |
|
||||
\*-----------------------------------------------------*/
|
||||
nlohmann::json GetSettings(std::string settings_key);
|
||||
void SaveSettings();
|
||||
void SetSettings(std::string settings_key, nlohmann::json new_settings);
|
||||
|
||||
private:
|
||||
std::vector<RGBController*> & rgb_controllers;
|
||||
LogManager * log_manager;
|
||||
PluginManagerInterface * plugin_manager;
|
||||
ProfileManager * profile_manager;
|
||||
ResourceManager * resource_manager;
|
||||
SettingsManager * settings_manager;
|
||||
};
|
||||
@@ -16,7 +16,8 @@
|
||||
#include <QLabel>
|
||||
#include <QMenu>
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "ResourceManagerInterface.h"
|
||||
#include "filesystem.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
#define OpenRGBPluginInterface_IID "com.OpenRGBPluginInterface"
|
||||
|
||||
@@ -70,28 +71,71 @@ struct OpenRGBPluginInfo
|
||||
unsigned int ProtocolVersion;/* Plugin SDK protocol version */
|
||||
};
|
||||
|
||||
class OpenRGBPluginAPIInterface
|
||||
{
|
||||
public:
|
||||
/*-----------------------------------------------------*\
|
||||
| LogManager APIs |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual void append(const char* filename, int line, unsigned int level, const char* fmt, ...) = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| PluginManager APIs |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual void RegisterRGBController(RGBController * controller) = 0;
|
||||
virtual void UnregisterRGBController(RGBController * controller) = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| ProfileManager APIs |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual void ClearActiveProfile() = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| ResourceManager APIs |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual filesystem::path GetConfigurationDirectory() = 0;
|
||||
virtual bool GetDetectionEnabled() = 0;
|
||||
virtual unsigned int GetDetectionPercent() = 0;
|
||||
virtual std::string GetDetectionString() = 0;
|
||||
virtual void WaitForDetection() = 0;
|
||||
virtual std::vector<RGBController*> & GetRGBControllers() = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| SettingsManager APIs |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual nlohmann::json GetSettings(std::string settings_key) = 0;
|
||||
virtual void SaveSettings() = 0;
|
||||
virtual void SetSettings(std::string settings_key, nlohmann::json new_settings) = 0;
|
||||
};
|
||||
|
||||
class OpenRGBPluginInterface
|
||||
{
|
||||
public:
|
||||
virtual ~OpenRGBPluginInterface() {}
|
||||
virtual ~OpenRGBPluginInterface() {}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin Information |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual OpenRGBPluginInfo GetPluginInfo() = 0;
|
||||
virtual unsigned int GetPluginAPIVersion() = 0;
|
||||
virtual OpenRGBPluginInfo GetPluginInfo() = 0;
|
||||
virtual unsigned int GetPluginAPIVersion() = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin Functionality |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual void Load(ResourceManagerInterface* resource_manager_ptr) = 0;
|
||||
virtual QWidget* GetWidget() = 0;
|
||||
virtual QMenu* GetTrayMenu() = 0;
|
||||
virtual void Unload() = 0;
|
||||
virtual void OnProfileAboutToLoad() = 0;
|
||||
virtual void OnProfileLoad(nlohmann::json profile_data) = 0;
|
||||
virtual nlohmann::json OnProfileSave() = 0;
|
||||
virtual unsigned char* OnSDKCommand(unsigned int pkt_id, unsigned char * pkt_data, unsigned int *pkt_size) = 0;
|
||||
virtual void Load(OpenRGBPluginAPIInterface* plugin_api_ptr) = 0;
|
||||
virtual QWidget* GetWidget() = 0;
|
||||
virtual QMenu* GetTrayMenu() = 0;
|
||||
virtual void Unload() = 0;
|
||||
virtual void OnProfileAboutToLoad() = 0;
|
||||
virtual void OnProfileLoad(nlohmann::json profile_data) = 0;
|
||||
virtual nlohmann::json OnProfileSave() = 0;
|
||||
virtual unsigned char* OnSDKCommand(unsigned int pkt_id, unsigned char * pkt_data, unsigned int *pkt_size) = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Update Signals |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual void ProfileManagerUpdated(unsigned int update_reason) = 0;
|
||||
virtual void ResourceManagerUpdated(unsigned int update_reason) = 0;
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE(OpenRGBPluginInterface, OpenRGBPluginInterface_IID)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "LogManager.h"
|
||||
#include "filesystem.h"
|
||||
#include "PluginManager.h"
|
||||
#include "OpenRGBThemeManager.h"
|
||||
#include "OpenRGBPluginAPI.h"
|
||||
#include "SettingsManager.h"
|
||||
#include "ResourceManager.h"
|
||||
|
||||
@@ -18,22 +18,51 @@
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
void PluginManagerProfileManagerCallback(void * this_ptr, unsigned int update_reason)
|
||||
{
|
||||
PluginManager * this_obj = (PluginManager *)this_ptr;
|
||||
|
||||
this_obj->ProfileManagerCallback(update_reason);
|
||||
}
|
||||
|
||||
void PluginManagerResourceManagerCallback(void * this_ptr, unsigned int update_reason)
|
||||
{
|
||||
PluginManager * this_obj = (PluginManager *)this_ptr;
|
||||
|
||||
this_obj->ResourceManagerCallback(update_reason);
|
||||
}
|
||||
|
||||
PluginManager::PluginManager()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize plugin manager class variables |
|
||||
\*---------------------------------------------------------*/
|
||||
/*-----------------------------------------------------*\
|
||||
| Initialize plugin manager class variables |
|
||||
\*-----------------------------------------------------*/
|
||||
AddPluginCallbackVal = nullptr;
|
||||
AddPluginCallbackArg = nullptr;
|
||||
RemovePluginCallbackVal = nullptr;
|
||||
RemovePluginCallbackArg = nullptr;
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| Create OpenRGB plugins directory |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------*\
|
||||
| Create OpenRGB plugins directory |
|
||||
\*-----------------------------------------------------*/
|
||||
filesystem::path plugins_dir = ResourceManager::get()->GetConfigurationDirectory() / plugins_path;
|
||||
|
||||
filesystem::create_directories(plugins_dir);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Register callbacks |
|
||||
\*-----------------------------------------------------*/
|
||||
ResourceManager::get()->GetProfileManager()->RegisterProfileManagerCallback(PluginManagerProfileManagerCallback, this);
|
||||
ResourceManager::get()->RegisterResourceManagerCallback(PluginManagerResourceManagerCallback, this);
|
||||
}
|
||||
|
||||
PluginManager::~PluginManager()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Unegister callbacks |
|
||||
\*-----------------------------------------------------*/
|
||||
ResourceManager::get()->GetProfileManager()->RegisterProfileManagerCallback(PluginManagerProfileManagerCallback, this);
|
||||
ResourceManager::get()->RegisterResourceManagerCallback(PluginManagerResourceManagerCallback, this);
|
||||
}
|
||||
|
||||
void PluginManager::RegisterAddPluginCallback(AddPluginCallback new_callback, void * new_callback_arg)
|
||||
@@ -268,6 +297,7 @@ void PluginManager::AddPlugin(const filesystem::path& path, bool is_system)
|
||||
|
||||
entry.info = info;
|
||||
entry.plugin = plugin;
|
||||
entry.api = new OpenRGBPluginAPI(entry.controllers);
|
||||
entry.loader = loader;
|
||||
entry.path = path_string;
|
||||
entry.enabled = enabled;
|
||||
@@ -304,6 +334,7 @@ void PluginManager::AddPlugin(const filesystem::path& path, bool is_system)
|
||||
|
||||
entry.info = info;
|
||||
entry.plugin = plugin;
|
||||
entry.api = new OpenRGBPluginAPI(entry.controllers);
|
||||
entry.loader = loader;
|
||||
entry.path = path_string;
|
||||
entry.enabled = false;
|
||||
@@ -435,7 +466,7 @@ void PluginManager::LoadPlugin(OpenRGBPluginEntry* plugin_entry)
|
||||
{
|
||||
plugin_entry->plugin = plugin;
|
||||
|
||||
plugin->Load(ResourceManager::get());
|
||||
plugin->Load(plugin_entry->api);
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Call the Add Plugin callback |
|
||||
@@ -600,6 +631,34 @@ unsigned char * PluginManager::OnSDKCommand(unsigned int plugin_idx, unsigned in
|
||||
return(out_data);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Callback functions |
|
||||
\*---------------------------------------------------------*/
|
||||
void PluginManager::ProfileManagerCallback(unsigned int update_reason)
|
||||
{
|
||||
for(std::size_t plugin_idx = 0; plugin_idx < ActivePlugins.size(); plugin_idx++)
|
||||
{
|
||||
if(ActivePlugins[plugin_idx].enabled && ActivePlugins[plugin_idx].loader->isLoaded())
|
||||
{
|
||||
ActivePlugins[plugin_idx].plugin->ProfileManagerUpdated(update_reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PluginManager::ResourceManagerCallback(unsigned int update_reason)
|
||||
{
|
||||
for(std::size_t plugin_idx = 0; plugin_idx < ActivePlugins.size(); plugin_idx++)
|
||||
{
|
||||
if(ActivePlugins[plugin_idx].enabled && ActivePlugins[plugin_idx].loader->isLoaded())
|
||||
{
|
||||
ActivePlugins[plugin_idx].plugin->ResourceManagerUpdated(update_reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Plugin Information |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int PluginManager::GetPluginCount()
|
||||
{
|
||||
return(ActivePlugins.size());
|
||||
@@ -656,3 +715,21 @@ std::string PluginManager::GetPluginVersion(unsigned int plugin_idx)
|
||||
|
||||
return("");
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Plugin-Created RGBControllers |
|
||||
\*---------------------------------------------------------*/
|
||||
std::vector<RGBController *> PluginManager::GetRGBControllers()
|
||||
{
|
||||
std::vector<RGBController *> plugin_controllers;
|
||||
|
||||
for(std::size_t plugin_idx = 0; plugin_idx < ActivePlugins.size(); plugin_idx++)
|
||||
{
|
||||
if(ActivePlugins[plugin_idx].enabled && ActivePlugins[plugin_idx].loader->isLoaded())
|
||||
{
|
||||
// build list of plugin-provided controllers here
|
||||
}
|
||||
}
|
||||
|
||||
return(plugin_controllers);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ struct OpenRGBPluginEntry
|
||||
{
|
||||
OpenRGBPluginInfo info;
|
||||
OpenRGBPluginInterface* plugin;
|
||||
OpenRGBPluginAPIInterface* api;
|
||||
std::vector<RGBController*> controllers;
|
||||
QPluginLoader* loader;
|
||||
QWidget* widget;
|
||||
QMenu* traymenu;
|
||||
@@ -39,18 +41,33 @@ class PluginManager : public PluginManagerInterface
|
||||
{
|
||||
public:
|
||||
PluginManager();
|
||||
~PluginManager();
|
||||
|
||||
unsigned int GetPluginCount();
|
||||
std::string GetPluginDescription(unsigned int plugin_idx);
|
||||
std::string GetPluginName(unsigned int plugin_idx);
|
||||
unsigned int GetPluginProtocolVersion(unsigned int plugin_idx);
|
||||
std::string GetPluginVersion(unsigned int plugin_idx);
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin Information |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned int GetPluginCount();
|
||||
std::string GetPluginDescription(unsigned int plugin_idx);
|
||||
std::string GetPluginName(unsigned int plugin_idx);
|
||||
unsigned int GetPluginProtocolVersion(unsigned int plugin_idx);
|
||||
std::string GetPluginVersion(unsigned int plugin_idx);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin-Created RGBControllers |
|
||||
\*-----------------------------------------------------*/
|
||||
std::vector<RGBController *> GetRGBControllers();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| PluginManager Callback Registration |
|
||||
\*-----------------------------------------------------*/
|
||||
void RegisterAddPluginCallback(AddPluginCallback new_callback, void * new_callback_arg);
|
||||
void RegisterRemovePluginCallback(RemovePluginCallback new_callback, void * new_callback_arg);
|
||||
|
||||
void ScanAndLoadPlugins();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin Management |
|
||||
\*-----------------------------------------------------*/
|
||||
void AddPlugin(const filesystem::path& path, bool is_system);
|
||||
void RemovePlugin(const filesystem::path& path);
|
||||
|
||||
@@ -60,11 +77,24 @@ public:
|
||||
void LoadPlugins();
|
||||
void UnloadPlugins();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin Profile Integration |
|
||||
\*-----------------------------------------------------*/
|
||||
void OnProfileAboutToLoad();
|
||||
void OnProfileLoad(nlohmann::json profile_data);
|
||||
nlohmann::json OnProfileSave();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin SDK Integration |
|
||||
\*-----------------------------------------------------*/
|
||||
unsigned char * OnSDKCommand(unsigned int plugin_idx, unsigned int pkt_id, unsigned char * pkt_data, unsigned int * pkt_size);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Callback functions |
|
||||
\*-----------------------------------------------------*/
|
||||
void ProfileManagerCallback(unsigned int update_reason);
|
||||
void ResourceManagerCallback(unsigned int update_reason);
|
||||
|
||||
std::vector<OpenRGBPluginEntry> ActivePlugins;
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,17 +17,35 @@
|
||||
class PluginManagerInterface
|
||||
{
|
||||
public:
|
||||
virtual unsigned int GetPluginCount() = 0;
|
||||
virtual std::string GetPluginDescription(unsigned int plugin_idx) = 0;
|
||||
virtual std::string GetPluginName(unsigned int plugin_idx) = 0;
|
||||
virtual unsigned int GetPluginProtocolVersion(unsigned int plugin_idx) = 0;
|
||||
virtual std::string GetPluginVersion(unsigned int plugin_idx) = 0;
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin Information |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual unsigned int GetPluginCount() = 0;
|
||||
virtual std::string GetPluginDescription(unsigned int plugin_idx) = 0;
|
||||
virtual std::string GetPluginName(unsigned int plugin_idx) = 0;
|
||||
virtual unsigned int GetPluginProtocolVersion(unsigned int plugin_idx) = 0;
|
||||
virtual std::string GetPluginVersion(unsigned int plugin_idx) = 0;
|
||||
|
||||
virtual void LoadPlugins() = 0;
|
||||
virtual void UnloadPlugins() = 0;
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin-Created RGBControllers |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual std::vector<RGBController *> GetRGBControllers() = 0;
|
||||
|
||||
virtual void OnProfileAboutToLoad() = 0;
|
||||
virtual void OnProfileLoad(nlohmann::json profile_data) = 0;
|
||||
virtual nlohmann::json OnProfileSave() = 0;
|
||||
virtual unsigned char * OnSDKCommand(unsigned int plugin_idx, unsigned int pkt_id, unsigned char * pkt_data, unsigned int * pkt_size) = 0;
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin Management |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual void LoadPlugins() = 0;
|
||||
virtual void UnloadPlugins() = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin Profile Integration |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual void OnProfileAboutToLoad() = 0;
|
||||
virtual void OnProfileLoad(nlohmann::json profile_data) = 0;
|
||||
virtual nlohmann::json OnProfileSave() = 0;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Plugin SDK Integration |
|
||||
\*-----------------------------------------------------*/
|
||||
virtual unsigned char * OnSDKCommand(unsigned int plugin_idx, unsigned int pkt_id, unsigned char * pkt_data, unsigned int * pkt_size) = 0;
|
||||
};
|
||||
|
||||
@@ -465,6 +465,19 @@ void ResourceManager::UpdateDeviceList()
|
||||
rgb_controllers.push_back(rgb_controllers_hw[rgb_controller_idx]);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Insert plugin controllers into controller list |
|
||||
\*-----------------------------------------------------*/
|
||||
if(plugin_manager)
|
||||
{
|
||||
std::vector<RGBController*> rgb_controllers_plugins = plugin_manager->GetRGBControllers();
|
||||
|
||||
for(std::size_t rgb_controller_idx = 0; rgb_controller_idx < rgb_controllers_hw.size(); rgb_controller_idx++)
|
||||
{
|
||||
rgb_controllers.push_back(rgb_controllers_plugins[rgb_controller_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Insert client controllers into controller list |
|
||||
\*-----------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user