Compare commits

..
Author SHA1 Message Date
Adam Honse 91c8ec0cb0 OpenRGB version 0.1 2020-03-28 15:06:37 -05:00
cip91sk 314283a37c add missing aura ram address 2020-03-28 14:46:02 -05:00
Adam Honse c3e5d91b6b Allow manual resizing of Hue+ channels 2020-03-28 14:37:27 -05:00
Adam Honse c769c20af1 Move static mode to top of Redragon M711 mode list 2020-03-28 14:35:14 -05:00
Adam Honse 2a43cefbe6 Add Redragon K556 modes, though grouped modes and colors aren't implemented yet 2020-03-27 23:24:16 -05:00
Adam Honse 68960b7b14 Add RGBController for Redragon K556 keyboard, only supports custom mode for now 2020-03-27 23:24:16 -05:00
Adam Honse ad85efcb14 Update Redragon code, split mouse and keyboard into their own controllers, and get mouse control working 2020-03-27 23:24:16 -05:00
Adam Honse 7c221416cc Redragon M709 and K556 development 2020-03-27 23:24:16 -05:00
Adam Honse 9ba1b2fc57 Bring in nct6775 SMBus driver improvements from updated patch to Windows 2020-03-24 18:07:23 -05:00
Adam Honse caf1e5c7f0 Update OpenRazer-win32 DLLs to openrazer commit bd864c8 2020-03-24 17:58:03 -05:00
Adam Honse 2b660a47c7 Fix wrong index being used in profile lookup that would cause segfaults if there are more controllers detected than in profile 2020-03-23 23:40:18 -05:00
Adam Honse 0c45e26c98 Add timeouts to i2c-nct6775 driver and fix kernel segfault caused by byte access with no data 2020-03-23 23:22:25 -05:00
Adam Honse fdbaf9bf63 Fix segfault in CLI 2020-03-22 22:18:30 -05:00
Adam Honse 08a1197b7e Fix arguments not parsing in CLI, add mode specific color support to CLI 2020-03-22 16:22:59 -05:00
Adam Honse 87a9ea5b14 Add some comments to the CLI code and clean up some warnings 2020-03-22 03:49:08 -05:00
Adam Honse 2b8d25559a Move help and version functions to the same place as the other arguments 2020-03-22 01:48:57 -05:00
Adam Honse 3db9189cbb Fix current device ID in CLI 2020-03-22 01:01:01 -05:00
Adam Honse a0c379e8c7 Add profile saving to command line 2020-03-22 00:26:06 -05:00
Adam Honse 0ae4964545 Clean up some of the CLI code and add option to load a profile from the command line 2020-03-22 00:04:27 -05:00
Adam Honse 69651b3f91 Load sizes for variable-size controllers in CLI mode 2020-03-20 13:50:54 -05:00
Adam Honse ce9508aa88 Allow 0x03 or 0x04 for detecting Corsair Pro DRAM 2020-03-20 13:05:49 -05:00
Adam Honse aa182936ba Clean up warnings, except in hidapi and cli files 2020-03-20 12:10:18 -05:00
Adam Honse 745bbac93b Fix i2c bus names on Linux 2020-03-20 10:20:46 -05:00
Adam Honse 5c3c15f930 Remove Synchronized Effects tab as the effects engine has been postponed until after 1.0 2020-03-20 00:39:29 -05:00
Adam Honse 4919b03bd1 Remove controller-side LED count from Corsair Lighting Node and ThermalTake Riing controllers, initialize them to zero LED count 2020-03-19 20:55:57 -05:00
Adam Honse 18c18e3999 Automatically save a sizes.ors profile when resizing a zone, then automatically load zone sizes from sizes.ors on start 2020-03-19 14:24:39 -05:00
Adam Honse 01020b50d9 Set default number of LEDs per strip in RGB Fusion 2 controller 2020-03-18 22:49:35 -05:00
Adam Honse 00f422375b Initial Corsair mouse support, tested on M65 RGB Elite. Shows as mousemat with 15 zones for now as zone mapping isn't supported yet 2020-03-13 18:55:07 -05:00
Adam Honse 25807902c9 Set each LED independently for Crucial effect modes 2020-03-13 21:41:23 +00:00
Adam Honse 0bbef425a4 Enable effects on Crucial controller, but color modes unimplemented 2020-03-13 17:20:32 +00:00
Adam Honse ec65d8a2a9 Update OpenRazer-win32 DLLs to openrazer commit 692e36b 2020-03-12 17:37:26 -05:00
Adam Honse 47df8f3414 Fix leftover un-renamed types 2020-03-12 14:53:32 -05:00
Adam Honse c560ee4b7e Rename RGBFusion2Controller to RGBFusion2USBController 2020-03-12 18:58:28 +00:00
Adam Honse 74080150e0 Rename AuraController to AuraSMBusController 2020-03-12 17:27:52 +00:00
Adam Honse ab7ddc1629 Rename HyperXController to HyperXDRAMController 2020-03-11 19:37:10 -05:00
Adam Honse 000bef969c Add more Corsair keyboards to the detection list 2020-03-11 19:19:37 -05:00
Adam Honse c8e0aec596 Use 24-bit color protocol for Corsair keyboards 2020-03-11 17:31:30 -05:00
Adam Honse ecf4427c76 Rename CorsairController to CorsairVengeanceController, CorsairProController to CorsairVengeanceProController 2020-03-11 21:15:05 +00:00
Adam Honse d299e90954 Fix 24-bit keyboard color set function 2020-03-11 12:18:24 -05:00
Adam Honse 98bb92acdb Add 24-bit color set function for keyboards 2020-03-11 15:15:43 +00:00
Adam Honse 0e77149444 Rename CorsairKeyboardController to CorsairPeripheralController 2020-03-10 21:26:36 -05:00
Adam Honse e6c21f0a72 Add firmware version to Corsair Lighting Node driver 2020-03-10 15:57:46 -05:00
Adam Honse da9f6d7c72 Add description for ASUS Aura device driver 2020-03-10 14:09:43 -05:00
Adam Honse 97975b6d36 Update description on Corsair Lighting Node driver 2020-03-10 13:59:17 -05:00
Adam Honse ad98cc173b Update description on Corsair peripheral driver 2020-03-10 11:35:16 -05:00
Adam Honse 5a33c80d65 Fix build issue in Linux in Corsair Keyboard driver 2020-03-09 20:47:07 -05:00
Adam Honse f661bf66f1 Fix button sizes a bit, it's not perfect but it's better than it was 2020-03-09 20:41:41 -05:00
Adam Honse f1e1c41d68 Add support for Corsair Polaris MM800 mousemat using CorsairKeyboardController driver 2020-03-09 20:39:55 -05:00
Adam Honse a7ed250c4e Don't initialize pointers on zones with no LEDs 2020-03-09 16:39:38 -05:00
Adam Honse 62c06202e0 Re-enable and update RGBController data block get/set functions for new API parameters. This gets profile savig and loading working again 2020-03-09 12:28:50 -05:00
Adam Honse 23ad5ca244 Fix setting individual LEDs when a specific zone is selected 2020-03-08 20:51:30 -05:00
Adam Honse 5712717ef8 Update maximum number of LEDs for Thermaltake Riing zone to 20 LEDs 2020-03-08 20:25:07 -05:00
Adam Honse da54e89839 Fix Thermaltake Riing controller 2020-03-08 17:07:57 -05:00
Adam Honse 57b8377f5a Disable built in effects before setting strip colors in RGB Fusion 2 controller 2020-03-08 17:01:09 -05:00
Adam Honse fbb718c532 Update RGB Fusion 2 controller to new RGBController API. Reworked some of the RGB Fusion 2 controller code to be more consistent with the rest of the project. 2020-03-08 12:06:21 -05:00
Adam Honse 5a469ea615 Update Corsair Keyboard controller to new RGBController API 2020-03-07 18:06:55 -06:00
Adam Honse 2099abb126 Update Patriot Viper RGB controller to new RGBController API 2020-03-07 18:01:00 -06:00
Adam Honse 4b4e939d10 Update Crucial Ballistix RGB controller to new RGBController API 2020-03-07 17:55:41 -06:00
Adam Honse e0094915fe Update ThermalTake Poseidon Z RGB controller to new RGBController API 2020-03-07 17:46:38 -06:00
Adam Honse aa6e2e611b Update HyperX Keyboard controller to new RGBController API 2020-03-07 17:37:50 -06:00
Adam Honse ce8331b467 Update Faustus controller to new RGBController API 2020-03-07 17:18:44 -06:00
Adam Honse 54ff4d57b0 Fix Hue 2 controller build on Linux 2020-03-07 17:12:31 -06:00
Adam Honse 3abb0c05ba Update Corsair Vengeance RGB Pro controller to new RGBController API 2020-03-07 17:08:04 -06:00
Adam Honse acc84f6a09 Update ASUS Aura GPU controller to new RGBController API. Also update ASUS Aura controller to read colors from hardware during initialization. 2020-03-07 16:55:02 -06:00
Adam Honse 74b0d195d9 Update Corsair Vengeance RGB controller to new RGBController API 2020-03-07 16:41:59 -06:00
Adam Honse 920e001bab Update MSI 3-Zone Keyboard controller to new RGBController API 2020-03-07 16:35:54 -06:00
Adam Honse 4c2ceed5b6 Update ASRock Polychrome controller to new RGBController API 2020-03-07 16:30:00 -06:00
Adam Honse 515c17b8dd Update MSI-RGB controller to new RGBController API 2020-03-07 16:20:35 -06:00
Adam Honse 2ffb02abde Update E1.31 controller to new RGBController API 2020-03-07 16:13:15 -06:00
Adam Honse 3237c8842a Update NZXT Hue+ and Hue 2 controllers to new RGBController API. Fix direct mode not working on Hue 2. 2020-03-07 15:56:07 -06:00
Adam Honse fde468a162 Update LED Strip controller to new RGBController API 2020-03-07 01:38:32 -06:00
Adam Honse f854441cf7 Update HyperX RGB RAM controller to new RGBController API 2020-03-07 01:28:26 -06:00
Adam Honse 408020c244 Update Gigabyte RGB Fusion 1.0 controller to new RGBController API 2020-03-07 01:10:26 -06:00
Adam Honse f806f3ad66 Update AMD Wraith Prism controller to new RGBController API 2020-03-07 01:00:58 -06:00
Adam Honse 7c1c9a7979 Update OpenRazer (Windows and Linux) controllers for new RGBController API 2020-03-07 00:38:42 -06:00
Adam Honse 283cb5a8ac Update RGB Fusion GPU controller to new RGBController API 2020-03-06 16:54:53 -06:00
Adam Honse 5f21674b8f Update Aura controller for RGBController API changes 2020-03-06 14:20:17 -06:00
Adam Honse fe6a84d6c9 Rename NodePro to LightingNode 2020-03-06 12:11:53 -06:00
Adam Honse f7cb8ca969 Delete CorsairCmdrProController files now that Corsair Pro is merged into Lighting Node driver 2020-03-05 22:26:29 -06:00
Adam Honse 64dad049f9 Set endpoint based on Corsair Lighting Node device table 2020-03-05 22:04:30 -06:00
Adam Honse 1115213d5a Consolidate Corsair Lighting Node and compatible device drivers 2020-03-05 21:12:17 -06:00
Adam Honse bc01ec0e4b Update Thermaltake Riing controller for resizable channels 2020-03-05 12:29:17 -06:00
Adam Honse 62518b5163 Update RGBController API and GUI to handle resizable zones. All controllers except for CorsairNodePro have been disabled pending rework 2020-03-04 19:29:58 -06:00
Adam Honse 736e624366 Resize button. Resizes mode specific color lists. Partial implementation of resizing zones 2020-03-04 17:53:44 -06:00
Adam Honse d7298cafd0 Fix build on Linux 2020-03-03 22:06:46 -06:00
Adam Honse 70783fb28f Add button to delete profiles and confirmation dialog 2020-03-03 21:15:33 -06:00
Adam Honse 45a5f629e5 Do a complete refresh of profile list when saving profile 2020-03-03 21:02:50 -06:00
Adam Honse ec73337929 Update OpenRazer-Win32 DLLs to fix corrupt serial and version strings, enable reading these in OpenRGB. 2020-03-03 13:22:23 -06:00
Adam Honse 148b84b7d1 Add support for ASRock Polychrome FW 3.04 (X570 Taichi) 2020-03-03 12:15:55 -06:00
Adam Honse 3cf855bd10 Search through controller list for each controller when loading profile, allows controller order to change without breaking the profile 2020-03-03 12:11:21 -06:00
Adam Honse 9deb0f8fff Move profile code from Qt UI to new ProfileManager class 2020-03-02 16:05:07 -06:00
Adam Honse 8c86686d01 Delay 200ms after changing Poseidon Z RGB mode so that direct colors are set correctly 2020-03-01 22:12:51 -06:00
Adam Honse c451487401 Change direct effects mode back to Direct mode on HyperX keyboard 2020-03-01 22:04:52 -06:00
Adam Honse 5defbc1580 Fix color mode for Thermaltake Riing direct mode 2020-03-01 22:00:24 -06:00
Adam Honse b5af840dcc Fix possible out of bounds access when initializing Aura RAM addresses 2020-03-01 21:50:08 -06:00
Adam Honse 1b170ff664 Update libusb DLLs to include a small change to fix detection of some composite HID devices such as RGB keyboards. Source for this new DLL at my libusb fork - https://github.com/CalcProgrammer1/libusb 2020-03-01 21:42:43 -06:00
Adam Honse 31a6da1b21 Build hidapi from source using libusb backend. This requires installation of WinUSB driver on Windows but fixes issues with Windows-specific HID implementation 2020-03-01 21:16:22 -06:00
Adam Honse cb6dfd83d8 Add refreshing thread for HyperX keyboard Direct mode 2020-03-01 20:57:04 -06:00
Adam Honse 50ea274205 Add timeouts to fix HyperX and Poseidon Z RGB in Linux 2020-03-01 20:56:07 -06:00
138 changed files with 6467 additions and 4842 deletions
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| AuraController.cpp |
| AuraSMBusController.cpp |
| |
| Driver for ASUS Aura RGB lighting |
| controller |
@@ -7,10 +7,10 @@
| Adam Honse (CalcProgrammer1) 8/19/2018 |
\*-----------------------------------------*/
#include "AuraController.h"
#include "AuraSMBusController.h"
#include <cstring>
AuraController::AuraController(i2c_smbus_interface* bus, aura_dev_id dev)
AuraSMBusController::AuraSMBusController(i2c_smbus_interface* bus, aura_dev_id dev)
{
this->bus = bus;
this->dev = dev;
@@ -77,17 +77,17 @@ AuraController::AuraController(i2c_smbus_interface* bus, aura_dev_id dev)
}
}
AuraController::~AuraController()
AuraSMBusController::~AuraSMBusController()
{
}
std::string AuraController::GetDeviceName()
std::string AuraSMBusController::GetDeviceName()
{
return(device_name);
}
std::string AuraController::GetDeviceLocation()
std::string AuraSMBusController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
@@ -97,12 +97,12 @@ std::string AuraController::GetDeviceLocation()
return(return_string);
}
unsigned char AuraController::GetChannel(unsigned int led)
unsigned char AuraSMBusController::GetChannel(unsigned int led)
{
return(config_table[channel_cfg + led]);
}
const char * AuraController::GetChannelName(unsigned int led)
const char * AuraSMBusController::GetChannelName(unsigned int led)
{
switch (config_table[channel_cfg + led])
{
@@ -152,27 +152,27 @@ const char * AuraController::GetChannelName(unsigned int led)
}
}
unsigned int AuraController::GetLEDCount()
unsigned int AuraSMBusController::GetLEDCount()
{
return(led_count);
}
unsigned char AuraController::GetLEDRed(unsigned int led)
unsigned char AuraSMBusController::GetLEDRed(unsigned int led)
{
return(AuraRegisterRead(direct_reg + ( 3 * led )));
}
unsigned char AuraController::GetLEDGreen(unsigned int led)
unsigned char AuraSMBusController::GetLEDGreen(unsigned int led)
{
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 2));
}
unsigned char AuraController::GetLEDBlue(unsigned int led)
unsigned char AuraSMBusController::GetLEDBlue(unsigned int led)
{
return(AuraRegisterRead(direct_reg + ( 3 * led ) + 1));
}
void AuraController::SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue)
void AuraSMBusController::SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char* colors = new unsigned char[led_count * 3];
@@ -188,7 +188,7 @@ void AuraController::SetAllColorsDirect(unsigned char red, unsigned char green,
delete colors;
}
void AuraController::SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
void AuraSMBusController::SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char* colors = new unsigned char[led_count * 3];
@@ -206,20 +206,20 @@ void AuraController::SetAllColorsEffect(unsigned char red, unsigned char green,
delete[] colors;
}
void AuraController::SetDirect(unsigned char direct)
void AuraSMBusController::SetDirect(unsigned char direct)
{
AuraRegisterWrite(AURA_REG_DIRECT, direct);
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
}
void AuraController::SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
void AuraSMBusController::SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char colors[3] = { red, blue, green };
AuraRegisterWriteBlock(direct_reg + ( 3 * led ), colors, 3);
}
void AuraController::SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
void AuraSMBusController::SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char colors[3] = { red, blue, green };
@@ -228,13 +228,13 @@ void AuraController::SetLEDColorEffect(unsigned int led, unsigned char red, unsi
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
}
void AuraController::SetMode(unsigned char mode)
void AuraSMBusController::SetMode(unsigned char mode)
{
AuraRegisterWrite(AURA_REG_MODE, mode);
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
}
void AuraController::AuraUpdateDeviceName()
void AuraSMBusController::AuraUpdateDeviceName()
{
for (int i = 0; i < 16; i++)
{
@@ -242,7 +242,7 @@ void AuraController::AuraUpdateDeviceName()
}
}
unsigned char AuraController::AuraRegisterRead(aura_register reg)
unsigned char AuraSMBusController::AuraRegisterRead(aura_register reg)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
@@ -252,7 +252,7 @@ unsigned char AuraController::AuraRegisterRead(aura_register reg)
}
void AuraController::AuraRegisterWrite(aura_register reg, unsigned char val)
void AuraSMBusController::AuraRegisterWrite(aura_register reg, unsigned char val)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
@@ -262,7 +262,7 @@ void AuraController::AuraRegisterWrite(aura_register reg, unsigned char val)
}
void AuraController::AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz)
void AuraSMBusController::AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz)
{
//Write Aura register
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| AuraController.h |
| AuraSMBusController.h |
| |
| Definitions and types for ASUS Aura RGB |
| lighting controller |
@@ -88,11 +88,11 @@ enum
AURA_CONFIG_CHANNEL_V2 = 0x1B, /* LED Channel V2 configuration offset */
};
class AuraController
class AuraSMBusController
{
public:
AuraController(i2c_smbus_interface* bus, aura_dev_id dev);
~AuraController();
AuraSMBusController(i2c_smbus_interface* bus, aura_dev_id dev);
~AuraSMBusController();
std::string GetDeviceName();
std::string GetDeviceLocation();
@@ -1,6 +1,6 @@
#include "AuraController.h"
#include "AuraSMBusController.h"
#include "RGBController.h"
#include "RGBController_Aura.h"
#include "RGBController_AuraSMBus.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
@@ -20,12 +20,13 @@ static void Sleep(unsigned int milliseconds)
/*----------------------------------------------------------------------*\
| This list contains the available SMBus addresses for mapping Aura RAM |
\*----------------------------------------------------------------------*/
#define AURA_RAM_ADDRESS_COUNT 21
#define AURA_RAM_ADDRESS_COUNT 22
static const unsigned char aura_ram_addresses[] =
{
0x70,
0x71,
0x72,
0x73,
0x74,
0x75,
@@ -64,9 +65,9 @@ static const unsigned char aura_mobo_addresses[] =
* *
* AuraRegisterWrite *
* *
* A standalone version of the AuraController::AuraRegisterWrite function for access *
* to Aura devices without instancing the AuraController class or reading the config *
* table from the device. *
* A standalone version of the AuraSMBusController::AuraRegisterWrite function for *
* access to Aura devices without instancing the AuraSMBusController class or reading *
* the config table from the device. *
* *
\******************************************************************************************/
@@ -81,7 +82,7 @@ void AuraRegisterWrite(i2c_smbus_interface* bus, aura_dev_id dev, aura_register
/******************************************************************************************\
* *
* TestForAuraController *
* TestForAuraSMBusController *
* *
* Tests the given address to see if an Aura controller exists there. First does a *
* quick write to test for a response, and if so does a simple read at 0xA0 to test *
@@ -89,7 +90,7 @@ void AuraRegisterWrite(i2c_smbus_interface* bus, aura_dev_id dev, aura_register
* *
\******************************************************************************************/
bool TestForAuraController(i2c_smbus_interface* bus, unsigned char address)
bool TestForAuraSMBusController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
@@ -112,11 +113,11 @@ bool TestForAuraController(i2c_smbus_interface* bus, unsigned char address)
return(pass);
} /* TestForAuraController() */
} /* TestForAuraSMBusController() */
/******************************************************************************************\
* *
* DetectAuraControllers *
* DetectAuraSMBusControllers *
* *
* Detect Aura controllers on the enumerated I2C busses. Searches for Aura-enabled *
* RAM at 0x77 and tries to initialize their slot addresses, then searches for them *
@@ -128,10 +129,10 @@ bool TestForAuraController(i2c_smbus_interface* bus, unsigned char address)
* *
\******************************************************************************************/
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
void DetectAuraSMBusControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
AuraController* new_aura;
RGBController_Aura* new_controller;
AuraSMBusController* new_aura;
RGBController_AuraSMBus* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
@@ -149,9 +150,10 @@ void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vecto
do
{
address_list_idx++;
if(address_list_idx < AURA_RAM_ADDRESS_COUNT)
{
address_list_idx++;
res = busses[bus]->i2c_smbus_write_quick(aura_ram_addresses[address_list_idx], I2C_SMBUS_WRITE);
}
else
@@ -160,17 +162,20 @@ void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vecto
}
} while (res >= 0);
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_SLOT_INDEX, slot);
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_I2C_ADDRESS, (aura_ram_addresses[address_list_idx] << 1));
if(address_list_idx < AURA_RAM_ADDRESS_COUNT)
{
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_SLOT_INDEX, slot);
AuraRegisterWrite(busses[bus], 0x77, AURA_REG_I2C_ADDRESS, (aura_ram_addresses[address_list_idx] << 1));
}
}
// Add Aura-enabled controllers at their remapped addresses
for (unsigned int address_list_idx = 0; address_list_idx < AURA_RAM_ADDRESS_COUNT; address_list_idx++)
{
if (TestForAuraController(busses[bus], aura_ram_addresses[address_list_idx]))
if (TestForAuraSMBusController(busses[bus], aura_ram_addresses[address_list_idx]))
{
new_aura = new AuraController(busses[bus], aura_ram_addresses[address_list_idx]);
new_controller = new RGBController_Aura(new_aura);
new_aura = new AuraSMBusController(busses[bus], aura_ram_addresses[address_list_idx]);
new_controller = new RGBController_AuraSMBus(new_aura);
rgb_controllers.push_back(new_controller);
}
@@ -180,10 +185,10 @@ void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vecto
// Add Aura-enabled motherboard controllers
for (unsigned int address_list_idx = 0; address_list_idx < AURA_MOBO_ADDRESS_COUNT; address_list_idx++)
{
if (TestForAuraController(busses[bus], aura_mobo_addresses[address_list_idx]))
if (TestForAuraSMBusController(busses[bus], aura_mobo_addresses[address_list_idx]))
{
new_aura = new AuraController(busses[bus], aura_mobo_addresses[address_list_idx]);
new_controller = new RGBController_Aura(new_aura);
new_aura = new AuraSMBusController(busses[bus], aura_mobo_addresses[address_list_idx]);
new_controller = new RGBController_AuraSMBus(new_aura);
rgb_controllers.push_back(new_controller);
}
@@ -191,4 +196,4 @@ void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vecto
}
}
} /* DetectAuraControllers() */
} /* DetectAuraSMBusControllers() */
@@ -1,507 +0,0 @@
/*---------------------------------------------------------*\
| Processing Code for Corsair Commander Pro |
| |
| Adam Honse ([email protected]), 1/16/2020 |
\*---------------------------------------------------------*/
#include "CorsairCmdrProController.h"
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
//Include thread libraries for Windows or Linux
#ifdef WIN32
#include <process.h>
#else
#include "pthread.h"
#include "unistd.h"
#endif
//Thread functions have different types in Windows and Linux
#ifdef WIN32
#define THREAD static void
#define THREADRETURN
#else
#define THREAD static void*
#define THREADRETURN return(NULL);
#endif
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
THREAD keepalive_thread(void *param)
{
CorsairCmdrProController* corsair = static_cast<CorsairCmdrProController*>(param);
corsair->KeepaliveThread();
THREADRETURN
}
CorsairCmdrProController::CorsairCmdrProController(libusb_device_handle* dev_handle)
{
dev = dev_handle;
channel_leds[0] = 60;
channel_leds[1] = 60;
/*-----------------------------------------------------*\
| The Corsair Lighting Node Pro requires a packet within|
| 20 seconds of sending the lighting change in order |
| to not revert back into rainbow mode. Start a thread |
| to continuously send a keepalive packet every 5s |
\*-----------------------------------------------------*/
#ifdef WIN32
_beginthread(keepalive_thread, 0, this);
#else
pthread_t thread;
pthread_create(&thread, NULL, &keepalive_thread, this);
#endif
}
CorsairCmdrProController::~CorsairCmdrProController()
{
}
void CorsairCmdrProController::KeepaliveThread()
{
while(1)
{
SendCommit();
Sleep(5000);
}
}
void CorsairCmdrProController::SetChannelEffect(unsigned char channel,
unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2,
unsigned char red3,
unsigned char grn3,
unsigned char blu3
)
{
/*-----------------------------------------------------*\
| Send Reset packet |
\*-----------------------------------------------------*/
SendReset(channel);
/*-----------------------------------------------------*\
| Send Begin packet |
\*-----------------------------------------------------*/
SendBegin(channel);
/*-----------------------------------------------------*\
| Set Port State packet |
\*-----------------------------------------------------*/
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE);
/*-----------------------------------------------------*\
| Set Effect Configuration packet |
\*-----------------------------------------------------*/
SendEffectConfig
(
channel,
0,
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP,
mode,
speed,
direction,
random,
red1,
grn1,
blu1,
red2,
grn2,
blu2,
red3,
grn3,
blu3,
0,
0,
0
);
/*-----------------------------------------------------*\
| Send Commit packet |
\*-----------------------------------------------------*/
SendCommit();
}
void CorsairCmdrProController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
{
unsigned char color_data[50];
unsigned char pkt_max;
/*-----------------------------------------------------*\
| Send Port State packet |
\*-----------------------------------------------------*/
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE);
/*-----------------------------------------------------*\
| Send red channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
{
pkt_max = (unsigned char)colors.size();
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetRValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
/*-----------------------------------------------------*\
| Send red channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetRValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
}
/*-----------------------------------------------------*\
| Send green channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
{
pkt_max = (unsigned char)colors.size();
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetGValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
/*-----------------------------------------------------*\
| Send green channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetGValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
}
/*-----------------------------------------------------*\
| Send blue channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
{
pkt_max = (unsigned char)colors.size();
}
for(int idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetBValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
/*-----------------------------------------------------*\
| Send blue channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
}
if(pkt_max > 0)
{
for (std::size_t idx = 0; idx < pkt_max; idx++)
{
color_data[idx] = RGBGetBValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
}
/*-----------------------------------------------------*\
| Send Commit packet |
\*-----------------------------------------------------*/
SendCommit();
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void CorsairCmdrProController::SendDirect
(
unsigned char channel,
unsigned char start,
unsigned char count,
unsigned char color_channel,
unsigned char* color_data
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_DIRECT;
usb_buf[0x01] = channel;
usb_buf[0x02] = start;
usb_buf[0x03] = count;
usb_buf[0x04] = color_channel;
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x05], color_data, count);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendCommit()
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Commit packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_COMMIT;
usb_buf[0x01] = 0xFF;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendBegin
(
unsigned char channel
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Begin packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_BEGIN;
usb_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendEffectConfig
(
unsigned char channel,
unsigned char count,
unsigned char led_type,
unsigned char mode,
unsigned char speed,
unsigned char direction,
unsigned char change_style,
unsigned char color_0_red,
unsigned char color_0_green,
unsigned char color_0_blue,
unsigned char color_1_red,
unsigned char color_1_green,
unsigned char color_1_blue,
unsigned char color_2_red,
unsigned char color_2_green,
unsigned char color_2_blue,
unsigned short temperature_0,
unsigned short temperature_1,
unsigned short temperature_2
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Effect Config packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x01] = channel;
usb_buf[0x02] = count * 10;
usb_buf[0x03] = led_type;
/*-----------------------------------------------------*\
| Set up mode parameters |
\*-----------------------------------------------------*/
usb_buf[0x04] = mode;
usb_buf[0x05] = speed;
usb_buf[0x06] = direction;
usb_buf[0x07] = change_style;
usb_buf[0x08] = 0;
/*-----------------------------------------------------*\
| Set up mode colors |
\*-----------------------------------------------------*/
usb_buf[0x09] = color_0_red;
usb_buf[0x10] = color_0_green;
usb_buf[0x11] = color_0_blue;
usb_buf[0x12] = color_1_red;
usb_buf[0x13] = color_1_green;
usb_buf[0x14] = color_1_blue;
usb_buf[0x15] = color_2_red;
usb_buf[0x16] = color_2_green;
usb_buf[0x17] = color_2_blue;
/*-----------------------------------------------------*\
| Set up temperatures |
\*-----------------------------------------------------*/
usb_buf[0x12] = (temperature_0 >> 8);
usb_buf[0x13] = (temperature_0 & 0xFF);
usb_buf[0x14] = (temperature_1 >> 8);
usb_buf[0x15] = (temperature_1 & 0xFF);
usb_buf[0x16] = (temperature_2 >> 8);
usb_buf[0x17] = (temperature_2 & 0xFF);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendTemperature()
{
}
void CorsairCmdrProController::SendReset
(
unsigned char channel
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Reset packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_RESET;
usb_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendPortState
(
unsigned char channel,
unsigned char state
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Port State packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE;
usb_buf[0x01] = channel;
usb_buf[0x02] = state;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x02, usb_buf, 64, &actual, 0);
}
void CorsairCmdrProController::SendBrightness()
{
}
void CorsairCmdrProController::SendLEDCount()
{
}
void CorsairCmdrProController::SendProtocol()
{
}
@@ -1,166 +0,0 @@
/*---------------------------------------------------------*\
| Definitions for Corsair Commander Pro |
| |
| Adam Honse ([email protected]), 1/16/2020 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#pragma once
enum
{
CORSAIR_CMDR_PRO_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
CORSAIR_CMDR_PRO_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
CORSAIR_CMDR_PRO_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG = 0x35, /* Effect mode configuration packet */
CORSAIR_CMDR_PRO_PACKET_ID_TEMPERATURE = 0x36, /* Update temperature value packet */
CORSAIR_CMDR_PRO_PACKET_ID_RESET = 0x37, /* Reset channel packet */
CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE = 0x38, /* Set port state packet */
CORSAIR_CMDR_PRO_PACKET_ID_BRIGHTNESS = 0x39, /* Set brightness packet */
CORSAIR_CMDR_PRO_PACKET_ID_LED_COUNT = 0x3A, /* Set LED count packet */
CORSAIR_CMDR_PRO_PACKET_ID_PROTOCOL = 0x3B, /* Set protocol packet */
};
enum
{
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED = 0x00, /* Red channel for direct update */
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN = 0x01, /* Green channel for direct update */
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE = 0x02, /* Blue channel for direct update */
};
enum
{
CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE = 0x01, /* Effect hardware control of channel */
CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE = 0x02, /* Direct software control of channel */
};
enum
{
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP = 0x0A, /* Corsair LED Strip Type */
CORSAIR_CMDR_PRO_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
CORSAIR_CMDR_PRO_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
CORSAIR_CMDR_PRO_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
};
enum
{
CORSAIR_CMDR_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
CORSAIR_CMDR_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
CORSAIR_CMDR_PRO_NUM_CHANNELS = 0x02, /* Number of channels */
};
enum
{
CORSAIR_CMDR_PRO_SPEED_FAST = 0x00, /* Fast speed */
CORSAIR_CMDR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
CORSAIR_CMDR_PRO_SPEED_SLOW = 0x02, /* Slow speed */
};
enum
{
CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
CORSAIR_CMDR_PRO_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
CORSAIR_CMDR_PRO_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
CORSAIR_CMDR_PRO_MODE_STATIC = 0x04, /* Static mode */
CORSAIR_CMDR_PRO_MODE_TEMPERATURE = 0x05, /* Temperature mode */
CORSAIR_CMDR_PRO_MODE_VISOR = 0x06, /* Visor mode */
CORSAIR_CMDR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
CORSAIR_CMDR_PRO_MODE_BLINK = 0x08, /* Blink mode */
CORSAIR_CMDR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
CORSAIR_CMDR_PRO_MODE_RAINBOW = 0x0A, /* Rainbow mode */
};
class CorsairCmdrProController
{
public:
CorsairCmdrProController(libusb_device_handle* dev_handle);
~CorsairCmdrProController();
unsigned int GetStripsOnChannel(unsigned int channel);
void SetChannelEffect(unsigned char channel,
unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2,
unsigned char red3,
unsigned char grn3,
unsigned char blu3
);
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
unsigned int channel_leds[CORSAIR_CMDR_PRO_NUM_CHANNELS];
void KeepaliveThread();
private:
libusb_device_handle* dev;
void SendDirect
(
unsigned char channel,
unsigned char start,
unsigned char count,
unsigned char color_channel,
unsigned char* color_data
);
void SendCommit();
void SendBegin
(
unsigned char channel
);
void SendEffectConfig
(
unsigned char channel,
unsigned char count,
unsigned char led_type,
unsigned char mode,
unsigned char speed,
unsigned char direction,
unsigned char change_style,
unsigned char color_0_red,
unsigned char color_0_green,
unsigned char color_0_blue,
unsigned char color_1_red,
unsigned char color_1_green,
unsigned char color_1_blue,
unsigned char color_2_red,
unsigned char color_2_green,
unsigned char color_2_blue,
unsigned short temperature_0,
unsigned short temperature_1,
unsigned short temperature_2
);
void SendTemperature();
void SendReset
(
unsigned char channel
);
void SendPortState
(
unsigned char channel,
unsigned char state
);
void SendBrightness();
void SendLEDCount();
void SendProtocol();
};
@@ -1,37 +0,0 @@
#include "CorsairCmdrProController.h"
#include "RGBController.h"
#include "RGBController_CorsairCmdrPro.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#define CORSAIR_COMMANDER_PRO_VID 0x1B1C
#define CORSAIR_COMMANDER_PRO_PID 0x0C10
/******************************************************************************************\
* *
* DetectCorsairCmdrProControllers *
* *
* Detect devices supported by the Corsair Commander Pro driver *
* * *
\******************************************************************************************/
void DetectCorsairCmdrProControllers(std::vector<RGBController*> &rgb_controllers)
{
libusb_context * ctx;
libusb_init(&ctx);
//Look for Corsair Commander Pro
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, CORSAIR_COMMANDER_PRO_VID, CORSAIR_COMMANDER_PRO_PID);
if( dev )
{
libusb_detach_kernel_driver(dev, 0);
libusb_claim_interface(dev, 0);
CorsairCmdrProController* controller = new CorsairCmdrProController(dev);
RGBController_CorsairCmdrPro* rgb_controller = new RGBController_CorsairCmdrPro(controller);
rgb_controllers.push_back(rgb_controller);
}
} /* DetectCorsairCmdrProControllers() */
@@ -1,253 +0,0 @@
/*-----------------------------------------*\
| CorsairKeyboardController.cpp |
| |
| Driver for Corsair RGB keyboard lighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 1/9/2020 |
\*-----------------------------------------*/
#include "CorsairKeyboardController.h"
#include <cstring>
static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78,
79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97,
98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115,
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
136, 137, 139, 140, 141};
static void send_usb_msg(hid_device* dev, char * data_pkt)
{
char usb_pkt[65];
usb_pkt[0] = 0x00;
for(int i = 1; i < 65; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
int bytes = hid_send_feature_report(dev, (unsigned char *)usb_pkt, 65);
bytes++;
}
static void get_usb_msg(hid_device* dev, char* data_pkt)
{
char usb_pkt[65];
usb_pkt[0] = 0x00;
for(int i = 1; i < 65; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
int bytes = hid_get_feature_report(dev, (unsigned char*)data_pkt, 64);
bytes++;
}
CorsairKeyboardController::CorsairKeyboardController(hid_device* dev_handle)
{
dev = dev_handle;
char data_pkt[64] = { 0 };
LightingControl();
}
CorsairKeyboardController::~CorsairKeyboardController()
{
}
void CorsairKeyboardController::SetLEDs(std::vector<RGBColor> colors)
{
unsigned char data_pkt[216];
unsigned char red_val[144];
unsigned char grn_val[144];
unsigned char blu_val[144];
/*-----------------------------------------------------*\
| Zero out buffers |
\*-----------------------------------------------------*/
memset(data_pkt, 0x00, sizeof( data_pkt ));
memset(red_val, 0x00, sizeof( red_val ));
memset(grn_val, 0x00, sizeof( grn_val ));
memset(blu_val, 0x00, sizeof( blu_val ));
/*-----------------------------------------------------*\
| Scale color values to 9-bit |
\*-----------------------------------------------------*/
for(int color_idx = 0; color_idx < colors.size(); color_idx++)
{
RGBColor color = colors[color_idx];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if( red > 7 ) red = 7;
if( grn > 7 ) grn = 7;
if( blu > 7 ) blu = 7;
red = 7 - red;
grn = 7 - grn;
blu = 7 - blu;
red_val[keys[color_idx]] = red;
grn_val[keys[color_idx]] = grn;
blu_val[keys[color_idx]] = blu;
}
/*-----------------------------------------------------*\
| Pack the color values, 2 values per byte |
\*-----------------------------------------------------*/
for(int red_idx = 0; red_idx < 72; red_idx++)
{
data_pkt[red_idx] = red_val[(red_idx * 2) + 1] << 4 | red_val[red_idx * 2];
}
for(int grn_idx = 0; grn_idx < 72; grn_idx++)
{
data_pkt[grn_idx + 72] = grn_val[(grn_idx * 2) + 1] << 4 | grn_val[grn_idx * 2];
}
for(int blu_idx = 0; blu_idx < 72; blu_idx++)
{
data_pkt[blu_idx + 144] = blu_val[(blu_idx * 2) + 1] << 4 | blu_val[blu_idx * 2];
}
/*-----------------------------------------------------*\
| Send the packets |
\*-----------------------------------------------------*/
StreamPacket(1, 60, &data_pkt[0]);
StreamPacket(2, 60, &data_pkt[60]);
StreamPacket(3, 60, &data_pkt[120]);
StreamPacket(4, 36, &data_pkt[180]);
SubmitLimitedColors(216);
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void CorsairKeyboardController::LightingControl()
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_LIGHTING_CONTROL;
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
usb_buf[0x04] = 0x03;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairKeyboardController::ReadFirmwareInfo()
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Read Firmware Info packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_READ;
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
get_usb_msg(dev, usb_buf);
}
void CorsairKeyboardController::StreamPacket
(
unsigned char packet_id,
unsigned char data_sz,
unsigned char* data_ptr
)
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Stream packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_STREAM;
usb_buf[0x01] = packet_id;
usb_buf[0x02] = data_sz;
/*-----------------------------------------------------*\
| Copy in data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x04], data_ptr, data_sz);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairKeyboardController::SubmitColors()
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Submit Keyboard 24-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairKeyboardController::SubmitLimitedColors
(
unsigned char byte_count
)
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Submit Keyboard 9-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9;
usb_buf[0x04] = byte_count;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
@@ -1,52 +0,0 @@
#include "CorsairKeyboardController.h"
#include "RGBController.h"
#include "RGBController_CorsairKeyboard.h"
#include <vector>
#include <hidapi/hidapi.h>
#define CORSAIR_RGB_KEYBOARD_VID 0x1B1C
#define CORSAIR_RGB_KEYBOARD_K70_PID 0x1B13
#define CORSAIR_RGB_KEYBOARD_K95_PID 0x1B11
/******************************************************************************************\
* *
* DetectCorsairKeyboardControllers *
* *
* Tests the USB address to see if a Corsair RGB Keyboard controller exists there. *
* *
\******************************************************************************************/
void DetectCorsairKeyboardControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev = NULL;
hid_init();
info = hid_enumerate(CORSAIR_RGB_KEYBOARD_VID, CORSAIR_RGB_KEYBOARD_K70_PID);
//Look for Corsair RGB Keyboard, interface 1
while(info)
{
if((info->vendor_id == CORSAIR_RGB_KEYBOARD_VID)
&&(info->product_id == CORSAIR_RGB_KEYBOARD_K70_PID)
&&(info->interface_number == 1))
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
CorsairKeyboardController* controller = new CorsairKeyboardController(dev);
RGBController_CorsairKeyboard* rgb_controller = new RGBController_CorsairKeyboard(controller);
rgb_controllers.push_back(rgb_controller);
}
}
@@ -4,7 +4,7 @@
| Adam Honse (calcprogrammer1@gmail.com), 1/12/2020 |
\*---------------------------------------------------------*/
#include "CorsairNodeProController.h"
#include "CorsairLightingNodeController.h"
#include <fstream>
#include <iostream>
@@ -41,16 +41,17 @@ static void Sleep(unsigned int milliseconds)
THREAD keepalive_thread(void *param)
{
CorsairNodeProController* corsair = static_cast<CorsairNodeProController*>(param);
CorsairLightingNodeController* corsair = static_cast<CorsairLightingNodeController*>(param);
corsair->KeepaliveThread();
THREADRETURN
}
CorsairNodeProController::CorsairNodeProController(libusb_device_handle* dev_handle)
CorsairLightingNodeController::CorsairLightingNodeController(libusb_device_handle* dev_handle, unsigned int dev_endpoint)
{
dev = dev_handle;
channel_leds[0] = 60;
channel_leds[1] = 60;
endpoint = dev_endpoint;
SendFirmwareRequest();
/*-----------------------------------------------------*\
| The Corsair Lighting Node Pro requires a packet within|
@@ -66,11 +67,11 @@ CorsairNodeProController::CorsairNodeProController(libusb_device_handle* dev_han
#endif
}
CorsairNodeProController::~CorsairNodeProController()
CorsairLightingNodeController::~CorsairLightingNodeController()
{
}
void CorsairNodeProController::KeepaliveThread()
void CorsairLightingNodeController::KeepaliveThread()
{
while(1)
{
@@ -79,7 +80,13 @@ void CorsairNodeProController::KeepaliveThread()
}
}
void CorsairNodeProController::SetChannelEffect(unsigned char channel,
std::string CorsairLightingNodeController::GetFirmwareString()
{
return(firmware_version);
}
void CorsairLightingNodeController::SetChannelEffect(unsigned char channel,
unsigned char num_leds,
unsigned char mode,
unsigned char speed,
unsigned char direction,
@@ -108,7 +115,7 @@ void CorsairNodeProController::SetChannelEffect(unsigned char channel,
/*-----------------------------------------------------*\
| Set Port State packet |
\*-----------------------------------------------------*/
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE);
SendPortState(channel, CORSAIR_LIGHTING_NODE_PORT_STATE_HARDWARE);
/*-----------------------------------------------------*\
| Set Effect Configuration packet |
@@ -117,7 +124,7 @@ void CorsairNodeProController::SetChannelEffect(unsigned char channel,
(
channel,
0,
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP,
num_leds,
mode,
speed,
direction,
@@ -142,7 +149,7 @@ void CorsairNodeProController::SetChannelEffect(unsigned char channel,
SendCommit();
}
void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
void CorsairLightingNodeController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
{
unsigned char color_data[50];
unsigned char pkt_max;
@@ -150,16 +157,16 @@ void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector
/*-----------------------------------------------------*\
| Send Port State packet |
\*-----------------------------------------------------*/
SendPortState(channel, CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE);
SendPortState(channel, CORSAIR_LIGHTING_NODE_PORT_STATE_SOFTWARE);
/*-----------------------------------------------------*\
| Send red channel packet 1 |
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
if(pkt_max > num_colors)
{
pkt_max = (unsigned char)colors.size();
pkt_max = (unsigned char)num_colors;
}
for(int idx = 0; idx < pkt_max; idx++)
@@ -167,16 +174,16 @@ void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector
color_data[idx] = RGBGetRValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
SendDirect(channel, 0, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_RED, color_data);
/*-----------------------------------------------------*\
| Send red channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
if (num_colors > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
pkt_max = (unsigned char)(num_colors - 50);
}
if(pkt_max > 0)
@@ -186,7 +193,7 @@ void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector
color_data[idx] = RGBGetRValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED, color_data);
SendDirect(channel, 50, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_RED, color_data);
}
/*-----------------------------------------------------*\
@@ -194,9 +201,9 @@ void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
if(pkt_max > num_colors)
{
pkt_max = (unsigned char)colors.size();
pkt_max = (unsigned char)num_colors;
}
for(int idx = 0; idx < pkt_max; idx++)
@@ -204,16 +211,16 @@ void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector
color_data[idx] = RGBGetGValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
SendDirect(channel, 0, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_GREEN, color_data);
/*-----------------------------------------------------*\
| Send green channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
if (num_colors > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
pkt_max = (unsigned char)(num_colors - 50);
}
if(pkt_max > 0)
@@ -223,7 +230,7 @@ void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector
color_data[idx] = RGBGetGValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN, color_data);
SendDirect(channel, 50, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_GREEN, color_data);
}
/*-----------------------------------------------------*\
@@ -231,9 +238,9 @@ void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector
\*-----------------------------------------------------*/
pkt_max = 50;
if(pkt_max > colors.size())
if(pkt_max > num_colors)
{
pkt_max = (unsigned char)colors.size();
pkt_max = (unsigned char)num_colors;
}
for(int idx = 0; idx < pkt_max; idx++)
@@ -241,16 +248,16 @@ void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector
color_data[idx] = RGBGetBValue(colors[idx]);
}
SendDirect(channel, 0, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
SendDirect(channel, 0, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_BLUE, color_data);
/*-----------------------------------------------------*\
| Send blue channel packet 2 if necessary |
\*-----------------------------------------------------*/
pkt_max = 0;
if (colors.size() > 50)
if (num_colors > 50)
{
pkt_max = (unsigned char)(colors.size() - 50);
pkt_max = (unsigned char)(num_colors - 50);
}
if(pkt_max > 0)
@@ -260,7 +267,7 @@ void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector
color_data[idx] = RGBGetBValue(colors[idx+50]);
}
SendDirect(channel, 50, pkt_max, CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE, color_data);
SendDirect(channel, 50, pkt_max, CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_BLUE, color_data);
}
/*-----------------------------------------------------*\
@@ -273,7 +280,34 @@ void CorsairNodeProController::SetChannelLEDs(unsigned char channel, std::vector
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void CorsairNodeProController::SendDirect
void CorsairLightingNodeController::SendFirmwareRequest()
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Firmware Version Request packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_FIRMWARE;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x80 + endpoint, usb_buf, 64, &actual, 0);
if(actual > 0)
{
firmware_version = std::to_string(usb_buf[0x01]) + "." + std::to_string(usb_buf[0x02]) + "." + std::to_string(usb_buf[0x03]);
}
}
void CorsairLightingNodeController::SendDirect
(
unsigned char channel,
unsigned char start,
@@ -293,7 +327,7 @@ void CorsairNodeProController::SendDirect
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_DIRECT;
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_DIRECT;
usb_buf[0x01] = channel;
usb_buf[0x02] = start;
usb_buf[0x03] = count;
@@ -307,10 +341,10 @@ void CorsairNodeProController::SendDirect
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendCommit()
void CorsairLightingNodeController::SendCommit()
{
int actual;
unsigned char usb_buf[64];
@@ -323,16 +357,16 @@ void CorsairNodeProController::SendCommit()
/*-----------------------------------------------------*\
| Set up Commit packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_COMMIT;
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_COMMIT;
usb_buf[0x01] = 0xFF;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendBegin
void CorsairLightingNodeController::SendBegin
(
unsigned char channel
)
@@ -348,16 +382,16 @@ void CorsairNodeProController::SendBegin
/*-----------------------------------------------------*\
| Set up Begin packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_BEGIN;
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_BEGIN;
usb_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendEffectConfig
void CorsairLightingNodeController::SendEffectConfig
(
unsigned char channel,
unsigned char count,
@@ -391,7 +425,7 @@ void CorsairNodeProController::SendEffectConfig
/*-----------------------------------------------------*\
| Set up Effect Config packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_EFFECT_CONFIG;
usb_buf[0x01] = channel;
usb_buf[0x02] = count * 10;
usb_buf[0x03] = led_type;
@@ -431,15 +465,15 @@ void CorsairNodeProController::SendEffectConfig
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendTemperature()
void CorsairLightingNodeController::SendTemperature()
{
}
void CorsairNodeProController::SendReset
void CorsairLightingNodeController::SendReset
(
unsigned char channel
)
@@ -455,16 +489,16 @@ void CorsairNodeProController::SendReset
/*-----------------------------------------------------*\
| Set up Reset packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_RESET;
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_RESET;
usb_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendPortState
void CorsairLightingNodeController::SendPortState
(
unsigned char channel,
unsigned char state
@@ -481,27 +515,27 @@ void CorsairNodeProController::SendPortState
/*-----------------------------------------------------*\
| Set up Port State packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE;
usb_buf[0x00] = CORSAIR_LIGHTING_NODE_PACKET_ID_PORT_STATE;
usb_buf[0x01] = channel;
usb_buf[0x02] = state;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, endpoint, usb_buf, 64, &actual, 0);
}
void CorsairNodeProController::SendBrightness()
void CorsairLightingNodeController::SendBrightness()
{
}
void CorsairNodeProController::SendLEDCount()
void CorsairLightingNodeController::SendLEDCount()
{
}
void CorsairNodeProController::SendProtocol()
void CorsairLightingNodeController::SendProtocol()
{
}
@@ -0,0 +1,173 @@
/*---------------------------------------------------------*\
| Definitions for Corsair Lighting Node Pro |
| |
| Adam Honse ([email protected]), 1/12/2020 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#pragma once
enum
{
CORSAIR_LIGHTING_NODE_PACKET_ID_FIRMWARE = 0x02, /* Get firmware version */
CORSAIR_LIGHTING_NODE_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
CORSAIR_LIGHTING_NODE_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
CORSAIR_LIGHTING_NODE_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
CORSAIR_LIGHTING_NODE_PACKET_ID_EFFECT_CONFIG = 0x35, /* Effect mode configuration packet */
CORSAIR_LIGHTING_NODE_PACKET_ID_TEMPERATURE = 0x36, /* Update temperature value packet */
CORSAIR_LIGHTING_NODE_PACKET_ID_RESET = 0x37, /* Reset channel packet */
CORSAIR_LIGHTING_NODE_PACKET_ID_PORT_STATE = 0x38, /* Set port state packet */
CORSAIR_LIGHTING_NODE_PACKET_ID_BRIGHTNESS = 0x39, /* Set brightness packet */
CORSAIR_LIGHTING_NODE_PACKET_ID_LED_COUNT = 0x3A, /* Set LED count packet */
CORSAIR_LIGHTING_NODE_PACKET_ID_PROTOCOL = 0x3B, /* Set protocol packet */
};
enum
{
CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_RED = 0x00, /* Red channel for direct update */
CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_GREEN = 0x01, /* Green channel for direct update */
CORSAIR_LIGHTING_NODE_DIRECT_CHANNEL_BLUE = 0x02, /* Blue channel for direct update */
};
enum
{
CORSAIR_LIGHTING_NODE_PORT_STATE_HARDWARE = 0x01, /* Effect hardware control of channel */
CORSAIR_LIGHTING_NODE_PORT_STATE_SOFTWARE = 0x02, /* Direct software control of channel */
};
enum
{
CORSAIR_LIGHTING_NODE_LED_TYPE_LED_STRIP = 0x0A, /* Corsair LED Strip Type */
CORSAIR_LIGHTING_NODE_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
CORSAIR_LIGHTING_NODE_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
CORSAIR_LIGHTING_NODE_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
};
enum
{
CORSAIR_LIGHTING_NODE_CHANNEL_1 = 0x00, /* Channel 1 */
CORSAIR_LIGHTING_NODE_CHANNEL_2 = 0x01, /* Channel 2 */
CORSAIR_LIGHTING_NODE_NUM_CHANNELS = 0x02, /* Number of channels */
};
enum
{
CORSAIR_LIGHTING_NODE_SPEED_FAST = 0x00, /* Fast speed */
CORSAIR_LIGHTING_NODE_SPEED_MEDIUM = 0x01, /* Medium speed */
CORSAIR_LIGHTING_NODE_SPEED_SLOW = 0x02, /* Slow speed */
};
enum
{
CORSAIR_LIGHTING_NODE_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
CORSAIR_LIGHTING_NODE_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
CORSAIR_LIGHTING_NODE_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
CORSAIR_LIGHTING_NODE_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
CORSAIR_LIGHTING_NODE_MODE_STATIC = 0x04, /* Static mode */
CORSAIR_LIGHTING_NODE_MODE_TEMPERATURE = 0x05, /* Temperature mode */
CORSAIR_LIGHTING_NODE_MODE_VISOR = 0x06, /* Visor mode */
CORSAIR_LIGHTING_NODE_MODE_MARQUEE = 0x07, /* Marquee mode */
CORSAIR_LIGHTING_NODE_MODE_BLINK = 0x08, /* Blink mode */
CORSAIR_LIGHTING_NODE_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
CORSAIR_LIGHTING_NODE_MODE_RAINBOW = 0x0A, /* Rainbow mode */
};
class CorsairLightingNodeController
{
public:
CorsairLightingNodeController(libusb_device_handle* dev_handle, unsigned int dev_endpoint);
~CorsairLightingNodeController();
std::string GetFirmwareString();
unsigned int GetStripsOnChannel(unsigned int channel);
void SetChannelEffect(unsigned char channel,
unsigned char num_leds,
unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2,
unsigned char red3,
unsigned char grn3,
unsigned char blu3
);
void SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors);
void KeepaliveThread();
private:
libusb_device_handle* dev;
unsigned int endpoint;
std::string firmware_version;
void SendFirmwareRequest();
void SendDirect
(
unsigned char channel,
unsigned char start,
unsigned char count,
unsigned char color_channel,
unsigned char* color_data
);
void SendCommit();
void SendBegin
(
unsigned char channel
);
void SendEffectConfig
(
unsigned char channel,
unsigned char count,
unsigned char led_type,
unsigned char mode,
unsigned char speed,
unsigned char direction,
unsigned char change_style,
unsigned char color_0_red,
unsigned char color_0_green,
unsigned char color_0_blue,
unsigned char color_1_red,
unsigned char color_1_green,
unsigned char color_1_blue,
unsigned char color_2_red,
unsigned char color_2_green,
unsigned char color_2_blue,
unsigned short temperature_0,
unsigned short temperature_1,
unsigned short temperature_2
);
void SendTemperature();
void SendReset
(
unsigned char channel
);
void SendPortState
(
unsigned char channel,
unsigned char state
);
void SendBrightness();
void SendLEDCount();
void SendProtocol();
};
@@ -0,0 +1,67 @@
#include "CorsairLightingNodeController.h"
#include "RGBController.h"
#include "RGBController_CorsairLightingNode.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#define CORSAIR_VID 0x1B1C
#define CORSAIR_LIGHTING_NODE_CORE_PID 0x0C1A
#define CORSAIR_LIGHTING_NODE_PRO_PID 0x0C0B
#define CORSAIR_COMMANDER_PRO_PID 0x0C10
#define CORSAIR_LS100_PID 0x0C1E
#define CORSAIR_1000D_OBSIDIAN_PID 0x1D00
#define CORSAIR_SPEC_OMEGA_RGB_PID 0x1D04
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_endpoint;
unsigned char channel_count;
const char * name;
} corsair_node_device;
static const corsair_node_device device_list[6] =
{
{ CORSAIR_VID, CORSAIR_LIGHTING_NODE_CORE_PID, 1, 1, "Corsair Lighting Node Core" },
{ CORSAIR_VID, CORSAIR_LIGHTING_NODE_PRO_PID, 1, 2, "Corsair Lighting Node Pro" },
{ CORSAIR_VID, CORSAIR_COMMANDER_PRO_PID, 2, 2, "Corsair Commander Pro" },
{ CORSAIR_VID, CORSAIR_LS100_PID, 1, 1, "Corsair LS100 Lighting Kit" },
{ CORSAIR_VID, CORSAIR_1000D_OBSIDIAN_PID, 2, 2, "Corsair 1000D Obsidian" },
{ CORSAIR_VID, CORSAIR_SPEC_OMEGA_RGB_PID, 1, 2, "Corsair SPEC OMEGA RGB" }
};
/******************************************************************************************\
* *
* DetectCorsairLightingNodeControllers *
* *
* Detect devices supported by the Corsair Lighting Node Pro driver *
* * *
\******************************************************************************************/
void DetectCorsairLightingNodeControllers(std::vector<RGBController*> &rgb_controllers)
{
libusb_context * ctx;
libusb_init(&ctx);
for(int device_idx = 0; device_idx < 6; device_idx++)
{
//Look for Corsair Lighting Node Device
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
if( dev )
{
libusb_detach_kernel_driver(dev, 0);
libusb_claim_interface(dev, 0);
CorsairLightingNodeController* controller = new CorsairLightingNodeController(dev, device_list[device_idx].usb_endpoint);
RGBController_CorsairLightingNode* rgb_controller = new RGBController_CorsairLightingNode(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
} /* DetectCorsairLightingNodeControllers() */
@@ -1,173 +0,0 @@
/*---------------------------------------------------------*\
| Definitions for Corsair Lighting Node Pro |
| |
| Adam Honse ([email protected]), 1/12/2020 |
\*---------------------------------------------------------*/
#include "RGBController.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#pragma once
enum
{
CORSAIR_CMDR_PRO_PACKET_ID_DIRECT = 0x32, /* Direct mode LED update packet */
CORSAIR_CMDR_PRO_PACKET_ID_COMMIT = 0x33, /* Commit changes packet */
CORSAIR_CMDR_PRO_PACKET_ID_BEGIN = 0x34, /* Begin effect packet */
CORSAIR_CMDR_PRO_PACKET_ID_EFFECT_CONFIG = 0x35, /* Effect mode configuration packet */
CORSAIR_CMDR_PRO_PACKET_ID_TEMPERATURE = 0x36, /* Update temperature value packet */
CORSAIR_CMDR_PRO_PACKET_ID_RESET = 0x37, /* Reset channel packet */
CORSAIR_CMDR_PRO_PACKET_ID_PORT_STATE = 0x38, /* Set port state packet */
CORSAIR_CMDR_PRO_PACKET_ID_BRIGHTNESS = 0x39, /* Set brightness packet */
CORSAIR_CMDR_PRO_PACKET_ID_LED_COUNT = 0x3A, /* Set LED count packet */
CORSAIR_CMDR_PRO_PACKET_ID_PROTOCOL = 0x3B, /* Set protocol packet */
};
enum
{
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_RED = 0x00, /* Red channel for direct update */
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_GREEN = 0x01, /* Green channel for direct update */
CORSAIR_CMDR_PRO_DIRECT_CHANNEL_BLUE = 0x02, /* Blue channel for direct update */
};
enum
{
CORSAIR_CMDR_PRO_PORT_STATE_HARDWARE = 0x01, /* Effect hardware control of channel */
CORSAIR_CMDR_PRO_PORT_STATE_SOFTWARE = 0x02, /* Direct software control of channel */
};
enum
{
CORSAIR_CMDR_PRO_LED_TYPE_LED_STRIP = 0x0A, /* Corsair LED Strip Type */
CORSAIR_CMDR_PRO_LED_TYPE_HD_FAN = 0x0C, /* Corsair HD-series Fan Type */
CORSAIR_CMDR_PRO_LED_TYPE_SP_FAN = 0x01, /* Corsair SP-series Fan Type */
CORSAIR_CMDR_PRO_LED_TYPE_ML_FAN = 0x02, /* Corsair ML-series Fan Type */
};
enum
{
CORSAIR_CMDR_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
CORSAIR_CMDR_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
CORSAIR_CMDR_PRO_NUM_CHANNELS = 0x02, /* Number of channels */
};
enum
{
CORSAIR_CMDR_PRO_SPEED_FAST = 0x00, /* Fast speed */
CORSAIR_CMDR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
CORSAIR_CMDR_PRO_SPEED_SLOW = 0x02, /* Slow speed */
};
enum
{
CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE = 0x00, /* Rainbow Wave mode */
CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT = 0x01, /* Color Shift mode */
CORSAIR_CMDR_PRO_MODE_COLOR_PULSE = 0x02, /* Color Pulse mode */
CORSAIR_CMDR_PRO_MODE_COLOR_WAVE = 0x03, /* Color Wave mode */
CORSAIR_CMDR_PRO_MODE_STATIC = 0x04, /* Static mode */
CORSAIR_CMDR_PRO_MODE_TEMPERATURE = 0x05, /* Temperature mode */
CORSAIR_CMDR_PRO_MODE_VISOR = 0x06, /* Visor mode */
CORSAIR_CMDR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
CORSAIR_CMDR_PRO_MODE_BLINK = 0x08, /* Blink mode */
CORSAIR_CMDR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
CORSAIR_CMDR_PRO_MODE_RAINBOW = 0x0A, /* Rainbow mode */
};
enum
{
CORSAIR_NODE_PRO_CHANNEL_1 = 0x00, /* Channel 1 */
CORSAIR_NODE_PRO_CHANNEL_2 = 0x01, /* Channel 2 */
CORSAIR_NODE_PRO_NUM_CHANNELS = 0x02 /* Number of channels */
};
class CorsairNodeProController
{
public:
CorsairNodeProController(libusb_device_handle* dev_handle);
~CorsairNodeProController();
unsigned int GetStripsOnChannel(unsigned int channel);
void SetChannelEffect(unsigned char channel,
unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
unsigned char red1,
unsigned char grn1,
unsigned char blu1,
unsigned char red2,
unsigned char grn2,
unsigned char blu2,
unsigned char red3,
unsigned char grn3,
unsigned char blu3
);
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
unsigned int channel_leds[CORSAIR_NODE_PRO_NUM_CHANNELS];
void KeepaliveThread();
private:
libusb_device_handle* dev;
void SendDirect
(
unsigned char channel,
unsigned char start,
unsigned char count,
unsigned char color_channel,
unsigned char* color_data
);
void SendCommit();
void SendBegin
(
unsigned char channel
);
void SendEffectConfig
(
unsigned char channel,
unsigned char count,
unsigned char led_type,
unsigned char mode,
unsigned char speed,
unsigned char direction,
unsigned char change_style,
unsigned char color_0_red,
unsigned char color_0_green,
unsigned char color_0_blue,
unsigned char color_1_red,
unsigned char color_1_green,
unsigned char color_1_blue,
unsigned char color_2_red,
unsigned char color_2_green,
unsigned char color_2_blue,
unsigned short temperature_0,
unsigned short temperature_1,
unsigned short temperature_2
);
void SendTemperature();
void SendReset
(
unsigned char channel
);
void SendPortState
(
unsigned char channel,
unsigned char state
);
void SendBrightness();
void SendLEDCount();
void SendProtocol();
};
@@ -1,37 +0,0 @@
#include "CorsairNodeProController.h"
#include "RGBController.h"
#include "RGBController_CorsairNodePro.h"
#include <vector>
#include <libusb-1.0/libusb.h>
#define CORSAIR_LIGHTING_NODE_PRO_VID 0x1B1C
#define CORSAIR_LIGHTING_NODE_PRO_PID 0x0C0B
/******************************************************************************************\
* *
* DetectCorsairNodeProControllers *
* *
* Detect devices supported by the Corsair Lighting Node Pro driver *
* * *
\******************************************************************************************/
void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controllers)
{
libusb_context * ctx;
libusb_init(&ctx);
//Look for Corsair Lighting Node Pro
libusb_device_handle * dev = libusb_open_device_with_vid_pid(ctx, CORSAIR_LIGHTING_NODE_PRO_VID, CORSAIR_LIGHTING_NODE_PRO_PID);
if( dev )
{
libusb_detach_kernel_driver(dev, 0);
libusb_claim_interface(dev, 0);
CorsairNodeProController* controller = new CorsairNodeProController(dev);
RGBController_CorsairNodePro* rgb_controller = new RGBController_CorsairNodePro(controller);
rgb_controllers.push_back(rgb_controller);
}
} /* DetectCorsairNodeProControllers() */
@@ -0,0 +1,487 @@
/*-----------------------------------------*\
| CorsairPeripheralController.cpp |
| |
| Driver for Corsair RGB keyboard, mouse, |
| and mousemat lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/9/2020 |
\*-----------------------------------------*/
#include "CorsairPeripheralController.h"
#include <cstring>
static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
0x27, 0x28, 0x2A, 0x2B, 0x2C, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39,
0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x42, 0x43, 0x44, 0x45, 0x48, 73, 74, 75, 76, 78,
79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 96, 97,
98, 99, 100, 101, 102, 103, 104, 105, 108, 109, 110, 111, 112, 113, 115,
116, 117, 120, 121, 122, 123, 124, 126, 127, 128, 129, 132, 133, 134, 135,
136, 137, 139, 140, 141};
static void send_usb_msg(hid_device* dev, char * data_pkt)
{
char usb_pkt[65];
usb_pkt[0] = 0x00;
for(int i = 1; i < 65; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
int bytes = hid_send_feature_report(dev, (unsigned char *)usb_pkt, 65);
bytes++;
}
CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle)
{
dev = dev_handle;
ReadFirmwareInfo();
SpecialFunctionControl();
LightingControl();
}
CorsairPeripheralController::~CorsairPeripheralController()
{
}
device_type CorsairPeripheralController::GetDeviceType()
{
return type;
}
std::string CorsairPeripheralController::GetFirmwareString()
{
return firmware_version;
}
void CorsairPeripheralController::SetLEDs(std::vector<RGBColor>colors)
{
switch(type)
{
case DEVICE_TYPE_KEYBOARD:
SetLEDsKeyboardFull(colors);
break;
case DEVICE_TYPE_MOUSE:
SetLEDsMouse(colors);
break;
case DEVICE_TYPE_MOUSEMAT:
SetLEDsMousemat(colors);
break;
}
}
void CorsairPeripheralController::SetLEDsKeyboardFull(std::vector<RGBColor> colors)
{
unsigned char red_val[144];
unsigned char grn_val[144];
unsigned char blu_val[144];
/*-----------------------------------------------------*\
| Zero out buffers |
\*-----------------------------------------------------*/
memset(red_val, 0x00, sizeof( red_val ));
memset(grn_val, 0x00, sizeof( grn_val ));
memset(blu_val, 0x00, sizeof( blu_val ));
/*-----------------------------------------------------*\
| Copy red, green, and blue components into buffers |
\*-----------------------------------------------------*/
for(std::size_t color_idx = 0; color_idx < colors.size(); color_idx++)
{
RGBColor color = colors[color_idx];
red_val[keys[color_idx]] = RGBGetRValue(color);
grn_val[keys[color_idx]] = RGBGetGValue(color);
blu_val[keys[color_idx]] = RGBGetBValue(color);
}
/*-----------------------------------------------------*\
| Send red bytes |
\*-----------------------------------------------------*/
StreamPacket(1, 60, &red_val[0]);
StreamPacket(2, 60, &red_val[60]);
StreamPacket(3, 24, &red_val[120]);
SubmitKeyboardFullColors(1, 3, 1);
/*-----------------------------------------------------*\
| Send green bytes |
\*-----------------------------------------------------*/
StreamPacket(1, 60, &grn_val[0]);
StreamPacket(2, 60, &grn_val[60]);
StreamPacket(3, 24, &grn_val[120]);
SubmitKeyboardFullColors(2, 3, 1);
/*-----------------------------------------------------*\
| Send blue bytes |
\*-----------------------------------------------------*/
StreamPacket(1, 60, &blu_val[0]);
StreamPacket(2, 60, &blu_val[60]);
StreamPacket(3, 24, &blu_val[120]);
SubmitKeyboardFullColors(3, 3, 2);
}
void CorsairPeripheralController::SetLEDsMouse(std::vector<RGBColor> colors)
{
SubmitMouseColors(colors.size(), &colors[0]);
}
void CorsairPeripheralController::SetLEDsMousemat(std::vector<RGBColor> colors)
{
SubmitMousematColors(colors.size(), &colors[0]);
}
void CorsairPeripheralController::SetLEDsKeyboardLimited(std::vector<RGBColor> colors)
{
unsigned char data_pkt[216];
unsigned char red_val[144];
unsigned char grn_val[144];
unsigned char blu_val[144];
/*-----------------------------------------------------*\
| Zero out buffers |
\*-----------------------------------------------------*/
memset(data_pkt, 0x00, sizeof( data_pkt ));
memset(red_val, 0x00, sizeof( red_val ));
memset(grn_val, 0x00, sizeof( grn_val ));
memset(blu_val, 0x00, sizeof( blu_val ));
/*-----------------------------------------------------*\
| Scale color values to 9-bit |
\*-----------------------------------------------------*/
for(std::size_t color_idx = 0; color_idx < colors.size(); color_idx++)
{
RGBColor color = colors[color_idx];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if( red > 7 ) red = 7;
if( grn > 7 ) grn = 7;
if( blu > 7 ) blu = 7;
red = 7 - red;
grn = 7 - grn;
blu = 7 - blu;
red_val[keys[color_idx]] = red;
grn_val[keys[color_idx]] = grn;
blu_val[keys[color_idx]] = blu;
}
/*-----------------------------------------------------*\
| Pack the color values, 2 values per byte |
\*-----------------------------------------------------*/
for(int red_idx = 0; red_idx < 72; red_idx++)
{
data_pkt[red_idx] = red_val[(red_idx * 2) + 1] << 4 | red_val[red_idx * 2];
}
for(int grn_idx = 0; grn_idx < 72; grn_idx++)
{
data_pkt[grn_idx + 72] = grn_val[(grn_idx * 2) + 1] << 4 | grn_val[grn_idx * 2];
}
for(int blu_idx = 0; blu_idx < 72; blu_idx++)
{
data_pkt[blu_idx + 144] = blu_val[(blu_idx * 2) + 1] << 4 | blu_val[blu_idx * 2];
}
/*-----------------------------------------------------*\
| Send the packets |
\*-----------------------------------------------------*/
StreamPacket(1, 60, &data_pkt[0]);
StreamPacket(2, 60, &data_pkt[60]);
StreamPacket(3, 60, &data_pkt[120]);
StreamPacket(4, 36, &data_pkt[180]);
SubmitKeyboardLimitedColors(216);
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void CorsairPeripheralController::LightingControl()
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_LIGHTING_CONTROL;
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
/*-----------------------------------------------------*\
| Lighting control byte needs to be 3 for keyboards, 1 |
| for mice and mousepads |
\*-----------------------------------------------------*/
switch(type)
{
default:
case DEVICE_TYPE_KEYBOARD:
usb_buf[0x04] = 0x03;
break;
case DEVICE_TYPE_MOUSE:
usb_buf[0x04] = 0x01;
break;
case DEVICE_TYPE_MOUSEMAT:
usb_buf[0x04] = 0x04;
break;
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairPeripheralController::SpecialFunctionControl()
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SPECIAL_FUNCTION;
usb_buf[0x02] = CORSAIR_LIGHTING_CONTROL_SOFTWARE;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairPeripheralController::ReadFirmwareInfo()
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Read Firmware Info packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_READ;
usb_buf[0x01] = CORSAIR_PROPERTY_FIRMWARE_INFO;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
hid_get_feature_report(dev, (unsigned char*)usb_buf, 64);
/*-----------------------------------------------------*\
| Get device type |
| 0xC0 Device is a keyboard |
| 0xC1 Device is a mouse |
| 0xC2 Device is a mousepad |
\*-----------------------------------------------------*/
switch((unsigned char)usb_buf[0x14])
{
case 0xC0:
type = DEVICE_TYPE_KEYBOARD;
break;
case 0xC1:
type = DEVICE_TYPE_MOUSE;
break;
case 0xC2:
type = DEVICE_TYPE_MOUSEMAT;
break;
default:
type = DEVICE_TYPE_UNKNOWN;
break;
}
/*-----------------------------------------------------*\
| Format firmware version string if device type is valid|
\*-----------------------------------------------------*/
if(type != DEVICE_TYPE_UNKNOWN)
{
firmware_version = std::to_string(usb_buf[0x09]) + "." + std::to_string(usb_buf[0x08]);
}
}
void CorsairPeripheralController::StreamPacket
(
unsigned char packet_id,
unsigned char data_sz,
unsigned char* data_ptr
)
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Stream packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_STREAM;
usb_buf[0x01] = packet_id;
usb_buf[0x02] = data_sz;
/*-----------------------------------------------------*\
| Copy in data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x04], data_ptr, data_sz);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairPeripheralController::SubmitKeyboardFullColors
(
unsigned char color_channel,
unsigned char packet_count,
unsigned char finish_val
)
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Submit Keyboard 24-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_24;
usb_buf[0x02] = color_channel;
usb_buf[0x03] = packet_count;
usb_buf[0x04] = finish_val;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairPeripheralController::SubmitKeyboardLimitedColors
(
unsigned char byte_count
)
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Submit Keyboard 9-Bit Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_KEYBOARD_COLOR_9;
usb_buf[0x04] = byte_count;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairPeripheralController::SubmitMouseColors
(
unsigned char num_zones,
RGBColor * color_data
)
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Submit Mouse Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x02] = num_zones;
usb_buf[0x03] = 0x00;
/*-----------------------------------------------------*\
| Copy in colors in <ZONE> <RED> <GREEN> <BLUE> order |
\*-----------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < num_zones; zone_idx++)
{
usb_buf[(zone_idx * 4) + 4] = zone_idx;
usb_buf[(zone_idx * 4) + 5] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 6] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 4) + 7] = RGBGetBValue(color_data[zone_idx]);
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
void CorsairPeripheralController::SubmitMousematColors
(
unsigned char num_zones,
RGBColor * color_data
)
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Submit Mouse Colors packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = CORSAIR_COMMAND_WRITE;
usb_buf[0x01] = CORSAIR_PROPERTY_SUBMIT_MOUSE_COLOR;
usb_buf[0x02] = num_zones;
usb_buf[0x03] = 0x00;
/*-----------------------------------------------------*\
| Copy in colors in <ZONE> <RED> <GREEN> <BLUE> order |
\*-----------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < num_zones; zone_idx++)
{
//usb_buf[(zone_idx * 4) + 4] = zone_idx;
usb_buf[(zone_idx * 3) + 4] = RGBGetRValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 5] = RGBGetGValue(color_data[zone_idx]);
usb_buf[(zone_idx * 3) + 6] = RGBGetBValue(color_data[zone_idx]);
}
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf);
}
@@ -1,8 +1,9 @@
/*-----------------------------------------*\
| CorsairKeyboardController.h |
| CorsairPeripheralController.h |
| |
| Definitions and types for Corsair RGB |
| keyboard lighting controller |
| keyboard, mouse, and mousemat lighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 1/9/2020 |
\*-----------------------------------------*/
@@ -46,19 +47,29 @@ enum
CORSAIR_COLOR_CHANNEL_BLUE = 0x03
};
class CorsairKeyboardController
class CorsairPeripheralController
{
public:
CorsairKeyboardController(hid_device* dev_handle);
~CorsairKeyboardController();
CorsairPeripheralController(hid_device* dev_handle);
~CorsairPeripheralController();
void SetLEDsDirect(std::vector<RGBColor> colors);
void SetLEDs(std::vector<RGBColor> colors);
device_type GetDeviceType();
std::string GetFirmwareString();
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);
private:
hid_device* dev;
std::string firmware_version;
device_type type;
void LightingControl();
void SpecialFunctionControl();
void ReadFirmwareInfo();
@@ -69,10 +80,27 @@ private:
unsigned char* data_ptr
);
void SubmitColors();
void SubmitKeyboardFullColors
(
unsigned char color_channel,
unsigned char packet_count,
unsigned char finish_val
);
void SubmitLimitedColors
void SubmitKeyboardLimitedColors
(
unsigned char byte_count
);
void SubmitMouseColors
(
unsigned char num_zones,
RGBColor * color_data
);
void SubmitMousematColors
(
unsigned char num_zones,
RGBColor * color_data
);
};
@@ -0,0 +1,137 @@
#include "CorsairPeripheralController.h"
#include "RGBController.h"
#include "RGBController_CorsairPeripheral.h"
#include <vector>
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
| Corsair vendor ID |
\*-----------------------------------------------------*/
#define CORSAIR_VID 0x1B1C
/*-----------------------------------------------------*\
| Keyboard product IDs |
| List taken from ckb-next |
| Non-RGB keyboards were omitted from this list |
\*-----------------------------------------------------*/
#define CORSAIR_K55_RGB_PID 0x1B3D
#define CORSAIR_K65_RGB_PID 0x1B17
#define CORSAIR_K65_LUX_RGB_PID 0x1B37
#define CORSAIR_K65_RGB_RAPIDFIRE_PID 0x1B39
#define CORSAIR_K68_RGB 0x1B4F
#define CORSAIR_K70_RGB_PID 0x1B13
#define CORSAIR_K70_LUX_RGB_PID 0x1B33
#define CORSAIR_K70_RGB_RAPIDFIRE_PID 0x1B38
#define CORSAIR_K70_RGB_MK2_PID 0x1B38
#define CORSAIR_K70_RGB_MK2_SE_PID 0x1B6B
#define CORSAIR_K70_RGB_MK2_LP_PID 0x1B55
#define CORSAIR_K95_RGB_PID 0x1B11
#define CORSAIR_K95_PLATINUM_PID 0x1B2D
#define CORSAIR_STRAFE_PID 0x1B20
#define CORSAIR_STRAFE_MK2_PID 0x1B48
/*-----------------------------------------------------*\
| Mouse product IDs |
| List taken from ckb-next |
\*-----------------------------------------------------*/
#define CORSAIR_M65_PRO_PID 0x1B2E
#define CORSAIR_M65_RGB_ELITE_PID 0x1B5A
/*-----------------------------------------------------*\
| Mousepad product IDs |
| List taken from ckb-next |
\*-----------------------------------------------------*/
#define CORSAIR_MM800_RGB_POLARIS_PID 0x1B3B
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_interface;
const char * name;
} corsair_node_device;
#define CORSAIR_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const corsair_node_device device_list[] =
{
/*-----------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-----------------------------------------------------------------------------------------------------*/
{ CORSAIR_VID, CORSAIR_K68_RGB, 1, "Corsair K68 RGB" },
{ CORSAIR_VID, CORSAIR_K70_RGB_PID, 1, "Corsair K70 RGB" },
{ CORSAIR_VID, CORSAIR_K70_LUX_RGB_PID, 1, "Corsair K70 LUX RGB" },
{ CORSAIR_VID, CORSAIR_K70_RGB_RAPIDFIRE_PID, 1, "Corsair K70 RGB RAPIDFIRE" },
{ CORSAIR_VID, CORSAIR_K70_RGB_MK2_PID, 1, "Corsair K70 RGB MK.2" },
{ CORSAIR_VID, CORSAIR_K70_RGB_MK2_SE_PID, 1, "Corsair K70 RGB MK.2 SE" },
{ CORSAIR_VID, CORSAIR_K70_RGB_MK2_LP_PID, 1, "Corsair K70 RGB MK.2 Low Profile" },
{ CORSAIR_VID, CORSAIR_K95_RGB_PID, 1, "Corsair K95 RGB" },
{ CORSAIR_VID, CORSAIR_K95_PLATINUM_PID, 1, "Corsair K95 RGB PLATINUM" },
/*-----------------------------------------------------------------------------------------------------*\
| Mice |
\*-----------------------------------------------------------------------------------------------------*/
{ CORSAIR_VID, CORSAIR_M65_PRO_PID, 1, "Corsair M65 PRO" },
{ CORSAIR_VID, CORSAIR_M65_RGB_ELITE_PID, 1, "Corsair M65 RGB Elite" },
/*-----------------------------------------------------------------------------------------------------*\
| Mousemats |
\*-----------------------------------------------------------------------------------------------------*/
{ CORSAIR_VID, CORSAIR_MM800_RGB_POLARIS_PID, 0, "Corsair MM800 RGB Polaris" }
};
/******************************************************************************************\
* *
* DetectCorsairPeripheralControllers *
* *
* Tests the USB address to see if a Corsair RGB Keyboard controller exists there. *
* *
\******************************************************************************************/
void DetectCorsairPeripheralControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
hid_init();
for(std::size_t device_idx = 0; device_idx < CORSAIR_NUM_DEVICES; device_idx++)
{
dev = NULL;
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
//Look for Corsair RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
CorsairPeripheralController* controller = new CorsairPeripheralController(dev);
if(controller->GetDeviceType() != DEVICE_TYPE_UNKNOWN)
{
RGBController_CorsairPeripheral* rgb_controller = new RGBController_CorsairPeripheral(controller);
rgb_controller->name = device_list[device_idx].name;
rgb_controllers.push_back(rgb_controller);
}
}
}
}
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| CorsairController.h |
| CorsairVengeanceController.h |
| |
| Driver for Corsair Vengeance RGB RAM |
| lighting controller |
@@ -7,10 +7,10 @@
| Adam Honse (CalcProgrammer1) 3/8/2019 |
\*-----------------------------------------*/
#include "CorsairController.h"
#include "CorsairVengeanceController.h"
#include <cstring>
CorsairController::CorsairController(i2c_smbus_interface* bus, corsair_dev_id dev)
CorsairVengeanceController::CorsairVengeanceController(i2c_smbus_interface* bus, corsair_dev_id dev)
{
this->bus = bus;
this->dev = dev;
@@ -19,17 +19,17 @@ CorsairController::CorsairController(i2c_smbus_interface* bus, corsair_dev_id de
led_count = 1;
}
CorsairController::~CorsairController()
CorsairVengeanceController::~CorsairVengeanceController()
{
}
std::string CorsairController::GetDeviceName()
std::string CorsairVengeanceController::GetDeviceName()
{
return(device_name);
}
std::string CorsairController::GetDeviceLocation()
std::string CorsairVengeanceController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
@@ -39,12 +39,12 @@ std::string CorsairController::GetDeviceLocation()
return(return_string);
}
unsigned int CorsairController::GetLEDCount()
unsigned int CorsairVengeanceController::GetLEDCount()
{
return(led_count);
}
void CorsairController::SetLEDColor(unsigned char red, unsigned char green, unsigned char blue)
void CorsairVengeanceController::SetLEDColor(unsigned char red, unsigned char green, unsigned char blue)
{
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_FADE_TIME, 0x00);
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_RED_VAL, red);
@@ -53,7 +53,7 @@ void CorsairController::SetLEDColor(unsigned char red, unsigned char green, unsi
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
}
void CorsairController::SetMode(unsigned char /*mode*/)
void CorsairVengeanceController::SetMode(unsigned char /*mode*/)
{
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
}
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| CorsairController.h |
| CorsairVengeanceController.h |
| |
| Definitions and types for Corsair |
| Vengeance RGB RAM lighting controller |
@@ -33,11 +33,11 @@ enum
CORSAIR_NUMBER_MODES /* Number of Corsair modes */
};
class CorsairController
class CorsairVengeanceController
{
public:
CorsairController(i2c_smbus_interface* bus, corsair_dev_id dev);
~CorsairController();
CorsairVengeanceController(i2c_smbus_interface* bus, corsair_dev_id dev);
~CorsairVengeanceController();
std::string GetDeviceName();
std::string GetDeviceLocation();
@@ -1,6 +1,6 @@
#include "CorsairController.h"
#include "CorsairVengeanceController.h"
#include "RGBController.h"
#include "RGBController_Corsair.h"
#include "RGBController_CorsairVengeance.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
@@ -8,13 +8,13 @@
/******************************************************************************************\
* *
* TestForCorsairController *
* TestForCorsairVengeanceController *
* *
* Tests the given address to see if a Corsair controller exists there. *
* *
\******************************************************************************************/
bool TestForCorsairController(i2c_smbus_interface* bus, unsigned char address)
bool TestForCorsairVengeanceController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
@@ -37,11 +37,11 @@ bool TestForCorsairController(i2c_smbus_interface* bus, unsigned char address)
return(pass);
} /* TestForCorsairController() */
} /* TestForCorsairVengeanceController() */
/******************************************************************************************\
* *
* DetectCorsairControllers *
* DetectCorsairVengeanceControllers *
* *
* Detect Corsair controllers on the enumerated I2C busses. *
* *
@@ -50,76 +50,76 @@ bool TestForCorsairController(i2c_smbus_interface* bus, unsigned char address)
* *
\******************************************************************************************/
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
void DetectCorsairVengeanceControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
CorsairController* new_corsair;
RGBController_Corsair* new_controller;
CorsairVengeanceController* new_corsair;
RGBController_CorsairVengeance* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Check for Corsair controller at 0x58
if (TestForCorsairController(busses[bus], 0x58))
if (TestForCorsairVengeanceController(busses[bus], 0x58))
{
new_corsair = new CorsairController(busses[bus], 0x58);
new_controller = new RGBController_Corsair(new_corsair);
new_corsair = new CorsairVengeanceController(busses[bus], 0x58);
new_controller = new RGBController_CorsairVengeance(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x59
if (TestForCorsairController(busses[bus], 0x59))
if (TestForCorsairVengeanceController(busses[bus], 0x59))
{
new_corsair = new CorsairController(busses[bus], 0x59);
new_controller = new RGBController_Corsair(new_corsair);
new_corsair = new CorsairVengeanceController(busses[bus], 0x59);
new_controller = new RGBController_CorsairVengeance(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5A
if (TestForCorsairController(busses[bus], 0x5A))
if (TestForCorsairVengeanceController(busses[bus], 0x5A))
{
new_corsair = new CorsairController(busses[bus], 0x5A);
new_controller = new RGBController_Corsair(new_corsair);
new_corsair = new CorsairVengeanceController(busses[bus], 0x5A);
new_controller = new RGBController_CorsairVengeance(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5B
if (TestForCorsairController(busses[bus], 0x5B))
if (TestForCorsairVengeanceController(busses[bus], 0x5B))
{
new_corsair = new CorsairController(busses[bus], 0x5B);
new_controller = new RGBController_Corsair(new_corsair);
new_corsair = new CorsairVengeanceController(busses[bus], 0x5B);
new_controller = new RGBController_CorsairVengeance(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5C
if (TestForCorsairController(busses[bus], 0x5C))
if (TestForCorsairVengeanceController(busses[bus], 0x5C))
{
new_corsair = new CorsairController(busses[bus], 0x5C);
new_controller = new RGBController_Corsair(new_corsair);
new_corsair = new CorsairVengeanceController(busses[bus], 0x5C);
new_controller = new RGBController_CorsairVengeance(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5D
if (TestForCorsairController(busses[bus], 0x5D))
if (TestForCorsairVengeanceController(busses[bus], 0x5D))
{
new_corsair = new CorsairController(busses[bus], 0x5D);
new_controller = new RGBController_Corsair(new_corsair);
new_corsair = new CorsairVengeanceController(busses[bus], 0x5D);
new_controller = new RGBController_CorsairVengeance(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5E
if (TestForCorsairController(busses[bus], 0x5E))
if (TestForCorsairVengeanceController(busses[bus], 0x5E))
{
new_corsair = new CorsairController(busses[bus], 0x5E);
new_controller = new RGBController_Corsair(new_corsair);
new_corsair = new CorsairVengeanceController(busses[bus], 0x5E);
new_controller = new RGBController_CorsairVengeance(new_corsair);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5F
if (TestForCorsairController(busses[bus], 0x5F))
if (TestForCorsairVengeanceController(busses[bus], 0x5F))
{
new_corsair = new CorsairController(busses[bus], 0x5F);
new_controller = new RGBController_Corsair(new_corsair);
new_corsair = new CorsairVengeanceController(busses[bus], 0x5F);
new_controller = new RGBController_CorsairVengeance(new_corsair);
rgb_controllers.push_back(new_controller);
}
}
} /* DetectCorsairControllers() */
} /* DetectCorsairVengeanceControllers() */
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| CorsairProController.cpp |
| CorsairVengeanceProController.cpp |
| |
| Definitions and types for Corsair |
| Vengeance Pro RGB RAM lighting controller|
@@ -7,7 +7,7 @@
| Adam Honse (CalcProgrammer1) 6/30/2019 |
\*-----------------------------------------*/
#include "CorsairProController.h"
#include "CorsairVengeanceProController.h"
#include <cstring>
#ifdef WIN32
@@ -21,7 +21,7 @@ static void Sleep(unsigned int milliseconds)
}
#endif
CorsairProController::CorsairProController(i2c_smbus_interface* bus, corsair_dev_id dev)
CorsairVengeanceProController::CorsairVengeanceProController(i2c_smbus_interface* bus, corsair_dev_id dev)
{
this->bus = bus;
this->dev = dev;
@@ -39,17 +39,17 @@ CorsairProController::CorsairProController(i2c_smbus_interface* bus, corsair_dev
}
}
CorsairProController::~CorsairProController()
CorsairVengeanceProController::~CorsairVengeanceProController()
{
}
std::string CorsairProController::GetDeviceName()
std::string CorsairVengeanceProController::GetDeviceName()
{
return(device_name);
}
std::string CorsairProController::GetDeviceLocation()
std::string CorsairVengeanceProController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
@@ -59,17 +59,17 @@ std::string CorsairProController::GetDeviceLocation()
return(return_string);
}
unsigned int CorsairProController::GetLEDCount()
unsigned int CorsairVengeanceProController::GetLEDCount()
{
return(led_count);
}
unsigned char CorsairProController::GetEffect()
unsigned char CorsairVengeanceProController::GetEffect()
{
return(effect_mode);
}
void CorsairProController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
void CorsairVengeanceProController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
{
for (unsigned int i = 0; i < led_count; i++)
{
@@ -79,14 +79,14 @@ void CorsairProController::SetAllColors(unsigned char red, unsigned char green,
}
}
void CorsairProController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
void CorsairVengeanceProController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
led_red[led] = red;
led_green[led] = green;
led_blue[led] = blue;
}
void CorsairProController::ApplyColors()
void CorsairVengeanceProController::ApplyColors()
{
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x02);
Sleep(1);
@@ -104,7 +104,7 @@ void CorsairProController::ApplyColors()
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x02);
}
void CorsairProController::SetEffect(unsigned char mode,
void CorsairVengeanceProController::SetEffect(unsigned char mode,
unsigned char speed,
unsigned char direction,
bool random,
@@ -159,7 +159,7 @@ void CorsairProController::SetEffect(unsigned char mode,
WaitReady();
}
bool CorsairProController::WaitReady()
bool CorsairVengeanceProController::WaitReady()
{
int i = 0;
while (bus->i2c_smbus_read_byte_data(dev, 0x41) != 0x00)
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| CorsairProController.h |
| CorsairVengeanceProController.h |
| |
| Definitions and types for Corsair |
| Vengeance Pro RGB RAM lighting controller|
@@ -60,11 +60,11 @@ enum
CORSAIR_PRO_DIRECTION_HORIZONTAL = 0x03, /* Horizontal direction */
};
class CorsairProController
class CorsairVengeanceProController
{
public:
CorsairProController(i2c_smbus_interface* bus, corsair_dev_id dev);
~CorsairProController();
CorsairVengeanceProController(i2c_smbus_interface* bus, corsair_dev_id dev);
~CorsairVengeanceProController();
std::string GetDeviceName();
std::string GetDeviceLocation();
@@ -1,6 +1,6 @@
#include "CorsairProController.h"
#include "CorsairVengeanceProController.h"
#include "RGBController.h"
#include "RGBController_CorsairPro.h"
#include "RGBController_CorsairVengeancePro.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
@@ -19,13 +19,13 @@ static void Sleep(unsigned int milliseconds)
/******************************************************************************************\
* *
* TestForCorsairProController *
* TestForCorsairVengeanceProController *
* *
* Tests the given address to see if a Corsair Pro controller exists there. *
* *
\******************************************************************************************/
bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address)
bool TestForCorsairVengeanceProController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
@@ -44,7 +44,7 @@ bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address
res = bus->i2c_smbus_read_byte_data(address, 0x44);
if (res != 0x03)
if (!((res == 0x03) || (res == 0x04)))
{
pass = false;
}
@@ -54,89 +54,89 @@ bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address
return(pass);
} /* TestForCorsairProController() */
} /* TestForCorsairVengeanceProController() */
/******************************************************************************************\
* *
* DetectCorsairProControllers *
* DetectCorsairVengeanceProControllers *
* *
* Detect Corsair Pro controllers on the enumerated I2C busses. *
* Detect Corsair Vengeance Pro controllers on the enumerated I2C busses. *
* *
* bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device *
* *
\******************************************************************************************/
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
void DetectCorsairVengeanceProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
CorsairProController* new_corsair_pro;
RGBController_CorsairPro* new_controller;
CorsairVengeanceProController* new_corsair_pro;
RGBController_CorsairVengeancePro* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Check for Corsair controller at 0x58
if (TestForCorsairProController(busses[bus], 0x58))
if (TestForCorsairVengeanceProController(busses[bus], 0x58))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x58);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x58);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x59
if (TestForCorsairProController(busses[bus], 0x59))
if (TestForCorsairVengeanceProController(busses[bus], 0x59))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x59);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x59);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5A
if (TestForCorsairProController(busses[bus], 0x5A))
if (TestForCorsairVengeanceProController(busses[bus], 0x5A))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5A);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5A);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5B
if (TestForCorsairProController(busses[bus], 0x5B))
if (TestForCorsairVengeanceProController(busses[bus], 0x5B))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5B);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5B);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5C
if (TestForCorsairProController(busses[bus], 0x5C))
if (TestForCorsairVengeanceProController(busses[bus], 0x5C))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5C);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5C);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5D
if (TestForCorsairProController(busses[bus], 0x5D))
if (TestForCorsairVengeanceProController(busses[bus], 0x5D))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5D);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5D);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5E
if (TestForCorsairProController(busses[bus], 0x5E))
if (TestForCorsairVengeanceProController(busses[bus], 0x5E))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5E);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5E);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
// Check for Corsair controller at 0x5F
if (TestForCorsairProController(busses[bus], 0x5F))
if (TestForCorsairVengeanceProController(busses[bus], 0x5F))
{
new_corsair_pro = new CorsairProController(busses[bus], 0x5F);
new_controller = new RGBController_CorsairPro(new_corsair_pro);
new_corsair_pro = new CorsairVengeanceProController(busses[bus], 0x5F);
new_controller = new RGBController_CorsairVengeancePro(new_corsair_pro);
rgb_controllers.push_back(new_controller);
}
}
} /* DetectCorsairProControllers() */
} /* DetectCorsairVengeanceProControllers() */
@@ -52,16 +52,15 @@ void CrucialController::SetAllColorsDirect(RGBColor* colors)
SendDirectColors(colors);
}
void CrucialController::SendEffectColors(unsigned char red, unsigned char green, unsigned char blue)
void CrucialController::SetAllColorsEffect(RGBColor* colors)
{
CrucialRegisterWrite(0x82E9, 0xFF);
CrucialRegisterWrite(0x82EA, 0x00);
CrucialRegisterWrite(0x82EB, 0x00);
CrucialRegisterWrite(0x82EC, 0x00);
CrucialRegisterWrite(0x82ED, red);
CrucialRegisterWrite(0x82EE, green);
CrucialRegisterWrite(0x82EF, blue);
CrucialRegisterWrite(0x82F0, 0x01);
for(int led_idx = 0; led_idx < 8; led_idx++)
{
unsigned char red = RGBGetRValue(colors[led_idx]);
unsigned char grn = RGBGetGValue(colors[led_idx]);
unsigned char blu = RGBGetBValue(colors[led_idx]);
SendEffectColor(led_idx, red, grn, blu);
}
}
void CrucialController::SendBrightness(unsigned char brightness)
@@ -131,3 +130,21 @@ void CrucialController::CrucialRegisterWrite(crucial_register reg, unsigned char
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
}
void CrucialController::SendEffectColor
(
unsigned int led_idx,
unsigned int red,
unsigned int green,
unsigned int blue
)
{
CrucialRegisterWrite(0x82E9, (1 << led_idx));
CrucialRegisterWrite(0x82EA, 0x00);
CrucialRegisterWrite(0x82EB, 0x00);
CrucialRegisterWrite(0x82EC, 0x00);
CrucialRegisterWrite(0x82ED, red);
CrucialRegisterWrite(0x82EE, green);
CrucialRegisterWrite(0x82EF, blue);
CrucialRegisterWrite(0x82F0, 0x01);
}
@@ -42,6 +42,7 @@ public:
std::string GetDeviceLocation();
unsigned int GetLEDCount();
void SetAllColorsDirect(RGBColor* colors);
void SetAllColorsEffect(RGBColor* colors);
void SetMode(unsigned char mode);
unsigned char CrucialRegisterRead(crucial_register reg);
@@ -55,8 +56,15 @@ private:
i2c_smbus_interface * bus;
crucial_dev_id dev;
void SendEffectColor
(
unsigned int led_idx,
unsigned int red,
unsigned int green,
unsigned int blue
);
void SendDirectColors(RGBColor* color_buf);
void SendEffectColors(unsigned char red, unsigned char green, unsigned char blue);
void SendBrightness(unsigned char brightness);
void SendEffectMode(unsigned char mode, unsigned char speed);
};
+173 -48
View File
@@ -9,6 +9,7 @@
#include <fstream>
#include <iostream>
#include <string>
#include <cstring>
Hue2Controller::Hue2Controller(libusb_device_handle* dev_handle)
{
@@ -19,9 +20,7 @@ Hue2Controller::Hue2Controller(libusb_device_handle* dev_handle)
Hue2Controller::~Hue2Controller()
{
current_mode = HUE_2_MODE_FIXED;
current_speed = HUE_2_SPEED_NORMAL;
current_direction = false;
}
unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
@@ -89,73 +88,199 @@ unsigned int Hue2Controller::GetStripsOnChannel(unsigned int /*channel*/)
return(ret_val);
}
void Hue2Controller::SetMode(unsigned char mode, unsigned char speed, bool direction)
void Hue2Controller::SetChannelEffect
(
unsigned char channel,
unsigned char mode,
unsigned char speed,
bool direction,
RGBColor * colors,
unsigned int num_colors
)
{
current_mode = mode;
current_speed = speed;
current_direction = direction;
}
void Hue2Controller::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
{
unsigned char usb_buf[] =
{
0x28, 0x03, 0x00, 0x28,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
int actual = 0;
unsigned char color_data[24];
/*-----------------------------------------------------*\
| Set channel in USB packet |
| Fill in color data (up to 8 colors) |
\*-----------------------------------------------------*/
usb_buf[0x02] = 1 << channel;
for (std::size_t idx = 0; idx < num_colors; idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[idx];
color_data[pixel_idx + 0x00] = RGBGetGValue(color);
color_data[pixel_idx + 0x01] = RGBGetRValue(color);
color_data[pixel_idx + 0x02] = RGBGetBValue(color);
}
/*-----------------------------------------------------*\
| Send effect packet |
\*-----------------------------------------------------*/
SendEffect(channel, mode, speed, direction, num_colors, &color_data[0]);
}
void Hue2Controller::SetChannelLEDs
(
unsigned char channel,
RGBColor * colors,
unsigned int num_colors
)
{
unsigned char color_data[120];
/*-----------------------------------------------------*\
| Fill in color data (up to 40 colors) |
\*-----------------------------------------------------*/
for (std::size_t idx = 0; idx < num_colors; idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[idx];
color_data[pixel_idx + 0x00] = RGBGetGValue(color);
color_data[pixel_idx + 0x01] = RGBGetRValue(color);
color_data[pixel_idx + 0x02] = RGBGetBValue(color);
}
/*-----------------------------------------------------*\
| Send first group of color data |
\*-----------------------------------------------------*/
SendDirect(channel, 0, 20, &color_data[0]);
/*-----------------------------------------------------*\
| Send second group of color data if necessary |
\*-----------------------------------------------------*/
if(num_colors > 20)
{
SendDirect(channel, 1, 20, &color_data[60]);
}
/*-----------------------------------------------------*\
| Send apply packet |
\*-----------------------------------------------------*/
SendApply(channel);
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void Hue2Controller::SendApply
(
unsigned char channel
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Apply packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x22;
usb_buf[0x01] = 0xA0;
usb_buf[0x02] = (unsigned char)(1 << channel);
usb_buf[0x04] = 0x01;
usb_buf[0x07] = 0x28;
usb_buf[0x0A] = 0x80;
usb_buf[0x0C] = 0x32;
usb_buf[0x0F] = 0x01;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
}
void Hue2Controller::SendDirect
(
unsigned char channel,
unsigned char group,
unsigned char color_count,
unsigned char* color_data
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Direct packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x22;
usb_buf[0x01] = 0x10 | group;
usb_buf[0x02] = (unsigned char)(1 << channel);
usb_buf[0x03] = 0x00;
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x04], color_data, color_count * 3);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
}
void Hue2Controller::SendEffect
(
unsigned char channel,
unsigned char mode,
unsigned char speed,
bool direction,
unsigned char color_count,
unsigned char* color_data
)
{
int actual;
unsigned char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Effect packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x28;
usb_buf[0x01] = 0x03;
usb_buf[0x02] = (unsigned char)(1 << channel);
usb_buf[0x03] = 0x28;
/*-----------------------------------------------------*\
| Set mode in USB packet |
\*-----------------------------------------------------*/
usb_buf[0x04] = current_mode;
usb_buf[0x04] = mode;
/*-----------------------------------------------------*\
| Set speed in USB packet |
\*-----------------------------------------------------*/
usb_buf[0x05] = current_speed;
usb_buf[0x05] = speed;
/*-----------------------------------------------------*\
| Set direction in USB packet |
\*-----------------------------------------------------*/
usb_buf[0x06] = current_direction ? 0x01 : 0x00;
usb_buf[0x06] = direction ? 0x01 : 0x00;
/*-----------------------------------------------------*\
| Set color count in USB packet |
\*-----------------------------------------------------*/
usb_buf[0x08] = colors.size();
usb_buf[0x08] = color_count;
/*-----------------------------------------------------*\
| Fill in color data |
| Copy in color data bytes |
\*-----------------------------------------------------*/
for (std::size_t idx = 0; idx < colors.size(); idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[idx];
usb_buf[pixel_idx + 0x0A] = RGBGetGValue(color);
usb_buf[pixel_idx + 0x0B] = RGBGetRValue(color);
usb_buf[pixel_idx + 0x0C] = RGBGetBValue(color);
}
memcpy(&usb_buf[0x0A], color_data, color_count * 3);
libusb_interrupt_transfer(dev, 0x01, usb_buf, 64, &actual, 0);
libusb_interrupt_transfer(dev, 0x81, usb_buf, 64, &actual, 0);
}
}
+43 -6
View File
@@ -56,16 +56,53 @@ public:
Hue2Controller(libusb_device_handle* dev_handle);
~Hue2Controller();
unsigned int GetStripsOnChannel(unsigned int channel);
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
void SetMode(unsigned char mode, unsigned char speed, bool direction);
unsigned int GetStripsOnChannel
(
unsigned int channel
);
void SetChannelEffect
(
unsigned char channel,
unsigned char mode,
unsigned char speed,
bool direction,
RGBColor * colors,
unsigned int num_colors
);
void SetChannelLEDs
(
unsigned char channel,
RGBColor * colors,
unsigned int num_colors
);
unsigned int channel_leds[HUE_2_NUM_CHANNELS];
private:
libusb_device_handle* dev;
unsigned char current_mode;
unsigned char current_speed;
bool current_direction;
void SendApply
(
unsigned char channel
);
void SendDirect
(
unsigned char channel,
unsigned char group,
unsigned char color_count,
unsigned char* color_data
);
void SendEffect
(
unsigned char channel,
unsigned char mode,
unsigned char speed,
bool direction,
unsigned char color_count,
unsigned char* color_data
);
};
@@ -24,9 +24,7 @@ static void Sleep(unsigned int milliseconds)
HuePlusController::HuePlusController()
{
current_mode = HUE_PLUS_MODE_FIXED;
current_speed = HUE_PLUS_SPEED_NORMAL;
current_direction = false;
}
HuePlusController::~HuePlusController()
@@ -85,70 +83,119 @@ unsigned int HuePlusController::GetLEDsOnChannel(unsigned int channel)
return(ret_val);
}
void HuePlusController::SetMode(unsigned char mode, unsigned char speed, bool direction)
void HuePlusController::SetChannelEffect
(
unsigned char channel,
unsigned char mode,
unsigned char speed,
bool direction,
RGBColor * colors,
unsigned int num_colors
)
{
current_mode = mode;
current_speed = speed;
current_direction = direction;
}
unsigned char color_data[120];
void HuePlusController::SetModeColors(unsigned char channel, std::vector<RGBColor> colors)
{
unsigned char serial_buf[125];
for(int color_idx = 0; color_idx < colors.size(); color_idx++)
/*-----------------------------------------------------*\
| If mode requires no colors, send packet |
\*-----------------------------------------------------*/
if(num_colors == 0)
{
/*-----------------------------------------------------*\
| Zero out buffer |
| Send mode without color data |
\*-----------------------------------------------------*/
memset(serial_buf, 0x00, sizeof(serial_buf));
SendPacket(channel, mode, direction, 0, speed, 0, NULL);
}
/*-----------------------------------------------------*\
| If mode requires indexed colors, send color index |
| packets for each mode color |
\*-----------------------------------------------------*/
else if(num_colors <= 8)
{
for(std::size_t color_idx = 0; color_idx < num_colors; color_idx++)
{
/*-----------------------------------------------------*\
| Fill in color data (40 entries per color) |
\*-----------------------------------------------------*/
for (std::size_t idx = 0; idx < 40; idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[color_idx];
color_data[pixel_idx + 0x00] = RGBGetGValue(color);
color_data[pixel_idx + 0x01] = RGBGetRValue(color);
color_data[pixel_idx + 0x02] = RGBGetBValue(color);
}
/*-----------------------------------------------------*\
| Send mode and color data |
\*-----------------------------------------------------*/
SendPacket(channel, mode, direction, color_idx, speed, 40, &color_data[0]);
}
}
/*-----------------------------------------------------*\
| If mode requires per-LED colors, fill colors array |
\*-----------------------------------------------------*/
else
{
/*-----------------------------------------------------*\
| Set up main packet |
| Fill in color data (up to 40 colors) |
\*-----------------------------------------------------*/
serial_buf[0x00] = 0x4B;
/*-----------------------------------------------------*\
| Set channel in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x01] = channel;
/*-----------------------------------------------------*\
| Set mode in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x02] = current_mode;
/*-----------------------------------------------------*\
| Set options bitfield in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x03] = 0;
serial_buf[0x03] |= current_direction ? ( 1 << 4 ) : 0;
/*-----------------------------------------------------*\
| Set color index and speed in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x04] = ( color_idx << 5 ) | current_speed;
/*-----------------------------------------------------*\
| Fill in color data |
\*-----------------------------------------------------*/
for (std::size_t idx = 0; idx < 40; idx++)
for (std::size_t idx = 0; idx < num_colors; idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[color_idx];
serial_buf[pixel_idx + 0x05] = RGBGetGValue(color);
serial_buf[pixel_idx + 0x06] = RGBGetRValue(color);
serial_buf[pixel_idx + 0x07] = RGBGetBValue(color);
RGBColor color = colors[idx];
color_data[pixel_idx + 0x00] = RGBGetGValue(color);
color_data[pixel_idx + 0x01] = RGBGetRValue(color);
color_data[pixel_idx + 0x02] = RGBGetBValue(color);
}
serialport->serial_write((char *)serial_buf, HUE_PLUS_PACKET_SIZE);
serialport->serial_flush_tx();
Sleep(10);
/*-----------------------------------------------------*\
| Send mode and color data |
\*-----------------------------------------------------*/
SendPacket(channel, mode, direction, 0, speed, num_colors, &color_data[0]);
}
}
void HuePlusController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
void HuePlusController::SetChannelLEDs
(
unsigned char channel,
RGBColor * colors,
unsigned int num_colors
)
{
unsigned char color_data[120];
/*-----------------------------------------------------*\
| Fill in color data (up to 40 colors) |
\*-----------------------------------------------------*/
for (std::size_t idx = 0; idx < num_colors; idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[idx];
color_data[pixel_idx + 0x00] = RGBGetGValue(color);
color_data[pixel_idx + 0x01] = RGBGetRValue(color);
color_data[pixel_idx + 0x02] = RGBGetBValue(color);
}
/*-----------------------------------------------------*\
| Send color data |
\*-----------------------------------------------------*/
SendPacket(channel, HUE_PLUS_MODE_FIXED, false, 0, 0, num_colors, &color_data[0]);
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void HuePlusController::SendPacket
(
unsigned char channel,
unsigned char mode,
bool direction,
unsigned char color_idx,
unsigned char speed,
unsigned char color_count,
unsigned char* color_data
)
{
unsigned char serial_buf[125];
@@ -158,45 +205,44 @@ void HuePlusController::SetChannelLEDs(unsigned char channel, std::vector<RGBCol
memset(serial_buf, 0x00, sizeof(serial_buf));
/*-----------------------------------------------------*\
| Set up main packet |
| Set up Direct packet |
\*-----------------------------------------------------*/
serial_buf[0x00] = 0x4B;
/*-----------------------------------------------------*\
| Set channel in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x01] = channel;
serial_buf[0x01] = channel + 1;
/*-----------------------------------------------------*\
| Set mode in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x02] = current_mode;
serial_buf[0x02] = mode;
/*-----------------------------------------------------*\
| Set options bitfield in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x03] = 0;
serial_buf[0x03] |= current_direction ? ( 1 << 4 ) : 0;
serial_buf[0x03] |= direction ? ( 1 << 4 ) : 0;
/*-----------------------------------------------------*\
| Set speed in serial packet |
| Set color index and speed in serial packet |
\*-----------------------------------------------------*/
serial_buf[0x04] = current_speed;
serial_buf[0x04] = ( color_idx << 5 ) | speed;
/*-----------------------------------------------------*\
| Fill in color data |
| Copy in color data bytes |
\*-----------------------------------------------------*/
for (std::size_t idx = 0; idx < colors.size(); idx++)
{
int pixel_idx = idx * 3;
RGBColor color = colors[idx];
serial_buf[pixel_idx + 0x05] = RGBGetGValue(color);
serial_buf[pixel_idx + 0x06] = RGBGetRValue(color);
serial_buf[pixel_idx + 0x07] = RGBGetBValue(color);
}
memcpy(&serial_buf[0x05], color_data, color_count * 3);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
serialport->serial_write((char *)serial_buf, HUE_PLUS_PACKET_SIZE);
serialport->serial_flush_tx();
Sleep(10);
/*-----------------------------------------------------*\
| Delay to allow Hue+ device to ready for next packet |
\*-----------------------------------------------------*/
Sleep(20);
}
@@ -73,9 +73,23 @@ public:
void Initialize(char* port);
char* GetLocation();
unsigned int GetLEDsOnChannel(unsigned int channel);
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
void SetMode(unsigned char mode, unsigned char speed, bool direction);
void SetModeColors(unsigned char channel, std::vector<RGBColor> colors);
void SetChannelEffect
(
unsigned char channel,
unsigned char mode,
unsigned char speed,
bool direction,
RGBColor * colors,
unsigned int num_colors
);
void SetChannelLEDs
(
unsigned char channel,
RGBColor * colors,
unsigned int num_colors
);
unsigned int channel_leds[HUE_PLUS_NUM_CHANNELS];
@@ -83,9 +97,16 @@ private:
char port_name[128];
serial_port *serialport;
unsigned char current_mode;
unsigned char current_speed;
bool current_direction;
void SendPacket
(
unsigned char channel,
unsigned char mode,
bool direction,
unsigned char color_idx,
unsigned char speed,
unsigned char color_count,
unsigned char* color_data
);
};
#endif
@@ -1,16 +1,16 @@
/*-----------------------------------------*\
| HyperXController.cpp |
| HyperXDRAMController.cpp |
| |
| Definitions and types for HyperX Predator|
| RGB RAM lighting controller |
| and Fury RGB RAM lighting controller |
| |
| Adam Honse (CalcProgrammer1) 6/29/2019 |
\*-----------------------------------------*/
#include "HyperXController.h"
#include "HyperXDRAMController.h"
#include <cstring>
HyperXController::HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev, unsigned char slots)
HyperXDRAMController::HyperXDRAMController(i2c_smbus_interface* bus, hyperx_dev_id dev, unsigned char slots)
{
this->bus = bus;
this->dev = dev;
@@ -31,17 +31,17 @@ HyperXController::HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev,
mode = HYPERX_MODE_DIRECT;
}
HyperXController::~HyperXController()
HyperXDRAMController::~HyperXDRAMController()
{
}
std::string HyperXController::GetDeviceName()
std::string HyperXDRAMController::GetDeviceName()
{
return(device_name);
}
std::string HyperXController::GetDeviceLocation()
std::string HyperXDRAMController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
@@ -51,12 +51,12 @@ std::string HyperXController::GetDeviceLocation()
return(return_string);
}
unsigned int HyperXController::GetLEDCount()
unsigned int HyperXDRAMController::GetLEDCount()
{
return(led_count);
}
unsigned int HyperXController::GetSlotCount()
unsigned int HyperXDRAMController::GetSlotCount()
{
unsigned int slot_count = 0;
@@ -71,12 +71,12 @@ unsigned int HyperXController::GetSlotCount()
return(slot_count);
}
unsigned int HyperXController::GetMode()
unsigned int HyperXDRAMController::GetMode()
{
return(mode);
}
void HyperXController::SetEffectColor(unsigned char red, unsigned char green, unsigned char blue)
void HyperXDRAMController::SetEffectColor(unsigned char red, unsigned char green, unsigned char blue)
{
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
@@ -89,7 +89,7 @@ void HyperXController::SetEffectColor(unsigned char red, unsigned char green, un
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
void HyperXController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
void HyperXDRAMController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
{
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
@@ -126,7 +126,7 @@ void HyperXController::SetAllColors(unsigned char red, unsigned char green, unsi
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
void HyperXController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
void HyperXDRAMController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
/*-----------------------------------------------------*\
| led_slot - the unmapped slot ID for the given LED |
@@ -175,7 +175,7 @@ void HyperXController::SetLEDColor(unsigned int led, unsigned char red, unsigned
}
void HyperXController::SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
void HyperXDRAMController::SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char base = slot_base[slot];
unsigned char red_base = base + 0x00;
@@ -194,7 +194,7 @@ void HyperXController::SetLEDColor(unsigned int slot, unsigned int led, unsigned
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
}
void HyperXController::SetMode(unsigned char new_mode, bool random, unsigned short new_speed)
void HyperXDRAMController::SetMode(unsigned char new_mode, bool random, unsigned short new_speed)
{
mode = new_mode;
speed = new_speed;
@@ -1,8 +1,8 @@
/*-----------------------------------------*\
| HyperXController.h |
| HyperXDRAMController.h |
| |
| Definitions and types for HyperX Predator|
| RGB RAM lighting controller |
| and Fury RGB RAM lighting controller |
| |
| Adam Honse (CalcProgrammer1) 6/29/2019 |
\*-----------------------------------------*/
@@ -193,11 +193,11 @@ static const unsigned char slot_base[4] =
HYPERX_REG_SLOT3_LED0_RED /* SPD 0x53 maps to slot 3 */
};
class HyperXController
class HyperXDRAMController
{
public:
HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev, unsigned char slots);
~HyperXController();
HyperXDRAMController(i2c_smbus_interface* bus, hyperx_dev_id dev, unsigned char slots);
~HyperXDRAMController();
std::string GetDeviceName();
std::string GetDeviceLocation();
@@ -1,6 +1,6 @@
#include "HyperXController.h"
#include "HyperXDRAMController.h"
#include "RGBController.h"
#include "RGBController_HyperX.h"
#include "RGBController_HyperXDRAM.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
@@ -19,13 +19,13 @@ static void Sleep(unsigned int milliseconds)
/******************************************************************************************\
* *
* TestForHyperXController *
* TestForHyperXDRAMController *
* *
* Tests the given address to see if a HyperX controller exists there. *
* Tests the given address to see if a HyperX controller exists there. *
* *
\******************************************************************************************/
bool TestForHyperXController(i2c_smbus_interface* bus, unsigned char address)
bool TestForHyperXDRAMController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
@@ -48,31 +48,31 @@ bool TestForHyperXController(i2c_smbus_interface* bus, unsigned char address)
return(pass);
} /* TestForHyperXController() */
} /* TestForHyperXDRAMController() */
/******************************************************************************************\
* *
* DetectHyperXControllers *
* DetectHyperXDRAMControllers *
* *
* Detect HyperX controllers on the enumerated I2C busses. *
* Detect HyperX DRAM controllers on the enumerated I2C busses. *
* *
* bus - pointer to i2c_smbus_interface where Aura device is connected *
* dev - I2C address of Aura device *
* *
\******************************************************************************************/
void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
void DetectHyperXDRAMControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
HyperXController* new_hyperx;
RGBController_HyperX* new_controller;
HyperXDRAMController* new_hyperx;
RGBController_HyperXDRAM* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
unsigned char slots_valid = 0x00;
// Check for HyperX controller at 0x27
if (TestForHyperXController(busses[bus], 0x27))
if (TestForHyperXDRAMController(busses[bus], 0x27))
{
busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF);
@@ -94,11 +94,11 @@ void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vec
if(slots_valid != 0)
{
new_hyperx = new HyperXController(busses[bus], 0x27, slots_valid);
new_controller = new RGBController_HyperX(new_hyperx);
new_hyperx = new HyperXDRAMController(busses[bus], 0x27, slots_valid);
new_controller = new RGBController_HyperXDRAM(new_hyperx);
rgb_controllers.push_back(new_controller);
}
}
}
} /* DetectHyperXControllers() */
} /* DetectHyperXDRAMControllers() */
@@ -126,7 +126,7 @@ void PatriotViperController::SetLEDEffectColor(unsigned int led, unsigned char r
ViperRegisterWrite(VIPER_REG_MODE, 0xFA, 0x00, 0x00);
}
void PatriotViperController::SetLEDColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
void PatriotViperController::SetLEDColor(unsigned int /*slot*/, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
@@ -136,7 +136,7 @@ void PatriotViperController::SetLEDColor(unsigned int slot, unsigned int led, un
ViperRegisterWrite(VIPER_REG_APPLY, 0x01, 0x00, 0x00);
}
void PatriotViperController::SetLEDEffectColor(unsigned int slot, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
void PatriotViperController::SetLEDEffectColor(unsigned int /*slot*/, unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
ViperRegisterWrite(VIPER_REG_START, 0xFF, 0xFF, 0xFF);
ViperRegisterWrite(VIPER_REG_STATIC, 0x04, 0x00, 0x00);
@@ -47,6 +47,12 @@ PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_
strcpy(device_name, "ASRock Polychrome FW 3.00");
break;
case FIRMWARE_VER_3_PT_04:
led_count = 1;
asr_led = false;
strcpy(device_name, "ASRock Polychrome FW 3.04");
break;
default:
led_count = 0;
strcpy(device_name, "");
@@ -21,6 +21,7 @@ enum
FIRMWARE_VER_2_PT_08 = 0x0208, /* Firmware nu51_2.08 */
FIRMWARE_VER_2_PT_10 = 0x020A, /* Firmware nu51_2.10 */
FIRMWARE_VER_3_PT_00 = 0x0300, /* Firmware nu51_3.00 */
FIRMWARE_VER_3_PT_04 = 0x0304, /* Firmware nu51_3.04 */
};
enum
@@ -56,6 +56,8 @@ void PoseidonZRGBController::SetMode(unsigned char mode, unsigned char direction
POSEIDONZ_BRIGHTNESS_MAX,
active_speed
);
Sleep(200);
}
void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
@@ -1,13 +1,13 @@
/*-----------------------------------------*\
| RGBFusion2Controller.cpp |
| RGBFusion2USBController.cpp |
| |
| Driver for Gigabyte Aorus RGB Fusion 2.0 |
| lighting controller |
| USB lighting controller |
| |
| jackun 1/8/2020 |
\*-----------------------------------------*/
#include "RGBFusion2Controller.h"
#include "RGBFusion2USBController.h"
#include <algorithm>
#include <array>
#include <thread>
@@ -27,7 +27,7 @@ static LEDCount LedCountToEnum(unsigned int c)
return(LEDS_1024);
}
RGBFusion2Controller::RGBFusion2Controller(hid_device* handle, const char *path) : dev(handle)
RGBFusion2USBController::RGBFusion2USBController(hid_device* handle, const char *path) : dev(handle)
{
int res = 0;
char text[64] {};
@@ -62,14 +62,14 @@ RGBFusion2Controller::RGBFusion2Controller(hid_device* handle, const char *path)
}
}
RGBFusion2Controller::~RGBFusion2Controller()
RGBFusion2USBController::~RGBFusion2USBController()
{
if( dev ) {
hid_close(dev);
}
}
void RGBFusion2Controller::SetMode(int m)
void RGBFusion2USBController::SetMode(int m)
{
mode = m;
}
@@ -78,7 +78,7 @@ void RGBFusion2Controller::SetMode(int m)
// "Custom" RGB packets don't seem to get remapped so use report.byteorderN and do it manually.
// Of course it all depends how we send data to the controller, but bios/rgb fusion 2 itself
// set it up like this.
void RGBFusion2Controller::SetCalibration()
void RGBFusion2USBController::SetCalibration()
{
uint8_t buffer[64] {};
buffer[0] = report_id;
@@ -105,14 +105,14 @@ void RGBFusion2Controller::SetCalibration()
SendPacket(buffer);
}
void RGBFusion2Controller::SetLedCount(unsigned int count)
void RGBFusion2USBController::SetLedCount(unsigned int count)
{
led_count = count;
LEDCount s0 = LedCountToEnum(count);
SendPacket(0x34, s0 | (s0 << 4)); // D_LED1 | D_LED2
}
bool RGBFusion2Controller::DisableBuiltinEffect(int enable_bit, int mask)
bool RGBFusion2USBController::DisableBuiltinEffect(int enable_bit, int mask)
{
if(effect_disabled & enable_bit)
return(true);
@@ -126,32 +126,38 @@ bool RGBFusion2Controller::DisableBuiltinEffect(int enable_bit, int mask)
return res;
}
bool RGBFusion2Controller::EnableBeat(bool e)
bool RGBFusion2USBController::EnableBeat(bool e)
{
return SendPacket(0x31, e ? 1 : 0);
}
std::string RGBFusion2Controller::GetDeviceName()
std::string RGBFusion2USBController::GetDeviceName()
{
return(name);
}
std::string RGBFusion2Controller::GetFWVersion()
std::string RGBFusion2USBController::GetFWVersion()
{
return(version);
}
std::string RGBFusion2Controller::GetDeviceLocation()
std::string RGBFusion2USBController::GetDeviceLocation()
{
return(loc);
}
std::string RGBFusion2Controller::GetSerial()
std::string RGBFusion2USBController::GetSerial()
{
return(chip_id);
}
void RGBFusion2Controller::SetStripColors(unsigned int hdr, int start, int end, std::vector<RGBColor>& colors, int single_led)
void RGBFusion2USBController::SetStripColors
(
unsigned int hdr,
RGBColor * colors,
unsigned int num_colors,
int single_led
)
{
PktRGB pkt;
pkt.Init(hdr, report_id);
@@ -164,7 +170,7 @@ void RGBFusion2Controller::SetStripColors(unsigned int hdr, int start, int end,
unsigned char bo_b = byteorder & 0xFF;
int res;
int leds_left = end - start;
int leds_left = num_colors;
int sent_data = 0;
int k = 0;
int leds_in_pkt = sizeof(pkt.s.leds) / sizeof(*pkt.s.leds); /* 19 */
@@ -174,7 +180,7 @@ void RGBFusion2Controller::SetStripColors(unsigned int hdr, int start, int end,
if(single_led > -1)
{
leds_left = 1;
k = single_led - start;
k = single_led;
sent_data = k * 3;
leds_in_pkt = 1;
}
@@ -190,7 +196,7 @@ void RGBFusion2Controller::SetStripColors(unsigned int hdr, int start, int end,
for(int i = 0; i < leds_in_pkt; i++)
{
RGBColor color = colors[start + k];
RGBColor color = colors[k];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
@@ -222,7 +228,7 @@ static const std::array< std::array<int, 3>, 5> speeds = {
},
};
void RGBFusion2Controller::SetLEDEffect(unsigned int led, int mode, unsigned int speed, bool random, unsigned char r, unsigned char g, unsigned char b)
void RGBFusion2USBController::SetLEDEffect(unsigned int led, int mode, unsigned int speed, bool random, unsigned char r, unsigned char g, unsigned char b)
{
PktEffect pkt;
pkt.Init(led, report_id);
@@ -264,12 +270,12 @@ void RGBFusion2Controller::SetLEDEffect(unsigned int led, int mode, unsigned int
SendPacket(pkt.buffer);
}
bool RGBFusion2Controller::ApplyEffect()
bool RGBFusion2USBController::ApplyEffect()
{
return SendPacket(0x28, 0xFF);
}
bool RGBFusion2Controller::SendPacket(uint8_t a, uint8_t b, uint8_t c)
bool RGBFusion2USBController::SendPacket(uint8_t a, uint8_t b, uint8_t c)
{
unsigned char buffer[64] {};
buffer[0] = report_id;
@@ -279,7 +285,7 @@ bool RGBFusion2Controller::SendPacket(uint8_t a, uint8_t b, uint8_t c)
return (SendPacket(buffer) == 64);
}
int RGBFusion2Controller::SendPacket(unsigned char* packet)
int RGBFusion2USBController::SendPacket(unsigned char* packet)
{
return hid_send_feature_report(dev, packet, 64);
}
@@ -1,8 +1,8 @@
/*-----------------------------------------*\
| RGBFusion2Controller.h |
| RGBFusion2USBController.h |
| |
| Definitions and types for Gigabyte Aorus |
| RGB Fusion 2.0 lighting controller |
| RGB Fusion 2.0 USB lighting controller |
| |
| jackun 1/8/2020 |
\*-----------------------------------------*/
@@ -154,13 +154,20 @@ struct IT8297Report
#pragma pack(pop)
class RGBFusion2Controller
class RGBFusion2USBController
{
public:
RGBFusion2Controller(hid_device* handle, const char *path);
~RGBFusion2Controller();
RGBFusion2USBController(hid_device* handle, const char *path);
~RGBFusion2USBController();
void SetStripColors
(
unsigned int hdr,
RGBColor * colors,
unsigned int num_colors,
int single_led = -1
);
void SetStripColors(unsigned int hdr, int start, int end, std::vector<RGBColor>& colors, int single_led = -1);
void SetLEDEffect(unsigned int led, int mode, unsigned int speed, bool random, unsigned char red, unsigned char green, unsigned char blue);
void SetLedCount(unsigned int count);
void SetMode(int mode);
@@ -1,18 +1,18 @@
#include "RGBFusion2Controller.h"
#include "RGBController_RGBFusion2.h"
#include "RGBFusion2USBController.h"
#include "RGBController_RGBFusion2USB.h"
#define IT8297_VID 0x048D
#define IT8297_PID 0x8297
/******************************************************************************************\
* *
* DetectRGBFusion2Controllers *
* DetectRGBFusion2USBControllers *
* *
* Detect RGB Fusion 2 devices that use IT8297 RGB controller *
* *
\******************************************************************************************/
void DetectRGBFusion2Controllers(std::vector<RGBController*> &rgb_controllers)
void DetectRGBFusion2USBControllers(std::vector<RGBController*> &rgb_controllers)
{
if (hid_init() < 0)
return;
@@ -26,8 +26,8 @@ void DetectRGBFusion2Controllers(std::vector<RGBController*> &rgb_controllers)
{
hid_device * dev = hid_open_path(device->path);
if (dev) {
RGBFusion2Controller * controller = new RGBFusion2Controller(dev, device_list->path);
RGBController_RGBFusion2 * rgb_controller = new RGBController_RGBFusion2(controller);
RGBFusion2USBController * controller = new RGBFusion2USBController(dev, device_list->path);
RGBController_RGBFusion2USB * rgb_controller = new RGBController_RGBFusion2USB(controller);
rgb_controllers.push_back(rgb_controller);
}
device = device->next;
@@ -0,0 +1,108 @@
#include "RedragonK556Controller.h"
#include "RedragonM711Controller.h"
#include "RGBController.h"
#include "RGBController_RedragonK556.h"
#include "RGBController_RedragonM711.h"
#include <vector>
#include <hidapi/hidapi.h>
/*-----------------------------------------------------*\
| Keyboard product IDs |
\*-----------------------------------------------------*/
#define REDRAGON_K556_VID 0x0C45
#define REDRAGON_K556_PID 0x5004
/*-----------------------------------------------------*\
| Mouse product IDs |
\*-----------------------------------------------------*/
#define REDRAGON_M711_VID 0x04D9
#define REDRAGON_M711_PID 0xFC30
typedef struct
{
unsigned short usb_vid;
unsigned short usb_pid;
unsigned char usb_interface;
device_type type;
const char * name;
} redragon_device;
#define REDRAGON_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
static const redragon_device device_list[] =
{
/*-----------------------------------------------------------------------------------------------------*\
| Keyboards |
\*-----------------------------------------------------------------------------------------------------*/
{ REDRAGON_K556_VID, REDRAGON_K556_PID, 1, DEVICE_TYPE_KEYBOARD, "Redragon K556 Devarajas" },
/*-----------------------------------------------------------------------------------------------------*\
| Mice |
\*-----------------------------------------------------------------------------------------------------*/
{ REDRAGON_M711_VID, REDRAGON_M711_PID, 2, DEVICE_TYPE_MOUSE, "Redragon M711 Cobra" },
/*-----------------------------------------------------------------------------------------------------*\
| Mousemats |
\*-----------------------------------------------------------------------------------------------------*/
};
/******************************************************************************************\
* *
* DetectRedragonControllers *
* *
* Tests the USB address to see if a Redragon RGB Keyboard controller exists there. *
* *
\******************************************************************************************/
void DetectRedragonControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
hid_init();
for(int device_idx = 0; device_idx < REDRAGON_NUM_DEVICES; device_idx++)
{
dev = NULL;
info = hid_enumerate(device_list[device_idx].usb_vid, device_list[device_idx].usb_pid);
//Look for Redragon RGB Peripheral
while(info)
{
if((info->vendor_id == device_list[device_idx].usb_vid)
&&(info->product_id == device_list[device_idx].usb_pid)
&&(info->interface_number == device_list[device_idx].usb_interface))
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
switch(device_list[device_idx].type)
{
case DEVICE_TYPE_KEYBOARD:
{
RedragonK556Controller* controller = new RedragonK556Controller(dev);
RGBController_RedragonK556* rgb_controller = new RGBController_RedragonK556(controller);
rgb_controllers.push_back(rgb_controller);
}
break;
case DEVICE_TYPE_MOUSE:
{
RedragonM711Controller* controller = new RedragonM711Controller(dev);
RGBController_RedragonM711* rgb_controller = new RGBController_RedragonM711(controller);
rgb_controllers.push_back(rgb_controller);
}
break;
}
}
}
}
@@ -0,0 +1,159 @@
#include "RedragonK556Controller.h"
#include <cstring>
RedragonK556Controller::RedragonK556Controller(hid_device* dev_handle)
{
dev = dev_handle;
}
void RedragonK556Controller::SetKeyboardColors
(
unsigned char * color_data,
unsigned int size
)
{
unsigned int packet_size = 0;
unsigned int packet_offset = 0;
while(size > 0)
{
if(size >= REDRAGON_K556_MAX_PACKET_SIZE)
{
packet_size = REDRAGON_K556_MAX_PACKET_SIZE;
}
else
{
packet_size = size;
}
SendKeyboardData
(
&color_data[packet_offset],
packet_size,
packet_offset
);
size -= packet_size;
packet_offset += packet_size;
}
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void RedragonK556Controller::SendKeyboardBegin()
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Keyboard Begin packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x04;
usb_buf[0x01] = 0x01;
usb_buf[0x02] = 0x00;
usb_buf[0x03] = 0x01;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_read(dev, (unsigned char *)usb_buf, 64);
}
void RedragonK556Controller::SendKeyboardData
(
unsigned char * data,
unsigned char data_size,
unsigned short data_offset
)
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Keyboard End packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x04;
usb_buf[0x01] = 0x11 + data_offset;
usb_buf[0x02] = data_size;
usb_buf[0x03] = ( data_size / 3 ) - 1;
usb_buf[0x04] = data_size;
usb_buf[0x05] = data_offset & 0x00FF;
usb_buf[0x06] = data_offset >> 8;
/*-----------------------------------------------------*\
| Copy in data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x08], data, data_size);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_read(dev, (unsigned char *)usb_buf, 64);
}
void RedragonK556Controller::SendKeyboardMode
(
unsigned char mode
)
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Keyboard End packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x04;
usb_buf[0x01] = 0x00;
usb_buf[0x02] = 0x00;
usb_buf[0x03] = 0x06;
usb_buf[0x04] = 0x01;
usb_buf[0x08] = mode;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_read(dev, (unsigned char *)usb_buf, 64);
}
void RedragonK556Controller::SendKeyboardEnd()
{
char usb_buf[64];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Keyboard End packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x04;
usb_buf[0x01] = 0x02;
usb_buf[0x02] = 0x00;
usb_buf[0x03] = 0x02;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_read(dev, (unsigned char *)usb_buf, 64);
}
@@ -0,0 +1,72 @@
/*-----------------------------------------*\
| RedragonK556Controller.h |
| |
| Definitions and types for Redragon K556 |
| Devarajas keyboard lighting controller |
| |
| Adam Honse (CalcProgrammer1) 3/15/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
#define REDRAGON_K556_MAX_PACKET_SIZE ( 0x36 ) /* max packet size for color*/
/* update packets */
enum
{
REDRAGON_K556_MODE_COLOR_WAVE_SHORT = 0x01, /* "Go with the stream" */
REDRAGON_K556_MODE_COLOR_WAVE_LONG = 0x02, /* "Clouds fly" */
REDRAGON_K556_MODE_COLOR_WHEEL = 0x03, /* "Winding paths" */
REDRAGON_K556_MODE_SPECTRUM_CYCLE = 0x04, /* "The trial of light" */
REDRAGON_K556_MODE_BREATHING = 0x05, /* "Breathing" */
REDRAGON_K556_MODE_STATIC = 0x06, /* "Normally on" */
REDRAGON_K556_MODE_REACTIVE = 0x07, /* "Pass without trace" */
REDRAGON_K556_MODE_REACTIVE_RIPPLE = 0x08, /* "Ripple graff" */
REDRAGON_K556_MODE_REACTIVE_LINE = 0x09, /* "Fast run without trace" */
REDRAGON_K556_MODE_STARLIGHT_FAST = 0x0A, /* "Swift action" */
REDRAGON_K556_MODE_BLOOMING = 0x0B, /* "Flowers blooming" */
REDRAGON_K556_MODE_RAINBOW_WAVE_VERTICAL = 0x0C, /* "Snow winter jasmine" */
REDRAGON_K556_MODE_HURRICANE = 0x0D, /* "Hurricane" */
REDRAGON_K556_MODE_ACCUMULATE = 0x0E, /* "Accumulate" */
REDRAGON_K556_MODE_STARLIGHT_SLOW = 0x0F, /* "Digital times" */
REDRAGON_K556_MODE_VISOR = 0x10, /* "Both ways" */
REDRAGON_K556_MODE_RAINBOW_WAVE_CIRCLE = 0x12, /* "Fast and the Furious" */
REDRAGON_K556_MODE_CUSTOM = 0x14, /* "Coastal" */
};
class RedragonK556Controller
{
public:
RedragonK556Controller(hid_device* dev_handle);
~RedragonK556Controller();
void SetKeyboardColors
(
unsigned char * color_data,
unsigned int size
);
void SendKeyboardBegin();
void SendKeyboardMode
(
unsigned char mode
);
void SendKeyboardData
(
unsigned char * data,
unsigned char data_size,
unsigned short data_offset
);
void SendKeyboardEnd();
private:
hid_device* dev;
};
@@ -0,0 +1,90 @@
#include "RedragonM711Controller.h"
#include <cstring>
static void send_usb_msg(hid_device* dev, char * data_pkt, unsigned int size)
{
char* usb_pkt = new char[size + 1];
usb_pkt[0] = 0x00;
for(int i = 1; i < size + 1; i++)
{
usb_pkt[i] = data_pkt[i-1];
}
hid_send_feature_report(dev, (unsigned char *)usb_pkt, size + 1);
delete usb_pkt;
}
RedragonM711Controller::RedragonM711Controller(hid_device* dev_handle)
{
dev = dev_handle;
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void RedragonM711Controller::SendMouseApply()
{
char usb_buf[16];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Apply packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x02;
usb_buf[0x01] = 0xF1;
usb_buf[0x02] = 0x02;
usb_buf[0x03] = 0x04;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf, 16);
}
void RedragonM711Controller::SendMouseMode
(
unsigned char mode,
unsigned char speed,
unsigned char red,
unsigned char green,
unsigned char blue
)
{
char usb_buf[16];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up Lighting Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x02;
usb_buf[0x01] = 0xF3;
usb_buf[0x02] = 0x49;
usb_buf[0x03] = 0x04;
usb_buf[0x04] = 0x06;
usb_buf[0x08] = red;
usb_buf[0x09] = green;
usb_buf[0x0A] = blue;
usb_buf[0x0B] = 0x01; //on
usb_buf[0x0C] = speed;
usb_buf[0x0D] = mode;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
send_usb_msg(dev, usb_buf, 16);
}
@@ -0,0 +1,46 @@
/*-----------------------------------------*\
| RedragonM711Controller.h |
| |
| Definitions and types for Redragon M711 |
| Cobra mouse lighting controller |
| |
| Adam Honse (CalcProgrammer1) 3/15/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
enum
{
REDRAGON_M711_MODE_WAVE = 0x00,
REDRAGON_M711_MODE_RANDOM_BREATHING = 0x01,
REDRAGON_M711_MODE_STATIC = 0x02,
REDRAGON_M711_MODE_BREATHING = 0x04,
REDRAGON_M711_MODE_RAINBOW = 0x08,
REDRAGON_M711_MODE_FLASHING = 0x10,
};
class RedragonM711Controller
{
public:
RedragonM711Controller(hid_device* dev_handle);
~RedragonM711Controller();
void SendMouseApply();
void SendMouseMode
(
unsigned char mode,
unsigned char speed,
unsigned char red,
unsigned char green,
unsigned char blue
);
private:
hid_device* dev;
};
@@ -16,12 +16,6 @@ ThermaltakeRiingController::ThermaltakeRiingController(libusb_device_handle* dev
dev = dev_handle;
SendInit();
channel_leds[0] = 9;
channel_leds[1] = 9;
channel_leds[2] = 9;
channel_leds[3] = 0;
channel_leds[4] = 0;
}
ThermaltakeRiingController::~ThermaltakeRiingController()
@@ -29,11 +23,11 @@ ThermaltakeRiingController::~ThermaltakeRiingController()
}
void ThermaltakeRiingController::SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors)
void ThermaltakeRiingController::SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors)
{
unsigned char* color_data = new unsigned char[3 * colors.size()];
unsigned char* color_data = new unsigned char[3 * num_colors];
for(int color = 0; color < colors.size(); color++)
for(std::size_t color = 0; color < num_colors; color++)
{
int color_idx = color * 3;
color_data[color_idx + 0] = RGBGetGValue(colors[color]);
@@ -41,7 +35,7 @@ void ThermaltakeRiingController::SetChannelLEDs(unsigned char channel, std::vect
color_data[color_idx + 2] = RGBGetBValue(colors[color]);
}
SendRGB(channel, current_mode, current_speed, colors.size(), color_data);
SendRGB(channel + 1, current_mode, current_speed, num_colors, color_data);
delete[] color_data;
}
@@ -42,16 +42,16 @@ enum
THERMALTAKE_SPEED_EXTREME = 0x00
};
#define THERMALTAKE_NUM_CHANNELS 5
class ThermaltakeRiingController
{
public:
ThermaltakeRiingController(libusb_device_handle* dev_handle);
~ThermaltakeRiingController();
void SetChannelLEDs(unsigned char channel, std::vector<RGBColor> colors);
void SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors);
void SetMode(unsigned char mode, unsigned char speed);
unsigned int channel_leds[5];
private:
libusb_device_handle* dev;
+23 -20
View File
@@ -247,7 +247,10 @@ void DetectI2CBusses()
if(test_fd)
{
memset(device_string, 0x00, sizeof(device_string));
read(test_fd, device_string, sizeof(device_string));
device_string[strlen(device_string) - 1] = 0x00;
close(test_fd);
bus = new i2c_smbus_linux();
@@ -276,12 +279,12 @@ void DetectI2CBusses()
#endif /* WIN32 */
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectAuraSMBusControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectAuraGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCorsairVengeanceControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCorsairVengeanceProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectHyperXDRAMControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
@@ -295,13 +298,13 @@ void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers);
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers);
void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers);
void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers);
void DetectCorsairCmdrProControllers(std::vector<RGBController*> &rgb_controllers);
void DetectCorsairKeyboardControllers(std::vector<RGBController*>& rgb_controllers);
void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controllers);
void DetectCorsairPeripheralControllers(std::vector<RGBController*>& rgb_controllers);
void DetectCorsairLightingNodeControllers(std::vector<RGBController*> &rgb_controllers);
void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers);
void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controllers);
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers);
void DetectRGBFusion2Controllers(std::vector<RGBController*> &rgb_controllers);
void DetectRGBFusion2USBControllers(std::vector<RGBController*> &rgb_controllers);
void DetectRedragonControllers(std::vector<RGBController*>& rgb_controllers);
/******************************************************************************************\
* *
@@ -310,17 +313,17 @@ void DetectRGBFusion2Controllers(std::vector<RGBController*> &rgb_controllers);
* Detect and populate RGB Controllers vector *
* *
\******************************************************************************************/
#include "RGBController_Dummy.h"
void DetectRGBControllers(void)
{
DetectI2CBusses();
DetectAuraControllers(busses, rgb_controllers);
DetectAuraSMBusControllers(busses, rgb_controllers);
DetectAuraGPUControllers(busses, rgb_controllers);
DetectCorsairControllers(busses, rgb_controllers);
DetectCorsairProControllers(busses, rgb_controllers);
DetectCorsairVengeanceControllers(busses, rgb_controllers);
DetectCorsairVengeanceProControllers(busses, rgb_controllers);
DetectCrucialControllers(busses, rgb_controllers);
DetectHyperXControllers(busses, rgb_controllers);
DetectHyperXDRAMControllers(busses, rgb_controllers);
DetectPatriotViperControllers(busses, rgb_controllers);
DetectPolychromeControllers(busses, rgb_controllers);
DetectRGBFusionGPUControllers(busses, rgb_controllers);
@@ -336,24 +339,24 @@ void DetectRGBControllers(void)
DetectMSI3ZoneControllers(rgb_controllers);
DetectPoseidonZRGBControllers(rgb_controllers);
DetectHyperXKeyboardControllers(rgb_controllers);
DetectCorsairCmdrProControllers(rgb_controllers);
DetectCorsairKeyboardControllers(rgb_controllers);
DetectCorsairNodeProControllers(rgb_controllers);
DetectCorsairPeripheralControllers(rgb_controllers);
DetectCorsairLightingNodeControllers(rgb_controllers);
DetectThermaltakeRiingControllers(rgb_controllers);
DetectRGBFusion2Controllers(rgb_controllers);
DetectRGBFusion2USBControllers(rgb_controllers);
DetectRedragonControllers(rgb_controllers);
DetectE131Controllers(rgb_controllers);
DetectOpenRazerControllers(rgb_controllers);
/*-------------------------------------*\
| Windows-only devices |
\*-------------------------------------*/
#ifdef WIN32
DetectOpenRazerControllers(rgb_controllers);
/*-------------------------------------*\
| Linux-only devices |
\*-------------------------------------*/
#else
DetectOpenRazerControllers(rgb_controllers);
DetectFaustusControllers(rgb_controllers);
#endif
+44 -14
View File
@@ -1,8 +1,8 @@
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
index 09367fc014c3..25c0e02b3344 100644
index 2ddca08f8a76..72647850f08e 100644
--- a/drivers/i2c/busses/Kconfig
+++ b/drivers/i2c/busses/Kconfig
@@ -216,6 +216,15 @@ config I2C_CHT_WC
@@ -217,6 +217,15 @@ config I2C_CHT_WC
combined with a FUSB302 Type-C port-controller as such it is advised
to also select CONFIG_TYPEC_FUSB302=m.
@@ -19,7 +19,7 @@ index 09367fc014c3..25c0e02b3344 100644
tristate "Nvidia nForce2, nForce3 and nForce4"
depends on PCI
diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile
index 80c23895eaaf..57a2daf0b94e 100644
index 25d60889713c..3c2a9b237ac6 100644
--- a/drivers/i2c/busses/Makefile
+++ b/drivers/i2c/busses/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_I2C_CHT_WC) += i2c-cht-wc.o
@@ -32,10 +32,10 @@ index 80c23895eaaf..57a2daf0b94e 100644
obj-$(CONFIG_I2C_NVIDIA_GPU) += i2c-nvidia-gpu.o
diff --git a/drivers/i2c/busses/i2c-nct6775.c b/drivers/i2c/busses/i2c-nct6775.c
new file mode 100644
index 000000000000..e2b491a4b9f6
index 000000000000..0462f0952043
--- /dev/null
+++ b/drivers/i2c/busses/i2c-nct6775.c
@@ -0,0 +1,617 @@
@@ -0,0 +1,647 @@
+/*
+ * i2c-nct6775 - Driver for the SMBus master functionality of
+ * Nuvoton NCT677x Super-I/O chips
@@ -71,6 +71,7 @@ index 000000000000..e2b491a4b9f6
+#include <linux/hwmon-vid.h>
+#include <linux/err.h>
+#include <linux/mutex.h>
+#include <linux/delay.h>
+#include <linux/ioport.h>
+#include <linux/i2c.h>
+#include <linux/acpi.h>
@@ -115,6 +116,9 @@ index 000000000000..e2b491a4b9f6
+
+#define NCT6775_LD_SMBUS 0x0B
+
+/* Other settings */
+#define MAX_RETRIES 400
+
+enum kinds { nct6106, nct6775, nct6776, nct6779, nct6791, nct6792, nct6793,
+ nct6795, nct6796, nct6798 };
+
@@ -237,10 +241,13 @@ index 000000000000..e2b491a4b9f6
+ struct i2c_nct6775_adapdata *adapdata = i2c_get_adapdata(adap);
+ unsigned short nuvoton_nct6793d_smba = adapdata->smba;
+ int i, len, cnt;
+ union i2c_smbus_data tmp_data;
+ int timeout = 0;
+
+ tmp_data.word = 0;
+ cnt = 0;
+ len = 0;
+
+
+ outb_p(NCT6793D_SOFT_RESET, SMBHSTCTL);
+
+ switch (size) {
@@ -248,13 +255,14 @@ index 000000000000..e2b491a4b9f6
+ outb_p((addr << 1) | read_write,
+ SMBHSTADD);
+ break;
+ case I2C_SMBUS_BYTE:
+ case I2C_SMBUS_BYTE_DATA:
+ tmp_data.byte = data->byte;
+ case I2C_SMBUS_BYTE:
+ outb_p((addr << 1) | read_write,
+ SMBHSTADD);
+ outb_p(command, SMBHSTIDX);
+ if (read_write == I2C_SMBUS_WRITE) {
+ outb_p(data->byte, SMBHSTDAT);
+ outb_p(tmp_data.byte, SMBHSTDAT);
+ outb_p(NCT6793D_WRITE_BYTE, SMBHSTCMD);
+ }
+ else {
@@ -268,7 +276,7 @@ index 000000000000..e2b491a4b9f6
+ if (read_write == I2C_SMBUS_WRITE) {
+ outb_p(data->word & 0xff, SMBHSTDAT);
+ outb_p((data->word & 0xff00) >> 8, SMBHSTDAT);
+ outb_p(NCT6793D_WRITE_WORD, SMBHSTCMD);
+ outb_p(NCT6793D_WRITE_WORD, SMBHSTCMD);
+ }
+ else {
+ outb_p(NCT6793D_READ_WORD, SMBHSTCMD);
@@ -316,7 +324,16 @@ index 000000000000..e2b491a4b9f6
+
+ while ((size == I2C_SMBUS_BLOCK_DATA) && (len > 0)) {
+ if (read_write == I2C_SMBUS_WRITE) {
+ while ((inb_p(SMBHSTSTS) & NCT6793D_FIFO_EMPTY) == 0);
+ timeout = 0;
+ while ((inb_p(SMBHSTSTS) & NCT6793D_FIFO_EMPTY) == 0)
+ {
+ if(timeout > MAX_RETRIES)
+ {
+ return -ETIMEDOUT;
+ }
+ usleep_range(250, 500);
+ timeout++;
+ }
+
+ //Load more bytes into FIFO
+ if (len >= 4) {
@@ -335,10 +352,23 @@ index 000000000000..e2b491a4b9f6
+ len = 0;
+ }
+ }
+ else {
+ return -ENOTSUPP;
+ }
+
+ }
+
+ //wait for manual mode to complete
+ while ((inb_p(SMBHSTSTS) & NCT6793D_MANUAL_ACTIVE) != 0);
+ timeout = 0;
+ while ((inb_p(SMBHSTSTS) & NCT6793D_MANUAL_ACTIVE) != 0)
+ {
+ if(timeout > MAX_RETRIES)
+ {
+ return -ETIMEDOUT;
+ }
+ usleep_range(250, 500);
+ timeout++;
+ }
+
+ if ((inb_p(SMBHSTERR) & NCT6793D_NO_ACK) != 0) {
+ return -ENXIO;
@@ -654,10 +684,10 @@ index 000000000000..e2b491a4b9f6
+module_init(i2c_nct6775_init);
+module_exit(i2c_nct6775_exit);
diff --git a/drivers/i2c/busses/i2c-piix4.c b/drivers/i2c/busses/i2c-piix4.c
index c46c4bddc7ca..8565d08178a2 100644
index 30ded6422e7b..e25ce84c26af 100644
--- a/drivers/i2c/busses/i2c-piix4.c
+++ b/drivers/i2c/busses/i2c-piix4.c
@@ -468,11 +468,11 @@ static int piix4_transaction(struct i2c_adapter *piix4_adapter)
@@ -467,11 +467,11 @@ static int piix4_transaction(struct i2c_adapter *piix4_adapter)
if (srvrworks_csb5_delay) /* Extra delay for SERVERWORKS_CSB5 */
usleep_range(2000, 2100);
else
@@ -671,7 +701,7 @@ index c46c4bddc7ca..8565d08178a2 100644
/* If the SMBus is still busy, we give up */
if (timeout == MAX_TIMEOUT) {
@@ -963,6 +963,11 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
@@ -981,6 +981,11 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
retval = piix4_setup_sb800(dev, id, 1);
}
+65 -57
View File
@@ -5,7 +5,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = OpenRGB
TEMPLATE = app
VERSION = 0.0
VERSION = 0.1
win32:BUILDDATE = $$system(date /t)
unix:BUILDDATE = $$system(date -R)
GIT_COMMIT_ID = $$system(git --git-dir $$_PRO_FILE_PWD_/.git --work-tree $$_PRO_FILE_PWD_ rev-parse HEAD)
@@ -22,6 +22,7 @@ DEFINES += \
RC_ICONS = qt/OpenRGB.ico
INCLUDEPATH += \
dependencies/hidapi \
dependencies/libe131/src/ \
i2c_smbus/ \
i2c_tools/ \
@@ -29,17 +30,16 @@ INCLUDEPATH += \
serial_port/ \
super_io/ \
Controllers/AMDWraithPrismController/ \
Controllers/AuraController/ \
Controllers/AuraGPUController/ \
Controllers/CorsairController/ \
Controllers/CorsairCmdrProController/ \
Controllers/CorsairKeyboardController/ \
Controllers/CorsairNodeProController/ \
Controllers/CorsairProController/ \
Controllers/AuraSMBusController/ \
Controllers/CorsairPeripheralController/ \
Controllers/CorsairLightingNodeController/ \
Controllers/CorsairVengeanceController/ \
Controllers/CorsairVengeanceProController/ \
Controllers/CrucialController/ \
Controllers/Hue2Controller/ \
Controllers/HuePlusController/ \
Controllers/HyperXController/ \
Controllers/HyperXDRAMController/ \
Controllers/HyperXKeyboardController/ \
Controllers/LEDStripController/ \
Controllers/MSI3ZoneController/ \
@@ -47,18 +47,21 @@ INCLUDEPATH += \
Controllers/PatriotViperController/ \
Controllers/PolychromeController/ \
Controllers/PoseidonZRGBController/ \
Controllers/RedragonController/ \
Controllers/RGBFusionController/ \
Controllers/RGBFusion2Controller/ \
Controllers/RGBFusion2USBController/ \
Controllers/RGBFusionGPUController/ \
Controllers/ThermaltakeRiingController/ \
RGBController/ \
qt/
SOURCES += \
dependencies/hidapi/hidapi.c \
dependencies/libe131/src/e131.c \
main.cpp \
cli.cpp \
OpenRGB.cpp \
ProfileManager.cpp \
qt/OpenRGBDeviceInfoPage.cpp \
qt/OpenRGBDevicePage.cpp \
qt/OpenRGBDialog.cpp \
@@ -66,36 +69,35 @@ SOURCES += \
i2c_tools/i2c_tools.cpp \
net_port/net_port.cpp \
qt/OpenRGBDialog2.cpp \
qt/OpenRGBProfileSaveDialog.cpp \
qt/OpenRGBSoftwareInfoPage.cpp \
qt/OpenRGBProfileSaveDialog.cpp \
qt/OpenRGBSoftwareInfoPage.cpp \
qt/OpenRGBSystemInfoPage.cpp \
qt/OpenRGBZoneResizeDialog.cpp \
qt/hsv.cpp \
serial_port/serial_port.cpp \
super_io/super_io.cpp \
Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp \
Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \
Controllers/AuraController/AuraController.cpp \
Controllers/AuraController/AuraControllerDetect.cpp \
Controllers/AuraGPUController/AuraGPUController.cpp \
Controllers/AuraGPUController/AuraGPUControllerDetect.cpp \
Controllers/CorsairController/CorsairController.cpp \
Controllers/CorsairController/CorsairControllerDetect.cpp \
Controllers/CorsairCmdrProController/CorsairCmdrProController.cpp \
Controllers/CorsairCmdrProController/CorsairCmdrProControllerDetect.cpp \
Controllers/CorsairKeyboardController/CorsairKeyboardController.cpp \
Controllers/CorsairKeyboardController/CorsairKeyboardControllerDetect.cpp \
Controllers/CorsairNodeProController/CorsairNodeProController.cpp \
Controllers/CorsairNodeProController/CorsairNodeProControllerDetect.cpp \
Controllers/CorsairProController/CorsairProController.cpp \
Controllers/CorsairProController/CorsairProControllerDetect.cpp \
Controllers/AuraSMBusController/AuraSMBusController.cpp \
Controllers/AuraSMBusController/AuraSMBusControllerDetect.cpp \
Controllers/CorsairLightingNodeController/CorsairLightingNodeController.cpp \
Controllers/CorsairLightingNodeController/CorsairLightingNodeControllerDetect.cpp \
Controllers/CorsairPeripheralController/CorsairPeripheralController.cpp \
Controllers/CorsairPeripheralController/CorsairPeripheralControllerDetect.cpp \
Controllers/CorsairVengeanceController/CorsairVengeanceController.cpp \
Controllers/CorsairVengeanceController/CorsairVengeanceControllerDetect.cpp \
Controllers/CorsairVengeanceProController/CorsairVengeanceProController.cpp \
Controllers/CorsairVengeanceProController/CorsairVengeanceProControllerDetect.cpp \
Controllers/CrucialController/CrucialController.cpp \
Controllers/CrucialController/CrucialControllerDetect.cpp \
Controllers/Hue2Controller/Hue2Controller.cpp \
Controllers/Hue2Controller/Hue2ControllerDetect.cpp \
Controllers/HuePlusController/HuePlusController.cpp \
Controllers/HuePlusController/HuePlusControllerDetect.cpp \
Controllers/HyperXController/HyperXController.cpp \
Controllers/HyperXController/HyperXControllerDetect.cpp \
Controllers/HyperXDRAMController/HyperXDRAMController.cpp \
Controllers/HyperXDRAMController/HyperXDRAMControllerDetect.cpp \
Controllers/HyperXKeyboardController/HyperXKeyboardController.cpp \
Controllers/HyperXKeyboardController/HyperXKeyboardControllerDetect.cpp \
Controllers/LEDStripController/LEDStripController.cpp \
@@ -112,27 +114,29 @@ SOURCES += \
Controllers/PoseidonZRGBController/PoseidonZRGBControllerDetect.cpp \
Controllers/RGBFusionController/RGBFusionController.cpp \
Controllers/RGBFusionController/RGBFusionControllerDetect.cpp \
Controllers/RGBFusion2Controller/RGBFusion2Controller.cpp \
Controllers/RGBFusion2Controller/RGBFusion2ControllerDetect.cpp \
Controllers/RGBFusion2USBController/RGBFusion2USBController.cpp \
Controllers/RGBFusion2USBController/RGBFusion2USBControllerDetect.cpp \
Controllers/RGBFusionGPUController/RGBFusionGPUController.cpp \
Controllers/RGBFusionGPUController/RGBFusionGPUControllerDetect.cpp \
Controllers/RedragonController/RedragonK556Controller.cpp \
Controllers/RedragonController/RedragonM711Controller.cpp \
Controllers/RedragonController/RedragonControllerDetect.cpp \
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp \
Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp \
RGBController/RGBController.cpp \
RGBController/E131ControllerDetect.cpp \
RGBController/RGBController_AMDWraithPrism.cpp \
RGBController/RGBController_Aura.cpp \
RGBController/RGBController_AuraGPU.cpp \
RGBController/RGBController_Corsair.cpp \
RGBController/RGBController_CorsairCmdrPro.cpp \
RGBController/RGBController_CorsairKeyboard.cpp \
RGBController/RGBController_CorsairNodePro.cpp \
RGBController/RGBController_CorsairPro.cpp \
RGBController/RGBController_AuraSMBus.cpp \
RGBController/RGBController_CorsairLightingNode.cpp \
RGBController/RGBController_CorsairPeripheral.cpp \
RGBController/RGBController_CorsairVengeance.cpp \
RGBController/RGBController_CorsairVengeancePro.cpp \
RGBController/RGBController_Crucial.cpp \
RGBController/RGBController_Dummy.cpp \
RGBController/RGBController_Hue2.cpp \
RGBController/RGBController_HuePlus.cpp \
RGBController/RGBController_HyperX.cpp \
RGBController/RGBController_HyperXDRAM.cpp \
RGBController/RGBController_HyperXKeyboard.cpp \
RGBController/RGBController_E131.cpp \
RGBController/RGBController_LEDStrip.cpp \
@@ -141,12 +145,15 @@ SOURCES += \
RGBController/RGBController_PatriotViper.cpp \
RGBController/RGBController_Polychrome.cpp \
RGBController/RGBController_PoseidonZRGB.cpp \
RGBController/RGBController_RedragonK556.cpp \
RGBController/RGBController_RedragonM711.cpp \
RGBController/RGBController_RGBFusion.cpp \
RGBController/RGBController_RGBFusion2.cpp \
RGBController/RGBController_RGBFusion2USB.cpp \
RGBController/RGBController_RGBFusionGPU.cpp \
RGBController/RGBController_ThermaltakeRiing.cpp \
HEADERS += \
ProfileManager.h \
qt/OpenRGBDeviceInfoPage.h \
qt/OpenRGBDevicePage.h \
qt/OpenRGBDialog.h \
@@ -154,24 +161,24 @@ HEADERS += \
i2c_tools/i2c_tools.h \
net_port/net_port.h \
qt/OpenRGBDialog2.h \
qt/OpenRGBProfileSaveDialog.h \
qt/OpenRGBSoftwareInfoPage.h \
qt/OpenRGBProfileSaveDialog.h \
qt/OpenRGBSoftwareInfoPage.h \
qt/OpenRGBSystemInfoPage.h \
qt/OpenRGBZoneResizeDialog.h \
serial_port/find_usb_serial_port.h \
serial_port/serial_port.h \
super_io/super_io.h \
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
Controllers/AuraController/AuraController.h \
Controllers/AuraGPUController/AuraGPUController.h \
Controllers/CorsairController/CorsairController.h \
Controllers/CorsairCmdrProController/CorsairCmdrProController.h \
Controllers/CorsairKeyboardController/CorsairKeyboardController.h \
Controllers/CorsairNodeProController/CorsairNodeProController.h \
Controllers/CorsairProController/CorsairProController.h \
Controllers/AuraSMBusController/AuraSMBusController.h \
Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h \
Controllers/CorsairPeripheralController/CorsairPeripheralController.h \
Controllers/CorsairVengeanceController/CorsairVengeanceController.h \
Controllers/CorsairVengeanceProController/CorsairVengeanceProController.h \
Controllers/CrucialController/CrucialController.h \
Controllers/Hue2Controller/Hue2Controller.h \
Controllers/HuePlusController/HuePlusController.h \
Controllers/HyperXController/HyperXController.h \
Controllers/HyperXDRAMController/HyperXDRAMController.h \
Controllers/HyperXKeyboardController/HyperXKeyboardController.h \
Controllers/LEDStripController/LEDStripController.h \
Controllers/MSI3ZoneController/MSI3ZoneController.h \
@@ -180,23 +187,25 @@ HEADERS += \
Controllers/PolychromeController/PolychromeController.h \
Controllers/PoseidonZRGBController/PoseidonZRGBController.h \
Controllers/RGBFusionController/RGBFusionController.h \
Controllers/RGBFusion2Controller/RGBFusion2Controller.h \
Controllers/RGBFusion2USBController/RGBFusion2USBController.h \
Controllers/RGBFusionGPUController/RGBFusionGPUController.h \
Controllers/RedragonController/RedragonK556Controller.h \
Controllers/RedragonController/RedragonM711Controller.h \
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h \
RGBController/RGBController.h \
RGBController/RGBController_AMDWraithPrism.h \
RGBController/RGBController_Aura.h \
RGBController/RGBController_AuraGPU.h \
RGBController/RGBController_Corsair.h \
RGBController/RGBController_CorsairCmdrPro.h \
RGBController/RGBController_CorsairNodePro.h \
RGBController/RGBController_CorsairPro.h \
RGBController/RGBController_AuraSMBus.h \
RGBController/RGBController_CorsairLightingNode.h \
RGBController/RGBController_CorsairPeripheral.h \
RGBController/RGBController_CorsairVengeance.h \
RGBController/RGBController_CorsairVengeancePro.h \
RGBController/RGBController_Crucial.h \
RGBController/RGBController_Dummy.h \
RGBController/RGBController_E131.h \
RGBController/RGBController_Hue2.h \
RGBController/RGBController_HuePlus.h \
RGBController/RGBController_HyperX.h \
RGBController/RGBController_HyperXDRAM.h \
RGBController/RGBController_HyperXKeyboard.h \
RGBController/RGBController_LEDStrip.h \
RGBController/RGBController_MSI3Zone.h \
@@ -204,8 +213,10 @@ HEADERS += \
RGBController/RGBController_PatriotViper.h \
RGBController/RGBController_Polychrome.h \
RGBController/RGBController_PoseidonZRGB.h \
RGBController/RGBController_RedragonK556.h \
RGBController/RGBController_RedragonM711.h \
RGBController/RGBController_RGBFusion.h \
RGBController/RGBController_RGBFusion2.h \
RGBController/RGBController_RGBFusion2USB.h \
RGBController/RGBController_RGBFusionGPU.h \
RGBController/RGBController_ThermaltakeRiing.h \
@@ -219,7 +230,8 @@ FORMS += \
qt/OpenRGBDialog2.ui \
qt/OpenRGBProfileSaveDialog.ui \
qt/OpenRGBSoftwareInfoPage.ui \
qt/OpenRGBSystemInfoPage.ui
qt/OpenRGBSystemInfoPage.ui \
qt/OpenRGBZoneResizeDialog.ui
#-----------------------------------------------
# Windows specific project configuration
@@ -227,14 +239,12 @@ FORMS += \
win32:INCLUDEPATH += \
dependencies/inpout32_1501/Win32/ \
dependencies/libusb-1.0.22/include \
dependencies/hidapi \
dependencies/NVFC \
dependencies/openrazer-win32 \
wmi/ \
win32:SOURCES += \
dependencies/NVFC/nvapi.cpp \
dependencies/hidapi/hid_win.c \
i2c_smbus/i2c_smbus_i801.cpp \
i2c_smbus/i2c_smbus_nct6775.cpp \
i2c_smbus/i2c_smbus_nvapi.cpp \
@@ -299,7 +309,6 @@ win32:contains(QMAKE_TARGET.arch, x86) {
# Linux specific project configuration
#-----------------------------------------------
unix:INCLUDEPATH += \
dependencies/hidapi \
unix:HEADERS += \
i2c_smbus/i2c_smbus_linux.h \
@@ -310,7 +319,6 @@ unix:LIBS += \
-lstdc++fs \
unix:SOURCES += \
dependencies/hidapi/hid_win.c \
i2c_smbus/i2c_smbus_linux.cpp \
serial_port/find_usb_serial_port_linux.cpp \
RGBController/OpenRazerDetect.cpp \
+300
View File
@@ -0,0 +1,300 @@
#include "ProfileManager.h"
#include "RGBController_Dummy.h"
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
#include <experimental/filesystem>
#include <fstream>
#include <iostream>
#include <cstring>
namespace fs = std::experimental::filesystem;
ProfileManager::ProfileManager(std::vector<RGBController *>& control) : controllers(control)
{
UpdateProfileList();
}
ProfileManager::~ProfileManager()
{
}
bool ProfileManager::SaveProfile(std::string profile_name)
{
/*---------------------------------------------------------*\
| If a name was entered, save the profile file |
\*---------------------------------------------------------*/
if(profile_name != "")
{
/*---------------------------------------------------------*\
| Open an output file in binary mode |
\*---------------------------------------------------------*/
std::ofstream controller_file(profile_name, std::ios::out | std::ios::binary);
/*---------------------------------------------------------*\
| Write header |
| 16 bytes - "OPENRGB_PROFILE" |
| 4 bytes - Version, unsigned int |
\*---------------------------------------------------------*/
unsigned int profile_version = 1;
controller_file.write("OPENRGB_PROFILE", 16);
controller_file.write((char *)&profile_version, sizeof(unsigned int));
/*---------------------------------------------------------*\
| Write controller data for each controller |
\*---------------------------------------------------------*/
for(std::size_t controller_index = 0; controller_index < controllers.size(); controller_index++)
{
unsigned char *controller_data = controllers[controller_index]->GetDeviceDescription();
unsigned int controller_size;
memcpy(&controller_size, controller_data, sizeof(controller_size));
controller_file.write((const char *)controller_data, controller_size);
}
/*---------------------------------------------------------*\
| Close the file when done |
\*---------------------------------------------------------*/
controller_file.close();
/*---------------------------------------------------------*\
| Update the profile list |
\*---------------------------------------------------------*/
UpdateProfileList();
return(true);
}
else
{
return(false);
}
}
bool ProfileManager::LoadProfile(std::string profile_name)
{
return(LoadProfileWithOptions(profile_name, false, true));
}
bool ProfileManager::LoadSizeFromProfile(std::string profile_name)
{
return(LoadProfileWithOptions(profile_name, true, false));
}
bool ProfileManager::LoadProfileWithOptions
(
std::string profile_name,
bool load_size,
bool load_settings
)
{
std::vector<RGBController*> temp_controllers;
std::vector<bool> temp_controller_used;
unsigned int controller_size;
unsigned int controller_offset = 0;
bool ret_val = false;
std::string filename = profile_name;
/*---------------------------------------------------------*\
| Open input file in binary mode |
\*---------------------------------------------------------*/
std::ifstream controller_file(filename, std::ios::in | std::ios::binary);
/*---------------------------------------------------------*\
| Read and verify file header |
\*---------------------------------------------------------*/
char header_string[16];
unsigned int header_version;
controller_file.read(header_string, 16);
controller_file.read((char *)&header_version, sizeof(unsigned int));
controller_offset += 16 + sizeof(unsigned int);
controller_file.seekg(controller_offset);
if(strcmp(header_string, "OPENRGB_PROFILE") == 0)
{
if(header_version == 1)
{
/*---------------------------------------------------------*\
| Read controller data from file until EOF |
\*---------------------------------------------------------*/
while(!(controller_file.peek() == EOF))
{
controller_file.read((char *)&controller_size, sizeof(controller_size));
unsigned char *controller_data = new unsigned char[controller_size];
controller_file.seekg(controller_offset);
controller_file.read((char *)controller_data, controller_size);
RGBController_Dummy *temp_controller = new RGBController_Dummy();
temp_controller->ReadDeviceDescription(controller_data);
temp_controllers.push_back(temp_controller);
temp_controller_used.push_back(false);
delete[] controller_data;
controller_offset += controller_size;
controller_file.seekg(controller_offset);
ret_val = true;
}
/*---------------------------------------------------------*\
| Loop through all controllers. For each controller, search|
| all saved controllers until a match is found |
\*---------------------------------------------------------*/
for(std::size_t controller_index = 0; controller_index < controllers.size(); controller_index++)
{
RGBController *controller_ptr = controllers[controller_index];
for(std::size_t temp_index = 0; temp_index < temp_controllers.size(); temp_index++)
{
RGBController *temp_controller = temp_controllers[temp_index];
/*---------------------------------------------------------*\
| Test if saved controller data matches this controller |
\*---------------------------------------------------------*/
if((temp_controller_used[temp_index] == false )
&&(temp_controller->type == controller_ptr->type )
&&(temp_controller->name == controller_ptr->name )
&&(temp_controller->description == controller_ptr->description)
&&(temp_controller->version == controller_ptr->version )
&&(temp_controller->serial == controller_ptr->serial )
&&(temp_controller->location == controller_ptr->location ))
{
/*---------------------------------------------------------*\
| Update zone sizes if requested |
\*---------------------------------------------------------*/
if(load_size)
{
if(temp_controller->zones.size() == controller_ptr->zones.size())
{
for(std::size_t zone_idx = 0; zone_idx < temp_controller->zones.size(); zone_idx++)
{
if((temp_controller->zones[zone_idx].name == controller_ptr->zones[zone_idx].name )
&&(temp_controller->zones[zone_idx].type == controller_ptr->zones[zone_idx].type )
&&(temp_controller->zones[zone_idx].leds_min == controller_ptr->zones[zone_idx].leds_min )
&&(temp_controller->zones[zone_idx].leds_max == controller_ptr->zones[zone_idx].leds_max )
&&(temp_controller->zones[zone_idx].leds_count != controller_ptr->zones[zone_idx].leds_count))
{
controller_ptr->ResizeZone(zone_idx, temp_controller->zones[zone_idx].leds_count);
}
}
}
}
/*---------------------------------------------------------*\
| Update settings if requested |
\*---------------------------------------------------------*/
if(load_settings)
{
/*---------------------------------------------------------*\
| Update all modes |
\*---------------------------------------------------------*/
if(temp_controller->modes.size() == controller_ptr->modes.size())
{
for(std::size_t mode_index = 0; mode_index < temp_controller->modes.size(); mode_index++)
{
if((temp_controller->modes[mode_index].name == controller_ptr->modes[mode_index].name )
&&(temp_controller->modes[mode_index].value == controller_ptr->modes[mode_index].value )
&&(temp_controller->modes[mode_index].flags == controller_ptr->modes[mode_index].flags )
&&(temp_controller->modes[mode_index].speed_min == controller_ptr->modes[mode_index].speed_min )
&&(temp_controller->modes[mode_index].speed_max == controller_ptr->modes[mode_index].speed_max )
&&(temp_controller->modes[mode_index].colors_min == controller_ptr->modes[mode_index].colors_min)
&&(temp_controller->modes[mode_index].colors_max == controller_ptr->modes[mode_index].colors_max))
{
controller_ptr->modes[mode_index].speed = temp_controller->modes[mode_index].speed;
controller_ptr->modes[mode_index].direction = temp_controller->modes[mode_index].direction;
controller_ptr->modes[mode_index].color_mode = temp_controller->modes[mode_index].color_mode;
controller_ptr->modes[mode_index].colors.resize(temp_controller->modes[mode_index].colors.size());
for(std::size_t mode_color_index = 0; mode_color_index < temp_controller->modes[mode_index].colors.size(); mode_color_index++)
{
controller_ptr->modes[mode_index].colors[mode_color_index] = temp_controller->modes[mode_index].colors[mode_color_index];
}
}
}
controller_ptr->active_mode = temp_controller->active_mode;
}
/*---------------------------------------------------------*\
| Update all colors |
\*---------------------------------------------------------*/
if(temp_controller->colors.size() == controller_ptr->colors.size())
{
for(std::size_t color_index = 0; color_index < temp_controller->colors.size(); color_index++)
{
controller_ptr->colors[color_index] = temp_controller->colors[color_index];
}
}
temp_controller_used[temp_index] = true;
break;
}
}
}
}
}
}
return(ret_val);
}
void ProfileManager::DeleteProfile(std::string profile_name)
{
remove(profile_name.c_str());
UpdateProfileList();
}
void ProfileManager::UpdateProfileList()
{
profile_list.clear();
/*---------------------------------------------------------*\
| Load profiles by looking for .orp files in current dir |
\*---------------------------------------------------------*/
for(const auto & entry : fs::directory_iterator("."))
{
std::string filename = entry.path().filename().string();
if(filename.find(".orp") != std::string::npos)
{
/*---------------------------------------------------------*\
| Open input file in binary mode |
\*---------------------------------------------------------*/
std::ifstream profile_file(filename, std::ios::in | std::ios::binary);
/*---------------------------------------------------------*\
| Read and verify file header |
\*---------------------------------------------------------*/
char header_string[16];
unsigned int header_version;
profile_file.read(header_string, 16);
profile_file.read((char *)&header_version, sizeof(unsigned int));
if(strcmp(header_string, "OPENRGB_PROFILE") == 0)
{
if(header_version == 1)
{
/*---------------------------------------------------------*\
| Add this profile to the list |
\*---------------------------------------------------------*/
profile_list.push_back(filename);
}
}
profile_file.close();
}
}
}
+29
View File
@@ -0,0 +1,29 @@
#include "RGBController.h"
#pragma once
class ProfileManager
{
public:
ProfileManager(std::vector<RGBController *>& control);
~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;
protected:
std::vector<RGBController *>& controllers;
private:
void UpdateProfileList();
bool LoadProfileWithOptions
(
std::string profile_name,
bool load_size,
bool load_settings
);
};
-2
View File
@@ -68,8 +68,6 @@ void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
if(dir == NULL)
{
closedir(dir);
driver_to_read++;
continue;
}
+96 -81
View File
@@ -25,8 +25,6 @@ unsigned char * RGBController::GetDeviceDescription()
unsigned short *mode_num_colors = new unsigned short[num_modes];
unsigned short *zone_map_rows = new unsigned short[num_zones];
data_size += sizeof(data_size);
data_size += sizeof(device_type);
data_size += name_len + sizeof(name_len);
@@ -62,21 +60,12 @@ unsigned char * RGBController::GetDeviceDescription()
for(int zone_index = 0; zone_index < num_zones; zone_index++)
{
zone_name_len[zone_index] = strlen(zones[zone_index].name.c_str()) + 1;
zone_map_rows[zone_index] = zones[zone_index].map.size();
data_size += zone_name_len[zone_index] + sizeof(zone_name_len[zone_index]);
data_size += sizeof(zones[zone_index].type);
data_size += sizeof(zone_map_rows[zone_index]);
for(int row_index = 0; row_index < zone_map_rows[zone_index]; row_index++)
{
data_size += sizeof(unsigned short);
for(int row_led_index = 0; row_led_index < zones[zone_index].map[row_index].size(); row_led_index++)
{
data_size += sizeof(int);
}
}
data_size += sizeof(zones[zone_index].leds_min);
data_size += sizeof(zones[zone_index].leds_max);
data_size += sizeof(zones[zone_index].leds_count);
}
data_size += sizeof(num_leds);
@@ -86,6 +75,8 @@ unsigned char * RGBController::GetDeviceDescription()
led_name_len[led_index] = strlen(leds[led_index].name.c_str()) + 1;
data_size += led_name_len[led_index] + sizeof(led_name_len[led_index]);
data_size += sizeof(leds[led_index].value);
}
data_size += sizeof(num_colors);
@@ -279,35 +270,22 @@ unsigned char * RGBController::GetDeviceDescription()
data_ptr += sizeof(zones[zone_index].type);
/*---------------------------------------------------------*\
| Copy in zone map number of rows |
| Copy in zone minimum LED count (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &zone_map_rows[zone_index], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
memcpy(&data_buf[data_ptr], &zones[zone_index].leds_min, sizeof(zones[zone_index].leds_min));
data_ptr += sizeof(zones[zone_index].leds_min);
/*---------------------------------------------------------*\
| Copy in rows |
| Copy in zone maximum LED count (data) |
\*---------------------------------------------------------*/
for(int row_index = 0; row_index < zone_map_rows[zone_index]; row_index++)
{
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
unsigned short zone_map_row_size = zones[zone_index].map[row_index].size();
memcpy(&data_buf[data_ptr], &zone_map_row_size, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
memcpy(&data_buf[data_ptr], &zones[zone_index].leds_max, sizeof(zones[zone_index].leds_max));
data_ptr += sizeof(zones[zone_index].leds_max);
/*---------------------------------------------------------*\
| Copy in row LEDs |
\*---------------------------------------------------------*/
for(int row_led_index = 0; row_led_index < zone_map_row_size; row_led_index++)
{
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &zones[zone_index].map[row_index][row_led_index], sizeof(zones[zone_index].map[row_index][row_led_index]));
data_ptr += sizeof(zones[zone_index].map[row_index][row_led_index]);
}
}
/*---------------------------------------------------------*\
| Copy in zone LED count (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &zones[zone_index].leds_count, sizeof(zones[zone_index].leds_count));
data_ptr += sizeof(zones[zone_index].leds_count);
}
/*---------------------------------------------------------*\
@@ -330,6 +308,12 @@ unsigned char * RGBController::GetDeviceDescription()
strcpy((char *)&data_buf[data_ptr], leds[led_index].name.c_str());
data_ptr += ledname_len;
/*---------------------------------------------------------*\
| Copy in LED value (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &leds[led_index].value, sizeof(leds[led_index].value));
data_ptr += sizeof(leds[led_index].value);
}
/*---------------------------------------------------------*\
@@ -356,7 +340,6 @@ unsigned char * RGBController::GetDeviceDescription()
delete[] led_name_len;
delete[] mode_num_colors;
delete[] zone_map_rows;
return(data_buf);
}
@@ -563,44 +546,22 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf)
data_ptr += sizeof(new_zone.type);
/*---------------------------------------------------------*\
| Copy in zone map number of rows |
| Copy in zone minimum LED count (data) |
\*---------------------------------------------------------*/
unsigned short zone_map_rows;
memcpy(&zone_map_rows, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
memcpy(&new_zone.leds_min, &data_buf[data_ptr], sizeof(new_zone.leds_min));
data_ptr += sizeof(new_zone.leds_min);
/*---------------------------------------------------------*\
| Copy in rows |
| Copy in zone maximum LED count (data) |
\*---------------------------------------------------------*/
for(int row_index = 0; row_index < zone_map_rows; row_index++)
{
std::vector<int> new_zone_map_row;
memcpy(&new_zone.leds_max, &data_buf[data_ptr], sizeof(new_zone.leds_max));
data_ptr += sizeof(new_zone.leds_max);
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
unsigned short zone_map_row_size;
memcpy(&zone_map_row_size, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in row LEDs |
\*---------------------------------------------------------*/
for(int row_led_index = 0; row_led_index < zone_map_row_size; row_led_index++)
{
int new_index;
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
memcpy(&new_index, &data_buf[data_ptr], sizeof(int));
data_ptr += sizeof(int);
new_zone_map_row.push_back(new_index);
}
new_zone.map.push_back(new_zone_map_row);
}
/*---------------------------------------------------------*\
| Copy in zone LED count (data) |
\*---------------------------------------------------------*/
memcpy(&new_zone.leds_count, &data_buf[data_ptr], sizeof(new_zone.leds_count));
data_ptr += sizeof(new_zone.leds_count);
zones.push_back(new_zone);
}
@@ -629,6 +590,12 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf)
new_led.name = (char *)&data_buf[data_ptr];
data_ptr += ledname_len;
/*---------------------------------------------------------*\
| Copy in LED value (data) |
\*---------------------------------------------------------*/
memcpy(&new_led.value, &data_buf[data_ptr], sizeof(new_led.value));
data_ptr += sizeof(new_led.value);
leds.push_back(new_led);
}
@@ -656,7 +623,58 @@ void RGBController::ReadDeviceDescription(unsigned char* data_buf)
}
}
RGBColor RGBController::GetLED(int led)
void RGBController::SetupColors()
{
unsigned int total_led_count;
/*---------------------------------------------------------*\
| Determine total number of LEDs on the device |
\*---------------------------------------------------------*/
total_led_count = 0;
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
total_led_count += zones[zone_idx].leds_count;
}
/*---------------------------------------------------------*\
| Set the size of the color buffer to the number of LEDs |
\*---------------------------------------------------------*/
colors.resize(total_led_count);
/*---------------------------------------------------------*\
| Set the color buffer pointers on each zone |
\*---------------------------------------------------------*/
total_led_count = 0;
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
zones[zone_idx].start_idx=total_led_count;
if((colors.size() > 0) && (zones[zone_idx].leds_count > 0))
{
zones[zone_idx].colors = &colors[total_led_count];
}
else
{
zones[zone_idx].colors = NULL;
}
if((leds.size() > 0) && (zones[zone_idx].leds_count > 0))
{
zones[zone_idx].leds = &leds[total_led_count];
}
else
{
zones[zone_idx].leds = NULL;
}
total_led_count += zones[zone_idx].leds_count;
}
}
RGBColor RGBController::GetLED(unsigned int led)
{
if(led < colors.size())
{
@@ -668,7 +686,7 @@ RGBColor RGBController::GetLED(int led)
}
}
void RGBController::SetLED(int led, RGBColor color)
void RGBController::SetLED(unsigned int led, RGBColor color)
{
if(led < colors.size())
{
@@ -680,9 +698,9 @@ void RGBController::SetLED(int led, RGBColor color)
void RGBController::SetAllLEDs(RGBColor color)
{
for(int led = 0; led < colors.size(); led++)
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
colors[led] = color;
SetAllZoneLEDs(zone_idx, color);
}
UpdateLEDs();
@@ -690,12 +708,9 @@ void RGBController::SetAllLEDs(RGBColor color)
void RGBController::SetAllZoneLEDs(int zone, RGBColor color)
{
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
for (std::size_t color_idx = 0; color_idx < zones[zone].leds_count; color_idx++)
{
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
{
colors[zones[zone].map[x][y]] = color;
}
zones[zone].colors[color_idx] = color;
}
UpdateZoneLEDs(zone);
+18 -7
View File
@@ -84,7 +84,8 @@ typedef struct
typedef struct
{
std::string name; /* LED name */
std::string name; /* LED name */
unsigned int value; /* Device-specific LED value */
} led;
typedef int zone_type;
@@ -116,10 +117,14 @@ std::string device_type_to_str(device_type type);
typedef struct
{
std::string name; /* Zone name */
zone_type type; /* Zone type */
std::vector<std::vector<int>>
map; /* LED index map */
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 */
} zone;
class RGBController
@@ -142,8 +147,10 @@ public:
/*---------------------------------------------------------*\
| Generic functions implemented in RGBController.cpp |
\*---------------------------------------------------------*/
RGBColor GetLED(int led);
void SetLED(int led, RGBColor color);
void SetupColors();
RGBColor GetLED(unsigned int led);
void SetLED(unsigned int led, RGBColor color);
void SetAllLEDs(RGBColor color);
void SetAllZoneLEDs(int zone, RGBColor color);
@@ -156,6 +163,10 @@ public:
/*---------------------------------------------------------*\
| Functions to be implemented in device implementation |
\*---------------------------------------------------------*/
virtual void SetupZones() = 0;
virtual void ResizeZone(int zone, int new_size) = 0;
virtual void UpdateLEDs() = 0;
virtual void UpdateZoneLEDs(int zone) = 0;
virtual void UpdateSingleLED(int led) = 0;
+55 -38
View File
@@ -84,44 +84,7 @@ RGBController_AMDWraithPrism::RGBController_AMDWraithPrism(AMDWraithPrismControl
Swirl.speed = AMD_WRAITH_PRISM_SPEED_NORMAL;
modes.push_back(Swirl);
led logo_led;
logo_led.name = "Logo";
leds.push_back(logo_led);
colors.push_back(0x00000000);
zone logo_zone;
logo_zone.name = "Logo";
logo_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> logo_zone_map;
logo_zone_map.push_back(0);
logo_zone.map.push_back(logo_zone_map);
zones.push_back(logo_zone);
led fan_led;
fan_led.name = "Fan";
leds.push_back(fan_led);
colors.push_back(0x00000000);
zone fan_zone;
fan_zone.name = "Fan";
fan_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> fan_zone_map;
fan_zone_map.push_back(1);
fan_zone.map.push_back(fan_zone_map);
zones.push_back(fan_zone);
led ring_led;
ring_led.name = "Ring";
leds.push_back(ring_led);
colors.push_back(0x00000000);
zone ring_zone;
ring_zone.name = "Ring";
ring_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> ring_zone_map;
ring_zone_map.push_back(2);
ring_zone.map.push_back(ring_zone_map);
zones.push_back(ring_zone);
SetupZones();
}
RGBController_AMDWraithPrism::~RGBController_AMDWraithPrism()
@@ -129,6 +92,60 @@ RGBController_AMDWraithPrism::~RGBController_AMDWraithPrism()
}
void RGBController_AMDWraithPrism::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
zone logo_zone;
logo_zone.name = "Logo";
logo_zone.type = ZONE_TYPE_SINGLE;
logo_zone.leds_min = 1;
logo_zone.leds_max = 1;
logo_zone.leds_count = 1;
zones.push_back(logo_zone);
zone fan_zone;
fan_zone.name = "Fan";
fan_zone.type = ZONE_TYPE_SINGLE;
fan_zone.leds_min = 1;
fan_zone.leds_max = 1;
fan_zone.leds_count = 1;
zones.push_back(fan_zone);
zone ring_zone;
ring_zone.name = "Ring";
ring_zone.type = ZONE_TYPE_SINGLE;
ring_zone.leds_min = 1;
ring_zone.leds_max = 1;
ring_zone.leds_count = 1;
zones.push_back(ring_zone);
/*---------------------------------------------------------*\
| Set up LEDs |
\*---------------------------------------------------------*/
led logo_led;
logo_led.name = "Logo LED";
leds.push_back(logo_led);
led fan_led;
fan_led.name = "Fan LED";
leds.push_back(fan_led);
led ring_led;
ring_led.name = "Ring LED";
leds.push_back(ring_led);
SetupColors();
}
void RGBController_AMDWraithPrism::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AMDWraithPrism::UpdateLEDs()
{
unsigned char red = RGBGetRValue(colors[0]);
@@ -16,6 +16,11 @@ class RGBController_AMDWraithPrism : public RGBController
public:
RGBController_AMDWraithPrism(AMDWraithPrismController* wraith_ptr);
~RGBController_AMDWraithPrism();
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
+66 -46
View File
@@ -29,7 +29,7 @@ int RGBController_AuraGPU::GetDeviceMode()
break;
}
for(int mode = 0; mode < modes.size(); mode++)
for(std::size_t mode = 0; mode < modes.size(); mode++)
{
if(modes[mode].value == dev_mode)
{
@@ -41,39 +41,10 @@ int RGBController_AuraGPU::GetDeviceMode()
return(active_mode);
}
void RGBController_AuraGPU::UpdateLEDs()
{
for(std::size_t led = 0; led < colors.size(); led++)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
if (GetMode() == 0)
{
aura_gpu->SetLEDColorsDirect(red, grn, blu);
}
else
{
aura_gpu->SetLEDColorsEffect(red, grn, blu);
}
}
}
void RGBController_AuraGPU::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_AuraGPU::UpdateSingleLED(int led)
{
UpdateLEDs();
}
RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * aura_gpu_ptr)
{
aura_gpu = aura_gpu_ptr;
name = aura_gpu->GetDeviceName();
version = "0.00.1";
@@ -101,7 +72,7 @@ RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * aura_gpu_ptr)
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Breathing;
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AURA_GPU_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
@@ -122,28 +93,77 @@ RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * aura_gpu_ptr)
Spectrum_Cycle.color_mode = MODE_COLORS_NONE;
modes.push_back(Spectrum_Cycle);
colors.resize(1);
SetupZones();
led aura_gpu_led;
active_mode = GetDeviceMode();
}
void RGBController_AuraGPU::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zone |
\*---------------------------------------------------------*/
zone aura_gpu_zone;
aura_gpu_zone.name = "GPU";
aura_gpu_zone.type = ZONE_TYPE_SINGLE;
aura_gpu_zone.leds_min = 1;
aura_gpu_zone.leds_max = 1;
aura_gpu_zone.leds_count = 1;
zones.push_back(aura_gpu_zone);
/*---------------------------------------------------------*\
| Set up LED |
\*---------------------------------------------------------*/
led aura_gpu_led;
aura_gpu_led.name = "GPU";
leds.push_back(aura_gpu_led);
zone aura_gpu_zone;
aura_gpu_zone.name = "GPU";
aura_gpu_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> aura_gpu_zone_map;
aura_gpu_zone_map.push_back(0);
aura_gpu_zone.map.push_back(aura_gpu_zone_map);
zones.push_back(aura_gpu_zone);
SetupColors();
/*---------------------------------------------------------*\
| Initialize color |
\*---------------------------------------------------------*/
unsigned char red = aura_gpu->GetLEDRed();
unsigned char grn = aura_gpu->GetLEDGreen();
unsigned char blu = aura_gpu->GetLEDBlue();
colors[0] = ToRGBColor(red, grn, blu);
active_mode = GetDeviceMode();
colors[0] = ToRGBColor(red, grn, blu);
}
void RGBController_AuraGPU::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AuraGPU::UpdateLEDs()
{
for(std::size_t led = 0; led < colors.size(); led++)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
if (GetMode() == 0)
{
aura_gpu->SetLEDColorsDirect(red, grn, blu);
}
else
{
aura_gpu->SetLEDColorsEffect(red, grn, blu);
}
}
}
void RGBController_AuraGPU::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_AuraGPU::UpdateSingleLED(int /*led*/)
{
UpdateLEDs();
}
void RGBController_AuraGPU::SetCustomMode()
@@ -173,4 +193,4 @@ void RGBController_AuraGPU::UpdateMode()
}
aura_gpu->SetMode(new_mode);
}
}
+6 -1
View File
@@ -15,6 +15,11 @@ class RGBController_AuraGPU : public RGBController
{
public:
RGBController_AuraGPU(AuraGPUController* aura_gpu_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -26,4 +31,4 @@ private:
AuraGPUController* aura_gpu;
int GetDeviceMode();
};
};
@@ -1,15 +1,15 @@
/*-----------------------------------------*\
| RGBController_Aura.cpp |
| RGBController_AuraSMBus.cpp |
| |
| Generic RGB Interface for OpenAuraSDK |
| Asus Aura driver |
| Asus Aura SMBus driver |
| |
| Adam Honse (CalcProgrammer1) 6/13/2019 |
\*-----------------------------------------*/
#include "RGBController_Aura.h"
#include "RGBController_AuraSMBus.h"
int RGBController_Aura::GetDeviceMode()
int RGBController_AuraSMBus::GetDeviceMode()
{
int dev_mode = aura->AuraRegisterRead(AURA_REG_MODE);
int color_mode = MODE_COLORS_PER_LED;
@@ -44,7 +44,7 @@ int RGBController_Aura::GetDeviceMode()
break;
}
for(int mode = 0; mode < modes.size(); mode++)
for(std::size_t mode = 0; mode < modes.size(); mode++)
{
if(modes[mode].value == dev_mode)
{
@@ -56,7 +56,7 @@ int RGBController_Aura::GetDeviceMode()
return(active_mode);
}
void RGBController_Aura::UpdateLEDs()
void RGBController_AuraSMBus::UpdateLEDs()
{
for(std::size_t led = 0; led < colors.size(); led++)
{
@@ -75,31 +75,28 @@ void RGBController_Aura::UpdateLEDs()
}
}
void RGBController_Aura::UpdateZoneLEDs(int zone)
void RGBController_AuraSMBus::UpdateZoneLEDs(int zone)
{
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
for (std::size_t led_idx = 0; led_idx < zones[zone].leds_count; led_idx++)
{
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
{
int led = zones[zone].map[x][y];
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
int led = zones[zone].leds[led_idx].value;
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if (GetMode() == 0)
{
aura->SetLEDColorDirect(led, red, grn, blu);
}
else
{
aura->SetLEDColorEffect(led, red, grn, blu);
}
if (GetMode() == 0)
{
aura->SetLEDColorDirect(led, red, grn, blu);
}
else
{
aura->SetLEDColorEffect(led, red, grn, blu);
}
}
}
void RGBController_Aura::UpdateSingleLED(int led)
void RGBController_AuraSMBus::UpdateSingleLED(int led)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
@@ -116,10 +113,8 @@ void RGBController_Aura::UpdateSingleLED(int led)
}
}
RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
RGBController_AuraSMBus::RGBController_AuraSMBus(AuraSMBusController * aura_ptr)
{
std::vector<unsigned char> aura_channels;
aura = aura_ptr;
version = aura->GetDeviceName();
@@ -134,6 +129,7 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
type = DEVICE_TYPE_MOTHERBOARD;
name = "ASUS Aura Motherboard";
}
description = "ASUS Aura SMBus Device";
mode Direct;
Direct.name = "Direct";
@@ -205,82 +201,134 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
RandomFlicker.color_mode = MODE_COLORS_NONE;
modes.push_back(RandomFlicker);
colors.resize(aura->GetLEDCount());
for (std::size_t i = 0; i < aura->GetLEDCount(); i++)
{
aura_channels.push_back(aura->GetChannel(i));
led* new_led = new led();
new_led->name = aura->GetChannelName(i);
new_led->name.append(std::to_string(i));
leds.push_back(*new_led);
unsigned char red = aura->GetLEDRed(i);
unsigned char grn = aura->GetLEDGreen(i);
unsigned char blu = aura->GetLEDBlue(i);
colors[i] = ToRGBColor(red, grn, blu);
}
std::vector<unsigned char> aura_zones;
// Search through all LEDs and create zones for each channel type
for (std::size_t i = 0; i < aura_channels.size(); i++)
{
bool matched = false;
// Search through existing zones to make sure we don't create a duplicate zone
for (std::size_t j = 0; j < aura_zones.size(); j++)
{
if (aura_channels[i] == aura_zones[j])
{
matched = true;
}
}
// If zone does not already exist, create it
if (matched == false)
{
zone* new_zone = new zone();
std::vector<int>* zone_row = new std::vector<int>();
// Set zone name to channel name
new_zone->name = aura->GetChannelName(i);
// Find all LEDs with this channel type and add them to zone
for (std::size_t j = 0; j < aura->GetLEDCount(); j++)
{
if (aura->GetChannel(j) == aura_channels[i])
{
zone_row->push_back(j);
}
}
// Aura devices can be either single or linear, never matrix
// That means only one row is needed
new_zone->map.push_back(*zone_row);
// Save channel to aura_zones so we know not to create another zone with this channel
aura_zones.push_back(aura_channels[i]);
// Push new zone to zones vector
zones.push_back(*new_zone);
}
}
SetupZones();
// Initialize active mode
active_mode = GetDeviceMode();
}
void RGBController_Aura::SetCustomMode()
void RGBController_AuraSMBus::SetupZones()
{
std::vector<int> aura_led_map;
/*---------------------------------------------------------*\
| Search through all LEDs and create zones for each channel |
| type |
\*---------------------------------------------------------*/
for (std::size_t led_idx = 0; led_idx < aura->GetLEDCount(); led_idx++)
{
bool matched = false;
/*---------------------------------------------------------*\
| Search through existing zones to make sure we don't |
| create a duplicate zone |
\*---------------------------------------------------------*/
for (std::size_t existing_zone_idx = 0; existing_zone_idx < zones.size(); existing_zone_idx++)
{
if (aura->GetChannelName(led_idx) == zones[existing_zone_idx].name)
{
matched = true;
}
}
/*---------------------------------------------------------*\
| If zone does not already exist, create it |
\*---------------------------------------------------------*/
if (matched == false)
{
zone* new_zone = new zone();
/*---------------------------------------------------------*\
| Set zone name to channel name |
\*---------------------------------------------------------*/
new_zone->name = aura->GetChannelName(led_idx);
new_zone->leds_count = 0;
/*---------------------------------------------------------*\
| Find all LEDs with this channel type and add them to zone |
\*---------------------------------------------------------*/
for (std::size_t zone_led_idx = 0; zone_led_idx < aura->GetLEDCount(); zone_led_idx++)
{
if (aura->GetChannelName(zone_led_idx) == new_zone->name)
{
new_zone->leds_count++;
aura_led_map.push_back(zone_led_idx);
}
}
/*---------------------------------------------------------*\
| Aura zones have fixed size, so set min and max to count |
\*---------------------------------------------------------*/
new_zone->leds_min = new_zone->leds_count;
new_zone->leds_max = new_zone->leds_count;
/*---------------------------------------------------------*\
| If this zone has more than one LED, mark it as linear type|
\*---------------------------------------------------------*/
if(new_zone->leds_count > 1)
{
new_zone->type = ZONE_TYPE_LINEAR;
}
else
{
new_zone->type = ZONE_TYPE_SINGLE;
}
/*---------------------------------------------------------*\
| Push new zone to zones vector |
\*---------------------------------------------------------*/
zones.push_back(*new_zone);
}
}
/*---------------------------------------------------------*\
| Create LED entries for each zone |
\*---------------------------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{
led* new_led = new led();
new_led->name = zones[zone_idx].name + " LED ";
new_led->name.append(std::to_string(led_idx + 1));
new_led->value = aura_led_map[led_idx];
leds.push_back(*new_led);
}
}
SetupColors();
/*---------------------------------------------------------*\
| Initialize colors for each LED |
\*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < leds.size(); led_idx++)
{
unsigned int led = leds[led_idx].value;
unsigned char red = aura->GetLEDRed(led);
unsigned char grn = aura->GetLEDGreen(led);
unsigned char blu = aura->GetLEDBlue(led);
colors[led_idx] = ToRGBColor(red, grn, blu);
}
}
void RGBController_AuraSMBus::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AuraSMBus::SetCustomMode()
{
active_mode = 0;
}
void RGBController_Aura::UpdateMode()
void RGBController_AuraSMBus::UpdateMode()
{
if (modes[active_mode].value == 0xFFFF)
{
@@ -1,8 +1,8 @@
/*-----------------------------------------*\
| RGBController_Aura.h |
| RGBController_AuraSMBus.h |
| |
| Generic RGB Interface for OpenAuraSDK |
| Asus Aura driver |
| Asus Aura SMBus driver |
| |
| Adam Honse (CalcProgrammer1) 6/13/2019 |
\*-----------------------------------------*/
@@ -10,12 +10,17 @@
#pragma once
#include "RGBController.h"
#include "AuraController.h"
#include "AuraSMBusController.h"
class RGBController_Aura : public RGBController
class RGBController_AuraSMBus : public RGBController
{
public:
RGBController_Aura(AuraController* aura_ptr);
RGBController_AuraSMBus(AuraSMBusController* aura_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -24,7 +29,7 @@ public:
void UpdateMode();
private:
AuraController* aura;
AuraSMBusController* aura;
int GetDeviceMode();
};
@@ -1,331 +0,0 @@
/*-----------------------------------------*\
| RGBController_CorsairCmdrPro.cpp |
| |
| Generic RGB Interface for Corsair |
| Commander Pro |
| |
| Adam Honse (CalcProgrammer1) 1/16/2020 |
\*-----------------------------------------*/
#include "RGBController_CorsairCmdrPro.h"
RGBController_CorsairCmdrPro::RGBController_CorsairCmdrPro(CorsairCmdrProController* corsair_ptr)
{
corsair = corsair_ptr;
name = "Corsair Commander Pro";
type = DEVICE_TYPE_LEDSTRIP;
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
mode RainbowWave;
RainbowWave.name = "Rainbow Wave";
RainbowWave.value = CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE;
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
RainbowWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
RainbowWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
RainbowWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
RainbowWave.direction = MODE_DIRECTION_RIGHT;
RainbowWave.color_mode = MODE_COLORS_NONE;
modes.push_back(RainbowWave);
mode ColorShift;
ColorShift.name = "Color Shift";
ColorShift.value = CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT;
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
ColorShift.colors_min = 2;
ColorShift.colors_max = 2;
ColorShift.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorShift.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorShift.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorShift.colors.resize(2);
modes.push_back(ColorShift);
mode ColorPulse;
ColorPulse.name = "Color Pulse";
ColorPulse.value = CORSAIR_CMDR_PRO_MODE_COLOR_PULSE;
ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
ColorPulse.colors_min = 2;
ColorPulse.colors_max = 2;
ColorPulse.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorPulse.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorPulse.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
ColorPulse.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorPulse.colors.resize(2);
modes.push_back(ColorPulse);
mode ColorWave;
ColorWave.name = "Color Wave";
ColorWave.value = CORSAIR_CMDR_PRO_MODE_COLOR_WAVE;
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
ColorWave.colors_min = 2;
ColorWave.colors_max = 2;
ColorWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
ColorWave.direction = MODE_DIRECTION_RIGHT;
ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorWave.colors.resize(2);
modes.push_back(ColorWave);
mode Static;
Static.name = "Static";
Static.value = CORSAIR_CMDR_PRO_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Static.colors_min = 1;
Static.colors_max = 1;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.colors.resize(1);
modes.push_back(Static);
mode Temperature;
Temperature.name = "Temperature";
Temperature.value = CORSAIR_CMDR_PRO_MODE_TEMPERATURE;
Temperature.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Temperature.colors_min = 3;
Temperature.colors_max = 3;
Temperature.color_mode = MODE_COLORS_MODE_SPECIFIC;
Temperature.colors.resize(3);
modes.push_back(Temperature);
mode Visor;
Visor.name = "Visor";
Visor.value = CORSAIR_CMDR_PRO_MODE_VISOR;
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Visor.colors_min = 2;
Visor.colors_max = 2;
Visor.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Visor.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Visor.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Visor.color_mode = MODE_COLORS_MODE_SPECIFIC;
Visor.colors.resize(2);
modes.push_back(Visor);
mode Marquee;
Marquee.name = "Marquee";
Marquee.value = CORSAIR_CMDR_PRO_MODE_MARQUEE;
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Marquee.colors_min = 1;
Marquee.colors_max = 1;
Marquee.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Marquee.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Marquee.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Marquee.direction = MODE_DIRECTION_RIGHT;
Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC;
Marquee.colors.resize(1);
modes.push_back(Marquee);
mode Blink;
Blink.name = "Blink";
Blink.value = CORSAIR_CMDR_PRO_MODE_BLINK;
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Blink.colors_min = 2;
Blink.colors_max = 2;
Blink.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Blink.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Blink.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Blink.color_mode = MODE_COLORS_MODE_SPECIFIC;
Blink.colors.resize(2);
modes.push_back(Blink);
mode Sequential;
Sequential.name = "Sequential";
Sequential.value = CORSAIR_CMDR_PRO_MODE_SEQUENTIAL;
Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Sequential.colors_min = 1;
Sequential.colors_max = 1;
Sequential.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Sequential.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Sequential.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Sequential.direction = MODE_DIRECTION_RIGHT;
Sequential.color_mode = MODE_COLORS_MODE_SPECIFIC;
Sequential.colors.resize(1);
modes.push_back(Sequential);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = CORSAIR_CMDR_PRO_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED;
Rainbow.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Rainbow.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Rainbow.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow);
/*-------------------------------------------------*\
| Set size of colors array |
\*-------------------------------------------------*/
unsigned int led_count = 0;
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel_idx++)
{
led_count += corsair->channel_leds[channel_idx];
}
colors.resize(led_count);
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
unsigned int led_idx = 0;
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel_idx++)
{
if(corsair->channel_leds[channel_idx] > 0)
{
zone* new_zone = new zone;
char ch_idx_string[2];
sprintf(ch_idx_string, "%d", channel_idx + 1);
new_zone->name = "Corsair Channel ";
new_zone->name.append(ch_idx_string);
new_zone->type = ZONE_TYPE_LINEAR;
std::vector<int> *new_zone_map = new std::vector<int>();
for (unsigned int led_ch_idx = 0; led_ch_idx < corsair->channel_leds[channel_idx]; led_ch_idx++)
{
char led_idx_string[3];
sprintf(led_idx_string, "%d", led_ch_idx + 1);
led new_led;
new_led.name = "Corsair Channel ";
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
leds.push_back(new_led);
leds_channel.push_back(channel_idx);
new_zone_map->push_back(led_idx);
led_idx++;
}
new_zone->map.push_back(*new_zone_map);
zones.push_back(*new_zone);
zones_channel.push_back(channel_idx);
}
}
}
void RGBController_CorsairCmdrPro::UpdateLEDs()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
unsigned int channel = zones_channel[zone_idx];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
}
}
void RGBController_CorsairCmdrPro::UpdateZoneLEDs(int zone)
{
unsigned int channel = zones_channel[zone];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
}
void RGBController_CorsairCmdrPro::UpdateSingleLED(int led)
{
unsigned int channel = leds_channel[led];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
}
void RGBController_CorsairCmdrPro::SetCustomMode()
{
active_mode = 0;
}
void RGBController_CorsairCmdrPro::UpdateMode()
{
if(modes[active_mode].value == 0xFFFF)
{
UpdateLEDs();
}
else
{
for(int channel = 0; channel < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel++)
{
unsigned int direction = 0;
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
if(modes[active_mode].direction == MODE_DIRECTION_RIGHT)
{
direction = 1;
}
unsigned char mode_colors[9];
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{
for(int i = 0; i < modes[active_mode].colors.size(); i++)
{
mode_colors[(3 * i) + 0] = RGBGetRValue(modes[active_mode].colors[i]);
mode_colors[(3 * i) + 1] = RGBGetGValue(modes[active_mode].colors[i]);
mode_colors[(3 * i) + 2] = RGBGetBValue(modes[active_mode].colors[i]);
}
}
corsair->SetChannelEffect(channel,
modes[active_mode].value,
modes[active_mode].speed,
direction,
random,
mode_colors[0],
mode_colors[1],
mode_colors[2],
mode_colors[3],
mode_colors[4],
mode_colors[5],
mode_colors[6],
mode_colors[7],
mode_colors[8]);
}
}
}
@@ -1,29 +0,0 @@
/*-----------------------------------------*\
| RGBController_CorsairCmdrPro.h |
| |
| Generic RGB Interface for Corsair |
| Commander Pro |
| |
| Adam Honse (CalcProgrammer1) 1/16/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "CorsairCmdrProController.h"
class RGBController_CorsairCmdrPro : public RGBController
{
public:
RGBController_CorsairCmdrPro(CorsairCmdrProController* corsair_ptr);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
CorsairCmdrProController* corsair;
std::vector<unsigned int> leds_channel;
std::vector<unsigned int> zones_channel;
};
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| RGBController_CorsairNodePro.cpp |
| RGBController_CorsairLightingNode.cpp |
| |
| Generic RGB Interface for Corsair |
| Lighting Node Pro |
@@ -7,16 +7,17 @@
| Adam Honse (CalcProgrammer1) 1/12/2020 |
\*-----------------------------------------*/
#include "RGBController_CorsairNodePro.h"
#include "RGBController_CorsairLightingNode.h"
RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProController* corsair_ptr)
RGBController_CorsairLightingNode::RGBController_CorsairLightingNode(CorsairLightingNodeController* corsair_ptr)
{
corsair = corsair_ptr;
name = "Corsair Lighting Node Pro";
type = DEVICE_TYPE_LEDSTRIP;
name = "Corsair Lighting Node Device";
description = "Corsair Lighting Node Device";
type = DEVICE_TYPE_LEDSTRIP;
version = corsair->GetFirmwareString();
mode Direct;
Direct.name = "Direct";
@@ -27,50 +28,50 @@ RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProControl
mode RainbowWave;
RainbowWave.name = "Rainbow Wave";
RainbowWave.value = CORSAIR_CMDR_PRO_MODE_RAINBOW_WAVE;
RainbowWave.value = CORSAIR_LIGHTING_NODE_MODE_RAINBOW_WAVE;
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR;
RainbowWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
RainbowWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
RainbowWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
RainbowWave.speed_min = CORSAIR_LIGHTING_NODE_SPEED_SLOW;
RainbowWave.speed_max = CORSAIR_LIGHTING_NODE_SPEED_FAST;
RainbowWave.speed = CORSAIR_LIGHTING_NODE_SPEED_MEDIUM;
RainbowWave.direction = MODE_DIRECTION_RIGHT;
RainbowWave.color_mode = MODE_COLORS_NONE;
modes.push_back(RainbowWave);
mode ColorShift;
ColorShift.name = "Color Shift";
ColorShift.value = CORSAIR_CMDR_PRO_MODE_COLOR_SHIFT;
ColorShift.value = CORSAIR_LIGHTING_NODE_MODE_COLOR_SHIFT;
ColorShift.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
ColorShift.colors_min = 2;
ColorShift.colors_max = 2;
ColorShift.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorShift.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorShift.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
ColorShift.speed_min = CORSAIR_LIGHTING_NODE_SPEED_SLOW;
ColorShift.speed_max = CORSAIR_LIGHTING_NODE_SPEED_FAST;
ColorShift.speed = CORSAIR_LIGHTING_NODE_SPEED_MEDIUM;
ColorShift.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorShift.colors.resize(2);
modes.push_back(ColorShift);
mode ColorPulse;
ColorPulse.name = "Color Pulse";
ColorPulse.value = CORSAIR_CMDR_PRO_MODE_COLOR_PULSE;
ColorPulse.value = CORSAIR_LIGHTING_NODE_MODE_COLOR_PULSE;
ColorPulse.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
ColorPulse.colors_min = 2;
ColorPulse.colors_max = 2;
ColorPulse.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorPulse.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorPulse.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
ColorPulse.speed_min = CORSAIR_LIGHTING_NODE_SPEED_SLOW;
ColorPulse.speed_max = CORSAIR_LIGHTING_NODE_SPEED_FAST;
ColorPulse.speed = CORSAIR_LIGHTING_NODE_SPEED_MEDIUM;
ColorPulse.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorPulse.colors.resize(2);
modes.push_back(ColorPulse);
mode ColorWave;
ColorWave.name = "Color Wave";
ColorWave.value = CORSAIR_CMDR_PRO_MODE_COLOR_WAVE;
ColorWave.value = CORSAIR_LIGHTING_NODE_MODE_COLOR_WAVE;
ColorWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
ColorWave.colors_min = 2;
ColorWave.colors_max = 2;
ColorWave.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
ColorWave.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
ColorWave.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
ColorWave.speed_min = CORSAIR_LIGHTING_NODE_SPEED_SLOW;
ColorWave.speed_max = CORSAIR_LIGHTING_NODE_SPEED_FAST;
ColorWave.speed = CORSAIR_LIGHTING_NODE_SPEED_MEDIUM;
ColorWave.direction = MODE_DIRECTION_RIGHT;
ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorWave.colors.resize(2);
@@ -78,7 +79,7 @@ RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProControl
mode Static;
Static.name = "Static";
Static.value = CORSAIR_CMDR_PRO_MODE_STATIC;
Static.value = CORSAIR_LIGHTING_NODE_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Static.colors_min = 1;
Static.colors_max = 1;
@@ -88,7 +89,7 @@ RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProControl
mode Temperature;
Temperature.name = "Temperature";
Temperature.value = CORSAIR_CMDR_PRO_MODE_TEMPERATURE;
Temperature.value = CORSAIR_LIGHTING_NODE_MODE_TEMPERATURE;
Temperature.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Temperature.colors_min = 3;
Temperature.colors_max = 3;
@@ -98,26 +99,26 @@ RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProControl
mode Visor;
Visor.name = "Visor";
Visor.value = CORSAIR_CMDR_PRO_MODE_VISOR;
Visor.value = CORSAIR_LIGHTING_NODE_MODE_VISOR;
Visor.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Visor.colors_min = 2;
Visor.colors_max = 2;
Visor.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Visor.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Visor.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Visor.speed_min = CORSAIR_LIGHTING_NODE_SPEED_SLOW;
Visor.speed_max = CORSAIR_LIGHTING_NODE_SPEED_FAST;
Visor.speed = CORSAIR_LIGHTING_NODE_SPEED_MEDIUM;
Visor.color_mode = MODE_COLORS_MODE_SPECIFIC;
Visor.colors.resize(2);
modes.push_back(Visor);
mode Marquee;
Marquee.name = "Marquee";
Marquee.value = CORSAIR_CMDR_PRO_MODE_MARQUEE;
Marquee.value = CORSAIR_LIGHTING_NODE_MODE_MARQUEE;
Marquee.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Marquee.colors_min = 1;
Marquee.colors_max = 1;
Marquee.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Marquee.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Marquee.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Marquee.speed_min = CORSAIR_LIGHTING_NODE_SPEED_SLOW;
Marquee.speed_max = CORSAIR_LIGHTING_NODE_SPEED_FAST;
Marquee.speed = CORSAIR_LIGHTING_NODE_SPEED_MEDIUM;
Marquee.direction = MODE_DIRECTION_RIGHT;
Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC;
Marquee.colors.resize(1);
@@ -125,26 +126,26 @@ RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProControl
mode Blink;
Blink.name = "Blink";
Blink.value = CORSAIR_CMDR_PRO_MODE_BLINK;
Blink.value = CORSAIR_LIGHTING_NODE_MODE_BLINK;
Blink.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Blink.colors_min = 2;
Blink.colors_max = 2;
Blink.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Blink.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Blink.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Blink.speed_min = CORSAIR_LIGHTING_NODE_SPEED_SLOW;
Blink.speed_max = CORSAIR_LIGHTING_NODE_SPEED_FAST;
Blink.speed = CORSAIR_LIGHTING_NODE_SPEED_MEDIUM;
Blink.color_mode = MODE_COLORS_MODE_SPECIFIC;
Blink.colors.resize(2);
modes.push_back(Blink);
mode Sequential;
Sequential.name = "Sequential";
Sequential.value = CORSAIR_CMDR_PRO_MODE_SEQUENTIAL;
Sequential.value = CORSAIR_LIGHTING_NODE_MODE_SEQUENTIAL;
Sequential.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Sequential.colors_min = 1;
Sequential.colors_max = 1;
Sequential.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Sequential.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Sequential.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Sequential.speed_min = CORSAIR_LIGHTING_NODE_SPEED_SLOW;
Sequential.speed_max = CORSAIR_LIGHTING_NODE_SPEED_FAST;
Sequential.speed = CORSAIR_LIGHTING_NODE_SPEED_MEDIUM;
Sequential.direction = MODE_DIRECTION_RIGHT;
Sequential.color_mode = MODE_COLORS_MODE_SPECIFIC;
Sequential.colors.resize(1);
@@ -152,137 +153,116 @@ RGBController_CorsairNodePro::RGBController_CorsairNodePro(CorsairNodeProControl
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = CORSAIR_CMDR_PRO_MODE_RAINBOW;
Rainbow.value = CORSAIR_LIGHTING_NODE_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED;
Rainbow.speed_min = CORSAIR_CMDR_PRO_SPEED_SLOW;
Rainbow.speed_max = CORSAIR_CMDR_PRO_SPEED_FAST;
Rainbow.speed = CORSAIR_CMDR_PRO_SPEED_MEDIUM;
Rainbow.speed_min = CORSAIR_LIGHTING_NODE_SPEED_SLOW;
Rainbow.speed_max = CORSAIR_LIGHTING_NODE_SPEED_FAST;
Rainbow.speed = CORSAIR_LIGHTING_NODE_SPEED_MEDIUM;
Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow);
SetupZones();
}
void RGBController_CorsairLightingNode::SetupZones()
{
/*-------------------------------------------------*\
| Set size of colors array |
| Only set LED count on the first run |
\*-------------------------------------------------*/
unsigned int led_count = 0;
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_NODE_PRO_NUM_CHANNELS; channel_idx++)
bool first_run = false;
if(zones.size() == 0)
{
led_count += corsair->channel_leds[channel_idx];
first_run = true;
}
colors.resize(led_count);
/*-------------------------------------------------*\
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
leds.clear();
colors.clear();
zones.resize(CORSAIR_LIGHTING_NODE_NUM_CHANNELS);
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
unsigned int led_idx = 0;
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_NODE_PRO_NUM_CHANNELS; channel_idx++)
for (unsigned int channel_idx = 0; channel_idx < CORSAIR_LIGHTING_NODE_NUM_CHANNELS; channel_idx++)
{
if(corsair->channel_leds[channel_idx] > 0)
char ch_idx_string[2];
sprintf(ch_idx_string, "%d", channel_idx + 1);
zones[channel_idx].name = "Corsair Channel ";
zones[channel_idx].name.append(ch_idx_string);
zones[channel_idx].type = ZONE_TYPE_LINEAR;
/*-------------------------------------------------*\
| According to some research on Corsair forums, the |
| maximum number of LEDs supported by Corsair Link |
| devices is 96 |
\*-------------------------------------------------*/
zones[channel_idx].leds_min = 0;
zones[channel_idx].leds_max = 96;
if(first_run)
{
zone* new_zone = new zone;
char ch_idx_string[2];
sprintf(ch_idx_string, "%d", channel_idx + 1);
new_zone->name = "Corsair Channel ";
new_zone->name.append(ch_idx_string);
new_zone->type = ZONE_TYPE_LINEAR;
std::vector<int> *new_zone_map = new std::vector<int>();
for (unsigned int led_ch_idx = 0; led_ch_idx < corsair->channel_leds[channel_idx]; led_ch_idx++)
{
char led_idx_string[3];
sprintf(led_idx_string, "%d", led_ch_idx + 1);
led new_led;
new_led.name = "Corsair Channel ";
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
leds.push_back(new_led);
leds_channel.push_back(channel_idx);
new_zone_map->push_back(led_idx);
led_idx++;
}
new_zone->map.push_back(*new_zone_map);
zones.push_back(*new_zone);
zones_channel.push_back(channel_idx);
zones[channel_idx].leds_count = 0;
}
for (unsigned int led_ch_idx = 0; led_ch_idx < zones[channel_idx].leds_count; led_ch_idx++)
{
char led_idx_string[3];
sprintf(led_idx_string, "%d", led_ch_idx + 1);
led new_led;
new_led.name = "Corsair Channel ";
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
leds.push_back(new_led);
leds_channel.push_back(channel_idx);
}
}
SetupColors();
}
void RGBController_CorsairLightingNode::ResizeZone(int zone, int new_size)
{
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
{
zones[zone].leds_count = new_size;
SetupZones();
}
}
void RGBController_CorsairNodePro::UpdateLEDs()
void RGBController_CorsairLightingNode::UpdateLEDs()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
unsigned int channel = zones_channel[zone_idx];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
corsair->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
}
}
void RGBController_CorsairNodePro::UpdateZoneLEDs(int zone)
void RGBController_CorsairLightingNode::UpdateZoneLEDs(int zone)
{
unsigned int channel = zones_channel[zone];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
corsair->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count);
}
void RGBController_CorsairNodePro::UpdateSingleLED(int led)
void RGBController_CorsairLightingNode::UpdateSingleLED(int led)
{
unsigned int channel = leds_channel[led];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
corsair->SetChannelLEDs(channel, channel_colors);
}
corsair->SetChannelLEDs(channel, zones[channel].colors, zones[channel].leds_count);
}
void RGBController_CorsairNodePro::SetCustomMode()
void RGBController_CorsairLightingNode::SetCustomMode()
{
active_mode = 0;
}
void RGBController_CorsairNodePro::UpdateMode()
void RGBController_CorsairLightingNode::UpdateMode()
{
if(modes[active_mode].value == 0xFFFF)
{
@@ -290,7 +270,7 @@ void RGBController_CorsairNodePro::UpdateMode()
}
else
{
for(int channel = 0; channel < CORSAIR_CMDR_PRO_NUM_CHANNELS; channel++)
for(int channel = 0; channel < CORSAIR_LIGHTING_NODE_NUM_CHANNELS; channel++)
{
unsigned int direction = 0;
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
@@ -304,7 +284,7 @@ void RGBController_CorsairNodePro::UpdateMode()
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{
for(int i = 0; i < modes[active_mode].colors.size(); i++)
for(std::size_t i = 0; i < modes[active_mode].colors.size(); i++)
{
mode_colors[(3 * i) + 0] = RGBGetRValue(modes[active_mode].colors[i]);
mode_colors[(3 * i) + 1] = RGBGetGValue(modes[active_mode].colors[i]);
@@ -313,6 +293,7 @@ void RGBController_CorsairNodePro::UpdateMode()
}
corsair->SetChannelEffect(channel,
zones[channel].leds_count,
modes[active_mode].value,
modes[active_mode].speed,
direction,
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| RGBController_CorsairNodePro.h |
| RGBController_CorsairLightingNode.h |
| |
| Generic RGB Interface for Corsair |
| Lighting Node Pro |
@@ -9,12 +9,17 @@
#pragma once
#include "RGBController.h"
#include "CorsairNodeProController.h"
#include "CorsairLightingNodeController.h"
class RGBController_CorsairNodePro : public RGBController
class RGBController_CorsairLightingNode : public RGBController
{
public:
RGBController_CorsairNodePro(CorsairNodeProController* corsair_ptr);
RGBController_CorsairLightingNode(CorsairLightingNodeController* corsair_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -23,7 +28,7 @@ public:
void UpdateMode();
private:
CorsairNodeProController* corsair;
CorsairLightingNodeController* corsair;
std::vector<unsigned int> leds_channel;
std::vector<unsigned int> zones_channel;
};
@@ -1,13 +1,13 @@
/*-----------------------------------------*\
| RGBController_CorsairKeyboard.cpp |
| RGBController_CorsairPeripheral.cpp |
| |
| Generic RGB Interface for Corsair RGB |
| keyboards |
| keyboard, mouse, and mousemat devices |
| |
| Adam Honse (CalcProgrammer1) 1/9/2020 |
\*-----------------------------------------*/
#include "RGBController_CorsairKeyboard.h"
#include "RGBController_CorsairPeripheral.h"
static const char* zone_names[] =
{
@@ -137,12 +137,14 @@ static const char* led_names[] =
"Key: F12"
};
RGBController_CorsairKeyboard::RGBController_CorsairKeyboard(CorsairKeyboardController* corsair_ptr)
RGBController_CorsairPeripheral::RGBController_CorsairPeripheral(CorsairPeripheralController* corsair_ptr)
{
corsair = corsair_ptr;
name = "Corsair RGB Keyboard";
type = DEVICE_TYPE_KEYBOARD;
name = "Corsair RGB Peripheral Device";
description = "Corsair RGB Peripheral Device";
type = corsair->GetDeviceType();
version = corsair->GetFirmwareString();
mode Direct;
Direct.name = "Direct";
@@ -151,59 +153,115 @@ RGBController_CorsairKeyboard::RGBController_CorsairKeyboard(CorsairKeyboardCont
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
colors.resize(111);
SetupZones();
}
unsigned int led_idx = 0;
for(unsigned int zone_idx = 0; zone_idx < 2; zone_idx++)
RGBController_CorsairPeripheral::~RGBController_CorsairPeripheral()
{
}
void RGBController_CorsairPeripheral::SetupZones()
{
/*---------------------------------------------------------*\
| Determine number of zones |
| For now, keyboard has 2 zones and mousemat has 1 |
\*---------------------------------------------------------*/
unsigned int num_zones = 0;
switch(type)
{
case DEVICE_TYPE_KEYBOARD:
num_zones = 2;
break;
case DEVICE_TYPE_MOUSE:
case DEVICE_TYPE_MOUSEMAT:
num_zones = 1;
break;
}
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
unsigned int total_led_count = 0;
for(unsigned int zone_idx = 0; zone_idx < num_zones; zone_idx++)
{
zone new_zone;
new_zone.name.append(zone_names[zone_idx]);
std::vector<int> new_zone_map;
for(unsigned int led_count = 0; led_count < zone_sizes[zone_idx]; led_count++)
switch(type)
{
led new_led;
new_led.name.append(led_names[led_idx]);
leds.push_back(new_led);
case DEVICE_TYPE_KEYBOARD:
new_zone.name = zone_names[zone_idx];
new_zone.leds_min = zone_sizes[zone_idx];
new_zone.leds_max = zone_sizes[zone_idx];
new_zone.leds_count = zone_sizes[zone_idx];
break;
new_zone_map.push_back(led_idx);
led_idx++;
case DEVICE_TYPE_MOUSE:
case DEVICE_TYPE_MOUSEMAT:
new_zone.name = "Mousemat Zone";
new_zone.leds_min = 15;
new_zone.leds_max = 15;
new_zone.leds_count = 15;
break;
}
new_zone.map.push_back(new_zone_map);
zones.push_back(new_zone);
total_led_count += new_zone.leds_count;
}
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
{
led new_led;
switch(type)
{
case DEVICE_TYPE_KEYBOARD:
new_led.name = led_names[led_idx];
break;
case DEVICE_TYPE_MOUSE:
case DEVICE_TYPE_MOUSEMAT:
new_led.name = "Mousemat LED ";
new_led.name.append(std::to_string(led_idx + 1));
break;
}
leds.push_back(new_led);
}
SetupColors();
}
RGBController_CorsairKeyboard::~RGBController_CorsairKeyboard()
void RGBController_CorsairPeripheral::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_CorsairKeyboard::UpdateLEDs()
void RGBController_CorsairPeripheral::UpdateLEDs()
{
corsair->SetLEDs(colors);
}
void RGBController_CorsairKeyboard::UpdateZoneLEDs(int zone)
void RGBController_CorsairPeripheral::UpdateZoneLEDs(int /*zone*/)
{
corsair->SetLEDs(colors);
}
void RGBController_CorsairKeyboard::UpdateSingleLED(int led)
void RGBController_CorsairPeripheral::UpdateSingleLED(int /*led*/)
{
corsair->SetLEDs(colors);
}
void RGBController_CorsairKeyboard::SetCustomMode()
void RGBController_CorsairPeripheral::SetCustomMode()
{
active_mode = 0;
}
void RGBController_CorsairKeyboard::UpdateMode()
void RGBController_CorsairPeripheral::UpdateMode()
{
}
@@ -1,22 +1,26 @@
/*-----------------------------------------*\
| RGBController_CorsairKeyboard.h |
| RGBController_CorsairPeripheral.h |
| |
| Generic RGB Interface for Corsair RGB |
| keyboards |
| keyboard, mouse, and mousemat devices |
| |
| Adam Honse (CalcProgrammer1) 1/9/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "CorsairKeyboardController.h"
#include "CorsairPeripheralController.h"
class RGBController_CorsairKeyboard : public RGBController
class RGBController_CorsairPeripheral : public RGBController
{
public:
RGBController_CorsairKeyboard(CorsairKeyboardController* corsair_ptr);
~RGBController_CorsairKeyboard();
RGBController_CorsairPeripheral(CorsairPeripheralController* corsair_ptr);
~RGBController_CorsairPeripheral();
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -25,5 +29,5 @@ public:
void UpdateMode();
private:
CorsairKeyboardController* corsair;
CorsairPeripheralController* corsair;
};
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| RGBController_Corsair.cpp |
| RGBController_CorsairVengeance.cpp |
| |
| Generic RGB Interface for OpenAuraSDK |
| Corsair Vengeance RGB driver |
@@ -7,29 +7,9 @@
| Adam Honse (CalcProgrammer1) 6/13/2019 |
\*-----------------------------------------*/
#include "RGBController_Corsair.h"
#include "RGBController_CorsairVengeance.h"
void RGBController_Corsair::UpdateLEDs()
{
RGBColor color = colors[0];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(red, grn, blu);
}
void RGBController_Corsair::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_Corsair::UpdateSingleLED(int led)
{
UpdateLEDs();
}
RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
RGBController_CorsairVengeance::RGBController_CorsairVengeance(CorsairVengeanceController* corsair_ptr)
{
corsair = corsair_ptr;
@@ -59,39 +39,68 @@ RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
Pulse.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Pulse);
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
{
led* new_led = new led();
new_led->name = "Corsair LED";
leds.push_back(*new_led);
colors.push_back(0x00000000);
}
zone new_zone;
new_zone.name = "Corsair Zone";
new_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> zone_row;
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
{
zone_row.push_back(i);
}
new_zone.map.push_back(zone_row);
zones.push_back(new_zone);
SetupZones();
}
void RGBController_Corsair::SetCustomMode()
void RGBController_CorsairVengeance::SetupZones()
{
/*---------------------------------------------------------*\
| Create a single zone |
\*---------------------------------------------------------*/
zone new_zone;
new_zone.name = "Corsair Zone";
new_zone.type = ZONE_TYPE_SINGLE;
new_zone.leds_min = corsair->GetLEDCount();
new_zone.leds_max = corsair->GetLEDCount();
new_zone.leds_count = corsair->GetLEDCount();
zones.push_back(new_zone);
/*---------------------------------------------------------*\
| Set up LEDs |
\*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
{
led* new_led = new led();
new_led->name = "Corsair LED";
leds.push_back(*new_led);
}
SetupColors();
}
void RGBController_CorsairVengeance::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_CorsairVengeance::UpdateLEDs()
{
RGBColor color = colors[0];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(red, grn, blu);
}
void RGBController_CorsairVengeance::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_CorsairVengeance::UpdateSingleLED(int /*led*/)
{
UpdateLEDs();
}
void RGBController_CorsairVengeance::SetCustomMode()
{
active_mode = 0;
}
void RGBController_Corsair::UpdateMode()
void RGBController_CorsairVengeance::UpdateMode()
{
corsair->SetMode(modes[active_mode].value);
}
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| RGBController_Corsair.h |
| RGBController_CorsairVengeance.h |
| |
| Generic RGB Interface for OpenAuraSDK |
| Corsair Vengeance RGB driver |
@@ -10,12 +10,17 @@
#pragma once
#include "RGBController.h"
#include "CorsairController.h"
#include "CorsairVengeanceController.h"
class RGBController_Corsair : public RGBController
class RGBController_CorsairVengeance : public RGBController
{
public:
RGBController_Corsair(CorsairController* corsair_ptr);
RGBController_CorsairVengeance(CorsairVengeanceController* corsair_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -24,5 +29,5 @@ public:
void UpdateMode();
private:
CorsairController* corsair;
CorsairVengeanceController* corsair;
};
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| RGBController_CorsairPro.cpp |
| RGBController_CorsairVengeancePro.cpp |
| |
| Generic RGB Interface for OpenAuraSDK |
| Corsair Vengeance Pro RGB driver |
@@ -7,39 +7,9 @@
| Adam Honse (CalcProgrammer1) 6/30/2019 |
\*-----------------------------------------*/
#include "RGBController_CorsairPro.h"
#include "RGBController_CorsairVengeancePro.h"
void RGBController_CorsairPro::UpdateLEDs()
{
for (std::size_t led = 0; led < colors.size(); led++)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(led, red, grn, blu);
}
corsair->ApplyColors();
}
void RGBController_CorsairPro::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_CorsairPro::UpdateSingleLED(int led)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(led, red, grn, blu);
corsair->ApplyColors();
}
RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair_ptr)
RGBController_CorsairVengeancePro::RGBController_CorsairVengeancePro(CorsairVengeanceProController* corsair_ptr)
{
corsair = corsair_ptr;
@@ -97,8 +67,8 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
ColorWave.direction = MODE_DIRECTION_DOWN;
ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC;
ColorWave.colors.resize(2);
modes.push_back(ColorWave);
modes.push_back(ColorWave);
mode Visor;
Visor.name = "Visor";
Visor.value = CORSAIR_PRO_MODE_VISOR;
@@ -139,7 +109,7 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
Marquee.color_mode = MODE_COLORS_MODE_SPECIFIC;
Marquee.colors.resize(1);
modes.push_back(Marquee);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = CORSAIR_PRO_MODE_RAINBOW;
@@ -149,7 +119,7 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
Rainbow.speed = CORSAIR_PRO_SPEED_SLOW;
Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow);
mode Sequential;
Sequential.name = "Sequential";
Sequential.value = CORSAIR_PRO_MODE_SEQUENTIAL;
@@ -174,44 +144,83 @@ RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
SetupZones();
active_mode = 9;
}
colors.resize(corsair->GetLEDCount());
void RGBController_CorsairVengeancePro::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zone |
\*---------------------------------------------------------*/
zone new_zone;
new_zone.name = "Corsair Pro Zone";
new_zone.type = ZONE_TYPE_LINEAR;
new_zone.leds_min = corsair->GetLEDCount();
new_zone.leds_max = corsair->GetLEDCount();
new_zone.leds_count = corsair->GetLEDCount();
zones.push_back(new_zone);
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
/*---------------------------------------------------------*\
| Set up LEDs |
\*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
{
led* new_led = new led();
new_led->name = "Corsair Pro LED";
new_led->name = "Corsair Pro LED ";
new_led->name.append(std::to_string(led_idx));
leds.push_back(*new_led);
}
zone new_zone;
new_zone.name = "Corsair Pro Zone";
new_zone.type = ZONE_TYPE_LINEAR;
std::vector<int> zone_row;
for (unsigned int i = 0; i < corsair->GetLEDCount(); i++)
{
zone_row.push_back(i);
}
new_zone.map.push_back(zone_row);
zones.push_back(new_zone);
SetupColors();
}
void RGBController_CorsairPro::SetCustomMode()
void RGBController_CorsairVengeancePro::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_CorsairVengeancePro::UpdateLEDs()
{
for (std::size_t led = 0; led < colors.size(); led++)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(led, red, grn, blu);
}
corsair->ApplyColors();
}
void RGBController_CorsairVengeancePro::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_CorsairVengeancePro::UpdateSingleLED(int led)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
corsair->SetLEDColor(led, red, grn, blu);
corsair->ApplyColors();
}
void RGBController_CorsairVengeancePro::SetCustomMode()
{
active_mode = 9;
}
void RGBController_CorsairPro::UpdateMode()
void RGBController_CorsairVengeancePro::UpdateMode()
{
unsigned int corsair_direction;
unsigned int corsair_direction = 0;
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
unsigned char mode_colors[6];
@@ -237,6 +246,13 @@ void RGBController_CorsairPro::UpdateMode()
break;
}
mode_colors[0] = 0;
mode_colors[1] = 0;
mode_colors[2] = 0;
mode_colors[3] = 0;
mode_colors[4] = 0;
mode_colors[5] = 0;
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{
mode_colors[0] = RGBGetRValue(modes[active_mode].colors[0]);
@@ -248,7 +264,7 @@ void RGBController_CorsairPro::UpdateMode()
mode_colors[3] = RGBGetRValue(modes[active_mode].colors[1]);
mode_colors[4] = RGBGetGValue(modes[active_mode].colors[1]);
mode_colors[5] = RGBGetBValue(modes[active_mode].colors[1]);
}
}
}
corsair->SetEffect(modes[active_mode].value,
@@ -1,5 +1,5 @@
/*-----------------------------------------*\
| RGBController_CorsairPro.h |
| RGBController_CorsairVengeancePro.h |
| |
| Generic RGB Interface for OpenAuraSDK |
| Corsair Vengeance Pro RGB driver |
@@ -10,12 +10,17 @@
#pragma once
#include "RGBController.h"
#include "CorsairProController.h"
#include "CorsairVengeanceProController.h"
class RGBController_CorsairPro : public RGBController
class RGBController_CorsairVengeancePro : public RGBController
{
public:
RGBController_CorsairPro(CorsairProController* corsair_ptr);
RGBController_CorsairVengeancePro(CorsairVengeanceProController* corsair_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -24,5 +29,5 @@ public:
void UpdateMode();
private:
CorsairProController* corsair;
CorsairVengeanceProController* corsair;
};
+81 -60
View File
@@ -9,28 +9,6 @@
#include "RGBController_Crucial.h"
void RGBController_Crucial::UpdateLEDs()
{
if(modes[active_mode].value == 0xFFFF)
{
crucial->SetAllColorsDirect(&colors[0]);
}
else
{
}
}
void RGBController_Crucial::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_Crucial::UpdateSingleLED(int led)
{
UpdateLEDs();
}
RGBController_Crucial::RGBController_Crucial(CrucialController * crucial_ptr)
{
crucial = crucial_ptr;
@@ -46,7 +24,6 @@ RGBController_Crucial::RGBController_Crucial(CrucialController * crucial_ptr)
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
#if 0
mode Shift;
Shift.name = "Shift";
Shift.value = CRUCIAL_MODE_SHIFT;
@@ -79,74 +56,118 @@ RGBController_Crucial::RGBController_Crucial(CrucialController * crucial_ptr)
modes.push_back(Stack);
mode DoubleStack;
DoubleStack.name = "Double Stack";
DoubleStack.value = CRUCIAL_MODE_DOUBLE_STACK;
DoubleStack.flags = 0;
DoubleStack.name = "Double Stack";
DoubleStack.value = CRUCIAL_MODE_DOUBLE_STACK;
DoubleStack.flags = 0;
DoubleStack.color_mode = MODE_COLORS_NONE;
modes.push_back(DoubleStack);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = CRUCIAL_MODE_BREATHING;
Breathing.flags = 0;
Breathing.name = "Breathing";
Breathing.value = CRUCIAL_MODE_BREATHING;
Breathing.flags = 0;
Breathing.color_mode = MODE_COLORS_NONE;
modes.push_back(Breathing);
mode MotionPoint;
MotionPoint.name = "Motion Point";
MotionPoint.value = CRUCIAL_MODE_MOTION_POINT;
MotionPoint.flags = 0;
MotionPoint.name = "Motion Point";
MotionPoint.value = CRUCIAL_MODE_MOTION_POINT;
MotionPoint.flags = 0;
MotionPoint.color_mode = MODE_COLORS_NONE;
modes.push_back(MotionPoint);
mode InsideOut;
InsideOut.name = "Inside Out";
InsideOut.value = CRUCIAL_MODE_INSIDE_OUT;
InsideOut.flags = 0;
InsideOut.name = "Inside Out";
InsideOut.value = CRUCIAL_MODE_INSIDE_OUT;
InsideOut.flags = 0;
InsideOut.color_mode = MODE_COLORS_NONE;
modes.push_back(InsideOut);
mode ColorStep;
ColorStep.name = "Color Step";
ColorStep.value = CRUCIAL_MODE_COLOR_STEP;
ColorStep.flags = 0;
ColorStep.name = "Color Step";
ColorStep.value = CRUCIAL_MODE_COLOR_STEP;
ColorStep.flags = 0;
ColorStep.color_mode = MODE_COLORS_NONE;
modes.push_back(ColorStep);
mode WaterWave;
WaterWave.name = "Water Wave (Color Blending)";
WaterWave.value = CRUCIAL_MODE_WATER_WAVE;
WaterWave.flags = 0;
WaterWave.name = "Water Wave (Color Blending)";
WaterWave.value = CRUCIAL_MODE_WATER_WAVE;
WaterWave.flags = 0;
WaterWave.color_mode = MODE_COLORS_NONE;
modes.push_back(WaterWave);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = CRUCIAL_MODE_FLASHING;
Flashing.flags = 0;
Flashing.name = "Flashing";
Flashing.value = CRUCIAL_MODE_FLASHING;
Flashing.flags = 0;
Flashing.color_mode = MODE_COLORS_NONE;
modes.push_back(Flashing);
mode Static;
Static.name = "Static";
Static.value = CRUCIAL_MODE_STATIC;
Static.flags = 0;
Static.name = "Static";
Static.value = CRUCIAL_MODE_STATIC;
Static.flags = 0;
Static.color_mode = MODE_COLORS_NONE;
modes.push_back(Static);
#endif
SetupZones();
}
void RGBController_Crucial::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zone |
\*---------------------------------------------------------*/
zone new_zone;
new_zone.name = "DRAM";
new_zone.type = ZONE_TYPE_LINEAR;
std::vector<int> new_zone_map;
new_zone.name = "DRAM";
new_zone.type = ZONE_TYPE_LINEAR;
new_zone.leds_min = 8;
new_zone.leds_max = 8;
new_zone.leds_count = 8;
zones.push_back(new_zone);
for(int led_idx = 0; led_idx < 8; led_idx++)
/*---------------------------------------------------------*\
| Set up LEDs |
\*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
{
colors.push_back(0x00000000);
led new_led;
new_led.name = "DRAM LED";
new_led.name = "DRAM LED ";
new_led.name.append(std::to_string(led_idx));
leds.push_back(new_led);
new_zone_map.push_back(led_idx);
}
new_zone.map.push_back(new_zone_map);
SetupColors();
}
zones.push_back(new_zone);
void RGBController_Crucial::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_Crucial::UpdateLEDs()
{
if(modes[active_mode].value == 0xFFFF)
{
crucial->SetAllColorsDirect(&colors[0]);
}
else
{
crucial->SetAllColorsEffect(&colors[0]);
}
}
void RGBController_Crucial::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_Crucial::UpdateSingleLED(int /*led*/)
{
UpdateLEDs();
}
void RGBController_Crucial::SetCustomMode()
+5
View File
@@ -16,6 +16,11 @@ class RGBController_Crucial : public RGBController
{
public:
RGBController_Crucial(CrucialController* crucial_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
+13 -3
View File
@@ -13,17 +13,27 @@ RGBController_Dummy::RGBController_Dummy()
}
void RGBController_Dummy::SetupZones()
{
}
void RGBController_Dummy::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
void RGBController_Dummy::UpdateLEDs()
{
}
void RGBController_Dummy::UpdateZoneLEDs(int zone)
void RGBController_Dummy::UpdateZoneLEDs(int /*zone*/)
{
}
void RGBController_Dummy::UpdateSingleLED(int led)
void RGBController_Dummy::UpdateSingleLED(int /*led*/)
{
}
@@ -36,4 +46,4 @@ void RGBController_Dummy::SetCustomMode()
void RGBController_Dummy::UpdateMode()
{
}
}
+6 -1
View File
@@ -14,10 +14,15 @@ class RGBController_Dummy : public RGBController
{
public:
RGBController_Dummy();
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
};
};
+50 -40
View File
@@ -17,8 +17,6 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
devices = device_list;
unsigned int led_zone_idx = 0;
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
@@ -27,50 +25,19 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
modes.push_back(Direct);
sockfd = e131_socket();
colors.resize(0);
for (std::size_t i = 0; i < devices.size(); i++)
SetupZones();
for (std::size_t device_idx = 0; device_idx < devices.size(); device_idx++)
{
/*-----------------------------------------*\
| Add LEDs |
\*-----------------------------------------*/
colors.resize(colors.size() + devices[i].num_leds);
for (unsigned int led_idx = 0; led_idx < devices[i].num_leds; led_idx++)
{
char id_buf[16];
snprintf(id_buf, 16, "%d", led_idx);
led new_led;
new_led.name = devices[i].name + " LED ";
new_led.name.append(id_buf);
leds.push_back(new_led);
}
/*-----------------------------------------*\
| Add Zones |
\*-----------------------------------------*/
zone led_zone;
led_zone.name = devices[i].name;
led_zone.type = devices[i].type;
std::vector<int> led_zone_map;
for (unsigned int led_idx = 0; led_idx < devices[i].num_leds; led_idx++)
{
led_zone_map.push_back(led_zone_idx);
led_zone_idx++;
}
led_zone.map.push_back(led_zone_map);
zones.push_back(led_zone);
/*-----------------------------------------*\
| Add Universes |
\*-----------------------------------------*/
unsigned int total_universes = ceil( ( ( devices[i].num_leds * 3 ) + devices[i].start_channel ) / 512.0f );
unsigned int total_universes = ceil( ( ( devices[device_idx].num_leds * 3 ) + devices[device_idx].start_channel ) / 512.0f );
for (unsigned int univ_idx = 0; univ_idx < total_universes; univ_idx++)
{
unsigned int universe = devices[i].start_universe + univ_idx;
unsigned int universe = devices[device_idx].start_universe + univ_idx;
bool universe_exists = false;
for (std::size_t pkt_idx = 0; pkt_idx < packets.size(); pkt_idx++)
@@ -97,6 +64,49 @@ RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
}
}
void RGBController_E131::SetupZones()
{
/*-----------------------------------------*\
| Add Zones |
\*-----------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < devices.size(); zone_idx++)
{
zone led_zone;
led_zone.name = devices[zone_idx].name;
led_zone.type = devices[zone_idx].type;
led_zone.leds_min = devices[zone_idx].num_leds;
led_zone.leds_max = devices[zone_idx].num_leds;
led_zone.leds_count = devices[zone_idx].num_leds;
zones.push_back(led_zone);
}
/*-----------------------------------------*\
| Add LEDs |
\*-----------------------------------------*/
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{
led new_led;
new_led.name = zones[zone_idx].name + " LED ";
new_led.name.append(std::to_string(led_idx));
leds.push_back(new_led);
}
}
SetupColors();
}
void RGBController_E131::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_E131::UpdateLEDs()
{
int color_idx = 0;
@@ -158,12 +168,12 @@ void RGBController_E131::UpdateLEDs()
}
}
void RGBController_E131::UpdateZoneLEDs(int zone)
void RGBController_E131::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_E131::UpdateSingleLED(int led)
void RGBController_E131::UpdateSingleLED(int /*led*/)
{
UpdateLEDs();
}
+5
View File
@@ -37,6 +37,11 @@ class RGBController_E131 : public RGBController
{
public:
RGBController_E131(std::vector<E131Device> device_list);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
+31 -9
View File
@@ -39,13 +39,7 @@ RGBController_Faustus::RGBController_Faustus(const std::string& dev_path)
modes[3].color_mode = MODE_COLORS_NONE;
modes[3].speed = FAUSTUS_SPEED_NORMAL;
colors.resize(1);
leds.resize(1);
leds[0].name = "Keyboard backlight LED";
zones.resize(1);
zones[0].type = ZONE_TYPE_SINGLE;
zones[0].name = "Keyboard backlight zone";
zones[0].map.push_back(std::vector<int>(1, 0));
SetupZones();
// Prepare file streams
r_path = dev_path;
@@ -63,6 +57,34 @@ RGBController_Faustus::RGBController_Faustus(const std::string& dev_path)
set_path.append("/kbbl_set");
}
void RGBController_Faustus::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;
/*---------------------------------------------------------*\
| Set up LED |
\*---------------------------------------------------------*/
leds.resize(1);
leds[0].name = "Keyboard Backlight LED";
SetupColors();
}
void RGBController_Faustus::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_Faustus::UpdateLEDs()
{
int rv = uint8_t(RGBGetRValue(colors[0]));
@@ -106,12 +128,12 @@ void RGBController_Faustus::UpdateLEDs()
str_set.close();
}
void RGBController_Faustus::UpdateZoneLEDs(int zone)
void RGBController_Faustus::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_Faustus::UpdateSingleLED(int led)
void RGBController_Faustus::UpdateSingleLED(int /*led*/)
{
UpdateLEDs();
}
+5
View File
@@ -30,6 +30,11 @@ class RGBController_Faustus : public RGBController
public:
RGBController_Faustus(const std::string& dev_path);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
+70 -119
View File
@@ -19,11 +19,21 @@ RGBController_Hue2::RGBController_Hue2(Hue2Controller* hue2_ptr)
mode Direct;
Direct.name = "Direct";
Direct.value = HUE_2_MODE_FIXED;
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
mode Static;
Static.name = "Static";
Static.value = HUE_2_MODE_FIXED;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Static.colors_min = 1;
Static.colors_max = 1;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.colors.resize(1);
modes.push_back(Static);
mode Fading;
Fading.name = "Fading";
Fading.value = HUE_2_MODE_FADING;
@@ -116,121 +126,72 @@ RGBController_Hue2::RGBController_Hue2(Hue2Controller* hue2_ptr)
Breathing.colors.resize(1);
modes.push_back(Breathing);
SetupZones();
}
void RGBController_Hue2::SetupZones()
{
/*-------------------------------------------------*\
| Set size of colors array |
| Set up zones |
\*-------------------------------------------------*/
unsigned int led_count = 0;
for (unsigned int channel_idx = 0; channel_idx < HUE_2_NUM_CHANNELS; channel_idx++)
for(unsigned int zone_idx = 0; zone_idx < HUE_2_NUM_CHANNELS; zone_idx++)
{
led_count += hue2->channel_leds[channel_idx];
zone* new_zone = new zone;
new_zone->name = "Hue 2 Channel ";
new_zone->name.append(std::to_string(zone_idx + 1));
new_zone->type = ZONE_TYPE_LINEAR;
new_zone->leds_min = 0;
new_zone->leds_max = 40;
new_zone->leds_count = hue2->channel_leds[zone_idx];
zones.push_back(*new_zone);
}
colors.resize(led_count);
/*-------------------------------------------------*\
| Set zones and leds |
| Set up LEDs |
\*-------------------------------------------------*/
unsigned int led_idx = 0;
for (unsigned int channel_idx = 0; channel_idx < HUE_2_NUM_CHANNELS; channel_idx++)
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
if(hue2->channel_leds[channel_idx] > 0)
for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{
zone* new_zone = new zone;
led new_led;
new_led.name = "Hue 2 Channel ";
new_led.name.append(std::to_string(zone_idx + 1));
new_led.name.append(", LED ");
new_led.name.append(std::to_string(led_idx + 1));
new_led.value = zone_idx;
char ch_idx_string[2];
sprintf(ch_idx_string, "%d", channel_idx + 1);
new_zone->name = "Hue 2 Channel ";
new_zone->name.append(ch_idx_string);
new_zone->type = ZONE_TYPE_LINEAR;
std::vector<int> *new_zone_map = new std::vector<int>();
for (unsigned int led_ch_idx = 0; led_ch_idx < hue2->channel_leds[channel_idx]; led_ch_idx++)
{
char led_idx_string[3];
sprintf(led_idx_string, "%d", led_ch_idx + 1);
led new_led;
new_led.name = "Hue 2 Channel ";
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
leds.push_back(new_led);
leds_channel.push_back(channel_idx);
new_zone_map->push_back(led_idx);
led_idx++;
}
new_zone->map.push_back(*new_zone_map);
zones.push_back(*new_zone);
zones_channel.push_back(channel_idx);
leds.push_back(new_led);
}
}
SetupColors();
}
void RGBController_Hue2::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
void RGBController_Hue2::UpdateLEDs()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
unsigned int channel = zones_channel[zone_idx];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
hue2->SetChannelLEDs(channel, channel_colors);
}
hue2->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
}
}
void RGBController_Hue2::UpdateZoneLEDs(int zone)
{
unsigned int channel = zones_channel[zone];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
hue2->SetChannelLEDs(channel, channel_colors);
}
hue2->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count);
}
void RGBController_Hue2::UpdateSingleLED(int led)
{
unsigned int channel = leds_channel[led];
unsigned int zone_idx = leds[led].value;
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
hue2->SetChannelLEDs(channel, channel_colors);
}
hue2->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
}
void RGBController_Hue2::SetCustomMode()
@@ -240,46 +201,36 @@ void RGBController_Hue2::SetCustomMode()
void RGBController_Hue2::UpdateMode()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
if(modes[active_mode].value == 0xFFFF)
{
unsigned int channel = zones_channel[zone_idx];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
UpdateLEDs();
}
else
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
bool direction = false;
RGBColor* colors = NULL;
bool direction = false;
if(modes[active_mode].direction == MODE_DIRECTION_LEFT)
{
direction = true;
}
hue2->SetMode(modes[active_mode].value, modes[active_mode].speed, direction);
if(modes[active_mode].colors.size() > 0)
{
colors = &modes[active_mode].colors[0];
}
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
{
hue2->SetChannelLEDs(channel, channel_colors);
}
else if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{
hue2->SetChannelLEDs(channel, modes[active_mode].colors);
}
else if(modes[active_mode].color_mode == MODE_COLORS_NONE)
{
std::vector<RGBColor> temp_colors;
temp_colors.push_back(0x00000000);
hue2->SetChannelLEDs(channel, temp_colors);
}
hue2->SetChannelEffect
(
zone_idx,
modes[active_mode].value,
modes[active_mode].speed,
direction,
colors,
modes[active_mode].colors.size()
);
}
}
}
+5
View File
@@ -14,6 +14,11 @@ class RGBController_Hue2 : public RGBController
{
public:
RGBController_Hue2(Hue2Controller* hue2_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
+80 -118
View File
@@ -158,121 +158,94 @@ RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr)
Wave.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Wave);
SetupZones();
}
void RGBController_HuePlus::SetupZones()
{
/*-------------------------------------------------*\
| Set size of colors array |
| Only set LED count on the first run |
\*-------------------------------------------------*/
unsigned int led_count = 0;
for (unsigned int channel_idx = 0; channel_idx < HUE_PLUS_NUM_CHANNELS; channel_idx++)
bool first_run = false;
if(zones.size() == 0)
{
led_count += hueplus->channel_leds[channel_idx];
first_run = true;
}
colors.resize(led_count);
/*-------------------------------------------------*\
| Set zones and leds |
| Clear any existing color/LED configuration |
\*-------------------------------------------------*/
unsigned int led_idx = 0;
for (int channel_idx = 0; channel_idx < HUE_PLUS_NUM_CHANNELS; channel_idx++)
leds.clear();
colors.clear();
zones.resize(HUE_PLUS_NUM_CHANNELS);
/*-------------------------------------------------*\
| Set up zones |
\*-------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < HUE_PLUS_NUM_CHANNELS; zone_idx++)
{
if(hueplus->channel_leds[channel_idx] > 0)
zones[zone_idx].name = "Hue+ Channel ";
zones[zone_idx].name.append(std::to_string(zone_idx + 1));
zones[zone_idx].type = ZONE_TYPE_LINEAR;
zones[zone_idx].leds_min = 0;
zones[zone_idx].leds_max = 40;
if(first_run)
{
zone* new_zone = new zone;
char ch_idx_string[2];
sprintf(ch_idx_string, "%d", channel_idx + 1);
new_zone->name = "Hue+ Channel ";
new_zone->name.append(ch_idx_string);
new_zone->type = ZONE_TYPE_LINEAR;
std::vector<int> *new_zone_map = new std::vector<int>();
for (unsigned led_ch_idx = 0; led_ch_idx < hueplus->channel_leds[channel_idx]; led_ch_idx++)
{
char led_idx_string[3];
sprintf(led_idx_string, "%d", led_ch_idx + 1);
led new_led;
new_led.name = "Hue+ Channel ";
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
leds.push_back(new_led);
leds_channel.push_back(channel_idx + 1);
new_zone_map->push_back(led_idx);
led_idx++;
}
new_zone->map.push_back(*new_zone_map);
zones.push_back(*new_zone);
zones_channel.push_back(channel_idx + 1);
zones[zone_idx].leds_count = 0;
}
}
/*-------------------------------------------------*\
| Set up LEDs |
\*-------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
for(unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{
led new_led;
new_led.name = "Hue+ Channel ";
new_led.name.append(std::to_string(zone_idx + 1));
new_led.name.append(", LED ");
new_led.name.append(std::to_string(led_idx + 1));
new_led.value = zone_idx;
leds.push_back(new_led);
}
}
SetupColors();
}
void RGBController_HuePlus::ResizeZone(int zone, int new_size)
{
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
{
zones[zone].leds_count = new_size;
SetupZones();
}
}
void RGBController_HuePlus::UpdateLEDs()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
unsigned int channel = zones_channel[zone_idx];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
hueplus->SetChannelLEDs(channel, channel_colors);
}
hueplus->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
}
}
void RGBController_HuePlus::UpdateZoneLEDs(int zone)
{
unsigned int channel = zones_channel[zone];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
hueplus->SetChannelLEDs(channel, channel_colors);
}
hueplus->SetChannelLEDs(zone, zones[zone].colors, zones[zone].leds_count);
}
void RGBController_HuePlus::UpdateSingleLED(int led)
{
unsigned int channel = leds_channel[led];
unsigned int zone_idx = leds[led].value;
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
hueplus->SetChannelLEDs(channel, channel_colors);
}
hueplus->SetChannelLEDs(zone_idx, zones[zone_idx].colors, zones[zone_idx].leds_count);
}
void RGBController_HuePlus::SetCustomMode()
@@ -282,47 +255,36 @@ void RGBController_HuePlus::SetCustomMode()
void RGBController_HuePlus::UpdateMode()
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
if(modes[active_mode].value == HUE_PLUS_MODE_FIXED)
{
unsigned int channel = zones_channel[zone_idx];
std::vector<RGBColor> channel_colors;
for(std::size_t color = 0; color < colors.size(); color++)
UpdateLEDs();
}
else
{
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
if(leds_channel[color] == channel)
{
channel_colors.push_back(colors[color]);
}
}
if(channel_colors.size() > 0)
{
bool direction = false;
RGBColor* colors = NULL;
bool direction = false;
if(modes[active_mode].direction == MODE_DIRECTION_LEFT)
{
direction = true;
}
hueplus->SetMode(modes[active_mode].value, modes[active_mode].speed, direction);
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
if(modes[active_mode].colors.size() > 0)
{
hueplus->SetChannelLEDs(channel, channel_colors);
colors = &modes[active_mode].colors[0];
}
else if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{
hueplus->SetModeColors(channel, modes[active_mode].colors);
}
else if(modes[active_mode].color_mode == MODE_COLORS_NONE)
{
std::vector<RGBColor> temp_colors;
temp_colors.push_back(0x00000000);
hueplus->SetModeColors(channel, temp_colors);
}
hueplus->SetChannelEffect
(
zone_idx,
modes[active_mode].value,
modes[active_mode].speed,
direction,
colors,
modes[active_mode].colors.size()
);
}
}
}
+5
View File
@@ -15,6 +15,11 @@ class RGBController_HuePlus : public RGBController
{
public:
RGBController_HuePlus(HuePlusController* hueplus_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -1,94 +1,22 @@
/*-----------------------------------------*\
| RGBController_HyperX.cpp |
| RGBController_HyperXDRAM.cpp |
| |
| Generic RGB Interface for OpenAuraSDK |
| HyperX Predator RGB interface |
| HyperX Predator and Fury RGB interface |
| |
| Adam Honse (CalcProgrammer1) 6/29/2019 |
\*-----------------------------------------*/
#include "RGBController_HyperX.h"
#include "RGBController_HyperXDRAM.h"
void RGBController_HyperX::UpdateLEDs()
{
if(hyperx->GetMode() == HYPERX_MODE_DIRECT)
{
for (std::size_t zone = 0; zone < zones.size(); zone++ )
{
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
{
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
{
int led = zones[zone].map[x][y];
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
hyperx->SetLEDColor(led, red, grn, blu);
}
}
}
}
else
{
unsigned char red = RGBGetRValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]);
hyperx->SetEffectColor(red, grn, blu);
}
}
void RGBController_HyperX::UpdateZoneLEDs(int zone)
{
if(hyperx->GetMode() == HYPERX_MODE_DIRECT)
{
for (std::size_t x = 0; x < zones[zone].map.size(); x++)
{
for (std::size_t y = 0; y < zones[zone].map[x].size(); y++)
{
int led = zones[zone].map[x][y];
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
hyperx->SetLEDColor(led, red, grn, blu);
}
}
}
else
{
unsigned char red = RGBGetRValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]);
hyperx->SetEffectColor(red, grn, blu);
}
}
void RGBController_HyperX::UpdateSingleLED(int led)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if(hyperx->GetMode() == HYPERX_MODE_DIRECT)
{
hyperx->SetLEDColor(led, red, grn, blu);
}
else
{
hyperx->SetEffectColor(red, grn, blu);
}
}
RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
RGBController_HyperXDRAM::RGBController_HyperXDRAM(HyperXDRAMController* hyperx_ptr)
{
hyperx = hyperx_ptr;
name = hyperx->GetDeviceName();
location = hyperx->GetDeviceLocation();
type = DEVICE_TYPE_DRAM;
mode Direct;
@@ -153,7 +81,7 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
SpectrumCycle.speed = HYPERX_SPEED_CYCLE_NORMAL;
SpectrumCycle.color_mode = MODE_COLORS_NONE;
modes.push_back(SpectrumCycle);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = HYPERX_MODE_BREATHING;
@@ -193,51 +121,120 @@ RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
Blink.colors.resize(1);
modes.push_back(Blink);
colors.resize(hyperx->GetLEDCount());
unsigned int led_idx = 0;
SetupZones();
}
void RGBController_HyperXDRAM::SetupZones()
{
for(unsigned int slot = 0; slot < hyperx->GetSlotCount(); slot++)
{
zone* new_zone = new zone;
char slot_idx_str[3];
sprintf(slot_idx_str, "%d", slot);
new_zone->name = "HyperX Slot ";
new_zone->name.append(slot_idx_str);
new_zone->name = "HyperX Slot ";
new_zone->name.append(std::to_string(slot + 1));
new_zone->type = ZONE_TYPE_LINEAR;
new_zone->leds_min = 5;
new_zone->leds_max = 5;
new_zone->leds_count = 5;
new_zone->type = ZONE_TYPE_LINEAR;
zones.push_back(*new_zone);
}
std::vector<int> *new_zone_map = new std::vector<int>();
for(int led_slot_idx = 0; led_slot_idx < 5; led_slot_idx++)
for(std::size_t zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
for(std::size_t led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
{
led* new_led = new led();
char led_idx_str[3];
sprintf(led_idx_str, "%d", led_slot_idx);
new_led->name = "HyperX Slot ";
new_led->name.append(slot_idx_str);
new_led->name.append(std::to_string(zone_idx + 1));
new_led->name.append(", LED ");
new_led->name.append(led_idx_str);
new_led->name.append(std::to_string(led_idx + 1));
new_led->value = leds.size();
leds.push_back(*new_led);
new_zone_map->push_back(led_idx);
led_idx++;
}
}
new_zone->map.push_back(*new_zone_map);
zones.push_back(*new_zone);
SetupColors();
}
void RGBController_HyperXDRAM::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HyperXDRAM::UpdateLEDs()
{
if(hyperx->GetMode() == HYPERX_MODE_DIRECT)
{
for (std::size_t led_idx = 0; led_idx < colors.size(); led_idx++ )
{
RGBColor color = colors[led_idx];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
hyperx->SetLEDColor(led_idx, red, grn, blu);
}
}
else
{
unsigned char red = RGBGetRValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]);
hyperx->SetEffectColor(red, grn, blu);
}
}
void RGBController_HyperX::SetCustomMode()
void RGBController_HyperXDRAM::UpdateZoneLEDs(int zone)
{
if(hyperx->GetMode() == HYPERX_MODE_DIRECT)
{
for (std::size_t led_idx = 0; led_idx < zones[zone].leds_count; led_idx++ )
{
unsigned int led = zones[zone].leds[led_idx].value;
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
hyperx->SetLEDColor(led, red, grn, blu);
}
}
else
{
unsigned char red = RGBGetRValue(colors[0]);
unsigned char grn = RGBGetGValue(colors[0]);
unsigned char blu = RGBGetBValue(colors[0]);
hyperx->SetEffectColor(red, grn, blu);
}
}
void RGBController_HyperXDRAM::UpdateSingleLED(int led)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if(hyperx->GetMode() == HYPERX_MODE_DIRECT)
{
hyperx->SetLEDColor(led, red, grn, blu);
}
else
{
hyperx->SetEffectColor(red, grn, blu);
}
}
void RGBController_HyperXDRAM::SetCustomMode()
{
active_mode = 0;
}
void RGBController_HyperX::UpdateMode()
void RGBController_HyperXDRAM::UpdateMode()
{
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
@@ -1,8 +1,8 @@
/*-----------------------------------------*\
| RGBController_HyperX.h |
| RGBController_HyperXDRAM.h |
| |
| Generic RGB Interface for OpenAuraSDK |
| HyperX Predator RGB interface |
| HyperX Predator and Fury RGB interface |
| |
| Adam Honse (CalcProgrammer1) 6/29/2019 |
\*-----------------------------------------*/
@@ -10,12 +10,17 @@
#pragma once
#include "RGBController.h"
#include "HyperXController.h"
#include "HyperXDRAMController.h"
class RGBController_HyperX : public RGBController
class RGBController_HyperXDRAM : public RGBController
{
public:
RGBController_HyperX(HyperXController* hyperx_ptr);
RGBController_HyperXDRAM(HyperXDRAMController* hyperx_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -24,5 +29,5 @@ public:
void UpdateMode();
private:
HyperXController* hyperx;
HyperXDRAMController* hyperx;
};
+41 -30
View File
@@ -233,31 +233,7 @@ RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardControl
Breathing.colors.resize(2);
modes.push_back(Breathing);
colors.resize(126);
unsigned int led_idx = 0;
for(unsigned int zone_idx = 0; zone_idx < 3; zone_idx++)
{
zone new_zone;
new_zone.name.append(zone_names[zone_idx]);
std::vector<int> new_zone_map;
for(unsigned int led_count = 0; led_count < zone_sizes[zone_idx]; led_count++)
{
led new_led;
new_led.name.append(led_names[led_idx]);
leds.push_back(new_led);
new_zone_map.push_back(led_idx);
led_idx++;
}
new_zone.map.push_back(new_zone_map);
zones.push_back(new_zone);
}
SetupZones();
/*-----------------------------------------------------*\
| The Corsair Lighting Node Pro requires a packet within|
@@ -278,6 +254,41 @@ RGBController_HyperXKeyboard::~RGBController_HyperXKeyboard()
}
void RGBController_HyperXKeyboard::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
unsigned int total_led_count = 0;
for(unsigned int zone_idx = 0; zone_idx < 3; zone_idx++)
{
zone new_zone;
new_zone.name = zone_names[zone_idx];
new_zone.leds_min = zone_sizes[zone_idx];
new_zone.leds_max = zone_sizes[zone_idx];
new_zone.leds_count = zone_sizes[zone_idx];
zones.push_back(new_zone);
total_led_count += zone_sizes[zone_idx];
}
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
{
led new_led;
new_led.name = led_names[led_idx];
leds.push_back(new_led);
}
SetupColors();
}
void RGBController_HyperXKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HyperXKeyboard::UpdateLEDs()
{
if(active_mode == 0)
@@ -290,19 +301,19 @@ void RGBController_HyperXKeyboard::UpdateLEDs()
}
}
void RGBController_HyperXKeyboard::UpdateZoneLEDs(int zone)
void RGBController_HyperXKeyboard::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_HyperXKeyboard::UpdateSingleLED(int led)
void RGBController_HyperXKeyboard::UpdateSingleLED(int /*led*/)
{
UpdateLEDs();
}
void RGBController_HyperXKeyboard::SetCustomMode()
{
active_mode = 1;
active_mode = 0;
}
void RGBController_HyperXKeyboard::UpdateMode()
@@ -326,6 +337,6 @@ void RGBController_HyperXKeyboard::KeepaliveThread()
{
hyperx->SetLEDsDirect(colors);
}
Sleep(200);
Sleep(100);
}
}
}
@@ -16,6 +16,11 @@ class RGBController_HyperXKeyboard : public RGBController
public:
RGBController_HyperXKeyboard(HyperXKeyboardController* hyperx_ptr);
~RGBController_HyperXKeyboard();
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
+26 -19
View File
@@ -25,29 +25,36 @@ RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr)
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
colors.resize(strip->num_leds);
for (int i = 0; i < strip->num_leds; i++)
{
char id_buf[16];
snprintf(id_buf, 16, "%d", i);
SetupZones();
}
void RGBController_LEDStrip::SetupZones()
{
zone led_zone;
led_zone.name = "LED Strip";
led_zone.type = ZONE_TYPE_LINEAR;
led_zone.leds_min = strip->num_leds;
led_zone.leds_max = strip->num_leds;
led_zone.leds_count = strip->num_leds;
zones.push_back(led_zone);
for(int led_idx = 0; led_idx < strip->num_leds; led_idx++)
{
led new_led;
new_led.name = "LED ";
new_led.name.append(id_buf);
new_led.name.append(std::to_string(led_idx));
leds.push_back(new_led);
}
zone led_zone;
led_zone.name = "LED Strip";
std::vector<int> led_zone_map;
for (int i = 0; i < strip->num_leds; i++)
{
led_zone_map.push_back(i);
}
led_zone.map.push_back(led_zone_map);
zones.push_back(led_zone);
SetupColors();
}
void RGBController_LEDStrip::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_LEDStrip::UpdateLEDs()
@@ -55,12 +62,12 @@ void RGBController_LEDStrip::UpdateLEDs()
strip->SetLEDs(colors);
}
void RGBController_LEDStrip::UpdateZoneLEDs(int zone)
void RGBController_LEDStrip::UpdateZoneLEDs(int /*zone*/)
{
strip->SetLEDs(colors);
}
void RGBController_LEDStrip::UpdateSingleLED(int led)
void RGBController_LEDStrip::UpdateSingleLED(int /*led*/)
{
strip->SetLEDs(colors);
}
+5
View File
@@ -16,6 +16,11 @@ class RGBController_LEDStrip : public RGBController
{
public:
RGBController_LEDStrip(LEDStripController* ledstrip_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
+53 -39
View File
@@ -23,43 +23,7 @@ RGBController_MSI3Zone::RGBController_MSI3Zone(MSI3ZoneController* msi_ptr)
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
led left_led;
left_led.name = "Keyboard Left";
leds.push_back(left_led);
colors.push_back(0x00000000);
led mid_led;
mid_led.name = "Keyboard Middle";
leds.push_back(mid_led);
colors.push_back(0x00000000);
led right_led;
right_led.name = "Keyboard Right";
leds.push_back(right_led);
colors.push_back(0x00000000);
zone keyboard_zone;
keyboard_zone.name = "Keyboard";
keyboard_zone.type = ZONE_TYPE_LINEAR;
std::vector<int> keyboard_zone_map;
keyboard_zone_map.push_back(0);
keyboard_zone_map.push_back(1);
keyboard_zone_map.push_back(2);
keyboard_zone.map.push_back(keyboard_zone_map);
zones.push_back(keyboard_zone);
led aux_led;
aux_led.name = "Aux";
leds.push_back(aux_led);
colors.push_back(0x00000000);
zone aux_zone;
aux_zone.name = "Aux";
aux_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> aux_zone_map;
aux_zone_map.push_back(3);
aux_zone.map.push_back(aux_zone_map);
zones.push_back(aux_zone);
SetupZones();
}
RGBController_MSI3Zone::~RGBController_MSI3Zone()
@@ -67,17 +31,67 @@ RGBController_MSI3Zone::~RGBController_MSI3Zone()
}
void RGBController_MSI3Zone::SetupZones()
{
/*---------------------------------------------------------*\
| Set up Keyboard zone and Keyboard LEDs |
\*---------------------------------------------------------*/
zone keyboard_zone;
keyboard_zone.name = "Keyboard";
keyboard_zone.type = ZONE_TYPE_LINEAR;
keyboard_zone.leds_min = 3;
keyboard_zone.leds_max = 3;
keyboard_zone.leds_count = 3;
zones.push_back(keyboard_zone);
led left_led;
left_led.name = "Keyboard Left";
leds.push_back(left_led);
led mid_led;
mid_led.name = "Keyboard Middle";
leds.push_back(mid_led);
led right_led;
right_led.name = "Keyboard Right";
leds.push_back(right_led);
/*---------------------------------------------------------*\
| Set up Aux zone and Aux LED |
\*---------------------------------------------------------*/
zone aux_zone;
aux_zone.name = "Aux";
aux_zone.type = ZONE_TYPE_SINGLE;
aux_zone.leds_min = 1;
aux_zone.leds_max = 1;
aux_zone.leds_count = 1;
zones.push_back(aux_zone);
led aux_led;
aux_led.name = "Aux";
leds.push_back(aux_led);
SetupColors();
}
void RGBController_MSI3Zone::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_MSI3Zone::UpdateLEDs()
{
msi->SetLEDs(colors);
}
void RGBController_MSI3Zone::UpdateZoneLEDs(int zone)
void RGBController_MSI3Zone::UpdateZoneLEDs(int /*zone*/)
{
msi->SetLEDs(colors);
}
void RGBController_MSI3Zone::UpdateSingleLED(int led)
void RGBController_MSI3Zone::UpdateSingleLED(int /*led*/)
{
msi->SetLEDs(colors);
}
+6 -1
View File
@@ -16,6 +16,11 @@ class RGBController_MSI3Zone : public RGBController
public:
RGBController_MSI3Zone(MSI3ZoneController* msi_ptr);
~RGBController_MSI3Zone();
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -25,4 +30,4 @@ public:
private:
MSI3ZoneController* msi;
};
};
+22 -12
View File
@@ -24,22 +24,32 @@ RGBController_MSIRGB::RGBController_MSIRGB(MSIRGBController* msi_ptr)
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
}
RGBController_MSIRGB::~RGBController_MSIRGB()
{
}
void RGBController_MSIRGB::SetupZones()
{
zone msi_zone;
msi_zone.name = "MSI Zone";
msi_zone.type = ZONE_TYPE_SINGLE;
msi_zone.leds_min = 1;
msi_zone.leds_max = 1;
msi_zone.leds_count = 1;
zones.push_back(msi_zone);
led msi_led;
msi_led.name = "MSI LED";
leds.push_back(msi_led);
zone msi_zone;
msi_zone.name = "MSI Zone";
msi_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> msi_zone_map;
msi_zone_map.push_back(0);
msi_zone.map.push_back(msi_zone_map);
zones.push_back(msi_zone);
colors.push_back(0x00000000);
SetupColors();
}
RGBController_MSIRGB::~RGBController_MSIRGB()
void RGBController_MSIRGB::ResizeZone(int /*zone*/, int /*new_size*/)
{
}
@@ -54,12 +64,12 @@ void RGBController_MSIRGB::UpdateLEDs()
msi->SetColor(red, grn, blu);
}
void RGBController_MSIRGB::UpdateZoneLEDs(int zone)
void RGBController_MSIRGB::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_MSIRGB::UpdateSingleLED(int led)
void RGBController_MSIRGB::UpdateSingleLED(int /*led*/)
{
UpdateLEDs();
}
+6 -1
View File
@@ -15,6 +15,11 @@ class RGBController_MSIRGB : public RGBController
public:
RGBController_MSIRGB(MSIRGBController* msi_ptr);
~RGBController_MSIRGB();
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -24,4 +29,4 @@ public:
private:
MSIRGBController* msi;
};
};
+51 -43
View File
@@ -110,17 +110,17 @@ void RGBController_OpenRazer::UpdateLEDs()
}
}
void RGBController_OpenRazer::UpdateZoneLEDs(int zone)
void RGBController_OpenRazer::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_OpenRazer::UpdateSingleLED(int led)
void RGBController_OpenRazer::UpdateSingleLED(int /*led*/)
{
UpdateLEDs();
}
void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned int rows, unsigned int cols)
void RGBController_OpenRazer::SetupMatrixDevice(unsigned int rows, unsigned int cols)
{
if(!matrix_custom_frame)
{
@@ -145,7 +145,7 @@ void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned i
}
}
void RGBController_OpenRazer::SetupNonMatrixDevice(std::string dev_path)
void RGBController_OpenRazer::SetupNonMatrixDevice()
{
matrix_type = RAZER_TYPE_NOMATRIX;
}
@@ -185,8 +185,6 @@ void RGBController_OpenRazer::OpenFunctions(std::string dev_path)
RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
{
unsigned int led_count = 0;
/*-----------------------------------------------------------------*\
| Open the OpenRazer device functions |
\*-----------------------------------------------------------------*/
@@ -324,53 +322,63 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
\*---------------------------------------------------------*/
if(device_list[i]->matrix_type == true)
{
SetupMatrixDevice(dev_path, device_list[i]->rows, device_list[i]->cols);
SetupMatrixDevice(device_list[i]->rows, device_list[i]->cols);
}
else
{
SetupNonMatrixDevice(dev_path);
SetupNonMatrixDevice();
}
/*---------------------------------------------------------*\
| Fill in zone information based on device table |
\*---------------------------------------------------------*/
for (int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++)
SetupZones();
}
}
}
void RGBController_OpenRazer::SetupZones()
{
/*---------------------------------------------------------*\
| Fill in zone information based on device table |
\*---------------------------------------------------------*/
for(unsigned int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++)
{
if(device_list[device_index]->zones[zone_id] != NULL)
{
zone new_zone;
new_zone.name = device_list[device_index]->zones[zone_id]->name;
new_zone.type = device_list[device_index]->zones[zone_id]->type;
new_zone.leds_count = device_list[device_index]->zones[zone_id]->rows * device_list[device_index]->zones[zone_id]->cols;
new_zone.leds_min = new_zone.leds_count;
new_zone.leds_max = new_zone.leds_count;
zones.push_back(new_zone);
}
}
for(unsigned int zone_id = 0; zone_id < zones.size(); zone_id++)
{
for (unsigned int row_id = 0; row_id < device_list[device_index]->zones[zone_id]->rows; row_id++)
{
for (unsigned int col_id = 0; col_id < device_list[device_index]->zones[zone_id]->cols; col_id++)
{
if (device_list[i]->zones[zone_id] != NULL)
{
zone new_zone;
new_zone.name = device_list[i]->zones[zone_id]->name;
new_zone.type = device_list[i]->zones[zone_id]->type;
led* new_led = new led();
for (unsigned int row_id = 0; row_id < device_list[i]->zones[zone_id]->rows; row_id++)
{
std::vector<int> new_zone_map;
for (unsigned int col_id = 0; col_id < device_list[i]->zones[zone_id]->cols; col_id++)
{
char id_buf[8];
snprintf(id_buf, 8, "%d", col_id + 1);
RGBColor new_color = 0x00000000;
colors.push_back(new_color);
led* new_led = new led();
new_led->name = device_list[i]->zones[zone_id]->name + " LED ";
new_led->name.append(id_buf);
leds.push_back(*new_led);
new_zone_map.push_back(led_count);
led_count++;
}
new_zone.map.push_back(new_zone_map);
}
zones.push_back(new_zone);
}
new_led->name = device_list[device_index]->zones[zone_id]->name + " LED ";
new_led->name.append(std::to_string(col_id + 1));
leds.push_back(*new_led);
}
}
}
SetupColors();
}
void RGBController_OpenRazer::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_OpenRazer::SetCustomMode()
+7 -2
View File
@@ -40,6 +40,11 @@ public:
public:
RGBController_OpenRazer(std::string dev_path);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -50,8 +55,8 @@ public:
int device_index;
private:
void SetupMatrixDevice(std::string dev_path, unsigned int rows, unsigned int cols);
void SetupNonMatrixDevice(std::string dev_path);
void SetupMatrixDevice(unsigned int rows, unsigned int cols);
void SetupNonMatrixDevice();
unsigned int matrix_type;
unsigned int matrix_rows;
@@ -110,17 +110,17 @@ void RGBController_OpenRazer::UpdateLEDs()
}
}
void RGBController_OpenRazer::UpdateZoneLEDs(int zone)
void RGBController_OpenRazer::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_OpenRazer::UpdateSingleLED(int led)
void RGBController_OpenRazer::UpdateSingleLED(int /*led*/)
{
UpdateLEDs();
}
void RGBController_OpenRazer::SetupMatrixDevice(device * razer_device, device_fn_type* razer_functions, unsigned int rows, unsigned int cols)
void RGBController_OpenRazer::SetupMatrixDevice(device_fn_type* razer_functions, unsigned int rows, unsigned int cols)
{
if(!razer_functions->matrix_custom_frame)
{
@@ -145,7 +145,7 @@ void RGBController_OpenRazer::SetupMatrixDevice(device * razer_device, device_fn
}
}
void RGBController_OpenRazer::SetupNonMatrixDevice(device * razer_device, device_fn_type* razer_functions)
void RGBController_OpenRazer::SetupNonMatrixDevice()
{
matrix_type = RAZER_TYPE_NOMATRIX;
}
@@ -157,14 +157,6 @@ RGBController_OpenRazer::RGBController_OpenRazer(device * razer_device, device_f
this->razer_device = razer_device;
this->razer_functions = razer_functions;
unsigned int led_count = 0;
/*-----------------------------------------------------------------*\
| Initialize buffer |
\*-----------------------------------------------------------------*/
memset(string_buf, 0xFF, sizeof(string_buf));
string_buf[1023] = '\0';
/*-----------------------------------------------------------------*\
| Start device at -1. This indicates the device was not detected |
\*-----------------------------------------------------------------*/
@@ -188,29 +180,17 @@ RGBController_OpenRazer::RGBController_OpenRazer(device * razer_device, device_f
\*-----------------------------------------------------------------*/
location = "";
/*-----------------------------------------------------------------*\
| Initialize buffer |
\*-----------------------------------------------------------------*/
//memset(string_buf, 0xFF, sizeof(string_buf));
//string_buf[1023] = '\0';
/*-----------------------------------------------------------------*\
| Get the serial number from the dev path |
\*-----------------------------------------------------------------*/
//razer_functions->device_serial->show(razer_device, NULL, string_buf);
//serial = string_buf;
/*-----------------------------------------------------------------*\
| Initialize buffer |
\*-----------------------------------------------------------------*/
//memset(string_buf, 0xFF, sizeof(string_buf));
//string_buf[1023] = '\0';
razer_functions->device_serial->show(razer_device, NULL, string_buf);
serial = string_buf;
/*-----------------------------------------------------------------*\
| Get the firmware version from the dev path |
\*-----------------------------------------------------------------*/
//razer_functions->firmware_version->show(razer_device, NULL, string_buf);
//version = string_buf;
razer_functions->firmware_version->show(razer_device, NULL, string_buf);
version = string_buf;
/*-----------------------------------------------------------------*\
| Loop through all known devices to look for a name match |
@@ -314,54 +294,64 @@ RGBController_OpenRazer::RGBController_OpenRazer(device * razer_device, device_f
\*---------------------------------------------------------*/
if(device_list[i]->matrix_type == true)
{
SetupMatrixDevice(razer_device, razer_functions, device_list[i]->rows, device_list[i]->cols);
SetupMatrixDevice(razer_functions, device_list[i]->rows, device_list[i]->cols);
}
else
{
SetupNonMatrixDevice(razer_device, razer_functions);
SetupNonMatrixDevice();
}
/*---------------------------------------------------------*\
| Fill in zone information based on device table |
\*---------------------------------------------------------*/
for (int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++)
SetupZones();
}
}
}
void RGBController_OpenRazer::SetupZones()
{
/*---------------------------------------------------------*\
| Fill in zone information based on device table |
\*---------------------------------------------------------*/
for(unsigned int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++)
{
if(device_list[device_index]->zones[zone_id] != NULL)
{
zone new_zone;
new_zone.name = device_list[device_index]->zones[zone_id]->name;
new_zone.type = device_list[device_index]->zones[zone_id]->type;
new_zone.leds_count = device_list[device_index]->zones[zone_id]->rows * device_list[device_index]->zones[zone_id]->cols;
new_zone.leds_min = new_zone.leds_count;
new_zone.leds_max = new_zone.leds_count;
zones.push_back(new_zone);
}
}
for(unsigned int zone_id = 0; zone_id < zones.size(); zone_id++)
{
for (unsigned int row_id = 0; row_id < device_list[device_index]->zones[zone_id]->rows; row_id++)
{
for (unsigned int col_id = 0; col_id < device_list[device_index]->zones[zone_id]->cols; col_id++)
{
if (device_list[i]->zones[zone_id] != NULL)
{
zone new_zone;
new_zone.name = device_list[i]->zones[zone_id]->name;
new_zone.type = device_list[i]->zones[zone_id]->type;
led* new_led = new led();
for (unsigned int row_id = 0; row_id < device_list[i]->zones[zone_id]->rows; row_id++)
{
std::vector<int> new_zone_map;
for (unsigned int col_id = 0; col_id < device_list[i]->zones[zone_id]->cols; col_id++)
{
char id_buf[8];
snprintf(id_buf, 8, "%d", col_id + 1);
RGBColor new_color = 0x00000000;
colors.push_back(new_color);
led* new_led = new led();
new_led->name = device_list[i]->zones[zone_id]->name + " LED ";
new_led->name.append(id_buf);
leds.push_back(*new_led);
new_zone_map.push_back(led_count);
led_count++;
}
new_zone.map.push_back(new_zone_map);
}
zones.push_back(new_zone);
}
new_led->name = device_list[device_index]->zones[zone_id]->name + " LED ";
new_led->name.append(std::to_string(col_id + 1));
leds.push_back(*new_led);
}
}
}
SetupColors();
}
void RGBController_OpenRazer::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_OpenRazer::SetCustomMode()
@@ -74,6 +74,11 @@ public:
public:
RGBController_OpenRazer(device * razer_device, device_fn_type* razer_functions);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
@@ -84,8 +89,8 @@ public:
int device_index;
private:
void SetupMatrixDevice(device * razer_device, device_fn_type* razer_functions, unsigned int rows, unsigned int cols);
void SetupNonMatrixDevice(device * razer_device, device_fn_type* razer_functions);
void SetupMatrixDevice(device_fn_type* razer_functions, unsigned int rows, unsigned int cols);
void SetupNonMatrixDevice();
unsigned int matrix_type;
unsigned int matrix_rows;
+81 -78
View File
@@ -9,54 +9,6 @@
#include "RGBController_PatriotViper.h"
void RGBController_PatriotViper::UpdateLEDs()
{
if(viper->direct == true)
{
for(int led = 0; led < 5; led++)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
viper->SetLEDColor(led, red, grn, blu);
}
}
else
{
for(int led = 0; led < 5; led++)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
viper->SetLEDEffectColor(led, red, grn, blu);
}
}
}
void RGBController_PatriotViper::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_PatriotViper::UpdateSingleLED(int led)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if(viper->direct == true)
{
viper->SetLEDColor(led, red, grn, blu);
}
else
{
viper->SetLEDEffectColor(led, red, grn, blu);
}
}
RGBController_PatriotViper::RGBController_PatriotViper(PatriotViperController* viper_ptr)
{
viper = viper_ptr;
@@ -146,42 +98,93 @@ RGBController_PatriotViper::RGBController_PatriotViper(PatriotViperController* v
Aurora.speed = VIPER_SPEED_DEFAULT;
modes.push_back(Aurora);
colors.resize(viper->GetLEDCount());
SetupZones();
}
unsigned int led_idx = 0;
void RGBController_PatriotViper::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
for(unsigned int slot = 0; slot < viper->GetSlotCount(); slot++)
{
zone* new_zone = new zone;
char slot_idx_str[3];
sprintf(slot_idx_str, "%d", slot);
new_zone->name = "Patriot Viper RGB Slot ";
new_zone->name.append(slot_idx_str);
new_zone->type = ZONE_TYPE_LINEAR;
std::vector<int> *new_zone_map = new std::vector<int>();
for(int led_slot_idx = 0; led_slot_idx < 5; led_slot_idx++)
{
led* new_led = new led();
char led_idx_str[3];
sprintf(led_idx_str, "%d", led_slot_idx);
new_led->name = "Patriot Viper RGB Slot ";
new_led->name.append(slot_idx_str);
new_led->name.append(", LED ");
new_led->name.append(led_idx_str);
leds.push_back(*new_led);
new_zone_map->push_back(led_idx);
led_idx++;
}
new_zone->map.push_back(*new_zone_map);
new_zone->name = "Patriot Viper RGB";
new_zone->type = ZONE_TYPE_LINEAR;
new_zone->leds_min = 5;
new_zone->leds_max = 5;
new_zone->leds_count = 5;
zones.push_back(*new_zone);
}
/*---------------------------------------------------------*\
| Set up LEDs |
\*---------------------------------------------------------*/
for(std::size_t led_idx = 0; led_idx < zones[0].leds_count; led_idx++)
{
led* new_led = new led();
new_led->name = "Patriot Viper RGB LED ";
new_led->name.append(std::to_string(led_idx + 1));
leds.push_back(*new_led);
}
SetupColors();
}
void RGBController_PatriotViper::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_PatriotViper::UpdateLEDs()
{
if(viper->direct == true)
{
for(int led = 0; led < 5; led++)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
viper->SetLEDColor(led, red, grn, blu);
}
}
else
{
for(int led = 0; led < 5; led++)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
viper->SetLEDEffectColor(led, red, grn, blu);
}
}
}
void RGBController_PatriotViper::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_PatriotViper::UpdateSingleLED(int led)
{
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
if(viper->direct == true)
{
viper->SetLEDColor(led, red, grn, blu);
}
else
{
viper->SetLEDEffectColor(led, red, grn, blu);
}
}
void RGBController_PatriotViper::SetCustomMode()
@@ -16,6 +16,11 @@ class RGBController_PatriotViper : public RGBController
{
public:
RGBController_PatriotViper(PatriotViperController* viper_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
+67 -42
View File
@@ -9,29 +9,6 @@
#include "RGBController_Polychrome.h"
void RGBController_Polychrome::UpdateLEDs()
{
for (std::size_t led = 0; led < colors.size(); led++)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
polychrome->SetColor(red, grn, blu);
}
}
void RGBController_Polychrome::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_Polychrome::UpdateSingleLED(int led)
{
UpdateLEDs();
}
static const char* polychrome_zone_names[] =
{
"Motherboard"
@@ -86,7 +63,7 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
Random.flags = MODE_FLAG_HAS_SPEED;
Random.color_mode = MODE_COLORS_NONE;
modes.push_back(Random);
mode Music;
Music.name = "Music";
Music.value = ASRLED_MODE_MUSIC;
@@ -202,32 +179,80 @@ RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychr
modes.push_back(Rainbow);
}
colors.resize(polychrome->GetLEDCount());
SetupZones();
}
// Search through all LEDs and create zones for each channel type
void RGBController_Polychrome::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
for (unsigned int i = 0; i < polychrome->GetLEDCount(); i++)
{
zone* new_zone = new zone();
led* new_led = new led();
std::vector<int>* zone_row = new std::vector<int>();
/*---------------------------------------------------------*\
| Set zone name to channel name |
\*---------------------------------------------------------*/
new_zone->name = polychrome_zone_names[i];
new_zone->leds_min = 1;
new_zone->leds_max = 1;
new_zone->leds_count = 1;
// Set zone name to channel name
new_zone->name = polychrome_zone_names[i];
new_led->name = polychrome_zone_names[i];
zone_row->push_back(i);
// Aura devices can be either single or linear, never matrix
// That means only one row is needed
new_zone->map.push_back(*zone_row);
// Push new LED to LEDs vector
leds.push_back(*new_led);
// Push new zone to zones vector
/*---------------------------------------------------------*\
| Push new zone to zones vector |
\*---------------------------------------------------------*/
zones.push_back(*new_zone);
}
/*---------------------------------------------------------*\
| Set up LEDs |
\*---------------------------------------------------------*/
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
{
/*---------------------------------------------------------*\
| Each zone only has one LED |
\*---------------------------------------------------------*/
led* new_led = new led();
new_led->name = polychrome_zone_names[zone_idx];
/*---------------------------------------------------------*\
| Push new LED to LEDs vector |
\*---------------------------------------------------------*/
leds.push_back(*new_led);
}
SetupColors();
}
void RGBController_Polychrome::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_Polychrome::UpdateLEDs()
{
for (std::size_t led = 0; led < colors.size(); led++)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
polychrome->SetColor(red, grn, blu);
}
}
void RGBController_Polychrome::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_Polychrome::UpdateSingleLED(int /*led*/)
{
UpdateLEDs();
}
void RGBController_Polychrome::SetCustomMode()
+5
View File
@@ -16,6 +16,11 @@ class RGBController_Polychrome : public RGBController
{
public:
RGBController_Polychrome(PolychromeController* polychrome_ptr);
void SetupZones();
void ResizeZone(int zone, int new_size);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
+38 -27
View File
@@ -173,31 +173,7 @@ RGBController_PoseidonZRGB::RGBController_PoseidonZRGB(PoseidonZRGBController* p
Reactive.color_mode = MODE_COLORS_NONE;
modes.push_back(Reactive);
colors.resize(104);
unsigned int led_idx = 0;
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
{
zone new_zone;
new_zone.name.append(zone_names[zone_idx]);
std::vector<int> new_zone_map;
for(unsigned int led_count = 0; led_count < zone_sizes[zone_idx]; led_count++)
{
led new_led;
new_led.name.append(led_names[led_idx]);
leds.push_back(new_led);
new_zone_map.push_back(led_idx);
led_idx++;
}
new_zone.map.push_back(new_zone_map);
zones.push_back(new_zone);
}
SetupZones();
}
RGBController_PoseidonZRGB::~RGBController_PoseidonZRGB()
@@ -205,6 +181,41 @@ RGBController_PoseidonZRGB::~RGBController_PoseidonZRGB()
}
void RGBController_PoseidonZRGB::SetupZones()
{
/*---------------------------------------------------------*\
| Set up zones |
\*---------------------------------------------------------*/
unsigned int total_led_count = 0;
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
{
zone new_zone;
new_zone.name = zone_names[zone_idx];
new_zone.leds_min = zone_sizes[zone_idx];
new_zone.leds_max = zone_sizes[zone_idx];
new_zone.leds_count = zone_sizes[zone_idx];
zones.push_back(new_zone);
total_led_count += zone_sizes[zone_idx];
}
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
{
led new_led;
new_led.name = led_names[led_idx];
leds.push_back(new_led);
}
SetupColors();
}
void RGBController_PoseidonZRGB::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_PoseidonZRGB::UpdateLEDs()
{
if(active_mode == 0)
@@ -217,12 +228,12 @@ void RGBController_PoseidonZRGB::UpdateLEDs()
}
}
void RGBController_PoseidonZRGB::UpdateZoneLEDs(int zone)
void RGBController_PoseidonZRGB::UpdateZoneLEDs(int /*zone*/)
{
UpdateLEDs();
}
void RGBController_PoseidonZRGB::UpdateSingleLED(int led)
void RGBController_PoseidonZRGB::UpdateSingleLED(int /*led*/)
{
UpdateLEDs();
}

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