Use OpenRGB as a submodule

This commit is contained in:
Adam Honse 2021-03-09 08:11:29 -06:00
parent 2fcaacfdff
commit d0020c222a
14 changed files with 6 additions and 26564 deletions

View file

@ -1,6 +1,8 @@
#-----------------------------------------------------------------------#
# OpenRGB E1.31 Receiver Plugin GitLab CI Configuration #
#-----------------------------------------------------------------------#
variables:
GIT_SUBMODULE_STRATEGY: recursive
.shared_windows_runners:
tags:

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "OpenRGB"]
path = OpenRGB
url = https://gitlab.com/CalcProgrammer1/OpenRGB

1
OpenRGB Submodule

@ -0,0 +1 @@
Subproject commit 526a4daae26536505948028fc2f302984da7114a

View file

@ -1,102 +0,0 @@
/*-----------------------------------------*\
| NetworkClient.h |
| |
| Client header for OpenRGB SDK |
| |
| Adam Honse (CalcProgrammer1) 5/9/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include "NetworkProtocol.h"
#include "net_port.h"
#include <mutex>
#include <thread>
#pragma once
typedef void (*NetClientCallback)(void *);
class NetworkClient
{
public:
NetworkClient(std::vector<RGBController *>& control);
~NetworkClient();
void ClientInfoChanged();
bool GetConnected();
const char * GetIP();
unsigned short GetPort();
unsigned int GetProtocolVersion();
bool GetOnline();
void RegisterClientInfoChangeCallback(NetClientCallback new_callback, void * new_callback_arg);
void SetIP(const char *new_ip);
void SetName(const char *new_name);
void SetPort(unsigned short new_port);
void StartClient();
void StopClient();
void ConnectionThreadFunction();
void ListenThreadFunction();
void WaitOnControllerData();
void ProcessReply_ControllerCount(unsigned int data_size, char * data);
void ProcessReply_ControllerData(unsigned int data_size, char * data, unsigned int dev_idx);
void ProcessReply_ProtocolVersion(unsigned int data_size, char * data);
void ProcessRequest_DeviceListChanged();
void SendData_ClientString();
void SendRequest_ControllerCount();
void SendRequest_ControllerData(unsigned int dev_idx);
void SendRequest_ProtocolVersion();
void SendRequest_RGBController_ResizeZone(unsigned int dev_idx, int zone, int new_size);
void SendRequest_RGBController_UpdateLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size);
void SendRequest_RGBController_UpdateZoneLEDs(unsigned int dev_idx, unsigned char * data, unsigned int size);
void SendRequest_RGBController_UpdateSingleLED(unsigned int dev_idx, unsigned char * data, unsigned int size);
void SendRequest_RGBController_SetCustomMode(unsigned int dev_idx);
void SendRequest_RGBController_UpdateMode(unsigned int dev_idx, unsigned char * data, unsigned int size);
std::vector<RGBController *> server_controllers;
std::mutex ControllerListMutex;
protected:
std::vector<RGBController *>& controllers;
private:
SOCKET client_sock;
std::string client_name;
net_port port;
char port_ip[20];
unsigned short port_num;
bool client_active;
bool controller_data_received;
bool server_connected;
bool server_initialized;
unsigned int server_controller_count;
bool server_controller_count_received;
unsigned int server_protocol_version;
bool server_protocol_version_received;
bool change_in_progress;
std::thread * ConnectionThread;
std::thread * ListenThread;
std::mutex ClientInfoChangeMutex;
std::vector<NetClientCallback> ClientInfoChangeCallbacks;
std::vector<void *> ClientInfoChangeCallbackArgs;
int recv_select(SOCKET s, char *buf, int len, int flags);
};

View file

@ -1,57 +0,0 @@
/*-----------------------------------------*\
| NetworkProtocol.h |
| |
| Protocol header for OpenRGB SDK |
| |
| Adam Honse (CalcProgrammer1) 5/9/2020 |
\*-----------------------------------------*/
#pragma once
/*-----------------------------------------------------*\
| OpenRGB SDK protocol version |
| |
| 0: Initial (unversioned) protocol |
| 1: Add versioning, vendor string (Release 0.5) |
\*-----------------------------------------------------*/
#define OPENRGB_SDK_PROTOCOL_VERSION 1
/*-----------------------------------------------------*\
| Default OpenRGB SDK port is 6742 |
| This is "ORGB" on a phone keypad |
\*-----------------------------------------------------*/
#define OPENRGB_SDK_PORT 6742
typedef struct NetPacketHeader
{
char pkt_magic[4]; /* Magic value "ORGB" identifies beginning of packet */
unsigned int pkt_dev_idx; /* Device index */
unsigned int pkt_id; /* Packet ID */
unsigned int pkt_size; /* Packet size */
} NetPacketHeader;
enum
{
/*----------------------------------------------------------------------------------------------------------*\
| Network requests |
\*----------------------------------------------------------------------------------------------------------*/
NET_PACKET_ID_REQUEST_CONTROLLER_COUNT = 0, /* Request RGBController device count from server */
NET_PACKET_ID_REQUEST_CONTROLLER_DATA = 1, /* Request RGBController data block */
NET_PACKET_ID_REQUEST_PROTOCOL_VERSION = 40, /* Request OpenRGB SDK protocol version from server */
NET_PACKET_ID_SET_CLIENT_NAME = 50, /* Send client name string to server */
NET_PACKET_ID_DEVICE_LIST_UPDATED = 100, /* Indicate to clients that device list has updated */
/*----------------------------------------------------------------------------------------------------------*\
| RGBController class functions |
\*----------------------------------------------------------------------------------------------------------*/
NET_PACKET_ID_RGBCONTROLLER_RESIZEZONE = 1000, /* RGBController::ResizeZone() */
NET_PACKET_ID_RGBCONTROLLER_UPDATELEDS = 1050, /* RGBController::UpdateLEDs() */
NET_PACKET_ID_RGBCONTROLLER_UPDATEZONELEDS = 1051, /* RGBController::UpdateZoneLEDs() */
NET_PACKET_ID_RGBCONTROLLER_UPDATESINGLELED = 1052, /* RGBController::UpdateSingleLED() */
NET_PACKET_ID_RGBCONTROLLER_SETCUSTOMMODE = 1100, /* RGBController::SetCustomMode() */
NET_PACKET_ID_RGBCONTROLLER_UPDATEMODE = 1101, /* RGBController::UpdateMode() */
};

