Compare commits
87
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
010ab1182d | ||
|
|
7e64ca1f83 | ||
|
|
2fcff92523 | ||
|
|
8beeb5f7b2 | ||
|
|
7d2b5f285f | ||
|
|
b8eb4e9bcb | ||
|
|
733b904ec4 | ||
|
|
59a3b41480 | ||
|
|
28b41451f8 | ||
|
|
126c9295ac | ||
|
|
0e4a162667 | ||
|
|
15fd537fa8 | ||
|
|
557c9df9a0 | ||
|
|
68b0dc9e2e | ||
|
|
c8a1363b35 | ||
|
|
0a61e38ee1 | ||
|
|
b5f687c402 | ||
|
|
50875fc698 | ||
|
|
802d444d9d | ||
|
|
a8c83e5688 | ||
|
|
63bf13faac | ||
|
|
5bc80cce96 | ||
|
|
3c34a659a0 | ||
|
|
efed3faaf4 | ||
|
|
155ad165b1 | ||
|
|
ef79de6c7c | ||
|
|
854d7d0ec5 | ||
|
|
727516e712 | ||
|
|
9126ded32e | ||
|
|
d5a32eb743 | ||
|
|
1bfeb59d6a | ||
|
|
fd7d956913 | ||
|
|
50942d11b1 | ||
|
|
aebffd9e48 | ||
|
|
ae77e44f73 | ||
|
|
675eb40b94 | ||
|
|
7f09b14f50 | ||
|
|
b17d87a15b | ||
|
|
9e963e5cc7 | ||
|
|
fa8f06f273 | ||
|
|
9c1d0e1a79 | ||
|
|
60b9fd08bb | ||
|
|
9c5f592618 | ||
|
|
8f96f9535d | ||
|
|
d94d6eb569 | ||
|
|
06f21865c6 | ||
|
|
18bf0ce013 | ||
|
|
af0bfde610 | ||
|
|
ab4a07244a | ||
|
|
08532dc56c | ||
|
|
c69d8c4680 | ||
|
|
e9cf421719 | ||
|
|
4887e9a11e | ||
|
|
f71f325a97 | ||
|
|
7ba607be8a | ||
|
|
4714aec6dd | ||
|
|
7554e366f4 | ||
|
|
d60936b2e5 | ||
|
|
90b57e1846 | ||
|
|
8c3acbe889 | ||
|
|
f5d7f2e537 | ||
|
|
234b006bee | ||
|
|
9c4bbec686 | ||
|
|
25d85a1db0 | ||
|
|
dde0292719 | ||
|
|
9d1745c0d0 | ||
|
|
559f1e9bcc | ||
|
|
3c95f9fe21 | ||
|
|
c2e384ab39 | ||
|
|
fe7d7df29b | ||
|
|
73d91b9494 | ||
|
|
a2cdfc5aec | ||
|
|
484e4e9770 | ||
|
|
c45001b810 | ||
|
|
e3dcb9e87d | ||
|
|
75cf8b6aa8 | ||
|
|
35ec4f5e90 | ||
|
|
ab03edb6ce | ||
|
|
022871c5c5 | ||
|
|
dc3009bcaf | ||
|
|
0941f25a8d | ||
|
|
20fa1f4b1a | ||
|
|
f1be1c9a8f | ||
|
|
b782a63ed5 | ||
|
|
31446d18b4 | ||
|
|
3a249382fb | ||
|
|
1e650d8f85 |
@@ -0,0 +1,3 @@
|
||||
[submodule "dependencies/libe131"]
|
||||
path = dependencies/libe131
|
||||
url = https://github.com/hhromic/libe131
|
||||
@@ -0,0 +1,248 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 8/19/2018 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraController::AuraController(i2c_smbus_interface* bus, aura_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
AuraUpdateDeviceName();
|
||||
|
||||
// Read the device configuration table
|
||||
for (int i = 0; i < 64; i++)
|
||||
{
|
||||
config_table[i] = AuraRegisterRead(AURA_REG_CONFIG_TABLE + i);
|
||||
}
|
||||
|
||||
// Read LED count from configuration table
|
||||
led_count = config_table[AURA_CONFIG_LED_COUNT];
|
||||
|
||||
// LED-0116 - First generation motherboard controller
|
||||
if (strcmp(device_name, "LED-0116") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V1;
|
||||
}
|
||||
// DIMM_LED-0102 - First generation DRAM controller (Trident Z RGB)
|
||||
else if (strcmp(device_name, "DIMM_LED-0102") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V1;
|
||||
}
|
||||
// AUDA0-E6K5-0101 - Second generation DRAM controller (Geil Super Luce)
|
||||
else if (strcmp(device_name, "AUDA0-E6K5-0101") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
// AUMA0-E6K5-0106 - Second generation motherboard controller
|
||||
else if (strcmp(device_name, "AUMA0-E6K5-0106") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
// AUMA0-E6K5-0105 - Second generation motherboard controller
|
||||
else if (strcmp(device_name, "AUMA0-E6K5-0105") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
// AUMA0-E6K5-0104 - Second generation motherboard controller
|
||||
else if (strcmp(device_name, "AUMA0-E6K5-0104") == 0)
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT_V2;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT_V2;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V2;
|
||||
}
|
||||
// Assume first generation controller if string does not match
|
||||
else
|
||||
{
|
||||
direct_reg = AURA_REG_COLORS_DIRECT;
|
||||
effect_reg = AURA_REG_COLORS_EFFECT;
|
||||
channel_cfg = AURA_CONFIG_CHANNEL_V1;
|
||||
}
|
||||
}
|
||||
|
||||
AuraController::~AuraController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char * AuraController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
unsigned char AuraController::GetChannel(unsigned int led)
|
||||
{
|
||||
return(config_table[channel_cfg + led]);
|
||||
}
|
||||
|
||||
const char * AuraController::GetChannelName(unsigned int led)
|
||||
{
|
||||
switch (config_table[channel_cfg + led])
|
||||
{
|
||||
case (unsigned char)AURA_LED_CHANNEL_AUDIO:
|
||||
return(aura_channels[0]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_BACKPLATE:
|
||||
return(aura_channels[1]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_BACK_IO:
|
||||
return(aura_channels[2]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_CENTER:
|
||||
return(aura_channels[3]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_CENTER_START:
|
||||
return(aura_channels[4]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_DRAM:
|
||||
return(aura_channels[5]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_PCIE:
|
||||
return(aura_channels[6]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER:
|
||||
return(aura_channels[7]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER_2:
|
||||
return(aura_channels[8]);
|
||||
break;
|
||||
|
||||
case (unsigned char)AURA_LED_CHANNEL_RGB_HEADER_3:
|
||||
return(aura_channels[9]);
|
||||
break;
|
||||
|
||||
default:
|
||||
return(aura_channels[10]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int AuraController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
void AuraController::SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char* colors = new unsigned char[led_count * 3];
|
||||
|
||||
for (int i = 0; i < (led_count * 3); i += 3)
|
||||
{
|
||||
colors[i + 0] = red;
|
||||
colors[i + 1] = blue;
|
||||
colors[i + 2] = green;
|
||||
}
|
||||
|
||||
AuraRegisterWriteBlock(direct_reg, colors, led_count * 3);
|
||||
|
||||
delete colors;
|
||||
}
|
||||
|
||||
void AuraController::SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char* colors = new unsigned char[led_count * 3];
|
||||
|
||||
for (int i = 0; i < (led_count * 3); i += 3)
|
||||
{
|
||||
colors[i + 0] = red;
|
||||
colors[i + 1] = blue;
|
||||
colors[i + 2] = green;
|
||||
}
|
||||
|
||||
AuraRegisterWriteBlock(effect_reg, colors, led_count * 3);
|
||||
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
|
||||
delete colors;
|
||||
}
|
||||
|
||||
void AuraController::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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
unsigned char colors[3] = { red, blue, green };
|
||||
|
||||
AuraRegisterWriteBlock(effect_reg + (3 * led), colors, 3);
|
||||
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
void AuraController::SetMode(unsigned char mode)
|
||||
{
|
||||
AuraRegisterWrite(AURA_REG_MODE, mode);
|
||||
AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
void AuraController::AuraUpdateDeviceName()
|
||||
{
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
device_name[i] = AuraRegisterRead(AURA_REG_DEVICE_NAME + i);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned char AuraController::AuraRegisterRead(aura_register reg)
|
||||
{
|
||||
//Write Aura register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Read Aura value
|
||||
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
|
||||
|
||||
}
|
||||
|
||||
void AuraController::AuraRegisterWrite(aura_register reg, unsigned char val)
|
||||
{
|
||||
//Write Aura register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write Aura value
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
|
||||
|
||||
}
|
||||
|
||||
void AuraController::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));
|
||||
|
||||
//Write Aura block data
|
||||
bus->i2c_smbus_write_block_data(dev, 0x03, sz, data);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura RGB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 8/19/2018 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char aura_dev_id;
|
||||
typedef unsigned short aura_register;
|
||||
|
||||
#define AURA_APPLY_VAL 0x01 /* Value for Apply Changes Register */
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_REG_DEVICE_NAME = 0x1000, /* Device String 16 bytes */
|
||||
AURA_REG_CONFIG_TABLE = 0x1C00, /* Start of LED configuration bytes */
|
||||
AURA_REG_COLORS_DIRECT = 0x8000, /* Colors for Direct Mode 15 bytes */
|
||||
AURA_REG_COLORS_EFFECT = 0x8010, /* Colors for Internal Effects 15 bytes */
|
||||
AURA_REG_DIRECT = 0x8020, /* "Direct Access" Selection Register */
|
||||
AURA_REG_MODE = 0x8021, /* AURA Mode Selection Register */
|
||||
AURA_REG_APPLY = 0x80A0, /* AURA Apply Changes Register */
|
||||
AURA_REG_SLOT_INDEX = 0x80F8, /* AURA Slot Index Register (RAM only) */
|
||||
AURA_REG_I2C_ADDRESS = 0x80F9, /* AURA I2C Address Register (RAM only) */
|
||||
AURA_REG_COLORS_DIRECT_V2 = 0x8100, /* Direct Colors (v2) 30 bytes */
|
||||
AURA_REG_COLORS_EFFECT_V2 = 0x8160, /* Internal Colors (v2) 30 bytes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_MODE_OFF = 0, /* OFF mode */
|
||||
AURA_MODE_STATIC = 1, /* Static color mode */
|
||||
AURA_MODE_BREATHING = 2, /* Breathing effect mode */
|
||||
AURA_MODE_FLASHING = 3, /* Flashing effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE = 4, /* Spectrum Cycle mode */
|
||||
AURA_MODE_RAINBOW = 5, /* Rainbow effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_BREATHING = 6, /* Rainbow Breathing effect mode */
|
||||
AURA_MODE_CHASE_FADE = 7, /* Chase with Fade effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE = 8, /* Chase with Fade, Rainbow effect mode */
|
||||
AURA_MODE_CHASE = 9, /* Chase effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_CHASE = 10, /* Chase with Rainbow effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_WAVE = 11, /* Wave effect mode */
|
||||
AURA_MODE_CHASE_RAINBOW_PULSE = 12, /* Chase with Rainbow Pulse effect mode*/
|
||||
AURA_MODE_RANDOM_FLICKER = 13, /* Random flicker effect mode */
|
||||
AURA_NUMBER_MODES /* Number of Aura modes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_LED_CHANNEL_DRAM_2 = 0x05, /* DRAM LED channel */
|
||||
AURA_LED_CHANNEL_CENTER_START = 0x82, /* Center zone first LED channel */
|
||||
AURA_LED_CHANNEL_CENTER = 0x83, /* Center zone LED channel */
|
||||
AURA_LED_CHANNEL_AUDIO = 0x84, /* Audio zone LED channel */
|
||||
AURA_LED_CHANNEL_BACK_IO = 0x85, /* Back I/O zone LED channel */
|
||||
AURA_LED_CHANNEL_RGB_HEADER = 0x86, /* RGB Header LED channel */
|
||||
AURA_LED_CHANNEL_RGB_HEADER_2 = 0x87, /* RGB Header 2 LED channel */
|
||||
AURA_LED_CHANNEL_BACKPLATE = 0x88, /* Backplate zone LED channel */
|
||||
AURA_LED_CHANNEL_DRAM = 0x8A, /* DRAM LED channel */
|
||||
AURA_LED_CHANNEL_PCIE = 0x8B, /* PCIe zone LED channel */
|
||||
AURA_LED_CHANNEL_RGB_HEADER_3 = 0x91, /* RGB Header 3 LED channel */
|
||||
};
|
||||
|
||||
static const char* aura_channels[] = /* Aura channel strings */
|
||||
{
|
||||
"Audio",
|
||||
"Backplate",
|
||||
"Back I/O",
|
||||
"Center",
|
||||
"Center",
|
||||
"DRAM",
|
||||
"PCIe",
|
||||
"RGB Header",
|
||||
"RGB Header 2",
|
||||
"RGB Header",
|
||||
"Unknown",
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CONFIG_LED_COUNT = 0x02, /* LED Count configuration offset */
|
||||
AURA_CONFIG_CHANNEL_V1 = 0x13, /* LED Channel configuration offset */
|
||||
AURA_CONFIG_CHANNEL_V2 = 0x1B, /* LED Channel V2 configuration offset */
|
||||
};
|
||||
|
||||
class AuraController
|
||||
{
|
||||
public:
|
||||
AuraController(i2c_smbus_interface* bus, aura_dev_id dev);
|
||||
~AuraController();
|
||||
|
||||
char* GetDeviceName();
|
||||
unsigned char GetChannel(unsigned int led);
|
||||
const char* GetChannelName(unsigned int led);
|
||||
unsigned int GetLEDCount();
|
||||
void SetAllColorsDirect(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetAllColorsEffect(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetDirect(unsigned char direct);
|
||||
void SetLEDColorDirect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColorEffect(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
void AuraUpdateDeviceName();
|
||||
|
||||
unsigned char AuraRegisterRead(aura_register reg);
|
||||
void AuraRegisterWrite(aura_register reg, unsigned char val);
|
||||
void AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz);
|
||||
|
||||
private:
|
||||
char device_name[16];
|
||||
unsigned char config_table[64];
|
||||
unsigned int led_count;
|
||||
aura_register direct_reg;
|
||||
aura_register effect_reg;
|
||||
unsigned char channel_cfg;
|
||||
i2c_smbus_interface * bus;
|
||||
aura_dev_id dev;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,125 @@
|
||||
#include "AuraController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Aura.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForAuraController *
|
||||
* *
|
||||
* 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 *
|
||||
* for incrementing values 0...F which was observed at this location during data dump *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForAuraController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != (i - 0xA0))
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForAuraController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraControllers *
|
||||
* *
|
||||
* 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 *
|
||||
* at their correct initialized addresses. Also looks for motherboard controller at *
|
||||
* address 0x4E. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
AuraController* new_aura;
|
||||
RGBController_Aura* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Remap Aura-enabled RAM modules on 0x77
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
{
|
||||
int res = busses[bus]->i2c_smbus_write_quick(0x77, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
AuraController temp_controller(busses[bus], 0x77);
|
||||
|
||||
temp_controller.AuraRegisterWrite(AURA_REG_SLOT_INDEX, slot);
|
||||
temp_controller.AuraRegisterWrite(AURA_REG_I2C_ADDRESS, 0xE0 + (slot << 1));
|
||||
}
|
||||
|
||||
// Add Aura-enabled controllers at their remapped addresses
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
{
|
||||
if (TestForAuraController(busses[bus], 0x70 + slot))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x70 + slot);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x40
|
||||
if (TestForAuraController(busses[bus], 0x40))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x40);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x4E
|
||||
if (TestForAuraController(busses[bus], 0x4E))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x4E);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x4F
|
||||
if (TestForAuraController(busses[bus], 0x4F))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x4F);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x66
|
||||
if (TestForAuraController(busses[bus], 0x66))
|
||||
{
|
||||
new_aura = new AuraController(busses[bus], 0x66);
|
||||
new_controller = new RGBController_Aura(new_aura);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectAuraControllers() */
|
||||
@@ -0,0 +1,58 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairController.h |
|
||||
| |
|
||||
| Driver for Corsair Vengeance RGB RAM |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/8/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "CorsairController.h"
|
||||
#include <cstring>
|
||||
|
||||
CorsairController::CorsairController(i2c_smbus_interface* bus, corsair_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
strcpy(device_name, "Corsair Vengeance RGB");
|
||||
led_count = 1;
|
||||
}
|
||||
|
||||
CorsairController::~CorsairController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char * CorsairController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
unsigned int CorsairController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
void CorsairController::SetAllColors(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);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_GREEN_VAL, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_BLUE_VAL, blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
|
||||
void CorsairController::SetLEDColor(unsigned int led, 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);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_GREEN_VAL, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_BLUE_VAL, blue);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
|
||||
void CorsairController::SetMode(unsigned char mode)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_VENGEANCE_RGB_CMD_MODE, CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairController.h |
|
||||
| |
|
||||
| Definitions and types for Corsair |
|
||||
| Vengeance RGB RAM lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 3/8/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char corsair_dev_id;
|
||||
typedef unsigned char corsair_cmd;
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_VENGEANCE_RGB_CMD_FADE_TIME = 0xA4, /* Fade Time, 0 for Static */
|
||||
CORSAIR_VENGEANCE_RGB_CMD_HOLD_TIME = 0xA5, /* Hold Time */
|
||||
CORSAIR_VENGEANCE_RGB_CMD_MODE = 0xA6, /* Mode Control Value */
|
||||
CORSAIR_VENGEANCE_RGB_CMD_RED_VAL = 0xB0, /* Red Color Value */
|
||||
CORSAIR_VENGEANCE_RGB_CMD_GREEN_VAL = 0xB1, /* Green Color Value */
|
||||
CORSAIR_VENGEANCE_RGB_CMD_BLUE_VAL = 0xB2, /* Blue Color Value */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_VENGEANCE_RGB_MODE_SINGLE = 0x00, /* Single Color Effect Mode */
|
||||
CORSAIR_VENGEANCE_RGB_MODE_FADE = 0x01, /* Fade Through Colors */
|
||||
CORSAIR_VENGEANCE_RGB_MODE_PULSE = 0x02, /* Pulse Through Colors */
|
||||
CORSAIR_NUMBER_MODES /* Number of Corsair modes */
|
||||
};
|
||||
|
||||
class CorsairController
|
||||
{
|
||||
public:
|
||||
CorsairController(i2c_smbus_interface* bus, corsair_dev_id dev);
|
||||
~CorsairController();
|
||||
|
||||
char* GetDeviceName();
|
||||
unsigned int GetLEDCount();
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
i2c_smbus_interface * bus;
|
||||
corsair_dev_id dev;
|
||||
};
|
||||
@@ -0,0 +1,109 @@
|
||||
#include "CorsairController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_Corsair.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairController *
|
||||
* *
|
||||
* Tests the given address to see if a Corsair controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCorsairController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != 0xBA)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairControllers *
|
||||
* *
|
||||
* Detect Corsair controllers on the enumerated I2C busses. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
CorsairController* new_corsair;
|
||||
RGBController_Corsair* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for Corsair controller at 0x58
|
||||
if (TestForCorsairController(busses[bus], 0x58))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x58);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x59
|
||||
if (TestForCorsairController(busses[bus], 0x59))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x59);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5A
|
||||
if (TestForCorsairController(busses[bus], 0x5A))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5A);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5B
|
||||
if (TestForCorsairController(busses[bus], 0x5B))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5B);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5C
|
||||
if (TestForCorsairController(busses[bus], 0x5C))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5C);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5D
|
||||
if (TestForCorsairController(busses[bus], 0x5D))
|
||||
{
|
||||
new_corsair = new CorsairController(busses[bus], 0x5D);
|
||||
new_controller = new RGBController_Corsair(new_corsair);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairControllers() */
|
||||
@@ -0,0 +1,137 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairProController.cpp |
|
||||
| |
|
||||
| Definitions and types for Corsair |
|
||||
| Vengeance Pro RGB RAM lighting controller|
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/30/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "CorsairProController.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
CorsairProController::CorsairProController(i2c_smbus_interface* bus, corsair_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
strcpy(device_name, "Corsair Vengeance Pro RGB");
|
||||
led_count = CORSAIR_PRO_LED_COUNT;
|
||||
|
||||
for (int i = 0; i < led_count; i++)
|
||||
{
|
||||
led_red[i] = 0;
|
||||
led_green[i] = 0;
|
||||
led_blue[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
CorsairProController::~CorsairProController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* CorsairProController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
unsigned int CorsairProController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
void CorsairProController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
for (int i = 0; i < led_count; i++)
|
||||
{
|
||||
led_red[i] = red;
|
||||
led_green[i] = green;
|
||||
led_blue[i] = blue;
|
||||
}
|
||||
}
|
||||
|
||||
void CorsairProController::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()
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x02);
|
||||
Sleep(1);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
Sleep(1);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_red[i]);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_green[i]);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, led_blue[i]);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
|
||||
}
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x02);
|
||||
}
|
||||
|
||||
void CorsairProController::SetEffect(unsigned char mode)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x01);
|
||||
Sleep(1);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
Sleep(1);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, mode); //Mode
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, CORSAIR_PRO_SPEED_MEDIUM); //Speed
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, CORSAIR_PRO_EFFECT_RANDOM_COLORS); //Custom color
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, CORSAIR_PRO_DIRECTION_UP); //Direction
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 1 red
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 1 green
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 1 blue
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 2 red
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 2 green
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00); // Custom color 2 blue
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0xFF);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
bus->i2c_smbus_write_byte_data(dev, CORSAIR_PRO_REG_COMMAND, 0x00);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x82, 0x01);
|
||||
WaitReady();
|
||||
}
|
||||
|
||||
void CorsairProController::SetCustom()
|
||||
{
|
||||
SetEffect(CORSAIR_PRO_MODE_STATIC);
|
||||
}
|
||||
|
||||
bool CorsairProController::WaitReady()
|
||||
{
|
||||
int i = 0;
|
||||
while (bus->i2c_smbus_read_byte_data(dev, 0x41) != 0x00)
|
||||
{
|
||||
i++;
|
||||
Sleep(1);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*-----------------------------------------*\
|
||||
| CorsairProController.h |
|
||||
| |
|
||||
| Definitions and types for Corsair |
|
||||
| Vengeance Pro RGB RAM lighting controller|
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/30/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char corsair_dev_id;
|
||||
|
||||
#define CORSAIR_PRO_LED_COUNT ( 10 )
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_PRO_REG_COMMAND = 0x20, /* Command write register */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_PRO_MODE_COLOR_SHIFT = 0x00, /* Color Shift mode */
|
||||
CORSAIR_PRO_MODE_COLOR_PULSE = 0x01, /* Color Pulse mode */
|
||||
CORSAIR_PRO_MODE_RAINBOW_WAVE = 0x03, /* Rainbow Wave mode */
|
||||
CORSAIR_PRO_MODE_COLOR_WAVE = 0x04, /* Color Wave mode */
|
||||
CORSAIR_PRO_MODE_VISOR = 0x05, /* Visor mode */
|
||||
CORSAIR_PRO_MODE_RAIN = 0x06, /* Rain mode */
|
||||
CORSAIR_PRO_MODE_MARQUEE = 0x07, /* Marquee mode */
|
||||
CORSAIR_PRO_MODE_RAINBOW = 0x08, /* Rainbow mode */
|
||||
CORSAIR_PRO_MODE_SEQUENTIAL = 0x09, /* Sequential mode */
|
||||
CORSAIR_PRO_MODE_STATIC = 0x10, /* Static mode */
|
||||
|
||||
CORSAIR_PRO_NUMBER_MODES = 10, /* Number of Corsair Pro modes */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_PRO_SPEED_SLOW = 0x00, /* Slow speed */
|
||||
CORSAIR_PRO_SPEED_MEDIUM = 0x01, /* Medium speed */
|
||||
CORSAIR_PRO_SPEED_FAST = 0x02, /* Fast speed */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_PRO_EFFECT_RANDOM_COLORS = 0x00, /* Random colors */
|
||||
CORSAIR_PRO_EFFECT_CUSTOM_COLORS = 0x01, /* Custom colors */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CORSAIR_PRO_DIRECTION_UP = 0x00, /* Up direction */
|
||||
CORSAIR_PRO_DIRECTION_DOWN = 0x01, /* Down direction */
|
||||
CORSAIR_PRO_DIRECTION_LEFT = 0x02, /* Left direction */
|
||||
CORSAIR_PRO_DIRECTION_RIGHT = 0x03, /* Right direction */
|
||||
CORSAIR_PRO_DIRECTION_VERTICAL = 0x01, /* Vertical direction */
|
||||
CORSAIR_PRO_DIRECTION_HORIZONTAL = 0x03, /* Horizontal direction */
|
||||
};
|
||||
|
||||
class CorsairProController
|
||||
{
|
||||
public:
|
||||
CorsairProController(i2c_smbus_interface* bus, corsair_dev_id dev);
|
||||
~CorsairProController();
|
||||
|
||||
char* GetDeviceName();
|
||||
unsigned int GetLEDCount();
|
||||
void SetEffect(unsigned char mode);
|
||||
void SetCustom();
|
||||
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void ApplyColors();
|
||||
bool WaitReady();
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
|
||||
unsigned char led_red[CORSAIR_PRO_LED_COUNT];
|
||||
unsigned char led_green[CORSAIR_PRO_LED_COUNT];
|
||||
unsigned char led_blue[CORSAIR_PRO_LED_COUNT];
|
||||
|
||||
i2c_smbus_interface* bus;
|
||||
corsair_dev_id dev;
|
||||
};
|
||||
@@ -0,0 +1,127 @@
|
||||
#include "CorsairProController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_CorsairPro.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForCorsairProController *
|
||||
* *
|
||||
* Tests the given address to see if a Corsair Pro controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForCorsairProController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x24);
|
||||
|
||||
if (res != 0x02)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x25);
|
||||
|
||||
if (res != 0x02)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x43);
|
||||
|
||||
if (res != 0x1C)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
|
||||
res = bus->i2c_smbus_read_byte_data(address, 0x44);
|
||||
|
||||
if (res != 0x03)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForCorsairProController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectCorsairProControllers *
|
||||
* *
|
||||
* Detect Corsair 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)
|
||||
{
|
||||
CorsairProController* new_corsair_pro;
|
||||
RGBController_CorsairPro* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for Corsair controller at 0x58
|
||||
if (TestForCorsairProController(busses[bus], 0x58))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x58);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x59
|
||||
if (TestForCorsairProController(busses[bus], 0x59))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x59);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5A
|
||||
if (TestForCorsairProController(busses[bus], 0x5A))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5A);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5B
|
||||
if (TestForCorsairProController(busses[bus], 0x5B))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5B);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5C
|
||||
if (TestForCorsairProController(busses[bus], 0x5C))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5C);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
// Check for Corsair controller at 0x5D
|
||||
if (TestForCorsairProController(busses[bus], 0x5D))
|
||||
{
|
||||
new_corsair_pro = new CorsairProController(busses[bus], 0x5D);
|
||||
new_controller = new RGBController_CorsairPro(new_corsair_pro);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectCorsairProControllers() */
|
||||
@@ -0,0 +1,136 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Processing Code for NZXT Hue+ |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 12/11/2016 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "HuePlusController.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
HuePlusController::HuePlusController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
HuePlusController::~HuePlusController()
|
||||
{
|
||||
}
|
||||
|
||||
void HuePlusController::Initialize(char* ledstring)
|
||||
{
|
||||
strcpy(led_string, ledstring);
|
||||
|
||||
LPSTR source = NULL;
|
||||
LPSTR channels = NULL;
|
||||
LPSTR numleds = NULL;
|
||||
LPSTR next = NULL;
|
||||
|
||||
source = strtok_s(ledstring, ",", &next);
|
||||
|
||||
//Check for selected channel 0=both, 1= Ch.1, 2= Ch.2
|
||||
if (strlen(next))
|
||||
{
|
||||
channels = strtok_s(next, ",", &next);
|
||||
}
|
||||
|
||||
switch (atoi(channels))
|
||||
{
|
||||
case 0:
|
||||
channel = 0x00;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
channel = 0x01;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
channel = 0x02;
|
||||
break;
|
||||
}
|
||||
|
||||
//Check for the number of LEDs, sets the corresponding variable with the counter for the fans
|
||||
if (strlen(next))
|
||||
{
|
||||
numleds = strtok_s(next, ",", &next);
|
||||
}
|
||||
|
||||
switch (atoi(numleds) / 8)
|
||||
{
|
||||
case 1:
|
||||
fans = 0x00;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
fans = 0x01;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
fans = 0x02;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
fans = 0x03;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
fans = 0x04;
|
||||
break;
|
||||
}
|
||||
|
||||
//Initialize with default baud rate
|
||||
source = strtok(source, "\r");
|
||||
strcpy(port_name, source);
|
||||
baud_rate = 256000;
|
||||
serialport = new serial_port(port_name, baud_rate);
|
||||
|
||||
if (numleds != NULL && strlen(numleds))
|
||||
{
|
||||
num_leds = atoi(numleds);
|
||||
}
|
||||
}
|
||||
|
||||
char* HuePlusController::GetLEDString()
|
||||
{
|
||||
return(led_string);
|
||||
}
|
||||
|
||||
void HuePlusController::SetLEDs(std::vector<RGBColor> colors)
|
||||
{
|
||||
if (serialport != NULL)
|
||||
{
|
||||
unsigned char *serial_buf;
|
||||
|
||||
serial_buf = new unsigned char[hueSize]; //Size of Message always 5 XX Blocks (Mode Selection) + 3 XX for each LED (1 color)
|
||||
//-> max of 40 LEDs per Channel (or 5 Fans a 8 LEDs) -> 125 Blocks (empty LEDs are written, too
|
||||
serial_buf[0] = 0x4b;
|
||||
serial_buf[1] = channel;
|
||||
serial_buf[2] = 0x0e;
|
||||
serial_buf[3] = fans;
|
||||
serial_buf[4] = 0x00;
|
||||
|
||||
for (int i = 5; i < hueSize; i++)
|
||||
{
|
||||
//clearing the buf otherwise sometimes strange things are written to the COM Port
|
||||
serial_buf[i] = 0x00;
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < (num_leds * 3); idx += 3)
|
||||
{
|
||||
int pixel_idx = idx / 3;
|
||||
RGBColor color = colors[pixel_idx];
|
||||
serial_buf[idx + 5] = RGBGetGValue(color);
|
||||
serial_buf[idx + 6] = RGBGetRValue(color);
|
||||
serial_buf[idx + 7] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
serialport->serial_write((char *)serial_buf, hueSize);
|
||||
serialport->serial_flush_tx();
|
||||
|
||||
delete[] serial_buf;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Definitions for NZXT Hue+ |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 12/11/2016 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#ifndef LED_STRIP_H
|
||||
#define LED_STRIP_H
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "serial_port.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE true
|
||||
#define FALSE false
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#define LPSTR char *
|
||||
#define strtok_s strtok_r
|
||||
#endif
|
||||
|
||||
class HuePlusController
|
||||
{
|
||||
public:
|
||||
HuePlusController();
|
||||
~HuePlusController();
|
||||
|
||||
void Initialize(char* ledstring);
|
||||
char* GetLEDString();
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
|
||||
int num_leds;
|
||||
|
||||
private:
|
||||
int baud_rate;
|
||||
int fans;
|
||||
int channel;
|
||||
const int hueSize = 125;
|
||||
|
||||
char led_string[1024];
|
||||
char port_name[128];
|
||||
serial_port *serialport;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,89 @@
|
||||
#include "HuePlusController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_HuePlus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHuePlusControllers *
|
||||
* *
|
||||
* Detect devices supported by the HuePlus driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
HuePlusController* new_hueplus;
|
||||
RGBController_HuePlus* new_controller;
|
||||
|
||||
//Get file path in executable directory
|
||||
std::ifstream infile;
|
||||
char filename[2048];
|
||||
char arg1[64];
|
||||
|
||||
#ifdef WIN32
|
||||
GetModuleFileName(NULL, filename, 2048);
|
||||
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
|
||||
strcat(filename, "\\settings.txt");
|
||||
#else
|
||||
snprintf(arg1, 64, "/proc/%d/exe", getpid());
|
||||
readlink(arg1, filename, 1024);
|
||||
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
|
||||
#endif
|
||||
|
||||
strcat(filename, "/settings.txt");
|
||||
|
||||
//Open settings file
|
||||
infile.open(filename);
|
||||
|
||||
if (infile.good())
|
||||
{
|
||||
for (std::string line; std::getline(infile, line); )
|
||||
{
|
||||
if (line == "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ((line[0] != ';') && (line[0] != '#') && (line[0] != '/'))
|
||||
{
|
||||
char * argument;
|
||||
char * value;
|
||||
|
||||
value = (char *)line.c_str();
|
||||
|
||||
argument = strtok_s(value, "=", &value);
|
||||
|
||||
//Strip off new line characters if present
|
||||
argument = strtok(argument, "\r\n");
|
||||
value = strtok(value, "\r\n");
|
||||
|
||||
if(argument)
|
||||
{
|
||||
if (strcmp(argument, "hueplus") == 0)
|
||||
{
|
||||
new_hueplus = new HuePlusController();
|
||||
new_hueplus->Initialize(value);
|
||||
|
||||
new_controller = new RGBController_HuePlus(new_hueplus);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* DetectHuePlusControllers() */
|
||||
@@ -0,0 +1,102 @@
|
||||
/*-----------------------------------------*\
|
||||
| HyperXController.cpp |
|
||||
| |
|
||||
| Definitions and types for HyperX Predator|
|
||||
| RGB RAM lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/29/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "HyperXController.h"
|
||||
#include <cstring>
|
||||
|
||||
HyperXController::HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
strcpy(device_name, "HyperX Predator RGB");
|
||||
led_count = 1;
|
||||
}
|
||||
|
||||
HyperXController::~HyperXController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* HyperXController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
unsigned int HyperXController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
void HyperXController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_RED, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_GREEN, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_BLUE, blue);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
|
||||
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)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_RED, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_GREEN, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_BLUE, blue);
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
|
||||
}
|
||||
|
||||
void HyperXController::SetMode(unsigned char mode)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x01);
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case HYPERX_MODE_STATIC:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_STATIC);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_RAINBOW:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE1, HYPERX_MODE1_RAINBOW);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_COMET:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_COMET);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_HEARTBEAT:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_HEARTBEAT);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_CYCLE:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE1, HYPERX_MODE1_CYCLE);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_BREATHING:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_BREATHING);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_BOUNCE:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_BOUNCE);
|
||||
break;
|
||||
|
||||
case HYPERX_MODE_BLINK:
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_MODE2, HYPERX_MODE2_BLINK);
|
||||
break;
|
||||
}
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x02);
|
||||
bus->i2c_smbus_write_byte_data(dev, HYPERX_REG_APPLY, 0x03);
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*-----------------------------------------*\
|
||||
| HyperXController.h |
|
||||
| |
|
||||
| Definitions and types for HyperX Predator|
|
||||
| RGB RAM lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/29/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char hyperx_dev_id;
|
||||
typedef unsigned short hyperx_register;
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_REG_BRIGHTNESS = 0xDD, /* Brightness control register (0-100) */
|
||||
HYPERX_REG_APPLY = 0xE1, /* Apply changes register */
|
||||
HYPERX_REG_MODE1 = 0xE3, /* Mode control register 1 */
|
||||
HYPERX_REG_MODE2 = 0xE4, /* Mode control register 2 */
|
||||
HYPERX_REG_RED = 0xEC, /* Red color register */
|
||||
HYPERX_REG_GREEN = 0xED, /* Green color register */
|
||||
HYPERX_REG_BLUE = 0xEE, /* Blue color register */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_MODE1_RAINBOW = 0x05, /* Mode 1 rainbow effect */
|
||||
HYPERX_MODE1_CYCLE = 0x04, /* Mode 1 cycle effect */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_MODE2_BOUNCE = 0x02, /* Mode 2 bounce effect */
|
||||
HYPERX_MODE2_BREATHING = 0x03, /* Mode 2 breathing effect */
|
||||
HYPERX_MODE2_BLINK = 0x06, /* Mode 2 blink effect */
|
||||
HYPERX_MODE2_HEARTBEAT = 0x07, /* Mode 2 heartbeat effect */
|
||||
HYPERX_MODE2_COMET = 0x08, /* Mode 2 comet effect */
|
||||
HYPERX_MODE2_STATIC = 0x09, /* Mode 2 static effect */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
HYPERX_MODE_STATIC = 0, /* Static color mode */
|
||||
HYPERX_MODE_RAINBOW = 1, /* Rainbow wave mode */
|
||||
HYPERX_MODE_COMET = 2, /* Comet (chase) mode */
|
||||
HYPERX_MODE_HEARTBEAT = 3, /* Heartbeat (pulsing) mode */
|
||||
HYPERX_MODE_CYCLE = 4, /* Spectrum cycle mode */
|
||||
HYPERX_MODE_BREATHING = 5, /* Breathing mode */
|
||||
HYPERX_MODE_BOUNCE = 6, /* Bounce mode */
|
||||
HYPERX_MODE_BLINK = 7, /* Blinking mode */
|
||||
HYPERX_NUMBER_MODES /* Number of HyperX modes */
|
||||
};
|
||||
|
||||
|
||||
class HyperXController
|
||||
{
|
||||
public:
|
||||
HyperXController(i2c_smbus_interface* bus, hyperx_dev_id dev);
|
||||
~HyperXController();
|
||||
|
||||
char* GetDeviceName();
|
||||
unsigned int GetLEDCount();
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
|
||||
private:
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
i2c_smbus_interface* bus;
|
||||
hyperx_dev_id dev;
|
||||
};
|
||||
@@ -0,0 +1,70 @@
|
||||
#include "HyperXController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_HyperX.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForHyperXController *
|
||||
* *
|
||||
* Tests the given address to see if a HyperX controller exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForHyperXController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
|
||||
for (int i = 0xA0; i < 0xB0; i++)
|
||||
{
|
||||
res = bus->i2c_smbus_read_byte_data(address, i);
|
||||
|
||||
if (res != i)
|
||||
{
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForHyperXController() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectHyperXControllers *
|
||||
* *
|
||||
* Detect HyperX 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)
|
||||
{
|
||||
HyperXController* new_hyperx;
|
||||
RGBController_HyperX* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for HyperX controller at 0x27
|
||||
if (TestForHyperXController(busses[bus], 0x27))
|
||||
{
|
||||
new_hyperx = new HyperXController(busses[bus], 0x27);
|
||||
new_controller = new RGBController_HyperX(new_hyperx);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectHyperXControllers() */
|
||||
@@ -0,0 +1,147 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Processing Code for Generic LED Strip Interface |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 12/11/2016 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "LEDStripController.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
LEDStripController::LEDStripController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
LEDStripController::~LEDStripController()
|
||||
{
|
||||
}
|
||||
|
||||
void LEDStripController::Initialize(char* ledstring)
|
||||
{
|
||||
LPSTR numleds = NULL;
|
||||
LPSTR source = NULL;
|
||||
LPSTR udpport_baud = NULL;
|
||||
LPSTR next = NULL;
|
||||
|
||||
//Assume serial device unless a different protocol is specified
|
||||
bool serial = TRUE;
|
||||
|
||||
source = strtok_s(ledstring, ",", &next);
|
||||
|
||||
//Check if we are setting up a Keyboard Visualizer UDP protocol device
|
||||
if (strncmp(source, "udp:", 4) == 0)
|
||||
{
|
||||
source = source + 4;
|
||||
serial = FALSE;
|
||||
}
|
||||
|
||||
//Check for either the UDP port or the serial baud rate
|
||||
if (strlen(next))
|
||||
{
|
||||
udpport_baud = strtok_s(next, ",", &next);
|
||||
}
|
||||
|
||||
//Check for the number of LEDs
|
||||
if (strlen(next))
|
||||
{
|
||||
numleds = strtok_s(next, ",", &next);
|
||||
}
|
||||
|
||||
if (serial)
|
||||
{
|
||||
if (udpport_baud == NULL)
|
||||
{
|
||||
//Initialize with default baud rate
|
||||
InitializeSerial(source, 115200);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Initialize with custom baud rate
|
||||
InitializeSerial(source, atoi(udpport_baud));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (udpport_baud == NULL)
|
||||
{
|
||||
//Do something
|
||||
}
|
||||
else
|
||||
{
|
||||
//Initialize UDP port
|
||||
InitializeUDP(source, udpport_baud);
|
||||
}
|
||||
}
|
||||
|
||||
if (numleds != NULL && strlen(numleds))
|
||||
{
|
||||
num_leds = atoi(numleds);
|
||||
}
|
||||
}
|
||||
|
||||
void LEDStripController::InitializeSerial(char* portname, int baud)
|
||||
{
|
||||
portname = strtok(portname, "\r");
|
||||
strcpy(port_name, portname);
|
||||
baud_rate = baud;
|
||||
serialport = new serial_port(port_name, baud_rate);
|
||||
udpport = NULL;
|
||||
}
|
||||
|
||||
void LEDStripController::InitializeUDP(char * clientname, char * port)
|
||||
{
|
||||
strcpy(client_name, clientname);
|
||||
strcpy(port_name, port);
|
||||
|
||||
udpport = new net_port(client_name, port_name);
|
||||
serialport = NULL;
|
||||
}
|
||||
|
||||
char* LEDStripController::GetLEDString()
|
||||
{
|
||||
return(led_string);
|
||||
}
|
||||
|
||||
void LEDStripController::SetLEDs(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char *serial_buf;
|
||||
|
||||
serial_buf = new unsigned char[(num_leds * 3) + 3];
|
||||
|
||||
serial_buf[0] = 0xAA;
|
||||
|
||||
for (int idx = 0; idx < (num_leds * 3); idx += 3)
|
||||
{
|
||||
int pixel_idx = idx / 3;
|
||||
RGBColor color = colors[pixel_idx];
|
||||
serial_buf[idx + 1] = RGBGetRValue(color);
|
||||
serial_buf[idx + 2] = RGBGetGValue(color);
|
||||
serial_buf[idx + 3] = RGBGetBValue(color);
|
||||
}
|
||||
|
||||
unsigned short sum = 0;
|
||||
|
||||
for (int i = 0; i < (num_leds * 3) + 1; i++)
|
||||
{
|
||||
sum += serial_buf[i];
|
||||
}
|
||||
|
||||
serial_buf[(num_leds * 3) + 1] = sum >> 8;
|
||||
serial_buf[(num_leds * 3) + 2] = sum & 0x00FF;
|
||||
|
||||
if (serialport != NULL)
|
||||
{
|
||||
serialport->serial_write((char *)serial_buf, (num_leds * 3) + 3);
|
||||
serialport->serial_flush_tx();
|
||||
}
|
||||
else if (udpport != NULL)
|
||||
{
|
||||
udpport->udp_write((char *)serial_buf, (num_leds * 3) + 3);
|
||||
}
|
||||
|
||||
delete[] serial_buf;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Definitions for Generic LED Strip Interface |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 12/11/2016 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#ifndef LED_STRIP_H
|
||||
#define LED_STRIP_H
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "serial_port.h"
|
||||
#include "net_port.h"
|
||||
#include <vector>
|
||||
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE true
|
||||
#define FALSE false
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#define LPSTR char *
|
||||
#define strtok_s strtok_r
|
||||
#endif
|
||||
|
||||
class LEDStripController
|
||||
{
|
||||
public:
|
||||
LEDStripController();
|
||||
~LEDStripController();
|
||||
|
||||
void Initialize(char* ledstring);
|
||||
void InitializeSerial(char* portname, int baud);
|
||||
void InitializeUDP(char* clientname, char* port);
|
||||
char* GetLEDString();
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
|
||||
int num_leds;
|
||||
|
||||
private:
|
||||
int baud_rate;
|
||||
|
||||
char led_string[1024];
|
||||
char port_name[128];
|
||||
char client_name[1024];
|
||||
serial_port *serialport;
|
||||
net_port *udpport;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,88 @@
|
||||
#include "LEDStripController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_LEDStrip.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectLEDStripControllers *
|
||||
* *
|
||||
* Detect devices supported by the LEDStrip driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
LEDStripController* new_ledstrip;
|
||||
RGBController_LEDStrip* new_controller;
|
||||
|
||||
//Get file path in executable directory
|
||||
std::ifstream infile;
|
||||
char filename[2048];
|
||||
char arg1[64];
|
||||
|
||||
#ifdef WIN32
|
||||
GetModuleFileName(NULL, filename, 2048);
|
||||
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
|
||||
strcat(filename, "\\ledstrip.txt");
|
||||
#else
|
||||
snprintf(arg1, 64, "/proc/%d/exe", getpid());
|
||||
readlink(arg1, filename, 1024);
|
||||
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
|
||||
strcat(filename, "/ledstrip.txt");
|
||||
#endif
|
||||
|
||||
//Open settings file
|
||||
infile.open(filename);
|
||||
|
||||
if (infile.good())
|
||||
{
|
||||
for (std::string line; std::getline(infile, line); )
|
||||
{
|
||||
if (line == "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ((line[0] != ';') && (line[0] != '#') && (line[0] != '/'))
|
||||
{
|
||||
char * argument;
|
||||
char * value;
|
||||
|
||||
value = (char *)line.c_str();
|
||||
|
||||
argument = strtok_s(value, "=", &value);
|
||||
|
||||
//Strip off new line characters if present
|
||||
argument = strtok(argument, "\r\n");
|
||||
value = strtok(value, "\r\n");
|
||||
|
||||
if(argument)
|
||||
{
|
||||
if (strcmp(argument, "ledstrip") == 0)
|
||||
{
|
||||
new_ledstrip = new LEDStripController();
|
||||
new_ledstrip->Initialize(value);
|
||||
|
||||
new_controller = new RGBController_LEDStrip(new_ledstrip);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} /* DetectLEDStripControllers() */
|
||||
@@ -0,0 +1,110 @@
|
||||
/*-----------------------------------------*\
|
||||
| PolychromeController.cpp |
|
||||
| |
|
||||
| Driver for for ASRock ASR LED and |
|
||||
| Polychrome RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/14/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "PolychromeController.h"
|
||||
#include <cstring>
|
||||
|
||||
PolychromeController::PolychromeController(i2c_smbus_interface* bus, polychrome_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
switch (GetFirmwareVersion())
|
||||
{
|
||||
case FIRMWARE_VER_1_PT_10:
|
||||
led_count = 1;
|
||||
asr_led = true;
|
||||
strcpy(device_name, "ASRock ASR LED FW 1.10");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_2_PT_00:
|
||||
led_count = 1;
|
||||
asr_led = false;
|
||||
strcpy(device_name, "ASRock Polychrome FW 2.00");
|
||||
break;
|
||||
|
||||
case FIRMWARE_VER_3_PT_00:
|
||||
led_count = 1;
|
||||
asr_led = false;
|
||||
strcpy(device_name, "ASRock Polychrome FW 3.00");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PolychromeController::~PolychromeController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* PolychromeController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
unsigned short PolychromeController::GetFirmwareVersion()
|
||||
{
|
||||
// The firmware register holds two bytes, so the first read should return 2
|
||||
// If not, report invalid firmware revision FFFF
|
||||
if (bus->i2c_smbus_read_byte_data(dev, POLYCHROME_REG_FIRMWARE_VER) == 0x02)
|
||||
{
|
||||
unsigned char major = bus->i2c_smbus_read_byte(dev);
|
||||
unsigned char minor = bus->i2c_smbus_read_byte(dev);
|
||||
|
||||
return((major << 8) | minor);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int PolychromeController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
void PolychromeController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
if (asr_led)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char colors[3] = { red, green, blue };
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_COLOR, 3, colors);
|
||||
}
|
||||
}
|
||||
|
||||
void PolychromeController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
if (asr_led)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char colors[3] = { red, green, blue };
|
||||
|
||||
bus->i2c_smbus_write_block_data(dev, POLYCHROME_REG_COLOR, 3, colors);
|
||||
}
|
||||
}
|
||||
|
||||
void PolychromeController::SetMode(unsigned char mode)
|
||||
{
|
||||
if (asr_led)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, POLYCHROME_REG_MODE, mode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/*-----------------------------------------*\
|
||||
| PolychromeController.h |
|
||||
| |
|
||||
| Definitions and types for ASRock |
|
||||
| ASR LED and Polychrome RGB lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/13/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char polychrome_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
FIRMWARE_VER_1_PT_10 = 0x010A, /* Firmware nu51_1.10 */
|
||||
FIRMWARE_VER_2_PT_00 = 0x0200, /* Firmware nu51_2.00 */
|
||||
FIRMWARE_VER_3_PT_00 = 0x0300, /* Firmware nu51_3.00 */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
ASRLED_REG_FIRMWARE_VER = 0x00, /* Firmware version Major.Minor */
|
||||
ASRLED_REG_MODE = 0x30, /* Mode selection register */
|
||||
};
|
||||
|
||||
#define ASRLED_NUM_MODES 8 /* Number of ASR LED modes */
|
||||
|
||||
enum
|
||||
{
|
||||
ASRLED_MODE_OFF = 0x10, /* OFF mode */
|
||||
ASRLED_MODE_STATIC = 0x11, /* Static color mode */
|
||||
ASRLED_MODE_BREATHING = 0x12, /* Breathing effect mode */
|
||||
ASRLED_MODE_FLASHING = 0x13, /* Flashing effect mode */
|
||||
ASRLED_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
|
||||
ASRLED_MODE_RANDOM = 0x15, /* Random effect mode */
|
||||
ASRLED_MODE_MUSIC = 0x17, /* Music effect mode */
|
||||
ASRLED_MODE_WAVE = 0x18, /* Wave effect mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_REG_FIRMWARE_VER = 0x00, /* Firmware version Major.Minor */
|
||||
POLYCHROME_REG_MODE = 0x30, /* Mode selection register */
|
||||
POLYCHROME_REG_COLOR = 0x34, /* Color register: Red, Green, Blue */
|
||||
};
|
||||
|
||||
#define POLYCHROME_NUM_MODES 14 /* Number of Polychrome modes */
|
||||
|
||||
enum
|
||||
{
|
||||
POLYCHROME_MODE_OFF = 0x10, /* OFF mode */
|
||||
POLYCHROME_MODE_STATIC = 0x11, /* Static color mode */
|
||||
POLYCHROME_MODE_BREATHING = 0x12, /* Breating effect mode */
|
||||
POLYCHROME_MODE_FLASHING = 0x13, /* Flashing effect mode */
|
||||
POLYCHROME_MODE_SPECTRUM_CYCLE = 0x14, /* Spectrum Cycle effect mode */
|
||||
POLYCHROME_MODE_RANDOM = 0x15, /* Random effect mode */
|
||||
POLYCHROME_MODE_WAVE = 0x17, /* Wave effect mode */
|
||||
POLYCHROME_MODE_SPRING = 0x18, /* Spring effect mode */
|
||||
POLYCHROME_MODE_STACK = 0x19, /* Stack effect mode */
|
||||
POLYCHROME_MODE_CRAM = 0x1A, /* Cram effect mode */
|
||||
POLYCHROME_MODE_SCAN = 0x1B, /* Scan effect mode */
|
||||
POLYCHROME_MODE_NEON = 0x1C, /* Neon effect mode */
|
||||
POLYCHROME_MODE_WATER = 0x1D, /* Water effect mode */
|
||||
POLYCHROME_MODE_RAINBOW = 0x1E, /* Rainbow effect mode */
|
||||
};
|
||||
|
||||
class PolychromeController
|
||||
{
|
||||
public:
|
||||
PolychromeController(i2c_smbus_interface* bus, polychrome_dev_id dev);
|
||||
~PolychromeController();
|
||||
|
||||
char* GetDeviceName();
|
||||
unsigned int GetLEDCount();
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode);
|
||||
unsigned short GetFirmwareVersion();
|
||||
|
||||
private:
|
||||
bool asr_led;
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
i2c_smbus_interface* bus;
|
||||
polychrome_dev_id dev;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,161 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusionController.cpp |
|
||||
| |
|
||||
| Driver for Gigabyte Aorus RGB Fusion |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/10/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBFusionController.h"
|
||||
#include <cstring>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
RGBFusionController::RGBFusionController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev)
|
||||
{
|
||||
this->bus = bus;
|
||||
this->dev = dev;
|
||||
|
||||
// Set Device name
|
||||
strcpy(device_name, "Gigabyte Motherboard");
|
||||
|
||||
// Set LED count
|
||||
led_count = 2;
|
||||
}
|
||||
|
||||
RGBFusionController::~RGBFusionController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* RGBFusionController::GetDeviceName()
|
||||
{
|
||||
return(device_name);
|
||||
}
|
||||
|
||||
unsigned int RGBFusionController::GetLEDCount()
|
||||
{
|
||||
return(led_count);
|
||||
}
|
||||
|
||||
unsigned char RGBFusionController::GetMode()
|
||||
{
|
||||
switch_bank(0);
|
||||
return(get_mode_ch_0());
|
||||
}
|
||||
|
||||
void RGBFusionController::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char mode_ch_0;
|
||||
unsigned char mode_ch_1;
|
||||
|
||||
switch_bank(1);
|
||||
set_color_ch_0(red, green, blue);
|
||||
set_color_ch_1(red, green, blue);
|
||||
|
||||
switch_bank(0);
|
||||
mode_ch_0 = get_mode_ch_0();
|
||||
mode_ch_1 = get_mode_ch_1();
|
||||
set_mode_ch_0(mode_ch_0);
|
||||
set_mode_ch_1(mode_ch_1);
|
||||
|
||||
}
|
||||
|
||||
void RGBFusionController::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
unsigned char mode;
|
||||
|
||||
switch (led)
|
||||
{
|
||||
case 0:
|
||||
switch_bank(1);
|
||||
set_color_ch_0(red, green, blue);
|
||||
|
||||
switch_bank(0);
|
||||
mode = get_mode_ch_0();
|
||||
set_mode_ch_0(mode);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
switch_bank(1);
|
||||
set_color_ch_1(red, green, blue);
|
||||
|
||||
switch_bank(0);
|
||||
mode = get_mode_ch_1();
|
||||
set_mode_ch_1(mode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBFusionController::SetMode(unsigned char mode)
|
||||
{
|
||||
switch_bank(0);
|
||||
set_mode_ch_0(mode);
|
||||
set_mode_ch_1(mode);
|
||||
}
|
||||
|
||||
void RGBFusionController::dump()
|
||||
{
|
||||
int i, j;
|
||||
|
||||
int start = 0x00;
|
||||
|
||||
FILE* file = freopen("rgb_fusion_dump.txt", "a", stdout);
|
||||
|
||||
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
|
||||
|
||||
for (i = 0; i < 0xFF; i += 16)
|
||||
{
|
||||
printf("%04x: ", i + start);
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
printf("%02x ", bus->i2c_smbus_read_byte_data(dev, (start + i + j)));
|
||||
}
|
||||
|
||||
printf("\r\n");
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
unsigned char RGBFusionController::get_mode_ch_0()
|
||||
{
|
||||
s32 temp = bus->i2c_smbus_read_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_0_MODE);
|
||||
return(temp);
|
||||
}
|
||||
|
||||
unsigned char RGBFusionController::get_mode_ch_1()
|
||||
{
|
||||
return(bus->i2c_smbus_read_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_1_MODE));
|
||||
}
|
||||
|
||||
void RGBFusionController::set_color_ch_0(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_R, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_G, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_0_B, blue);
|
||||
}
|
||||
|
||||
void RGBFusionController::set_color_ch_1(unsigned char red, unsigned char green, unsigned char blue)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_R, red);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_G, green);
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_0_REG_CH_1_B, blue);
|
||||
}
|
||||
|
||||
void RGBFusionController::set_mode_ch_0(unsigned char mode)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_0_MODE, mode + RGB_FUSION_WRITE_MODE_OFST);
|
||||
}
|
||||
|
||||
void RGBFusionController::set_mode_ch_1(unsigned char mode)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_1_REG_CH_1_MODE, mode + RGB_FUSION_WRITE_MODE_OFST);
|
||||
}
|
||||
|
||||
void RGBFusionController::switch_bank(unsigned char bank)
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, RGB_FUSION_BANK_SWITCH_REG, bank);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBFusionController.h |
|
||||
| |
|
||||
| Definitions and types for Gigabyte Aorus |
|
||||
| RGB Fusion lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/10/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char rgb_fusion_dev_id;
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_BANK_0_REG_CH_0_R = 0x00, /* Channel 0 Red Value */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_G = 0x01, /* Channel 0 Green Value */
|
||||
RGB_FUSION_BANK_0_REG_CH_0_B = 0x02, /* Channel 0 Blue Value */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_R = 0x08, /* Channel 1 Red Value */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_G = 0x09, /* Channel 1 Green Value */
|
||||
RGB_FUSION_BANK_0_REG_CH_1_B = 0x0A, /* Channel 1 Blue Value */
|
||||
RGB_FUSION_BANK_1_REG_CH_0_MODE = 0x03, /* Channel 0 Mode Selection */
|
||||
RGB_FUSION_BANK_1_REG_CH_1_MODE = 0x13, /* Channel 1 Mode Selection */
|
||||
RGB_FUSION_BANK_SWITCH_REG = 0xF0, /* Bank Switch Register */
|
||||
};
|
||||
|
||||
#define RGB_FUSION_NUMBER_MODES 3 /* Number of RGB Fusion modes */
|
||||
#define RGB_FUSION_WRITE_MODE_OFST 0x10 /* offset to add when writing mode */
|
||||
|
||||
enum
|
||||
{
|
||||
RGB_FUSION_MODE_STATIC = 0x00, /* Static color mode */
|
||||
RGB_FUSION_MODE_BREATHING = 0x01, /* Breathing effect mode */
|
||||
RGB_FUSION_MODE_FLASHING = 0x02, /* Flashing effect mode */
|
||||
};
|
||||
|
||||
class RGBFusionController
|
||||
{
|
||||
public:
|
||||
RGBFusionController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev);
|
||||
~RGBFusionController();
|
||||
|
||||
char* GetDeviceName();
|
||||
unsigned int GetLEDCount();
|
||||
unsigned char GetMode();
|
||||
void SetAllColors(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue);
|
||||
void SetMode(unsigned char mode);
|
||||
|
||||
private:
|
||||
void dump();
|
||||
|
||||
unsigned char get_mode_ch_0();
|
||||
unsigned char get_mode_ch_1();
|
||||
|
||||
void set_color_ch_0(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void set_color_ch_1(unsigned char red, unsigned char green, unsigned char blue);
|
||||
void set_mode_ch_0(unsigned char mode);
|
||||
void set_mode_ch_1(unsigned char mode);
|
||||
void switch_bank(unsigned char bank);
|
||||
|
||||
char device_name[32];
|
||||
unsigned int led_count;
|
||||
i2c_smbus_interface* bus;
|
||||
rgb_fusion_dev_id dev;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
#include "RGBFusionController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_RGBFusion.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* TestForRGBFusionController *
|
||||
* *
|
||||
* Tests the given address to see if an RGB Fusion controller exists there. First *
|
||||
* does a quick write to test for a response *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
bool TestForRGBFusionController(i2c_smbus_interface* bus, unsigned char address)
|
||||
{
|
||||
bool pass = false;
|
||||
|
||||
int res = bus->i2c_smbus_write_quick(address, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
pass = true;
|
||||
}
|
||||
|
||||
return(pass);
|
||||
|
||||
} /* TestForRGBFusionController() */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectRGBFusionControllers *
|
||||
* *
|
||||
* Detect RGB Fusion controllers on the enumerated I2C busses at address 0x28. *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where RGB Fusion device is connected *
|
||||
* dev - I2C address of RGB Fusion device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
RGBFusionController* new_rgb_fusion;
|
||||
RGBController_RGBFusion* new_controller;
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Check for RGB Fusion controller at 0x28
|
||||
if (TestForRGBFusionController(busses[bus], 0x28))
|
||||
{
|
||||
new_rgb_fusion = new RGBFusionController(busses[bus], 0x28);
|
||||
new_controller = new RGBController_RGBFusion(new_rgb_fusion);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectRGBFusionControllers() */
|
||||
@@ -7,6 +7,8 @@
|
||||
\******************************************************************************************/
|
||||
|
||||
#include "AuraController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AorusGPU.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
@@ -14,24 +16,145 @@
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <regex>
|
||||
#include "i2c_smbus_piix4.h"
|
||||
#include "i2c_smbus_i801.h"
|
||||
#include "i2c_smbus_nct6775.h"
|
||||
#include "wmi.h"
|
||||
#include "inpout32.h"
|
||||
|
||||
#pragma comment(lib, "inpout32.lib")
|
||||
#else /* WIN32 */
|
||||
|
||||
#include "i2c_smbus_linux.h"
|
||||
#include <regex>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
std::vector<AuraController *> controllers;
|
||||
std::vector<i2c_smbus_interface *> busses;
|
||||
std::vector<i2c_smbus_interface*> busses;
|
||||
std::vector<RGBController*> rgb_controllers;
|
||||
|
||||
#ifdef WIN32
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* Nuvoton Super IO constants *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#define SIO_NCT5577_ID 0xC330 /* Device ID for NCT5577D (C333) */
|
||||
#define SIO_NCT6102_ID 0x1060 /* Device ID for NCT6102D/6106D (1061) */
|
||||
#define SIO_NCT6793_ID 0xd120 /* Device ID for NCT6793D (D121) */
|
||||
#define SIO_NCT6796_ID 0xd420 /* Device ID for NCT6796D (D421) */
|
||||
#define SIO_REG_LOGDEV 0x07 /* Logical Device Register */
|
||||
#define SIO_REG_DEVID 0x20 /* Device ID Register */
|
||||
#define SIO_REG_SMBA 0x62 /* SMBus Base Address Register */
|
||||
#define SIO_LOGDEV_SMBUS 0x0B /* Logical Device for SMBus */
|
||||
#define SIO_ID_MASK 0xFFF8 /* Device ID mask */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_enter *
|
||||
* *
|
||||
* Put the Super IO chip into Extended Function Mode *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void superio_enter(int ioreg)
|
||||
{
|
||||
Out32(ioreg, 0x87);
|
||||
Out32(ioreg, 0x87);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_outb *
|
||||
* *
|
||||
* Write a byte to the Super IO configuration register *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void superio_outb(int ioreg, int reg, int val)
|
||||
{
|
||||
Out32(ioreg, reg);
|
||||
Out32(ioreg + 1, val);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* superio_inb *
|
||||
* *
|
||||
* Read a byte to the Super IO configuration register *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
int superio_inb(int ioreg, int reg)
|
||||
{
|
||||
Out32(ioreg, reg);
|
||||
return Inp32(ioreg + 1);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectNuvotonI2CBusses (Windows) *
|
||||
* *
|
||||
* Detects available Nuvoton Super IO SMBUS adapters and enumerates *
|
||||
* i2c_smbus_interface objects for them *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectNuvotonI2CBusses()
|
||||
{
|
||||
i2c_smbus_interface* bus;
|
||||
int sioaddr = 0x2E;
|
||||
superio_enter(sioaddr);
|
||||
|
||||
int val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8) | superio_inb(sioaddr, SIO_REG_DEVID + 1);
|
||||
|
||||
switch (val & SIO_ID_MASK)
|
||||
{
|
||||
case SIO_NCT5577_ID:
|
||||
case SIO_NCT6102_ID:
|
||||
case SIO_NCT6793_ID:
|
||||
case SIO_NCT6796_ID:
|
||||
bus = new i2c_smbus_nct6775();
|
||||
|
||||
// Set logical device register to get SMBus base address
|
||||
superio_outb(sioaddr, SIO_REG_LOGDEV, SIO_LOGDEV_SMBUS);
|
||||
|
||||
// Get SMBus base address from configuration register
|
||||
int smba = (superio_inb(sioaddr, SIO_REG_SMBA) << 8) | superio_inb(sioaddr, SIO_REG_SMBA + 1);
|
||||
((i2c_smbus_nct6775*)bus)->nct6775_smba = smba;
|
||||
|
||||
// Set device name string
|
||||
switch (val & SIO_ID_MASK)
|
||||
{
|
||||
case SIO_NCT5577_ID:
|
||||
sprintf(bus->device_name, "Nuvoton NCT5577D SMBus at %X", smba);
|
||||
break;
|
||||
case SIO_NCT6102_ID:
|
||||
sprintf(bus->device_name, "Nuvoton NCT6102D/NCT6106D SMBus at %X", smba);
|
||||
break;
|
||||
case SIO_NCT6793_ID:
|
||||
sprintf(bus->device_name, "Nuvoton NCT6793D SMBus at %X", smba);
|
||||
break;
|
||||
case SIO_NCT6796_ID:
|
||||
sprintf(bus->device_name, "Nuvoton NCT6796D SMBus at %X", smba);
|
||||
break;
|
||||
}
|
||||
|
||||
busses.push_back(bus);
|
||||
}
|
||||
|
||||
} /* DetectNuvotonI2CBusses() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectI2CBusses (Windows) *
|
||||
@@ -67,11 +190,15 @@ void DetectI2CBusses()
|
||||
if (i["Manufacturer"].find("Advanced Micro Devices, Inc") != std::string::npos)
|
||||
{
|
||||
bus = new i2c_smbus_piix4();
|
||||
strcpy(bus->device_name, i["Description"].c_str());
|
||||
strcat(bus->device_name, " at 0x0B00");
|
||||
((i2c_smbus_piix4 *)bus)->piix4_smba = 0x0B00;
|
||||
busses.push_back(bus);
|
||||
|
||||
bus = new i2c_smbus_piix4();
|
||||
((i2c_smbus_piix4 *)bus)->piix4_smba = 0x0B20;
|
||||
strcpy(bus->device_name, i["Description"].c_str());
|
||||
strcat(bus->device_name, " at 0x0B20");
|
||||
busses.push_back(bus);
|
||||
}
|
||||
|
||||
@@ -79,7 +206,8 @@ void DetectI2CBusses()
|
||||
// Analysis of many Intel boards has shown that Intel SMBus adapter I/O space varies between boards
|
||||
// We can query Win32_PnPAllocatedResource entries and look up the PCI device ID to find the allocated I/O space
|
||||
// Intel SMBus adapters use the i801 driver
|
||||
else if (i["Manufacturer"].find("Intel") != std::string::npos)
|
||||
else if ((i["Manufacturer"].find("Intel") != std::string::npos)
|
||||
|| (i["Manufacturer"].find("INTEL") != std::string::npos))
|
||||
{
|
||||
std::string rgx1 = ".+" + q_res_PnPSignedDriver[0]["DeviceID"].substr(4, 33) + ".+";
|
||||
|
||||
@@ -99,12 +227,16 @@ void DetectI2CBusses()
|
||||
unsigned int IORangeStart = std::stoi(matches[1].str());
|
||||
|
||||
bus = new i2c_smbus_i801();
|
||||
strcpy(bus->device_name, i["Description"].c_str());
|
||||
((i2c_smbus_i801 *)bus)->i801_smba = IORangeStart;
|
||||
busses.push_back(bus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Detect Nuvoton Super IO SMBus adapters
|
||||
DetectNuvotonI2CBusses();
|
||||
|
||||
} /* DetectI2CBusses() */
|
||||
|
||||
#else /* WIN32 */
|
||||
@@ -127,8 +259,8 @@ void DetectI2CBusses()
|
||||
struct dirent * ent;
|
||||
int test_fd;
|
||||
|
||||
// Start looking for I2C adapters in /sys/class/i2c-adapter/
|
||||
strcpy(driver_path, "/sys/class/i2c-adapter/");
|
||||
// Start looking for I2C adapters in /sys/bus/i2c/devices/
|
||||
strcpy(driver_path, "/sys/bus/i2c/devices/");
|
||||
dir = opendir(driver_path);
|
||||
|
||||
if(dir == NULL)
|
||||
@@ -187,30 +319,6 @@ void DetectI2CBusses()
|
||||
|
||||
#endif /* WIN32 */
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* CreateAuraDevice *
|
||||
* *
|
||||
* Enumerates an ASUS Aura compatibler I2C device with the given address on the given *
|
||||
* bus *
|
||||
* *
|
||||
* bus - pointer to i2c_smbus_interface where Aura device is connected *
|
||||
* dev - I2C address of Aura device *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
AuraController * CreateAuraDevice(i2c_smbus_interface * bus, aura_dev_id dev)
|
||||
{
|
||||
AuraController * aura;
|
||||
|
||||
aura = new AuraController();
|
||||
aura->bus = bus;
|
||||
aura->dev = dev;
|
||||
|
||||
return(aura);
|
||||
|
||||
} /* CreateAuraDevice() */
|
||||
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -230,19 +338,21 @@ AuraController * CreateAuraDevice(i2c_smbus_interface * bus, aura_dev_id dev)
|
||||
#define MODE_READ 2
|
||||
#define MODE_FUNC 3
|
||||
|
||||
void DetectI2C(i2c_smbus_interface * bus, int mode)
|
||||
std::string DetectI2C(i2c_smbus_interface * bus, int mode)
|
||||
{
|
||||
int i, j;
|
||||
int res;
|
||||
int slave_addr;
|
||||
char line[128];
|
||||
std::string text;
|
||||
|
||||
freopen("i2cdetect.txt", "a", stdout);
|
||||
|
||||
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
|
||||
sprintf(line, " 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
|
||||
text.append(line);
|
||||
|
||||
for (i = 0; i < 128; i += 16)
|
||||
{
|
||||
printf("%02x: ", i);
|
||||
sprintf(line, "%02x: ", i);
|
||||
text.append(line);
|
||||
|
||||
for (j = 0; j < 16; j++)
|
||||
{
|
||||
@@ -269,16 +379,21 @@ void DetectI2C(i2c_smbus_interface * bus, int mode)
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
printf("-- ");
|
||||
sprintf(line, "-- ");
|
||||
text.append(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%02x ", i + j);
|
||||
sprintf(line, "%02x ", i + j);
|
||||
text.append(line);
|
||||
}
|
||||
}
|
||||
printf("\r\n");
|
||||
sprintf(line, "\r\n");
|
||||
text.append(line);
|
||||
}
|
||||
|
||||
return text;
|
||||
|
||||
} /* DetectI2C() */
|
||||
|
||||
|
||||
@@ -294,13 +409,13 @@ void DumpAuraRegisters(AuraController * controller)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
int start = 0x8000;
|
||||
int start = 0x0000;
|
||||
|
||||
freopen("auradump.txt", "a", stdout);
|
||||
FILE* file = freopen("auradump.txt", "a", stdout);
|
||||
|
||||
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
|
||||
|
||||
for (i = 0; i < 512; i += 16)
|
||||
for (i = 0; i < 0xFFFF; i += 16)
|
||||
{
|
||||
printf("%04x: ", i + start);
|
||||
|
||||
@@ -312,87 +427,52 @@ void DumpAuraRegisters(AuraController * controller)
|
||||
printf("\r\n");
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
} /* DumpAuraRegisters() */
|
||||
|
||||
void DetectAuraControllers(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 DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers);
|
||||
void DetectRazerChromaSDKControllers(std::vector<RGBController*>& rgb_controllers);
|
||||
void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers);
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* main/WinMain *
|
||||
* DetectRGBConrollers *
|
||||
* *
|
||||
* Main function. Has no defined purpose yet, but is where you can call the other *
|
||||
* functions in this project to test them out *
|
||||
* *
|
||||
* Currently, this program will enumerate all detected SMBus adapters and then detect *
|
||||
* all attached devices, similar to i2cdetect on Linux *
|
||||
* Detect and populate RGB Controllers vector *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#ifdef WIN32
|
||||
INT WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, INT nCmdShow)
|
||||
#else /* WIN32 */
|
||||
int main()
|
||||
#endif /* WIN32 */
|
||||
void DetectRGBControllers(void)
|
||||
{
|
||||
// Colors Array R B G
|
||||
unsigned char colors[15] = { 255, 0, 0,
|
||||
0, 255, 0,
|
||||
0, 0, 255,
|
||||
255, 0, 255,
|
||||
0, 255, 255 };
|
||||
DetectI2CBusses();
|
||||
|
||||
for (unsigned int bus = 0; bus < busses.size(); bus++)
|
||||
{
|
||||
// Remap Aura-enabled RAM modules on 0x77
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
{
|
||||
int res = busses[bus]->i2c_smbus_write_quick(0x77, I2C_SMBUS_WRITE);
|
||||
DetectAuraControllers(busses, rgb_controllers);
|
||||
DetectCorsairControllers(busses, rgb_controllers);
|
||||
DetectCorsairProControllers(busses, rgb_controllers);
|
||||
DetectHyperXControllers(busses, rgb_controllers);
|
||||
DetectRGBFusionControllers(busses, rgb_controllers);
|
||||
|
||||
if (res < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
DetectLEDStripControllers(rgb_controllers);
|
||||
|
||||
#ifdef WIN32
|
||||
DetectRazerChromaSDKControllers(rgb_controllers);
|
||||
#else
|
||||
DetectE131Controllers(rgb_controllers);
|
||||
DetectOpenRazerControllers(rgb_controllers);
|
||||
#endif
|
||||
|
||||
AuraController * temp_controller = CreateAuraDevice(busses[bus], 0x77);
|
||||
//This is for testing Aorus GPU
|
||||
#if 0
|
||||
RGBController_AorusGPU * aorus_rgb = new RGBController_AorusGPU();
|
||||
|
||||
temp_controller->AuraRegisterWrite(AURA_REG_SLOT_INDEX, slot);
|
||||
temp_controller->AuraRegisterWrite(AURA_REG_I2C_ADDRESS, 0xE0 + ( slot << 1 ) );
|
||||
rgb_controllers.push_back(aorus_rgb);
|
||||
#endif
|
||||
|
||||
delete temp_controller;
|
||||
}
|
||||
|
||||
// Add Aura-enabled controllers at their remapped addresses
|
||||
for (unsigned int slot = 0; slot < 8; slot++)
|
||||
{
|
||||
int res = busses[bus]->i2c_smbus_write_quick(0x70 + slot, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
AuraController * new_controller = CreateAuraDevice(busses[bus], 0x70 + slot);
|
||||
controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for Aura controller at 0x4E
|
||||
int res = busses[bus]->i2c_smbus_write_quick(0x4E, I2C_SMBUS_WRITE);
|
||||
|
||||
if (res >= 0)
|
||||
{
|
||||
AuraController * new_controller = CreateAuraDevice(busses[bus], 0x4E);
|
||||
controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < controllers.size(); i++)
|
||||
{
|
||||
controllers[i]->AuraRegisterWrite(AURA_REG_DIRECT, 1);
|
||||
controllers[i]->AuraRegisterWrite(AURA_REG_APPLY, AURA_APPLY_VAL);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < controllers.size(); i++)
|
||||
{
|
||||
controllers[i]->AuraRegisterWriteBlock(AURA_REG_COLORS_DIRECT, colors, 15);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <string>
|
||||
#include "AuraController.h"
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#define MODE_AUTO 0
|
||||
#define MODE_QUICK 1
|
||||
#define MODE_READ 2
|
||||
#define MODE_FUNC 3
|
||||
|
||||
std::string DetectI2C(i2c_smbus_interface * bus, int mode);
|
||||
void DumpAuraRegisters(AuraController * controller);
|
||||
void DetectRGBControllers();
|
||||
@@ -0,0 +1,685 @@
|
||||
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig
|
||||
index 09367fc014c3..25c0e02b3344 100644
|
||||
--- a/drivers/i2c/busses/Kconfig
|
||||
+++ b/drivers/i2c/busses/Kconfig
|
||||
@@ -216,6 +216,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.
|
||||
|
||||
+config I2C_NCT6775
|
||||
+ tristate "Nuvoton NCT6775 and compatible SMBus controller"
|
||||
+ help
|
||||
+ If you say yes to this option, support will be included for the
|
||||
+ Nuvoton NCT6775 and compatible SMBus controllers.
|
||||
+
|
||||
+ This driver can also be built as a module. If so, the module
|
||||
+ will be called i2c-nct6775.
|
||||
+
|
||||
config I2C_NFORCE2
|
||||
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
|
||||
--- a/drivers/i2c/busses/Makefile
|
||||
+++ b/drivers/i2c/busses/Makefile
|
||||
@@ -17,6 +17,7 @@ obj-$(CONFIG_I2C_CHT_WC) += i2c-cht-wc.o
|
||||
obj-$(CONFIG_I2C_I801) += i2c-i801.o
|
||||
obj-$(CONFIG_I2C_ISCH) += i2c-isch.o
|
||||
obj-$(CONFIG_I2C_ISMT) += i2c-ismt.o
|
||||
+obj-$(CONFIG_I2C_NCT6775) += i2c-nct6775.o
|
||||
obj-$(CONFIG_I2C_NFORCE2) += i2c-nforce2.o
|
||||
obj-$(CONFIG_I2C_NFORCE2_S4985) += i2c-nforce2-s4985.o
|
||||
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
|
||||
--- /dev/null
|
||||
+++ b/drivers/i2c/busses/i2c-nct6775.c
|
||||
@@ -0,0 +1,617 @@
|
||||
+/*
|
||||
+ * i2c-nct6775 - Driver for the SMBus master functionality of
|
||||
+ * Nuvoton NCT677x Super-I/O chips
|
||||
+ *
|
||||
+ * Copyright (C) 2019 Adam Honse <[email protected]>
|
||||
+ *
|
||||
+ * Derived from nct6775 hwmon driver
|
||||
+ * Copyright (C) 2012 Guenter Roeck <[email protected]>
|
||||
+ *
|
||||
+ * This program is free software; you can redistribute it and/or modify
|
||||
+ * it under the terms of the GNU General Public License as published by
|
||||
+ * the Free Software Foundation; either version 2 of the License, or
|
||||
+ * (at your option) any later version.
|
||||
+ *
|
||||
+ * This program is distributed in the hope that it will be useful,
|
||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
+ * GNU General Public License for more details.
|
||||
+ *
|
||||
+ * You should have received a copy of the GNU General Public License
|
||||
+ * along with this program; if not, write to the Free Software
|
||||
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#include <linux/module.h>
|
||||
+#include <linux/init.h>
|
||||
+#include <linux/slab.h>
|
||||
+#include <linux/jiffies.h>
|
||||
+#include <linux/platform_device.h>
|
||||
+#include <linux/hwmon.h>
|
||||
+#include <linux/hwmon-sysfs.h>
|
||||
+#include <linux/hwmon-vid.h>
|
||||
+#include <linux/err.h>
|
||||
+#include <linux/mutex.h>
|
||||
+#include <linux/ioport.h>
|
||||
+#include <linux/i2c.h>
|
||||
+#include <linux/acpi.h>
|
||||
+#include <linux/bitops.h>
|
||||
+#include <linux/dmi.h>
|
||||
+#include <linux/io.h>
|
||||
+#include <linux/nospec.h>
|
||||
+
|
||||
+#define DRVNAME "i2c-nct6775"
|
||||
+
|
||||
+/* Nuvoton SMBus address offsets */
|
||||
+#define SMBHSTDAT (0 + nuvoton_nct6793d_smba)
|
||||
+#define SMBBLKSZ (1 + nuvoton_nct6793d_smba)
|
||||
+#define SMBHSTCMD (2 + nuvoton_nct6793d_smba)
|
||||
+#define SMBHSTIDX (3 + nuvoton_nct6793d_smba) //Index field is the Command field on other controllers
|
||||
+#define SMBHSTCTL (4 + nuvoton_nct6793d_smba)
|
||||
+#define SMBHSTADD (5 + nuvoton_nct6793d_smba)
|
||||
+#define SMBHSTERR (9 + nuvoton_nct6793d_smba)
|
||||
+#define SMBHSTSTS (0xE + nuvoton_nct6793d_smba)
|
||||
+
|
||||
+/* Command register */
|
||||
+#define NCT6793D_READ_BYTE 0
|
||||
+#define NCT6793D_READ_WORD 1
|
||||
+#define NCT6793D_READ_BLOCK 2
|
||||
+#define NCT6793D_BLOCK_WRITE_READ_PROC_CALL 3
|
||||
+#define NCT6793D_PROC_CALL 4
|
||||
+#define NCT6793D_WRITE_BYTE 8
|
||||
+#define NCT6793D_WRITE_WORD 9
|
||||
+#define NCT6793D_WRITE_BLOCK 10
|
||||
+
|
||||
+/* Control register */
|
||||
+#define NCT6793D_MANUAL_START 128
|
||||
+#define NCT6793D_SOFT_RESET 64
|
||||
+
|
||||
+/* Error register */
|
||||
+#define NCT6793D_NO_ACK 32
|
||||
+
|
||||
+/* Status register */
|
||||
+#define NCT6793D_FIFO_EMPTY 1
|
||||
+#define NCT6793D_FIFO_FULL 2
|
||||
+#define NCT6793D_MANUAL_ACTIVE 4
|
||||
+
|
||||
+#define NCT6775_LD_SMBUS 0x0B
|
||||
+
|
||||
+enum kinds { nct6106, nct6775, nct6776, nct6779, nct6791, nct6792, nct6793,
|
||||
+ nct6795, nct6796, nct6798 };
|
||||
+
|
||||
+struct nct6775_sio_data {
|
||||
+ int sioreg;
|
||||
+ enum kinds kind;
|
||||
+};
|
||||
+
|
||||
+/* used to set data->name = nct6775_device_names[data->sio_kind] */
|
||||
+static const char * const nct6775_device_names[] = {
|
||||
+ "nct6106",
|
||||
+ "nct6775",
|
||||
+ "nct6776",
|
||||
+ "nct6779",
|
||||
+ "nct6791",
|
||||
+ "nct6792",
|
||||
+ "nct6793",
|
||||
+ "nct6795",
|
||||
+ "nct6796",
|
||||
+ "nct6798",
|
||||
+};
|
||||
+
|
||||
+static const char * const nct6775_sio_names[] __initconst = {
|
||||
+ "NCT6106D",
|
||||
+ "NCT6775F",
|
||||
+ "NCT6776D/F",
|
||||
+ "NCT6779D",
|
||||
+ "NCT6791D",
|
||||
+ "NCT6792D",
|
||||
+ "NCT6793D",
|
||||
+ "NCT6795D",
|
||||
+ "NCT6796D",
|
||||
+ "NCT6798D",
|
||||
+};
|
||||
+
|
||||
+#define SIO_REG_LDSEL 0x07 /* Logical device select */
|
||||
+#define SIO_REG_DEVID 0x20 /* Device ID (2 bytes) */
|
||||
+#define SIO_REG_SMBA 0x62 /* SMBus base address register */
|
||||
+
|
||||
+#define SIO_NCT6106_ID 0xc450
|
||||
+#define SIO_NCT6775_ID 0xb470
|
||||
+#define SIO_NCT6776_ID 0xc330
|
||||
+#define SIO_NCT6779_ID 0xc560
|
||||
+#define SIO_NCT6791_ID 0xc800
|
||||
+#define SIO_NCT6792_ID 0xc910
|
||||
+#define SIO_NCT6793_ID 0xd120
|
||||
+#define SIO_NCT6795_ID 0xd350
|
||||
+#define SIO_NCT6796_ID 0xd420
|
||||
+#define SIO_NCT6798_ID 0xd428
|
||||
+#define SIO_ID_MASK 0xFFF0
|
||||
+
|
||||
+static inline void
|
||||
+superio_outb(int ioreg, int reg, int val)
|
||||
+{
|
||||
+ outb(reg, ioreg);
|
||||
+ outb(val, ioreg + 1);
|
||||
+}
|
||||
+
|
||||
+static inline int
|
||||
+superio_inb(int ioreg, int reg)
|
||||
+{
|
||||
+ outb(reg, ioreg);
|
||||
+ return inb(ioreg + 1);
|
||||
+}
|
||||
+
|
||||
+static inline void
|
||||
+superio_select(int ioreg, int ld)
|
||||
+{
|
||||
+ outb(SIO_REG_LDSEL, ioreg);
|
||||
+ outb(ld, ioreg + 1);
|
||||
+}
|
||||
+
|
||||
+static inline int
|
||||
+superio_enter(int ioreg)
|
||||
+{
|
||||
+ /*
|
||||
+ * Try to reserve <ioreg> and <ioreg + 1> for exclusive access.
|
||||
+ */
|
||||
+ if (!request_muxed_region(ioreg, 2, DRVNAME))
|
||||
+ return -EBUSY;
|
||||
+
|
||||
+ outb(0x87, ioreg);
|
||||
+ outb(0x87, ioreg);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static inline void
|
||||
+superio_exit(int ioreg)
|
||||
+{
|
||||
+ outb(0xaa, ioreg);
|
||||
+ outb(0x02, ioreg);
|
||||
+ outb(0x02, ioreg + 1);
|
||||
+ release_region(ioreg, 2);
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
+ * ISA constants
|
||||
+ */
|
||||
+
|
||||
+#define IOREGION_ALIGNMENT (~7)
|
||||
+#define IOREGION_LENGTH 2
|
||||
+#define ADDR_REG_OFFSET 0
|
||||
+#define DATA_REG_OFFSET 1
|
||||
+
|
||||
+#define NCT6775_REG_BANK 0x4E
|
||||
+#define NCT6775_REG_CONFIG 0x40
|
||||
+
|
||||
+static struct i2c_adapter *nct6775_adapter;
|
||||
+
|
||||
+struct i2c_nct6775_adapdata {
|
||||
+ unsigned short smba;
|
||||
+};
|
||||
+
|
||||
+/* Return negative errno on error. */
|
||||
+static s32 nct6775_access(struct i2c_adapter * adap, u16 addr,
|
||||
+ unsigned short flags, char read_write,
|
||||
+ u8 command, int size, union i2c_smbus_data * data)
|
||||
+{
|
||||
+ struct i2c_nct6775_adapdata *adapdata = i2c_get_adapdata(adap);
|
||||
+ unsigned short nuvoton_nct6793d_smba = adapdata->smba;
|
||||
+ int i, len, cnt;
|
||||
+
|
||||
+ cnt = 0;
|
||||
+ len = 0;
|
||||
+
|
||||
+ outb_p(NCT6793D_SOFT_RESET, SMBHSTCTL);
|
||||
+
|
||||
+ switch (size) {
|
||||
+ case I2C_SMBUS_QUICK:
|
||||
+ outb_p((addr << 1) | read_write,
|
||||
+ SMBHSTADD);
|
||||
+ break;
|
||||
+ case I2C_SMBUS_BYTE:
|
||||
+ case I2C_SMBUS_BYTE_DATA:
|
||||
+ outb_p((addr << 1) | read_write,
|
||||
+ SMBHSTADD);
|
||||
+ outb_p(command, SMBHSTIDX);
|
||||
+ if (read_write == I2C_SMBUS_WRITE) {
|
||||
+ outb_p(data->byte, SMBHSTDAT);
|
||||
+ outb_p(NCT6793D_WRITE_BYTE, SMBHSTCMD);
|
||||
+ }
|
||||
+ else {
|
||||
+ outb_p(NCT6793D_READ_BYTE, SMBHSTCMD);
|
||||
+ }
|
||||
+ break;
|
||||
+ case I2C_SMBUS_WORD_DATA:
|
||||
+ outb_p((addr << 1) | read_write,
|
||||
+ SMBHSTADD);
|
||||
+ outb_p(command, SMBHSTIDX);
|
||||
+ 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);
|
||||
+ }
|
||||
+ else {
|
||||
+ outb_p(NCT6793D_READ_WORD, SMBHSTCMD);
|
||||
+ }
|
||||
+ break;
|
||||
+ case I2C_SMBUS_BLOCK_DATA:
|
||||
+ outb_p((addr << 1) | read_write,
|
||||
+ SMBHSTADD);
|
||||
+ outb_p(command, SMBHSTIDX);
|
||||
+ if (read_write == I2C_SMBUS_WRITE) {
|
||||
+ len = data->block[0];
|
||||
+ if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
|
||||
+ return -EINVAL;
|
||||
+ outb_p(len, SMBBLKSZ);
|
||||
+
|
||||
+ cnt = 1;
|
||||
+ if (len >= 4) {
|
||||
+ for (i = cnt; i <= 4; i++) {
|
||||
+ outb_p(data->block[i], SMBHSTDAT);
|
||||
+ }
|
||||
+
|
||||
+ len -= 4;
|
||||
+ cnt += 4;
|
||||
+ }
|
||||
+ else {
|
||||
+ for (i = cnt; i <= len; i++ ) {
|
||||
+ outb_p(data->block[i], SMBHSTDAT);
|
||||
+ }
|
||||
+
|
||||
+ len = 0;
|
||||
+ }
|
||||
+
|
||||
+ outb_p(NCT6793D_WRITE_BLOCK, SMBHSTCMD);
|
||||
+ }
|
||||
+ else {
|
||||
+ return -ENOTSUPP;
|
||||
+ }
|
||||
+ break;
|
||||
+ default:
|
||||
+ dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
|
||||
+ return -EOPNOTSUPP;
|
||||
+ }
|
||||
+
|
||||
+ outb_p(NCT6793D_MANUAL_START, SMBHSTCTL);
|
||||
+
|
||||
+ while ((size == I2C_SMBUS_BLOCK_DATA) && (len > 0)) {
|
||||
+ if (read_write == I2C_SMBUS_WRITE) {
|
||||
+ while ((inb_p(SMBHSTSTS) & NCT6793D_FIFO_EMPTY) == 0);
|
||||
+
|
||||
+ //Load more bytes into FIFO
|
||||
+ if (len >= 4) {
|
||||
+ for (i = cnt; i <= (cnt + 4); i++) {
|
||||
+ outb_p(data->block[i], SMBHSTDAT);
|
||||
+ }
|
||||
+
|
||||
+ len -= 4;
|
||||
+ cnt += 4;
|
||||
+ }
|
||||
+ else {
|
||||
+ for (i = cnt; i <= (cnt + len); i++) {
|
||||
+ outb_p(data->block[i], SMBHSTDAT);
|
||||
+ }
|
||||
+
|
||||
+ len = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ //wait for manual mode to complete
|
||||
+ while ((inb_p(SMBHSTSTS) & NCT6793D_MANUAL_ACTIVE) != 0);
|
||||
+
|
||||
+ if ((inb_p(SMBHSTERR) & NCT6793D_NO_ACK) != 0) {
|
||||
+ return -ENXIO;
|
||||
+ }
|
||||
+ else if ((read_write == I2C_SMBUS_WRITE) || (size == I2C_SMBUS_QUICK)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ switch (size) {
|
||||
+ case I2C_SMBUS_QUICK:
|
||||
+ case I2C_SMBUS_BYTE_DATA:
|
||||
+ data->byte = inb_p(SMBHSTDAT);
|
||||
+ break;
|
||||
+ case I2C_SMBUS_WORD_DATA:
|
||||
+ data->word = inb_p(SMBHSTDAT) + (inb_p(SMBHSTDAT) << 8);
|
||||
+ break;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static u32 nct6775_func(struct i2c_adapter *adapter)
|
||||
+{
|
||||
+ return I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
|
||||
+ I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
|
||||
+ I2C_FUNC_SMBUS_BLOCK_DATA;
|
||||
+}
|
||||
+
|
||||
+static const struct i2c_algorithm smbus_algorithm = {
|
||||
+ .smbus_xfer = nct6775_access,
|
||||
+ .functionality = nct6775_func,
|
||||
+};
|
||||
+
|
||||
+static int nct6775_add_adapter(unsigned short smba, const char *name, struct i2c_adapter **padap)
|
||||
+{
|
||||
+ struct i2c_adapter *adap;
|
||||
+ struct i2c_nct6775_adapdata *adapdata;
|
||||
+ int retval;
|
||||
+
|
||||
+ adap = kzalloc(sizeof(*adap), GFP_KERNEL);
|
||||
+ if (adap == NULL) {
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ adap->owner = THIS_MODULE;
|
||||
+ adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
|
||||
+ adap->algo = &smbus_algorithm;
|
||||
+
|
||||
+ adapdata = kzalloc(sizeof(*adapdata), GFP_KERNEL);
|
||||
+ if (adapdata == NULL) {
|
||||
+ kfree(adap);
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
+ adapdata->smba = smba;
|
||||
+
|
||||
+ snprintf(adap->name, sizeof(adap->name),
|
||||
+ "SMBus NCT67xx adapter%s at %04x", name, smba);
|
||||
+
|
||||
+ i2c_set_adapdata(adap, adapdata);
|
||||
+
|
||||
+ retval = i2c_add_adapter(adap);
|
||||
+ if (retval) {
|
||||
+ kfree(adapdata);
|
||||
+ kfree(adap);
|
||||
+ return retval;
|
||||
+ }
|
||||
+
|
||||
+ *padap = adap;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void nct6775_remove_adapter(struct i2c_adapter *adap)
|
||||
+{
|
||||
+ struct i2c_nct6775_adapdata *adapdata = i2c_get_adapdata(adap);
|
||||
+
|
||||
+ if (adapdata->smba) {
|
||||
+ i2c_del_adapter(adap);
|
||||
+ kfree(adapdata);
|
||||
+ kfree(adap);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+//static SIMPLE_DEV_PM_OPS(nct6775_dev_pm_ops, nct6775_suspend, nct6775_resume);
|
||||
+
|
||||
+/*
|
||||
+ * when Super-I/O functions move to a separate file, the Super-I/O
|
||||
+ * bus will manage the lifetime of the device and this module will only keep
|
||||
+ * track of the nct6775 driver. But since we use platform_device_alloc(), we
|
||||
+ * must keep track of the device
|
||||
+ */
|
||||
+static struct platform_device *pdev[2];
|
||||
+
|
||||
+static int nct6775_probe(struct platform_device *pdev)
|
||||
+{
|
||||
+ struct device *dev = &pdev->dev;
|
||||
+ struct nct6775_sio_data *sio_data = dev_get_platdata(dev);
|
||||
+ struct resource *res;
|
||||
+
|
||||
+ res = platform_get_resource(pdev, IORESOURCE_IO, 0);
|
||||
+ if (!devm_request_region(&pdev->dev, res->start, IOREGION_LENGTH,
|
||||
+ DRVNAME))
|
||||
+ return -EBUSY;
|
||||
+
|
||||
+ switch (sio_data->kind) {
|
||||
+ case nct6791:
|
||||
+ case nct6792:
|
||||
+ case nct6793:
|
||||
+ case nct6795:
|
||||
+ case nct6796:
|
||||
+ case nct6798:
|
||||
+ nct6775_add_adapter(res->start, "", &nct6775_adapter);
|
||||
+ break;
|
||||
+ default:
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+/*
|
||||
+static void nct6791_enable_io_mapping(int sioaddr)
|
||||
+{
|
||||
+ int val;
|
||||
+
|
||||
+ val = superio_inb(sioaddr, NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE);
|
||||
+ if (val & 0x10) {
|
||||
+ pr_info("Enabling hardware monitor logical device mappings.\n");
|
||||
+ superio_outb(sioaddr, NCT6791_REG_HM_IO_SPACE_LOCK_ENABLE,
|
||||
+ val & ~0x10);
|
||||
+ }
|
||||
+}*/
|
||||
+
|
||||
+static struct platform_driver i2c_nct6775_driver = {
|
||||
+ .driver = {
|
||||
+ .name = DRVNAME,
|
||||
+// .pm = &nct6775_dev_pm_ops,
|
||||
+ },
|
||||
+ .probe = nct6775_probe,
|
||||
+};
|
||||
+
|
||||
+static void __exit i2c_nct6775_exit(void)
|
||||
+{
|
||||
+ int i;
|
||||
+
|
||||
+ if(nct6775_adapter)
|
||||
+ nct6775_remove_adapter(nct6775_adapter);
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(pdev); i++) {
|
||||
+ if (pdev[i])
|
||||
+ platform_device_unregister(pdev[i]);
|
||||
+ }
|
||||
+ platform_driver_unregister(&i2c_nct6775_driver);
|
||||
+}
|
||||
+
|
||||
+/* nct6775_find() looks for a '627 in the Super-I/O config space */
|
||||
+static int __init nct6775_find(int sioaddr, struct nct6775_sio_data *sio_data)
|
||||
+{
|
||||
+ u16 val;
|
||||
+ int err;
|
||||
+ int addr;
|
||||
+
|
||||
+ err = superio_enter(sioaddr);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ val = (superio_inb(sioaddr, SIO_REG_DEVID) << 8) |
|
||||
+ superio_inb(sioaddr, SIO_REG_DEVID + 1);
|
||||
+
|
||||
+ switch (val & SIO_ID_MASK) {
|
||||
+ case SIO_NCT6106_ID:
|
||||
+ sio_data->kind = nct6106;
|
||||
+ break;
|
||||
+ case SIO_NCT6775_ID:
|
||||
+ sio_data->kind = nct6775;
|
||||
+ break;
|
||||
+ case SIO_NCT6776_ID:
|
||||
+ sio_data->kind = nct6776;
|
||||
+ break;
|
||||
+ case SIO_NCT6779_ID:
|
||||
+ sio_data->kind = nct6779;
|
||||
+ break;
|
||||
+ case SIO_NCT6791_ID:
|
||||
+ sio_data->kind = nct6791;
|
||||
+ break;
|
||||
+ case SIO_NCT6792_ID:
|
||||
+ sio_data->kind = nct6792;
|
||||
+ break;
|
||||
+ case SIO_NCT6793_ID:
|
||||
+ sio_data->kind = nct6793;
|
||||
+ break;
|
||||
+ case SIO_NCT6795_ID:
|
||||
+ sio_data->kind = nct6795;
|
||||
+ break;
|
||||
+ case SIO_NCT6796_ID:
|
||||
+ sio_data->kind = nct6796;
|
||||
+ break;
|
||||
+ case SIO_NCT6798_ID:
|
||||
+ sio_data->kind = nct6798;
|
||||
+ break;
|
||||
+ default:
|
||||
+ if (val != 0xffff)
|
||||
+ pr_debug("unsupported chip ID: 0x%04x\n", val);
|
||||
+ superio_exit(sioaddr);
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ /* We have a known chip, find the SMBus I/O address */
|
||||
+ superio_select(sioaddr, NCT6775_LD_SMBUS);
|
||||
+ val = (superio_inb(sioaddr, SIO_REG_SMBA) << 8)
|
||||
+ | superio_inb(sioaddr, SIO_REG_SMBA + 1);
|
||||
+ addr = val & IOREGION_ALIGNMENT;
|
||||
+ if (addr == 0) {
|
||||
+ pr_err("Refusing to enable a Super-I/O device with a base I/O port 0\n");
|
||||
+ superio_exit(sioaddr);
|
||||
+ return -ENODEV;
|
||||
+ }
|
||||
+
|
||||
+ //if (sio_data->kind == nct6791 || sio_data->kind == nct6792 ||
|
||||
+ // sio_data->kind == nct6793 || sio_data->kind == nct6795 ||
|
||||
+ // sio_data->kind == nct6796)
|
||||
+ // nct6791_enable_io_mapping(sioaddr);
|
||||
+
|
||||
+ superio_exit(sioaddr);
|
||||
+ pr_info("Found %s or compatible chip at %#x:%#x\n",
|
||||
+ nct6775_sio_names[sio_data->kind], sioaddr, addr);
|
||||
+ sio_data->sioreg = sioaddr;
|
||||
+
|
||||
+ return addr;
|
||||
+}
|
||||
+
|
||||
+static int __init i2c_nct6775_init(void)
|
||||
+{
|
||||
+ int i, err;
|
||||
+ bool found = false;
|
||||
+ int address;
|
||||
+ struct resource res;
|
||||
+ struct nct6775_sio_data sio_data;
|
||||
+ int sioaddr[2] = { 0x2e, 0x4e };
|
||||
+
|
||||
+ err = platform_driver_register(&i2c_nct6775_driver);
|
||||
+ if (err)
|
||||
+ return err;
|
||||
+
|
||||
+ /*
|
||||
+ * initialize sio_data->kind and sio_data->sioreg.
|
||||
+ *
|
||||
+ * when Super-I/O functions move to a separate file, the Super-I/O
|
||||
+ * driver will probe 0x2e and 0x4e and auto-detect the presence of a
|
||||
+ * nct6775 hardware monitor, and call probe()
|
||||
+ */
|
||||
+ for (i = 0; i < ARRAY_SIZE(pdev); i++) {
|
||||
+ address = nct6775_find(sioaddr[i], &sio_data);
|
||||
+ if (address <= 0)
|
||||
+ continue;
|
||||
+
|
||||
+ found = true;
|
||||
+
|
||||
+ pdev[i] = platform_device_alloc(DRVNAME, address);
|
||||
+ if (!pdev[i]) {
|
||||
+ err = -ENOMEM;
|
||||
+ goto exit_device_unregister;
|
||||
+ }
|
||||
+
|
||||
+ err = platform_device_add_data(pdev[i], &sio_data,
|
||||
+ sizeof(struct nct6775_sio_data));
|
||||
+ if (err)
|
||||
+ goto exit_device_put;
|
||||
+
|
||||
+ memset(&res, 0, sizeof(res));
|
||||
+ res.name = DRVNAME;
|
||||
+ res.start = address;
|
||||
+ res.end = address + IOREGION_LENGTH - 1;
|
||||
+ res.flags = IORESOURCE_IO;
|
||||
+
|
||||
+ err = acpi_check_resource_conflict(&res);
|
||||
+ if (err) {
|
||||
+ platform_device_put(pdev[i]);
|
||||
+ pdev[i] = NULL;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ err = platform_device_add_resources(pdev[i], &res, 1);
|
||||
+ if (err)
|
||||
+ goto exit_device_put;
|
||||
+
|
||||
+ /* platform_device_add calls probe() */
|
||||
+ err = platform_device_add(pdev[i]);
|
||||
+ if (err)
|
||||
+ goto exit_device_put;
|
||||
+ }
|
||||
+ if (!found) {
|
||||
+ err = -ENODEV;
|
||||
+ goto exit_unregister;
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+
|
||||
+exit_device_put:
|
||||
+ platform_device_put(pdev[i]);
|
||||
+exit_device_unregister:
|
||||
+ while (--i >= 0) {
|
||||
+ if (pdev[i])
|
||||
+ platform_device_unregister(pdev[i]);
|
||||
+ }
|
||||
+exit_unregister:
|
||||
+ platform_driver_unregister(&i2c_nct6775_driver);
|
||||
+ return err;
|
||||
+}
|
||||
+
|
||||
+MODULE_AUTHOR("Adam Honse <[email protected]>");
|
||||
+MODULE_DESCRIPTION("SMBus driver for NCT6775F and compatible chips");
|
||||
+MODULE_LICENSE("GPL");
|
||||
+
|
||||
+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
|
||||
--- 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)
|
||||
if (srvrworks_csb5_delay) /* Extra delay for SERVERWORKS_CSB5 */
|
||||
usleep_range(2000, 2100);
|
||||
else
|
||||
- usleep_range(250, 500);
|
||||
+ usleep_range(25, 50);
|
||||
|
||||
while ((++timeout < MAX_TIMEOUT) &&
|
||||
((temp = inb_p(SMBHSTSTS)) & 0x01))
|
||||
- usleep_range(250, 500);
|
||||
+ usleep_range(25, 50);
|
||||
|
||||
/* 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)
|
||||
retval = piix4_setup_sb800(dev, id, 1);
|
||||
}
|
||||
|
||||
+ if (dev->vendor == PCI_VENDOR_ID_AMD &&
|
||||
+ dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS) {
|
||||
+ retval = piix4_setup_sb800(dev, id, 1);
|
||||
+ }
|
||||
+
|
||||
if (retval > 0) {
|
||||
/* Try to add the aux adapter if it exists,
|
||||
* piix4_add_adapter will clean up if this fails */
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = OpenAuraSDK
|
||||
TEMPLATE = app
|
||||
|
||||
INCLUDEPATH += \
|
||||
i2c_smbus/ \
|
||||
net_port/ \
|
||||
serial_port/ \
|
||||
Controllers/AuraController/ \
|
||||
Controllers/CorsairController/ \
|
||||
Controllers/CorsairProController/ \
|
||||
Controllers/HuePlusController/ \
|
||||
Controllers/HyperXController/ \
|
||||
Controllers/LEDStripController/ \
|
||||
Controllers/RGBFusionController/ \
|
||||
RGBController/ \
|
||||
qt/
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
OpenAuraSDK.cpp \
|
||||
qt/OpenAuraSDKQtDialog.cpp \
|
||||
i2c_smbus/i2c_smbus.cpp \
|
||||
net_port/net_port.cpp \
|
||||
serial_port/serial_port.cpp \
|
||||
Controllers/AuraController/AuraController.cpp \
|
||||
Controllers/AuraController/AuraControllerDetect.cpp \
|
||||
Controllers/CorsairController/CorsairController.cpp \
|
||||
Controllers/CorsairController/CorsairControllerDetect.cpp \
|
||||
Controllers/CorsairProController/CorsairProController.cpp \
|
||||
Controllers/CorsairProController/CorsairProControllerDetect.cpp \
|
||||
Controllers/HuePlusController/HuePlusController.cpp \
|
||||
Controllers/HuePlusController/HuePlusControllerDetect.cpp \
|
||||
Controllers/HyperXController/HyperXController.cpp \
|
||||
Controllers/HyperXController/HyperXControllerDetect.cpp \
|
||||
Controllers/LEDStripController/LEDStripController.cpp \
|
||||
Controllers/LEDStripController/LEDStripControllerDetect.cpp \
|
||||
Controllers/RGBFusionController/RGBFusionController.cpp \
|
||||
Controllers/RGBFusionController/RGBFusionControllerDetect.cpp \
|
||||
RGBController/RGBController_Aura.cpp \
|
||||
RGBController/RGBController_Corsair.cpp \
|
||||
RGBController/RGBController_CorsairPro.cpp \
|
||||
RGBController/RGBController_HuePlus.cpp \
|
||||
RGBController/RGBController_HyperX.cpp \
|
||||
RGBController/RGBController_LEDStrip.cpp \
|
||||
RGBController/RGBController_RGBFusion.cpp
|
||||
|
||||
HEADERS += \
|
||||
qt/OpenAuraSDKQtDialog.h \
|
||||
i2c_smbus/i2c_smbus.h \
|
||||
net_port/net_port.h \
|
||||
serial_port/serial_port.h \
|
||||
Controllers/AuraController/AuraController.h \
|
||||
Controllers/CorsairController/CorsairController.h \
|
||||
Controllers/CorsairProController/CorsairProController.h \
|
||||
Controllers/HuePlusController/HuePlusController.h \
|
||||
Controllers/HyperXController/HyperXController.h \
|
||||
Controllers/LEDStripController/LEDStripController.h \
|
||||
RGBController/RGBController.h \
|
||||
RGBController/RGBController_Aura.h \
|
||||
RGBController/RGBController_Corsair.h \
|
||||
RGBController/RGBController_CorsairPro.h \
|
||||
RGBController/RGBController_HuePlus.h \
|
||||
RGBController/RGBController_HyperX.h \
|
||||
RGBController/RGBController_RGBFusion.h
|
||||
|
||||
RESOURCES += \
|
||||
qt/resources.qrc
|
||||
|
||||
FORMS += \
|
||||
qt/openaurasdk.ui
|
||||
|
||||
#-----------------------------------------------
|
||||
# Windows specific project configuration
|
||||
#-----------------------------------------------
|
||||
win32:INCLUDEPATH += \
|
||||
dependencies/inpout32_1501/Win32/ \
|
||||
dependencies/razer-chroma-2.9.0/inc \
|
||||
wmi/ \
|
||||
|
||||
win32:SOURCES += \
|
||||
i2c_smbus/i2c_smbus_i801.cpp \
|
||||
i2c_smbus/i2c_smbus_nct6775.cpp \
|
||||
i2c_smbus/i2c_smbus_piix4.cpp \
|
||||
wmi/wmi.cpp \
|
||||
RGBController/RazerChromaSDKDetect.cpp \
|
||||
RGBController/RGBController_RazerChromaSDK.cpp \
|
||||
|
||||
win32:HEADERS += \
|
||||
dependencies/inpout32_1501/Win32/inpout32.h \
|
||||
i2c_smbus/i2c_smbus_i801.h \
|
||||
i2c_smbus/i2c_smbus_nct6775.h \
|
||||
i2c_smbus/i2c_smbus_piix4.h \
|
||||
wmi/wmi.h \
|
||||
RGBController/RGBController_RazerChromaSDK.h \
|
||||
|
||||
win32:LIBS += \
|
||||
-lws2_32 \
|
||||
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32
|
||||
|
||||
win32:DEFINES -= \
|
||||
UNICODE
|
||||
|
||||
win32:DEFINES += \
|
||||
_MBCS \
|
||||
WIN32 \
|
||||
_CRT_SECURE_NO_WARNINGS \
|
||||
_WINSOCK_DEPRECATED_NO_WARNINGS \
|
||||
WIN32_LEAN_AND_MEAN
|
||||
|
||||
#-----------------------------------------------
|
||||
# Linux specific project configuration
|
||||
#-----------------------------------------------
|
||||
unix:INCLUDEPATH += \
|
||||
dependencies/libe131/src/ \
|
||||
|
||||
unix:HEADERS += \
|
||||
i2c_smbus/i2c_smbus_linux.h \
|
||||
RGBController/RGBController_E131.h \
|
||||
|
||||
unix:SOURCES += \
|
||||
dependencies/libe131/src/e131.c \
|
||||
i2c_smbus/i2c_smbus_linux.cpp \
|
||||
RGBController/OpenRazerDetect.cpp \
|
||||
RGBController/E131ControllerDetect.cpp \
|
||||
RGBController/RGBController_E131.cpp \
|
||||
RGBController/RGBController_OpenRazer.cpp \
|
||||
@@ -1,31 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27703.2026
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenAuraSDK", "OpenAuraSDK\OpenAuraSDK.vcxproj", "{6D22BFF3-C1DF-407A-8816-05D63919A991}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x64.Build.0 = Debug|x64
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Debug|x86.Build.0 = Debug|Win32
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x64.ActiveCfg = Release|x64
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x64.Build.0 = Release|x64
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x86.ActiveCfg = Release|Win32
|
||||
{6D22BFF3-C1DF-407A-8816-05D63919A991}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A2BB3E13-D506-413D-900E-F2B1323B3BB3}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -1,40 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraController.h |
|
||||
| |
|
||||
| Driver for ASUS Aura RGB lighting |
|
||||
| controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 8/19/2018 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraController.h"
|
||||
|
||||
unsigned char AuraController::AuraRegisterRead(aura_register reg)
|
||||
{
|
||||
//Write Aura register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Read Aura value
|
||||
return(bus->i2c_smbus_read_byte_data(dev, 0x81));
|
||||
|
||||
}
|
||||
|
||||
void AuraController::AuraRegisterWrite(aura_register reg, unsigned char val)
|
||||
{
|
||||
//Write Aura register
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write Aura value
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x01, val);
|
||||
|
||||
}
|
||||
|
||||
void AuraController::AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz)
|
||||
{
|
||||
//Write Aura register (0x8000 for colors)
|
||||
bus->i2c_smbus_write_word_data(dev, 0x00, ((reg << 8) & 0xFF00) | ((reg >> 8) & 0x00FF));
|
||||
|
||||
//Write Aura block data
|
||||
bus->i2c_smbus_write_block_data(dev, 0x03, sz, data);
|
||||
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS Aura RGB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 8/19/2018 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef unsigned char aura_dev_id;
|
||||
typedef unsigned short aura_register;
|
||||
|
||||
#define AURA_APPLY_VAL 0x01 /* Value for Apply Changes Register */
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_REG_COLORS_DIRECT = 0x8000, /* Colors for Direct Mode 15 bytes */
|
||||
AURA_REG_COLORS_EFFECT = 0x8010, /* Colors for Internal Effects 15 bytes */
|
||||
AURA_REG_DIRECT = 0x8020, /* "Direct Access" Selection Register */
|
||||
AURA_REG_MODE = 0x8021, /* AURA Mode Selection Register */
|
||||
AURA_REG_APPLY = 0x80A0, /* AURA Apply Changes Register */
|
||||
AURA_REG_SLOT_INDEX = 0x80F8, /* AURA Slot Index Register (RAM only) */
|
||||
AURA_REG_I2C_ADDRESS = 0x80F9, /* AURA I2C Address Register (RAM only) */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_MODE_OFF = 0, /* OFF mode */
|
||||
AURA_MODE_STATIC = 1, /* Static color mode */
|
||||
AURA_MODE_BREATHING = 2, /* Breathing effect mode */
|
||||
AURA_MODE_FLASHING = 3, /* Flashing effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE = 4, /* Spectrum Cycle mode */
|
||||
AURA_MODE_RAINBOW = 5, /* Rainbow effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_BREATHING = 6, /* Rainbow Breathing effect mode */
|
||||
AURA_MODE_CHASE_FADE = 7, /* Chase with Fade effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_CHASE_FADE = 8, /* Chase with Fade, Rainbow effect mode */
|
||||
AURA_MODE_CHASE = 9, /* Chase effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_CHASE = 10, /* Chase with Rainbow effect mode */
|
||||
AURA_MODE_SPECTRUM_CYCLE_WAVE = 11, /* Wave effect mode */
|
||||
AURA_MODE_CHASE_RAINBOW_PULSE = 12, /* Chase with Rainbow Pulse effect mode*/
|
||||
AURA_MODE_RANDOM_FLICKER = 13, /* Random flicker effect mode */
|
||||
};
|
||||
|
||||
class AuraController
|
||||
{
|
||||
public:
|
||||
unsigned char AuraRegisterRead(aura_register reg);
|
||||
void AuraRegisterWrite(aura_register reg, unsigned char val);
|
||||
void AuraRegisterWriteBlock(aura_register reg, unsigned char * data, unsigned char sz);
|
||||
i2c_smbus_interface * bus;
|
||||
aura_dev_id dev;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
TEMPLATE = app
|
||||
CONFIG += console c++11
|
||||
CONFIG -= app_bundle
|
||||
CONFIG -= qt
|
||||
|
||||
SOURCES += \
|
||||
i2c_smbus.cpp \
|
||||
AuraController.cpp \
|
||||
OpenAuraSDK.cpp \
|
||||
i2c_smbus_linux.cpp
|
||||
|
||||
HEADERS += \
|
||||
i2c_smbus.h \
|
||||
i2c_smbus_linux.h \
|
||||
AuraController.h
|
||||
|
||||
FORMS +=
|
||||
@@ -1,191 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>15.0</VCProjectVersion>
|
||||
<ProjectGuid>{6D22BFF3-C1DF-407A-8816-05D63919A991}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>OpenAuraSDK</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="Shared">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetExt>.exe</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetExt>.exe</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetExt>.exe</TargetExt>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetExt>.exe</TargetExt>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<PrecompiledHeaderFile />
|
||||
<PrecompiledHeaderOutputFile />
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile />
|
||||
<PrecompiledHeaderOutputFile />
|
||||
<AdditionalIncludeDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<PrecompiledHeaderFile />
|
||||
<PrecompiledHeaderOutputFile />
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile />
|
||||
<PrecompiledHeaderOutputFile />
|
||||
<AdditionalIncludeDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalLibraryDirectories>..\dependencies\inpout32_1501\Win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="AuraController.h" />
|
||||
<ClInclude Include="i2c_smbus.h" />
|
||||
<ClInclude Include="i2c_smbus_i801.h" />
|
||||
<ClInclude Include="i2c_smbus_piix4.h" />
|
||||
<ClInclude Include="wmi.h" />
|
||||
<ClInclude Include="OpenAuraSDK.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="AuraController.cpp" />
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="i2c_smbus.cpp" />
|
||||
<ClCompile Include="i2c_smbus_i801.cpp" />
|
||||
<ClCompile Include="i2c_smbus_piix4.cpp" />
|
||||
<ClCompile Include="wmi.cpp" />
|
||||
<ClCompile Include="OpenAuraSDK.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="i2c_smbus.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="i2c_smbus_piix4.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="AuraController.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="OpenAuraSDK.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="i2c_smbus_i801.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="wmi.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="OpenAuraSDK.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="i2c_smbus_piix4.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="AuraController.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="i2c_smbus_i801.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="i2c_smbus.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wmi.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Binary file not shown.
@@ -0,0 +1,63 @@
|
||||
# OpenRGB (formerly OpenAuraSDK)
|
||||
|
||||
The goal of this project is to create an easy-to-use open source software program and library for accessing and controlling RGB lights on various PC hardware including motherboards, RAM modules, graphics cards, cooling devices, and peripherals.
|
||||
|
||||
This project originally focused only on ASUS Aura. It was spun off of Keyboard Visualizer's AsusAuraWindows branch to learn more about the details behind the Aura protocol and to develop a more flexible, compatible, and reliable driver for Aura. Our Aura implementation is now quite solid and supports multiple generations of Aura controller across both Intel and AMD platforms. It also supports Aura-compatible controllers used across multiple manufacturers of RGB memory modules including G.Skill Trident Z RGB and others. It is still lacking a few capabilities, namely saving settings to persist across reboots, but the core functionality of setting colors and modes is there.
|
||||
|
||||
After getting a solid Aura implementation, the project branched out into other manufacturers and categories of RGB devices. A major focus was to develop a software API that could reliably represent as many RGB devices as possible, exposing their various modes and describing their LED layouts via zones, that was generic enough to write a user application without specifically targeting any one manufacturer. To this extent, the generic_rgb_interface_test branch was created which became the foundation of OpenRGB. The goal of OpenRGB is to both develop new drivers for unsupported devices and integrate existing open source drivers for devices that do have some sort of open support. The goal is to be the one-stop solution to open source RGB lighting control!
|
||||
|
||||
## Supported Devices
|
||||
|
||||
* Asus Aura (SMBus variants only)
|
||||
|
||||
* Gigabyte RGB Fusion 1.0
|
||||
|
||||
* Asus Aura RAM
|
||||
|
||||
* Corsair Vengeance RGB
|
||||
|
||||
* Corsair Vengeance Pro RGB
|
||||
|
||||
* HyperX Predator RGB
|
||||
|
||||
* NZXT Hue+
|
||||
|
||||
* KeyboardVisualizer Arduino LED Strips
|
||||
|
||||
* E1.31 (Linux only)
|
||||
|
||||
* OpenRazer (Linux only)
|
||||
|
||||
## Installation
|
||||
#### Windows
|
||||
1. Download the latest Visual Studio Community Edition and Qt Creator.
|
||||
2. Open the OpenRGB_Win.pro project.
|
||||
3. Build the project for `x86` Architecture. The InpOut32 library I use does not support x64.
|
||||
4. Copy InpOut32.dll from dependencies to the same path as OpenAuraSDK.exe along with the Qt libraries.
|
||||
|
||||
**You must run the application as Administrator the first time to allow InpOut32 to set up. It can be run as a normal user afterwards**
|
||||
|
||||
#### Linux:
|
||||
1. Either open the project using QT Creator or build it using qmake.
|
||||
|
||||
cd OpenAuraSDK
|
||||
qmake OpenAuraSDK.pro
|
||||
make
|
||||
|
||||
|
||||
2. Allow access to SMBus:<br>
|
||||
|
||||
- This can be identified by your motherboard
|
||||
##### Intel
|
||||
- `modprobe i2c-dev i2c-i801`
|
||||
- Asus used the SMBus controller on the Super IO chip for on-board Aura chips on Intel motherboards. I have a kernel patch to add a driver for this chip [here](https://gitlab.com/CalcProgrammer1/OpenAuraSDK/issues/22). After patching the kernel, enable the Nuvoton NCT67xx SMBus driver in your kernel configuration. The driver may be loaded with `modprobe i2c-nct6775`
|
||||
##### AMD
|
||||
- `modprobe i2c-dev i2c-piix4`
|
||||
- The second SMBus isn't currently picked up by the kernel driver and that seems to be where Asus wired the Aura controllers so I have a kernel patch [here](https://gitlab.com/CalcProgrammer1/OpenAuraSDK/issues/9) that will allow the kernel to use the second bus (at `0x0b20`).
|
||||
|
||||
- You'll have to enable user access to your SMbus if you don't run as root.
|
||||
- List all SMBus controllers: `sudo i2cdetect -l`
|
||||
- Find out which control your Aura devices (PIIX4, I801, and NCT67xx)
|
||||
- Give user access to those controllers, for instance: `sudo chmod 777 /dev/i2c-0`
|
||||
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_E131.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#define LPSTR char *
|
||||
#define strtok_s strtok_r
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectE131Controllers *
|
||||
* *
|
||||
* Detect devices supported by the E131 driver *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
RGBController_E131* new_controller;
|
||||
|
||||
//Get file path in executable directory
|
||||
std::ifstream infile;
|
||||
char filename[2048];
|
||||
char arg1[64];
|
||||
|
||||
#ifdef WIN32
|
||||
GetModuleFileName(NULL, filename, 2048);
|
||||
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
|
||||
strcat(filename, "\\e131.txt");
|
||||
#else
|
||||
snprintf(arg1, 64, "/proc/%d/exe", getpid());
|
||||
readlink(arg1, filename, 1024);
|
||||
strcpy(filename, std::string(filename).substr(0, std::string(filename).find_last_of("\\/")).c_str());
|
||||
strcat(filename, "/e131.txt");
|
||||
#endif
|
||||
|
||||
E131Device dev;
|
||||
std::vector<E131Device> devices;
|
||||
|
||||
bool new_device = false;
|
||||
|
||||
//Open settings file
|
||||
infile.open(filename);
|
||||
|
||||
if (infile.good())
|
||||
{
|
||||
for (std::string line; std::getline(infile, line); )
|
||||
{
|
||||
if (new_device)
|
||||
{
|
||||
dev.name = line;
|
||||
new_device = false;
|
||||
}
|
||||
|
||||
if (line == "")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((line[0] != ';') && (line[0] != '#') && (line[0] != '/'))
|
||||
{
|
||||
char * argument;
|
||||
char * value;
|
||||
|
||||
value = (char *)line.c_str();
|
||||
|
||||
argument = strtok_s(value, "=", &value);
|
||||
|
||||
//Strip off new line characters if present
|
||||
argument = strtok(argument, "\r\n");
|
||||
value = strtok(value, "\r\n");
|
||||
|
||||
if(argument)
|
||||
{
|
||||
if (strcmp(argument, "e131_device_start") == 0)
|
||||
{
|
||||
new_device = true;
|
||||
}
|
||||
else if(strcmp(argument, "num_leds") == 0)
|
||||
{
|
||||
dev.num_leds = atoi(value);
|
||||
}
|
||||
else if(strcmp(argument, "start_universe") == 0)
|
||||
{
|
||||
dev.start_universe = atoi(value);
|
||||
}
|
||||
else if(strcmp(argument, "start_channel") == 0)
|
||||
{
|
||||
dev.start_channel = atoi(value);
|
||||
}
|
||||
else if(strcmp(argument, "rgb_order") == 0)
|
||||
{
|
||||
if(strcmp(value, "RGB") == 0)
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_RGB;
|
||||
}
|
||||
else if(strcmp(value, "RBG") == 0)
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_RBG;
|
||||
}
|
||||
else if(strcmp(value, "GRB") == 0)
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_GRB;
|
||||
}
|
||||
else if(strcmp(value, "GBR") == 0)
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_GBR;
|
||||
}
|
||||
else if(strcmp(value, "BRG") == 0)
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_BRG;
|
||||
}
|
||||
else if(strcmp(value, "BGR") == 0)
|
||||
{
|
||||
dev.rgb_order = E131_RGB_ORDER_BGR;
|
||||
}
|
||||
else
|
||||
{
|
||||
dev.rgb_order = atoi(value);
|
||||
}
|
||||
}
|
||||
else if(strcmp(argument, "type") == 0)
|
||||
{
|
||||
if(strcmp(value, "SINGLE") == 0)
|
||||
{
|
||||
dev.type = ZONE_TYPE_SINGLE;
|
||||
}
|
||||
else if(strcmp(value, "LINEAR") == 0)
|
||||
{
|
||||
dev.type = ZONE_TYPE_LINEAR;
|
||||
}
|
||||
else if(strcmp(value, "MATRIX") == 0)
|
||||
{
|
||||
dev.type = ZONE_TYPE_MATRIX;
|
||||
}
|
||||
else
|
||||
{
|
||||
dev.type = atoi(value);
|
||||
}
|
||||
}
|
||||
else if(strcmp(argument, "e131_device_end") == 0)
|
||||
{
|
||||
devices.push_back(dev);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(devices.size() > 0)
|
||||
{
|
||||
new_controller = new RGBController_E131(devices);
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
}
|
||||
|
||||
} /* DetectLEDStripControllers() */
|
||||
@@ -0,0 +1,127 @@
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_OpenRazer.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectOpenRazerControllers *
|
||||
* *
|
||||
* Detect devices supported by the OpenRazer kernel drivers *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers)
|
||||
{
|
||||
char driver_path[512];
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
int test_fd;
|
||||
bool done = false;
|
||||
int driver_to_read = 0;
|
||||
|
||||
while(driver_to_read < 8)
|
||||
{
|
||||
switch(driver_to_read)
|
||||
{
|
||||
case 0:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razerkbd/");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razermouse/");
|
||||
break;
|
||||
|
||||
case 2:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razerfirefly/");
|
||||
break;
|
||||
|
||||
case 3:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razermug/");
|
||||
break;
|
||||
|
||||
case 4:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razercore/");
|
||||
break;
|
||||
|
||||
case 5:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razerkraken/");
|
||||
break;
|
||||
|
||||
case 6:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razermousemat/");
|
||||
break;
|
||||
|
||||
case 7:
|
||||
strcpy(driver_path, "/sys/bus/hid/drivers/razerchromahdk/");
|
||||
break;
|
||||
}
|
||||
|
||||
done = false;
|
||||
|
||||
dir = opendir(driver_path);
|
||||
|
||||
if(dir == NULL)
|
||||
{
|
||||
closedir(dir);
|
||||
|
||||
driver_to_read++;
|
||||
continue;
|
||||
}
|
||||
|
||||
ent = readdir(dir);
|
||||
|
||||
while(ent != NULL)
|
||||
{
|
||||
if(ent->d_type == DT_DIR || ent->d_type == DT_LNK)
|
||||
{
|
||||
if(!strcmp(ent->d_name, "."))
|
||||
{
|
||||
if(done == false)
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(!strcmp(ent->d_name, "..") || !strcmp(ent->d_name, "module"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
int device_type;
|
||||
char device_string[1024];
|
||||
strcpy(device_string, driver_path);
|
||||
strcat(device_string, ent->d_name);
|
||||
|
||||
RGBController_OpenRazer * razer_rgb = new RGBController_OpenRazer(device_string);
|
||||
|
||||
if(razer_rgb->device != -1)
|
||||
{
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete razer_rgb;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ent = readdir(dir);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
|
||||
driver_to_read++;
|
||||
}
|
||||
|
||||
} /* DetectOpenRazerControllers() */
|
||||
@@ -0,0 +1,66 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController.h |
|
||||
| |
|
||||
| Definitions and types for generic RGB |
|
||||
| lighting controller interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/2/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
typedef unsigned int RGBColor;
|
||||
|
||||
#define RGBGetRValue(rgb) (rgb & 0x000000FF)
|
||||
#define RGBGetGValue(rgb) ((rgb >> 8) & 0x000000FF)
|
||||
#define RGBGetBValue(rgb) ((rgb >> 16) & 0x000000FF)
|
||||
|
||||
#define ToRGBColor(r, g, b) ((b << 16) | (g << 8) | (r))
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name; /* LED name */
|
||||
} led;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name; /* Mode name */
|
||||
} mode;
|
||||
|
||||
typedef int zone_type;
|
||||
|
||||
enum
|
||||
{
|
||||
ZONE_TYPE_SINGLE,
|
||||
ZONE_TYPE_LINEAR,
|
||||
ZONE_TYPE_MATRIX
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name; /* Zone name */
|
||||
zone_type type; /* Zone type */
|
||||
std::vector<std::vector<int>>
|
||||
map; /* LED index map */
|
||||
} zone;
|
||||
|
||||
class RGBController
|
||||
{
|
||||
public:
|
||||
std::string name; /* controller name */
|
||||
std::vector<led> leds; /* LEDs */
|
||||
std::vector<zone> zones; /* Zones */
|
||||
std::vector<mode> modes; /* Modes */
|
||||
std::vector<RGBColor> colors; /* Color buffer */
|
||||
|
||||
virtual int GetMode() = 0;
|
||||
virtual void SetMode(int mode) = 0;
|
||||
virtual void SetCustomMode() = 0;
|
||||
virtual void SetAllLEDs(RGBColor color) = 0;
|
||||
virtual void SetAllZoneLEDs(int zone, RGBColor color) = 0;
|
||||
virtual void SetLED(int led, RGBColor color) = 0;
|
||||
virtual void UpdateLEDs() = 0;
|
||||
};
|
||||
@@ -0,0 +1,92 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AorusGPU.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| Aorus GPU |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/17/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AorusGPU.h"
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
static HMODULE handle;
|
||||
static unsigned char data[] = { 0x8E, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00,
|
||||
0x64, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00 };
|
||||
|
||||
int RGBController_AorusGPU::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetMode(int mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
data[9] = RGBGetRValue(color);
|
||||
data[10] = RGBGetGValue(color);
|
||||
data[11] = RGBGetBValue(color);
|
||||
|
||||
GvWriteI2C(0x00000000, data, 0x00000000);
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
data[9] = RGBGetRValue(color);
|
||||
data[10] = RGBGetGValue(color);
|
||||
data[11] = RGBGetBValue(color);
|
||||
|
||||
GvWriteI2C(0x00000000, data, 0x00000000);
|
||||
}
|
||||
|
||||
void RGBController_AorusGPU::SetLED(int led, RGBColor color)
|
||||
{
|
||||
data[9] = RGBGetRValue(color);
|
||||
data[10] = RGBGetGValue(color);
|
||||
data[11] = RGBGetBValue(color);
|
||||
|
||||
GvWriteI2C(0x00000000, data, 0x00000000);
|
||||
}
|
||||
|
||||
RGBController_AorusGPU::RGBController_AorusGPU()
|
||||
{
|
||||
name = "Aorus GPU";
|
||||
|
||||
handle = LoadLibrary("GvDisplay.dll");
|
||||
|
||||
GvWriteI2C = (_GvWriteI2C)GetProcAddress(handle, "GvWriteI2C");
|
||||
GvFreeDispLib = (_GvFreeDispLib)GetProcAddress(handle, "GvFreeDispLib");
|
||||
GvInitDispLib = (_GvInitDispLib)GetProcAddress(handle, "GvInitDispLib");
|
||||
|
||||
GvFreeDispLib();
|
||||
GvInitDispLib();
|
||||
|
||||
mode aorus_mode;
|
||||
aorus_mode.name = "Static";
|
||||
modes.push_back(aorus_mode);
|
||||
|
||||
led aorus_led;
|
||||
aorus_led.name = "GPU LED";
|
||||
leds.push_back(aorus_led);
|
||||
|
||||
zone aorus_zone;
|
||||
aorus_zone.name = "GPU LED";
|
||||
std::vector<int> aorus_zone_map;
|
||||
aorus_zone_map.push_back(0);
|
||||
aorus_zone.map.push_back(aorus_zone_map);
|
||||
zones.push_back(aorus_zone);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AorusGPU.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| Aorus GPU |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/17/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
|
||||
typedef unsigned int uint32;
|
||||
typedef uint32(*_GvWriteI2C)(uint32, void*, uint32);
|
||||
typedef void (*_GvFreeDispLib)();
|
||||
typedef void (*_GvInitDispLib)();
|
||||
|
||||
class RGBController_AorusGPU : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AorusGPU();
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
|
||||
private:
|
||||
_GvWriteI2C GvWriteI2C;
|
||||
_GvFreeDispLib GvFreeDispLib;
|
||||
_GvInitDispLib GvInitDispLib;
|
||||
};
|
||||
@@ -0,0 +1,203 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Aura.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| Asus Aura driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/13/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_Aura.h"
|
||||
|
||||
int RGBController_Aura::GetMode()
|
||||
{
|
||||
if (aura->AuraRegisterRead(AURA_REG_DIRECT))
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(aura->AuraRegisterRead(AURA_REG_MODE) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetMode(int mode)
|
||||
{
|
||||
if (mode == 0)
|
||||
{
|
||||
aura->SetDirect(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetMode(mode - 1);
|
||||
aura->SetDirect(false);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetCustomMode()
|
||||
{
|
||||
aura->SetDirect(true);
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura->SetAllColorsDirect(red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetAllColorsEffect(red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
if (GetMode() == 0)
|
||||
{
|
||||
aura->SetLEDColorDirect(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetLEDColorEffect(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::SetLED(int led, RGBColor color)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Aura::UpdateLEDs()
|
||||
{
|
||||
for(int 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->SetLEDColorDirect(led, red, grn, blu);
|
||||
}
|
||||
else
|
||||
{
|
||||
aura->SetLEDColorEffect(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
|
||||
{
|
||||
std::vector<unsigned char> aura_channels;
|
||||
|
||||
aura = aura_ptr;
|
||||
|
||||
name = aura->GetDeviceName();
|
||||
|
||||
mode aura_modes[AURA_NUMBER_MODES + 1];
|
||||
|
||||
aura_modes[0].name = "Direct";
|
||||
aura_modes[1].name = "Off";
|
||||
aura_modes[2].name = "Static";
|
||||
aura_modes[3].name = "Breathing";
|
||||
aura_modes[4].name = "Flashing";
|
||||
aura_modes[5].name = "Spectrum Cycle";
|
||||
aura_modes[6].name = "Rainbow";
|
||||
aura_modes[7].name = "Spectrum Cycle Breathing";
|
||||
aura_modes[8].name = "Chase Fade";
|
||||
aura_modes[9].name = "Spectrum Cycle Chase Fade";
|
||||
aura_modes[10].name = "Chase";
|
||||
aura_modes[11].name = "Spectrum Cycle Chase";
|
||||
aura_modes[12].name = "Spectrum Cycle Wave";
|
||||
aura_modes[13].name = "Chase Rainbow Pulse";
|
||||
aura_modes[14].name = "Random Flicker";
|
||||
|
||||
for (int i = 0; i < (AURA_NUMBER_MODES + 1); i++)
|
||||
{
|
||||
modes.push_back(aura_modes[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < aura->GetLEDCount(); i++)
|
||||
{
|
||||
aura_channels.push_back(aura->GetChannel(i));
|
||||
|
||||
led* new_led = new led();
|
||||
|
||||
new_led->name = aura->GetChannelName(i);
|
||||
|
||||
leds.push_back(*new_led);
|
||||
colors.push_back(0x00000000);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> aura_zones;
|
||||
|
||||
// Search through all LEDs and create zones for each channel type
|
||||
for (int 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 (int 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 (int 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Aura.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| Asus Aura driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/13/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AuraController.h"
|
||||
|
||||
class RGBController_Aura : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Aura(AuraController* aura_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
AuraController* aura;
|
||||
};
|
||||
@@ -0,0 +1,107 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Corsair.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| Corsair Vengeance RGB driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/13/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_Corsair.h"
|
||||
|
||||
int RGBController_Corsair::GetMode()
|
||||
{
|
||||
return(CORSAIR_VENGEANCE_RGB_MODE_SINGLE);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetMode(int mode)
|
||||
{
|
||||
corsair->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
corsair->SetAllColors(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
corsair->SetLEDColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_Corsair::SetLED(int led, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
corsair->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_Corsair::UpdateLEDs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RGBController_Corsair::RGBController_Corsair(CorsairController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = corsair->GetDeviceName();
|
||||
|
||||
mode corsair_modes[CORSAIR_NUMBER_MODES];
|
||||
|
||||
corsair_modes[0].name = "Static";
|
||||
corsair_modes[1].name = "Fade";
|
||||
corsair_modes[2].name = "Pulse";
|
||||
|
||||
for (int i = 0; i < CORSAIR_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(corsair_modes[i]);
|
||||
}
|
||||
|
||||
for (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 (int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
{
|
||||
zone_row.push_back(i);
|
||||
}
|
||||
|
||||
new_zone.map.push_back(zone_row);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Corsair.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| Corsair Vengeance RGB driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/13/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "CorsairController.h"
|
||||
|
||||
class RGBController_Corsair : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Corsair(CorsairController* corsair_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
CorsairController* corsair;
|
||||
};
|
||||
@@ -0,0 +1,150 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairPro.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| Corsair Vengeance Pro RGB driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/30/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_CorsairPro.h"
|
||||
|
||||
int RGBController_CorsairPro::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetMode(int mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_COLOR_SHIFT);
|
||||
break;
|
||||
case 1:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_COLOR_PULSE);
|
||||
break;
|
||||
case 2:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_RAINBOW_WAVE);
|
||||
break;
|
||||
case 3:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_COLOR_WAVE);
|
||||
break;
|
||||
case 4:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_VISOR);
|
||||
break;
|
||||
case 5:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_RAIN);
|
||||
break;
|
||||
case 6:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_MARQUEE);
|
||||
break;
|
||||
case 7:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_RAINBOW);
|
||||
break;
|
||||
case 8:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_SEQUENTIAL);
|
||||
break;
|
||||
case 9:
|
||||
corsair->SetEffect(CORSAIR_PRO_MODE_STATIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetCustomMode()
|
||||
{
|
||||
corsair->SetCustom();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
corsair->SetAllColors(red, grn, blu);
|
||||
corsair->ApplyColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
corsair->SetLEDColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
corsair->ApplyColors();
|
||||
}
|
||||
|
||||
void RGBController_CorsairPro::SetLED(int led, RGBColor color)
|
||||
{
|
||||
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::UpdateLEDs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RGBController_CorsairPro::RGBController_CorsairPro(CorsairProController* corsair_ptr)
|
||||
{
|
||||
corsair = corsair_ptr;
|
||||
|
||||
name = corsair->GetDeviceName();
|
||||
|
||||
mode corsair_modes[CORSAIR_PRO_NUMBER_MODES];
|
||||
|
||||
corsair_modes[0].name = "Color Shift";
|
||||
corsair_modes[1].name = "Color Pulse";
|
||||
corsair_modes[2].name = "Rainbow Wave";
|
||||
corsair_modes[3].name = "Color Wave";
|
||||
corsair_modes[4].name = "Visor";
|
||||
corsair_modes[5].name = "Rain";
|
||||
corsair_modes[6].name = "Marquee";
|
||||
corsair_modes[7].name = "Rainbow";
|
||||
corsair_modes[8].name = "Sequential";
|
||||
corsair_modes[9].name = "Static";
|
||||
|
||||
for (int i = 0; i < CORSAIR_PRO_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(corsair_modes[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
{
|
||||
led* new_led = new led();
|
||||
|
||||
new_led->name = "Corsair Pro LED";
|
||||
|
||||
leds.push_back(*new_led);
|
||||
colors.push_back(0x00000000);
|
||||
}
|
||||
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Corsair Pro Zone";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
|
||||
std::vector<int> zone_row;
|
||||
|
||||
for (int i = 0; i < corsair->GetLEDCount(); i++)
|
||||
{
|
||||
zone_row.push_back(i);
|
||||
}
|
||||
|
||||
new_zone.map.push_back(zone_row);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_CorsairPro.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| Corsair Vengeance Pro RGB driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/30/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "CorsairProController.h"
|
||||
|
||||
class RGBController_CorsairPro : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_CorsairPro(CorsairProController* corsair_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
CorsairProController* corsair;
|
||||
};
|
||||
@@ -0,0 +1,193 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LEDStrip.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| E1.31 Streaming ACN interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 10/18/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_E131.h"
|
||||
#include <e131.h>
|
||||
#include <math.h>
|
||||
|
||||
RGBController_E131::RGBController_E131(std::vector<E131Device> device_list)
|
||||
{
|
||||
name = "E1.31 Streaming ACN Device";
|
||||
|
||||
devices = device_list;
|
||||
|
||||
unsigned int led_zone_idx = 0;
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
|
||||
sockfd = e131_socket();
|
||||
|
||||
for (int i = 0; i < devices.size(); i++)
|
||||
{
|
||||
/*-----------------------------------------*\
|
||||
| Add LEDs |
|
||||
\*-----------------------------------------*/
|
||||
for (int led_idx = 0; led_idx < devices[i].num_leds; led_idx++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
led new_led;
|
||||
new_led.name = devices[i].name + " LED";
|
||||
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 (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 );
|
||||
|
||||
for (int univ_idx = 0; univ_idx < total_universes; univ_idx++)
|
||||
{
|
||||
unsigned int universe = devices[i].start_universe + univ_idx;
|
||||
bool universe_exists = false;
|
||||
|
||||
for (int pkt_idx = 0; pkt_idx < packets.size(); pkt_idx++)
|
||||
{
|
||||
if(universes[pkt_idx] == universe)
|
||||
{
|
||||
universe_exists = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!universe_exists)
|
||||
{
|
||||
e131_packet_t packet;
|
||||
e131_addr_t dest_addr;
|
||||
|
||||
e131_pkt_init(&packet, universe, 512);
|
||||
e131_multicast_dest(&dest_addr, universe, E131_DEFAULT_PORT);
|
||||
|
||||
packets.push_back(packet);
|
||||
universes.push_back(universe);
|
||||
dest_addrs.push_back(dest_addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int RGBController_E131::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_E131::SetMode(int mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_E131::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_E131::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_E131::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
colors[zones[zone].map[x][y]] = color;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_E131::SetLED(int led, RGBColor color)
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_E131::UpdateLEDs()
|
||||
{
|
||||
int color_idx = 0;
|
||||
|
||||
for(int device_idx = 0; device_idx < devices.size(); device_idx++)
|
||||
{
|
||||
unsigned int total_universes = ceil( ( ( devices[device_idx].num_leds * 3 ) + devices[device_idx].start_channel ) / 512.0f );
|
||||
unsigned int channel_idx = devices[device_idx].start_channel;
|
||||
unsigned int led_idx = 0;
|
||||
unsigned int rgb_idx = 0;
|
||||
bool done = false;
|
||||
|
||||
for (int univ_idx = 0; univ_idx < total_universes; univ_idx++)
|
||||
{
|
||||
unsigned int universe = devices[device_idx].start_universe + univ_idx;
|
||||
|
||||
for(int packet_idx = 0; packet_idx < packets.size(); packet_idx++)
|
||||
{
|
||||
if(!done && (universes[packet_idx] == universe))
|
||||
{
|
||||
while(!done && (channel_idx <= 512))
|
||||
{
|
||||
switch(rgb_idx)
|
||||
{
|
||||
case 0:
|
||||
packets[packet_idx].dmp.prop_val[channel_idx] = RGBGetRValue( colors[color_idx] );
|
||||
rgb_idx = 1;
|
||||
break;
|
||||
case 1:
|
||||
packets[packet_idx].dmp.prop_val[channel_idx] = RGBGetGValue( colors[color_idx] );
|
||||
rgb_idx = 2;
|
||||
break;
|
||||
case 2:
|
||||
packets[packet_idx].dmp.prop_val[channel_idx] = RGBGetBValue( colors[color_idx] );
|
||||
rgb_idx = 0;
|
||||
led_idx++;
|
||||
color_idx++;
|
||||
break;
|
||||
}
|
||||
|
||||
if(led_idx >= devices[device_idx].num_leds)
|
||||
{
|
||||
done = true;
|
||||
}
|
||||
|
||||
channel_idx++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
channel_idx = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for(int packet_idx = 0; packet_idx < packets.size(); packet_idx++)
|
||||
{
|
||||
e131_send(sockfd, &packets[packet_idx], &dest_addrs[packet_idx]);
|
||||
packets[packet_idx].frame.seq_number++;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_E131.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| E1.31 Streaming ACN interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 10/18/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include <e131.h>
|
||||
|
||||
typedef unsigned int e131_rgb_order;
|
||||
|
||||
enum
|
||||
{
|
||||
E131_RGB_ORDER_RGB,
|
||||
E131_RGB_ORDER_RBG,
|
||||
E131_RGB_ORDER_GRB,
|
||||
E131_RGB_ORDER_GBR,
|
||||
E131_RGB_ORDER_BRG,
|
||||
E131_RGB_ORDER_BGR
|
||||
};
|
||||
|
||||
struct E131Device
|
||||
{
|
||||
std::string name;
|
||||
unsigned int num_leds;
|
||||
unsigned int start_universe;
|
||||
unsigned int start_channel;
|
||||
e131_rgb_order rgb_order;
|
||||
zone_type type;
|
||||
};
|
||||
|
||||
class RGBController_E131 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_E131(std::vector<E131Device> device_list);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
std::vector<E131Device> devices;
|
||||
std::vector<e131_packet_t> packets;
|
||||
std::vector<e131_addr_t> dest_addrs;
|
||||
std::vector<unsigned int> universes;
|
||||
int sockfd;
|
||||
};
|
||||
@@ -0,0 +1,86 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HuePlus.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for NZXT Hue+ |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/20/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_HuePlus.h"
|
||||
|
||||
|
||||
RGBController_HuePlus::RGBController_HuePlus(HuePlusController* hueplus_ptr)
|
||||
{
|
||||
strip = hueplus_ptr;
|
||||
|
||||
name = "LED Strip";
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
|
||||
for (int i = 0; i < strip->num_leds; i++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
led new_led;
|
||||
new_led.name = "LED Strip";
|
||||
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);
|
||||
}
|
||||
|
||||
int RGBController_HuePlus::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetMode(int mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::SetLED(int led, RGBColor color)
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_HuePlus::UpdateLEDs()
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HuePlus.h |
|
||||
| |
|
||||
| Generic RGB Interface for NZXT Hue+ |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/20/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "serial_port.h"
|
||||
#include "HuePlusController.h"
|
||||
|
||||
class RGBController_HuePlus : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HuePlus(HuePlusController* hueplus_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
HuePlusController* strip;
|
||||
};
|
||||
@@ -0,0 +1,112 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HyperX.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| HyperX Predator RGB interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/29/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_HyperX.h"
|
||||
|
||||
int RGBController_HyperX::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetMode(int mode)
|
||||
{
|
||||
hyperx->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetCustomMode()
|
||||
{
|
||||
hyperx->SetMode(HYPERX_MODE_STATIC);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
hyperx->SetAllColors(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
hyperx->SetLEDColor(zones[zone].map[x][y], red, grn, blu);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_HyperX::SetLED(int led, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
hyperx->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_HyperX::UpdateLEDs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
RGBController_HyperX::RGBController_HyperX(HyperXController* hyperx_ptr)
|
||||
{
|
||||
hyperx = hyperx_ptr;
|
||||
|
||||
name = hyperx->GetDeviceName();
|
||||
|
||||
mode hyperx_modes[HYPERX_NUMBER_MODES];
|
||||
|
||||
hyperx_modes[0].name = "Static";
|
||||
hyperx_modes[1].name = "Rainbow";
|
||||
hyperx_modes[2].name = "Comet";
|
||||
hyperx_modes[3].name = "Heartbeat";
|
||||
hyperx_modes[4].name = "Spectrum Cycle";
|
||||
hyperx_modes[5].name = "Breathing";
|
||||
hyperx_modes[6].name = "Bounce";
|
||||
hyperx_modes[7].name = "Blink";
|
||||
|
||||
for (int i = 0; i < HYPERX_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(hyperx_modes[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < hyperx->GetLEDCount(); i++)
|
||||
{
|
||||
led* new_led = new led();
|
||||
|
||||
new_led->name = "HyperX LED";
|
||||
|
||||
leds.push_back(*new_led);
|
||||
colors.push_back(0x00000000);
|
||||
}
|
||||
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "HyperX Zone";
|
||||
new_zone.type = ZONE_TYPE_SINGLE;
|
||||
|
||||
std::vector<int> zone_row;
|
||||
|
||||
for (int i = 0; i < hyperx->GetLEDCount(); i++)
|
||||
{
|
||||
zone_row.push_back(i);
|
||||
}
|
||||
|
||||
new_zone.map.push_back(zone_row);
|
||||
|
||||
zones.push_back(new_zone);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_HyperX.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| HyperX Predator RGB interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/29/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "HyperXController.h"
|
||||
|
||||
class RGBController_HyperX : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_HyperX(HyperXController* hyperx_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
HyperXController* hyperx;
|
||||
};
|
||||
@@ -0,0 +1,87 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LEDStrip.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| KeyboardVisualizer LED strip interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/20/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_LEDStrip.h"
|
||||
|
||||
|
||||
RGBController_LEDStrip::RGBController_LEDStrip(LEDStripController* ledstrip_ptr)
|
||||
{
|
||||
strip = ledstrip_ptr;
|
||||
|
||||
name = "LED Strip";
|
||||
|
||||
mode led_mode;
|
||||
led_mode.name = "Custom";
|
||||
modes.push_back(led_mode);
|
||||
|
||||
for (int i = 0; i < strip->num_leds; i++)
|
||||
{
|
||||
colors.push_back(0x00000000);
|
||||
led new_led;
|
||||
new_led.name = "LED Strip";
|
||||
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);
|
||||
}
|
||||
|
||||
int RGBController_LEDStrip::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetMode(int mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::SetLED(int led, RGBColor color)
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
|
||||
void RGBController_LEDStrip::UpdateLEDs()
|
||||
{
|
||||
strip->SetLEDs(colors);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_LEDStrip.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenAuraSDK |
|
||||
| KeyboardVisualizer LED strip interface |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/20/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "serial_port.h"
|
||||
#include "LEDStripController.h"
|
||||
|
||||
class RGBController_LEDStrip : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_LEDStrip(LEDStripController* ledstrip_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
LEDStripController* strip;
|
||||
};
|
||||
@@ -0,0 +1,370 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_OpenRazer.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRazer |
|
||||
| kernel drivers for Chroma peripherals |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/15/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_OpenRazer.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
int RGBController_OpenRazer::GetMode()
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetMode(int mode)
|
||||
{
|
||||
char update_value = 1;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case RAZER_TYPE_MATRIX_FRAME:
|
||||
case RAZER_TYPE_MATRIX_NOFRAME:
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
matrix_effect_custom.write(&update_value, 1);
|
||||
matrix_effect_custom.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_OFF:
|
||||
matrix_effect_none.write(&update_value, 1);
|
||||
matrix_effect_none.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_STATIC:
|
||||
break;
|
||||
|
||||
case RAZER_MODE_BREATHING:
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
matrix_effect_spectrum.write(&update_value, 1);
|
||||
matrix_effect_spectrum.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_WAVE:
|
||||
matrix_effect_wave.write(&update_value, 1);
|
||||
matrix_effect_wave.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_REACTIVE:
|
||||
matrix_effect_reactive.write(&update_value, 1);
|
||||
matrix_effect_reactive.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_TYPE_NOMATRIX:
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case RAZER_MODE_CUSTOM:
|
||||
update_value = 0;
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
|
||||
case RAZER_MODE_SPECTRUM_CYCLE:
|
||||
update_value = '4';
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetCustomMode()
|
||||
{
|
||||
SetMode(RAZER_MODE_CUSTOM);
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::UpdateLEDs()
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case RAZER_TYPE_MATRIX_FRAME:
|
||||
case RAZER_TYPE_MATRIX_NOFRAME:
|
||||
case RAZER_TYPE_MATRIX_STATIC:
|
||||
{
|
||||
char update_value = 1;
|
||||
|
||||
for (int row = 0; row < matrix_rows; row++)
|
||||
{
|
||||
unsigned int output_array_size;
|
||||
unsigned int output_offset;
|
||||
unsigned int row_offset = (row * matrix_cols);
|
||||
|
||||
if(type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
output_array_size = 3 + (matrix_cols* 3);
|
||||
output_offset = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
output_array_size = 3;
|
||||
output_offset = 0;
|
||||
}
|
||||
|
||||
char output_array[output_array_size];
|
||||
|
||||
if(type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
output_array[0] = row;
|
||||
output_array[1] = 0;
|
||||
output_array[2] = matrix_cols - 1;
|
||||
}
|
||||
|
||||
for(int col = 0; col < matrix_cols; col++)
|
||||
{
|
||||
unsigned int color_idx = col + row_offset;
|
||||
output_array[(col * 3) + 0 + output_offset] = (char)RGBGetRValue(colors[color_idx]);
|
||||
output_array[(col * 3) + 1 + output_offset] = (char)RGBGetGValue(colors[color_idx]);
|
||||
output_array[(col * 3) + 2 + output_offset] = (char)RGBGetBValue(colors[color_idx]);
|
||||
}
|
||||
|
||||
if(type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
matrix_custom_frame.write(output_array, output_array_size);
|
||||
matrix_custom_frame.flush();
|
||||
}
|
||||
else if(type == RAZER_TYPE_MATRIX_NOFRAME)
|
||||
{
|
||||
matrix_effect_custom.write(output_array, output_array_size);
|
||||
matrix_effect_custom.flush();
|
||||
}
|
||||
else
|
||||
{
|
||||
matrix_effect_static.write(output_array, output_array_size);
|
||||
matrix_effect_static.flush();
|
||||
}
|
||||
}
|
||||
|
||||
if(type == RAZER_TYPE_MATRIX_FRAME)
|
||||
{
|
||||
matrix_effect_custom.write(&update_value, 1);
|
||||
matrix_effect_custom.flush();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_TYPE_NOMATRIX:
|
||||
{
|
||||
unsigned int output_array_size = 3;
|
||||
char output_array[output_array_size];
|
||||
char update_value = 0;
|
||||
|
||||
output_array[0] = (char)RGBGetRValue(colors[0]);
|
||||
output_array[1] = (char)RGBGetGValue(colors[0]);
|
||||
output_array[2] = (char)RGBGetBValue(colors[0]);
|
||||
logo_led_rgb.write(output_array, output_array_size);
|
||||
|
||||
output_array[0] = (char)RGBGetRValue(colors[1]);
|
||||
output_array[1] = (char)RGBGetGValue(colors[1]);
|
||||
output_array[2] = (char)RGBGetBValue(colors[1]);
|
||||
scroll_led_rgb.write(output_array, output_array_size);
|
||||
|
||||
logo_led_rgb.flush();
|
||||
scroll_led_rgb.flush();
|
||||
|
||||
logo_led_effect.write(&update_value, 1);
|
||||
scroll_led_effect.write(&update_value, 1);
|
||||
logo_led_effect.flush();
|
||||
scroll_led_effect.flush();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for(int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
colors[zones[zone].map[x][y]] = color;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetLED(int led, RGBColor color)
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
static std::string GetDeviceTypeString(std::string dev_path)
|
||||
{
|
||||
// Read device_type for device name string
|
||||
std::string dev_type_path = dev_path + "/device_type";
|
||||
std::ifstream dev_type_file;
|
||||
std::string ret_str;
|
||||
|
||||
dev_type_file.open(dev_type_path);
|
||||
std::getline(dev_type_file, ret_str);
|
||||
dev_type_file.close();
|
||||
|
||||
return(ret_str);
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetupMatrixDevice(std::string dev_path, unsigned int rows, unsigned int cols)
|
||||
{
|
||||
matrix_custom_frame.open(dev_path + "/matrix_custom_frame");
|
||||
matrix_effect_custom.open(dev_path + "/matrix_effect_custom");
|
||||
matrix_effect_breath.open(dev_path + "/matrix_effect_breath");
|
||||
matrix_effect_none.open(dev_path + "/matrix_effect_none");
|
||||
matrix_effect_reactive.open(dev_path + "/matrix_effect_reactive");
|
||||
matrix_effect_spectrum.open(dev_path + "/matrix_effect_spectrum");
|
||||
matrix_effect_static.open(dev_path + "/matrix_effect_static");
|
||||
matrix_effect_wave.open(dev_path + "/matrix_effect_wave");
|
||||
|
||||
if(!matrix_custom_frame)
|
||||
{
|
||||
if(!matrix_effect_custom)
|
||||
{
|
||||
type = RAZER_TYPE_MATRIX_STATIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = RAZER_TYPE_MATRIX_NOFRAME;
|
||||
}
|
||||
|
||||
matrix_rows = 1;
|
||||
matrix_cols = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = RAZER_TYPE_MATRIX_FRAME;
|
||||
|
||||
matrix_rows = rows;
|
||||
matrix_cols = cols;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_OpenRazer::SetupNonMatrixDevice(std::string dev_path)
|
||||
{
|
||||
logo_led_effect.open(dev_path + "/logo_led_effect");
|
||||
logo_led_rgb.open(dev_path + "/logo_led_rgb");
|
||||
scroll_led_effect.open(dev_path + "/scroll_led_effect");
|
||||
scroll_led_rgb.open(dev_path + "/scroll_led_rgb");
|
||||
|
||||
type = RAZER_TYPE_NOMATRIX;
|
||||
}
|
||||
|
||||
RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
|
||||
{
|
||||
unsigned int led_count = 0;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Start device at -1. This indicates the device was not detected |
|
||||
\*-----------------------------------------------------------------*/
|
||||
device = -1;
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Get the device name from the OpenRazer driver |
|
||||
\*-----------------------------------------------------------------*/
|
||||
name = GetDeviceTypeString(dev_path);
|
||||
|
||||
/*-----------------------------------------------------------------*\
|
||||
| Loop through all known devices to look for a name match |
|
||||
\*-----------------------------------------------------------------*/
|
||||
for (int i = 0; i < RAZER_NUM_DEVICES; i++)
|
||||
{
|
||||
if (device_list[i]->name == name)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set device ID |
|
||||
\*---------------------------------------------------------*/
|
||||
device = i;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize modes |
|
||||
\*---------------------------------------------------------*/
|
||||
mode razer_modes[RAZER_NUM_MODES];
|
||||
|
||||
razer_modes[0].name = "Custom";
|
||||
razer_modes[1].name = "Off";
|
||||
razer_modes[2].name = "Static";
|
||||
razer_modes[3].name = "Breathing";
|
||||
razer_modes[4].name = "Spectrum Cycle";
|
||||
razer_modes[5].name = "Wave";
|
||||
razer_modes[6].name = "Reactive";
|
||||
|
||||
for (int i = 0; i < RAZER_NUM_MODES; i++)
|
||||
{
|
||||
modes.push_back(razer_modes[i]);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Initialize file descriptors |
|
||||
\*---------------------------------------------------------*/
|
||||
if(device_list[i]->matrix_type == true)
|
||||
{
|
||||
SetupMatrixDevice(dev_path, device_list[i]->rows, device_list[i]->cols);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetupNonMatrixDevice(dev_path);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Fill in zone information based on device table |
|
||||
\*---------------------------------------------------------*/
|
||||
for (int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_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;
|
||||
|
||||
for (int row_id = 0; row_id < device_list[i]->zones[zone_id]->rows; row_id++)
|
||||
{
|
||||
std::vector<int> new_zone_map;
|
||||
|
||||
for (int col_id = 0; col_id < device_list[i]->zones[zone_id]->cols; col_id++)
|
||||
{
|
||||
RGBColor new_color = 0x00000000;
|
||||
colors.push_back(new_color);
|
||||
|
||||
led* new_led = new led();
|
||||
new_led->name = device_list[i]->zones[zone_id]->name;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,935 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_OpenRazer.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRazer |
|
||||
| kernel drivers for Chroma peripherals |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 6/15/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <fstream>
|
||||
|
||||
#define RAZER_MAX_ZONES 6
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name;
|
||||
unsigned int type;
|
||||
unsigned int rows;
|
||||
unsigned int cols;
|
||||
} razer_zone;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name;
|
||||
bool matrix_type;
|
||||
unsigned int rows;
|
||||
unsigned int cols;
|
||||
const razer_zone* zones[RAZER_MAX_ZONES];
|
||||
} razer_device;
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| KEYBOARDS |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer BlackWidow Chroma |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 22 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone blackwidow_chroma_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
22
|
||||
};
|
||||
|
||||
static const razer_device blackwidow_chroma_device =
|
||||
{
|
||||
"Razer BlackWidow Chroma",
|
||||
true,
|
||||
6,
|
||||
22,
|
||||
{
|
||||
&blackwidow_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer BlackWidow Chroma Tournament Edition |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 22 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone blackwidow_chroma_te_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
22
|
||||
};
|
||||
|
||||
static const razer_device blackwidow_chroma_te_device =
|
||||
{
|
||||
"Razer BlackWidow Chroma Tournament Edition",
|
||||
true,
|
||||
6,
|
||||
22,
|
||||
{
|
||||
&blackwidow_chroma_te_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Ornata Chroma |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 22 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone ornata_chroma_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
22
|
||||
};
|
||||
|
||||
static const razer_device ornata_chroma_device =
|
||||
{
|
||||
"Razer Ornata Chroma",
|
||||
true,
|
||||
6,
|
||||
22,
|
||||
{
|
||||
&ornata_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer DeathStalker Chroma |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Linear |
|
||||
| 12 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone deathstalker_chroma_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
12
|
||||
};
|
||||
|
||||
static const razer_device deathstalker_chroma_device =
|
||||
{
|
||||
"Razer DeathStalker Chroma",
|
||||
true,
|
||||
1,
|
||||
12,
|
||||
{
|
||||
&deathstalker_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| LAPTOPS |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Blade Stealth |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 16 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone blade_stealth_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
16
|
||||
};
|
||||
|
||||
static const razer_device blade_stealth_device =
|
||||
{
|
||||
"Razer Blade Stealth",
|
||||
true,
|
||||
6,
|
||||
16,
|
||||
{
|
||||
&blade_stealth_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Blade Pro (Late 2016) |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 25 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone blade_pro_late_2016_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
25
|
||||
};
|
||||
|
||||
static const razer_device blade_pro_late_2016_device =
|
||||
{
|
||||
"Razer Blade Pro (Late 2016)",
|
||||
true,
|
||||
6,
|
||||
25,
|
||||
{
|
||||
&blade_pro_late_2016_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Blade Pro (2017) |
|
||||
| |
|
||||
| Zone "Keyboard" |
|
||||
| Matrix |
|
||||
| 6 Rows, 25 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone blade_pro_2017_zone =
|
||||
{
|
||||
"Keyboard",
|
||||
ZONE_TYPE_MATRIX,
|
||||
6,
|
||||
25
|
||||
};
|
||||
|
||||
static const razer_device blade_pro_2017_device =
|
||||
{
|
||||
"Razer Blade Pro (2017)",
|
||||
true,
|
||||
6,
|
||||
25,
|
||||
{
|
||||
&blade_pro_2017_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| MICE |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Mamba Tournament Edition |
|
||||
| |
|
||||
| Zone "Left" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| |
|
||||
| Zone "Right" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| |
|
||||
| Zone "Logo" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Scroll Wheel" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone mamba_te_left_zone =
|
||||
{
|
||||
"Left LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
7
|
||||
};
|
||||
|
||||
static const razer_zone mamba_te_right_zone =
|
||||
{
|
||||
"Right LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
7
|
||||
};
|
||||
|
||||
static const razer_zone mamba_te_logo_zone =
|
||||
{
|
||||
"Logo",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone mamba_te_scroll_wheel_zone =
|
||||
{
|
||||
"Scroll Wheel",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device mamba_te_device =
|
||||
{
|
||||
"Razer Mamba Tournament Edition",
|
||||
true,
|
||||
1,
|
||||
16,
|
||||
{
|
||||
&mamba_te_left_zone,
|
||||
&mamba_te_right_zone,
|
||||
&mamba_te_logo_zone,
|
||||
&mamba_te_scroll_wheel_zone,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Diamondback Chroma |
|
||||
| |
|
||||
| Zone "Right" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| |
|
||||
| Zone "Bottom" |
|
||||
| Linear |
|
||||
| 5 LEDs |
|
||||
| |
|
||||
| Zone "Left" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| |
|
||||
| Zone "Logo" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Scroll Wheel" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone diamondback_chroma_right_zone =
|
||||
{
|
||||
"Right LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
7
|
||||
};
|
||||
|
||||
static const razer_zone diamondback_chroma_bottom_zone =
|
||||
{
|
||||
"Bottom LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
5
|
||||
};
|
||||
|
||||
static const razer_zone diamondback_chroma_left_zone =
|
||||
{
|
||||
"Left LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
7
|
||||
};
|
||||
|
||||
static const razer_zone diamondback_chroma_logo_zone =
|
||||
{
|
||||
"Logo",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone diamondback_chroma_scroll_wheel_zone =
|
||||
{
|
||||
"Scroll Wheel",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device diamondback_chroma_device =
|
||||
{
|
||||
"Razer Diamondback Chroma",
|
||||
true,
|
||||
1,
|
||||
21,
|
||||
{
|
||||
&diamondback_chroma_right_zone,
|
||||
&diamondback_chroma_bottom_zone,
|
||||
&diamondback_chroma_left_zone,
|
||||
&diamondback_chroma_logo_zone,
|
||||
&diamondback_chroma_scroll_wheel_zone,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer DeathAdder Chroma |
|
||||
| |
|
||||
| Zone "Logo" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Scroll Wheel" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone deathadder_chroma_logo_zone =
|
||||
{
|
||||
"Logo",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone deathadder_chroma_scroll_wheel_zone =
|
||||
{
|
||||
"Scroll Wheel",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device deathadder_chroma_device =
|
||||
{
|
||||
"Razer DeathAdder Chroma",
|
||||
false,
|
||||
1,
|
||||
2,
|
||||
{
|
||||
&deathadder_chroma_logo_zone,
|
||||
&deathadder_chroma_scroll_wheel_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Naga Chroma |
|
||||
| |
|
||||
| Zone "Logo" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Scroll Wheel" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Numpad" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone naga_chroma_logo_zone =
|
||||
{
|
||||
"Logo",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone naga_chroma_scroll_wheel_zone =
|
||||
{
|
||||
"Scroll Wheel",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone naga_chroma_numpad_zone =
|
||||
{
|
||||
"Numpad",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device naga_chroma_device =
|
||||
{
|
||||
"Razer Naga Chroma",
|
||||
false,
|
||||
1,
|
||||
3,
|
||||
{
|
||||
&naga_chroma_logo_zone,
|
||||
&naga_chroma_scroll_wheel_zone,
|
||||
&naga_chroma_numpad_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| KEYPADS |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Orbweaver Chroma |
|
||||
| |
|
||||
| Zone "Keypad" |
|
||||
| Matrix |
|
||||
| 4 Rows, 5 Columns |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone orbweaver_chroma_zone =
|
||||
{
|
||||
"Keypad",
|
||||
ZONE_TYPE_MATRIX,
|
||||
4,
|
||||
5
|
||||
};
|
||||
|
||||
static const razer_device orbweaver_chroma_device =
|
||||
{
|
||||
"Razer Orbweaver Chroma",
|
||||
true,
|
||||
6,
|
||||
25,
|
||||
{
|
||||
&orbweaver_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Tartarus Chroma |
|
||||
| |
|
||||
| Zone "Keypad" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone tartarus_chroma_zone =
|
||||
{
|
||||
"Keypad",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device tartarus_chroma_device =
|
||||
{
|
||||
"Razer Tartarus Chroma",
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
{
|
||||
&tartarus_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| MOUSEMATS |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Firefly |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 15 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone firefly_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
15
|
||||
};
|
||||
|
||||
static const razer_device firefly_device =
|
||||
{
|
||||
"Razer Firefly",
|
||||
true,
|
||||
1,
|
||||
15,
|
||||
{
|
||||
&firefly_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Goliathus Extended |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone goliathus_extended_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device goliathus_extended_device =
|
||||
{
|
||||
"Razer Goliathus Extended",
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
{
|
||||
&goliathus_extended_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| HEADSETS |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Kraken 7.1 Chroma |
|
||||
| |
|
||||
| Zone "Headset" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone kraken_chroma_zone =
|
||||
{
|
||||
"Headset",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device kraken_chroma_device =
|
||||
{
|
||||
"Razer Kraken 7.1 Chroma",
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
{
|
||||
&kraken_chroma_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Kraken 7.1 V2 |
|
||||
| |
|
||||
| Zone "Headset" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone kraken_v2_zone =
|
||||
{
|
||||
"Headset",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device kraken_v2_device =
|
||||
{
|
||||
"Razer Kraken 7.1 V2",
|
||||
true,
|
||||
1,
|
||||
1,
|
||||
{
|
||||
&kraken_v2_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| OTHER |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Core |
|
||||
| |
|
||||
| Zone "Side Window Lights" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 8 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone core_side_zone =
|
||||
{
|
||||
"Side Window Lights",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone core_led_strip_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
8
|
||||
};
|
||||
|
||||
static const razer_device core_device =
|
||||
{
|
||||
"Razer Core",
|
||||
true,
|
||||
1,
|
||||
9,
|
||||
{
|
||||
&core_side_zone,
|
||||
&core_led_strip_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Chroma Mug Holder |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 15 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone mug_holder_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
15
|
||||
};
|
||||
|
||||
static const razer_device mug_holder_device =
|
||||
{
|
||||
"Razer Chroma Mug Holder",
|
||||
true,
|
||||
1,
|
||||
15,
|
||||
{
|
||||
&mug_holder_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Razer Chroma HDK |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone chromahdk_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
1,
|
||||
16
|
||||
};
|
||||
|
||||
static const razer_device chromahdk_device =
|
||||
{
|
||||
"Razer Chroma HDK",
|
||||
true,
|
||||
4,
|
||||
16,
|
||||
{
|
||||
&chromahdk_zone,
|
||||
&chromahdk_zone,
|
||||
&chromahdk_zone,
|
||||
&chromahdk_zone,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
| DEVICE MASTER LIST |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
#define RAZER_NUM_DEVICES (sizeof(device_list) / sizeof(device_list[ 0 ]))
|
||||
|
||||
static const razer_device* device_list[] =
|
||||
{
|
||||
/*-----------------------------------------------------------------*\
|
||||
| KEYBOARDS |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&blackwidow_chroma_device,
|
||||
&blackwidow_chroma_te_device,
|
||||
&ornata_chroma_device,
|
||||
&deathstalker_chroma_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| LAPTOPS |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&blade_stealth_device,
|
||||
&blade_pro_late_2016_device,
|
||||
&blade_pro_2017_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| MICE |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&mamba_te_device,
|
||||
&diamondback_chroma_device,
|
||||
&deathadder_chroma_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| KEYPADS |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&orbweaver_chroma_device,
|
||||
&tartarus_chroma_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| MOUSEMATS |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&firefly_device,
|
||||
&goliathus_extended_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| HEADSETS |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&kraken_chroma_device,
|
||||
&kraken_v2_device,
|
||||
/*-----------------------------------------------------------------*\
|
||||
| OTHER |
|
||||
\*-----------------------------------------------------------------*/
|
||||
&core_device,
|
||||
&mug_holder_device,
|
||||
&chromahdk_device
|
||||
};
|
||||
|
||||
|
||||
class RGBController_OpenRazer : public RGBController
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
RAZER_MODE_CUSTOM,
|
||||
RAZER_MODE_OFF,
|
||||
RAZER_MODE_STATIC,
|
||||
RAZER_MODE_BREATHING,
|
||||
RAZER_MODE_SPECTRUM_CYCLE,
|
||||
RAZER_MODE_WAVE,
|
||||
RAZER_MODE_REACTIVE,
|
||||
RAZER_NUM_MODES
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RAZER_TYPE_MATRIX_FRAME,
|
||||
RAZER_TYPE_MATRIX_NOFRAME,
|
||||
RAZER_TYPE_MATRIX_STATIC,
|
||||
RAZER_TYPE_NOMATRIX,
|
||||
RAZER_NUM_TYPES
|
||||
};
|
||||
|
||||
public:
|
||||
RGBController_OpenRazer(std::string dev_path);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
int device;
|
||||
|
||||
private:
|
||||
void SetupMatrixDevice(std::string dev_path, unsigned int rows, unsigned int cols);
|
||||
void SetupNonMatrixDevice(std::string dev_path);
|
||||
|
||||
unsigned int type;
|
||||
unsigned int matrix_rows;
|
||||
unsigned int matrix_cols;
|
||||
|
||||
//OpenRazer Sysfs Entries for Matrix Devices
|
||||
std::ofstream matrix_custom_frame;
|
||||
std::ofstream matrix_effect_custom;
|
||||
std::ofstream matrix_effect_breath;
|
||||
std::ofstream matrix_effect_none;
|
||||
std::ofstream matrix_effect_reactive;
|
||||
std::ofstream matrix_effect_spectrum;
|
||||
std::ofstream matrix_effect_static;
|
||||
std::ofstream matrix_effect_wave;
|
||||
|
||||
//OpenRazer Sysfs Entries for Non-Matrix Devices
|
||||
std::ofstream logo_led_effect;
|
||||
std::ofstream logo_led_rgb;
|
||||
std::ofstream scroll_led_effect;
|
||||
std::ofstream scroll_led_rgb;
|
||||
};
|
||||
@@ -0,0 +1,112 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Polychrome.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| ASRock ASR LED and Polychrome RGB Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/15/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_Polychrome.h"
|
||||
|
||||
int RGBController_Polychrome::GetMode()
|
||||
{
|
||||
return(polychrome->GetMode());
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetMode(int mode)
|
||||
{
|
||||
polychrome->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetCustomMode()
|
||||
{
|
||||
polychrome->SetMode(POLYCHROME_MODE_STATIC);
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
polychrome->SetAllColors(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
polychrome->SetLEDColor(zone, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::SetLED(int led, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
polychrome->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_Polychrome::UpdateLEDs()
|
||||
{
|
||||
for (int 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->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
static const char* polychrome_zone_names[] =
|
||||
{
|
||||
"Motherboard"
|
||||
};
|
||||
|
||||
RGBController_Polychrome::RGBController_Polychrome(PolychromeController* polychrome_ptr)
|
||||
{
|
||||
polychrome = polychrome_ptr;
|
||||
|
||||
name = polychrome->GetDeviceName();
|
||||
|
||||
mode polychrome_modes[POLYCHROME_NUM_MODES];
|
||||
|
||||
polychrome_modes[0].name = "Static";
|
||||
polychrome_modes[1].name = "Breathing";
|
||||
polychrome_modes[2].name = "Flashing";
|
||||
|
||||
for (int i = 0; i < POLYCHROME_NUM_MODES; i++)
|
||||
{
|
||||
modes.push_back(polychrome_modes[i]);
|
||||
}
|
||||
|
||||
// Search through all LEDs and create zones for each channel type
|
||||
for (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_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
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_Polychrome.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| ASRock ASR LED and Polychrome RGB Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/15/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "PolychromeController.h"
|
||||
|
||||
class RGBController_Polychrome : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Polychrome(PolychromeController* polychrome_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
PolychromeController* polychrome;
|
||||
};
|
||||
@@ -0,0 +1,113 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_RGBFusion.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| Gigabyte RGB Fusion Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/11/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_RGBFusion.h"
|
||||
|
||||
int RGBController_RGBFusion::GetMode()
|
||||
{
|
||||
return(rgb_fusion->GetMode());
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::SetMode(int mode)
|
||||
{
|
||||
rgb_fusion->SetMode(mode);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::SetCustomMode()
|
||||
{
|
||||
rgb_fusion->SetMode(RGB_FUSION_MODE_STATIC);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
rgb_fusion->SetAllColors(red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
rgb_fusion->SetLEDColor(zone, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::SetLED(int led, RGBColor color)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(color);
|
||||
unsigned char grn = RGBGetGValue(color);
|
||||
unsigned char blu = RGBGetBValue(color);
|
||||
|
||||
rgb_fusion->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
|
||||
void RGBController_RGBFusion::UpdateLEDs()
|
||||
{
|
||||
for (int led = 0; led < colors.size(); led++)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
|
||||
rgb_fusion->SetLEDColor(led, red, grn, blu);
|
||||
}
|
||||
}
|
||||
|
||||
static const char* rgb_fusion_zone_names[] =
|
||||
{
|
||||
"Motherboard",
|
||||
"RGB Header"
|
||||
};
|
||||
|
||||
RGBController_RGBFusion::RGBController_RGBFusion(RGBFusionController* rgb_fusion_ptr)
|
||||
{
|
||||
rgb_fusion = rgb_fusion_ptr;
|
||||
|
||||
name = rgb_fusion->GetDeviceName();
|
||||
|
||||
mode rgb_fusion_modes[RGB_FUSION_NUMBER_MODES];
|
||||
|
||||
rgb_fusion_modes[0].name = "Static";
|
||||
rgb_fusion_modes[1].name = "Breathing";
|
||||
rgb_fusion_modes[2].name = "Flashing";
|
||||
|
||||
for (int i = 0; i < RGB_FUSION_NUMBER_MODES; i++)
|
||||
{
|
||||
modes.push_back(rgb_fusion_modes[i]);
|
||||
}
|
||||
|
||||
// Search through all LEDs and create zones for each channel type
|
||||
for (int i = 0; i < rgb_fusion->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 = rgb_fusion_zone_names[i];
|
||||
new_led->name = rgb_fusion_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
|
||||
zones.push_back(*new_zone);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_RGBFusion.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| Gigabyte RGB Fusion Driver |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 12/11/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "RGBFusionController.h"
|
||||
|
||||
class RGBController_RGBFusion : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RGBFusion(RGBFusionController* rgb_fusion_ptr);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
RGBFusionController* rgb_fusion;
|
||||
};
|
||||
@@ -0,0 +1,189 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_RazerChromaSDK.h |
|
||||
| |
|
||||
| Generic RGB Interface for official Razer |
|
||||
| Chroma SDK |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/2/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_RazerChromaSDK.h"
|
||||
|
||||
CREATEEFFECT RGBController_RazerChromaSDK::CreateEffect = NULL;
|
||||
CREATEKEYBOARDEFFECT RGBController_RazerChromaSDK::CreateKeyboardEffect = NULL;
|
||||
CREATEMOUSEEFFECT RGBController_RazerChromaSDK::CreateMouseEffect = NULL;
|
||||
CREATEMOUSEPADEFFECT RGBController_RazerChromaSDK::CreateMousepadEffect = NULL;
|
||||
CREATEHEADSETEFFECT RGBController_RazerChromaSDK::CreateHeadsetEffect = NULL;
|
||||
CREATECHROMALINKEFFECT RGBController_RazerChromaSDK::CreateChromaLinkEffect = NULL;
|
||||
|
||||
RGBController_RazerChromaSDK::RGBController_RazerChromaSDK(unsigned int device_type, HMODULE* hModule)
|
||||
{
|
||||
unsigned int led_count = 0;
|
||||
|
||||
for (int i = 0; i < RAZER_NUM_DEVICES; i++)
|
||||
{
|
||||
if (device_list[i]->type == device_type)
|
||||
{
|
||||
name = device_list[i]->name;
|
||||
|
||||
for (int zone_id = 0; zone_id < RAZER_MAX_ZONES; zone_id++)
|
||||
{
|
||||
if (device_list[i]->zones[zone_id] != NULL)
|
||||
{
|
||||
device = device_list[i];
|
||||
|
||||
zone* new_zone = new zone();
|
||||
new_zone->name = device_list[i]->zones[zone_id]->name;
|
||||
new_zone->type = device_list[i]->zones[zone_id]->type;
|
||||
|
||||
std::vector<int> new_zone_map;
|
||||
|
||||
for (int led_id = 0; led_id < device_list[i]->zones[zone_id]->leds; led_id++)
|
||||
{
|
||||
RGBColor new_color = 0x00000000;
|
||||
colors.push_back(new_color);
|
||||
|
||||
led* new_led = new led();
|
||||
new_led->name = device_list[i]->zones[zone_id]->name;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(CreateEffect == NULL) CreateEffect = (CREATEEFFECT)GetProcAddress(*hModule, "CreateEffect");
|
||||
if(CreateKeyboardEffect == NULL) CreateKeyboardEffect = (CREATEKEYBOARDEFFECT)GetProcAddress(*hModule, "CreateKeyboardEffect");
|
||||
if(CreateMouseEffect == NULL) CreateMouseEffect = (CREATEMOUSEEFFECT)GetProcAddress(*hModule, "CreateMouseEffect");
|
||||
if(CreateMousepadEffect == NULL) CreateMousepadEffect = (CREATEMOUSEPADEFFECT)GetProcAddress(*hModule, "CreateMousepadEffect");
|
||||
if(CreateHeadsetEffect == NULL) CreateHeadsetEffect = (CREATEHEADSETEFFECT)GetProcAddress(*hModule, "CreateHeadsetEffect");
|
||||
if(CreateChromaLinkEffect == NULL) CreateChromaLinkEffect = (CREATECHROMALINKEFFECT)GetProcAddress(*hModule, "CreateChromaLinkEffect");
|
||||
}
|
||||
|
||||
int RGBController_RazerChromaSDK::GetMode()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::SetMode(int mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::SetCustomMode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::SetAllLEDs(RGBColor color)
|
||||
{
|
||||
for (int i = 0; i < colors.size(); i++)
|
||||
{
|
||||
colors[i] = color;
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::SetAllZoneLEDs(int zone, RGBColor color)
|
||||
{
|
||||
for (int x = 0; x < zones[zone].map.size(); x++)
|
||||
{
|
||||
for (int y = 0; y < zones[zone].map[x].size(); y++)
|
||||
{
|
||||
colors[zones[zone].map[x][y]] = color;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::SetLED(int led, RGBColor color)
|
||||
{
|
||||
colors[led] = color;
|
||||
|
||||
UpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_RazerChromaSDK::UpdateLEDs()
|
||||
{
|
||||
switch (device->type)
|
||||
{
|
||||
case RAZER_GENERIC_MOUSE:
|
||||
{
|
||||
ChromaSDK::Mouse::CUSTOM_EFFECT_TYPE2 MouseEffect = {};
|
||||
|
||||
std::vector<int> left_zone_map = zones[0].map[0];
|
||||
|
||||
for (int left = 1; left < 8; left++)
|
||||
{
|
||||
MouseEffect.Color[left][0] = colors[left_zone_map[left - 1]];
|
||||
}
|
||||
|
||||
std::vector<int> right_zone_map = zones[1].map[0];
|
||||
|
||||
for (int right = 1; right < 8; right++)
|
||||
{
|
||||
MouseEffect.Color[right][6] = colors[right_zone_map[right - 1]];
|
||||
}
|
||||
|
||||
std::vector<int> bottom_zone_map = zones[2].map[0];
|
||||
|
||||
for (int bottom = 1; bottom < 6; bottom++)
|
||||
{
|
||||
MouseEffect.Color[8][bottom] = colors[bottom_zone_map[bottom - 1]];
|
||||
}
|
||||
|
||||
std::vector<int> scroll_wheel_zone_map = zones[3].map[0];
|
||||
|
||||
MouseEffect.Color[2][3] = colors[scroll_wheel_zone_map[0]];
|
||||
|
||||
std::vector<int> logo_zone_map = zones[4].map[0];
|
||||
|
||||
MouseEffect.Color[7][3] = colors[logo_zone_map[0]];
|
||||
|
||||
std::vector<int> numpad_backlight_zone_map = zones[5].map[0];
|
||||
|
||||
MouseEffect.Color[4][3] = colors[numpad_backlight_zone_map[0]];
|
||||
|
||||
CreateMouseEffect(ChromaSDK::Mouse::CHROMA_CUSTOM2, &MouseEffect, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_GENERIC_MOUSEPAD:
|
||||
{
|
||||
ChromaSDK::Mousepad::CUSTOM_EFFECT_TYPE MousepadEffect = {};
|
||||
|
||||
for (int x = 0; x < 15; x++)
|
||||
{
|
||||
MousepadEffect.Color[x] = colors[x];
|
||||
}
|
||||
|
||||
CreateMousepadEffect(ChromaSDK::Mousepad::CHROMA_CUSTOM, &MousepadEffect, NULL);
|
||||
}
|
||||
break;
|
||||
|
||||
case RAZER_CHROMA_HDK:
|
||||
{
|
||||
ChromaSDK::CUSTOM_EFFECT_TYPE ChromaBoxEffect = {};
|
||||
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
for (int y = 0; y < 4; y++)
|
||||
{
|
||||
ChromaBoxEffect.Color[y][x] = colors[(y*16) + x];
|
||||
}
|
||||
}
|
||||
CreateEffect(ChromaSDK::CHROMABOX, ChromaSDK::CHROMA_CUSTOM, &ChromaBoxEffect, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_RazerChromaSDK.h |
|
||||
| |
|
||||
| Generic RGB Interface for official Razer |
|
||||
| Chroma SDK |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 9/2/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include <Windows.h>
|
||||
|
||||
#include "RzChromaSDKDefines.h"
|
||||
#include "RzChromaSDKTypes.h"
|
||||
#include "RzErrors.h"
|
||||
|
||||
using namespace ChromaSDK::Keyboard;
|
||||
|
||||
typedef RZRESULT(*INIT)(void);
|
||||
typedef RZRESULT(*UNINIT)(void);
|
||||
typedef RZRESULT(*CREATEEFFECT)(RZDEVICEID DeviceId, ChromaSDK::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
typedef RZRESULT(*CREATEKEYBOARDEFFECT)(ChromaSDK::Keyboard::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
typedef RZRESULT(*CREATEMOUSEEFFECT)(ChromaSDK::Mouse::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
typedef RZRESULT(*CREATEMOUSEPADEFFECT)(ChromaSDK::Mousepad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
typedef RZRESULT(*CREATEHEADSETEFFECT)(ChromaSDK::Headset::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
typedef RZRESULT(*CREATECHROMALINKEFFECT)(ChromaSDK::ChromaLink::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
|
||||
#define RAZER_MAX_ZONES 6
|
||||
#define RAZER_NUM_DEVICES 3
|
||||
|
||||
enum
|
||||
{
|
||||
RAZER_GENERIC_KEYBOARD,
|
||||
RAZER_GENERIC_MOUSE,
|
||||
RAZER_GENERIC_MOUSEPAD,
|
||||
RAZER_CHROMA_HDK
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
RAZER_MODE_CUSTOM,
|
||||
RAZER_MODE_OFF,
|
||||
RAZER_MODE_STATIC,
|
||||
RAZER_MODE_BREATHING,
|
||||
RAZER_MODE_SPECTRUM_CYCLE,
|
||||
RAZER_MODE_WAVE,
|
||||
RAZER_MODE_REACTIVE,
|
||||
RAZER_NUM_MODES
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name;
|
||||
unsigned int type;
|
||||
unsigned int leds;
|
||||
} razer_zone;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
std::string name;
|
||||
unsigned int type;
|
||||
const razer_zone* zones[RAZER_MAX_ZONES];
|
||||
} razer_device;
|
||||
|
||||
/*------------------------------------------------------------ *\
|
||||
| Razer Generic Mouse |
|
||||
| |
|
||||
| Zone "Left" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| |
|
||||
| Zone "Right" |
|
||||
| Linear |
|
||||
| 7 LEDs |
|
||||
| |
|
||||
| Zone "Bottom" |
|
||||
| Linear |
|
||||
| 5 LEDs |
|
||||
| |
|
||||
| Zone "Scroll Wheel" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Logo" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
| |
|
||||
| Zone "Numpad/Backlight" |
|
||||
| Single |
|
||||
| 1 LED |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone mouse_left_zone =
|
||||
{
|
||||
"Left LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
7
|
||||
};
|
||||
|
||||
static const razer_zone mouse_right_zone =
|
||||
{
|
||||
"Right LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
7
|
||||
};
|
||||
|
||||
static const razer_zone mouse_bottom_zone =
|
||||
{
|
||||
"Bottom LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
5
|
||||
};
|
||||
|
||||
static const razer_zone mouse_scroll_wheel_zone =
|
||||
{
|
||||
"Scroll Wheel",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone mouse_logo_zone =
|
||||
{
|
||||
"Logo",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_zone mouse_numpad_backlight_zone =
|
||||
{
|
||||
"Numpad/Backlight",
|
||||
ZONE_TYPE_SINGLE,
|
||||
1
|
||||
};
|
||||
|
||||
static const razer_device mouse_device =
|
||||
{
|
||||
"Razer Generic Mouse",
|
||||
RAZER_GENERIC_MOUSE,
|
||||
{
|
||||
&mouse_left_zone,
|
||||
&mouse_right_zone,
|
||||
&mouse_bottom_zone,
|
||||
&mouse_scroll_wheel_zone,
|
||||
&mouse_logo_zone,
|
||||
&mouse_numpad_backlight_zone
|
||||
}
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------ *\
|
||||
| Razer Generic Mousepad (Firefly, Mug Holder) |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 15 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone mousepad_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
15
|
||||
};
|
||||
|
||||
static const razer_device mousepad_device =
|
||||
{
|
||||
"Razer Generic Mousepad",
|
||||
RAZER_GENERIC_MOUSEPAD,
|
||||
{
|
||||
&mousepad_zone,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
/*------------------------------------------------------------ *\
|
||||
| Razer Chroma HDK |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
| |
|
||||
| Zone "LED Strip" |
|
||||
| Linear |
|
||||
| 16 LEDs |
|
||||
\*-------------------------------------------------------------*/
|
||||
static const razer_zone chromahdk_zone =
|
||||
{
|
||||
"LED Strip",
|
||||
ZONE_TYPE_LINEAR,
|
||||
16
|
||||
};
|
||||
|
||||
static const razer_device chromahdk_device =
|
||||
{
|
||||
"Razer Chroma HDK",
|
||||
RAZER_CHROMA_HDK,
|
||||
{
|
||||
&chromahdk_zone,
|
||||
&chromahdk_zone,
|
||||
&chromahdk_zone,
|
||||
&chromahdk_zone,
|
||||
NULL,
|
||||
NULL
|
||||
}
|
||||
};
|
||||
|
||||
static const razer_device* device_list[RAZER_NUM_DEVICES] =
|
||||
{
|
||||
&mouse_device,
|
||||
&mousepad_device,
|
||||
&chromahdk_device
|
||||
};
|
||||
|
||||
class RGBController_RazerChromaSDK : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_RazerChromaSDK(unsigned int device_type, HMODULE* hModule);
|
||||
int GetMode();
|
||||
void SetMode(int mode);
|
||||
void SetCustomMode();
|
||||
void SetAllLEDs(RGBColor color);
|
||||
void SetAllZoneLEDs(int zone, RGBColor color);
|
||||
void SetLED(int led, RGBColor color);
|
||||
void UpdateLEDs();
|
||||
|
||||
private:
|
||||
const razer_device* device;
|
||||
|
||||
static CREATEEFFECT CreateEffect;
|
||||
static CREATEKEYBOARDEFFECT CreateKeyboardEffect;
|
||||
static CREATEMOUSEEFFECT CreateMouseEffect;
|
||||
static CREATEMOUSEPADEFFECT CreateMousepadEffect;
|
||||
static CREATEHEADSETEFFECT CreateHeadsetEffect;
|
||||
static CREATECHROMALINKEFFECT CreateChromaLinkEffect;
|
||||
};
|
||||
@@ -0,0 +1,70 @@
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_RazerChromaSDK.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
static HMODULE hModule;
|
||||
|
||||
#include "RzChromaSDKDefines.h"
|
||||
#include "RzChromaSDKTypes.h"
|
||||
#include "RzErrors.h"
|
||||
|
||||
using namespace ChromaSDK::Keyboard;
|
||||
|
||||
typedef RZRESULT(*INIT)(void);
|
||||
typedef RZRESULT(*UNINIT)(void);
|
||||
typedef RZRESULT(*CREATEEFFECT)(RZDEVICEID DeviceId, ChromaSDK::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
typedef RZRESULT(*CREATEKEYBOARDEFFECT)(ChromaSDK::Keyboard::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
typedef RZRESULT(*CREATEMOUSEEFFECT)(ChromaSDK::Mouse::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
typedef RZRESULT(*CREATEMOUSEPADEFFECT)(ChromaSDK::Mousepad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
typedef RZRESULT(*CREATEHEADSETEFFECT)(ChromaSDK::Headset::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
typedef RZRESULT(*CREATECHROMALINKEFFECT)(ChromaSDK::ChromaLink::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId);
|
||||
|
||||
#ifdef _WIN64
|
||||
#define CHROMASDKDLL ("RzChromaSDK64.dll")
|
||||
#else
|
||||
#define CHROMASDKDLL ("RzChromaSDK.dll")
|
||||
#endif
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectRazerChromaSDKControllers *
|
||||
* *
|
||||
* Detect devices supported by the Razer Chroma SDK *
|
||||
* * *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectRazerChromaSDKControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
RGBController_RazerChromaSDK* razer_rgb;
|
||||
|
||||
// Dynamically loads the Chroma SDK library.
|
||||
hModule = LoadLibrary(CHROMASDKDLL);
|
||||
if (hModule)
|
||||
{
|
||||
INIT Init = (INIT)GetProcAddress(hModule, "Init");
|
||||
if (Init)
|
||||
{
|
||||
//Initialize the SDK
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
razer_rgb = new RGBController_RazerChromaSDK(RAZER_GENERIC_MOUSE, &hModule);
|
||||
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
|
||||
razer_rgb = new RGBController_RazerChromaSDK(RAZER_GENERIC_MOUSEPAD, &hModule);
|
||||
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
|
||||
razer_rgb = new RGBController_RazerChromaSDK(RAZER_CHROMA_HDK, &hModule);
|
||||
|
||||
rgb_controllers.push_back(razer_rgb);
|
||||
|
||||
} /* DetectRazerChromaSDKControllers() */
|
||||
+1
Submodule dependencies/libe131 added at 0fc009f1f6
@@ -0,0 +1,62 @@
|
||||
//! \file RzChromaLinkAPI.h
|
||||
//! \brief Exported APIs.
|
||||
|
||||
#ifndef _RZCHROMALINKAPI_H_
|
||||
#define _RZCHROMALINKAPI_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RzErrors.h"
|
||||
#include "RzChromaSDKTypes.h"
|
||||
|
||||
using namespace ChromaSDK;
|
||||
|
||||
// Callback funtion
|
||||
typedef LONG(*LPCHROMALINKPROC)(ChromaLink::EFFECT_TYPE Effect, PRZPARAM pData);
|
||||
|
||||
// Exported functions
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
/*!
|
||||
* Initialize Chroma Link API.
|
||||
* @return <b>RZRESULT_ALREADY_INITIALIZED</b>: Chroma Link API has already been initialized.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT Init(ChromaSDK::APPINFOTYPE AppInfo);
|
||||
|
||||
/*!
|
||||
* UnInitialize Chroma API.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT UnInit(void);
|
||||
|
||||
/*!
|
||||
* Register for Chroma Link effect events.
|
||||
* @param[in] lpFunc Callback function.
|
||||
* @return <b>ERROR_INVALID_PARAMETER</b>: lpFunc is invalid.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
* @remark
|
||||
* - <b>CHROMA_NONE</b> : This event will be sent when there are no more Chroma Link events.
|
||||
* Clients can resume their own lighting effects.
|
||||
* - <b>CHROMA_CUSTOM</b> : This event will be sent when there is a ChromaSDK::ChromaLink::CHROMA_CUSTOM effect event.
|
||||
* pData is casted to ChromaSDK::ChromaLink::CUSTOM_EFFECT_TYPE.
|
||||
* The colors of each (5) LEDs can be accessed from the array.
|
||||
* - <b>CHROMA_STATIC</b> : This event will be sent when there is a ChromaSDK::ChromaLink::CHROMA_STATIC effect event.
|
||||
* pData is casted to ChromaSDK::ChromaLink::STATIC_EFFECT_TYPE.
|
||||
* The color can be accessed from the structure.
|
||||
*/
|
||||
RZRESULT RegisterEventNotification(LPCHROMALINKPROC lpFunc);
|
||||
|
||||
/*!
|
||||
* Register for Chroma Link effect events.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT UnregisterEventNotification(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _RZCHROMALINKAPI_H_
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
|
||||
//! \file RzChromaSDK.h
|
||||
//! \brief Exported APIs.
|
||||
|
||||
#ifndef _RZCHROMASDK_H_
|
||||
#define _RZCHROMASDK_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RzErrors.h"
|
||||
#include "RzChromaSDKDefines.h"
|
||||
#include "RzChromaSDKTypes.h"
|
||||
|
||||
using namespace ChromaSDK;
|
||||
using namespace ChromaSDK::Keyboard;
|
||||
using namespace ChromaSDK::Mouse;
|
||||
using namespace ChromaSDK::Headset;
|
||||
using namespace ChromaSDK::Mousepad;
|
||||
using namespace ChromaSDK::Keypad;
|
||||
using namespace ChromaSDK::ChromaLink;
|
||||
|
||||
// Exported functions
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Initialize Chroma SDK.
|
||||
* @return <b>RZRESULT_SERVICE_NOT_ACTIVE</b>: Chroma SDK Service not running.
|
||||
* @return <b>RZRESULT_ALREADY_INITIALIZED</b>: Chroma SDK has already been initialized.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT Init(void);
|
||||
|
||||
/*!
|
||||
* UnInitialize Chroma SDK.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Chroma SDK not in a valid state. For every Init() call there should be a corresponding UnInit().
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT UnInit(void);
|
||||
|
||||
/*!
|
||||
* Create generic effect for specific or all devices.
|
||||
* @param[in] DeviceId Device Id defined in RzChromaSDKDefines.h
|
||||
* @param[in] Effect Standard effect type.
|
||||
* @param[in] pParam Pointer to a parameter type specified by Effect.
|
||||
* @param[in,out] pEffectId Valid effect Id if successful. Set it to NULL if not required.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Chroma SDK not in a valid state. Did you forgot to call Init()?
|
||||
* @return <b>RZRESULT_INVALID_PARAMETER</b>: Invalid parameter.
|
||||
* @return <b>RZRESULT_DEVICE_NOT_AVAILABLE</b>: Device not supported.
|
||||
* @return <b>RZRESULT_NOT_SUPPORTED</b>: Effect not supported for this device.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT CreateEffect(RZDEVICEID DeviceId, ChromaSDK::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
|
||||
/*!
|
||||
* Create keyboard effect.
|
||||
* @param[in] Effect Keyboard effect type.
|
||||
* @param[in] pParam Pointer to a parameter type specified by Effect.
|
||||
* @param[in,out] pEffectId Valid effect Id if successful. Set it to NULL if not required.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Chroma SDK not in a valid state. Did you forgot to call Init()?
|
||||
* @return <b>RZRESULT_INVALID_PARAMETER</b>: Invalid parameter.
|
||||
* @return <b>RZRESULT_NOT_SUPPORTED</b>: Effect not supported for this device.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT CreateKeyboardEffect(ChromaSDK::Keyboard::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
|
||||
/*!
|
||||
* Create mouse effect.
|
||||
* @param[in] Effect Mouse effect type.
|
||||
* @param[in] pParam Pointer to a parameter type specified by Effect.
|
||||
* @param[in,out] pEffectId Valid effect Id if successful. Set it to NULL if not required.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Chroma SDK not in a valid state. Did you forgot to call Init()?
|
||||
* @return <b>RZRESULT_INVALID_PARAMETER</b>: Invalid parameter.
|
||||
* @return <b>RZRESULT_NOT_SUPPORTED</b>: Effect not supported for this device.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT CreateMouseEffect(ChromaSDK::Mouse::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
|
||||
/*!
|
||||
* Create headset effect.
|
||||
* @param[in] Effect Headset effect type.
|
||||
* @param[in] pParam Pointer to a parameter type specified by Effect defined in RzChromaSDKTypes.h
|
||||
* @param[in,out] pEffectId Valid effect Id if successful. Set it to NULL if not required.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Chroma SDK not in a valid state. Did you forgot to call Init()?
|
||||
* @return <b>RZRESULT_INVALID_PARAMETER</b>: Invalid parameter.
|
||||
* @return <b>RZRESULT_NOT_SUPPORTED</b>: Effect not supported for this device.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT CreateHeadsetEffect(ChromaSDK::Headset::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
|
||||
/*!
|
||||
* Create mousepad effect.
|
||||
* @param[in] Effect Mousemat effect type.
|
||||
* @param[in] pParam Pointer to a parameter type specified by Effect defined in RzChromaSDKTypes.h
|
||||
* @param[in,out] pEffectId Valid effect Id if successful. Set it to NULL if not required.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Chroma SDK not in a valid state. Did you forgot to call Init()?
|
||||
* @return <b>RZRESULT_INVALID_PARAMETER</b>: Invalid parameter.
|
||||
* @return <b>RZRESULT_NOT_SUPPORTED</b>: Effect not supported for this device.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT CreateMousepadEffect(ChromaSDK::Mousepad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
|
||||
/*!
|
||||
* Create keypad effect.
|
||||
* @param[in] Effect Keypad effect type.
|
||||
* @param[in] pParam Pointer to a parameter type specified by Effect defined in RzChromaSDKTypes.h
|
||||
* @param[in,out] pEffectId Valid effect Id if successful. Set it to NULL if not required.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Chroma SDK not in a valid state. Did you forgot to call Init()?
|
||||
* @return <b>RZRESULT_INVALID_PARAMETER</b>: Invalid parameter.
|
||||
* @return <b>RZRESULT_NOT_SUPPORTED</b>: Effect not supported for this device.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT CreateKeypadEffect(ChromaSDK::Keypad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
|
||||
/*!
|
||||
* Create effects on Chroma Linked devices.
|
||||
* @param[in] Effect Chroma Link effect type.
|
||||
* @param[in] pParam Pointer to a parameter type specified by Effect defined in RzChromaSDKTypes.h
|
||||
* @param[in,out] pEffectId Valid effect Id if successful. Set it to NULL if not required.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Chroma SDK not in a valid state. Did you forgot to call Init()?
|
||||
* @return <b>RZRESULT_INVALID_PARAMETER</b>: Invalid parameter.
|
||||
* @return <b>RZRESULT_NOT_SUPPORTED</b>: Effect not supported for this device.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT CreateChromaLinkEffect(ChromaSDK::ChromaLink::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
|
||||
/*!
|
||||
* Delete effect
|
||||
* @param[in] EffectId Id of the effect that needs to be deleted.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Chroma SDK not in a valid state. Did you forgot to call Init()?
|
||||
* @return <b>RZRESULT_NOT_FOUND</b>: Effect Id not found.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT DeleteEffect(RZEFFECTID EffectId);
|
||||
|
||||
/*!
|
||||
* Set effect.
|
||||
* @param[in] EffectId Id of the effect that needs to be set.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Chroma SDK not in a valid state. Did you forgot to call Init()?
|
||||
* @return <b>RZRESULT_ACCESS_DENIED</b>: No permision to access device.
|
||||
* @return <b>RZRESULT_NOT_FOUND</b>: Effect Id not found.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT SetEffect(RZEFFECTID EffectId);
|
||||
|
||||
/*!
|
||||
* Register for event notification.
|
||||
* @param[in] hWnd Application window handle.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Chroma SDK not in a valid state. Did you forgot to call Init()?
|
||||
* @return <b>RZRESULT_ALREADY_INITIALIZED</b>: Invalid Windows handle.
|
||||
* @return <b>RZRESULT_INVALID_PARAMETER</b>: Invalid parameter.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
* @remark <b>WM_CHROMA_EVENT</b> will be sent if there is an event.
|
||||
* @remark
|
||||
* - \c <b>wParam</b> = 1 : Chroma SDK support.
|
||||
* - \c <b>lParam</b> = 1 : Enabled.
|
||||
* - \c <b>lParam</b> = 0 : Disabled.
|
||||
* - \c <b>wParam</b> = 2 : Access to device.
|
||||
* - \c <b>lParam</b> = 1 : Granted accessible.
|
||||
* - \c <b>lParam</b> = 0 = Access revoked.
|
||||
* - \c <b>wParam</b> = 3 : Application state.
|
||||
* - \c <b>lParam</b> = 1 : Enabled.
|
||||
* - \c <b>lParam</b> = 0 = Disabled.
|
||||
*/
|
||||
RZRESULT RegisterEventNotification(HWND hWnd);
|
||||
|
||||
/*!
|
||||
* Un-register for event notification.
|
||||
* @return <b>RZRESULT_NOT_VALID_STATE</b>: Internal state is not valid. There was no event registered.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT UnregisterEventNotification();
|
||||
|
||||
/*!
|
||||
* Query for device information.
|
||||
* @param[in] DeviceId Device id found in RzChromaSDKDefines.h
|
||||
* @param[out] DeviceInfo Contains device information specified by DeviceId.
|
||||
* @return <b>RZRESULT_DEVICE_NOT_AVAILABLE</b>: Device not supported.
|
||||
* @return For other error codes, please refer to [Windows System Error Codes](https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx) from Windows SDK (WinError.h).
|
||||
*/
|
||||
RZRESULT QueryDevice(RZDEVICEID DeviceId, DEVICE_INFO_TYPE &DeviceInfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,182 @@
|
||||
//! \file RzChromaSDKDefines.h
|
||||
//! \brief Definitions of global and static variables.
|
||||
|
||||
#ifndef _RZSCHROMADKDEFINES_H_
|
||||
#define _RZSCHROMADKDEFINES_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef GUID_DEFINED
|
||||
#include <Guiddef.h>
|
||||
#endif
|
||||
|
||||
namespace ChromaSDK
|
||||
{
|
||||
// Keyboards
|
||||
//! Razer Blackwidow Chroma device.
|
||||
// {2EA1BB63-CA28-428D-9F06-196B88330BBB}
|
||||
static const GUID BLACKWIDOW_CHROMA =
|
||||
{ 0x2ea1bb63, 0xca28, 0x428d, { 0x9f, 0x06, 0x19, 0x6b, 0x88, 0x33, 0x0b, 0xbb } };
|
||||
|
||||
//! Razer Blackwidow Chroma Tournament Edition device.
|
||||
// {ED1C1B82-BFBE-418F-B49D-D03F05B149DF}
|
||||
static const GUID BLACKWIDOW_CHROMA_TE =
|
||||
{ 0xed1c1b82, 0xbfbe, 0x418f, { 0xb4, 0x9d, 0xd0, 0x3f, 0x5, 0xb1, 0x49, 0xdf } };
|
||||
|
||||
//! Razer Deathstalker device.
|
||||
// {18C5AD9B-4326-4828-92C4-2669A66D2283}
|
||||
static const GUID DEATHSTALKER_CHROMA =
|
||||
{ 0x18c5ad9b, 0x4326, 0x4828, { 0x92, 0xc4, 0x26, 0x69, 0xa6, 0x6d, 0x22, 0x83 } };
|
||||
|
||||
//! Overwatch Keyboard.
|
||||
// {872AB2A9-7959-4478-9FED-15F6186E72E4}
|
||||
static const GUID OVERWATCH_KEYBOARD =
|
||||
{ 0x872ab2a9, 0x7959, 0x4478, { 0x9f, 0xed, 0x15, 0xf6, 0x18, 0x6e, 0x72, 0xe4 } };
|
||||
|
||||
//! Razer Blackwidow X Chroma device.
|
||||
// {5AF60076-ADE9-43D4-B574-52599293B554}
|
||||
static const GUID BLACKWIDOW_X_CHROMA =
|
||||
{ 0x5af60076, 0xade9, 0x43d4, { 0xb5, 0x74, 0x52, 0x59, 0x92, 0x93, 0xb5, 0x54 } };
|
||||
|
||||
//! Razer Blackwidow X TE Chroma device.
|
||||
// {2D84DD51-3290-4AAC-9A89-D8AFDE38B57C}
|
||||
static const GUID BLACKWIDOW_X_TE_CHROMA =
|
||||
{ 0x2d84dd51, 0x3290, 0x4aac, { 0x9a, 0x89, 0xd8, 0xaf, 0xde, 0x38, 0xb5, 0x7c } };
|
||||
|
||||
//! Razer Ornata Chroma
|
||||
// {803378C1-CC48-4970-8539-D828CC1D420A}
|
||||
static const GUID ORNATA_CHROMA =
|
||||
{ 0x803378c1, 0xcc48, 0x4970,{ 0x85, 0x39, 0xd8, 0x28, 0xcc, 0x1d, 0x42, 0xa } };
|
||||
|
||||
//! Razer Blade Stealth.
|
||||
// {C83BDFE8-E7FC-40E0-99DB-872E23F19891}
|
||||
static const GUID BLADE_STEALTH =
|
||||
{ 0xc83bdfe8, 0xe7fc, 0x40e0, { 0x99, 0xdb, 0x87, 0x2e, 0x23, 0xf1, 0x98, 0x91 } };
|
||||
|
||||
//! Razer Blade
|
||||
// {F2BEDFAF-A0FE-4651-9D41-B6CE603A3DDD}
|
||||
static const GUID BLADE =
|
||||
{ 0xf2bedfaf, 0xa0fe, 0x4651, { 0x9d, 0x41, 0xb6, 0xce, 0x60, 0x3a, 0x3d, 0xdd } };
|
||||
|
||||
//! Razer Blade Pro
|
||||
// {A73AC338-F0E5-4BF7-91AE-DD1F7E1737A5}
|
||||
static const GUID BLADE_PRO =
|
||||
{ 0xa73ac338, 0xf0e5, 0x4bf7,{ 0x91, 0xae, 0xdd, 0x1f, 0x7e, 0x17, 0x37, 0xa5 } };
|
||||
|
||||
|
||||
// Mice
|
||||
//! Razer Deathadder Chroma device.
|
||||
// {AEC50D91-B1F1-452F-8E16-7B73F376FDF3}
|
||||
static const GUID DEATHADDER_CHROMA =
|
||||
{ 0xaec50d91, 0xb1f1, 0x452f, { 0x8e, 0x16, 0x7b, 0x73, 0xf3, 0x76, 0xfd, 0xf3 } };
|
||||
|
||||
//! Razer Mamba Chroma Tournament Edition device.
|
||||
// {7EC00450-E0EE-4289-89D5-0D879C19061A}
|
||||
static const GUID MAMBA_CHROMA_TE =
|
||||
{ 0x7ec00450, 0xe0ee, 0x4289, { 0x89, 0xd5, 0xd, 0x87, 0x9c, 0x19, 0x6, 0x1a } };
|
||||
|
||||
//! Razer Diamondback device.
|
||||
// {FF8A5929-4512-4257-8D59-C647BF9935D0}
|
||||
static const GUID DIAMONDBACK_CHROMA =
|
||||
{ 0xff8a5929, 0x4512, 0x4257, { 0x8d, 0x59, 0xc6, 0x47, 0xbf, 0x99, 0x35, 0xd0 } };
|
||||
|
||||
//! Razer Mamba device.
|
||||
// {D527CBDC-EB0A-483A-9E89-66D50463EC6C}
|
||||
static const GUID MAMBA_CHROMA =
|
||||
{ 0xd527cbdc, 0xeb0a, 0x483a, { 0x9e, 0x89, 0x66, 0xd5, 0x4, 0x63, 0xec, 0x6c } };
|
||||
|
||||
//! Razer Naga Epic device.
|
||||
// {D714C50B-7158-4368-B99C-601ACB985E98}
|
||||
static const GUID NAGA_EPIC_CHROMA =
|
||||
{ 0xd714c50b, 0x7158, 0x4368, { 0xb9, 0x9c, 0x60, 0x1a, 0xcb, 0x98, 0x5e, 0x98 } };
|
||||
|
||||
//! Razer Naga device.
|
||||
// {F1876328-6CA4-46AE-BE04-BE812B414433}
|
||||
static const GUID NAGA_CHROMA =
|
||||
{ 0xf1876328, 0x6ca4, 0x46ae, { 0xbe, 0x4, 0xbe, 0x81, 0x2b, 0x41, 0x44, 0x33 } };
|
||||
|
||||
//! Razer Orochi Chroma device.
|
||||
// {52C15681-4ECE-4DD9-8A52-A1418459EB34}
|
||||
static const GUID OROCHI_CHROMA =
|
||||
{ 0x52c15681, 0x4ece, 0x4dd9, { 0x8a, 0x52, 0xa1, 0x41, 0x84, 0x59, 0xeb, 0x34 } };
|
||||
|
||||
//! Razer Naga Hex Chroma device.
|
||||
// {195D70F5-F285-4CFF-99F2-B8C0E9658DB4}
|
||||
static const GUID NAGA_HEX_CHROMA =
|
||||
{ 0x195d70f5, 0xf285, 0x4cff, { 0x99, 0xf2, 0xb8, 0xc0, 0xe9, 0x65, 0x8d, 0xb4 } };
|
||||
|
||||
//! Razer DeathAdder Elite Chroma device.
|
||||
// {77834867-3237-4A9F-AD77-4A46C4183003}
|
||||
static const GUID DEATHADDER_ELITE_CHROMA =
|
||||
{ 0x77834867, 0x3237, 0x4a9f,{ 0xad, 0x77, 0x4a, 0x46, 0xc4, 0x18, 0x30, 0x3 } };
|
||||
|
||||
|
||||
// Headsets
|
||||
//! Razer Kraken 7.1 Chroma device.
|
||||
// {CD1E09A5-D5E6-4A6C-A93B-E6D9BF1D2092}
|
||||
static const GUID KRAKEN71_CHROMA =
|
||||
{ 0xcd1e09a5, 0xd5e6, 0x4a6c, { 0xa9, 0x3b, 0xe6, 0xd9, 0xbf, 0x1d, 0x20, 0x92 } };
|
||||
|
||||
//! Razer ManO'War device.
|
||||
// {DF3164D7-5408-4A0E-8A7F-A7412F26BEBF}
|
||||
static const GUID MANOWAR_CHROMA =
|
||||
{ 0xdf3164d7, 0x5408, 0x4a0e, { 0x8a, 0x7f, 0xa7, 0x41, 0x2f, 0x26, 0xbe, 0xbf } };
|
||||
|
||||
//! Razer Kraken 7.1 Chroma Refresh headset.
|
||||
// {7FB8A36E-9E74-4BB3-8C86-CAC7F7891EBD}
|
||||
static const GUID KRAKEN71_REFRESH_CHROMA =
|
||||
{ 0x7fb8a36e, 0x9e74, 0x4bb3,{ 0x8c, 0x86, 0xca, 0xc7, 0xf7, 0x89, 0x1e, 0xbd } };
|
||||
|
||||
|
||||
// Mouse mat
|
||||
//! Razer Firefly device.
|
||||
// {80F95A94-73D2-48CA-AE9A-0986789A9AF2}
|
||||
static const GUID FIREFLY_CHROMA =
|
||||
{ 0x80f95a94, 0x73d2, 0x48ca, { 0xae, 0x9a, 0x9, 0x86, 0x78, 0x9a, 0x9a, 0xf2 } };
|
||||
|
||||
|
||||
// Keypads
|
||||
//! Razer Tartarus device.
|
||||
// {00F0545C-E180-4AD1-8E8A-419061CE505E}
|
||||
static const GUID TARTARUS_CHROMA =
|
||||
{ 0xf0545c, 0xe180, 0x4ad1, { 0x8e, 0x8a, 0x41, 0x90, 0x61, 0xce, 0x50, 0x5e } };
|
||||
|
||||
//! Razer Orbweaver device.
|
||||
// {9D24B0AB-0162-466C-9640-7A924AA4D9FD}
|
||||
static const GUID ORBWEAVER_CHROMA =
|
||||
{ 0x9d24b0ab, 0x162, 0x466c, { 0x96, 0x40, 0x7a, 0x92, 0x4a, 0xa4, 0xd9, 0xfd } };
|
||||
|
||||
|
||||
// Chroma Linked devices
|
||||
// {35F6F18D-1AE5-436C-A575-AB44A127903A}
|
||||
static const GUID LENOVO_Y900 =
|
||||
{ 0x35f6f18d, 0x1ae5, 0x436c, { 0xa5, 0x75, 0xab, 0x44, 0xa1, 0x27, 0x90, 0x3a } };
|
||||
|
||||
// {47DB1FA7-6B9B-4EE6-B6F4-4071A3B2053B}
|
||||
static const GUID LENOVO_Y27 =
|
||||
{ 0x47db1fa7, 0x6b9b, 0x4ee6, { 0xb6, 0xf4, 0x40, 0x71, 0xa3, 0xb2, 0x5, 0x3b } };
|
||||
|
||||
// {0201203B-62F3-4C50-83DD-598BABD208E0}
|
||||
static const GUID CORE_CHROMA =
|
||||
{ 0x201203b, 0x62f3, 0x4c50, { 0x83, 0xdd, 0x59, 0x8b, 0xab, 0xd2, 0x8, 0xe0 } };
|
||||
|
||||
// {BB2E9C9B-B0D2-461A-BA52-230B5D6C3609}
|
||||
static const GUID CHROMABOX =
|
||||
{ 0xbb2e9c9b, 0xb0d2, 0x461a,{ 0xba, 0x52, 0x23, 0xb, 0x5d, 0x6c, 0x36, 0x9 } };
|
||||
|
||||
|
||||
// Speakers
|
||||
//! Razer Nommo
|
||||
// {45B308F2-CD44-4594-8375-4D5945AD880E}
|
||||
static const GUID NOMMO_CHROMA =
|
||||
{ 0x45b308f2, 0xcd44, 0x4594,{ 0x83, 0x75, 0x4d, 0x59, 0x45, 0xad, 0x88, 0xe } };
|
||||
|
||||
|
||||
//! Razer Nommo Pro
|
||||
// {3017280B-D7F9-4D7B-930E-7B47181B46B5}
|
||||
static const GUID NOMMO_CHROMA_PRO =
|
||||
{ 0x3017280b, 0xd7f9, 0x4d7b,{ 0x93, 0xe, 0x7b, 0x47, 0x18, 0x1b, 0x46, 0xb5 } };
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,832 @@
|
||||
//! \file RzChromaSDKTypes.h
|
||||
//! \brief Data types.
|
||||
|
||||
#ifndef _RZCHROMASDKTYPES_H_
|
||||
#define _RZCHROMASDKTYPES_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef LONG RZRESULT; //!< Return result.
|
||||
typedef GUID RZEFFECTID; //!< Effect Id.
|
||||
typedef GUID RZDEVICEID; //!< Device Id.
|
||||
typedef unsigned int RZDURATION; //!< Milliseconds.
|
||||
typedef size_t RZSIZE; //!< Size.
|
||||
typedef void* PRZPARAM; //!< Context sensitive pointer.
|
||||
typedef DWORD RZID; //!< Generic data type for Identifier.
|
||||
typedef DWORD RZCOLOR; //!< Color data. 1st byte = Red; 2nd byte = Green; 3rd byte = Blue; 4th byte = Alpha (if applicable)
|
||||
|
||||
namespace ChromaSDK
|
||||
{
|
||||
//! Event notification Window message
|
||||
const UINT WM_CHROMA_EVENT = WM_APP+0x2000;
|
||||
|
||||
//! Application information.
|
||||
typedef struct APPINFOTYPE
|
||||
{
|
||||
TCHAR Title[256]; //!< Title of the application.
|
||||
TCHAR Description[1024]; //!< A short description of the application.
|
||||
//! Author information
|
||||
struct Author
|
||||
{
|
||||
TCHAR Name[256]; //!< Name of the developer/company.
|
||||
TCHAR Contact[256]; //!< Contact info.
|
||||
} Author;
|
||||
DWORD SupportedDevice;
|
||||
DWORD Category; //!< 0 = Utility; 1 = Game; 2 = Chroma Link Broadcast
|
||||
} APPINFOTYPE;
|
||||
|
||||
//! Chroma generic effects. Note: Not all devices supported the listed effects.
|
||||
typedef enum EFFECT_TYPE
|
||||
{
|
||||
CHROMA_NONE = 0, //!< No effect.
|
||||
CHROMA_WAVE, //!< Wave effect (Deprecated and should not be used).
|
||||
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (Deprecated and should not be used).
|
||||
CHROMA_BREATHING, //!< Breathing effect (Deprecated and should not be used).
|
||||
CHROMA_BLINKING, //!< Blinking effect (Deprecated and should not be used).
|
||||
CHROMA_REACTIVE, //!< Reactive effect (Deprecated and should not be used).
|
||||
CHROMA_STATIC, //!< Static single color effect.
|
||||
CHROMA_CUSTOM, //!< Custom effect. For mice, please see Mouse::CHROMA_CUSTOM2.
|
||||
CHROMA_RESERVED, //!< Reserved
|
||||
CHROMA_INVALID //!< Invalid effect.
|
||||
} EFFECT_TYPE;
|
||||
|
||||
//! Device info.
|
||||
typedef struct DEVICE_INFO_TYPE
|
||||
{
|
||||
//! Device types.
|
||||
enum DeviceType
|
||||
{
|
||||
DEVICE_KEYBOARD = 1, //!< Keyboard device.
|
||||
DEVICE_MOUSE = 2, //!< Mouse device.
|
||||
DEVICE_HEADSET = 3, //!< Headset device.
|
||||
DEVICE_MOUSEPAD = 4, //!< Mousepad device.
|
||||
DEVICE_KEYPAD = 5, //!< Keypad device.
|
||||
DEVICE_SYSTEM = 6, //!< System device.
|
||||
DEVICE_SPEAKERS = 7, //!< Speakers.
|
||||
DEVICE_INVALID //!< Invalid device.
|
||||
} DeviceType;
|
||||
|
||||
DWORD Connected; //!< Number of devices connected.
|
||||
} DEVICE_INFO_TYPE;
|
||||
|
||||
const RZSIZE MAX_ROW = 30; //!< Maximum rows for custom effects.
|
||||
const RZSIZE MAX_COLUMN = 30; //!< Maximum columns for custom effects.
|
||||
|
||||
//! Blinking effect (Deprecated and should not be used).
|
||||
typedef struct BLINKING_EFFECT_TYPE
|
||||
{
|
||||
RZSIZE Size; //!< Size of the structure. Size = sizeof(BLINKING_EFFECT_TYPE)
|
||||
DWORD Param; //!< Extra parameters.
|
||||
|
||||
COLORREF Color; //!< Blinking color
|
||||
} BLINKING_EFFECT_TYPE;
|
||||
|
||||
//! Breathing effect (Deprecated and should not be used).
|
||||
typedef struct BREATHING_EFFECT_TYPE
|
||||
{
|
||||
RZSIZE Size; //!< Size of ths structure. Size = sizeof(BREATHING_EFFECT_TYPE)
|
||||
DWORD Param; //!< Extra parameters.
|
||||
|
||||
//! Breathing effect types.
|
||||
enum _Type
|
||||
{
|
||||
ONE_COLOR = 1, //!< 1 color (Only fill Color1).
|
||||
TWO_COLORS, //!< 2 colors.
|
||||
RANDOM_COLORS //!< Random colors
|
||||
} Type;
|
||||
|
||||
COLORREF Color1; //!< First color.
|
||||
COLORREF Color2; //!< Second color.
|
||||
} BREATHING_EFFECT_TYPE;
|
||||
|
||||
//! Custom effect (Deprecated and should not be used).
|
||||
typedef struct CUSTOM_EFFECT_TYPE
|
||||
{
|
||||
RZSIZE Size; //!< Size of the structure. Size = sizeof(CUSTOM_EFFECT_TYPE)
|
||||
DWORD Param; //!< Extra parameters.
|
||||
|
||||
RZCOLOR Color[MAX_ROW][MAX_COLUMN];
|
||||
} CUSTOM_EFFECT_TYPE;
|
||||
|
||||
//! No effect.
|
||||
typedef struct NO_EFFECT_TYPE
|
||||
{
|
||||
RZSIZE Size; //!< Size of the structure. Size = sizeof(NO_EFFECT_TYPE)
|
||||
DWORD Param; //!< Extra parameters.
|
||||
} NO_EFFECT_TYPE;
|
||||
|
||||
//! Reactive effect (Deprecated and should not be used).
|
||||
typedef struct REACTIVE_EFFECT_TYPE
|
||||
{
|
||||
RZSIZE Size; //!< Size of the structure. Size = sizeof(REACTIVE_EFFECT_TYPE)
|
||||
DWORD Param; //!< Extra parameters.
|
||||
|
||||
//! Duration of the effect.
|
||||
enum _Duration
|
||||
{
|
||||
DURATION_SHORT = 1, //!< Short duration.
|
||||
DURATION_MEDIUM, //!< Medium duration.
|
||||
DURATION_LONG //!< Long duration.
|
||||
} Duration; //!< The time taken for the effect to fade away.
|
||||
|
||||
COLORREF Color; //!< Color of the effect.
|
||||
} REACTIVE_EFFECT_TYPE;
|
||||
|
||||
//! Spectrum cycling effect (Deprecated and should not be used).
|
||||
typedef struct SPECTRUMCYCLING_EFFECT_TYPE
|
||||
{
|
||||
RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE)
|
||||
DWORD Param; //!< Extra parameters.
|
||||
} SPECTRUMCYCLING_EFFECT_TYPE;
|
||||
|
||||
//! Starlight effect (Deprecated and should not be used).
|
||||
typedef struct STARLIGHT_EFFECT_TYPE
|
||||
{
|
||||
RZSIZE Size; //!< Size of the structure. Size = sizeof(SPECTRUMCYCLING_EFFECT_TYPE)
|
||||
DWORD Param; //!< Extra parameters.
|
||||
|
||||
//! Starlight effect types.
|
||||
enum _Type
|
||||
{
|
||||
TWO_COLORS = 1, //!< 2 colors.
|
||||
RANDOM_COLORS //!< Random colors
|
||||
} Type;
|
||||
|
||||
COLORREF Color1; //!< First color.
|
||||
COLORREF Color2; //!< Second color.
|
||||
|
||||
//! Duration of the effect.
|
||||
enum _Duration
|
||||
{
|
||||
DURATION_SHORT = 1, //!< Short duration.
|
||||
DURATION_MEDIUM, //!< Medium duration.
|
||||
DURATION_LONG //!< Long duration.
|
||||
} Duration; //!< The time taken for the effect to fade away.
|
||||
|
||||
} STARLIGHT_EFFECT_TYPE;
|
||||
|
||||
//! Static effect (Deprecated and should not be used).
|
||||
typedef struct STATIC_EFFECT_TYPE
|
||||
{
|
||||
RZSIZE Size; //!< Size of the structure. Size = sizeof(STATIC_EFFECT_TYPE)
|
||||
DWORD Param; //!< Extra parameters.
|
||||
|
||||
COLORREF Color; //!< Color of the effect.
|
||||
} STATIC_EFFECT_TYPE;
|
||||
|
||||
//! Wave effect (Deprecated and should not be used).
|
||||
typedef struct WAVE_EFFECT_TYPE
|
||||
{
|
||||
RZSIZE Size; //!< Size of the structure. Size = sizeof(WAVE_EFFECT_TYPE)
|
||||
DWORD Param; //!< Extra parameters.
|
||||
|
||||
//! Direction of effect.
|
||||
enum _Direction
|
||||
{
|
||||
DIRECTION_LEFT_TO_RIGHT = 1, //!< Left to right.
|
||||
DIRECTION_RIGHT_TO_LEFT, //!< Right to left.
|
||||
DIRECTION_FRONT_TO_BACK, //!< Front to back
|
||||
DIRECTION_BACK_TO_FRONT //!< Back top front
|
||||
} Direction;
|
||||
} WAVE_EFFECT_TYPE;
|
||||
|
||||
//! Keyboards
|
||||
namespace Keyboard
|
||||
{
|
||||
//! Definitions of keys.
|
||||
typedef enum RZKEY
|
||||
{
|
||||
RZKEY_ESC = 0x0001, /*!< Esc (VK_ESCAPE) */
|
||||
RZKEY_F1 = 0x0003, /*!< F1 (VK_F1) */
|
||||
RZKEY_F2 = 0x0004, /*!< F2 (VK_F2) */
|
||||
RZKEY_F3 = 0x0005, /*!< F3 (VK_F3) */
|
||||
RZKEY_F4 = 0x0006, /*!< F4 (VK_F4) */
|
||||
RZKEY_F5 = 0x0007, /*!< F5 (VK_F5) */
|
||||
RZKEY_F6 = 0x0008, /*!< F6 (VK_F6) */
|
||||
RZKEY_F7 = 0x0009, /*!< F7 (VK_F7) */
|
||||
RZKEY_F8 = 0x000A, /*!< F8 (VK_F8) */
|
||||
RZKEY_F9 = 0x000B, /*!< F9 (VK_F9) */
|
||||
RZKEY_F10 = 0x000C, /*!< F10 (VK_F10) */
|
||||
RZKEY_F11 = 0x000D, /*!< F11 (VK_F11) */
|
||||
RZKEY_F12 = 0x000E, /*!< F12 (VK_F12) */
|
||||
RZKEY_1 = 0x0102, /*!< 1 (VK_1) */
|
||||
RZKEY_2 = 0x0103, /*!< 2 (VK_2) */
|
||||
RZKEY_3 = 0x0104, /*!< 3 (VK_3) */
|
||||
RZKEY_4 = 0x0105, /*!< 4 (VK_4) */
|
||||
RZKEY_5 = 0x0106, /*!< 5 (VK_5) */
|
||||
RZKEY_6 = 0x0107, /*!< 6 (VK_6) */
|
||||
RZKEY_7 = 0x0108, /*!< 7 (VK_7) */
|
||||
RZKEY_8 = 0x0109, /*!< 8 (VK_8) */
|
||||
RZKEY_9 = 0x010A, /*!< 9 (VK_9) */
|
||||
RZKEY_0 = 0x010B, /*!< 0 (VK_0) */
|
||||
RZKEY_A = 0x0302, /*!< A (VK_A) */
|
||||
RZKEY_B = 0x0407, /*!< B (VK_B) */
|
||||
RZKEY_C = 0x0405, /*!< C (VK_C) */
|
||||
RZKEY_D = 0x0304, /*!< D (VK_D) */
|
||||
RZKEY_E = 0x0204, /*!< E (VK_E) */
|
||||
RZKEY_F = 0x0305, /*!< F (VK_F) */
|
||||
RZKEY_G = 0x0306, /*!< G (VK_G) */
|
||||
RZKEY_H = 0x0307, /*!< H (VK_H) */
|
||||
RZKEY_I = 0x0209, /*!< I (VK_I) */
|
||||
RZKEY_J = 0x0308, /*!< J (VK_J) */
|
||||
RZKEY_K = 0x0309, /*!< K (VK_K) */
|
||||
RZKEY_L = 0x030A, /*!< L (VK_L) */
|
||||
RZKEY_M = 0x0409, /*!< M (VK_M) */
|
||||
RZKEY_N = 0x0408, /*!< N (VK_N) */
|
||||
RZKEY_O = 0x020A, /*!< O (VK_O) */
|
||||
RZKEY_P = 0x020B, /*!< P (VK_P) */
|
||||
RZKEY_Q = 0x0202, /*!< Q (VK_Q) */
|
||||
RZKEY_R = 0x0205, /*!< R (VK_R) */
|
||||
RZKEY_S = 0x0303, /*!< S (VK_S) */
|
||||
RZKEY_T = 0x0206, /*!< T (VK_T) */
|
||||
RZKEY_U = 0x0208, /*!< U (VK_U) */
|
||||
RZKEY_V = 0x0406, /*!< V (VK_V) */
|
||||
RZKEY_W = 0x0203, /*!< W (VK_W) */
|
||||
RZKEY_X = 0x0404, /*!< X (VK_X) */
|
||||
RZKEY_Y = 0x0207, /*!< Y (VK_Y) */
|
||||
RZKEY_Z = 0x0403, /*!< Z (VK_Z) */
|
||||
RZKEY_NUMLOCK = 0x0112, /*!< Numlock (VK_NUMLOCK) */
|
||||
RZKEY_NUMPAD0 = 0x0513, /*!< Numpad 0 (VK_NUMPAD0) */
|
||||
RZKEY_NUMPAD1 = 0x0412, /*!< Numpad 1 (VK_NUMPAD1) */
|
||||
RZKEY_NUMPAD2 = 0x0413, /*!< Numpad 2 (VK_NUMPAD2) */
|
||||
RZKEY_NUMPAD3 = 0x0414, /*!< Numpad 3 (VK_NUMPAD3) */
|
||||
RZKEY_NUMPAD4 = 0x0312, /*!< Numpad 4 (VK_NUMPAD4) */
|
||||
RZKEY_NUMPAD5 = 0x0313, /*!< Numpad 5 (VK_NUMPAD5) */
|
||||
RZKEY_NUMPAD6 = 0x0314, /*!< Numpad 6 (VK_NUMPAD6) */
|
||||
RZKEY_NUMPAD7 = 0x0212, /*!< Numpad 7 (VK_NUMPAD7) */
|
||||
RZKEY_NUMPAD8 = 0x0213, /*!< Numpad 8 (VK_NUMPAD8) */
|
||||
RZKEY_NUMPAD9 = 0x0214, /*!< Numpad 9 (VK_ NUMPAD9*/
|
||||
RZKEY_NUMPAD_DIVIDE = 0x0113, /*!< Divide (VK_DIVIDE) */
|
||||
RZKEY_NUMPAD_MULTIPLY = 0x0114, /*!< Multiply (VK_MULTIPLY) */
|
||||
RZKEY_NUMPAD_SUBTRACT = 0x0115, /*!< Subtract (VK_SUBTRACT) */
|
||||
RZKEY_NUMPAD_ADD = 0x0215, /*!< Add (VK_ADD) */
|
||||
RZKEY_NUMPAD_ENTER = 0x0415, /*!< Enter (VK_RETURN - Extended) */
|
||||
RZKEY_NUMPAD_DECIMAL = 0x0514, /*!< Decimal (VK_DECIMAL) */
|
||||
RZKEY_PRINTSCREEN = 0x000F, /*!< Print Screen (VK_PRINT) */
|
||||
RZKEY_SCROLL = 0x0010, /*!< Scroll Lock (VK_SCROLL) */
|
||||
RZKEY_PAUSE = 0x0011, /*!< Pause (VK_PAUSE) */
|
||||
RZKEY_INSERT = 0x010F, /*!< Insert (VK_INSERT) */
|
||||
RZKEY_HOME = 0x0110, /*!< Home (VK_HOME) */
|
||||
RZKEY_PAGEUP = 0x0111, /*!< Page Up (VK_PRIOR) */
|
||||
RZKEY_DELETE = 0x020f, /*!< Delete (VK_DELETE) */
|
||||
RZKEY_END = 0x0210, /*!< End (VK_END) */
|
||||
RZKEY_PAGEDOWN = 0x0211, /*!< Page Down (VK_NEXT) */
|
||||
RZKEY_UP = 0x0410, /*!< Up (VK_UP) */
|
||||
RZKEY_LEFT = 0x050F, /*!< Left (VK_LEFT) */
|
||||
RZKEY_DOWN = 0x0510, /*!< Down (VK_DOWN) */
|
||||
RZKEY_RIGHT = 0x0511, /*!< Right (VK_RIGHT) */
|
||||
RZKEY_TAB = 0x0201, /*!< Tab (VK_TAB) */
|
||||
RZKEY_CAPSLOCK = 0x0301, /*!< Caps Lock(VK_CAPITAL) */
|
||||
RZKEY_BACKSPACE = 0x010E, /*!< Backspace (VK_BACK) */
|
||||
RZKEY_ENTER = 0x030E, /*!< Enter (VK_RETURN) */
|
||||
RZKEY_LCTRL = 0x0501, /*!< Left Control(VK_LCONTROL) */
|
||||
RZKEY_LWIN = 0x0502, /*!< Left Window (VK_LWIN) */
|
||||
RZKEY_LALT = 0x0503, /*!< Left Alt (VK_LMENU) */
|
||||
RZKEY_SPACE = 0x0507, /*!< Spacebar (VK_SPACE) */
|
||||
RZKEY_RALT = 0x050B, /*!< Right Alt (VK_RMENU) */
|
||||
RZKEY_FN = 0x050C, /*!< Function key. */
|
||||
RZKEY_RMENU = 0x050D, /*!< Right Menu (VK_APPS) */
|
||||
RZKEY_RCTRL = 0x050E, /*!< Right Control (VK_RCONTROL) */
|
||||
RZKEY_LSHIFT = 0x0401, /*!< Left Shift (VK_LSHIFT) */
|
||||
RZKEY_RSHIFT = 0x040E, /*!< Right Shift (VK_RSHIFT) */
|
||||
RZKEY_MACRO1 = 0x0100, /*!< Macro Key 1 */
|
||||
RZKEY_MACRO2 = 0x0200, /*!< Macro Key 2 */
|
||||
RZKEY_MACRO3 = 0x0300, /*!< Macro Key 3 */
|
||||
RZKEY_MACRO4 = 0x0400, /*!< Macro Key 4 */
|
||||
RZKEY_MACRO5 = 0x0500, /*!< Macro Key 5 */
|
||||
RZKEY_OEM_1 = 0x0101, /*!< ~ (tilde/半角/全角) (VK_OEM_3) */
|
||||
RZKEY_OEM_2 = 0x010C, /*!< -- (minus) (VK_OEM_MINUS) */
|
||||
RZKEY_OEM_3 = 0x010D, /*!< = (equal) (VK_OEM_PLUS) */
|
||||
RZKEY_OEM_4 = 0x020C, /*!< [ (left sqaure bracket) (VK_OEM_4) */
|
||||
RZKEY_OEM_5 = 0x020D, /*!< ] (right square bracket) (VK_OEM_6) */
|
||||
RZKEY_OEM_6 = 0x020E, /*!< \ (backslash) (VK_OEM_5) */
|
||||
RZKEY_OEM_7 = 0x030B, /*!< ; (semi-colon) (VK_OEM_1) */
|
||||
RZKEY_OEM_8 = 0x030C, /*!< ' (apostrophe) (VK_OEM_7) */
|
||||
RZKEY_OEM_9 = 0x040A, /*!< , (comma) (VK_OEM_COMMA) */
|
||||
RZKEY_OEM_10 = 0x040B, /*!< . (period) (VK_OEM_PERIOD) */
|
||||
RZKEY_OEM_11 = 0x040C, /*!< / (forward slash) (VK_OEM_2) */
|
||||
RZKEY_EUR_1 = 0x030D, /*!< "#" (VK_OEM_5) */
|
||||
RZKEY_EUR_2 = 0x0402, /*!< \ (VK_OEM_102) */
|
||||
RZKEY_JPN_1 = 0x0015, /*!< ¥ (0xFF) */
|
||||
RZKEY_JPN_2 = 0x040D, /*!< \ (0xC1) */
|
||||
RZKEY_JPN_3 = 0x0504, /*!< 無変換 (VK_OEM_PA1) */
|
||||
RZKEY_JPN_4 = 0x0509, /*!< 変換 (0xFF) */
|
||||
RZKEY_JPN_5 = 0x050A, /*!< ひらがな/カタカナ (0xFF) */
|
||||
RZKEY_KOR_1 = 0x0015, /*!< | (0xFF) */
|
||||
RZKEY_KOR_2 = 0x030D, /*!< (VK_OEM_5) */
|
||||
RZKEY_KOR_3 = 0x0402, /*!< (VK_OEM_102) */
|
||||
RZKEY_KOR_4 = 0x040D, /*!< (0xC1) */
|
||||
RZKEY_KOR_5 = 0x0504, /*!< (VK_OEM_PA1) */
|
||||
RZKEY_KOR_6 = 0x0509, /*!< 한/영 (0xFF) */
|
||||
RZKEY_KOR_7 = 0x050A, /*!< (0xFF) */
|
||||
RZKEY_INVALID = 0xFFFF /*!< Invalid keys. */
|
||||
} RZKEY;
|
||||
|
||||
//! Definition of LEDs.
|
||||
typedef enum RZLED
|
||||
{
|
||||
RZLED_LOGO = 0x0014 /*!< Razer logo */
|
||||
} RZLED;
|
||||
|
||||
//! Maximum number of rows in a keyboard.
|
||||
const RZSIZE MAX_ROW = 6;
|
||||
|
||||
//! Maximum number of columns in a keyboard.
|
||||
const RZSIZE MAX_COLUMN = 22;
|
||||
|
||||
//! Maximum number of keys.
|
||||
const RZSIZE MAX_KEYS = MAX_ROW * MAX_COLUMN;
|
||||
|
||||
//! Maximum number of custom effects.
|
||||
const RZSIZE MAX_CUSTOM_EFFECTS = MAX_KEYS;
|
||||
|
||||
//! Keyboard LED layout.
|
||||
const COLORREF RZKEY_LAYOUT[MAX_ROW][MAX_COLUMN] = {};
|
||||
|
||||
//! Chroma keyboard effect types
|
||||
typedef enum EFFECT_TYPE
|
||||
{
|
||||
CHROMA_NONE = 0, //!< No effect.
|
||||
CHROMA_BREATHING, //!< Breathing effect (Deprecated and should not be used.).
|
||||
CHROMA_CUSTOM, //!< Custom effect.
|
||||
CHROMA_REACTIVE, //!< Reactive effect (Deprecated and should not be used).
|
||||
CHROMA_STATIC, //!< Static single color effect.
|
||||
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (Deprecated and should not be used).
|
||||
CHROMA_WAVE, //!< Wave effect (Deprecated and should not be used).
|
||||
CHROMA_RESERVED, //!< Reserved.
|
||||
CHROMA_CUSTOM_KEY, //!< Custom effects with keys.
|
||||
CHROMA_INVALID //!< Invalid effect.
|
||||
} EFFECT_TYPE;
|
||||
|
||||
// Chroma keyboard effects
|
||||
//! Breathing effect type (Deprecated and should not be used).
|
||||
typedef struct BREATHING_EFFECT_TYPE
|
||||
{
|
||||
//! Breathing effects.
|
||||
enum Type
|
||||
{
|
||||
TWO_COLORS = 1, //!< 2 colors
|
||||
RANDOM_COLORS, //!< Random colors
|
||||
INVALID //!< Invalid type
|
||||
} Type;
|
||||
COLORREF Color1; //!< First color.
|
||||
COLORREF Color2; //!< Second color.
|
||||
} BREATHING_EFFECT_TYPE;
|
||||
|
||||
//! Custom effect using a matrix type.
|
||||
typedef struct CUSTOM_EFFECT_TYPE
|
||||
{
|
||||
COLORREF Color[MAX_ROW][MAX_COLUMN]; //!< Grid layout. 6 rows by 22 columns.
|
||||
} CUSTOM_EFFECT_TYPE;
|
||||
|
||||
//! Custom effect with keys.
|
||||
typedef struct CUSTOM_KEY_EFFECT_TYPE
|
||||
{
|
||||
COLORREF Color[MAX_ROW][MAX_COLUMN]; //!< Grid layout. 6 rows by 22 columns.
|
||||
COLORREF Key[MAX_ROW][MAX_COLUMN]; //!< Keys information. 6 rows by 22 columns. To indidate there is a key effect, OR with 0x01000000. i.e. Key[0][1] = 0x01000000 | Color;
|
||||
} CUSTOM_KEY_EFFECT_TYPE;
|
||||
|
||||
//! Reactive effect type (Deprecated and should not be used).
|
||||
typedef struct REACTIVE_EFFECT_TYPE
|
||||
{
|
||||
//! Duration of the effect.
|
||||
enum Duration
|
||||
{
|
||||
DURATION_NONE=0, //!< No duration.
|
||||
DURATION_SHORT, //!< Short duration.
|
||||
DURATION_MEDIUM, //!< Medium duration.
|
||||
DURATION_LONG, //!< Long duration.
|
||||
DURATION_INVALID //!< Invalid duration.
|
||||
} Duration; //!< The time taken for the effect to fade away.
|
||||
|
||||
COLORREF Color; //!< Color of the effect
|
||||
} REACTIVE_EFFECT_TYPE;
|
||||
|
||||
//! Starlight effect (Deprecated and should not be used).
|
||||
typedef struct STARLIGHT_EFFECT_TYPE
|
||||
{
|
||||
//! Starlight effect types.
|
||||
enum _Type
|
||||
{
|
||||
TWO_COLORS = 1, //!< 2 colors.
|
||||
RANDOM_COLORS //!< Random colors
|
||||
} Type;
|
||||
|
||||
COLORREF Color1; //!< First color.
|
||||
COLORREF Color2; //!< Second color.
|
||||
|
||||
//! Duration of the effect.
|
||||
enum _Duration
|
||||
{
|
||||
DURATION_SHORT = 1, //!< Short duration.
|
||||
DURATION_MEDIUM, //!< Medium duration.
|
||||
DURATION_LONG //!< Long duration.
|
||||
} Duration; //!< The time taken for the effect to fade away.
|
||||
|
||||
} STARLIGHT_EFFECT_TYPE;
|
||||
|
||||
//! Static effect type
|
||||
typedef struct STATIC_EFFECT_TYPE
|
||||
{
|
||||
COLORREF Color; //!< Color of the effect
|
||||
} STATIC_EFFECT_TYPE;
|
||||
|
||||
//! Wave effect type (Deprecated and should not be used).
|
||||
typedef struct WAVE_EFFECT_TYPE
|
||||
{
|
||||
//! Direction of the wave effect.
|
||||
enum Direction
|
||||
{
|
||||
DIRECTION_NONE=0, //!< No direction.
|
||||
DIRECTION_LEFT_TO_RIGHT, //!< Left to right.
|
||||
DIRECTION_RIGHT_TO_LEFT, //!< Right to left.
|
||||
DIRECTION_INVALID //!< Invalid direction.
|
||||
} Direction; //!< Direction of the wave.
|
||||
} WAVE_EFFECT_TYPE;
|
||||
}
|
||||
|
||||
//! Mice
|
||||
namespace Mouse
|
||||
{
|
||||
//! Maximum number of custom LEDs (old definition to maintain backward compatibility).
|
||||
const RZSIZE MAX_LEDS = 30;
|
||||
|
||||
//! Mice LED layout (old definition to maintain backward compatibility).
|
||||
const RZCOLOR RZLED_LAYOUT[MAX_LEDS] = {};
|
||||
|
||||
//! Maximum number of rows of the virtual grid.
|
||||
const RZSIZE MAX_ROW = 9;
|
||||
|
||||
//! Maximum number of columns of the virtual grid.
|
||||
const RZSIZE MAX_COLUMN = 7;
|
||||
|
||||
//! Maximum number of LEDs of the virtual grid.
|
||||
const RZSIZE MAX_LEDS2 = MAX_ROW * MAX_COLUMN;
|
||||
|
||||
//! Mice LED virtual grid layout.
|
||||
const RZCOLOR RZLED_LAYOUT2[MAX_ROW][MAX_COLUMN] = {};
|
||||
|
||||
//! Mouse LED Id defintion (Deprecated and should not be used).
|
||||
typedef enum RZLED
|
||||
{
|
||||
RZLED_NONE = 0, //!< No LED.
|
||||
RZLED_SCROLLWHEEL = 1, //!< Scroll Wheel LED.
|
||||
RZLED_LOGO = 2, //!< Logo LED.
|
||||
RZLED_BACKLIGHT = 3, //!< Backlight or numpad.
|
||||
RZLED_SIDE_STRIP1 = 4, //!< Side strip LED 1. (For Mamba TE, starts from top left hand)
|
||||
RZLED_SIDE_STRIP2 = 5, //!< Side strip LED 2. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP3 = 6, //!< Side strip LED 3. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP4 = 7, //!< Side strip LED 4. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP5 = 8, //!< Side strip LED 5. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP6 = 9, //!< Side strip LED 6. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP7 = 10, //!< Side strip LED 7. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP8 = 11, //!< Side strip LED 8. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP9 = 12, //!< Side strip LED 9. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP10 = 13, //!< Side strip LED 10. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP11 = 14, //!< Side strip LED 11. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP12 = 15, //!< Side strip LED 12. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP13 = 16, //!< Side strip LED 13. (For Mamba TE)
|
||||
RZLED_SIDE_STRIP14 = 17, //!< Side strip LED 14. (For Mamba TE)
|
||||
RZLED_ALL = 0xFFFF
|
||||
} RZLED;
|
||||
|
||||
//! Mouse LED Id defintion for the virtual grid.
|
||||
typedef enum RZLED2
|
||||
{
|
||||
RZLED2_SCROLLWHEEL = 0x0203, //!< Scroll Wheel LED.
|
||||
RZLED2_LOGO = 0x0703, //!< Logo LED.
|
||||
RZLED2_BACKLIGHT = 0x0403, //!< Backlight LED.
|
||||
RZLED2_LEFT_SIDE1 = 0x0100, //!< Left LED 1.
|
||||
RZLED2_LEFT_SIDE2 = 0x0200, //!< Left LED 2.
|
||||
RZLED2_LEFT_SIDE3 = 0x0300, //!< Left LED 3.
|
||||
RZLED2_LEFT_SIDE4 = 0x0400, //!< Left LED 4.
|
||||
RZLED2_LEFT_SIDE5 = 0x0500, //!< Left LED 5.
|
||||
RZLED2_LEFT_SIDE6 = 0x0600, //!< Left LED 6.
|
||||
RZLED2_LEFT_SIDE7 = 0x0700, //!< Left LED 7.
|
||||
RZLED2_BOTTOM1 = 0x0801, //!< Bottom LED 1.
|
||||
RZLED2_BOTTOM2 = 0x0802, //!< Bottom LED 2.
|
||||
RZLED2_BOTTOM3 = 0x0803, //!< Bottom LED 3.
|
||||
RZLED2_BOTTOM4 = 0x0804, //!< Bottom LED 4.
|
||||
RZLED2_BOTTOM5 = 0x0805, //!< Bottom LED 5.
|
||||
RZLED2_RIGHT_SIDE1 = 0x0106, //!< Right LED 1.
|
||||
RZLED2_RIGHT_SIDE2 = 0x0206, //!< Right LED 2.
|
||||
RZLED2_RIGHT_SIDE3 = 0x0306, //!< Right LED 3.
|
||||
RZLED2_RIGHT_SIDE4 = 0x0406, //!< Right LED 4.
|
||||
RZLED2_RIGHT_SIDE5 = 0x0506, //!< Right LED 5.
|
||||
RZLED2_RIGHT_SIDE6 = 0x0606, //!< Right LED 6.
|
||||
RZLED2_RIGHT_SIDE7 = 0x0706 //!< Right LED 7.
|
||||
} RZLED2;
|
||||
|
||||
//! Chroma mouse effect types
|
||||
typedef enum EFFECT_TYPE
|
||||
{
|
||||
CHROMA_NONE = 0, //!< No effect.
|
||||
CHROMA_BLINKING, //!< Blinking effect (Deprecated and should not be used).
|
||||
CHROMA_BREATHING, //!< Breathing effect (Deprecated and should not be used).
|
||||
CHROMA_CUSTOM, //!< Custom effect (Deprecated and should not be used).
|
||||
CHROMA_REACTIVE, //!< Reactive effect (Deprecated and should not be used).
|
||||
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (Deprecated and should not be used).
|
||||
CHROMA_STATIC, //!< Static single color effect.
|
||||
CHROMA_WAVE, //!< Wave effect (Deprecated and should not be used).
|
||||
CHROMA_CUSTOM2, //!< Custom effects using a virtual grid.
|
||||
CHROMA_INVALID //!< Invalid effect.
|
||||
} EFFECT_TYPE;
|
||||
|
||||
//! Static effect type
|
||||
typedef struct STATIC_EFFECT_TYPE
|
||||
{
|
||||
RZLED LEDId; //!< LED Id
|
||||
COLORREF Color; //!< Color of the effect.
|
||||
} STATIC_EFFECT_TYPE;
|
||||
|
||||
//! Blinking effect type (Deprecated and should not be used).
|
||||
typedef struct BLINKING_EFFECT_TYPE
|
||||
{
|
||||
RZLED LEDId; //!< LED Id
|
||||
COLORREF Color; //!< Color.
|
||||
} BLINKING_EFFECT_TYPE;
|
||||
|
||||
//! Breathing effect (Deprecated and should not be used).
|
||||
typedef struct BREATHING_EFFECT_TYPE
|
||||
{
|
||||
RZLED LEDId; //!< LED Id
|
||||
|
||||
//! Breathing type.
|
||||
enum Type
|
||||
{
|
||||
ONE_COLOR = 1, //!< 1 color (Only fill Color1).
|
||||
TWO_COLORS, //!< 2 colors.
|
||||
RANDOM_COLORS, //!< Random colors
|
||||
INVALID //!< Invalid type
|
||||
} Type;
|
||||
|
||||
COLORREF Color1; //!< First color.
|
||||
COLORREF Color2; //!< Second color.
|
||||
} BREATHING_EFFECT_TYPE;
|
||||
|
||||
//! Custom effect (Deprecated and should not be used).
|
||||
typedef struct CUSTOM_EFFECT_TYPE
|
||||
{
|
||||
RZCOLOR Color[MAX_LEDS]; //!< Array of colors.
|
||||
} CUSTOM_EFFECT_TYPE;
|
||||
|
||||
//! Custom effect using virtual grid.
|
||||
//! Indexes of the LED are defined in RZLED2.i.e. Row = HIBYTE(RZLED2_SCROLLWHEEL), Column = LOBYTE(RZLED2_SCROLLWHEEL)
|
||||
typedef struct CUSTOM_EFFECT_TYPE2
|
||||
{
|
||||
RZCOLOR Color[MAX_ROW][MAX_COLUMN]; //!< Array of colors.
|
||||
} CUSTOM_EFFECT_TYPE2;
|
||||
|
||||
//! Reactive effect (Deprecated and should not be used).
|
||||
typedef struct REACTIVE_EFFECT_TYPE
|
||||
{
|
||||
RZLED LEDId; //!< LED Id
|
||||
|
||||
//! Duration of the effect.
|
||||
enum Duration
|
||||
{
|
||||
DURATION_NONE=0, //!< No duration.
|
||||
DURATION_SHORT, //!< Short duration.
|
||||
DURATION_MEDIUM, //!< Medium duration.
|
||||
DURATION_LONG //!< Long duration.
|
||||
} Duration;
|
||||
|
||||
RZCOLOR Color; //!< Color of the effect.
|
||||
} REACTIVE_EFFECT_TYPE;
|
||||
|
||||
//! No effect (Deprecated and should not be used).
|
||||
typedef struct NO_EFFECT_TYPE
|
||||
{
|
||||
RZLED LEDId; //!< LED Id
|
||||
} NO_EFFECT_TYPE;
|
||||
|
||||
//! Spectrum cycling (Deprecated and should not be used).
|
||||
typedef struct SPECTRUMCYCLING_EFFECT_TYPE
|
||||
{
|
||||
RZLED LEDId; //!< LED id.
|
||||
} SPECTRUMCYCLING_EFFECT_TYPE;
|
||||
|
||||
//! Wave effect (Deprecated and should not be used).
|
||||
typedef struct WAVE_EFFECT_TYPE
|
||||
{
|
||||
//! Direction of the wave effect.
|
||||
enum Direction
|
||||
{
|
||||
FRONT_TO_BACK, //!< Front to back
|
||||
BACK_TO_FRONT //!< Back to front
|
||||
} Direction;
|
||||
} WAVE_EFFECT_TYPE;
|
||||
}
|
||||
|
||||
//! Headsets
|
||||
namespace Headset
|
||||
{
|
||||
//! Maximum number of LEDs
|
||||
const RZSIZE MAX_LEDS = 5;
|
||||
|
||||
//! Chroma headset effect types
|
||||
typedef enum EFFECT_TYPE
|
||||
{
|
||||
CHROMA_NONE = 0, //!< No effect.
|
||||
CHROMA_STATIC, //!< Static single color effect.
|
||||
CHROMA_BREATHING, //!< Breathing effect (Deprecated and should not be used).
|
||||
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (Deprecated and should not be used).
|
||||
CHROMA_CUSTOM, //!< Custom effects.
|
||||
CHROMA_INVALID //!< Invalid effect.
|
||||
} EFFECT_TYPE;
|
||||
|
||||
//! Static effect type
|
||||
typedef struct STATIC_EFFECT_TYPE
|
||||
{
|
||||
COLORREF Color; //!< Color of the effect.
|
||||
} STATIC_EFFECT_TYPE;
|
||||
|
||||
//! Breathing effect type (Deprecated and should not be used).
|
||||
typedef struct BREATHING_EFFECT_TYPE
|
||||
{
|
||||
COLORREF Color; //!< Color.
|
||||
} BREATHING_EFFECT_TYPE;
|
||||
|
||||
//! Custom effect type.
|
||||
typedef struct CUSTOM_EFFECT_TYPE
|
||||
{
|
||||
RZCOLOR Color[MAX_LEDS]; //!< Array of colors.
|
||||
} CUSTOM_EFFECT_TYPE;
|
||||
}
|
||||
|
||||
//! Mousepads
|
||||
namespace Mousepad
|
||||
{
|
||||
//! Maximum number of LEDs
|
||||
const RZSIZE MAX_LEDS = 15;
|
||||
|
||||
//! Chroma mousepad effect types
|
||||
typedef enum EFFECT_TYPE
|
||||
{
|
||||
CHROMA_NONE = 0, //!< No effect.
|
||||
CHROMA_BREATHING, //!< Breathing effect (Deprecated and should not be used).
|
||||
CHROMA_CUSTOM, //!< Custom effect.
|
||||
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (Deprecated and should not be used).
|
||||
CHROMA_STATIC, //!< Static single color effect.
|
||||
CHROMA_WAVE, //!< Wave effect (Deprecated and should not be used).
|
||||
CHROMA_INVALID //!< Invalid effect.
|
||||
} EFFECT_TYPE;
|
||||
|
||||
// Chroma mousepad effects
|
||||
//! Breathing effect type (Deprecated and should not be used).
|
||||
typedef struct BREATHING_EFFECT_TYPE
|
||||
{
|
||||
//! Breathing effects.
|
||||
enum Type
|
||||
{
|
||||
TWO_COLORS = 1, //!< 2 colors
|
||||
RANDOM_COLORS, //!< Random colors
|
||||
INVALID
|
||||
} Type;
|
||||
COLORREF Color1; //!< First color.
|
||||
COLORREF Color2; //!< Second color.
|
||||
} BREATHING_EFFECT_TYPE;
|
||||
|
||||
//! Custom effect type.
|
||||
typedef struct CUSTOM_EFFECT_TYPE
|
||||
{
|
||||
RZCOLOR Color[MAX_LEDS]; //!< An array of colors for all the sides of the mousepad. First LED starts from top-right corner.
|
||||
//!< LED 0-4 right side, 5-9 bottom side, 10-14 left side.
|
||||
} CUSTOM_EFFECT_TYPE;
|
||||
|
||||
//! Static effect type
|
||||
typedef struct STATIC_EFFECT_TYPE
|
||||
{
|
||||
COLORREF Color; //!< Color of the effect
|
||||
} STATIC_EFFECT_TYPE;
|
||||
|
||||
//! Wave effect type
|
||||
typedef struct WAVE_EFFECT_TYPE
|
||||
{
|
||||
//! Direction of the wave effect.
|
||||
enum Direction
|
||||
{
|
||||
DIRECTION_NONE=0, //!< No direction.
|
||||
DIRECTION_LEFT_TO_RIGHT, //!< Left to right.
|
||||
DIRECTION_RIGHT_TO_LEFT, //!< Right to left.
|
||||
DIRECTION_INVALID //!< Invalid direction.
|
||||
} Direction; //!< Direction of the wave.
|
||||
} WAVE_EFFECT_TYPE;
|
||||
}
|
||||
|
||||
//! Keypads
|
||||
namespace Keypad
|
||||
{
|
||||
//! Maximum number of rows.
|
||||
const RZSIZE MAX_ROW = 4;
|
||||
|
||||
//! Maximum number of columns.
|
||||
const RZSIZE MAX_COLUMN = 5;
|
||||
|
||||
//! Total number of keys.
|
||||
const RZSIZE MAX_KEYS = MAX_ROW * MAX_COLUMN;
|
||||
|
||||
//! Chroma keypad effect types
|
||||
typedef enum EFFECT_TYPE
|
||||
{
|
||||
CHROMA_NONE = 0, //!< No effect.
|
||||
CHROMA_BREATHING, //!< Breathing effect (Deprecated and should not be used).
|
||||
CHROMA_CUSTOM, //!< Custom effect.
|
||||
CHROMA_REACTIVE, //!< Reactive effect (Deprecated and should not be used).
|
||||
CHROMA_SPECTRUMCYCLING, //!< Spectrum cycling effect (Deprecated and should not be used).
|
||||
CHROMA_STATIC, //!< Static single color effect.
|
||||
CHROMA_WAVE, //!< Wave effect (Deprecated and should not be used).
|
||||
CHROMA_INVALID //!< Invalid effect.
|
||||
} EFFECT_TYPE;
|
||||
|
||||
// Chroma keypad effects
|
||||
//! Breathing effect type (Deprecated and should not be used).
|
||||
typedef struct BREATHING_EFFECT_TYPE
|
||||
{
|
||||
//! Breathing effects.
|
||||
enum Type
|
||||
{
|
||||
TWO_COLORS = 1, //!< 2 colors
|
||||
RANDOM_COLORS, //!< Random colors
|
||||
INVALID //!< Invalid type
|
||||
} Type;
|
||||
COLORREF Color1; //!< First color.
|
||||
COLORREF Color2; //!< Second color.
|
||||
} BREATHING_EFFECT_TYPE;
|
||||
|
||||
//! Custom effect type
|
||||
typedef struct CUSTOM_EFFECT_TYPE
|
||||
{
|
||||
RZCOLOR Color[MAX_ROW][MAX_COLUMN]; //!< Custom effect.
|
||||
//!< For Razer Tartarus Chroma only Color[0] is valid. Use index '0' to change the keypad color.
|
||||
} CUSTOM_EFFECT_TYPE;
|
||||
|
||||
//! Reactive effect type (Deprecated and should not be used).
|
||||
typedef struct REACTIVE_EFFECT_TYPE
|
||||
{
|
||||
//! Duration of the effect.
|
||||
enum Duration
|
||||
{
|
||||
DURATION_NONE=0, //!< No duration.
|
||||
DURATION_SHORT, //!< Short duration.
|
||||
DURATION_MEDIUM, //!< Medium duration.
|
||||
DURATION_LONG, //!< Long duration.
|
||||
DURATION_INVALID //!< Invalid duration.
|
||||
} Duration; //!< The time taken for the effect to fade away.
|
||||
|
||||
COLORREF Color; //!< Color of the effect
|
||||
} REACTIVE_EFFECT_TYPE;
|
||||
|
||||
//! Static effect type
|
||||
typedef struct STATIC_EFFECT_TYPE
|
||||
{
|
||||
RZCOLOR Color; //!< Color of the effect.
|
||||
} STATIC_EFFECT_TYPE;
|
||||
|
||||
//! Wave effect type (Deprecated and should not be used).
|
||||
typedef struct WAVE_EFFECT_TYPE
|
||||
{
|
||||
//! Direction of the wave effect.
|
||||
enum Direction
|
||||
{
|
||||
DIRECTION_NONE=0, //!< No direction.
|
||||
DIRECTION_LEFT_TO_RIGHT, //!< Left to right.
|
||||
DIRECTION_RIGHT_TO_LEFT, //!< Right to left.
|
||||
DIRECTION_INVALID //!< Invalid direction.
|
||||
} Direction; //!< Direction of the wave.
|
||||
} WAVE_EFFECT_TYPE;
|
||||
}
|
||||
|
||||
//! Chroma Link
|
||||
namespace ChromaLink
|
||||
{
|
||||
//! Maximum number of elements/LEDs
|
||||
const RZSIZE MAX_LEDS = 5;
|
||||
|
||||
//! Chroma Link effect types
|
||||
typedef enum EFFECT_TYPE
|
||||
{
|
||||
CHROMA_NONE = 0, //!< No effect.
|
||||
CHROMA_CUSTOM, //!< Custom effect.
|
||||
CHROMA_STATIC, //!< Static single color effect.
|
||||
CHROMA_INVALID //!< Invalid effect.
|
||||
} EFFECT_TYPE;
|
||||
|
||||
//! Custom effect type.\n
|
||||
//! Use Custom type to create a sequence of animated effects.\n
|
||||
//! [ChromaLinkL#1|ChromaLinkL#2|ChromaLinkL#3|ChromaLinkL#4|ChromaLinkL#5].\n
|
||||
typedef struct CUSTOM_EFFECT_TYPE
|
||||
{
|
||||
RZCOLOR Color[MAX_LEDS]; //!< Array of colors.
|
||||
} CUSTOM_EFFECT_TYPE;
|
||||
|
||||
//! Static effect type.\n
|
||||
//! Use Static type to create effects for all LEDs (ChromaLinkL#1).
|
||||
typedef struct STATIC_EFFECT_TYPE
|
||||
{
|
||||
RZCOLOR Color; //!< Color of the effect.
|
||||
} STATIC_EFFECT_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
|
||||
//! \file RzErrors.h
|
||||
//! \brief Error codes for Chroma SDK. If the error is not defined here, refer to WinError.h from the Windows SDK.
|
||||
|
||||
#ifndef _RZERRORS_H_
|
||||
#define _RZERRORS_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
// Error codes
|
||||
//! Invalid
|
||||
#define RZRESULT_INVALID -1L
|
||||
//! Success
|
||||
#define RZRESULT_SUCCESS 0L
|
||||
//! Access denied
|
||||
#define RZRESULT_ACCESS_DENIED 5L
|
||||
//! Invalid handle
|
||||
#define RZRESULT_INVALID_HANDLE 6L
|
||||
//! Not supported
|
||||
#define RZRESULT_NOT_SUPPORTED 50L
|
||||
//! Invalid parameter.
|
||||
#define RZRESULT_INVALID_PARAMETER 87L
|
||||
//! The service has not been started
|
||||
#define RZRESULT_SERVICE_NOT_ACTIVE 1062L
|
||||
//! Cannot start more than one instance of the specified program.
|
||||
#define RZRESULT_SINGLE_INSTANCE_APP 1152L
|
||||
//! Device not connected
|
||||
#define RZRESULT_DEVICE_NOT_CONNECTED 1167L
|
||||
//! Element not found.
|
||||
#define RZRESULT_NOT_FOUND 1168L
|
||||
//! Request aborted.
|
||||
#define RZRESULT_REQUEST_ABORTED 1235L
|
||||
//! An attempt was made to perform an initialization operation when initialization has already been completed.
|
||||
#define RZRESULT_ALREADY_INITIALIZED 1247L
|
||||
//! Resource not available or disabled
|
||||
#define RZRESULT_RESOURCE_DISABLED 4309L
|
||||
//! Device not available or supported
|
||||
#define RZRESULT_DEVICE_NOT_AVAILABLE 4319L
|
||||
//! The group or resource is not in the correct state to perform the requested operation.
|
||||
#define RZRESULT_NOT_VALID_STATE 5023L
|
||||
//! No more items
|
||||
#define RZRESULT_NO_MORE_ITEMS 259L
|
||||
//! General failure.
|
||||
#define RZRESULT_FAILED 2147500037L
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,160 @@
|
||||
/*-----------------------------------------*\
|
||||
| i2c_smbus_nct6775.cpp |
|
||||
| |
|
||||
| Nuvoton NCT67xx SMBUS driver for Windows |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 5/19/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus_nct6775.h"
|
||||
#include <Windows.h>
|
||||
#include "inpout32.h"
|
||||
|
||||
#pragma comment(lib, "inpout32.lib")
|
||||
|
||||
s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int size, i2c_smbus_data *data)
|
||||
{
|
||||
int i, len, status, cnt;
|
||||
|
||||
Out32(SMBHSTCTL, NCT6775_SOFT_RESET);
|
||||
|
||||
switch (size)
|
||||
{
|
||||
case I2C_SMBUS_QUICK:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
break;
|
||||
case I2C_SMBUS_BYTE:
|
||||
case I2C_SMBUS_BYTE_DATA:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
Out32(SMBHSTIDX, command);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
Out32(SMBHSTDAT, data->byte);
|
||||
Out32(SMBHSTCMD, NCT6775_WRITE_BYTE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Out32(SMBHSTCMD, NCT6775_READ_BYTE);
|
||||
}
|
||||
break;
|
||||
case I2C_SMBUS_WORD_DATA:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
Out32(SMBHSTIDX, command);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
Out32(SMBHSTDAT, data->word & 0xFF);
|
||||
Out32(SMBHSTDAT, (data->word & 0xFF00) >> 8);
|
||||
Out32(SMBHSTCMD, NCT6775_WRITE_WORD);
|
||||
}
|
||||
else
|
||||
{
|
||||
Out32(SMBHSTCMD, NCT6775_READ_WORD);
|
||||
}
|
||||
break;
|
||||
case I2C_SMBUS_BLOCK_DATA:
|
||||
Out32(SMBHSTADD, (addr << 1) | read_write);
|
||||
Out32(SMBHSTIDX, command);
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
len = data->block[0];
|
||||
if (len == 0 || len > I2C_SMBUS_BLOCK_MAX)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
Out32(SMBBLKSZ, len);
|
||||
|
||||
//Load 4 bytes into FIFO
|
||||
cnt = 1;
|
||||
if (len >= 4)
|
||||
{
|
||||
for (i = cnt; i <= 4; i++)
|
||||
{
|
||||
Out32(SMBHSTDAT, data->block[i]);
|
||||
}
|
||||
|
||||
len -= 4;
|
||||
cnt += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = cnt; i <= len; i++)
|
||||
{
|
||||
Out32(SMBHSTDAT, data->block[i]);
|
||||
}
|
||||
|
||||
len = 0;
|
||||
}
|
||||
|
||||
Out32(SMBHSTCMD, NCT6775_WRITE_BLOCK);
|
||||
}
|
||||
else
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
//Out32(SMBHSTCMD, NCT6775_READ_BLOCK);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
Out32(SMBHSTCTL, NCT6775_MANUAL_START);
|
||||
|
||||
while ((size == I2C_SMBUS_BLOCK_DATA) && (len > 0))
|
||||
{
|
||||
if (read_write == I2C_SMBUS_WRITE)
|
||||
{
|
||||
while ((Inp32(SMBHSTSTS) & NCT6775_FIFO_EMPTY) == 0);
|
||||
|
||||
//Load more bytes into FIFO
|
||||
if (len >= 4)
|
||||
{
|
||||
for (i = cnt; i <= (cnt + 4); i++)
|
||||
{
|
||||
Out32(SMBHSTDAT, data->block[i]);
|
||||
}
|
||||
|
||||
len -= 4;
|
||||
cnt += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = cnt; i <= (cnt + len); i++)
|
||||
{
|
||||
Out32(SMBHSTDAT, data->block[i]);
|
||||
}
|
||||
|
||||
len = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//wait for manual mode to complete
|
||||
while ((Inp32(SMBHSTSTS) & NCT6775_MANUAL_ACTIVE) != 0);
|
||||
|
||||
if ((Inp32(SMBHSTERR) & NCT6775_NO_ACK) != 0)
|
||||
{
|
||||
return -EPROTO;
|
||||
}
|
||||
else if ((read_write == I2C_SMBUS_WRITE) || (size == I2C_SMBUS_QUICK))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (size)
|
||||
{
|
||||
case I2C_SMBUS_QUICK:
|
||||
case I2C_SMBUS_BYTE_DATA:
|
||||
data->byte = (u8)Inp32(SMBHSTDAT);
|
||||
break;
|
||||
case I2C_SMBUS_WORD_DATA:
|
||||
data->word = Inp32(SMBHSTDAT) + (Inp32(SMBHSTDAT) << 8);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 i2c_smbus_nct6775::i2c_smbus_xfer(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data)
|
||||
{
|
||||
return nct6775_access(addr, read_write, command, size, data);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*-----------------------------------------*\
|
||||
| i2c_smbus_nct6775.h |
|
||||
| |
|
||||
| Nuvoton NCT67xx SMBUS driver for Windows |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 5/19/2019 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "i2c_smbus.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
#define SMBHSTDAT (0 + nct6775_smba)
|
||||
#define SMBBLKSZ (1 + nct6775_smba)
|
||||
#define SMBHSTCMD (2 + nct6775_smba)
|
||||
#define SMBHSTIDX (3 + nct6775_smba) //Index field is the Command field on other controllers
|
||||
#define SMBHSTCTL (4 + nct6775_smba)
|
||||
#define SMBHSTADD (5 + nct6775_smba)
|
||||
#define SMBHSTERR (9 + nct6775_smba)
|
||||
#define SMBHSTSTS (0xE + nct6775_smba)
|
||||
|
||||
/* Command register */
|
||||
#define NCT6775_READ_BYTE 0
|
||||
#define NCT6775_READ_WORD 1
|
||||
#define NCT6775_READ_BLOCK 2
|
||||
#define NCT6775_BLOCK_WRITE_READ_PROC_CALL 3
|
||||
#define NCT6775_PROC_CALL 4
|
||||
#define NCT6775_WRITE_BYTE 8
|
||||
#define NCT6775_WRITE_WORD 9
|
||||
#define NCT6775_WRITE_BLOCK 10
|
||||
|
||||
/* Control register */
|
||||
#define NCT6775_MANUAL_START 128
|
||||
#define NCT6775_SOFT_RESET 64
|
||||
|
||||
/* Error register */
|
||||
#define NCT6775_NO_ACK 32
|
||||
|
||||
/* Status register */
|
||||
#define NCT6775_FIFO_EMPTY 1
|
||||
#define NCT6775_FIFO_FULL 2
|
||||
#define NCT6775_MANUAL_ACTIVE 4
|
||||
|
||||
class i2c_smbus_nct6775: public i2c_smbus_interface
|
||||
{
|
||||
public:
|
||||
u16 nct6775_smba = 0x0290;
|
||||
|
||||
private:
|
||||
s32 nct6775_access(u16 addr, char read_write, u8 command, int size, i2c_smbus_data *data);
|
||||
s32 i2c_smbus_xfer(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data);
|
||||
|
||||
};
|
||||
@@ -0,0 +1,55 @@
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* main.cpp *
|
||||
* *
|
||||
* Main function for OpenAuraSDK GUI project *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#include "OpenAuraSDK.h"
|
||||
#include "RGBController.h"
|
||||
#include "i2c_smbus.h"
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "OpenAuraSDKQtDialog.h"
|
||||
|
||||
|
||||
extern std::vector<i2c_smbus_interface*> busses;
|
||||
extern std::vector<RGBController*> rgb_controllers;
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* main *
|
||||
* *
|
||||
* Main function. Detects busses and Aura controllers, then opens the main window *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
DetectRGBControllers();
|
||||
|
||||
QApplication a(argc, argv);
|
||||
|
||||
Ui::OpenAuraSDKQtDialog dlg(busses, rgb_controllers);
|
||||
dlg.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* wWinMain *
|
||||
* *
|
||||
* Entry point for Windows. Calls main(). *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
#ifdef WIN32
|
||||
//int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
|
||||
//{
|
||||
// main(0, NULL);
|
||||
//}
|
||||
#endif
|
||||
@@ -0,0 +1,371 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Cross Platform Network Library for Windows and Linux |
|
||||
| This library provides access to TCP and UDP ports with |
|
||||
| a common API for both Windows and Linux systems. It |
|
||||
| features read and write |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 12/15/2016 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "net_port.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <memory.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <iostream>
|
||||
|
||||
const char yes = 1;
|
||||
|
||||
net_port::net_port()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//net_port (constructor)
|
||||
// When created with port information, the constructor
|
||||
// will automatically open client address <client_name> on port <port>
|
||||
net_port::net_port(const char * client_name, const char * port)
|
||||
{
|
||||
udp_client(client_name, port);
|
||||
}
|
||||
|
||||
net_port::~net_port()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool net_port::udp_client(const char * client_name, const char * port)
|
||||
{
|
||||
sockaddr_in myAddress;
|
||||
|
||||
#ifdef WIN32
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsa) != NO_ERROR)
|
||||
{
|
||||
WSACleanup();
|
||||
return(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock == INVALID_SOCKET)
|
||||
{
|
||||
WSACleanup();
|
||||
return(false);
|
||||
}
|
||||
|
||||
myAddress.sin_family = AF_INET;
|
||||
myAddress.sin_addr.s_addr = inet_addr("0.0.0.0");
|
||||
myAddress.sin_port = htons(0);
|
||||
|
||||
if (bind(sock, (sockaddr*)&myAddress, sizeof(myAddress)) == SOCKET_ERROR)
|
||||
{
|
||||
WSACleanup();
|
||||
return false;
|
||||
}
|
||||
|
||||
result_list = NULL;
|
||||
addrinfo hints = {};
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
if(getaddrinfo(client_name, port, &hints, &result_list) == 0)
|
||||
{
|
||||
memcpy(&addrDest, result_list->ai_addr, result_list->ai_addrlen);
|
||||
freeaddrinfo(result_list);
|
||||
return(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
WSACleanup();
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
int net_port::udp_listen(char * recv_data, int length)
|
||||
{
|
||||
return(recvfrom(sock, recv_data, length, 0, NULL, NULL));
|
||||
}
|
||||
|
||||
int net_port::udp_write(char * buffer, int length)
|
||||
{
|
||||
return(sendto(sock, buffer, length, 0, (sockaddr *)&addrDest, sizeof(addrDest)));
|
||||
}
|
||||
|
||||
bool net_port::tcp_client(const char * client_name, const char * port)
|
||||
{
|
||||
addrinfo hints = {};
|
||||
|
||||
connected = false;
|
||||
result_list = NULL;
|
||||
|
||||
#ifdef WIN32
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsa) != NO_ERROR)
|
||||
{
|
||||
WSACleanup();
|
||||
return(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
port = strtok((char *)port, "\r");
|
||||
|
||||
hints.ai_family = AF_INET;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
getaddrinfo(client_name, port, &hints, &result_list);
|
||||
|
||||
if(result_list == NULL)
|
||||
{
|
||||
WSACleanup();
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool net_port::tcp_client_connect()
|
||||
{
|
||||
if (!connected)
|
||||
{
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sock == INVALID_SOCKET)
|
||||
{
|
||||
WSACleanup();
|
||||
return(false);
|
||||
}
|
||||
|
||||
u_long arg = 1;
|
||||
fd_set fdset;
|
||||
timeval tv;
|
||||
|
||||
ioctlsocket(sock, FIONBIO, &arg);
|
||||
|
||||
if(result_list == NULL)
|
||||
{
|
||||
connected = false;
|
||||
return(false);
|
||||
}
|
||||
connect(sock, result_list->ai_addr, result_list->ai_addrlen);
|
||||
|
||||
FD_ZERO(&fdset);
|
||||
FD_SET(sock, &fdset);
|
||||
|
||||
tv.tv_sec = 4;
|
||||
tv.tv_usec = 0;
|
||||
|
||||
if (select(sock + 1, NULL, &fdset, NULL, &tv) == 1)
|
||||
{
|
||||
char so_error;
|
||||
socklen_t len = sizeof(so_error);
|
||||
|
||||
getsockopt(sock, SOL_SOCKET, SO_ERROR, &so_error, &len);
|
||||
|
||||
if (so_error == 0)
|
||||
{
|
||||
connected = true;
|
||||
arg = 0;
|
||||
ioctlsocket(sock, FIONBIO, &arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
connected = false;
|
||||
closesocket(sock);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
connected = false;
|
||||
closesocket(sock);
|
||||
}
|
||||
}
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool net_port::tcp_server(const char * port)
|
||||
{
|
||||
sockaddr_in myAddress;
|
||||
|
||||
#ifdef WIN32
|
||||
if (WSAStartup(MAKEWORD(2, 2), &wsa) != NO_ERROR)
|
||||
{
|
||||
WSACleanup();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sock == INVALID_SOCKET)
|
||||
{
|
||||
WSACleanup();
|
||||
return false;
|
||||
}
|
||||
|
||||
port = strtok((char *)port, "\r");
|
||||
|
||||
myAddress.sin_family = AF_INET;
|
||||
myAddress.sin_addr.s_addr = inet_addr("0.0.0.0");
|
||||
myAddress.sin_port = htons(atoi(port));
|
||||
|
||||
if (bind(sock, (sockaddr*)&myAddress, sizeof(myAddress)) == SOCKET_ERROR)
|
||||
{
|
||||
WSACleanup();
|
||||
return false;
|
||||
}
|
||||
|
||||
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void net_port::tcp_server_listen()
|
||||
{
|
||||
SOCKET * client = new SOCKET();
|
||||
listen(sock, 10);
|
||||
*client = accept(sock, NULL, NULL);
|
||||
u_long arg = 0;
|
||||
ioctlsocket(*client, FIONBIO, &arg);
|
||||
setsockopt(*client, IPPROTO_TCP, TCP_NODELAY, &yes, sizeof(yes));
|
||||
clients.push_back(client);
|
||||
}
|
||||
|
||||
void net_port::tcp_close()
|
||||
{
|
||||
closesocket(sock);
|
||||
connected = false;
|
||||
}
|
||||
|
||||
int net_port::tcp_listen(char * recv_data, int length)
|
||||
{
|
||||
int ret = 0;
|
||||
int len = 0;
|
||||
int tot = 0;
|
||||
timeval waitd;
|
||||
|
||||
fd_set readfd;
|
||||
|
||||
FD_ZERO(&readfd);
|
||||
FD_SET(sock, &readfd);
|
||||
|
||||
if (connected)
|
||||
{
|
||||
while(ret != sizeof(len))
|
||||
{
|
||||
waitd.tv_sec = 10;
|
||||
waitd.tv_usec = 0;
|
||||
|
||||
if (select(sock + 1, &readfd, NULL, NULL, &waitd))
|
||||
{
|
||||
ret = recv(sock, (char *)&len, sizeof(len), 0);
|
||||
|
||||
if (ret == -1 || ret == 0)
|
||||
{
|
||||
closesocket(sock);
|
||||
connected = false;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
closesocket(sock);
|
||||
connected = false;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
while(tot != len)
|
||||
{
|
||||
waitd.tv_sec = 10;
|
||||
waitd.tv_usec = 0;
|
||||
|
||||
if (select(sock + 1, &readfd, NULL, NULL, &waitd))
|
||||
{
|
||||
ret = recv(sock, recv_data + ret, len - ret, 0);
|
||||
|
||||
if (ret == -1 || ret == 0)
|
||||
{
|
||||
closesocket(sock);
|
||||
connected = false;
|
||||
return(0);
|
||||
}
|
||||
|
||||
tot += ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
closesocket(sock);
|
||||
connected = false;
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int net_port::tcp_client_write(char * buffer, int length)
|
||||
{
|
||||
return(send(sock, buffer, length, 0));
|
||||
}
|
||||
|
||||
int net_port::tcp_write(char * buffer, int length)
|
||||
{
|
||||
int ret = length;
|
||||
int val = length;
|
||||
|
||||
timeval waitd;
|
||||
fd_set writefd;
|
||||
|
||||
for (unsigned int i = 0; i < clients.size(); i++)
|
||||
{
|
||||
val = length;
|
||||
|
||||
FD_ZERO(&writefd);
|
||||
FD_SET(*(clients[i]), &writefd);
|
||||
|
||||
waitd.tv_sec = 5;
|
||||
waitd.tv_usec = 0;
|
||||
|
||||
if (select(*(clients[i]) + 1, NULL, &writefd, NULL, &waitd))
|
||||
{
|
||||
val = send(*(clients[i]), (const char *)&length, sizeof(length), 0);
|
||||
|
||||
if (val == -1)
|
||||
{
|
||||
clients.erase(clients.begin() + i);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clients.erase(clients.begin() + i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
waitd.tv_sec = 5;
|
||||
waitd.tv_usec = 0;
|
||||
|
||||
if (select(*(clients[i]) + 1, NULL, &writefd, NULL, &waitd))
|
||||
{
|
||||
val = send(*(clients[i]), buffer, length, 0);
|
||||
|
||||
if (val == -1)
|
||||
{
|
||||
clients.erase(clients.begin() + i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (val != length)
|
||||
{
|
||||
ret = val;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clients.erase(clients.begin() + i);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Cross Platform Network Library for Windows and Linux |
|
||||
| This library provides access to TCP and UDP ports with |
|
||||
| a common API for both Windows and Linux systems. It |
|
||||
| features read and write |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 12/15/2016 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#ifndef NET_PORT_H
|
||||
#define NET_PORT_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <net/if.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
#define SOCKET int
|
||||
#define ioctlsocket ioctl
|
||||
#define closesocket close
|
||||
#define WSACleanup()
|
||||
#define INVALID_SOCKET -1
|
||||
#define SOCKET_ERROR -1
|
||||
#endif
|
||||
|
||||
//Network Port Class
|
||||
//The reason for this class is that network ports are treated differently
|
||||
//on Windows and Linux. By creating a class, those differences can be
|
||||
//made invisible to the program and make cross-platform usage easy
|
||||
|
||||
class net_port
|
||||
{
|
||||
public:
|
||||
net_port();
|
||||
net_port(const char * client_name, const char * port);
|
||||
|
||||
~net_port();
|
||||
|
||||
//Function to open the port
|
||||
bool udp_client(const char* client_name, const char * port);
|
||||
bool tcp_client(const char* client_name, const char * port);
|
||||
bool tcp_client_connect();
|
||||
|
||||
//Function to open a server
|
||||
bool tcp_server(const char * port);
|
||||
void tcp_server_listen();
|
||||
|
||||
int udp_listen(char * recv_data, int length);
|
||||
int tcp_listen(char * recv_data, int length);
|
||||
|
||||
//Function to write data to the serial port
|
||||
int udp_write(char * buffer, int length);
|
||||
int tcp_write(char * buffer, int length);
|
||||
int tcp_client_write(char * buffer, int length);
|
||||
|
||||
void tcp_close();
|
||||
|
||||
bool connected;
|
||||
|
||||
private:
|
||||
#ifdef WIN32
|
||||
WSADATA wsa;
|
||||
#endif
|
||||
SOCKET sock;
|
||||
std::vector<SOCKET *> clients;
|
||||
|
||||
sockaddr addrDest;
|
||||
addrinfo* result_list;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,199 @@
|
||||
#include "OpenAuraSDKQtDialog.h"
|
||||
#include "OpenAuraSDK.h"
|
||||
|
||||
using namespace Ui;
|
||||
|
||||
OpenAuraSDKQtDialog::OpenAuraSDKQtDialog(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, QWidget *parent) : QMainWindow(parent), busses(bus), controllers (control), ui(new OpenAuraSDKQtDialogUi)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QIcon icon(":OpenRGB.png");
|
||||
setWindowIcon(icon);
|
||||
|
||||
QPalette pal;
|
||||
|
||||
pal = ui->ButtonRed->palette();
|
||||
pal.setColor(QPalette::Button, QColor(255, 0, 0));
|
||||
ui->ButtonRed->setAutoFillBackground(true);
|
||||
ui->ButtonRed->setPalette(pal);
|
||||
ui->ButtonRed->setFlat(true);
|
||||
ui->ButtonRed->update();
|
||||
|
||||
pal = ui->ButtonYellow->palette();
|
||||
pal.setColor(QPalette::Button, QColor(255, 255, 0));
|
||||
ui->ButtonYellow->setAutoFillBackground(true);
|
||||
ui->ButtonYellow->setPalette(pal);
|
||||
ui->ButtonYellow->setFlat(true);
|
||||
ui->ButtonYellow->update();
|
||||
|
||||
pal = ui->ButtonGreen->palette();
|
||||
pal.setColor(QPalette::Button, QColor(0, 255, 0));
|
||||
ui->ButtonGreen->setAutoFillBackground(true);
|
||||
ui->ButtonGreen->setPalette(pal);
|
||||
ui->ButtonGreen->setFlat(true);
|
||||
ui->ButtonGreen->update();
|
||||
|
||||
pal = ui->ButtonCyan->palette();
|
||||
pal.setColor(QPalette::Button, QColor(0, 255, 255));
|
||||
ui->ButtonCyan->setAutoFillBackground(true);
|
||||
ui->ButtonCyan->setPalette(pal);
|
||||
ui->ButtonCyan->setFlat(true);
|
||||
ui->ButtonCyan->update();
|
||||
|
||||
pal = ui->ButtonBlue->palette();
|
||||
pal.setColor(QPalette::Button, QColor(0, 0, 255));
|
||||
ui->ButtonBlue->setAutoFillBackground(true);
|
||||
ui->ButtonBlue->setPalette(pal);
|
||||
ui->ButtonBlue->setFlat(true);
|
||||
ui->ButtonBlue->update();
|
||||
|
||||
pal = ui->ButtonMagenta->palette();
|
||||
pal.setColor(QPalette::Button, QColor(255, 0, 255));
|
||||
ui->ButtonMagenta->setAutoFillBackground(true);
|
||||
ui->ButtonMagenta->setPalette(pal);
|
||||
ui->ButtonMagenta->setFlat(true);
|
||||
ui->ButtonMagenta->update();
|
||||
|
||||
for (int i = 0; i < controllers.size(); i++)
|
||||
{
|
||||
ui->ComboDevices->addItem(controllers[i]->name.c_str());
|
||||
}
|
||||
|
||||
//Triggers on_ComboDevices_currentIndexChanged so we don't need to update the other fields here
|
||||
ui->ComboDevices->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
OpenAuraSDKQtDialog::~OpenAuraSDKQtDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void OpenAuraSDKQtDialog::show()
|
||||
{
|
||||
QMainWindow::show();
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ButtonRed_clicked()
|
||||
{
|
||||
ui->EditLED0R->setText("255");
|
||||
ui->EditLED0G->setText("0");
|
||||
ui->EditLED0B->setText("0");
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ButtonYellow_clicked()
|
||||
{
|
||||
ui->EditLED0R->setText("255");
|
||||
ui->EditLED0G->setText("255");
|
||||
ui->EditLED0B->setText("0");
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ButtonGreen_clicked()
|
||||
{
|
||||
ui->EditLED0R->setText("0");
|
||||
ui->EditLED0G->setText("255");
|
||||
ui->EditLED0B->setText("0");
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ButtonCyan_clicked()
|
||||
{
|
||||
ui->EditLED0R->setText("0");
|
||||
ui->EditLED0G->setText("255");
|
||||
ui->EditLED0B->setText("255");
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ButtonBlue_clicked()
|
||||
{
|
||||
ui->EditLED0R->setText("0");
|
||||
ui->EditLED0G->setText("0");
|
||||
ui->EditLED0B->setText("255");
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ButtonMagenta_clicked()
|
||||
{
|
||||
ui->EditLED0R->setText("255");
|
||||
ui->EditLED0G->setText("0");
|
||||
ui->EditLED0B->setText("255");
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ButtonSetAll_clicked()
|
||||
{
|
||||
RGBColor color = ToRGBColor(
|
||||
ui->EditLED0R->text().toInt(),
|
||||
ui->EditLED0G->text().toInt(),
|
||||
ui->EditLED0B->text().toInt()
|
||||
);
|
||||
|
||||
for (int i = 0; i < controllers.size(); i++)
|
||||
{
|
||||
controllers[i]->SetCustomMode();
|
||||
controllers[i]->SetAllLEDs(color);
|
||||
}
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ButtonSetDevice_clicked()
|
||||
{
|
||||
RGBColor color = ToRGBColor(
|
||||
ui->EditLED0R->text().toInt(),
|
||||
ui->EditLED0G->text().toInt(),
|
||||
ui->EditLED0B->text().toInt()
|
||||
);
|
||||
|
||||
controllers[ui->ComboDevices->currentIndex()]->SetAllLEDs(color);
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ButtonSetZone_clicked()
|
||||
{
|
||||
RGBColor color = ToRGBColor(
|
||||
ui->EditLED0R->text().toInt(),
|
||||
ui->EditLED0G->text().toInt(),
|
||||
ui->EditLED0B->text().toInt()
|
||||
);
|
||||
|
||||
controllers[ui->ComboDevices->currentIndex()]->SetAllZoneLEDs(ui->ComboZones->currentIndex(), color);
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ButtonSetLED_clicked()
|
||||
{
|
||||
RGBColor color = ToRGBColor(
|
||||
ui->EditLED0R->text().toInt(),
|
||||
ui->EditLED0G->text().toInt(),
|
||||
ui->EditLED0B->text().toInt()
|
||||
);
|
||||
|
||||
controllers[ui->ComboDevices->currentIndex()]->SetLED(ui->ComboLEDs->currentIndex(), color);
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ComboDevices_currentIndexChanged(int index)
|
||||
{
|
||||
ui->ComboModes->clear();
|
||||
|
||||
for (int i = 0; i < controllers[ui->ComboDevices->currentIndex()]->modes.size(); i++)
|
||||
{
|
||||
ui->ComboModes->addItem(controllers[ui->ComboDevices->currentIndex()]->modes[i].name.c_str());
|
||||
}
|
||||
|
||||
ui->ComboModes->setCurrentIndex(controllers[ui->ComboDevices->currentIndex()]->GetMode());
|
||||
|
||||
ui->ComboZones->clear();
|
||||
|
||||
for (int i = 0; i < controllers[ui->ComboDevices->currentIndex()]->zones.size(); i++)
|
||||
{
|
||||
ui->ComboZones->addItem(controllers[ui->ComboDevices->currentIndex()]->zones[i].name.c_str());
|
||||
}
|
||||
|
||||
ui->ComboZones->setCurrentIndex(0);
|
||||
|
||||
ui->ComboLEDs->clear();
|
||||
|
||||
for (int i = 0; i < controllers[ui->ComboDevices->currentIndex()]->leds.size(); i++)
|
||||
{
|
||||
ui->ComboLEDs->addItem(controllers[ui->ComboDevices->currentIndex()]->leds[i].name.c_str());
|
||||
}
|
||||
|
||||
ui->ComboLEDs->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void Ui::OpenAuraSDKQtDialog::on_ComboModes_currentIndexChanged(int index)
|
||||
{
|
||||
controllers[ui->ComboDevices->currentIndex()]->SetMode(ui->ComboModes->currentIndex());
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
#ifndef OPENAURASDKQTDIALOG_H
|
||||
#define OPENAURASDKQTDIALOG_H
|
||||
|
||||
#include "ui_openaurasdk.h"
|
||||
|
||||
#include <vector>
|
||||
#include "i2c_smbus.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QTimer>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class OpenAuraSDKQtDialog;
|
||||
}
|
||||
|
||||
class Ui::OpenAuraSDKQtDialog : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit OpenAuraSDKQtDialog(std::vector<i2c_smbus_interface *>& bus, std::vector<RGBController *>& control, QWidget *parent = 0);
|
||||
~OpenAuraSDKQtDialog();
|
||||
|
||||
void show();
|
||||
void setMode(unsigned char mode_val);
|
||||
|
||||
protected:
|
||||
std::vector<i2c_smbus_interface *>& busses;
|
||||
std::vector<RGBController *>& controllers;
|
||||
|
||||
private slots:
|
||||
void on_ButtonRed_clicked();
|
||||
void on_ButtonYellow_clicked();
|
||||
void on_ButtonGreen_clicked();
|
||||
void on_ButtonCyan_clicked();
|
||||
void on_ButtonBlue_clicked();
|
||||
void on_ButtonMagenta_clicked();
|
||||
|
||||
void on_ButtonSetAll_clicked();
|
||||
|
||||
void on_ButtonSetDevice_clicked();
|
||||
|
||||
void on_ButtonSetZone_clicked();
|
||||
|
||||
void on_ButtonSetLED_clicked();
|
||||
|
||||
void on_ComboDevices_currentIndexChanged(int index);
|
||||
|
||||
void on_ComboModes_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
Ui::OpenAuraSDKQtDialogUi *ui;
|
||||
};
|
||||
|
||||
#endif // OPENAURASDKQTDIALOG_H
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.7 KiB |
@@ -0,0 +1,312 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>OpenAuraSDKQtDialogUi</class>
|
||||
<widget class="QMainWindow" name="OpenAuraSDKQtDialogUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>500</width>
|
||||
<height>160</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>OpenAuraSDK</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QPushButton" name="ButtonSetAll">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>80</y>
|
||||
<width>80</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set All</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="ButtonSetZone">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>110</y>
|
||||
<width>80</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set Zone</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="EditLED0R">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>50</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="EditLED0G">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>50</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="EditLED0B">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>50</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="LabelRed">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>30</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Red</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="LabelGreen">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>30</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Green</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="LabelBlue">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>30</y>
|
||||
<width>50</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Blue</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="ComboDevices">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>290</x>
|
||||
<y>10</y>
|
||||
<width>200</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="LabelAuraDevice">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>10</y>
|
||||
<width>90</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Device</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="ComboModes">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>290</x>
|
||||
<y>40</y>
|
||||
<width>200</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="LabelMode">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>40</y>
|
||||
<width>90</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="ComboZones">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>290</x>
|
||||
<y>70</y>
|
||||
<width>200</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="LabelZone">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>70</y>
|
||||
<width>90</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Zone</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="ComboLEDs">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>290</x>
|
||||
<y>100</y>
|
||||
<width>200</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="LabelLED">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>100</y>
|
||||
<width>90</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>LED</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="ButtonSetLED">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>110</y>
|
||||
<width>80</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set LED</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="ButtonSetDevice">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>80</y>
|
||||
<width>80</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Set Device</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="ButtonRed">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>21</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="ButtonYellow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>10</y>
|
||||
<width>21</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="ButtonGreen">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>10</y>
|
||||
<width>21</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="ButtonCyan">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>10</y>
|
||||
<width>21</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="ButtonBlue">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>130</x>
|
||||
<y>10</y>
|
||||
<width>21</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="ButtonMagenta">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>160</x>
|
||||
<y>10</y>
|
||||
<width>21</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>OpenRGB.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -0,0 +1,219 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Cross Platform Serial COM Library for Windows and Linux |
|
||||
| This library provides access to serial ports with a |
|
||||
| common API for both Windows and Linux systems. It |
|
||||
| features read and write as well as tx/rx buffer flush. |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/21/2013 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "serial_port.h"
|
||||
|
||||
//serial_port (constructor)
|
||||
// The default constructor does not initialize the serial port
|
||||
serial_port::serial_port()
|
||||
{
|
||||
//Set a default baud rate
|
||||
baud_rate = 9600;
|
||||
}
|
||||
|
||||
//serial_port (constructor)
|
||||
// When created with port information, the constructor
|
||||
// will automatically open port <name> at baud rate <baud>
|
||||
serial_port::serial_port(const char * name, unsigned int baud)
|
||||
{
|
||||
serial_open(name, baud);
|
||||
}
|
||||
|
||||
//~serial_port (destructor)
|
||||
// Closes the port before destroying the object
|
||||
serial_port::~serial_port()
|
||||
{
|
||||
serial_close();
|
||||
}
|
||||
|
||||
//open
|
||||
// Opens the serial port using stored information
|
||||
// Sets the baud rate to the stored baud rate
|
||||
// 8 data bits, no parity, one stop bit
|
||||
bool serial_port::serial_open()
|
||||
{
|
||||
// printf("SerialPort: Opening serial port %s at baud rate %d.\n", port_name, baud_rate);
|
||||
|
||||
#ifdef WIN32
|
||||
file_descriptor = CreateFile(port_name, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
if((int)file_descriptor < 0)
|
||||
{
|
||||
// printf("SerialPort: Port %s could not be opened: %d.\n", port_name, file_descriptor);
|
||||
return false;
|
||||
}
|
||||
|
||||
SetupComm(file_descriptor, 1, 128);
|
||||
GetCommState(file_descriptor, &dcb);
|
||||
|
||||
dcb.BaudRate = baud_rate; //Set baud rate
|
||||
dcb.ByteSize = 8; //8 data bits
|
||||
dcb.Parity = NOPARITY; //Parity = none
|
||||
dcb.StopBits = ONESTOPBIT; //One stop bit
|
||||
dcb.fAbortOnError = TRUE; //Abort on error
|
||||
dcb.fOutX = FALSE; //XON/XOFF off for transmit
|
||||
dcb.fInX = FALSE; //XON/XOFF off for receive
|
||||
dcb.fOutxCtsFlow = FALSE; //Turn off CTS flow control
|
||||
dcb.fRtsControl = RTS_CONTROL_DISABLE; //Options DISABLE, ENABLE, HANDSHAKE
|
||||
dcb.fOutxDsrFlow = FALSE; //Turn off DSR flow control
|
||||
dcb.fDtrControl = DTR_CONTROL_DISABLE; //Disable DTR control
|
||||
|
||||
SetCommState(file_descriptor, &dcb);
|
||||
|
||||
COMMTIMEOUTS timeouts = {0};
|
||||
timeouts.ReadIntervalTimeout = 50;
|
||||
timeouts.ReadTotalTimeoutConstant=50;
|
||||
timeouts.ReadTotalTimeoutMultiplier=10;
|
||||
timeouts.WriteTotalTimeoutConstant=50;
|
||||
timeouts.WriteTotalTimeoutMultiplier=10;
|
||||
SetCommTimeouts(file_descriptor, &timeouts);
|
||||
|
||||
#else
|
||||
|
||||
file_descriptor = open(port_name, O_RDWR | O_NOCTTY | O_NDELAY);
|
||||
|
||||
if(file_descriptor < 0)
|
||||
{
|
||||
// printf("SerialPort: Port %s could not be opened: %d.\n", port_name, file_descriptor);
|
||||
return false;
|
||||
}
|
||||
|
||||
struct termios2 options;
|
||||
ioctl(file_descriptor, TCGETS2, &options);
|
||||
options.c_cflag &= ~CBAUD;
|
||||
options.c_cflag |= BOTHER;
|
||||
options.c_ispeed = baud_rate;
|
||||
options.c_ospeed = baud_rate;
|
||||
ioctl(file_descriptor, TCSETS2, &options);
|
||||
|
||||
//serial_struct ss;
|
||||
//int closestSpeed;
|
||||
//ioctl(file_descriptor, TIOCGSERIAL, &ss);
|
||||
//ss.flags = (ss.flags & ~ASYNC_SPD_MASK) | ASYNC_SPD_CUST | ASYNCB_LOW_LATENCY;
|
||||
//ss.custom_divisor = (ss.baud_base + (baud_rate / 2)) / baud_rate;
|
||||
//if(ss.custom_divisor == 0)
|
||||
//{
|
||||
// closestSpeed = baud_rate;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// closestSpeed = ss.baud_base / ss.custom_divisor;
|
||||
//}
|
||||
|
||||
//if((float)closestSpeed < ((float)baud_rate * (98.0f/100.0f)) || (float)closestSpeed > ((float)baud_rate * (102.0f/100.0f)))
|
||||
//{
|
||||
// printf("SerialPort: Cannot set %s to %d. Closest possible speed is %d.\n", port_name, baud_rate, closestSpeed);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// printf("SerialPort: %s speed set to %d.\n", port_name, baud_rate);
|
||||
//}
|
||||
|
||||
//fcntl(file_descriptor, F_SETFL, 0);
|
||||
#endif
|
||||
|
||||
// printf("SerialPort: Serial port %s opened successfully.\n", port_name);
|
||||
return true;
|
||||
}
|
||||
|
||||
//open
|
||||
// Opens the serial port <name> without changing stored baud rate
|
||||
bool serial_port::serial_open(const char * name)
|
||||
{
|
||||
return serial_open(name, baud_rate);
|
||||
}
|
||||
|
||||
//open
|
||||
// Opens the serial port <name> at baud rate <baud>
|
||||
bool serial_port::serial_open(const char* name, unsigned int baud)
|
||||
{
|
||||
strcpy(port_name, name);
|
||||
baud_rate = baud;
|
||||
return serial_open();
|
||||
}
|
||||
|
||||
//close
|
||||
// Closes the serial port
|
||||
void serial_port::serial_close()
|
||||
{
|
||||
// printf("SerialPort: Closing port %s.\n", port_name);
|
||||
#ifdef WIN32
|
||||
|
||||
#else
|
||||
|
||||
close(file_descriptor);
|
||||
#endif
|
||||
}
|
||||
|
||||
// read
|
||||
// Reads <length> bytes from the serial port into <buffer>
|
||||
// Returns the number of bytes actually read
|
||||
// If less than <length> bytes are available, it will read all
|
||||
// available bytes
|
||||
int serial_port::serial_read(char * buffer, int length)
|
||||
{
|
||||
#ifdef WIN32
|
||||
DWORD bytesread;
|
||||
ReadFile(file_descriptor, buffer, length, &bytesread, NULL);
|
||||
|
||||
#else
|
||||
|
||||
int bytesread;
|
||||
bytesread = read(file_descriptor, buffer, length);
|
||||
#endif
|
||||
|
||||
//printf("SerialPort: Read %d bytes on port %s.\n", bytesread, port_name);
|
||||
return bytesread;
|
||||
}
|
||||
|
||||
//write
|
||||
// Writes <length> bytes to the serial port from <buffer>
|
||||
// Returns the number of bytes actually written
|
||||
// Does not check for null-termination, so if <length> is
|
||||
// greater than the number of bytes in <buffer>, it will read
|
||||
// past <buffer> and may cause a segfault
|
||||
int serial_port::serial_write(char * buffer, int length)
|
||||
{
|
||||
#ifdef WIN32
|
||||
DWORD byteswritten;
|
||||
WriteFile(file_descriptor, buffer, length, &byteswritten, NULL);
|
||||
|
||||
#else
|
||||
|
||||
int byteswritten;
|
||||
byteswritten = write(file_descriptor, buffer, length);
|
||||
#endif
|
||||
|
||||
//printf("SerialPort: Wrote %d bytes on port %s.\n", byteswritten, port_name);
|
||||
return byteswritten;
|
||||
}
|
||||
|
||||
//flush
|
||||
void serial_port::serial_flush_rx()
|
||||
{
|
||||
#ifdef WIN32
|
||||
PurgeComm(file_descriptor, PURGE_RXABORT | PURGE_RXCLEAR);
|
||||
|
||||
#else
|
||||
|
||||
tcflush(file_descriptor, TCIFLUSH);
|
||||
#endif
|
||||
}
|
||||
|
||||
void serial_port::serial_flush_tx()
|
||||
{
|
||||
|
||||
#ifdef WIN32
|
||||
PurgeComm(file_descriptor, PURGE_TXABORT | PURGE_TXCLEAR);
|
||||
|
||||
#else
|
||||
|
||||
tcflush(file_descriptor, TCOFLUSH);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| Cross Platform Serial COM Library for Windows and Linux |
|
||||
| This library provides access to serial ports with a |
|
||||
| common API for both Windows and Linux systems. It |
|
||||
| features read and write as well as tx/rx buffer flush. |
|
||||
| |
|
||||
| Adam Honse ([email protected]), 1/21/2013 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#ifndef SERIAL_PORT_H
|
||||
#define SERIAL_PORT_H
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <termios.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
//winsize, termio, and termios structs are redefined in
|
||||
//asm/termios.h, to prevent compiler errors from multply
|
||||
//defining them, use a #define to rename them -
|
||||
//essentially to undef them before they are redefined
|
||||
#define winsize undefine_winsize
|
||||
#define termio undefine_termio
|
||||
#define termios undefine_termios
|
||||
|
||||
#include <asm/termios.h>
|
||||
#include <asm-generic/ioctls.h>
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//Serial Port Class
|
||||
//The reason for this class is that serial ports are treated differently
|
||||
//on Windows and Linux. By creating a class, those differences can be
|
||||
//made invisible to the program and make cross-platform usage easy
|
||||
|
||||
class serial_port
|
||||
{
|
||||
public:
|
||||
serial_port();
|
||||
serial_port(const char * name, unsigned int baud);
|
||||
|
||||
~serial_port();
|
||||
|
||||
//Function to open the port
|
||||
bool serial_open();
|
||||
bool serial_open(const char* name);
|
||||
bool serial_open(const char* name, unsigned int baud);
|
||||
|
||||
//Function to close the port
|
||||
void serial_close();
|
||||
|
||||
//Functions for controlling baud rate
|
||||
void serial_set_baud(unsigned int baud);
|
||||
int serial_get_baud();
|
||||
|
||||
//Function to read data from the port buffer
|
||||
int serial_read(char * buffer, int length);
|
||||
|
||||
//Function to write data to the serial port
|
||||
int serial_write(char * buffer, int length);
|
||||
|
||||
//Functions to flush the serial port rx and tx buffers
|
||||
void serial_flush_rx();
|
||||
void serial_flush_tx();
|
||||
|
||||
//Function to list the number of available bytes
|
||||
int serial_available();
|
||||
|
||||
private:
|
||||
char port_name[1024];
|
||||
unsigned int baud_rate;
|
||||
|
||||
#ifdef WIN32
|
||||
HANDLE file_descriptor;
|
||||
DCB dcb;
|
||||
|
||||
#else
|
||||
|
||||
int file_descriptor;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -155,7 +155,7 @@ HRESULT Wmi::query(std::string queryStr, std::vector<QueryObj>& queryVectorOut,
|
||||
|
||||
while (pEnumerator)
|
||||
{
|
||||
hres = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
|
||||
hres = pEnumerator->Next(WMI_WAIT_TIME, 1, &pclsObj, &uReturn);
|
||||
|
||||
if (0==uReturn)
|
||||
{
|
||||
@@ -9,6 +9,8 @@
|
||||
#include <Wbemidl.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#define WMI_WAIT_TIME 2000 /// Max time to wait for next object in when enumerating next object in wmi query in milliseconds
|
||||
|
||||
#pragma comment(lib, "wbemuuid.lib")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user