Compare commits

..
234 changed files with 942 additions and 3800 deletions
-2
View File
@@ -4,8 +4,6 @@ ui_*
moc_*
qrc_*
OpenRGB
openrgb
Makefile
OpenRGB-x86_64.AppImage
.qmake.stash
.vscode
+6 -58
View File
@@ -20,90 +20,38 @@ stages:
before_script:
- echo "started by ${GITLAB_USER_NAME}"
#reusable templates
.ccache_init: &ccache_init
before_script:
- apt update
- apt install -y build-essential qtcreator qt5-default libusb-1.0-0-dev libhidapi-dev pkgconf wget git
#-----------------------------------------------------------------------#
# Linux (AppImage) 32-bit Build Target #
#-----------------------------------------------------------------------#
build_linux_32:
<<: *ccache_init
image: i386/ubuntu:bionic
stage: build
script:
- export $(dpkg-architecture)
- ./scripts/build-appimage.sh
- apt update
- apt install -y build-essential qtcreator qt5-default libusb-1.0-0-dev libhidapi-dev pkgconf wget git
- ./scripts/build-appimage-32.sh
artifacts:
paths:
- OpenRGB-i386.AppImage
- 60-openrgb.rules
- README.md
expire_in: 30 days
#-----------------------------------------------------------------------#
# Linux (AppImage) 64-bit Build Target #
#-----------------------------------------------------------------------#
build_linux_64:
<<: *ccache_init
image: ubuntu:bionic
stage: build
script:
- export $(dpkg-architecture)
- apt update
- apt install -y build-essential qtcreator qt5-default libusb-1.0-0-dev libhidapi-dev pkgconf wget git
- ./scripts/build-appimage.sh
artifacts:
paths:
- OpenRGB-x86_64.AppImage
- 60-openrgb.rules
- README.md
expire_in: 30 days
#-----------------------------------------------------------------------#
# Linux (.deb) 32-bit Build Target #
#-----------------------------------------------------------------------#
build_linux_deb32:
<<: *ccache_init
image: i386/ubuntu:bionic
stage: build
script:
- apt install -y debhelper
- dpkg-architecture -l
- dpkg-buildpackage --target-arch i386 -us -B
- rm -v ../openrgb-dbgsym*.ddeb
- mv -v ../openrgb*.deb ./
artifacts:
paths:
- openrgb*.deb
exclude:
- openrgb-dbgsym*.deb
expire_in: 30 days
#-----------------------------------------------------------------------#
# Linux (.deb) 64-bit Build Target #
#-----------------------------------------------------------------------#
build_linux_deb64:
<<: *ccache_init
image: ubuntu:bionic
stage: build
script:
- apt install -y debhelper
- dpkg-architecture -l
- dpkg-buildpackage -us -B
- rm -v ../openrgb-dbgsym*.ddeb
- mv -v ../openrgb*.deb ./
artifacts:
paths:
- openrgb*.deb
exclude:
- openrgb-dbgsym*.deb
expire_in: 30 days
#-----------------------------------------------------------------------#
# Windows (32-bit) Build Target #
#-----------------------------------------------------------------------#
+1 -1
View File
@@ -4,7 +4,7 @@ Found a bug? Something isn't working as expected? To help us keep track of the
### Description of Bug
<!--
Please describe the bug. Explain steps taken to reproduce the bug and what you expect the correct behavior to be.
Please describe the bug. Explain steps taken to reproduct the bug and what you expect the correct behavior to be.
-->
+2 -4
View File
@@ -17,9 +17,7 @@ Please link us to the manufacturer's product page beneath this line
### Please select what type of device/interface the device uses:
<!--
Place an x between the brackets to check the box
-->
- [ ] Motherboard (SMBus)
- [ ] Motherboard (USB)
- [ ] RAM (SMBus)
@@ -31,7 +29,7 @@ Place an x between the brackets to check the box
### ID information:
<!--
For PCI (GPU) devices we will need the Vendor ID, Device ID, Sub-Vendor ID and Sub-Device IDs
In Windows this can be found under the device manager and on Linux this can be found with lspci -vv
In Windows this can be found under the device manager and on Linux this can be found wit lspci -vv
For USB devices we will need the USB VID and PID
-->
-5
View File
@@ -239,11 +239,6 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="1462", ATTR{idProduct}=="905D", TAG+="uacces
#---------------------------------------------------------------#
SUBSYSTEMS=="usb", ATTR{idVendor}=="1770", ATTR{idProduct}=="FF00", TAG+="uaccess"
#---------------------------------------------------------------#
# NZXT Hue+ #
#---------------------------------------------------------------#
KERNEL=="ttyACM[0-9]*", ATTR{idVendor}=="04D8", ATTR{idProduct}=="00DF", TAG+="uaccess"
#---------------------------------------------------------------#
# NZXT Hue 2 Devices #
# #
@@ -41,7 +41,7 @@ AMDWraithPrismController::~AMDWraithPrismController()
std::string AMDWraithPrismController::GetLocationString()
{
return("HID: " + location);
return(location);
}
char* AMDWraithPrismController::GetDeviceName()
@@ -49,17 +49,6 @@ char* AMDWraithPrismController::GetDeviceName()
return device_name;
}
std::string AMDWraithPrismController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
std::string AMDWraithPrismController::GetEffectChannelString(unsigned char channel)
{
std::string ret_string = "";
@@ -117,7 +117,6 @@ public:
std::string GetEffectChannelString(unsigned char channel);
std::string GetFirmwareVersionString();
std::string GetLocationString();
std::string GetSerialString();
void SetRingEffectChannel(unsigned char channel);
@@ -14,16 +14,10 @@ RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismControl
wraith = wraith_ptr;
name = "AMD Wraith Prism";
vendor = "Cooler Master";
type = DEVICE_TYPE_COOLER;
description = "AMD Wraith Prism Device";
version = wraith->GetFirmwareVersionString();
location = wraith->GetLocationString();
/*-----------------------------------------------------*\
| Don't use HID serial string, it is inconsistent on my |
| Wraith Prism |
\*-----------------------------------------------------*/
serial = "";//wraith->GetSerialString();
mode Direct;
Direct.name = "Direct";
@@ -9,7 +9,6 @@
#include "ASRockPolychromeSMBusController.h"
#include <cstring>
#include "dependencies/dmiinfo.h"
using namespace std::chrono_literals;
@@ -18,8 +17,6 @@ PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_
this->bus = bus;
this->dev = dev;
DMIInfo dmi;
unsigned short fw_version = ReadFirmwareVersion();
unsigned char major_version = fw_version >> 8;
@@ -32,19 +29,19 @@ PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_
switch(major_version)
{
case ASROCK_TYPE_ASRLED:
device_name = "ASRock " + dmi.getMainboard();
device_name = "ASRock ASR LED";
asrock_type = ASROCK_TYPE_ASRLED;
memset(zone_led_count, 0, sizeof(zone_led_count));
break;
case ASROCK_TYPE_POLYCHROME_V1:
device_name = "ASRock " + dmi.getMainboard();
device_name = "ASRock Polychrome V1";
asrock_type = ASROCK_TYPE_POLYCHROME_V1;
ReadLEDConfiguration();
break;
case ASROCK_TYPE_POLYCHROME_V2:
device_name = "ASRock " + dmi.getMainboard();
device_name = "ASRock Polychrome V2";
asrock_type = ASROCK_TYPE_POLYCHROME_V2;
ReadLEDConfiguration();
break;
@@ -37,17 +37,15 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
polychrome = polychrome_ptr;
name = polychrome->GetDeviceName();
vendor = "ASRock";
version = polychrome->GetFirmwareVersion();
type = DEVICE_TYPE_MOTHERBOARD;
description = "ASRock ASR LED/Polychrome Device";
location = polychrome->GetDeviceLocation();
switch(polychrome->GetASRockType())
{
case ASROCK_TYPE_ASRLED:
{
description = "ASRock ASR LED Device";
mode Off;
Off.name = "Off";
Off.value = ASRLED_MODE_OFF;
@@ -123,8 +121,6 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
case ASROCK_TYPE_POLYCHROME_V1:
{
description = "ASRock Polychrome v1 Device";
mode Off;
Off.name = "Off";
Off.value = POLYCHROME_V1_MODE_OFF;
@@ -273,8 +269,6 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
case ASROCK_TYPE_POLYCHROME_V2:
{
description = "ASRock Polychrome v2 Device";
mode Off;
Off.name = "Off";
Off.value = POLYCHROME_V2_MODE_OFF;
@@ -10,10 +10,9 @@
#include "AsusAuraCoreController.h"
#include <cstring>
AuraCoreController::AuraCoreController(hid_device* dev_handle, const char* path)
AuraCoreController::AuraCoreController(hid_device* dev_handle)
{
dev = dev_handle;
location = path;
dev = dev_handle;
}
AuraCoreController::~AuraCoreController()
@@ -21,22 +20,6 @@ AuraCoreController::~AuraCoreController()
}
std::string AuraCoreController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string AuraCoreController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
void AuraCoreController::SendBrightness
(
unsigned char brightness
@@ -48,12 +48,9 @@ enum
class AuraCoreController
{
public:
AuraCoreController(hid_device* dev_handle, const char* path);
AuraCoreController(hid_device* dev_handle);
~AuraCoreController();
std::string GetDeviceLocation();
std::string GetSerialString();
void SendBrightness
(
unsigned char brightness
@@ -75,6 +72,5 @@ public:
private:
hid_device* dev;
std::string location;
};
@@ -19,7 +19,7 @@ void DetectAsusAuraCoreControllers(hid_device_info* info, const std::string&)
hid_device* dev = hid_open_path(info->path);
if( dev )
{
AuraCoreController* controller = new AuraCoreController(dev, info->path);
AuraCoreController* controller = new AuraCoreController(dev);
RGBController_AuraCore* rgb_controller = new RGBController_AuraCore(controller);
// Constructor sets the name
ResourceManager::get()->RegisterRGBController(rgb_controller);
@@ -13,11 +13,8 @@ RGBController_AuraCore::RGBController_AuraCore(AuraCoreController* aura_ptr)
aura = aura_ptr;
name = "ASUS Aura Core";
vendor = "ASUS";
type = DEVICE_TYPE_KEYBOARD;
description = "ASUS Aura Core Device";
location = aura->GetDeviceLocation();
serial = aura->GetSerialString();
mode Static;
Static.name = "Static";
@@ -47,7 +47,6 @@ RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * aura_gpu_ptr)
name = aura_gpu->GetDeviceName();
vendor = "ASUS";
type = DEVICE_TYPE_GPU;
description = "ASUS Aura GPU Device";
version = "0.00.1";
@@ -129,7 +129,6 @@ RGBController_AuraSMBus::RGBController_AuraSMBus(AuraSMBusController * aura_ptr)
type = DEVICE_TYPE_MOTHERBOARD;
name = "ASUS Aura Motherboard";
}
vendor = "ASUS";
description = "ASUS Aura SMBus Device";
mode Direct;
@@ -24,18 +24,7 @@ AuraMouseController::~AuraMouseController()
std::string AuraMouseController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string AuraMouseController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(location);
}
void AuraMouseController::SendUpdate
@@ -38,7 +38,6 @@ public:
virtual ~AuraMouseController();
std::string GetDeviceLocation();
std::string GetSerialString();
void SendUpdate
(
@@ -32,7 +32,7 @@ unsigned int AuraUSBController::GetChannelCount()
std::string AuraUSBController::GetDeviceLocation()
{
return("HID: " + location);
return(location);
}
std::string AuraUSBController::GetDeviceName()
@@ -40,17 +40,6 @@ std::string AuraUSBController::GetDeviceName()
return(device_name);
}
std::string AuraUSBController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
const std::vector<AuraDeviceInfo>& AuraUSBController::GetAuraDevices() const
{
return(device_info);
@@ -66,7 +66,6 @@ public:
std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString();
const std::vector<AuraDeviceInfo>& GetAuraDevices() const;
@@ -14,11 +14,9 @@ RGBController_AuraMouse::RGBController_AuraMouse(AuraMouseController* aura_ptr)
aura = aura_ptr;
name = "ASUS Aura Mouse";
vendor = "ASUS";
type = DEVICE_TYPE_MOUSE;
description = "ASUS Aura Mouse Device";
location = aura->GetDeviceLocation();
serial = aura->GetSerialString();
mode Direct;
Direct.name = "Direct";
@@ -9,18 +9,15 @@
#include "RGBController_AsusAuraUSB.h"
RGBController_AuraUSB::RGBController_AuraUSB(AuraUSBController* aura_ptr) :
initializedMode(false)
RGBController_AuraUSB::RGBController_AuraUSB(AuraUSBController* aura_ptr)
{
aura = aura_ptr;
name = "ASUS Aura USB";
vendor = "ASUS";
version = aura->GetDeviceName();
type = DEVICE_TYPE_MOTHERBOARD;
description = "ASUS Aura USB Device";
location = aura->GetDeviceLocation();
serial = aura->GetSerialString();
mode Direct;
Direct.name = "Direct";
@@ -194,10 +191,6 @@ void RGBController_AuraUSB::ResizeZone(int zone, int new_size)
void RGBController_AuraUSB::DeviceUpdateLEDs()
{
if(!initializedMode)
{
DeviceUpdateMode();
}
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
aura->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
@@ -206,19 +199,11 @@ void RGBController_AuraUSB::DeviceUpdateLEDs()
void RGBController_AuraUSB::UpdateZoneLEDs(int zone)
{
if(!initializedMode)
{
DeviceUpdateMode();
}
aura->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count);
}
void RGBController_AuraUSB::UpdateSingleLED(int led)
{
if(!initializedMode)
{
DeviceUpdateMode();
}
unsigned int channel = leds[led].value;
aura->SetChannelLEDs(channel, zones[channel].colors, zones[channel].leds_count);
@@ -231,7 +216,6 @@ void RGBController_AuraUSB::SetCustomMode()
void RGBController_AuraUSB::DeviceUpdateMode()
{
initializedMode = true;
unsigned char red = 0;
unsigned char grn = 0;
unsigned char blu = 0;
@@ -31,8 +31,7 @@ public:
void DeviceUpdateMode();
private:
AuraUSBController* aura;
AuraUSBController* aura;
std::vector<unsigned int> leds_channel;
std::vector<unsigned int> zones_channel;
bool initializedMode;
};
@@ -1,48 +0,0 @@
#ifdef _WIN32
#include "RGBController_AsusTUFLaptopWMI.h"
#include "acpiwmi.h"
#include "Detector.h"
#include "wmi.h"
#include <string>
static void DetectAsusTUFLaptopWMIControllers(std::vector<RGBController*>&)
{
// Try to retrieve ProductID / Device name from WMI; Possibly can be rewritten to use wmi.cpp
// IF you encounter false detection ( e.g. if your laptop keyboard backlight uses USB interface
// instead of ACPI WMI) please add a WHITELIST by checking the
// `name` variable for model substrings like "FX505DU"
// For now, checking for "TUF Gaming" should suffice
Wmi wmi;
wmi.init();
std::vector<QueryObj> systemProduct;
if (wmi.query("SELECT * FROM Win32_ComputerSystemProduct", systemProduct))
{
return;
}
// There should only be one, a cycle is a precaution
if(systemProduct.size() != 1)
{
return;
}
std::string& name = systemProduct[0]["Name"];
if(name.find("TUF Gaming") == name.npos)
{
return;
}
if(AsWMI_Open())
{
RGBController* new_controller = new RGBController_AsusTUFLaptopWMI();
ResourceManager::get()->RegisterRGBController(new_controller);
// Success! No more if's
}
} /* DetectFaustusControllers() */
REGISTER_DETECTOR("TUF Laptop WMI", DetectAsusTUFLaptopWMIControllers);
#endif
@@ -1,143 +0,0 @@
#ifdef _WIN32
#include "RGBController_AsusTUFLaptopWMI.h"
#include "acpiwmi.h"
#include "ResourceManager.h"
#include "Detector.h"
#include "wmi.h"
#include <string>
using namespace std::chrono_literals;
RGBController_AsusTUFLaptopWMI::RGBController_AsusTUFLaptopWMI()
{
name = "ASUS TUF Keyboard";
vendor = "ASUS";
type = DEVICE_TYPE_KEYBOARD;
description = "WMI Device";
location = "\\\\.\\ATKACPI";
modes.resize(5);
modes[0].name = "Direct";
modes[0].value = 4;
modes[0].flags = MODE_FLAG_HAS_PER_LED_COLOR;
modes[0].color_mode = MODE_COLORS_PER_LED;
modes[1].name = "Static";
modes[1].value = 0;
modes[1].flags = MODE_FLAG_HAS_PER_LED_COLOR;
modes[1].color_mode = MODE_COLORS_PER_LED;
modes[2].name = "Breathing";
modes[2].value = 1;
modes[2].flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
modes[2].speed_min = 0;
modes[2].speed_max = 2;
modes[2].color_mode = MODE_COLORS_PER_LED;
modes[2].speed = 1;
modes[3].name = "Color Cycle";
modes[3].value = 2;
modes[3].flags = MODE_FLAG_HAS_SPEED;
modes[3].speed_min = 0;
modes[3].speed_max = 2;
modes[3].color_mode = MODE_COLORS_NONE;
modes[3].speed = 1;
modes[4].name = "Strobe";
modes[4].value = 0x0A;
modes[4].flags = MODE_FLAG_HAS_PER_LED_COLOR;
modes[4].color_mode = MODE_COLORS_PER_LED;
SetupZones();
}
RGBController_AsusTUFLaptopWMI::~RGBController_AsusTUFLaptopWMI()
{
AsWMI_Close();
}
void RGBController_AsusTUFLaptopWMI::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zone |
\*---------------------------------------------------------*/
zones.resize(1);
zones[0].type = ZONE_TYPE_SINGLE;
zones[0].name = "Keyboard Backlight zone";
zones[0].leds_min = 1;
zones[0].leds_max = 1;
zones[0].leds_count = 1;
zones[0].matrix_map = NULL;
/*---------------------------------------------------------*\
| Set up LED |
\*---------------------------------------------------------*/
leds.resize(1);
leds[0].name = "Keyboard Backlight LED";
SetupColors();
}
void RGBController_AsusTUFLaptopWMI::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AsusTUFLaptopWMI::DeviceUpdateLEDs()
{
uint8_t red = RGBGetRValue(colors[0]);
uint8_t green = RGBGetGValue(colors[0]);
uint8_t blue = RGBGetBValue(colors[0]);
uint8_t speed_byte = 0;
uint8_t mode = modes[active_mode].value;
uint8_t inv = 0;
if(mode == 4)
{
mode = 1;
inv = 4; // Any invalid mode, i.e. anything other than 0, 1, 2 and 10
}
if(mode == 1 || mode == 2)
{
switch(modes[active_mode].speed)
{
case 0: speed_byte = 0xE1; break;
case 1: speed_byte = 0xEB; break;
case 2: speed_byte = 0xF5; break;
}
}
int high = ((mode | ((red | (green << 8)) << 8)) << 8) | 0xB3;
int low = blue | (speed_byte << 8);
AsWMI_NB_DeviceControl_2arg(0x100056, high, low);
if(inv)
{
//std::this_thread::sleep_for(10ms);
high = ((inv | ((red | (green << 8)) << 8)) << 8) | 0xB3;
AsWMI_NB_DeviceControl_2arg(0x100056, high, low);
}
}
void RGBController_AsusTUFLaptopWMI::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AsusTUFLaptopWMI::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_AsusTUFLaptopWMI::SetCustomMode()
{
SetMode(0);
}
void RGBController_AsusTUFLaptopWMI::DeviceUpdateMode()
{
DeviceUpdateLEDs();
}
#endif
@@ -1,29 +0,0 @@
#ifndef RGBCONTROLLER_ASUSTUFLAPTOPWMI_H
#define RGBCONTROLLER_ASUSTUFLAPTOPWMI_H
#ifdef _WIN32
#include "RGBController.h"
class RGBController_AsusTUFLaptopWMI : public RGBController
{
public:
RGBController_AsusTUFLaptopWMI();
virtual ~RGBController_AsusTUFLaptopWMI();
void SetupZones() override;
void ResizeZone(int zone, int new_size) override;
void DeviceUpdateLEDs() override;
void UpdateZoneLEDs(int zone) override;
void UpdateSingleLED(int led) override;
void DeviceUpdateMode() override;
void SetCustomMode() override;
};
#endif
#endif // RGBCONTROLLER_ASUSTUFLAPTOPWMI_H
@@ -92,7 +92,7 @@ std::string CMARGBController::GetSerial()
std::string CMARGBController::GetLocation()
{
return("HID: " + location);
return location;
}
unsigned char CMARGBController::GetZoneIndex()
@@ -99,7 +99,7 @@ std::string CMMP750Controller::GetSerial()
std::string CMMP750Controller::GetLocation()
{
return("HID: " + location);
return location;
}
unsigned char CMMP750Controller::GetMode()
@@ -15,7 +15,6 @@ RGBController_CMARGBController::RGBController_CMARGBController(CMARGBController
unsigned char speed = cmargb->GetLedSpeed();
name = argb_header_data[cmargb->GetZoneIndex()].name;
vendor = "Cooler Master";
type = DEVICE_TYPE_LEDSTRIP;
description = cmargb->GetDeviceName();
version = "1.0";
@@ -15,7 +15,6 @@ RGBController_CMMP750Controller::RGBController_CMMP750Controller(CMMP750Controll
unsigned char speed = cmmp750->GetLedSpeed();
name = cmmp750->GetDeviceName();
vendor = "Cooler Master";
type = DEVICE_TYPE_MOUSEMAT;
description = cmmp750->GetDeviceName();
version = "1.0";
@@ -13,7 +13,6 @@ RGBController_CorsairDominatorPlatinum::RGBController_CorsairDominatorPlatinum(C
corsair = corsair_ptr;
name = corsair->GetDeviceName();
vendor = "Corsair";
type = DEVICE_TYPE_DRAM;
description = "Corsair Dominator Platinum RGB Device";
location = corsair->GetDeviceLocation();
@@ -7,22 +7,10 @@
#include "CorsairHydroController.h"
#include <cstring>
#include <iomanip>
#include <sstream>
CorsairHydroController::CorsairHydroController(libusb_device_handle* dev_handle)
{
dev = dev_handle;
/*-----------------------------------------------------*\
| Fill in location string with USB ID |
\*-----------------------------------------------------*/
libusb_device_descriptor descriptor;
libusb_get_device_descriptor(libusb_get_device(dev_handle), &descriptor);
std::stringstream location_stream;
location_stream << std::hex << std::setfill('0') << std::setw(4) << descriptor.idVendor << ":" << std::hex << std::setfill('0') << std::setw(4) << descriptor.idProduct;
location = location_stream.str();
dev = dev_handle;
SendInit();
@@ -34,11 +22,6 @@ std::string CorsairHydroController::GetFirmwareString()
return(firmware_version);
}
std::string CorsairHydroController::GetLocation()
{
return("USB: " + location);
}
void CorsairHydroController::SetBlink
(
std::vector<RGBColor> & colors,
@@ -265,4 +248,4 @@ void CorsairHydroController::SendSpeed
\*-----------------------------------------------------*/
libusb_bulk_transfer(dev, 0x01, usb_buf, 2, &actual, 1000);
libusb_bulk_transfer(dev, 0x81, usb_buf, 3, &actual, 1000);
}
}
@@ -39,8 +39,6 @@ public:
std::string GetFirmwareString();
std::string GetLocation();
void SetBlink
(
std::vector<RGBColor> & colors,
@@ -67,7 +65,6 @@ public:
private:
libusb_device_handle* dev;
std::string firmware_version;
std::string location;
void SendApplyBlink();
void SendApplyPulse();
@@ -50,10 +50,6 @@ void DetectCorsairHydroControllers(std::vector<RGBController*>& rgb_controllers)
libusb_context * ctx;
libusb_init(&ctx);
#ifdef _WIN32
libusb_set_option(ctx, LIBUSB_OPTION_USE_USBDK);
#endif
for(std::size_t device_idx = 0; device_idx < CORSAIR_NUM_DEVICES; device_idx++)
{
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
@@ -13,11 +13,9 @@ RGBController_CorsairHydro::RGBController_CorsairHydro(CorsairHydroController* c
{
corsair = corsair_ptr;
vendor = "Corsair";
description = "Corsair Hydro Series Device";
version = corsair->GetFirmwareString();
type = DEVICE_TYPE_COOLER;
location = corsair->GetLocation();
mode Direct;
Direct.name = "Direct";
@@ -56,18 +56,7 @@ std::string CorsairLightingNodeController::GetFirmwareString()
std::string CorsairLightingNodeController::GetLocationString()
{
return("HID: " + location);
}
std::string CorsairLightingNodeController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(location);
}
void CorsairLightingNodeController::SetChannelEffect(unsigned char channel,
@@ -84,7 +84,6 @@ public:
std::string GetFirmwareString();
std::string GetLocationString();
std::string GetSerialString();
unsigned int GetStripsOnChannel(unsigned int channel);
@@ -15,12 +15,10 @@ RGBController_CorsairLightingNode::RGBController_CorsairLightingNode(CorsairLigh
corsair = corsair_ptr;
name = "Corsair Lighting Node Device";
vendor = "Corsair";
description = "Corsair Lighting Node Device";
type = DEVICE_TYPE_LEDSTRIP;
version = corsair->GetFirmwareString();
location = corsair->GetLocationString();
serial = corsair->GetSerialString();
mode Direct;
Direct.name = "Direct";
@@ -73,7 +73,7 @@ device_type CorsairPeripheralController::GetDeviceType()
std::string CorsairPeripheralController::GetDeviceLocation()
{
return("HID: " + location);
return(location);
}
int CorsairPeripheralController::GetPhysicalLayout()
@@ -91,22 +91,6 @@ std::string CorsairPeripheralController::GetFirmwareString()
return firmware_version;
}
std::string CorsairPeripheralController::GetName()
{
return name;
}
std::string CorsairPeripheralController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
}
void CorsairPeripheralController::SetLEDs(std::vector<RGBColor>colors)
{
switch(type)
@@ -286,11 +270,6 @@ void CorsairPeripheralController::SetLEDsKeyboardLimited(std::vector<RGBColor> c
SubmitKeyboardLimitedColors(216);
}
void CorsairPeripheralController::SetName(std::string device_name)
{
name = device_name;
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
@@ -74,22 +74,18 @@ public:
device_type GetDeviceType();
std::string GetDeviceLocation();
std::string GetFirmwareString();
std::string GetName();
std::string GetSerialString();
void SetLEDs(std::vector<RGBColor> colors);
void SetLEDsKeyboardFull(std::vector<RGBColor> colors);
void SetLEDsKeyboardLimited(std::vector<RGBColor> colors);
void SetLEDsMouse(std::vector<RGBColor> colors);
void SetLEDsMousemat(std::vector<RGBColor> colors);
void SetName(std::string device_name);
private:
hid_device* dev;
std::string firmware_version;
std::string location;
std::string name;
device_type type;
int physical_layout; //ANSI, ISO, etc.
int logical_layout; //Normal, K95 or K95 Platinum
@@ -73,11 +73,10 @@ void DetectCorsairPeripheralControllers(hid_device_info* info, const std::string
if( dev )
{
CorsairPeripheralController* controller = new CorsairPeripheralController(dev, info->path);
controller->SetName(name);
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
{
RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
else
@@ -115,20 +114,11 @@ REGISTER_HID_DETECTOR_IP("Corsair M65 PRO", DetectCorsairPeriph
REGISTER_HID_DETECTOR_IP("Corsair M65 RGB Elite" , DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_M65_RGB_ELITE_PID, 1, 0xFFC2);
REGISTER_HID_DETECTOR_IP("Corsair Scimitar PRO RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_SCIMITAR_PRO_RGB_PID, 1, 0xFFC2);
REGISTER_HID_DETECTOR_IP("Corsair Sabre RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_SABRE_RGB_PID, 1, 0xFFC2);
/*-----------------------------------------------------------------------------------------------------*\
| Mousemats |
\*-----------------------------------------------------------------------------------------------------*/
#ifdef USE_HID_USAGE
REGISTER_HID_DETECTOR_P("Corsair MM800 RGB Polaris", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_MM800_RGB_POLARIS_PID, 0xFFC2);
#else
REGISTER_HID_DETECTOR_I("Corsair MM800 RGB Polaris", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_MM800_RGB_POLARIS_PID, 0);
#endif
REGISTER_HID_DETECTOR_IP("Corsair MM800 RGB Polaris", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_MM800_RGB_POLARIS_PID, 0, 0xFFC2);
/*-----------------------------------------------------------------------------------------------------*\
| Headset Stands |
\*-----------------------------------------------------------------------------------------------------*/
#ifdef USE_HID_USAGE
REGISTER_HID_DETECTOR_P("Corsair ST100 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_ST100_PID, 0xFFC2);
#else
REGISTER_HID_DETECTOR_I("Corsair ST100 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_ST100_PID, 0);
#endif
REGISTER_HID_DETECTOR_IP("Corsair ST100 RGB", DetectCorsairPeripheralControllers, CORSAIR_VID, CORSAIR_ST100_PID, 0, 0xFFC2);
@@ -513,25 +513,6 @@ static const char* corsair_mouse_leds[] =
"Mouse LED 15",
};
static const char* corsair_m65_elite_leds[] =
{
"",
"",
"Logo",
"DPI",
"Scroll Wheel",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
};
static const char* corsair_sabre_rgb_leds[] =
{
"",
@@ -574,13 +555,11 @@ RGBController_CorsairPeripheral::RGBController_CorsairPeripheral(CorsairPeripher
{
corsair = corsair_ptr;
name = corsair->GetName();
vendor = "Corsair";
name = "Corsair RGB Peripheral Device";
description = "Corsair RGB Peripheral Device";
type = corsair->GetDeviceType();
version = corsair->GetFirmwareString();
location = corsair->GetDeviceLocation();
serial = corsair->GetSerialString();
physical_layout = corsair->GetPhysicalLayout();
logical_layout = corsair->GetLogicalLayout();
@@ -778,22 +757,7 @@ void RGBController_CorsairPeripheral::SetupZones()
break;
case DEVICE_TYPE_MOUSE:
if(name == "Corsair M65 RGB Elite")
{
new_led.name = corsair_m65_elite_leds[led_idx];
}
else if(name == "Corsair Harpoon RGB PRO")
{
new_led.name = corsair_harpoon_pro_leds[led_idx];
}
else if(name == "Corsair Sabre RGB")
{
new_led.name = corsair_sabre_rgb_leds[led_idx];
}
else
{
new_led.name = corsair_mouse_leds[led_idx];
}
new_led.name = corsair_mouse_leds[led_idx];
break;
case DEVICE_TYPE_MOUSEMAT:
@@ -14,7 +14,6 @@ RGBController_CorsairVengeance::RGBController_CorsairVengeance(CorsairVengeanceC
corsair = corsair_ptr;
name = corsair->GetDeviceName();
vendor = "Corsair";
type = DEVICE_TYPE_DRAM;
description = "Corsair Vengeance RGB Device";
location = corsair->GetDeviceLocation();
@@ -14,7 +14,6 @@ RGBController_CorsairVengeancePro::RGBController_CorsairVengeancePro(CorsairVeng
corsair = corsair_ptr;
name = corsair->GetDeviceName();
vendor = "Corsair";
type = DEVICE_TYPE_DRAM;
description = "Corsair Vengeance Pro RGB Device";
location = corsair->GetDeviceLocation();
@@ -14,7 +14,6 @@ RGBController_Crucial::RGBController_Crucial(CrucialController * crucial_ptr)
crucial = crucial_ptr;
name = "Crucial DRAM";
vendor = "Crucial";
type = DEVICE_TYPE_DRAM;
description = "Crucial DRAM Device";
location = crucial->GetDeviceLocation();
@@ -1,6 +1,5 @@
#include "Detector.h"
#include "RGBController.h"
#include "RGBController_Debug.h"
#include "RGBController_Dummy.h"
#include "SettingsManager.h"
#include <vector>
@@ -162,7 +161,7 @@ static const char *led_names[] =
* *
* DetectDebugControllers *
* *
* Add dummy controllers based on the DebugDevices key in the settings json *
* Add dummy controllers based on debug.txt *
* *
\******************************************************************************************/
@@ -173,7 +172,7 @@ void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
/*-------------------------------------------------*\
| Get Debug Device settings from settings manager |
\*-------------------------------------------------*/
debug_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("DebugDevices");
debug_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Setting_DebugDevices");
/*-------------------------------------------------*\
| If the Debug settings contains devices, process |
@@ -488,54 +487,6 @@ void DetectDebugControllers(std::vector<RGBController*> &rgb_controllers)
\*---------------------------------------------------------*/
rgb_controllers.push_back(dummy_keyboard);
}
else if(type == "argb")
{
/*---------------------------------------------------------*\
| Create a dummy ARGB |
\*---------------------------------------------------------*/
RGBController_Debug* dummy_argb = new RGBController_Debug();
dummy_argb->name = "Debug ARGB";
dummy_argb->type = DEVICE_TYPE_LEDSTRIP;
dummy_argb->description = "Debug ARGB Device";
dummy_argb->location = "Debug ARGB Location";
dummy_argb->version = "Debug ARGB Version";
dummy_argb->serial = "Debug ARGB Serial";
/*---------------------------------------------------------*\
| Create a direct mode for the dummy ARGB |
\*---------------------------------------------------------*/
mode dummy_argb_direct_mode;
dummy_argb_direct_mode.name = "Direct";
dummy_argb_direct_mode.value = 0;
dummy_argb_direct_mode.flags = MODE_FLAG_HAS_PER_LED_COLOR;
dummy_argb_direct_mode.color_mode = MODE_COLORS_PER_LED;
dummy_argb->modes.push_back(dummy_argb_direct_mode);
/*---------------------------------------------------------*\
| Create a linear zone for the dummy ARGB |
\*---------------------------------------------------------*/
zone dummy_argb_linear_zone;
dummy_argb_linear_zone.name = "Resizable zone";
dummy_argb_linear_zone.type = ZONE_TYPE_LINEAR;
dummy_argb_linear_zone.leds_min = 1;
dummy_argb_linear_zone.leds_max = 100;
dummy_argb_linear_zone.leds_count = 0;
dummy_argb_linear_zone.matrix_map = NULL;
dummy_argb->zones.push_back(dummy_argb_linear_zone);
dummy_argb->SetupColors();
dummy_argb->ResizeZone(0, 60);
/*---------------------------------------------------------*\
| Push the dummy ARGB onto the controller list |
\*---------------------------------------------------------*/
rgb_controllers.push_back(dummy_argb);
}
}
}
@@ -1,49 +0,0 @@
#include "RGBController_Debug.h"
#include <algorithm>
#include <cstring>
RGBController_Debug::RGBController_Debug()
{
}
void RGBController_Debug::ResizeZone(int index, int new_size)
{
//Make sure that it isn't out of bounds (negative numbers)
if(new_size < int(zones[index].leds_min))
{
new_size = zones[index].leds_min;
}
// Same thing as the above line except for over 100
if(new_size > int(zones[index].leds_max))
{
new_size = zones[index].leds_max;
}
// Store the previous amount of LEDs
int old_size = zones[index].leds_count;
// Set the LED count in the zone to the new ammount
zones[index].leds_count = new_size;
// Set the new ammount of LEDs for to the new size
size_t old_leds_size = leds.size();
// Add the new ammount of LEDs to the old ammount
size_t new_leds_size = leds.size() - old_size + new_size;
leds.resize(std::max(old_leds_size, new_leds_size));
memmove(&leds[zones[index].start_idx] + old_leds_size, &leds[zones[index].start_idx] + new_leds_size, (old_leds_size - zones[index].start_idx - old_size) * sizeof(led));
leds.resize(new_leds_size);
for(int i = 0; i < new_size; ++i)
{
leds[zones[index].start_idx + i].name = "Linear LED " + std::to_string(i);
}
SetupColors();
}
@@ -1,15 +0,0 @@
#ifndef RGBCONTROLLER_DEBUG_H
#define RGBCONTROLLER_DEBUG_H
#include "RGBController_Dummy.h"
// A variation of Dummy controller that allows the zones to be resized
class RGBController_Debug : public RGBController_Dummy
{
public:
RGBController_Debug();
void ResizeZone(int zone, int newSize) override;
};
#endif // RGBCONTROLLER_DEBUG_H
@@ -25,18 +25,7 @@ DuckyKeyboardController::~DuckyKeyboardController()
std::string DuckyKeyboardController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string DuckyKeyboardController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(location);
}
void DuckyKeyboardController::SendColors
@@ -21,7 +21,6 @@ public:
~DuckyKeyboardController();
std::string GetDeviceLocation();
std::string GetSerialString();
void SendColors
(
@@ -176,11 +176,9 @@ RGBController_DuckyKeyboard::RGBController_DuckyKeyboard(DuckyKeyboardController
ducky = ducky_ptr;
name = "Ducky Keyboard Device";
vendor = "Ducky";
type = DEVICE_TYPE_KEYBOARD;
description = "Ducky Keyboard Device";
location = ducky->GetDeviceLocation();
serial = ducky->GetSerialString();
mode Direct;
Direct.name = "Direct";
@@ -30,7 +30,7 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
/*-------------------------------------------------*\
| Get E1.31 settings from settings manager |
\*-------------------------------------------------*/
e131_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("E131Devices");
e131_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Setting_E131Devices");
/*-------------------------------------------------*\
| If the E1.31 settings contains devices, process |
@@ -43,7 +43,6 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
| Clear E1.31 device data |
\*-------------------------------------------------*/
dev.name = "";
dev.ip = "";
dev.type = ZONE_TYPE_SINGLE;
dev.num_leds = 0;
dev.rgb_order = E131_RGB_ORDER_RBG;
@@ -58,11 +57,6 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
dev.name = e131_settings["devices"][device_idx]["name"];
}
if(e131_settings["devices"][device_idx].contains("ip"))
{
dev.ip = e131_settings["devices"][device_idx]["ip"];
}
if(e131_settings["devices"][device_idx].contains("num_leds"))
{
dev.num_leds = e131_settings["devices"][device_idx]["num_leds"];
@@ -194,70 +188,40 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
\*---------------------------------------------------------*/
bool device_added_to_existing_list = false;
/*---------------------------------------------------------*\
| Only track grouping for multicast controllers. Unicast |
| controllers are currently not grouped. |
\*---------------------------------------------------------*/
if(dev.ip == "")
for(unsigned int list_idx = 0; list_idx < device_lists.size(); list_idx++)
{
for(unsigned int list_idx = 0; list_idx < device_lists.size(); list_idx++)
for(unsigned int device_idx = 0; device_idx < device_lists[list_idx].size(); device_idx++)
{
for(unsigned int device_idx = 0; device_idx < device_lists[list_idx].size(); device_idx++)
{
/*---------------------------------------------------------*\
| Determine if there is any overlap between this device and |
| any existing device list |
| Offset the end by two - one because the range is 1-512 |
| rather than 0-511, and one because the start channel is |
| included in the first set of 3 channels. |
\*---------------------------------------------------------*/
unsigned int dev_start = dev.start_universe;
unsigned int list_start = device_lists[list_idx][device_idx].start_universe;
unsigned int dev_end = dev.start_universe + ((dev.start_channel + (3 * dev.num_leds) - 2) / 512);
unsigned int list_end = device_lists[list_idx][device_idx].start_universe + ((device_lists[list_idx][device_idx].start_channel + (3 * device_lists[list_idx][device_idx].num_leds) - 2) / 512);
bool overlap = !(dev_end < list_start || list_end < dev_start);
/*---------------------------------------------------------*\
| Check if any universes used by this new device exist in |
| the existing device. If so, add the new device to the |
| existing list. |
\*---------------------------------------------------------*/
if(overlap)
{
device_lists[list_idx].push_back(dev);
device_added_to_existing_list = true;
break;
}
}
if(device_added_to_existing_list)
/*---------------------------------------------------------*\
| Check if any universes used by this new device exist in |
| the existing device. If so, add the new device to the |
| existing list. |
\*---------------------------------------------------------*/
if(dev.start_universe == device_lists[list_idx][device_idx].start_universe)
{
device_lists[list_idx].push_back(dev);
device_added_to_existing_list = true;
break;
}
}
/*---------------------------------------------------------*\
| If the device did not overlap with existing devices, |
| create a new list for it |
\*---------------------------------------------------------*/
if(!device_added_to_existing_list)
if(device_added_to_existing_list)
{
std::vector<E131Device> new_list;
new_list.push_back(dev);
device_lists.push_back(new_list);
break;
}
}
else
{
std::vector<E131Device> tmp_device_list;
tmp_device_list.push_back(dev);
RGBController_E131* rgb_controller;
rgb_controller = new RGBController_E131(tmp_device_list);
rgb_controllers.push_back(rgb_controller);
/*---------------------------------------------------------*\
| If the device did not overlap with existing devices, |
| create a new list for it |
\*---------------------------------------------------------*/
if(!device_added_to_existing_list)
{
std::vector<E131Device> new_list;
new_list.push_back(dev);
device_lists.push_back(new_list);
}
}
@@ -15,8 +15,6 @@ using namespace std::chrono_literals;
RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
{
bool multicast = false;
devices = device_list;
name = "E1.31 Device Group";
@@ -36,17 +34,9 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
/*-----------------------------------------*\
| Append the destination address to the |
| location field |
| location field (multicast only for now) |
\*-----------------------------------------*/
if((devices.size() == 1) && (devices[0].ip != ""))
{
location += "Unicast " + devices[0].ip + ", ";
}
else
{
location += "Multicast, ";
multicast = true;
}
location += "Multicast, ";
/*-----------------------------------------*\
| Calculate universe list |
@@ -162,15 +152,7 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
e131_addr_t dest_addr;
e131_pkt_init(&packet, universe, 512);
if(multicast)
{
e131_multicast_dest(&dest_addr, universe, E131_DEFAULT_PORT);
}
else
{
e131_unicast_dest(&dest_addr, devices[0].ip.c_str(), E131_DEFAULT_PORT);
}
e131_multicast_dest(&dest_addr, universe, E131_DEFAULT_PORT);
packets.push_back(packet);
universes.push_back(universe);
@@ -42,7 +42,6 @@ typedef unsigned int e131_matrix_order;
struct E131Device
{
std::string name;
std::string ip;
unsigned int num_leds;
unsigned int start_universe;
unsigned int start_channel;
+1 -1
View File
@@ -86,7 +86,7 @@ std::string EKController::GetSerial()
std::string EKController::GetLocation()
{
return("HID: " + location);
return location;
}
void EKController::SetMode(unsigned char mode, unsigned char speed)
@@ -14,7 +14,6 @@ RGBController_EKController::RGBController_EKController(EKController* _dev)
EK_dev = _dev;
name = EK_dev->GetDeviceName();
vendor = "EK";
type = DEVICE_TYPE_LEDSTRIP;
description = EK_dev->GetDeviceName();
version = "1.0";
@@ -14,7 +14,6 @@ RGBController_EVGAGPUv1::RGBController_EVGAGPUv1(EVGAGPUv1Controller* evga_ptr)
evga = evga_ptr;
name = "EVGA GPU";
vendor = "EVGA";
description = "EVGA RGB v1 GPU Device";
location = evga->GetDeviceLocation();
@@ -14,7 +14,6 @@ RGBController_EVGAGPUv2::RGBController_EVGAGPUv2(EVGAGPUv2Controller* evga_ptr)
evga = evga_ptr;
name = "EVGA GPU";
vendor = "EVGA";
description = "EVGA RGB v2 GPU Device";
location = evga->GetDeviceLocation();
@@ -46,17 +46,11 @@ void EspurnaController::Initialize(char* ledstring)
void EspurnaController::InitializeEspurna(char * clientname, char * port, char * apikey)
{
client_name = clientname;
port_name = port;
strcpy(client_name, clientname);
strcpy(port_name, port);
strcpy(espurna_apikey, apikey);
tcpport = new net_port;
tcpport->tcp_client(client_name.c_str(), port_name.c_str());
}
std::string EspurnaController::GetLocation()
{
return("TCP: " + client_name + ":" + port_name);
tcpport->tcp_client(client_name, port_name);
}
void EspurnaController::SetLEDs(std::vector<RGBColor> colors)
@@ -66,7 +60,7 @@ void EspurnaController::SetLEDs(std::vector<RGBColor> colors)
RGBColor color = colors[0];
char get_request[1024];
snprintf(get_request, 1024, "GET /api/rgb?apikey=%s&value=%%23%02X%02X%02X HTTP/1.1\r\nHost: %s\r\n\r\n", espurna_apikey, RGBGetRValue(color), RGBGetGValue(color), RGBGetBValue(color), client_name.c_str());
snprintf(get_request, 1024, "GET /api/rgb?apikey=%s&value=%%23%02X%02X%02X HTTP/1.1\r\nHost: %s\r\n\r\n", espurna_apikey, RGBGetRValue(color), RGBGetGValue(color), RGBGetBValue(color), client_name);
tcpport->tcp_client_connect();
tcpport->tcp_client_write(get_request, strlen(get_request));
tcpport->tcp_close();
@@ -28,19 +28,16 @@ public:
EspurnaController();
~EspurnaController();
void Initialize(char* ledstring);
void InitializeEspurna(char* clientname, char* port, char * apikey);
std::string GetLocation();
void SetLEDs(std::vector<RGBColor> colors);
void Initialize(char* ledstring);
void InitializeEspurna(char* clientname, char* port, char * apikey);
void SetLEDs(std::vector<RGBColor> colors);
private:
int baud_rate;
char led_string[1024];
std::string port_name;
std::string client_name;
char port_name[128];
char client_name[1024];
char espurna_apikey[128];
net_port *tcpport;
@@ -24,7 +24,7 @@ void DetectEspurnaControllers(std::vector<RGBController*> &rgb_controllers)
/*-------------------------------------------------*\
| Get Espurna settings from settings manager |
\*-------------------------------------------------*/
espurna_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("EspurnaDevices");
espurna_settings = ResourceManager::get()->GetSettingsManager()->GetSettings("Setting_EspurnaDevices");
/*-------------------------------------------------*\
| If the Espurna settings contains devices, process |
@@ -15,7 +15,6 @@ RGBController_Espurna::RGBController_Espurna(EspurnaController* espurna_ptr)
name = "Espurna";
type = DEVICE_TYPE_LIGHT;
description = "Espurna Device";
location = espurna->GetLocation();
mode Direct;
Direct.name = "Direct";
@@ -6,7 +6,6 @@
RGBController_Faustus::RGBController_Faustus(const std::string& dev_path)
{
name = "ASUS TUF Keyboard";
vendor = "ASUS";
type = DEVICE_TYPE_KEYBOARD;
description = "Faustus Device";
@@ -34,8 +33,11 @@ RGBController_Faustus::RGBController_Faustus(const std::string& dev_path)
modes[3].name = "Strobe";
modes[3].value = FAUSTUS_MODE_STROBE;
modes[3].flags = MODE_FLAG_HAS_PER_LED_COLOR;
modes[3].color_mode = MODE_COLORS_PER_LED;
modes[3].flags = MODE_FLAG_HAS_SPEED;
modes[3].speed_min = FAUSTUS_SPEED_SLOWEST;
modes[3].speed_max = FAUSTUS_SPEED_FASTEST;
modes[3].color_mode = MODE_COLORS_NONE;
modes[3].speed = FAUSTUS_SPEED_NORMAL;
SetupZones();
@@ -45,7 +45,6 @@ RGBController_GalaxGPU::RGBController_GalaxGPU(GalaxGPUController * galax_gpu_pt
galax_gpu = galax_gpu_ptr;
name = galax_gpu->GetDeviceName();
vendor = "GALAX";
type = DEVICE_TYPE_GPU;
description = "GALAX / KFA2 RTX GPU";
version = "1.0";
@@ -24,18 +24,7 @@ ATC800Controller::~ATC800Controller()
std::string ATC800Controller::GetDeviceLocation()
{
return("HID: " + location);
}
std::string ATC800Controller::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(location);
}
void ATC800Controller::SendCoolerMode
@@ -45,7 +45,6 @@ public:
~ATC800Controller();
std::string GetDeviceLocation();
std::string GetSerialString();
void SendCoolerMode
(
@@ -14,11 +14,9 @@ RGBController_AorusATC800::RGBController_AorusATC800(ATC800Controller* cooler_pt
cooler = cooler_ptr;
name = "Aorus ATC800 CPU Cooler";
vendor = "Gigabyte";
type = DEVICE_TYPE_COOLER;
description = "Aorus ATC800 CPU Cooler";
location = cooler->GetDeviceLocation();
serial = cooler->GetSerialString();
mode Static;
Static.name = "Static";
@@ -14,7 +14,6 @@ RGBController_RGBFusion2DRAM::RGBController_RGBFusion2DRAM(RGBFusion2DRAMControl
rgb_fusion = rgb_fusion_ptr;
name = "RGB Fusion 2 DRAM";
vendor = "Gigabyte";
description = "RGB Fusion 2 DRAM Device";
location = rgb_fusion->GetDeviceLocation();
@@ -18,15 +18,14 @@
#include <iomanip>
#endif
RGBFusion2SMBusController::RGBFusion2SMBusController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev, std::string mb_name)
RGBFusion2SMBusController::RGBFusion2SMBusController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev)
{
this->bus = bus;
this->dev = dev;
this->name = mb_name;
this->bus = bus;
this->dev = dev;
memset(led_data, 0, 10*16);
led_count = 10; // Protocol supports 10 'slots'
led_count = 10; // Protocol supports 10 'slots'
}
unsigned int RGBFusion2SMBusController::GetLEDCount()
@@ -34,11 +33,6 @@ unsigned int RGBFusion2SMBusController::GetLEDCount()
return(led_count);
}
std::string RGBFusion2SMBusController::GetDeviceName()
{
return(name);
}
std::string RGBFusion2SMBusController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
@@ -75,10 +75,9 @@ enum
class RGBFusion2SMBusController
{
public:
RGBFusion2SMBusController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev, std::string mb_name);
RGBFusion2SMBusController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev);
~RGBFusion2SMBusController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
void Apply();
@@ -97,7 +96,6 @@ private:
unsigned int led_count;
i2c_smbus_interface* bus;
rgb_fusion_dev_id dev;
std::string name;
unsigned char led_data[10][16];
@@ -9,8 +9,6 @@
#include <stdlib.h>
#include <string>
#include "dependencies/dmiinfo.h"
#define DETECTOR_NAME "Gigabyte RGB Fusion 2 SMBus"
#define VENDOR_NAME "Gigabyte Technology Co., Ltd."
typedef struct
{
@@ -20,22 +18,21 @@ typedef struct
#define RGB_FUSION_2_SMBUS_NUM_DEVICES (sizeof(rgb_fusion_2_smbus_motherboards) / sizeof(rgb_fusion_2_smbus_motherboards[ 0 ]))
json rgb_fusion_2_smbus_motherboards[] =
const motherboard_info rgb_fusion_2_smbus_motherboards[] =
{
"B450 AORUS ELITE",
"B450 AORUS M",
"B450 AORUS PRO WIFI-CF",
"B450 AORUS PRO-CF",
"B450 AORUS PRO-CF4",
"B450 I AORUS PRO WIFI-CF",
"B450M DS3H-CF",
"X399 AORUS XTREME-CF",
"X399 DESIGNARE EX-CF",
"X470 AORUS GAMING 5 WIFI",
"X470 AORUS GAMING 7 WIFI-CF",
"X470 AORUS ULTRA GAMING",
"X470 AORUS ULTRA GAMING-CF",
"Z370 AORUS Gaming 5-CF"
{ "Gigabyte Technology Co., Ltd.", "B450 AORUS ELITE" },
{ "Gigabyte Technology Co., Ltd.", "B450 AORUS M" },
{ "Gigabyte Technology Co., Ltd.", "B450 AORUS PRO WIFI-CF" },
{ "Gigabyte Technology Co., Ltd.", "B450 AORUS PRO-CF" },
{ "Gigabyte Technology Co., Ltd.", "B450 AORUS PRO-CF4" },
{ "Gigabyte Technology Co., Ltd.", "B450 I AORUS PRO WIFI-CF" },
{ "Gigabyte Technology Co., Ltd.", "B450M DS3H-CF" },
{ "Gigabyte Technology Co., Ltd.", "X399 AORUS XTREME-CF" },
{ "Gigabyte Technology Co., Ltd.", "X399 DESIGNARE EX-CF" },
{ "Gigabyte Technology Co., Ltd.", "X470 AORUS GAMING 5 WIFI" },
{ "Gigabyte Technology Co., Ltd.", "X470 AORUS GAMING 7 WIFI-CF" },
{ "Gigabyte Technology Co., Ltd.", "X470 AORUS ULTRA GAMING" },
{ "Gigabyte Technology Co., Ltd.", "X470 AORUS ULTRA GAMING-CF" },
};
/******************************************************************************************\
@@ -75,37 +72,21 @@ bool TestForGigabyteRGBFusion2SMBusController(i2c_smbus_interface* bus, unsigned
void DetectGigabyteRGBFusion2SMBusControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
{
RGBFusion2SMBusController* new_rgb_fusion;
RGBController_RGBFusion2SMBus* new_controller;
SettingsManager* set_man = ResourceManager::get()->GetSettingsManager();
json device_settings;
RGBFusion2SMBusController* new_rgb_fusion;
RGBController_RGBFusion2SMBus* new_controller;
DMIInfo dmi;
bool found = false;
DMIInfo dmi;
bool found = false;
/*-------------------------------------------------*\
| Get Linux LED settings from settings manager |
\*-------------------------------------------------*/
device_settings = set_man->GetSettings(DETECTOR_NAME);
if (!device_settings.contains("SupportedDevices"))
for(unsigned int mb_idx = 0; mb_idx < RGB_FUSION_2_SMBUS_NUM_DEVICES; mb_idx++)
{
//If supported devices is not found then write it to settings
device_settings["SupportedDevices"] = rgb_fusion_2_smbus_motherboards;
set_man->SetSettings(DETECTOR_NAME, device_settings);
set_man->SaveSettings();
if( ( dmi.getManufacturer() == rgb_fusion_2_smbus_motherboards[mb_idx].manufacturer )
&& ( dmi.getMainboard() == rgb_fusion_2_smbus_motherboards[mb_idx].motherboard ) )
{
found = true;
}
}
bool boolVendor = ( dmi.getManufacturer() == VENDOR_NAME );
bool boolMotherboard = false;
nlohmann::detail::iter_impl<nlohmann::json> result = std::find(std::begin(device_settings["SupportedDevices"]), std::end(device_settings["SupportedDevices"]), dmi.getMainboard() );
if(result != std::end(device_settings["SupportedDevices"]))
{
boolMotherboard = true;
}
found = ( boolVendor && boolMotherboard );
if(found)
{
for (unsigned int bus = 0; bus < busses.size(); bus++)
@@ -120,7 +101,7 @@ void DetectGigabyteRGBFusion2SMBusControllers(std::vector<i2c_smbus_interface*>&
// Check for RGB Fusion 2 controller at 0x68
if (TestForGigabyteRGBFusion2SMBusController(busses[bus], 0x68))
{
new_rgb_fusion = new RGBFusion2SMBusController(busses[bus], 0x68, dmi.getMainboard() );
new_rgb_fusion = new RGBFusion2SMBusController(busses[bus], 0x68);
new_controller = new RGBController_RGBFusion2SMBus(new_rgb_fusion);
rgb_controllers.push_back(new_controller);
}
@@ -131,4 +112,4 @@ void DetectGigabyteRGBFusion2SMBusControllers(std::vector<i2c_smbus_interface*>&
} /* DetectRGBFusion2SMBusControllers() */
REGISTER_I2C_DETECTOR(DETECTOR_NAME, DetectGigabyteRGBFusion2SMBusControllers);
REGISTER_I2C_DETECTOR("Gigabyte RGB Fusion 2 SMBus", DetectGigabyteRGBFusion2SMBusControllers);
@@ -41,8 +41,7 @@ RGBController_RGBFusion2SMBus::RGBController_RGBFusion2SMBus(RGBFusion2SMBusCont
{
rgb_fusion = rgb_fusion_ptr;
name = rgb_fusion->GetDeviceName();
vendor = "Gigabyte";
name = "RGB Fusion 2 SMBus";
description = "RGB Fusion 2 SMBus";
location = rgb_fusion->GetDeviceLocation();
@@ -59,7 +59,7 @@ RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char
D_LED1_count = LedCountToEnum(report.total_leds & 0x0F);
D_LED2_count = LedCountToEnum(report.total_leds & 0xF0);
}
location = path;
loc = path;
EnableBeat(false);
}
@@ -157,7 +157,7 @@ std::string RGBFusion2USBController::GetFWVersion()
std::string RGBFusion2USBController::GetDeviceLocation()
{
return("HID: " + location);
return(loc);
}
std::string RGBFusion2USBController::GetSerial()
@@ -190,7 +190,7 @@ private:
IT8297Report report;
std::string name;
std::string description;
std::string location;
std::string loc;
std::string version;
std::string chip_id;
int effect_disabled = 0;
@@ -29,11 +29,5 @@ void DetectGigabyteRGBFusion2USBControllers(hid_device_info* info, const std::st
}
} /* DetectRGBFusion2USBControllers() */
#ifdef USE_HID_USAGE
REGISTER_HID_DETECTOR_PU("Gigabyte RGB Fusion 2 USB", DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x8297, IT8297_UPG, IT8297_U);
REGISTER_HID_DETECTOR_PU("Gigabyte RGB Fusion 2 USB", DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x5702, IT8297_UPG, IT8297_U);
#else
REGISTER_HID_DETECTOR_I("Gigabyte RGB Fusion 2 USB", DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x8297, IT8297_IFC);
REGISTER_HID_DETECTOR_I("Gigabyte RGB Fusion 2 USB", DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x5702, IT8297_IFC);
#endif
REGISTER_HID_DETECTOR_IPU("Gigabyte RGB Fusion 2 USB", DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x8297, IT8297_IFC, IT8297_UPG, IT8297_U);
REGISTER_HID_DETECTOR_IPU("Gigabyte RGB Fusion 2 USB", DetectGigabyteRGBFusion2USBControllers, IT8297_VID, 0x5702, IT8297_IFC, IT8297_UPG, IT8297_U);
@@ -108,7 +108,6 @@ RGBController_RGBFusion2USB::RGBController_RGBFusion2USB(RGBFusion2USBController
controller = controller_ptr;
name = controller->GetDeviceName();
vendor = "Gigabyte";
type = DEVICE_TYPE_MOTHERBOARD;
description = controller->GetDeviceDescription();
version = controller->GetFWVersion();
@@ -20,7 +20,6 @@ RGBController_RGBFusion::RGBController_RGBFusion(RGBFusionController* rgb_fusion
rgb_fusion = rgb_fusion_ptr;
name = rgb_fusion->GetDeviceName();
vendor = "Gigabyte";
description = "RGB Fusion 1.0";
location = rgb_fusion->GetDeviceLocation();
@@ -42,39 +42,71 @@ bool TestForGigabyteRGBFusionGPUController(i2c_smbus_interface* bus, unsigned ch
bool pass = false;
int res;
//Write out 0xAB 0x00 0x00 0x00 sequence
res = bus->i2c_smbus_write_byte(address, 0xAB);
if (res >= 0)
switch(address)
{
bus->i2c_smbus_write_byte(address, 0x00);
bus->i2c_smbus_write_byte(address, 0x00);
bus->i2c_smbus_write_byte(address, 0x00);
case 0x47:
//Write out 0xAB 0x00 0x00 0x00 sequence
res = bus->i2c_smbus_write_byte(address, 0xAB);
pass = true;
if (res >= 0)
{
bus->i2c_smbus_write_byte(address, 0x00);
bus->i2c_smbus_write_byte(address, 0x00);
bus->i2c_smbus_write_byte(address, 0x00);
res = bus->i2c_smbus_read_byte(address);
pass = true;
if (res != 0xAB)
{
pass = false;
}
res = bus->i2c_smbus_read_byte(address);
res = bus->i2c_smbus_read_byte(address);
if (res != 0xAB)
{
pass = false;
}
if(res != 0x14)
{
pass = false;
}
res = bus->i2c_smbus_read_byte(address);
bus->i2c_smbus_read_byte(address);
bus->i2c_smbus_read_byte(address);
if(res != 0x14)
{
pass = false;
}
//We don't know what the 0x48 controller returns, so for now just assume it exists
if(address == 0x48)
{
bus->i2c_smbus_read_byte(address);
bus->i2c_smbus_read_byte(address);
}
break;
case 0x48:
pass = true;
}
//Write out 0xCC 0x01 0x00 0x00 sequence
// res = bus->i2c_smbus_write_byte(address, 0xCC);
// if (res >= 0)
// {
// bus->i2c_smbus_write_byte(address, 0x01);
// bus->i2c_smbus_write_byte(address, 0x00);
// bus->i2c_smbus_write_byte(address, 0x00);
// pass = true;
// res = bus->i2c_smbus_read_byte(address);
// if (res != 0xCC)
// {
// pass = false;
// }
// res = bus->i2c_smbus_read_byte(address);
// if(res != 0x01)
// {
// pass = false;
// }
// bus->i2c_smbus_read_byte(address);
// bus->i2c_smbus_read_byte(address);
// }
break;
}
return(pass);
@@ -14,7 +14,6 @@ RGBController_RGBFusionGPU::RGBController_RGBFusionGPU(RGBFusionGPUController* r
rgb_fusion = rgb_fusion_ptr;
name = "Gigabyte GPU";
vendor = "Gigabyte";
description = "RGB Fusion GPU";
location = rgb_fusion->GetDeviceLocation();
@@ -18,18 +18,7 @@ HoltekA070Controller::HoltekA070Controller(hid_device* dev_handle, const char* p
std::string HoltekA070Controller::GetDeviceLocation()
{
return("HID: " + location);
}
std::string HoltekA070Controller::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(location);
}
/*-------------------------------------------------------------------------------------------------*\
@@ -28,7 +28,6 @@ public:
~HoltekA070Controller();
std::string GetDeviceLocation();
std::string GetSerialString();
void SendCustomColor
(
@@ -13,11 +13,9 @@ RGBController_HoltekA070::RGBController_HoltekA070(HoltekA070Controller* holtek_
holtek = holtek_ptr;
name = "Holtek USB Gaming Mouse Device";
vendor = "Holtek";
type = DEVICE_TYPE_MOUSE;
description = "Holtek USB Gaming Mouse Device";
location = holtek->GetDeviceLocation();
serial = holtek->GetSerialString();
mode Static;
Static.name = "Static";
@@ -16,12 +16,13 @@ HyperXDRAMController::HyperXDRAMController(i2c_smbus_interface* bus, hyperx_dev_
this->dev = dev;
slots_valid = slots;
strcpy(device_name, "HyperX Predator RGB");
led_count = 0;
for(unsigned int slot = 0; slot < 4; slot++)
for(int i = 0; i < 8; i++)
{
if(((slots_valid & ( 0x01 << slot)) != 0)
||((slots_valid & ( 0x10 << slot)) != 0))
if((slots_valid & (1 << i)) != 0)
{
led_count += 5;
}
@@ -35,6 +36,11 @@ HyperXDRAMController::~HyperXDRAMController()
}
std::string HyperXDRAMController::GetDeviceName()
{
return(device_name);
}
std::string HyperXDRAMController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
@@ -56,8 +62,7 @@ unsigned int HyperXDRAMController::GetSlotCount()
for(int slot = 0; slot < 4; slot++)
{
if(((slots_valid & ( 0x01 << slot)) != 0)
||((slots_valid & ( 0x10 << slot)) != 0))
if((slots_valid & (1 << slot)) != 0)
{
slot_count++;
}
@@ -71,12 +76,6 @@ unsigned int HyperXDRAMController::GetMode()
return(mode);
}
void HyperXDRAMController::SendApply()
{
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
void HyperXDRAMController::SetEffectColor(unsigned char red, unsigned char green, unsigned char blue)
{
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
@@ -98,12 +97,9 @@ void HyperXDRAMController::SetAllColors(unsigned char red, unsigned char green,
| Loop through all slots and only set those which are |
| active. |
\*-----------------------------------------------------*/
for(unsigned int slot_idx = 0; slot_idx < 4; slot_idx++)
for(int slot = 0; slot < 4; slot++)
{
unsigned char slot = slot_map[slot_idx];
if(((slots_valid & ( 0x01 << slot)) != 0)
||((slots_valid & ( 0x10 << slot)) != 0))
if((slots_valid & (1 << slot)) != 0)
{
unsigned char base = slot_base[slot];
unsigned char red_base = base + 0x00;
@@ -140,7 +136,7 @@ void HyperXDRAMController::SetLEDColor(unsigned int led, unsigned char red, unsi
\*-----------------------------------------------------*/
int led_slot = led / 5;
int slot_id = -1;
unsigned char slot;
int slot;
led -= (led_slot * 5);
@@ -148,12 +144,9 @@ void HyperXDRAMController::SetLEDColor(unsigned int led, unsigned char red, unsi
| Loop through all possible slots and only count those |
| which are active. |
\*-----------------------------------------------------*/
for(unsigned int slot_idx = 0; slot_idx < 4; slot_idx++)
for(slot = 0; slot < 4; slot++)
{
slot = slot_map[slot_idx];
if(((slots_valid & ( 0x01 << slot)) != 0)
||((slots_valid & ( 0x10 << slot)) != 0))
if((slots_valid & ( 1 << slot)) != 0)
{
slot_id++;
}
@@ -164,7 +157,21 @@ void HyperXDRAMController::SetLEDColor(unsigned int led, unsigned char red, unsi
}
}
SetLEDColor(slot, led, red, green, blue);
unsigned char base = slot_base[slot];
unsigned char red_base = base + 0x00;
unsigned char green_base = base + 0x01;
unsigned char blue_base = base + 0x02;
unsigned char bright_base = base + 0x10;
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
bus->i2c_smbus_write_byte_data(dev, red_base + (3 * led), red );
bus->i2c_smbus_write_byte_data(dev, green_base + (3 * led), green);
bus->i2c_smbus_write_byte_data(dev, blue_base + (3 * led), blue );
bus->i2c_smbus_write_byte_data(dev, bright_base + (3 * led), 0x64 );
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
@@ -182,6 +189,9 @@ void HyperXDRAMController::SetLEDColor(unsigned int slot, unsigned int led, unsi
bus->i2c_smbus_write_byte_data(dev, green_base + (3 * led), green);
bus->i2c_smbus_write_byte_data(dev, blue_base + (3 * led), blue );
bus->i2c_smbus_write_byte_data(dev, bright_base + (3 * led), 0x64 );
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
void HyperXDRAMController::SetMode(unsigned char new_mode, bool random, unsigned short new_speed)
@@ -188,32 +188,22 @@ enum
static const unsigned char slot_base[4] =
{
HYPERX_REG_SLOT0_LED0_RED, /* SPD 0x50 maps to slot 0 */
HYPERX_REG_SLOT1_LED0_RED, /* SPD 0x52 maps to slot 1 */
HYPERX_REG_SLOT2_LED0_RED, /* SPD 0x51 maps to slot 2 */
HYPERX_REG_SLOT1_LED0_RED, /* SPD 0x52 maps to slot 1 */
HYPERX_REG_SLOT3_LED0_RED /* SPD 0x53 maps to slot 3 */
};
static const unsigned char slot_map[4] =
{
0,
2,
1,
3
};
class HyperXDRAMController
{
public:
HyperXDRAMController(i2c_smbus_interface* bus, hyperx_dev_id dev, unsigned char slots);
~HyperXDRAMController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetLEDCount();
unsigned int GetSlotCount();
unsigned int GetMode();
void SendApply();
void SetMode(unsigned char new_mode, bool random, unsigned short new_speed);
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
@@ -222,6 +212,7 @@ public:
void SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
private:
char device_name[32];
unsigned int led_count;
unsigned char slots_valid;
i2c_smbus_interface* bus;
@@ -63,8 +63,6 @@ void DetectHyperXDRAMControllers(std::vector<i2c_smbus_interface*> &busses, std:
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
unsigned char slots_valid = 0x00;
bool fury_detected = false;
bool pred_detected = false;
IF_DRAM_SMBUS(busses[bus]->pci_vendor, busses[bus]->pci_device)
{
@@ -84,15 +82,6 @@ void DetectHyperXDRAMControllers(std::vector<i2c_smbus_interface*> &busses, std:
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x41) == 0x98))
{
slots_valid |= (1 << (slot_addr - 0x50));
if(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x67) == 0x01)
{
fury_detected = true;
}
else
{
pred_detected = true;
}
}
std::this_thread::sleep_for(1ms);
@@ -102,16 +91,6 @@ void DetectHyperXDRAMControllers(std::vector<i2c_smbus_interface*> &busses, std:
{
new_hyperx = new HyperXDRAMController(busses[bus], 0x27, slots_valid);
new_controller = new RGBController_HyperXDRAM(new_hyperx);
if(fury_detected && !pred_detected)
{
new_controller->name = "HyperX Fury RGB";
}
else if(!fury_detected && pred_detected)
{
new_controller->name = "HyperX Predator RGB";
}
rgb_controllers.push_back(new_controller);
}
}
@@ -14,8 +14,7 @@ RGBController_HyperXDRAM::RGBController_HyperXDRAM(HyperXDRAMController* hyperx_
{
hyperx = hyperx_ptr;
name = "HyperX DRAM";
vendor = "HyperX";
name = hyperx->GetDeviceName();
type = DEVICE_TYPE_DRAM;
description = "HyperX DRAM Device";
location = hyperx->GetDeviceLocation();
@@ -181,7 +180,6 @@ void RGBController_HyperXDRAM::DeviceUpdateLEDs()
unsigned char blu = RGBGetBValue(color);
hyperx->SetLEDColor(led_idx, red, grn, blu);
}
hyperx->SendApply();
}
else
{
@@ -205,7 +203,6 @@ void RGBController_HyperXDRAM::UpdateZoneLEDs(int zone)
unsigned char blu = RGBGetBValue(color);
hyperx->SetLEDColor(led, red, grn, blu);
}
hyperx->SendApply();
}
else
{
@@ -231,7 +228,6 @@ void RGBController_HyperXDRAM::UpdateSingleLED(int led)
{
hyperx->SetEffectColor(red, grn, blu);
}
hyperx->SendApply();
}
void RGBController_HyperXDRAM::SetCustomMode()
@@ -27,18 +27,7 @@ HyperXAlloyOriginsController::~HyperXAlloyOriginsController()
std::string HyperXAlloyOriginsController::GetDeviceLocation()
{
return("HID " + location);
}
std::string HyperXAlloyOriginsController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(location);
}
void HyperXAlloyOriginsController::SetLEDsDirect(std::vector<RGBColor> colors)
@@ -21,7 +21,6 @@ public:
~HyperXAlloyOriginsController();
std::string GetDeviceLocation();
std::string GetSerialString();
void SetLEDsDirect(std::vector<RGBColor> colors);
@@ -40,18 +40,7 @@ HyperXKeyboardController::~HyperXKeyboardController()
std::string HyperXKeyboardController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string HyperXKeyboardController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(location);
}
void HyperXKeyboardController::SetMode
@@ -69,7 +69,6 @@ public:
~HyperXKeyboardController();
std::string GetDeviceLocation();
std::string GetSerialString();
void SetMode
(
@@ -172,11 +172,9 @@ RGBController_HyperXAlloyOrigins::RGBController_HyperXAlloyOrigins(HyperXAlloyOr
hyperx = hyperx_ptr;
name = "HyperX Alloy Origins Keyboard Device";
vendor = "HyperX";
type = DEVICE_TYPE_KEYBOARD;
description = "HyperX Alloy Origins Keyboard Device";
location = hyperx->GetDeviceLocation();
serial = hyperx->GetSerialString();
mode Direct;
Direct.name = "Direct";
@@ -180,11 +180,9 @@ RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardControl
hyperx = hyperx_ptr;
name = "HyperX RGB Keyboard";
vendor = "HyperX";
type = DEVICE_TYPE_KEYBOARD;
description = "HyperX RGB Keyboard Device";
location = hyperx->GetDeviceLocation();
serial = hyperx->GetSerialString();
mode Direct;
Direct.name = "Direct";
@@ -24,18 +24,7 @@ HyperXPulsefireSurgeController::~HyperXPulsefireSurgeController()
std::string HyperXPulsefireSurgeController::GetDeviceLocation()
{
return("HID " + location);
}
std::string HyperXPulsefireSurgeController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(location);
}
/*-------------------------------------------------------------------------------------------------*\
@@ -38,7 +38,6 @@ public:
~HyperXPulsefireSurgeController();
std::string GetDeviceLocation();
std::string GetSerialString();
void SelectProfile
(
@@ -16,11 +16,9 @@ RGBController_HyperXPulsefireSurge::RGBController_HyperXPulsefireSurge(HyperXPul
hyperx = hyperx_ptr;
name = "HyperX Pulsefire Surge Device";
vendor = "HyperX";
type = DEVICE_TYPE_MOUSE;
description = "HyperX Pulsefire Surge Device";
location = hyperx->GetDeviceLocation();
serial = hyperx->GetSerialString();
mode Direct;
Direct.name = "Direct";
@@ -24,18 +24,7 @@ HyperXMousematController::~HyperXMousematController()
std::string HyperXMousematController::GetDeviceLocation()
{
return("HID " + location);
}
std::string HyperXMousematController::GetSerialString()
{
wchar_t serial_string[128];
hid_get_serial_number_string(dev, serial_string, 128);
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_string);
return(location);
}
/*-------------------------------------------------------------------------------------------------*\
@@ -21,7 +21,6 @@ public:
~HyperXMousematController();
std::string GetDeviceLocation();
std::string GetSerialString();
void SendDirect
(
@@ -16,11 +16,9 @@ RGBController_HyperXMousemat::RGBController_HyperXMousemat(HyperXMousematControl
hyperx = hyperx_ptr;
name = "HyperX Mousemat Device";
vendor = "HyperX";
type = DEVICE_TYPE_MOUSEMAT;
description = "HyperX Mousemat Device";
location = hyperx->GetDeviceLocation();
serial = hyperx->GetSerialString();
mode Direct;
Direct.name = "Direct";
@@ -86,37 +86,21 @@ void LEDStripController::Initialize(char* ledstring)
void LEDStripController::InitializeSerial(char* portname, int baud)
{
portname = strtok(portname, "\r");
port_name = portname;
strcpy(port_name, portname);
baud_rate = baud;
serialport = new serial_port(port_name.c_str(), baud_rate);
serialport = new serial_port(port_name, baud_rate);
udpport = NULL;
}
void LEDStripController::InitializeUDP(char * clientname, char * port)
{
client_name = clientname;
port_name = port;
strcpy(client_name, clientname);
strcpy(port_name, port);
udpport = new net_port(client_name.c_str(), port_name.c_str());
udpport = new net_port(client_name, port_name);
serialport = NULL;
}
std::string LEDStripController::GetLocation()
{
if(serialport != NULL)
{
return("COM: " + port_name);
}
else if(udpport != NULL)
{
return("UDP: " + client_name + ":" + port_name);
}
else
{
return("");
}
}
char* LEDStripController::GetLEDString()
{
return(led_string);
@@ -152,6 +136,7 @@ void LEDStripController::SetLEDs(std::vector<RGBColor> colors)
if (serialport != NULL)
{
serialport->serial_write((char *)serial_buf, (num_leds * 3) + 3);
serialport->serial_flush_tx();
}
else if (udpport != NULL)
{
@@ -159,4 +144,4 @@ void LEDStripController::SetLEDs(std::vector<RGBColor> colors)
}
delete[] serial_buf;
}
}
@@ -36,14 +36,11 @@ public:
LEDStripController();
~LEDStripController();
void Initialize(char* ledstring);
void InitializeSerial(char* portname, int baud);
void InitializeUDP(char* clientname, char* port);
char* GetLEDString();
std::string GetLocation();
void SetLEDs(std::vector<RGBColor> colors);
void Initialize(char* ledstring);
void InitializeSerial(char* portname, int baud);
void InitializeUDP(char* clientname, char* port);
char* GetLEDString();
void SetLEDs(std::vector<RGBColor> colors);
int num_leds;
@@ -51,8 +48,8 @@ private:
int baud_rate;
char led_string[1024];
std::string port_name;
std::string client_name;
char port_name[128];
char client_name[1024];
serial_port *serialport;
net_port *udpport;
};

Some files were not shown because too many files have changed in this diff Show More