mirror of
https://github.com/sudoxnym/open-hyperion.git
synced 2026-04-14 11:36:31 +00:00
Finalize plugin interface and rework into a template for plugin development
This commit is contained in:
parent
1d70b9b490
commit
3d2d86d129
20 changed files with 596 additions and 662 deletions
147
Dependencies/ResourceManager.h
vendored
147
Dependencies/ResourceManager.h
vendored
|
|
@ -1,147 +0,0 @@
|
|||
/*-----------------------------------------*\
|
||||
| ResourceManager.h |
|
||||
| |
|
||||
| OpenRGB Resource Manager controls access |
|
||||
| to application components including |
|
||||
| RGBControllers, I2C interfaces, and |
|
||||
| network SDK components |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/27/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
|
||||
#include "NetworkClient.h"
|
||||
#include "NetworkServer.h"
|
||||
#include "RGBController.h"
|
||||
#include "SettingsManager.h"
|
||||
|
||||
#define HID_INTERFACE_ANY -1
|
||||
#define HID_USAGE_ANY -1
|
||||
#define HID_USAGE_PAGE_ANY -1L
|
||||
|
||||
#define CONTROLLER_LIST_HID 0
|
||||
|
||||
struct hid_device_info;
|
||||
|
||||
typedef std::function<void(std::vector<RGBController*>&)> DeviceDetectorFunction;
|
||||
|
||||
typedef void (*DeviceListChangeCallback)(void *);
|
||||
typedef void (*DetectionProgressCallback)(void *);
|
||||
typedef void (*I2CBusListChangeCallback)(void *);
|
||||
|
||||
class ResourceManager
|
||||
{
|
||||
public:
|
||||
static ResourceManager *get();
|
||||
|
||||
ResourceManager();
|
||||
~ResourceManager();
|
||||
|
||||
void RegisterRGBController(RGBController *rgb_controller);
|
||||
|
||||
std::vector<RGBController*> & GetRGBControllers();
|
||||
|
||||
unsigned int GetDetectionPercent();
|
||||
const char* GetDetectionString();
|
||||
|
||||
std::string GetConfigurationDirectory();
|
||||
|
||||
std::vector<NetworkClient*>& GetClients();
|
||||
NetworkServer* GetServer();
|
||||
|
||||
SettingsManager* GetSettingsManager();
|
||||
|
||||
void SetConfigurationDirectory(std::string directory);
|
||||
|
||||
void DeviceListChanged();
|
||||
void DetectionProgressChanged();
|
||||
void I2CBusListChanged();
|
||||
|
||||
void Cleanup();
|
||||
|
||||
void DetectDevices();
|
||||
|
||||
void DisableDetection();
|
||||
|
||||
void StopDeviceDetection();
|
||||
|
||||
void WaitForDeviceDetection();
|
||||
|
||||
private:
|
||||
void DetectDevicesThreadFunction();
|
||||
|
||||
static std::unique_ptr<ResourceManager> instance;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Detection enabled flag |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
bool detection_enabled;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Settings Manager |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
SettingsManager* settings_manager;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| RGBControllers |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::vector<RGBController*> rgb_controllers_sizes;
|
||||
std::vector<RGBController*> rgb_controllers_hw;
|
||||
std::vector<RGBController*> rgb_controllers;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Network Server |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
NetworkServer* server;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Network Clients |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::vector<NetworkClient*> clients;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Detectors |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::vector<DeviceDetectorFunction> device_detectors;
|
||||
std::vector<std::string> device_detector_strings;
|
||||
std::vector<std::string> i2c_device_detector_strings;
|
||||
std::vector<std::string> hid_device_detector_strings;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Detection Thread and Detection State |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::thread * DetectDevicesThread;
|
||||
std::mutex DetectDeviceMutex;
|
||||
|
||||
std::atomic<bool> detection_is_required;
|
||||
std::atomic<unsigned int> detection_percent;
|
||||
const char* detection_string;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Device List Changed Callback |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::mutex DeviceListChangeMutex;
|
||||
std::vector<DeviceListChangeCallback> DeviceListChangeCallbacks;
|
||||
std::vector<void *> DeviceListChangeCallbackArgs;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| Detection Progress Callback |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::mutex DetectionProgressMutex;
|
||||
std::vector<DetectionProgressCallback> DetectionProgressCallbacks;
|
||||
std::vector<void *> DetectionProgressCallbackArgs;
|
||||
|
||||
/*-------------------------------------------------------------------------------------*\
|
||||
| I2C/SMBus Adapter List Changed Callback |
|
||||
\*-------------------------------------------------------------------------------------*/
|
||||
std::mutex I2CBusListChangeMutex;
|
||||
std::vector<I2CBusListChangeCallback> I2CBusListChangeCallbacks;
|
||||
std::vector<void *> I2CBusListChangeCallbackArgs;
|
||||
};
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
#include "ORGBExamplePlugin.h"
|
||||
#include "Dependencies/ResourceManager.h"
|
||||
|
||||
PluginInfo ORGBPlugin::DefineNeeded()
|
||||
{
|
||||
ORGBPlugin::PInfo.PluginName = "Example";
|
||||
ORGBPlugin::PInfo.PluginDesc = "An example Plugin for OpenRGB";
|
||||
ORGBPlugin::PInfo.PluginLoca = "InfoTab";
|
||||
|
||||
ORGBPlugin::PInfo.HasCustom = false;
|
||||
ORGBPlugin::PInfo.SettingName = "";
|
||||
|
||||
return ORGBPlugin::PInfo;
|
||||
}
|
||||
|
||||
QLabel* TabLabel()
|
||||
{
|
||||
QLabel *TLabel = new QLabel();
|
||||
TLabel->setText("Example");
|
||||
return TLabel;
|
||||
}
|
||||
|
||||
PluginInfo ORGBPlugin::init(json Settings, bool DarkTheme)
|
||||
{
|
||||
ORGBPlugin::PInfo.PluginLabel = TabLabel();
|
||||
|
||||
return ORGBPlugin::PInfo;
|
||||
}
|
||||
|
||||
QWidget* ORGBPlugin::CreateGUI(QWidget *Parent)
|
||||
{
|
||||
QWidget *ORGBExamplePage = new QWidget(Parent);
|
||||
QLabel *ORGBExampleLabel = new QLabel(ORGBExamplePage);
|
||||
|
||||
QPushButton *ORGBExamplePushButton = new QPushButton(ORGBExamplePage);
|
||||
qDebug() << ORGBExamplePushButton->objectName();
|
||||
connect(ORGBExamplePushButton,SIGNAL(clicked()) ,this , SLOT(on_ExampleButton_clicked()));
|
||||
|
||||
ORGBExampleLabel->setText("This is an example page added by plugins");
|
||||
return ORGBExamplePage;
|
||||
}
|
||||
|
||||
void ORGBPlugin::on_ExampleButton_clicked()
|
||||
{
|
||||
QDialog *ButtonDialog = new QDialog();
|
||||
ButtonDialog->setModal(true);
|
||||
QLabel *DialogText = new QLabel(ButtonDialog);
|
||||
DialogText->setText("This is the result of the button being clicked");
|
||||
ButtonDialog->show();
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "ORGBPluginInterface.h"
|
||||
#include "Dependencies/ResourceManager.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QtPlugin>
|
||||
#include "QWidget"
|
||||
#include "QLabel"
|
||||
#include "QPushButton"
|
||||
#include "QDialog"
|
||||
#include "QAction"
|
||||
|
||||
class ORGBPlugin : public QObject, public ORGBPluginInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID ORGBPluginInterface_IID)
|
||||
Q_INTERFACES(ORGBPluginInterface)
|
||||
|
||||
public:
|
||||
virtual ~ORGBPlugin() {};
|
||||
|
||||
PluginInfo PInfo;
|
||||
|
||||
virtual PluginInfo DefineNeeded() override;
|
||||
|
||||
virtual PluginInfo init(json Settings , bool DarkTheme) override;
|
||||
|
||||
virtual QWidget *CreateGUI(QWidget *Parent) override;
|
||||
private slots:
|
||||
void on_ExampleButton_clicked();
|
||||
};
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
QT += \
|
||||
gui \
|
||||
widgets \
|
||||
core \
|
||||
|
||||
TEMPLATE = lib
|
||||
DEFINES += ORGBEXAMPLEPLUGIN_LIBRARY
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
# You can make your code fail to compile if it uses deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
SOURCES += \
|
||||
ORGBExamplePlugin.cpp
|
||||
|
||||
HEADERS += \
|
||||
ORGBExamplePlugin.h \
|
||||
Dependencies/ResourceManager.h \
|
||||
Dependencies/RGBController.h \
|
||||
Dependencies/NetworkClient.h \
|
||||
Dependencies/NetworkServer.h \
|
||||
Dependencies/SettingsManager.h \
|
||||
Dependencies/NetworkProtocol.h \
|
||||
Dependencies/net_port.h \
|
||||
Dependencies/json.hpp \
|
||||
ORGBPluginInterface.h
|
||||
|
||||
# Default rules for deployment.
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
}
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
|
|
@ -1,357 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.13.3, 2020-12-12T17:58:36. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{a9f886a9-a27f-40ea-90f1-a5ecc7e77297}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
|
||||
<value type="QString" key="language">QmlJS</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
|
||||
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
|
||||
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.IndentSize">4</value>
|
||||
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
|
||||
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
|
||||
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
|
||||
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
|
||||
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
|
||||
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
|
||||
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
|
||||
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
|
||||
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
|
||||
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
|
||||
<value type="int" key="EditorConfiguration.TabSize">8</value>
|
||||
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
|
||||
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
|
||||
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
|
||||
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
|
||||
<value type="QString" key="EditorConfiguration.ignoreFileTypes">*.md, *.MD, Makefile</value>
|
||||
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
|
||||
<value type="bool" key="EditorConfiguration.skipTrailingWhitespace">true</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.PluginSettings</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<valuemap type="QVariantMap" key="AutoTest.ActiveFrameworks">
|
||||
<value type="bool" key="AutoTest.Framework.Boost">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.Catch">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.GTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtQuickTest">true</value>
|
||||
<value type="bool" key="AutoTest.Framework.QtTest">true</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="AutoTest.CheckStates"/>
|
||||
<value type="int" key="AutoTest.RunAfterBuild">0</value>
|
||||
<value type="bool" key="AutoTest.UseGlobal">true</value>
|
||||
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey">
|
||||
<value type="QString">-fno-delayed-template-parsing</value>
|
||||
</valuelist>
|
||||
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
|
||||
<value type="QString" key="ClangCodeModel.WarningConfigId">Builtin.Questionable</value>
|
||||
<valuemap type="QVariantMap" key="ClangTools">
|
||||
<value type="bool" key="ClangTools.BuildBeforeAnalysis">true</value>
|
||||
<value type="QString" key="ClangTools.DiagnosticConfig">Builtin.DefaultTidyAndClazy</value>
|
||||
<value type="int" key="ClangTools.ParallelJobs">6</value>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedDirs"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SelectedFiles"/>
|
||||
<valuelist type="QVariantList" key="ClangTools.SuppressedDiagnostics"/>
|
||||
<value type="bool" key="ClangTools.UseGlobalSettings">true</value>
|
||||
</valuemap>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Target.0</variable>
|
||||
<valuemap type="QVariantMap">
|
||||
<value type="QString" key="DeviceType">Desktop</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.15.1 MSVC2019 64bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.15.1 MSVC2019 64bit</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5151.win64_msvc2019_64_kit</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
|
||||
<value type="bool">true</value>
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\heros\OneDrive\Documents\Code\OpenRGB related\Plugin\build-ORGBExamplePlugin-Desktop_Qt_5_15_1_MSVC2019_64bit-Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/heros/OneDrive/Documents/Code/OpenRGB related/Plugin/build-ORGBExamplePlugin-Desktop_Qt_5_15_1_MSVC2019_64bit-Debug</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">true</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
|
||||
<value type="int" key="QtQuickCompiler">2</value>
|
||||
<value type="int" key="SeparateDebugInfo">2</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
|
||||
<value type="bool">true</value>
|
||||
<value type="int" key="EnableQmlDebugging">2</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\heros\OneDrive\Documents\Code\OpenRGB related\Plugin\build-ORGBExamplePlugin-Desktop_Qt_5_15_1_MSVC2019_64bit-Release</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/heros/OneDrive/Documents/Code/OpenRGB related/Plugin/build-ORGBExamplePlugin-Desktop_Qt_5_15_1_MSVC2019_64bit-Release</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
<value type="int" key="SeparateDebugInfo">2</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
|
||||
<value type="bool">true</value>
|
||||
<value type="int" key="EnableQmlDebugging">0</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:\Users\heros\OneDrive\Documents\Code\OpenRGB related\Plugin\build-ORGBExamplePlugin-Desktop_Qt_5_15_1_MSVC2019_64bit-Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory.shadowDir">C:/Users/heros/OneDrive/Documents/Code/OpenRGB related/Plugin/build-ORGBExamplePlugin-Desktop_Qt_5_15_1_MSVC2019_64bit-Profile</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
|
||||
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
|
||||
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">true</value>
|
||||
<valuelist type="QVariantList" key="QtProjectManager.QMakeBuildStep.SelectedAbis"/>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Build</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
|
||||
</valuemap>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
|
||||
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
|
||||
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
|
||||
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Clean</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
|
||||
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.CustomParsers"/>
|
||||
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
|
||||
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
|
||||
<value type="int" key="QtQuickCompiler">0</value>
|
||||
<value type="int" key="SeparateDebugInfo">0</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
|
||||
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Deploy</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.DeployConfiguration.CustomData"/>
|
||||
<value type="bool" key="ProjectExplorer.DeployConfiguration.CustomDataEnabled">false</value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
|
||||
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
|
||||
<value type="QString" key="Analyzer.Perf.CallgraphMode">dwarf</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.Events">
|
||||
<value type="QString">cpu-cycles</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.ExtraArguments"/>
|
||||
<value type="int" key="Analyzer.Perf.Frequency">250</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Perf.RecordArguments">
|
||||
<value type="QString">-e</value>
|
||||
<value type="QString">cpu-cycles</value>
|
||||
<value type="QString">--call-graph</value>
|
||||
<value type="QString">dwarf,4096</value>
|
||||
<value type="QString">-F</value>
|
||||
<value type="QString">250</value>
|
||||
</valuelist>
|
||||
<value type="QString" key="Analyzer.Perf.SampleMode">-F</value>
|
||||
<value type="bool" key="Analyzer.Perf.Settings.UseGlobalSettings">true</value>
|
||||
<value type="int" key="Analyzer.Perf.StackSize">4096</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
|
||||
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
|
||||
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
|
||||
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
|
||||
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.KCachegrindExecutable">kcachegrind</value>
|
||||
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
|
||||
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
|
||||
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
|
||||
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
|
||||
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
|
||||
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
|
||||
<value type="int">0</value>
|
||||
<value type="int">1</value>
|
||||
<value type="int">2</value>
|
||||
<value type="int">3</value>
|
||||
<value type="int">4</value>
|
||||
<value type="int">5</value>
|
||||
<value type="int">6</value>
|
||||
<value type="int">7</value>
|
||||
<value type="int">8</value>
|
||||
<value type="int">9</value>
|
||||
<value type="int">10</value>
|
||||
<value type="int">11</value>
|
||||
<value type="int">12</value>
|
||||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</valuelist>
|
||||
<valuelist type="QVariantList" key="CustomOutputParsers"/>
|
||||
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
|
||||
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
|
||||
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
|
||||
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
|
||||
<value type="QString" key="RunConfiguration.Arguments"></value>
|
||||
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
|
||||
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
|
||||
<value type="QString" key="RunConfiguration.WorkingDirectory.default"></value>
|
||||
</valuemap>
|
||||
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
|
||||
</valuemap>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.TargetCount</variable>
|
||||
<value type="int">1</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>Version</variable>
|
||||
<value type="int">22</value>
|
||||
</data>
|
||||
</qtcreator>
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QLabel>
|
||||
#include "Dependencies/ResourceManager.h"
|
||||
|
||||
#define ORGBPluginInterface_IID "com.ORGBPluginInterface"
|
||||
|
||||
struct PluginInfo
|
||||
{
|
||||
std::string PluginName;
|
||||
std::string PluginDesc;
|
||||
std::string PluginLoca;
|
||||
|
||||
bool HasCustom;
|
||||
QLabel *PluginLabel;
|
||||
|
||||
std::string SettingName;
|
||||
};
|
||||
|
||||
class ORGBPluginInterface
|
||||
{
|
||||
public:
|
||||
virtual ~ORGBPluginInterface() {}
|
||||
|
||||
PluginInfo PInfo;
|
||||
|
||||
virtual PluginInfo DefineNeeded() = 0;
|
||||
|
||||
virtual PluginInfo init(json Settings , bool DarkTheme) = 0;
|
||||
|
||||
virtual QWidget *CreateGUI(QWidget *Parent) = 0;
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE(ORGBPluginInterface, ORGBPluginInterface_IID)
|
||||
43
OpenRGB/OpenRGBPluginInterface.h
Normal file
43
OpenRGB/OpenRGBPluginInterface.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*-----------------------------------------*\
|
||||
| OpenRGBPluginInterface.h |
|
||||
| |
|
||||
| OpenRGB Plugin Interface Class |
|
||||
| |
|
||||
| herosilas12 (CoffeeIsLife) 12/11/2020 |
|
||||
| Adam Honse (CalcProgrammer1) 1/5/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ResourceManager.h"
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QLabel>
|
||||
|
||||
#define OpenRGBPluginInterface_IID "com.OpenRGBPluginInterface"
|
||||
|
||||
struct OpenRGBPluginInfo
|
||||
{
|
||||
std::string PluginName;
|
||||
std::string PluginDescription;
|
||||
std::string PluginLocation;
|
||||
|
||||
bool HasCustom;
|
||||
QLabel *PluginLabel;
|
||||
|
||||
std::string SettingName;
|
||||
};
|
||||
|
||||
class OpenRGBPluginInterface
|
||||
{
|
||||
public:
|
||||
virtual ~OpenRGBPluginInterface() {}
|
||||
|
||||
virtual OpenRGBPluginInfo Initialize(bool dark_theme, ResourceManager* resource_manager_ptr) = 0;
|
||||
|
||||
virtual QWidget *CreateGUI(QWidget* parent) = 0;
|
||||
|
||||
OpenRGBPluginInfo info;
|
||||
};
|
||||
|
||||
Q_DECLARE_INTERFACE(OpenRGBPluginInterface, OpenRGBPluginInterface_IID)
|
||||
70
OpenRGB/ProfileManager.h
Normal file
70
OpenRGB/ProfileManager.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#include "RGBController.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
class ProfileManagerInterface
|
||||
{
|
||||
public:
|
||||
virtual bool SaveProfile(std::string profile_name) = 0;
|
||||
virtual bool LoadProfile(std::string profile_name) = 0;
|
||||
virtual bool LoadSizeFromProfile(std::string profile_name) = 0;
|
||||
virtual void DeleteProfile(std::string profile_name) = 0;
|
||||
|
||||
std::vector<std::string> profile_list;
|
||||
|
||||
virtual bool LoadDeviceFromListWithOptions
|
||||
(
|
||||
std::vector<RGBController*>& temp_controllers,
|
||||
std::vector<bool>& temp_controller_used,
|
||||
RGBController* load_controller,
|
||||
bool load_size,
|
||||
bool load_settings
|
||||
) = 0;
|
||||
|
||||
virtual std::vector<RGBController*> LoadProfileToList (std::string profile_name) = 0;
|
||||
|
||||
virtual void SetConfigurationDirectory(std::string directory) = 0;
|
||||
protected:
|
||||
virtual ~ProfileManagerInterface() {};
|
||||
};
|
||||
|
||||
class ProfileManager: public ProfileManagerInterface
|
||||
{
|
||||
public:
|
||||
ProfileManager(std::string config_dir);
|
||||
~ProfileManager();
|
||||
|
||||
bool SaveProfile(std::string profile_name);
|
||||
bool LoadProfile(std::string profile_name);
|
||||
bool LoadSizeFromProfile(std::string profile_name);
|
||||
void DeleteProfile(std::string profile_name);
|
||||
|
||||
std::vector<std::string> profile_list;
|
||||
|
||||
bool LoadDeviceFromListWithOptions
|
||||
(
|
||||
std::vector<RGBController*>& temp_controllers,
|
||||
std::vector<bool>& temp_controller_used,
|
||||
RGBController* load_controller,
|
||||
bool load_size,
|
||||
bool load_settings
|
||||
);
|
||||
|
||||
std::vector<RGBController*> LoadProfileToList
|
||||
(
|
||||
std::string profile_name
|
||||
);
|
||||
|
||||
void SetConfigurationDirectory(std::string directory);
|
||||
|
||||
private:
|
||||
std::string configuration_directory;
|
||||
|
||||
void UpdateProfileList();
|
||||
bool LoadProfileWithOptions
|
||||
(
|
||||
std::string profile_name,
|
||||
bool load_size,
|
||||
bool load_settings
|
||||
);
|
||||
};
|
||||
117
OpenRGB/ResourceManager.h
Normal file
117
OpenRGB/ResourceManager.h
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
/*-----------------------------------------*\
|
||||
| ResourceManager.h |
|
||||
| |
|
||||
| OpenRGB Resource Manager controls access |
|
||||
| to application components including |
|
||||
| RGBControllers, I2C interfaces, and |
|
||||
| network SDK components |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/27/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
#include "NetworkClient.h"
|
||||
#include "NetworkServer.h"
|
||||
#include "ProfileManager.h"
|
||||
#include "RGBController.h"
|
||||
#include "SettingsManager.h"
|
||||
|
||||
#define HID_INTERFACE_ANY -1
|
||||
#define HID_USAGE_ANY -1
|
||||
#define HID_USAGE_PAGE_ANY -1L
|
||||
|
||||
#define CONTROLLER_LIST_HID 0
|
||||
|
||||
typedef std::function<void(std::vector<i2c_smbus_interface*>&)> I2CBusDetectorFunction;
|
||||
typedef std::function<void(std::vector<RGBController*>&)> DeviceDetectorFunction;
|
||||
typedef std::function<void(std::vector<i2c_smbus_interface*>&, std::vector<RGBController*>&)> I2CDeviceDetectorFunction;
|
||||
|
||||
typedef void (*DeviceListChangeCallback)(void *);
|
||||
typedef void (*DetectionProgressCallback)(void *);
|
||||
typedef void (*I2CBusListChangeCallback)(void *);
|
||||
|
||||
class ResourceManagerInterface
|
||||
{
|
||||
public:
|
||||
virtual std::vector<i2c_smbus_interface*> & GetI2CBusses() = 0;
|
||||
|
||||
virtual void RegisterRGBController(RGBController *rgb_controller) = 0;
|
||||
|
||||
virtual void RegisterDeviceListChangeCallback(DeviceListChangeCallback new_callback, void * new_callback_arg) = 0;
|
||||
virtual void RegisterDetectionProgressCallback(DetectionProgressCallback new_callback, void * new_callback_arg) = 0;
|
||||
virtual void RegisterI2CBusListChangeCallback(I2CBusListChangeCallback new_callback, void * new_callback_arg) = 0;
|
||||
|
||||
virtual std::vector<RGBController*> & GetRGBControllers() = 0;
|
||||
|
||||
virtual std::string GetConfigurationDirectory() = 0;
|
||||
|
||||
virtual std::vector<NetworkClient*>& GetClients() = 0;
|
||||
virtual NetworkServer* GetServer() = 0;
|
||||
|
||||
virtual ProfileManager* GetProfileManager() = 0;
|
||||
virtual SettingsManager* GetSettingsManager() = 0;
|
||||
|
||||
virtual void DeviceListChanged() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~ResourceManagerInterface() {};
|
||||
};
|
||||
|
||||
class ResourceManager: public ResourceManagerInterface
|
||||
{
|
||||
public:
|
||||
static ResourceManager *get();
|
||||
|
||||
ResourceManager();
|
||||
~ResourceManager();
|
||||
|
||||
void RegisterI2CBus(i2c_smbus_interface *);
|
||||
std::vector<i2c_smbus_interface*> & GetI2CBusses();
|
||||
|
||||
void RegisterRGBController(RGBController *rgb_controller);
|
||||
|
||||
std::vector<RGBController*> & GetRGBControllers();
|
||||
|
||||
void RegisterI2CBusDetector (I2CBusDetectorFunction detector);
|
||||
void RegisterDeviceDetector (std::string name, DeviceDetectorFunction detector);
|
||||
void RegisterI2CDeviceDetector (std::string name, I2CDeviceDetectorFunction detector);
|
||||
|
||||
void RegisterDeviceListChangeCallback(DeviceListChangeCallback new_callback, void * new_callback_arg);
|
||||
void RegisterDetectionProgressCallback(DetectionProgressCallback new_callback, void * new_callback_arg);
|
||||
void RegisterI2CBusListChangeCallback(I2CBusListChangeCallback new_callback, void * new_callback_arg);
|
||||
|
||||
unsigned int GetDetectionPercent();
|
||||
const char* GetDetectionString();
|
||||
|
||||
std::string GetConfigurationDirectory();
|
||||
|
||||
std::vector<NetworkClient*>& GetClients();
|
||||
NetworkServer* GetServer();
|
||||
|
||||
ProfileManager* GetProfileManager();
|
||||
SettingsManager* GetSettingsManager();
|
||||
|
||||
void SetConfigurationDirectory(std::string directory);
|
||||
|
||||
void DeviceListChanged();
|
||||
void DetectionProgressChanged();
|
||||
void I2CBusListChanged();
|
||||
|
||||
void Cleanup();
|
||||
|
||||
void DetectDevices();
|
||||
|
||||
void DisableDetection();
|
||||
|
||||
void StopDeviceDetection();
|
||||
|
||||
void WaitForDeviceDetection();
|
||||
};
|
||||
|
|
@ -15,19 +15,31 @@
|
|||
|
||||
using json = nlohmann::json;
|
||||
|
||||
class SettingsManager
|
||||
class SettingsManagerInterface
|
||||
{
|
||||
public:
|
||||
virtual json GetSettings(std::string settings_key) = 0;
|
||||
virtual void SetSettings(std::string settings_key, json new_settings) = 0;
|
||||
|
||||
virtual void LoadSettings(std::string filename) = 0;
|
||||
virtual void SaveSettings() = 0;
|
||||
|
||||
protected:
|
||||
virtual ~SettingsManagerInterface() {};
|
||||
};
|
||||
|
||||
class SettingsManager: public SettingsManagerInterface
|
||||
{
|
||||
public:
|
||||
SettingsManager();
|
||||
~SettingsManager();
|
||||
|
||||
json GetSettings(std::string settings_key);
|
||||
void SetSettings(std::string settings_key, json new_settings);
|
||||
json GetSettings(std::string settings_key) override;
|
||||
void SetSettings(std::string settings_key, json new_settings) override;
|
||||
|
||||
void LoadSettings(std::string filename);
|
||||
void SaveSettings();
|
||||
void LoadSettings(std::string filename) override;
|
||||
void SaveSettings() override;
|
||||
|
||||
|
||||
private:
|
||||
json settings_data;
|
||||
json settings_prototype;
|
||||
129
OpenRGB/i2c_smbus/i2c_smbus.h
Normal file
129
OpenRGB/i2c_smbus/i2c_smbus.h
Normal file
|
|
@ -0,0 +1,129 @@
|
|||
/*-----------------------------------------*\
|
||||
| i2c_smbus.h |
|
||||
| |
|
||||
| Definitions and types for SMBUS drivers |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 8/8/2018 |
|
||||
| Portions based on Linux source code |
|
||||
| GNU GPL v2 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#ifndef I2C_SMBUS_H
|
||||
#define I2C_SMBUS_H
|
||||
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef int s32;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
//Data for SMBus Messages
|
||||
#define I2C_SMBUS_BLOCK_MAX 32
|
||||
|
||||
union i2c_smbus_data
|
||||
{
|
||||
u8 byte;
|
||||
u16 word;
|
||||
u8 block[I2C_SMBUS_BLOCK_MAX + 2];
|
||||
};
|
||||
|
||||
#endif /* _WIN32 */
|
||||
|
||||
#ifdef __linux__
|
||||
|
||||
#include <linux/i2c.h>
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
//Data for SMBus Messages
|
||||
#define I2C_SMBUS_BLOCK_MAX 32
|
||||
|
||||
union i2c_smbus_data
|
||||
{
|
||||
u8 byte;
|
||||
u16 word;
|
||||
u8 block[I2C_SMBUS_BLOCK_MAX + 2];
|
||||
};
|
||||
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
// i2c_smbus_xfer read or write markers
|
||||
#define I2C_SMBUS_READ 1
|
||||
#define I2C_SMBUS_WRITE 0
|
||||
|
||||
// SMBus transaction types (size parameter in the above functions)
|
||||
#define I2C_SMBUS_QUICK 0
|
||||
#define I2C_SMBUS_BYTE 1
|
||||
#define I2C_SMBUS_BYTE_DATA 2
|
||||
#define I2C_SMBUS_WORD_DATA 3
|
||||
#define I2C_SMBUS_PROC_CALL 4
|
||||
#define I2C_SMBUS_BLOCK_DATA 5
|
||||
#define I2C_SMBUS_I2C_BLOCK_BROKEN 6
|
||||
#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
|
||||
#define I2C_SMBUS_I2C_BLOCK_DATA 8
|
||||
|
||||
class i2c_smbus_interface
|
||||
{
|
||||
public:
|
||||
char device_name[512];
|
||||
|
||||
int port_id;
|
||||
int pci_device;
|
||||
int pci_vendor;
|
||||
int pci_subsystem_device;
|
||||
int pci_subsystem_vendor;
|
||||
|
||||
i2c_smbus_interface();
|
||||
virtual ~i2c_smbus_interface();
|
||||
|
||||
void i2c_smbus_thread_function();
|
||||
|
||||
//Functions derived from i2c-core.c
|
||||
s32 i2c_smbus_write_quick(u8 addr, u8 value);
|
||||
s32 i2c_smbus_read_byte(u8 addr);
|
||||
s32 i2c_smbus_write_byte(u8 addr, u8 value);
|
||||
s32 i2c_smbus_read_byte_data(u8 addr, u8 command);
|
||||
s32 i2c_smbus_write_byte_data(u8 addr, u8 command, u8 value);
|
||||
s32 i2c_smbus_read_word_data(u8 addr, u8 command);
|
||||
s32 i2c_smbus_write_word_data(u8 addr, u8 command, u16 value);
|
||||
s32 i2c_smbus_read_block_data(u8 addr, u8 command, u8 *values);
|
||||
s32 i2c_smbus_write_block_data(u8 addr, u8 command, u8 length, const u8 *values);
|
||||
s32 i2c_smbus_read_i2c_block_data(u8 addr, u8 command, u8 length, u8 *values);
|
||||
s32 i2c_smbus_write_i2c_block_data(u8 addr, u8 command, u8 length, const u8 *values);
|
||||
|
||||
s32 i2c_smbus_xfer_call(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data);
|
||||
|
||||
//Virtual function to be implemented by the driver
|
||||
virtual s32 i2c_smbus_xfer(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data) = 0;
|
||||
|
||||
private:
|
||||
std::thread * i2c_smbus_thread;
|
||||
std::atomic<bool> i2c_smbus_thread_running;
|
||||
|
||||
std::atomic<bool> i2c_smbus_start;
|
||||
std::condition_variable i2c_smbus_start_cv;
|
||||
std::mutex i2c_smbus_start_mutex;
|
||||
|
||||
std::atomic<bool> i2c_smbus_done;
|
||||
std::condition_variable i2c_smbus_done_cv;
|
||||
std::mutex i2c_smbus_done_mutex;
|
||||
|
||||
std::mutex i2c_smbus_xfer_mutex;
|
||||
|
||||
u8 i2c_addr;
|
||||
char i2c_read_write;
|
||||
u16 i2c_command;
|
||||
int i2c_size;
|
||||
i2c_smbus_data* i2c_data;
|
||||
s32 i2c_ret;
|
||||
};
|
||||
|
||||
#endif /* I2C_SMBUS_H */
|
||||
114
OpenRGBPlugin.cpp
Normal file
114
OpenRGBPlugin.cpp
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
/*-----------------------------------------*\
|
||||
| OpenRGBPlugin.cpp |
|
||||
| |
|
||||
| OpenRGB Plugin template with example |
|
||||
| |
|
||||
| herosilas12 (CoffeeIsLife) 12/11/2020 |
|
||||
| Adam Honse (CalcProgrammer1) 1/5/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "OpenRGBPlugin.h"
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Initialize |
|
||||
| |
|
||||
| This function must be present in all |
|
||||
| OpenRGB plugins. It defines the plugin |
|
||||
| name, description, location, and other |
|
||||
| plugin information. It creates the tab |
|
||||
| label and is the entry point for plugin |
|
||||
| code |
|
||||
\*-----------------------------------------*/
|
||||
OpenRGBPluginInfo OpenRGBPlugin::Initialize(bool dark_theme, ResourceManager* resource_manager_ptr)
|
||||
{
|
||||
info.PluginName = "OpenRGB Plugin Template";
|
||||
info.PluginDescription = "An example plugin for OpenRGB";
|
||||
info.PluginLocation = "InformationTab";
|
||||
info.HasCustom = false;
|
||||
info.SettingName = "";
|
||||
info.PluginLabel = new QLabel();
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set the label text |
|
||||
\*-----------------------------------------------------*/
|
||||
info.PluginLabel->setText("OpenRGB Example Plugin");
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Save the arguments to Initialize based on what you |
|
||||
| need for this plugin's functionality. In this example|
|
||||
| we will need the Resource Manager to access the device|
|
||||
| list, so save the Resource Manager pointer locally. |
|
||||
\*-----------------------------------------------------*/
|
||||
resource_manager = resource_manager_ptr;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| CreateGUI |
|
||||
| |
|
||||
| This function must be present in all |
|
||||
| OpenRGB plugins. It creates the QWidget |
|
||||
| that represents the plugin tab's content |
|
||||
\*-----------------------------------------*/
|
||||
QWidget* OpenRGBPlugin::CreateGUI(QWidget* parent)
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Create the main widget for this plugin tab |
|
||||
\*-----------------------------------------------------*/
|
||||
QWidget* plugin_widget = new QWidget(parent);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| In this example, we will create a label showing the |
|
||||
| number of RGBController devices. This will be shown |
|
||||
| in a QLabel, updated at 1Hz by a background thread. |
|
||||
\*-----------------------------------------------------*/
|
||||
plugin_label = new QLabel(plugin_widget);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| With the label created, start the worker thread |
|
||||
\*-----------------------------------------------------*/
|
||||
TimerThread = new std::thread(&OpenRGBPlugin::TimerThreadFunction, this);
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| The CreateGUI function must return the main widget |
|
||||
\*-----------------------------------------------------*/
|
||||
return plugin_widget;
|
||||
}
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| TimerThreadFunction |
|
||||
| |
|
||||
| This function is part of the example code|
|
||||
| and is not a required part of an OpenRGB |
|
||||
| plugin. This function is an example of |
|
||||
| how a plugin can run a background thread |
|
||||
| and interact with the Resource Manager |
|
||||
\*-----------------------------------------*/
|
||||
void OpenRGBPlugin::TimerThreadFunction()
|
||||
{
|
||||
/*-----------------------------------------------------*\
|
||||
| Begin infinite loop |
|
||||
\*-----------------------------------------------------*/
|
||||
while(1)
|
||||
{
|
||||
/*-------------------------------------------------*\
|
||||
| Print the number of devices to a string |
|
||||
\*-------------------------------------------------*/
|
||||
std::string text;
|
||||
|
||||
text.append("Number of devices detected: ");
|
||||
text.append(std::to_string(resource_manager->GetRGBControllers().size()));
|
||||
text.append("\r\n");
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Update the label |
|
||||
\*-------------------------------------------------*/
|
||||
plugin_label->setText(QString::fromStdString(text));
|
||||
|
||||
/*-------------------------------------------------*\
|
||||
| Sleep for 1 second |
|
||||
\*-------------------------------------------------*/
|
||||
Sleep(1000);
|
||||
}
|
||||
}
|
||||
40
OpenRGBPlugin.h
Normal file
40
OpenRGBPlugin.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
/*-----------------------------------------*\
|
||||
| OpenRGBPlugin.h |
|
||||
| |
|
||||
| OpenRGB Plugin template with example |
|
||||
| |
|
||||
| herosilas12 (CoffeeIsLife) 12/11/2020 |
|
||||
| Adam Honse (CalcProgrammer1) 1/5/2021 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "OpenRGBPluginInterface.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QtPlugin>
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
|
||||
class OpenRGBPlugin : public QObject, public OpenRGBPluginInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID OpenRGBPluginInterface_IID)
|
||||
Q_INTERFACES(OpenRGBPluginInterface)
|
||||
|
||||
public:
|
||||
virtual ~OpenRGBPlugin() {};
|
||||
|
||||
virtual OpenRGBPluginInfo Initialize(bool dark_theme, ResourceManager* resource_manager_ptr) override;
|
||||
|
||||
virtual QWidget *CreateGUI(QWidget* parent) override;
|
||||
|
||||
void TimerThreadFunction();
|
||||
|
||||
private:
|
||||
ResourceManager* resource_manager;
|
||||
QLabel* plugin_label;
|
||||
|
||||
std::thread* TimerThread;
|
||||
};
|
||||
65
OpenRGBPlugin.pro
Normal file
65
OpenRGBPlugin.pro
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#-----------------------------------------------------------------------------------------------#
|
||||
# OpenRGB Plugin Template QMake Project #
|
||||
# #
|
||||
# herosilas12 (CoffeeIsLife) 12/11/2020 #
|
||||
# Adam Honse (CalcProgrammer1) 1/5/2021 #
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
# Qt Configuration #
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
QT += \
|
||||
core \
|
||||
gui \
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
# Application Configuration #
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
|
||||
TEMPLATE = lib
|
||||
DEFINES += ORGBEXAMPLEPLUGIN_LIBRARY
|
||||
|
||||
CONFIG += c++11
|
||||
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
# Plugin Project Files #
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
SOURCES += \
|
||||
OpenRGBPlugin.cpp \
|
||||
|
||||
HEADERS += \
|
||||
OpenRGBPlugin.h \
|
||||
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
# OpenRGB Plugin SDK #
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
INCLUDEPATH += \
|
||||
OpenRGB/ \
|
||||
OpenRGB/dependencies/json \
|
||||
OpenRGB/i2c_smbus \
|
||||
OpenRGB/net_port \
|
||||
OpenRGB/RGBController \
|
||||
|
||||
HEADERS += \
|
||||
OpenRGB/NetworkClient.h \
|
||||
OpenRGB/NetworkProtocol.h \
|
||||
OpenRGB/NetworkServer.h \
|
||||
OpenRGB/OpenRGBPluginInterface.h \
|
||||
OpenRGB/ProfileManager.h \
|
||||
OpenRGB/ResourceManager.h \
|
||||
OpenRGB/SettingsManager.h \
|
||||
OpenRGB/dependencies/json/json.hpp \
|
||||
OpenRGB/i2c_smbus/i2c_smbus.h \
|
||||
OpenRGB/net_port/net_port.h \
|
||||
OpenRGB/RGBController/RGBController.h \
|
||||
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
# Default rules for deployment. #
|
||||
#-----------------------------------------------------------------------------------------------#
|
||||
unix {
|
||||
target.path = /usr/lib
|
||||
}
|
||||
|
||||
!isEmpty(target.path): INSTALLS += target
|
||||
Loading…
Reference in a new issue