OpenRGB/Controllers/GigabyteRGBFusion2USBController/RGBController_GigabyteRGBFusion2USB.h
Chris 727fd9efb9 Moved GB_Fusion2USB calibration & custom layout loading to config file
+ Adding layout for Z390 AORUS MASTER-CF
+ Adding destructor to RGBController_GigabyteRGBFusion2USB.cpp to
'delete controller'

+ Allows custom layout saving to config
+ Custom config will save out to config if not present
+ Layout is enablable and disabled by default
+ Added a lookup map from mapping in config
+ Added a template for the reverse_map for saving to the config
+ Removed the header integers from the config to avoid invalid values
+ Changed internal mapping closer to JSON for ease of lookup
+ Added protection to the led count

+ Added calibration to config
* Disabled execution of calibration until explicitely enabled in config

Commit amended for code style of changes as well as general cleanup of RGB Fusion 2 USB controller by Adam Honse <calcprogrammer1@gmail.com>
2021-04-14 23:30:34 -05:00

77 lines
2.2 KiB
C++

/*-----------------------------------------*\
| RGBController_GigabyteRGBFusion2USB.h |
| |
| Generic RGB Interface for OpenRGB |
| Gigabyte RGB Fusion 2.0 USB Driver |
| |
| Author: jackun 1/8/2020 |
| Maintainer: Chris M (Dr_No) |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "GigabyteRGBFusion2USBController.h"
#include <map>
#include <vector>
#define RGBFusion2_Digital_LEDS_Min 0;
#define RGBFusion2_Digital_LEDS_Max 1024;
#define RGBFusion2_Digital_Direct_Offset (HDR_D_LED1_RGB - HDR_D_LED1);
template<typename K, typename V>
static std::map<V, K> reverse_map(const std::map<K, V>& map)
{
std::map<V, K> reversed_map;
for(const std::pair<K, V>& entry : map)
{
reversed_map[entry.second] = entry.first;
}
return reversed_map;
}
typedef std::map< std::string, int > FwdLedHeaders;
typedef std::map< int, std::string > RvrseLedHeaders;
struct LedPort
{
std::string name;
int header;
int count;
};
typedef std::map< std::string, std::string > MBName;
typedef std::map< std::string, std::vector<LedPort> > ZoneLeds;
typedef std::map< std::string, ZoneLeds> KnownLayout;
class RGBController_RGBFusion2USB: public RGBController
{
public:
RGBController_RGBFusion2USB(RGBFusion2USBController* controller_ptr, std::string _detector_name);
~RGBController_RGBFusion2USB();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void DeviceUpdateMode();
private:
MBName MBName2Layout;
bool custom_layout;
std::string detector_name;
RGBFusion2USBController* controller;
IT8297Report report;
ZoneLeds layout;
void Load_Device_Config();
void Init_Controller();
int GetLED_Zone(int led_idx);
};