View file

@ -1,87 +0,0 @@
/*-----------------------------------------*\
| NetworkServer.h |
| |
| Server header for OpenRGB SDK |
| |
| Adam Honse (CalcProgrammer1) 5/9/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include "NetworkProtocol.h"
#include "net_port.h"
#include <mutex>
#include <thread>
#include <chrono>
#pragma once
typedef void (*NetServerCallback)(void *);
struct NetworkClientInfo
{
SOCKET client_sock;
std::thread * client_listen_thread;
std::string client_string;
unsigned int client_protocol_version;
char client_ip[INET_ADDRSTRLEN];
};
class NetworkServer
{
public:
NetworkServer(std::vector<RGBController *>& control);
~NetworkServer();
unsigned short GetPort();
bool GetOnline();
unsigned int GetNumClients();
const char * GetClientString(unsigned int client_num);
const char * GetClientIP(unsigned int client_num);
unsigned int GetClientProtocolVersion(unsigned int client_num);
void ClientInfoChanged();
void DeviceListChanged();
void RegisterClientInfoChangeCallback(NetServerCallback, void * new_callback_arg);
void SetPort(unsigned short new_port);
void StartServer();
void StopServer();
void ConnectionThreadFunction();
void ListenThreadFunction(NetworkClientInfo * client_sock);
void ProcessRequest_ClientProtocolVersion(SOCKET client_sock, unsigned int data_size, char * data);
void ProcessRequest_ClientString(SOCKET client_sock, unsigned int data_size, char * data);
void SendReply_ControllerCount(SOCKET client_sock);
void SendReply_ControllerData(SOCKET client_sock, unsigned int dev_idx, unsigned int protocol_version);
void SendReply_ProtocolVersion(SOCKET client_sock);
void SendRequest_DeviceListChanged(SOCKET client_sock);
protected:
unsigned short port_num;
bool server_online;
std::vector<RGBController *>& controllers;
std::mutex ServerClientsMutex;
std::vector<NetworkClientInfo *> ServerClients;
std::thread * ConnectionThread;
std::mutex ClientInfoChangeMutex;
std::vector<NetServerCallback> ClientInfoChangeCallbacks;
std::vector<void *> ClientInfoChangeCallbackArgs;
private:
#ifdef WIN32
WSADATA wsa;
#endif
SOCKET server_sock;
int accept_select(int sockfd, struct sockaddr *addr, socklen_t *addrlen);
int recv_select(SOCKET s, char *buf, int len, int flags);
};

View file

@ -1,41 +0,0 @@
/*-----------------------------------------*\
| 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;
};
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)

View file

@ -1,70 +0,0 @@
#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
);
};

View file

@ -1,292 +0,0 @@
/*-----------------------------------------*\
| RGBController.h |
| |
| Definitions and types for generic RGB |
| lighting controller interface |
| |
| Adam Honse (CalcProgrammer1) 6/2/2019 |
\*-----------------------------------------*/
#pragma once
#include <atomic>
#include <vector>
#include <string>
#include <thread>
#include <chrono>
#include <mutex>
typedef unsigned int RGBColor;
#define RGBGetRValue(rgb) (rgb & 0x000000FF)
#define RGBGetGValue(rgb) ((rgb >> 8) & 0x000000FF)
#define RGBGetBValue(rgb) ((rgb >> 16) & 0x000000FF)
#define ToRGBColor(r, g, b) ((b << 16) | (g << 8) | (r))
/*------------------------------------------------------------------*\
| Mode Flags |
\*------------------------------------------------------------------*/
enum
{
MODE_FLAG_HAS_SPEED = (1 << 0), /* Mode has speed parameter */
MODE_FLAG_HAS_DIRECTION_LR = (1 << 1), /* Mode has left/right parameter */
MODE_FLAG_HAS_DIRECTION_UD = (1 << 2), /* Mode has up/down parameter */
MODE_FLAG_HAS_DIRECTION_HV = (1 << 3), /* Mode has horiz/vert parameter */
MODE_FLAG_HAS_BRIGHTNESS = (1 << 4), /* Mode has brightness parameter */
MODE_FLAG_HAS_PER_LED_COLOR = (1 << 5), /* Mode has per-LED colors */
MODE_FLAG_HAS_MODE_SPECIFIC_COLOR = (1 << 6), /* Mode has mode specific colors */
MODE_FLAG_HAS_RANDOM_COLOR = (1 << 7), /* Mode has random color option */
};
/*------------------------------------------------------------------*\
| Mode Directions |
\*------------------------------------------------------------------*/
enum
{
MODE_DIRECTION_LEFT = 0, /* Mode direction left */
MODE_DIRECTION_RIGHT = 1, /* Mode direction right */
MODE_DIRECTION_UP = 2, /* Mode direction up */
MODE_DIRECTION_DOWN = 3, /* Mode direction down */
MODE_DIRECTION_HORIZONTAL = 4, /* Mode direction horizontal */
MODE_DIRECTION_VERTICAL = 5, /* Mode direction vertical */
};
enum
{
MODE_COLORS_NONE = 0, /* Mode has no colors */
MODE_COLORS_PER_LED = 1, /* Mode has per LED colors selected */
MODE_COLORS_MODE_SPECIFIC = 2, /* Mode specific colors selected */
MODE_COLORS_RANDOM = 3, /* Mode has random colors selected */
};
/*------------------------------------------------------------------*\
| Mode Type |
\*------------------------------------------------------------------*/
typedef struct
{
/*--------------------------------------------------------------*\
| Mode Information |
\*--------------------------------------------------------------*/
std::string name; /* Mode name */
int value; /* Device-specific mode value */
unsigned int flags; /* Mode flags bitfield */
unsigned int speed_min; /* speed minimum value */
unsigned int speed_max; /* speed maximum value */
unsigned int colors_min; /* minimum number of mode colors*/
unsigned int colors_max; /* maximum numver of mode colors*/
/*--------------------------------------------------------------*\
| Mode Settings |
\*--------------------------------------------------------------*/
unsigned int speed; /* Mode speed parameter value */
unsigned int direction; /* Mode direction value */
unsigned int color_mode; /* Mode color selection */
std::vector<RGBColor>
colors; /* mode-specific colors */
} mode;
typedef struct
{
std::string name; /* LED name */
unsigned int value; /* Device-specific LED value */
} led;
typedef int zone_type;
enum
{
ZONE_TYPE_SINGLE,
ZONE_TYPE_LINEAR,
ZONE_TYPE_MATRIX
};
typedef int device_type;
enum
{
DEVICE_TYPE_MOTHERBOARD,
DEVICE_TYPE_DRAM,
DEVICE_TYPE_GPU,
DEVICE_TYPE_COOLER,
DEVICE_TYPE_LEDSTRIP,
DEVICE_TYPE_KEYBOARD,
DEVICE_TYPE_MOUSE,
DEVICE_TYPE_MOUSEMAT,
DEVICE_TYPE_HEADSET,
DEVICE_TYPE_HEADSET_STAND,
DEVICE_TYPE_GAMEPAD,
DEVICE_TYPE_LIGHT,
DEVICE_TYPE_UNKNOWN
};
std::string device_type_to_str(device_type type);
typedef struct
{
unsigned int height;
unsigned int width;
unsigned int * map;
} matrix_map_type;
typedef struct
{
std::string name; /* Zone name */
zone_type type; /* Zone type */
led * leds; /* List of LEDs in zone */
RGBColor * colors; /* Colors of LEDs in zone */
unsigned int start_idx; /* Start index of led/color */
unsigned int leds_count; /* Number of LEDs in zone */
unsigned int leds_min; /* Minimum number of LEDs */
unsigned int leds_max; /* Maximum number of LEDs */
matrix_map_type * matrix_map; /* Matrix map pointer */
} zone;
typedef void (*RGBControllerCallback)(void *);
class RGBControllerInterface
{
public:
virtual void SetupColors() = 0;
virtual RGBColor GetLED(unsigned int led) = 0;
virtual void SetLED(unsigned int led, RGBColor color) = 0;
virtual void SetAllLEDs(RGBColor color) = 0;
virtual void SetAllZoneLEDs(int zone, RGBColor color) = 0;
virtual int GetMode() = 0;
virtual void SetMode(int mode) = 0;
virtual unsigned char * GetDeviceDescription(unsigned int protocol_version) = 0;
virtual void ReadDeviceDescription(unsigned char* data_buf, unsigned int protocol_version) = 0;
virtual unsigned char * GetModeDescription(int mode) = 0;
virtual void SetModeDescription(unsigned char* data_buf) = 0;
virtual unsigned char * GetColorDescription() = 0;
virtual void SetColorDescription(unsigned char* data_buf) = 0;
virtual unsigned char * GetZoneColorDescription(int zone) = 0;
virtual void SetZoneColorDescription(unsigned char* data_buf) = 0;
virtual unsigned char * GetSingleLEDColorDescription(int led) = 0;
virtual void SetSingleLEDColorDescription(unsigned char* data_buf) = 0;
virtual void RegisterUpdateCallback(RGBControllerCallback new_callback, void * new_callback_arg) = 0;
virtual void UnregisterUpdateCallback(void * callback_arg) = 0;
virtual void SignalUpdate() = 0;
virtual void UpdateLEDs() = 0;
//virtual void UpdateZoneLEDs(int zone) = 0;
//virtual void UpdateSingleLED(int led) = 0;
virtual void UpdateMode() = 0;
virtual void DeviceCallThreadFunction() = 0;
/*---------------------------------------------------------*\
| Functions to be implemented in device implementation |
\*---------------------------------------------------------*/
virtual void SetupZones() = 0;
virtual void ResizeZone(int zone, int new_size) = 0;
virtual void DeviceUpdateLEDs() = 0;
virtual void UpdateZoneLEDs(int zone) = 0;
virtual void UpdateSingleLED(int led) = 0;
virtual void DeviceUpdateMode() = 0;
virtual void SetCustomMode() = 0;
};
class RGBController : public RGBControllerInterface
{
public:
std::string name; /* controller name */
std::string vendor; /* controller vendor */
std::string description; /* controller description */
std::string version; /* controller version */
std::string serial; /* controller serial number */
std::string location; /* controller location */
std::vector<led> leds; /* LEDs */
std::vector<zone> zones; /* Zones */
std::vector<mode> modes; /* Modes */
std::vector<RGBColor> colors; /* Color buffer */
device_type type; /* device type */
int active_mode = 0;/* active mode */
/*---------------------------------------------------------*\
| RGBController base class constructor |
\*---------------------------------------------------------*/
RGBController();
virtual ~RGBController();
/*---------------------------------------------------------*\
| Generic functions implemented in RGBController.cpp |
\*---------------------------------------------------------*/
void SetupColors();
RGBColor GetLED(unsigned int led);
void SetLED(unsigned int led, RGBColor color);
void SetAllLEDs(RGBColor color);
void SetAllZoneLEDs(int zone, RGBColor color);
int GetMode();
void SetMode(int mode);
unsigned char * GetDeviceDescription(unsigned int protocol_version);
void ReadDeviceDescription(unsigned char* data_buf, unsigned int protocol_version);
unsigned char * GetModeDescription(int mode);
void SetModeDescription(unsigned char* data_buf);
unsigned char * GetColorDescription();
void SetColorDescription(unsigned char* data_buf);
unsigned char * GetZoneColorDescription(int zone);
void SetZoneColorDescription(unsigned char* data_buf);
unsigned char * GetSingleLEDColorDescription(int led);
void SetSingleLEDColorDescription(unsigned char* data_buf);
void RegisterUpdateCallback(RGBControllerCallback new_callback, void * new_callback_arg);
void UnregisterUpdateCallback(void * callback_arg);
void SignalUpdate();
void UpdateLEDs();
//void UpdateZoneLEDs(int zone);
//void UpdateSingleLED(int led);
void UpdateMode();
void DeviceCallThreadFunction();
/*---------------------------------------------------------*\
| Functions to be implemented in device implementation |
\*---------------------------------------------------------*/
virtual void SetupZones() = 0;
virtual void ResizeZone(int zone, int new_size) = 0;
virtual void DeviceUpdateLEDs() = 0;
virtual void UpdateZoneLEDs(int zone) = 0;
virtual void UpdateSingleLED(int led) = 0;
virtual void DeviceUpdateMode() = 0;
virtual void SetCustomMode() = 0;
private:
std::thread* DeviceCallThread;
std::atomic<bool> CallFlag_UpdateLEDs;
std::atomic<bool> CallFlag_UpdateMode;
std::atomic<bool> DeviceThreadRunning;
//bool CallFlag_UpdateZoneLEDs = false;
//bool CallFlag_UpdateSingleLED = false;
//bool CallFlag_UpdateMode = false;
std::mutex UpdateMutex;
std::vector<RGBControllerCallback> UpdateCallbacks;
std::vector<void *> UpdateCallbackArgs;
};

View file

@ -1,119 +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 "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 unsigned int GetDetectionPercent() = 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();
};

View file

@ -1,47 +0,0 @@
/*-----------------------------------------*\
| SettingsManager.h |
| |
| OpenRGB Settings Manager maintains a list|
| of application settings in JSON format. |
| Other components may register settings |
| with this class and store/load values. |
| |
| Adam Honse (CalcProgrammer1) 11/4/2020 |
\*-----------------------------------------*/
#pragma once
#include "json.hpp"
using json = nlohmann::json;
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) override;
void SetSettings(std::string settings_key, json new_settings) override;
void LoadSettings(std::string filename) override;
void SaveSettings() override;
private:
json settings_data;
json settings_prototype;
std::string settings_filename;
};

File diff suppressed because it is too large Load diff

View file

@ -1,129 +0,0 @@
/*-----------------------------------------*\
| 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 */

View file

@ -1,87 +0,0 @@
/*---------------------------------------------------------*\
| Cross Platform Network Library for Windows and Linux |
| This library provides access to TCP and UDP ports with |
| a common API for both Windows and Linux systems. It |
| features read and write |
| |
| Adam Honse (calcprogrammer1@gmail.com), 12/15/2016 |
\*---------------------------------------------------------*/
#ifndef NET_PORT_H
#define NET_PORT_H
#include <vector>
#ifdef WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <ifaddrs.h>
#include <net/if.h>
#endif
#ifndef WIN32
#define SOCKET int
#define ioctlsocket ioctl
#define closesocket close
#define WSACleanup()
#define INVALID_SOCKET -1
#define SOCKET_ERROR -1
#define SD_RECEIVE SHUT_RD
#endif
//Network Port Class
//The reason for this class is that network ports are treated differently
//on Windows and Linux. By creating a class, those differences can be
//made invisible to the program and make cross-platform usage easy
class net_port
{
public:
net_port();
net_port(const char * client_name, const char * port);
~net_port();
//Function to open the port
bool udp_client(const char* client_name, const char * port);
bool tcp_client(const char* client_name, const char * port);
bool tcp_client_connect();
//Function to open a server
bool tcp_server(const char * port);
std::size_t tcp_server_num_clients();
SOCKET * tcp_server_get_client(std::size_t client_idx);
SOCKET * tcp_server_listen();
int udp_listen(char * recv_data, int length);
int tcp_listen(char * recv_data, int length);
//Function to write data to the serial port
int udp_write(char * buffer, int length);
int tcp_write(char * buffer, int length);
int tcp_client_write(char * buffer, int length);
void tcp_close();
bool connected;
SOCKET sock;
private:
#ifdef WIN32
WSADATA wsa;
#endif
std::vector<SOCKET *> clients;
sockaddr addrDest;
addrinfo* result_list;
};
#endif