Compare commits

..
75 changed files with 982 additions and 6404 deletions
@@ -0,0 +1,202 @@
/*-----------------------------------------*\
| AuraAddressableController.cpp |
| |
| Driver for ASUS Aura RGB Addressable |
| lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/18/2020 |
\*-----------------------------------------*/
#include "AuraAddressableController.h"
#include <cstring>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
AuraAddressableController::AuraAddressableController(hid_device* dev_handle)
{
dev = dev_handle;
channel_leds[0] = 40;
}
AuraAddressableController::~AuraAddressableController()
{
}
void AuraAddressableController::SetLEDsDirect(std::vector<RGBColor> colors)
{
unsigned char led_data[60];
unsigned int leds_sent = 0;
SendDirectBegin();
while(leds_sent < colors.size())
{
unsigned int leds_to_send = 20;
if((colors.size() - leds_sent) < leds_to_send)
{
leds_to_send = colors.size() - leds_sent;
}
for(int led_idx = 0; leds_to_send < 20; led_idx++)
{
led_data[(led_idx * 3) + 0] = RGBGetRValue(colors[led_idx]);
led_data[(led_idx * 3) + 1] = RGBGetGValue(colors[led_idx]);
led_data[(led_idx * 3) + 2] = RGBGetBValue(colors[led_idx]);
}
SendDirect
(
0,
leds_sent,
leds_to_send,
led_data
);
}
SendDirectApply();
}
void AuraAddressableController::SetMode
(
unsigned char mode,
unsigned char red,
unsigned char grn,
unsigned char blu
)
{
SendEffect
(
mode,
red,
grn,
blu
);
}
void AuraAddressableController::SendEffect
(
unsigned char mode,
unsigned char red,
unsigned char grn,
unsigned char blu
)
{
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0xEC;
usb_buf[0x01] = AURA_CONTROL_MODE_EFFECT;
usb_buf[0x02] = 0x00;
usb_buf[0x03] = 0x00;
usb_buf[0x04] = mode;
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
usb_buf[0x05] = red;
usb_buf[0x06] = grn;
usb_buf[0x07] = blu;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, 64);
}
void AuraAddressableController::SendDirect
(
unsigned char device,
unsigned char start_led,
unsigned char led_count,
unsigned char* led_data
)
{
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0xEC;
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
usb_buf[0x02] = device;
usb_buf[0x03] = start_led;
usb_buf[0x04] = led_count;
/*-----------------------------------------------------*\
| Copy in color data bytes |
\*-----------------------------------------------------*/
memcpy(&usb_buf[0x05], led_data, led_count * 3);
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, 64);
}
void AuraAddressableController::SendDirectBegin()
{
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0xEC;
usb_buf[0x01] = AURA_CONTROL_MODE_EFFECT;
usb_buf[0x04] = 0xFF;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, 64);
}
void AuraAddressableController::SendDirectApply()
{
unsigned char usb_buf[65];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up message packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0xEC;
usb_buf[0x01] = AURA_CONTROL_MODE_DIRECT;
usb_buf[0x02] = 0x80;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, usb_buf, 64);
}
@@ -0,0 +1,84 @@
/*-----------------------------------------*\
| AuraAddressableController.h |
| |
| Definitions and types for ASUS Aura |
| Addressable RGB lighting controller |
| |
| Adam Honse (CalcProgrammer1) 1/18/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
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_MODE_MUSIC = 14, /* Music effect mode */
};
enum
{
AURA_CONTROL_MODE_EFFECT = 0x3B, /* Effect control mode */
AURA_CONTROL_MODE_DIRECT = 0x40, /* Direct control mode */
};
class AuraAddressableController
{
public:
AuraAddressableController(hid_device* dev_handle);
~AuraAddressableController();
void SetLEDsDirect(std::vector<RGBColor> colors);
void SetMode
(
unsigned char mode,
unsigned char red,
unsigned char grn,
unsigned char blu
);
unsigned int channel_leds[1];
private:
char device_name[32];
hid_device* dev;
unsigned int led_count;
void SendEffect
(
unsigned char mode,
unsigned char red,
unsigned char grn,
unsigned char blu
);
void SendDirect
(
unsigned char device,
unsigned char start_led,
unsigned char led_count,
unsigned char* led_data
);
void SendDirectBegin();
void SendDirectApply();
};
@@ -0,0 +1,36 @@
#include "AuraAddressableController.h"
#include "RGBController.h"
#include "RGBController_AuraAddressable.h"
#include <vector>
#include <hidapi/hidapi.h>
#define AURA_ADDRESSABLE_VID 0x0B05
#define AURA_ADDRESSABLE_PID 0x1872
/******************************************************************************************\
* *
* DetectAuraAddressableControllers *
* *
* Tests the USB address to see if an Asus Aura addressable RGB header controller *
* exists there. *
* *
\******************************************************************************************/
void DetectAuraAddressableControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device* dev;
//Look for Asus Aura addressable RGB header controller
hid_init();
dev = hid_open(AURA_ADDRESSABLE_VID, AURA_ADDRESSABLE_PID, 0);
if( dev )
{
AuraAddressableController* controller = new AuraAddressableController(dev);
RGBController_AuraAddressable* rgb_controller = new RGBController_AuraAddressable(controller);
rgb_controllers.push_back(rgb_controller);
}
}
@@ -135,7 +135,7 @@ void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vecto
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
int address_list_idx = -1;
int address_list_idx = 0;
// Remap Aura-enabled RAM modules on 0x77
for (unsigned int slot = 0; slot < 8; slot++)
@@ -151,8 +151,8 @@ void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vecto
{
if(address_list_idx < AURA_RAM_ADDRESS_COUNT)
{
address_list_idx++;
res = busses[bus]->i2c_smbus_write_quick(aura_ram_addresses[address_list_idx], I2C_SMBUS_WRITE);
address_list_idx++;
}
else
{
@@ -1,84 +0,0 @@
/*-----------------------------------------*\
| AuraGPUController.cpp |
| |
| Driver for ASUS Aura RGB on GPUs |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#include "AuraGPUController.h"
#include <cstring>
AuraGPUController::AuraGPUController(i2c_smbus_interface* bus, aura_gpu_dev_id dev)
{
this->bus = bus;
this->dev = dev;
strcpy(device_name, "ASUS Aura GPU"); // Would be nice to get the actual GPU name. Using this as a placeholder.
}
AuraGPUController::~AuraGPUController()
{
}
std::string AuraGPUController::GetDeviceName()
{
return(device_name);
}
std::string AuraGPUController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
unsigned char AuraGPUController::GetLEDRed()
{
return(AuraGPURegisterRead(AURA_GPU_REG_RED));
}
unsigned char AuraGPUController::GetLEDGreen()
{
return(AuraGPURegisterRead(AURA_GPU_REG_GREEN));
}
unsigned char AuraGPUController::GetLEDBlue()
{
return(AuraGPURegisterRead(AURA_GPU_REG_BLUE));
}
void AuraGPUController::SetLEDColorsDirect(unsigned char red, unsigned char green, unsigned char blue) // Direct Mode is just Static Mode without applying color changes
{
AuraGPURegisterWrite(AURA_GPU_REG_RED, red);
AuraGPURegisterWrite(AURA_GPU_REG_GREEN, green);
AuraGPURegisterWrite(AURA_GPU_REG_BLUE, blue);
}
void AuraGPUController::SetLEDColorsEffect(unsigned char red, unsigned char green, unsigned char blue)
{
AuraGPURegisterWrite(AURA_GPU_REG_RED, red);
AuraGPURegisterWrite(AURA_GPU_REG_GREEN, green);
AuraGPURegisterWrite(AURA_GPU_REG_BLUE, blue);
AuraGPURegisterWrite(AURA_GPU_REG_APPLY, AURA_GPU_APPLY_VAL);
}
void AuraGPUController::SetMode(unsigned char mode)
{
AuraGPURegisterWrite(AURA_GPU_REG_MODE, mode);
AuraGPURegisterWrite(AURA_GPU_REG_APPLY, AURA_GPU_APPLY_VAL);
}
unsigned char AuraGPUController::AuraGPURegisterRead(unsigned char reg)
{
return(bus->i2c_smbus_read_byte_data(dev, reg));
}
void AuraGPUController::AuraGPURegisterWrite(unsigned char reg, unsigned char val)
{
bus->i2c_smbus_write_byte_data(dev, reg, val);
}
@@ -1,64 +0,0 @@
/*-----------------------------------------*\
| AuraGPUController.h |
| |
| Definitions for ASUS Aura RGB on GPUs |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char aura_gpu_dev_id;
#define AURA_GPU_MAGIC_VAL 0x1589 /* This magic value is present in all Aura GPU controllers */
#define AURA_GPU_APPLY_VAL 0x01 /* Value for Apply Changes Register */
enum
{
AURA_GPU_REG_RED = 0x04, /* AURA GPU RED Register */
AURA_GPU_REG_GREEN = 0x05, /* AURA GPU GREEN Register */
AURA_GPU_REG_BLUE = 0x06, /* AURA GPU BLUE Register */
AURA_GPU_REG_MODE = 0x07, /* AURA GPU Mode Selection Register */
AURA_GPU_REG_SYNC = 0x0C, /* AURA GPU "Sync" Register */
AURA_GPU_REG_APPLY = 0x0E, /* AURA GPU Apply Chnages Register */
};
enum
{
AURA_GPU_MODE_OFF = 0, /* OFF mode (not a real Mode! Doesn't do anything!) */
AURA_GPU_MODE_STATIC = 1, /* Static color mode */
AURA_GPU_MODE_BREATHING = 2, /* Breathing effect mode */
AURA_GPU_MODE_FLASHING = 3, /* Flashing effect mode */
AURA_GPU_MODE_SPECTRUM_CYCLE = 4, /* Spectrum Cycle mode */
AURA_GPU_MODE_DIRECT = 5, /* Direct mode (not a real Mode! Doesn't do anything!) */
AURA_GPU_NUMBER_MODES
};
class AuraGPUController
{
public:
AuraGPUController(i2c_smbus_interface* bus, aura_gpu_dev_id);
~AuraGPUController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned char GetLEDRed();
unsigned char GetLEDGreen();
unsigned char GetLEDBlue();
void SetLEDColorsDirect(unsigned char red, unsigned char green, unsigned char blue);
void SetLEDColorsEffect(unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode);
unsigned char AuraGPURegisterRead(unsigned char reg);
void AuraGPURegisterWrite(unsigned char reg, unsigned char val);
bool direct = false; // Temporary solution to check if we are in "Direct" mode
private:
char device_name[16];
i2c_smbus_interface * bus;
aura_gpu_dev_id dev;
};
@@ -1,94 +0,0 @@
/*-----------------------------------------*\
| AuraGPUControllerDetect.cpp |
| |
| Driver for ASUS Aura RGB on GPUs |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#include "AuraGPUController.h"
#include "RGBController.h"
#include "RGBController_AuraGPU.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
/*-------------------------------------------------------------*\
| This list contains the available I2C addresses for Aura GPUs |
\*-------------------------------------------------------------*/
#define AURA_GPU_ADDRESS_COUNT 3
static const unsigned char aura_gpu_addresses[] =
{
0x29,
0x2A,
0x60
};
/******************************************************************************************\
* *
* TestForAuraGPUController *
* *
* Tests the given address to see if an Aura GPU controller exists there. *
* *
\******************************************************************************************/
bool TestForAuraGPUController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
unsigned char aura_gpu_magic_high = bus->i2c_smbus_read_byte_data(address, 0x20); // High Byte of magic (0x15)
unsigned char aura_gpu_magic_low = bus->i2c_smbus_read_byte_data(address, 0x21); // Low Byte of magic (0x89)
if((aura_gpu_magic_high << 8) + aura_gpu_magic_low == AURA_GPU_MAGIC_VAL)
{
pass = true;
}
return(pass);
} /* TestForAuraGPUController() */
/******************************************************************************************\
* *
* DetectAuraGPUControllers *
* *
* Detect Aura GPU controllers on the enumerated I2C busses. *
* *
\******************************************************************************************/
void DetectAuraGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers)
{
AuraGPUController* new_aura_gpu;
RGBController_AuraGPU* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Add Aura-enabled GPU controllers
for (unsigned int address_list_idx = 0; address_list_idx < AURA_GPU_ADDRESS_COUNT; address_list_idx++)
{
if (TestForAuraGPUController(busses[bus], aura_gpu_addresses[address_list_idx]))
{
new_aura_gpu = new AuraGPUController(busses[bus], aura_gpu_addresses[address_list_idx]);
new_controller = new RGBController_AuraGPU(new_aura_gpu);
rgb_controllers.push_back(new_controller);
}
Sleep(1);
}
}
} /* DetectAuraGPUControllers() */
@@ -137,7 +137,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
red_color_data
);
Sleep(5);
Sleep(2);
SendDirect
(
@@ -145,7 +145,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
grn_color_data
);
Sleep(5);
Sleep(2);
SendDirect
(
@@ -153,7 +153,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
blu_color_data
);
Sleep(5);
Sleep(2);
SendDirectExtended
(
@@ -189,8 +189,6 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
red_color_data
);
Sleep(5);
SendColor
(
0x01,
@@ -198,8 +196,6 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
grn_color_data
);
Sleep(5);
SendColor
(
0x01,
@@ -207,8 +203,6 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
blu_color_data
);
Sleep(5);
SendExtendedColor
(
0x01,
@@ -1,99 +0,0 @@
/*-----------------------------------------*\
| MSIRGBController.cpp |
| |
| Driver for MSI-RGB lighting controller |
| |
| Logic adapted from: |
| https://github.com/nagisa/msi-rgb |
| |
| Adam Honse (CalcProgrammer1) 2/11/2020 |
\*-----------------------------------------*/
#include "MSIRGBController.h"
#include "super_io.h"
MSIRGBController::MSIRGBController(int sioaddr)
{
msi_sioaddr = sioaddr;
/*-----------------------------------------------------*\
| This setup step isn't well documented |
| Without this, pulsing does not work |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, SIO_REG_LOGDEV, 0x09);
int val_at_2c = superio_inb(msi_sioaddr, 0x2C);
val_at_2c &= 0b11110111;
val_at_2c |= 0b00010000;
superio_outb(msi_sioaddr, 0x2C, val_at_2c);
/*-----------------------------------------------------*\
| Set logical device register to RGB controller |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, SIO_REG_LOGDEV, MSI_SIO_LOGDEV_RGB);
/*-----------------------------------------------------*\
| Test if RGB is enabled. If it is not, enable it. |
\*-----------------------------------------------------*/
int enable = superio_inb(msi_sioaddr, MSI_SIO_RGB_REG_ENABLE);
if((enable & MSI_SIO_RGB_ENABLE_MASK) != MSI_SIO_RGB_ENABLE_MASK)
{
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_ENABLE, MSI_SIO_RGB_ENABLE_MASK & (enable & !MSI_SIO_RGB_ENABLE_MASK));
}
/*-----------------------------------------------------*\
| Lighting enabled, no pulsing or blinking |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_CFG_1, 0x00);
/*-----------------------------------------------------*\
| Lighting enabled, RGB non-inverted, header on |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_CFG_3, 0xE2);
}
MSIRGBController::~MSIRGBController()
{
}
void MSIRGBController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{
/*-----------------------------------------------------*\
| The MSI RGB controller uses 4 bits per color rather |
| than 8. Shift the values by 4 so that the 4 most |
| significant bits of each color are the new color value|
\*-----------------------------------------------------*/
red = red >> 4;
green = green >> 4;
blue = blue >> 4;
/*-----------------------------------------------------*\
| Set logical device register to RGB controller |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, SIO_REG_LOGDEV, MSI_SIO_LOGDEV_RGB);
/*-----------------------------------------------------*\
| Write the colors to the color sequence registers |
| Only static mode is supported right now - all colors |
| are the same. |
\*-----------------------------------------------------*/
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_1_0, (red | (red << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_3_2, (red | (red << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_5_4, (red | (red << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_RED_7_6, (red | (red << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_1_0, (green | (green << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_3_2, (green | (green << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_5_4, (green | (green << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_GREEN_7_6, (green | (green << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_1_0, (blue | (blue << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_3_2, (blue | (blue << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_5_4, (blue | (blue << 4)));
superio_outb(msi_sioaddr, MSI_SIO_RGB_REG_BLUE_7_6, (blue | (blue << 4)));
}
@@ -1,56 +0,0 @@
/*-----------------------------------------*\
| MSIRGBController.h |
| |
| Definitions and types for MSI-RGB |
| lighting controller |
| |
| Logic adapted from: |
| https://github.com/nagisa/msi-rgb |
| |
| Adam Honse (CalcProgrammer1) 2/11/2020 |
\*-----------------------------------------*/
#include <string>
#pragma once
#define MSI_SIO_LOGDEV_RGB 0x12
enum
{
MSI_SIO_RGB_REG_ENABLE = 0xE0,
MSI_SIO_RGB_REG_CFG_1 = 0xE4,
MSI_SIO_RGB_REG_RED_1_0 = 0xF0,
MSI_SIO_RGB_REG_RED_3_2 = 0xF1,
MSI_SIO_RGB_REG_RED_5_4 = 0xF2,
MSI_SIO_RGB_REG_RED_7_6 = 0xF3,
MSI_SIO_RGB_REG_GREEN_1_0 = 0xF4,
MSI_SIO_RGB_REG_GREEN_3_2 = 0xF5,
MSI_SIO_RGB_REG_GREEN_5_4 = 0xF6,
MSI_SIO_RGB_REG_GREEN_7_6 = 0xF7,
MSI_SIO_RGB_REG_BLUE_1_0 = 0xF8,
MSI_SIO_RGB_REG_BLUE_3_2 = 0xF9,
MSI_SIO_RGB_REG_BLUE_5_4 = 0xFA,
MSI_SIO_RGB_REG_BLUE_7_6 = 0xFB,
MSI_SIO_RGB_REG_CFG_2 = 0xFE,
MSI_SIO_RGB_REG_CFG_3 = 0xFF,
};
#define MSI_SIO_RGB_ENABLE_MASK 0xE0
class MSIRGBController
{
public:
MSIRGBController(int sioaddr);
~MSIRGBController();
std::string GetDeviceName();
std::string GetDeviceLocation();
unsigned int GetMode();
void SetMode(unsigned char new_mode, unsigned char new_speed);
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
private:
int msi_sioaddr;
};
@@ -1,40 +0,0 @@
#include "MSIRGBController.h"
#include "RGBController.h"
#include "RGBController_MSIRGB.h"
#include "super_io.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/******************************************************************************************\
* *
* DetectMSIRGBControllers *
* *
* Detect MSI-RGB compatible Super-IO chips. *
* *
\******************************************************************************************/
void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers)
{
int sio_addrs[2] = {0x2E, 0x4E};
for(int sioaddr_idx = 0; sioaddr_idx < 2; sioaddr_idx++)
{
int sioaddr = sio_addrs[sioaddr_idx];
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_NCT6795_ID:
case SIO_NCT6797_ID:
MSIRGBController* new_msi = new MSIRGBController(sioaddr);
RGBController_MSIRGB* new_rgb = new RGBController_MSIRGB(new_msi);
rgb_controllers.push_back(new_rgb);
break;
}
}
} /* DetectMSIRGBControllers() */
@@ -104,9 +104,6 @@ void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
| Send packets |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, red_grn_buf, 264);
Sleep(5);
hid_send_feature_report(dev, blu_buf, 264);
}
@@ -4,282 +4,118 @@
| Driver for Gigabyte Aorus RGB Fusion 2.0 |
| lighting controller |
| |
| jackun 1/8/2020 |
| Adam Honse (CalcProgrammer1) 1/15/2020 |
\*-----------------------------------------*/
#include "RGBFusion2Controller.h"
#include <algorithm>
#include <array>
#include <thread>
#include <chrono>
#include <cstring>
#include <stdio.h>
#include <stdlib.h>
static LEDCount LedCountToEnum(unsigned int c)
RGBFusion2Controller::RGBFusion2Controller(hid_device* dev_handle)
{
if (c <= 32)
return(LEDS_32);
if (c <= 64)
return(LEDS_64);
if (c <= 256)
return(LEDS_256);
if (c <= 512)
return(LEDS_512);
dev = dev_handle;
return(LEDS_1024);
}
// Set Device name
strcpy(device_name, "Gigabyte Motherboard");
RGBFusion2Controller::RGBFusion2Controller(hid_device* handle, const char *path) : dev(handle)
{
int res = 0;
char text[64] {};
unsigned char buffer[64] {};
if( dev ) {
SetCalibration();
// hid report read needs 0x60 packet or it gives IO error
SendPacket(0x60, 0x00);
buffer[0] = report_id;
res = hid_get_feature_report(dev, buffer, 64);
if( res > 0 )
{
report = *reinterpret_cast<IT8297Report*>(buffer);
name = std::string(report.str_product, 32);
name.erase(std::find(name.begin(), name.end(), '\0'), name.end());
snprintf(text, 11, "0x%08X", report.fw_ver);
version = text;
snprintf(text, 11, "0x%08X", report.chip_id);
chip_id = text;
}
loc = path;
EnableBeat(false);
}
// Set LED count
led_count = 8;
}
RGBFusion2Controller::~RGBFusion2Controller()
{
if( dev ) {
hid_close(dev);
}
}
void RGBFusion2Controller::SetMode(int m)
{
mode = m;
}
// Sets RGB color mapping to LED pins.
// "Custom" RGB packets don't seem to get remapped so use report.byteorderN and do it manually.
// Of course it all depends how we send data to the controller, but bios/rgb fusion 2 itself
// set it up like this.
void RGBFusion2Controller::SetCalibration()
{
uint8_t buffer[64] {};
buffer[0] = report_id;
buffer[1] = 0x33;
// D_LED1 WS2812 GRB, 0x00RRGGBB to 0x00GGRRBB
buffer[2] = 0x02; // B
buffer[3] = 0x00; // G
buffer[4] = 0x01; // R
buffer[5] = 0x00;
// D_LED2 WS2812 GRB
buffer[6] = 0x02;
buffer[7] = 0x00;
buffer[8] = 0x01;
buffer[9] = 0x00;
// LED C1/C2 12vGRB, seems pins already connect to LEDs correctly
buffer[10] = 0x00;
buffer[11] = 0x01;
buffer[12] = 0x02;
buffer[13] = 0x00;
SendPacket(buffer);
}
void RGBFusion2Controller::SetLedCount(unsigned int count)
{
led_count = count;
LEDCount s0 = LedCountToEnum(count);
SendPacket(0x34, s0 | (s0 << 4)); // D_LED1 | D_LED2
}
bool RGBFusion2Controller::DisableBuiltinEffect(int enable_bit, int mask)
{
if(effect_disabled & enable_bit)
return(true);
effect_disabled &= ~mask;
effect_disabled |= enable_bit;
int res = SendPacket(0x32, effect_disabled);
// Sometimes effect doesn't apply at first, delay a little and let MCU to react, if this packet is the cause
std::this_thread::sleep_for(std::chrono::milliseconds(50));
return res;
}
bool RGBFusion2Controller::EnableBeat(bool e)
{
return SendPacket(0x31, e ? 1 : 0);
}
std::string RGBFusion2Controller::GetDeviceName()
{
return(name);
}
std::string RGBFusion2Controller::GetFWVersion()
{
return(version);
return(device_name);
}
std::string RGBFusion2Controller::GetDeviceLocation()
{
return(loc);
return("");
}
std::string RGBFusion2Controller::GetSerial()
unsigned int RGBFusion2Controller::GetLEDCount()
{
return(chip_id);
return(led_count);
}
void RGBFusion2Controller::SetStripColors(unsigned int hdr, int start, int end, std::vector<RGBColor>& colors, int single_led)
unsigned char RGBFusion2Controller::GetMode()
{
PktRGB pkt;
pkt.Init(hdr, report_id);
return(0);
}
// FIXME assuming that LED strips ports are 0x58/0x59 for all boards
uint32_t byteorder = hdr == HDR_D_LED1_RGB ? report.byteorder0 : report.byteorder1;
void RGBFusion2Controller::SetAllColors(unsigned char red, unsigned char green, unsigned char blue)
{
}
unsigned char bo_r = byteorder >> 16;
unsigned char bo_g = byteorder >> 8;
unsigned char bo_b = byteorder & 0xFF;
int res;
int leds_left = end - start;
int sent_data = 0;
int k = 0;
int leds_in_pkt = sizeof(pkt.s.leds) / sizeof(*pkt.s.leds); /* 19 */
// other leds stay at whatever the builtin effect was doing at that moment
// if breathing/pulse effect faded out then they stay dark
if(single_led > -1)
void RGBFusion2Controller::SetLEDColor(unsigned int led, unsigned char red, unsigned char green, unsigned char blue)
{
unsigned char usb_buf[] =
{
leds_left = 1;
k = single_led - start;
sent_data = k * 3;
leds_in_pkt = 1;
}
0xCC, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
0x5A, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
while(leds_left > 0)
usb_buf[0x01] = (0x20 | led);
usb_buf[0x02] = (0x01 << led );
usb_buf[0x0E] = blue;
usb_buf[0x0F] = green;
usb_buf[0x10] = red;
hid_send_feature_report(dev, usb_buf, 64);
SendApply();
}
void RGBFusion2Controller::SendApply()
{
unsigned char usb_buf[] =
{
leds_in_pkt = (std::min)(leds_in_pkt, leds_left);
leds_left -= leds_in_pkt;
0xCC, 0x28, 0xFF, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
};
pkt.s.bcount = leds_in_pkt * 3;
pkt.s.boffset = sent_data;
sent_data += pkt.s.bcount;
for(int i = 0; i < leds_in_pkt; i++)
{
RGBColor color = colors[start + k];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
pkt.buffer[5 + i * 3 + bo_r] = red;
pkt.buffer[5 + i * 3 + bo_g] = grn;
pkt.buffer[5 + i * 3 + bo_b] = blu;
k++;
}
res = SendPacket(pkt.buffer);
if(res < 0)
return;
}
if (hdr == HDR_D_LED1_RGB)
DisableBuiltinEffect(0x01, 0x01);
else
DisableBuiltinEffect(0x02, 0x02);
hid_send_feature_report(dev, usb_buf, 64);
}
static const std::array< std::array<int, 3>, 5> speeds = {
{
{1600, 1600, 200},
{1200, 1200, 200},
{800, 800, 200},
{400, 400, 200},
{200, 200, 200},
},
};
void RGBFusion2Controller::SetLEDEffect(unsigned int led, int mode, unsigned int speed, bool random, unsigned char r, unsigned char g, unsigned char b)
void RGBFusion2Controller::SetMode(unsigned char mode)
{
PktEffect pkt;
pkt.Init(led, report_id);
pkt.e.effect_type = mode;
pkt.e.color0 = r << 16 | g << 8 | b;
if (speed < speeds.size()) {
const auto& s = speeds[speed];
pkt.e.period0 = s[0];
pkt.e.period1 = s[1];
pkt.e.period2 = s[2];
}
switch(mode)
{
case 0: break;
case 1: break; // static
case 2: // breathing
case 3: // blink
if (random)
pkt.e.effect_param0 = 7; // cycle through up to 7 (max?) colors
break;
case 4: // color cycle
pkt.e.effect_param0 = 7; // cycle through up to 7 (max?) colors
break;
// "fake" effects
case 10: // flashing, flashing color cycle
pkt.e.period0 = 200;
pkt.e.period1 = 200;
pkt.e.period2 = 5000 - 1000 * speed; // time between flashing, doesn't seem to be affected by period0/period1
pkt.e.effect_type = 3;
pkt.e.effect_param2 = 2; // flash twice
if (random)
pkt.e.effect_param0 = 7;
break;
}
SendPacket(pkt.buffer);
}
bool RGBFusion2Controller::ApplyEffect()
void RGBFusion2Controller::dump()
{
return SendPacket(0x28, 0xFF);
}
bool RGBFusion2Controller::SendPacket(uint8_t a, uint8_t b, uint8_t c)
{
unsigned char buffer[64] {};
buffer[0] = report_id;
buffer[1] = a;
buffer[2] = b;
buffer[3] = c;
return (SendPacket(buffer) == 64);
}
int RGBFusion2Controller::SendPacket(unsigned char* packet)
{
return hid_send_feature_report(dev, packet, 64);
}
@@ -4,187 +4,36 @@
| Definitions and types for Gigabyte Aorus |
| RGB Fusion 2.0 lighting controller |
| |
| jackun 1/8/2020 |
| Adam Honse (CalcProgrammer1) 1/15/2020 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <cstring>
#include <string>
#include <hidapi/hidapi.h>
#pragma once
// LED "headers" 0x20..0x27, As seen on Gigabyte X570 Elite board
const uint8_t HDR_BACK_IO = 0x20;
const uint8_t HDR_CPU = 0x21;
const uint8_t HDR_LED_2 = 0x22;
const uint8_t HDR_PCIE = 0x23;
const uint8_t HDR_LED_C1C2 = 0x24;
const uint8_t HDR_D_LED1 = 0x25;
const uint8_t HDR_D_LED2 = 0x26;
const uint8_t HDR_LED_7 = 0x27;
const uint8_t HDR_D_LED1_RGB = 0x58; // FIXME assuming that it is 0x58 for all boards
const uint8_t HDR_D_LED2_RGB = 0x59;
enum EffectType
{
EFFECT_NONE = 0,
EFFECT_STATIC = 1,
EFFECT_PULSE = 2,
EFFECT_BLINKING = 3,
EFFECT_COLORCYCLE = 4,
// to be continued...
};
enum LEDCount
{
LEDS_32 = 0,
LEDS_64,
LEDS_256,
LEDS_512,
LEDS_1024,
};
struct LEDs
{
uint8_t r;
uint8_t g;
uint8_t b;
};
#pragma pack(push, 1)
union PktRGB
{
unsigned char buffer[64];
struct RGBData
{
uint8_t report_id;
uint8_t header;
uint16_t boffset; // in bytes, absolute
uint8_t bcount;
LEDs leds[19];
uint16_t padding0;
} s;
PktRGB() : s {}
{
}
void Init(uint8_t header, uint8_t report_id)
{
s.report_id = report_id;
s.header = header;
s.boffset = 0;
s.bcount = 0;
memset(s.leds, 0, sizeof(s.leds));
}
};
union PktEffect
{
unsigned char buffer[64];
struct Effect
{
uint8_t report_id;
uint8_t header;
uint32_t zone0; // rgb fusion seems to set it to pow(2, header - 0x20)
uint32_t zone1;
uint8_t reserved0;
uint8_t effect_type;
uint8_t max_brightness;
uint8_t min_brightness;
uint32_t color0;
uint32_t color1;
uint16_t period0; // fade in
uint16_t period1; // fade out
uint16_t period2; // hold
uint16_t period3;
uint8_t effect_param0;
uint8_t effect_param1;
uint8_t effect_param2;
uint8_t effect_param3;
uint8_t padding0[30];
} e;
PktEffect() : e {}
{
}
void Init(int header, uint8_t report_id)
{
memset(buffer, 0, sizeof(buffer));
e.report_id = report_id;
if (header < 8)
e.header = 32 + header; // set as default
else
e.header = header;
e.zone0 = (uint32_t)(1 << (e.header - 32));
e.effect_type = EFFECT_STATIC;
e.max_brightness = 100;
e.min_brightness = 0;
e.color0 = 0x00FF2100; //orange
e.period0 = 1200;
e.period1 = 1200;
e.period2 = 200;
e.period3 = 200;
e.effect_param0 = 0; // ex color count to cycle through (max seems to be 7)
e.effect_param1 = 0;
e.effect_param2 = 1; // ex flash repeat count
e.effect_param3 = 0;
}
};
struct IT8297Report
{
uint8_t report_id;
uint8_t product;
uint8_t device_num;
uint8_t total_leds;
uint32_t fw_ver;
uint16_t curr_led_count;
uint16_t reserved0;
char str_product[32]; // might be 28 and an extra byteorder3
uint32_t byteorder0; // is little-endian 0x00RRGGBB ?
uint32_t byteorder1;
uint32_t byteorder2;
uint32_t chip_id;
uint32_t reserved1;
};
#pragma pack(pop)
class RGBFusion2Controller
{
public:
RGBFusion2Controller(hid_device* handle, const char *path);
RGBFusion2Controller(hid_device* dev_handle);
~RGBFusion2Controller();
void SetStripColors(unsigned int hdr, int start, int end, std::vector<RGBColor>& colors, int single_led = -1);
void SetLEDEffect(unsigned int led, int mode, unsigned int speed, bool random, unsigned char red, unsigned char green, unsigned char blue);
void SetLedCount(unsigned int count);
void SetMode(int mode);
bool ApplyEffect();
bool DisableBuiltinEffect(int enable_bit, int mask);
void SetCalibration();
std::string GetDeviceName();
std::string GetDeviceLocation();
std::string GetFWVersion();
std::string GetSerial();
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:
bool EnableBeat(bool enable);
bool SendPacket(uint8_t a, uint8_t b, uint8_t c = 0);
int SendPacket(unsigned char* packet);
void dump();
hid_device* dev;
int mode;
char device_name[32];
unsigned int led_count;
IT8297Report report;
std::string name;
std::string loc;
std::string version;
std::string chip_id;
int effect_disabled = 0;
int report_id = 0xCC;
void SendApply();
hid_device* dev;
};
@@ -1,37 +1,36 @@
#include "RGBFusion2Controller.h"
#include "RGBController.h"
#include "RGBController_RGBFusion2.h"
#include <vector>
#include <hidapi/hidapi.h>
#define IT8297_VID 0x048D
#define IT8297_PID 0x8297
#define RGB_FUSION_2_VID 0x048D
#define RGB_FUSION_2_PID 0x8297
/******************************************************************************************\
* *
* DetectRGBFusion2Controllers *
* *
* Detect RGB Fusion 2 devices that use IT8297 RGB controller *
* Detect RGB Fusion 2.0 controllers on the USB interface. *
* *
\******************************************************************************************/
void DetectRGBFusion2Controllers(std::vector<RGBController*> &rgb_controllers)
void DetectRGBFusion2Controllers(std::vector<RGBController*>& rgb_controllers)
{
if (hid_init() < 0)
return;
hid_device* dev;
hid_device_info * device_list = hid_enumerate(IT8297_VID, IT8297_PID);
if (!device_list)
return;
//Look for RGB Fusion 2.0 Controller
hid_init();
hid_device_info * device = device_list;
while (device)
dev = hid_open(RGB_FUSION_2_VID, RGB_FUSION_2_PID, 0);
if( dev )
{
hid_device * dev = hid_open_path(device->path);
if (dev) {
RGBFusion2Controller * controller = new RGBFusion2Controller(dev, device_list->path);
RGBController_RGBFusion2 * rgb_controller = new RGBController_RGBFusion2(controller);
rgb_controllers.push_back(rgb_controller);
}
device = device->next;
RGBFusion2Controller* controller = new RGBFusion2Controller(dev);
RGBController_RGBFusion2* rgb_controller = new RGBController_RGBFusion2(controller);
rgb_controllers.push_back(rgb_controller);
}
hid_free_enumeration(device_list);
}
} /* DetectRGBFusionControllers() */
@@ -1,47 +0,0 @@
/*-----------------------------------------*\
| RGBFusionGPUController.cpp |
| |
| Driver for Gigabyte Aorus RGB Fusion GPU |
| lighting controller |
| |
| Adam Honse (CalcProgrammer1) 2/20/2020 |
\*-----------------------------------------*/
#include "RGBFusionGPUController.h"
RGBFusionGPUController::RGBFusionGPUController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev)
{
this->bus = bus;
this->dev = dev;
}
RGBFusionGPUController::~RGBFusionGPUController()
{
}
std::string RGBFusionGPUController::GetDeviceLocation()
{
std::string return_string(bus->device_name);
char addr[5];
snprintf(addr, 5, "0x%02X", dev);
return_string.append(", address ");
return_string.append(addr);
return(return_string);
}
void RGBFusionGPUController::SetColor(unsigned char red, unsigned char green, unsigned char blue)
{
bus->i2c_smbus_write_byte(dev, RGB_FUSION_GPU_REG_COLOR);
bus->i2c_smbus_write_byte(dev, red);
bus->i2c_smbus_write_byte(dev, green);
bus->i2c_smbus_write_byte(dev, blue);
}
void RGBFusionGPUController::SetMode(unsigned char mode, unsigned char speed)
{
bus->i2c_smbus_write_byte(dev, RGB_FUSION_GPU_REG_MODE);
bus->i2c_smbus_write_byte(dev, mode);
bus->i2c_smbus_write_byte(dev, speed);
bus->i2c_smbus_write_byte(dev, 0x63);
}
@@ -1,54 +0,0 @@
/*-----------------------------------------*\
| RGBFusionGPUController.h |
| |
| Definitions and types for Gigabyte Aorus |
| RGB Fusion GPU lighting controller |
| |
| Adam Honse (CalcProgrammer1) 2/20/2020 |
\*-----------------------------------------*/
#include <string>
#include "i2c_smbus.h"
#pragma once
typedef unsigned char rgb_fusion_dev_id;
enum
{
RGB_FUSION_GPU_REG_COLOR = 0x40,
RGB_FUSION_GPU_REG_MODE = 0x88
};
enum
{
RGB_FUSION_GPU_MODE_STATIC = 0x01,
RGB_FUSION_GPU_MODE_BREATHING = 0x02,
RGB_FUSION_GPU_MODE_FLASHING = 0x04,
RGB_FUSION_GPU_MODE_DUAL_FLASHING = 0x08,
RGB_FUSION_GPU_MODE_SPECTRUM_CYCLE = 0x11
};
enum
{
RGB_FUSION_GPU_SPEED_SLOWEST = 0x00,
RGB_FUSION_GPU_SPEED_NORMAL = 0x05,
RGB_FUSION_GPU_SPEED_FASTEST = 0x09
};
class RGBFusionGPUController
{
public:
RGBFusionGPUController(i2c_smbus_interface* bus, rgb_fusion_dev_id dev);
~RGBFusionGPUController();
std::string GetDeviceLocation();
void SetColor(unsigned char red, unsigned char green, unsigned char blue);
void SetMode(unsigned char mode, unsigned char speed);
private:
i2c_smbus_interface* bus;
rgb_fusion_dev_id dev;
};
@@ -1,83 +0,0 @@
#include "RGBFusionGPUController.h"
#include "RGBController.h"
#include "RGBController_RGBFusionGPU.h"
#include "i2c_smbus.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/******************************************************************************************\
* *
* TestForRGBFusionGPUController *
* *
* Tests the given address to see if an RGB Fusion controller exists there. First *
* does a quick write to test for a response *
* *
\******************************************************************************************/
bool TestForRGBFusionGPUController(i2c_smbus_interface* bus, unsigned char address)
{
bool pass = false;
int res;
//Write out 0xAB 0x00 0x00 0x00 sequence
res = bus->i2c_smbus_write_byte(address, 0xAB);
if (res >= 0)
{
bus->i2c_smbus_write_byte(address, 0x00);
bus->i2c_smbus_write_byte(address, 0x00);
bus->i2c_smbus_write_byte(address, 0x00);
pass = true;
res = bus->i2c_smbus_read_byte(address);
if (res != 0xAB)
{
pass = false;
}
res = bus->i2c_smbus_read_byte(address);
if(res != 0x14)
{
pass = false;
}
bus->i2c_smbus_read_byte(address);
bus->i2c_smbus_read_byte(address);
}
return(pass);
} /* TestForRGBFusionGPUController() */
/******************************************************************************************\
* *
* DetectRGBFusionGPUControllers *
* *
* Detect RGB Fusion controllers on the enumerated I2C busses at address 0x47. *
* *
* bus - pointer to i2c_smbus_interface where RGB Fusion device is connected *
* dev - I2C address of RGB Fusion device *
* *
\******************************************************************************************/
void DetectRGBFusionGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers)
{
RGBFusionGPUController* new_rgb_fusion;
RGBController_RGBFusionGPU* new_controller;
for (unsigned int bus = 0; bus < busses.size(); bus++)
{
// Check for RGB Fusion controller at 0x47
if (TestForRGBFusionGPUController(busses[bus], 0x47))
{
new_rgb_fusion = new RGBFusionGPUController(busses[bus], 0x47);
new_controller = new RGBController_RGBFusionGPU(new_rgb_fusion);
rgb_controllers.push_back(new_controller);
}
}
} /* DetectRGBFusionGPUControllers() */
+13 -42
View File
@@ -17,7 +17,6 @@
#include "i2c_smbus_piix4.h"
#include "i2c_smbus_i801.h"
#include "i2c_smbus_nct6775.h"
#include "i2c_smbus_nvapi.h"
#include "super_io.h"
#include "wmi.h"
#else /* WIN32 */
@@ -88,33 +87,6 @@ void DetectNuvotonI2CBusses()
} /* DetectNuvotonI2CBusses() */
/******************************************************************************************\
* *
* DetectNvAPII2CBusses (Windows) *
* *
* Detects available NVidia NvAPI I2C adapters and enumerates *
* i2c_smbus_interface objects for them. Only enumerates the first bus for each GPU *
* *
\******************************************************************************************/
void DetectNvAPII2CBusses()
{
static NV_PHYSICAL_GPU_HANDLE gpu_handles[64];
static NV_S32 gpu_count = 0;
NV_STATUS initialize = NvAPI_Initialize();
NvAPI_EnumPhysicalGPUs(gpu_handles, &gpu_count);
for(NV_S32 gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++)
{
i2c_smbus_nvapi * nvapi_bus = new i2c_smbus_nvapi(gpu_handles[gpu_idx]);
sprintf(nvapi_bus->device_name, "NVidia NvAPI I2C on GPU %d", gpu_idx);
busses.push_back(nvapi_bus);
}
} /* DetectNvAPII2CBusses() */
/******************************************************************************************\
* *
@@ -198,9 +170,6 @@ void DetectI2CBusses()
// Detect Nuvoton Super IO SMBus adapters
DetectNuvotonI2CBusses();
// Detect NVidia NvAPI I2C adapters
DetectNvAPII2CBusses();
} /* DetectI2CBusses() */
#else /* WIN32 */
@@ -249,7 +218,14 @@ void DetectI2CBusses()
{
read(test_fd, device_string, sizeof(device_string));
close(test_fd);
//ignore nvidia adapters for now
if(strncmp(device_string, "NVIDIA", 6) == 0)
{
ent = readdir(dir);
continue;
}
bus = new i2c_smbus_linux();
strcpy(bus->device_name, device_string);
@@ -277,7 +253,6 @@ void DetectI2CBusses()
#endif /* WIN32 */
void DetectAuraControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectAuraGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCorsairControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCorsairProControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectCrucialControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
@@ -285,14 +260,14 @@ void DetectHyperXControllers(std::vector<i2c_smbus_interface*> &busses, std::vec
void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, std::vector<RGBController*> &rgb_controllers);
void DetectPolychromeControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectRGBFusionControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectRGBFusionGPUControllers(std::vector<i2c_smbus_interface*>& busses, std::vector<RGBController*>& rgb_controllers);
void DetectMSIRGBControllers(std::vector<RGBController*> &rgb_controllers);
void DetectAuraAddressableControllers(std::vector<RGBController*> &rgb_controllers);
void DetectLEDStripControllers(std::vector<RGBController*> &rgb_controllers);
void DetectHue2Controllers(std::vector<RGBController*> &rgb_controllers);
void DetectHuePlusControllers(std::vector<RGBController*> &rgb_controllers);
void DetectOpenRazerControllers(std::vector<RGBController*> &rgb_controllers);
void DetectE131Controllers(std::vector<RGBController*> &rgb_controllers);
void DetectAMDWraithPrismControllers(std::vector<RGBController*>& rgb_controllers);
void DetectAorusGPUControllers(std::vector<RGBController*> &rgb_controllers);
void DetectMSI3ZoneControllers(std::vector<RGBController*>& rgb_controllers);
void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers);
void DetectCorsairCmdrProControllers(std::vector<RGBController*> &rgb_controllers);
@@ -301,7 +276,6 @@ void DetectCorsairNodeProControllers(std::vector<RGBController*> &rgb_controller
void DetectFaustusControllers(std::vector<RGBController*> &rgb_controllers);
void DetectHyperXKeyboardControllers(std::vector<RGBController*>& rgb_controllers);
void DetectThermaltakeRiingControllers(std::vector<RGBController*>& rgb_controllers);
void DetectRGBFusion2Controllers(std::vector<RGBController*> &rgb_controllers);
/******************************************************************************************\
* *
@@ -310,24 +284,21 @@ void DetectRGBFusion2Controllers(std::vector<RGBController*> &rgb_controllers);
* Detect and populate RGB Controllers vector *
* *
\******************************************************************************************/
#include "RGBController_Dummy.h"
void DetectRGBControllers(void)
{
DetectI2CBusses();
DetectAuraControllers(busses, rgb_controllers);
DetectAuraGPUControllers(busses, rgb_controllers);
DetectCorsairControllers(busses, rgb_controllers);
DetectCorsairProControllers(busses, rgb_controllers);
DetectCrucialControllers(busses, rgb_controllers);
DetectHyperXControllers(busses, rgb_controllers);
DetectPatriotViperControllers(busses, rgb_controllers);
DetectPolychromeControllers(busses, rgb_controllers);
DetectRGBFusionGPUControllers(busses, rgb_controllers);
DetectRGBFusionControllers(busses, rgb_controllers);
DetectMSIRGBControllers(rgb_controllers);
DetectAuraAddressableControllers(rgb_controllers);
DetectLEDStripControllers(rgb_controllers);
DetectHue2Controllers(rgb_controllers);
DetectHuePlusControllers(rgb_controllers);
@@ -340,7 +311,6 @@ void DetectRGBControllers(void)
DetectCorsairKeyboardControllers(rgb_controllers);
DetectCorsairNodeProControllers(rgb_controllers);
DetectThermaltakeRiingControllers(rgb_controllers);
DetectRGBFusion2Controllers(rgb_controllers);
DetectE131Controllers(rgb_controllers);
@@ -348,6 +318,7 @@ void DetectRGBControllers(void)
| Windows-only devices |
\*-------------------------------------*/
#ifdef WIN32
//DetectAorusGPUControllers(rgb_controllers);
DetectOpenRazerControllers(rgb_controllers);
/*-------------------------------------*\
| Linux-only devices |
+27 -74
View File
@@ -5,22 +5,6 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = OpenRGB
TEMPLATE = app
VERSION = 0.0
win32:BUILDDATE = $$system(date /t)
unix:BUILDDATE = $$system(date -R)
GIT_COMMIT_ID = $$system(git --git-dir $$_PRO_FILE_PWD_/.git --work-tree $$_PRO_FILE_PWD_ rev-parse HEAD)
GIT_COMMIT_DATE = $$system(git --git-dir $$_PRO_FILE_PWD_/.git --work-tree $$_PRO_FILE_PWD_ show -s --format=%ci HEAD)
GIT_BRANCH = $$system(git --git-dir $$_PRO_FILE_PWD_/.git --work-tree $$_PRO_FILE_PWD_ rev-parse --abbrev-ref HEAD)
DEFINES += \
VERSION_STRING=\\"\"\"$$VERSION\\"\"\" \
BUILDDATE_STRING=\\"\"\"$$BUILDDATE\\"\"\" \
GIT_COMMIT_ID=\\"\"\"$$GIT_COMMIT_ID\\"\"\" \
GIT_COMMIT_DATE=\\"\"\"$$GIT_COMMIT_DATE\\"\"\" \
GIT_BRANCH=\\"\"\"$$GIT_BRANCH\\"\"\"
RC_ICONS = qt/OpenRGB.ico
INCLUDEPATH += \
dependencies/libe131/src/ \
i2c_smbus/ \
@@ -29,8 +13,8 @@ INCLUDEPATH += \
serial_port/ \
super_io/ \
Controllers/AMDWraithPrismController/ \
Controllers/AuraAddressableController/ \
Controllers/AuraController/ \
Controllers/AuraGPUController/ \
Controllers/CorsairController/ \
Controllers/CorsairCmdrProController/ \
Controllers/CorsairKeyboardController/ \
@@ -43,13 +27,11 @@ INCLUDEPATH += \
Controllers/HyperXKeyboardController/ \
Controllers/LEDStripController/ \
Controllers/MSI3ZoneController/ \
Controllers/MSIRGBController/ \
Controllers/PatriotViperController/ \
Controllers/PolychromeController/ \
Controllers/PoseidonZRGBController/ \
Controllers/RGBFusionController/ \
Controllers/RGBFusion2Controller/ \
Controllers/RGBFusionGPUController/ \
Controllers/ThermaltakeRiingController/ \
RGBController/ \
qt/
@@ -57,7 +39,6 @@ INCLUDEPATH += \
SOURCES += \
dependencies/libe131/src/e131.c \
main.cpp \
cli.cpp \
OpenRGB.cpp \
qt/OpenRGBDeviceInfoPage.cpp \
qt/OpenRGBDevicePage.cpp \
@@ -66,18 +47,16 @@ SOURCES += \
i2c_tools/i2c_tools.cpp \
net_port/net_port.cpp \
qt/OpenRGBDialog2.cpp \
qt/OpenRGBProfileSaveDialog.cpp \
qt/OpenRGBSoftwareInfoPage.cpp \
qt/OpenRGBSystemInfoPage.cpp \
qt/hsv.cpp \
serial_port/serial_port.cpp \
super_io/super_io.cpp \
Controllers/AMDWraithPrismController/AMDWraithPrismController.cpp \
Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \
Controllers/AuraAddressableController/AuraAddressableController.cpp \
Controllers/AuraAddressableController/AuraAddressableControllerDetect.cpp \
Controllers/AuraController/AuraController.cpp \
Controllers/AuraController/AuraControllerDetect.cpp \
Controllers/AuraGPUController/AuraGPUController.cpp \
Controllers/AuraGPUController/AuraGPUControllerDetect.cpp \
Controllers/CorsairController/CorsairController.cpp \
Controllers/CorsairController/CorsairControllerDetect.cpp \
Controllers/CorsairCmdrProController/CorsairCmdrProController.cpp \
@@ -102,8 +81,6 @@ SOURCES += \
Controllers/LEDStripController/LEDStripControllerDetect.cpp \
Controllers/MSI3ZoneController/MSI3ZoneController.cpp \
Controllers/MSI3ZoneController/MSI3ZoneControllerDetect.cpp \
Controllers/MSIRGBController/MSIRGBController.cpp \
Controllers/MSIRGBController/MSIRGBControllerDetect.cpp \
Controllers/PatriotViperController/PatriotViperController.cpp \
Controllers/PatriotViperController/PatriotViperControllerDetect.cpp \
Controllers/PolychromeController/PolychromeController.cpp \
@@ -114,22 +91,19 @@ SOURCES += \
Controllers/RGBFusionController/RGBFusionControllerDetect.cpp \
Controllers/RGBFusion2Controller/RGBFusion2Controller.cpp \
Controllers/RGBFusion2Controller/RGBFusion2ControllerDetect.cpp \
Controllers/RGBFusionGPUController/RGBFusionGPUController.cpp \
Controllers/RGBFusionGPUController/RGBFusionGPUControllerDetect.cpp \
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.cpp \
Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp \
RGBController/RGBController.cpp \
RGBController/E131ControllerDetect.cpp \
RGBController/RGBController_AMDWraithPrism.cpp \
RGBController/RGBController_Aura.cpp \
RGBController/RGBController_AuraGPU.cpp \
RGBController/RGBController_AuraAddressable.cpp \
RGBController/RGBController_Corsair.cpp \
RGBController/RGBController_CorsairCmdrPro.cpp \
RGBController/RGBController_CorsairKeyboard.cpp \
RGBController/RGBController_CorsairNodePro.cpp \
RGBController/RGBController_CorsairPro.cpp \
RGBController/RGBController_Crucial.cpp \
RGBController/RGBController_Dummy.cpp \
RGBController/RGBController_Hue2.cpp \
RGBController/RGBController_HuePlus.cpp \
RGBController/RGBController_HyperX.cpp \
@@ -137,13 +111,11 @@ SOURCES += \
RGBController/RGBController_E131.cpp \
RGBController/RGBController_LEDStrip.cpp \
RGBController/RGBController_MSI3Zone.cpp \
RGBController/RGBController_MSIRGB.cpp \
RGBController/RGBController_PatriotViper.cpp \
RGBController/RGBController_Polychrome.cpp \
RGBController/RGBController_PoseidonZRGB.cpp \
RGBController/RGBController_RGBFusion.cpp \
RGBController/RGBController_RGBFusion2.cpp \
RGBController/RGBController_RGBFusionGPU.cpp \
RGBController/RGBController_ThermaltakeRiing.cpp \
HEADERS += \
@@ -154,15 +126,13 @@ HEADERS += \
i2c_tools/i2c_tools.h \
net_port/net_port.h \
qt/OpenRGBDialog2.h \
qt/OpenRGBProfileSaveDialog.h \
qt/OpenRGBSoftwareInfoPage.h \
qt/OpenRGBSystemInfoPage.h \
serial_port/find_usb_serial_port.h \
serial_port/serial_port.h \
super_io/super_io.h \
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
Controllers/AuraController/AuraController.h \
Controllers/AuraGPUController/AuraGPUController.h \
Controllers/AuraAddressableController/AuraAddressableController.h \
Controllers/CorsairController/CorsairController.h \
Controllers/CorsairCmdrProController/CorsairCmdrProController.h \
Controllers/CorsairKeyboardController/CorsairKeyboardController.h \
@@ -175,24 +145,21 @@ HEADERS += \
Controllers/HyperXKeyboardController/HyperXKeyboardController.h \
Controllers/LEDStripController/LEDStripController.h \
Controllers/MSI3ZoneController/MSI3ZoneController.h \
Controllers/MSIRGBController/MSIRGBController.h \
Controllers/PatriotViperController/PatriotViperController.h \
Controllers/PolychromeController/PolychromeController.h \
Controllers/PoseidonZRGBController/PoseidonZRGBController.h \
Controllers/RGBFusionController/RGBFusionController.h \
Controllers/RGBFusion2Controller/RGBFusion2Controller.h \
Controllers/RGBFusionGPUController/RGBFusionGPUController.h \
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h \
RGBController/RGBController.h \
RGBController/RGBController_AMDWraithPrism.h \
RGBController/RGBController_Aura.h \
RGBController/RGBController_AuraGPU.h \
RGBController/RGBController_AuraAddressable.h \
RGBController/RGBController_Corsair.h \
RGBController/RGBController_CorsairCmdrPro.h \
RGBController/RGBController_CorsairNodePro.h \
RGBController/RGBController_CorsairPro.h \
RGBController/RGBController_Crucial.h \
RGBController/RGBController_Dummy.h \
RGBController/RGBController_E131.h \
RGBController/RGBController_Hue2.h \
RGBController/RGBController_HuePlus.h \
@@ -200,13 +167,11 @@ HEADERS += \
RGBController/RGBController_HyperXKeyboard.h \
RGBController/RGBController_LEDStrip.h \
RGBController/RGBController_MSI3Zone.h \
RGBController/RGBController_MSIRGB.h \
RGBController/RGBController_PatriotViper.h \
RGBController/RGBController_Polychrome.h \
RGBController/RGBController_PoseidonZRGB.h \
RGBController/RGBController_RGBFusion.h \
RGBController/RGBController_RGBFusion2.h \
RGBController/RGBController_RGBFusionGPU.h \
RGBController/RGBController_ThermaltakeRiing.h \
RESOURCES += \
@@ -217,8 +182,6 @@ FORMS += \
qt/OpenRGBDevicePage.ui \
qt/OpenRGBDialog.ui \
qt/OpenRGBDialog2.ui \
qt/OpenRGBProfileSaveDialog.ui \
qt/OpenRGBSoftwareInfoPage.ui \
qt/OpenRGBSystemInfoPage.ui
#-----------------------------------------------
@@ -228,45 +191,34 @@ win32:INCLUDEPATH += \
dependencies/inpout32_1501/Win32/ \
dependencies/libusb-1.0.22/include \
dependencies/hidapi \
dependencies/NVFC \
dependencies/openrazer-win32 \
wmi/ \
win32:SOURCES += \
dependencies/NVFC/nvapi.cpp \
dependencies/hidapi/hid_win.c \
i2c_smbus/i2c_smbus_i801.cpp \
i2c_smbus/i2c_smbus_nct6775.cpp \
i2c_smbus/i2c_smbus_nvapi.cpp \
i2c_smbus/i2c_smbus_piix4.cpp \
serial_port/find_usb_serial_port_win.cpp \
wmi/wmi.cpp \
RGBController/AorusGPUDetect.cpp \
RGBController/OpenRazerWindowsDetect.cpp \
RGBController/RGBController_AorusGPU.cpp \
RGBController/RGBController_OpenRazerWindows.cpp \
win32:HEADERS += \
dependencies/inpout32_1501/Win32/inpout32.h \
dependencies/NVFC/nvapi.h \
i2c_smbus/i2c_smbus_i801.h \
i2c_smbus/i2c_smbus_nct6775.h \
i2c_smbus/i2c_smbus_nvapi.h \
i2c_smbus/i2c_smbus_piix4.h \
wmi/wmi.h \
RGBController/RGBController_AorusGPU.h \
RGBController/RGBController_OpenRazerWindows.h \
win32:contains(QMAKE_TARGET.arch, x86_64) {
LIBS += \
-lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/x64/" -linpoutx64 \
-L"$$PWD/dependencies/libusb-1.0.22/MS64/dll" -llibusb-1.0 \
}
win32:contains(QMAKE_TARGET.arch, x86) {
LIBS += \
-lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \
-L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0 \
}
win32:LIBS += \
-lws2_32 \
-L"$$PWD/dependencies/inpout32_1501/Win32/" -linpout32 \
-L"$$PWD/dependencies/libusb-1.0.22/MS32/dll" -llibusb-1.0 \
-L"$$PWD/dependencies/hidapi-win/x86/" -lhidapi
win32:DEFINES -= \
UNICODE
@@ -279,15 +231,8 @@ win32:DEFINES += \
WIN32_LEAN_AND_MEAN
# Copy OpenRazer.dll to output directory
win32:contains(QMAKE_TARGET.arch, x86_64) {
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD\\dependencies\\openrazer-win32\\OpenRazer64.dll)\" \"$$shell_path($$OUT_PWD)\"
first.depends = $(first) copydata
export(first.depends)
export(copydata.commands)
QMAKE_EXTRA_TARGETS += first copydata
}
win32:contains(QMAKE_TARGET.arch, x86) {
win32
{
copydata.commands = $(COPY_FILE) \"$$shell_path($$PWD\\dependencies\\openrazer-win32\\OpenRazer.dll)\" \"$$shell_path($$OUT_PWD)\"
first.depends = $(first) copydata
export(first.depends)
@@ -299,7 +244,6 @@ win32:contains(QMAKE_TARGET.arch, x86) {
# Linux specific project configuration
#-----------------------------------------------
unix:INCLUDEPATH += \
dependencies/hidapi \
unix:HEADERS += \
i2c_smbus/i2c_smbus_linux.h \
@@ -307,10 +251,19 @@ unix:HEADERS += \
unix:LIBS += \
-lusb-1.0 \
-lstdc++fs \
packagesExist(hidapi-libusb){
unix:LIBS += -lhidapi-libusb
} else {
packagesExist(hidapi) {
unix:LIBS += -lhidapi
} else {
unix:LIBS += -lhidapi-libusb
}
}
unix:SOURCES += \
dependencies/hidapi/hid_win.c \
i2c_smbus/i2c_smbus_linux.cpp \
serial_port/find_usb_serial_port_linux.cpp \
RGBController/OpenRazerDetect.cpp \
+21
View File
@@ -0,0 +1,21 @@
#include "RGBController.h"
#include "RGBController_AorusGPU.h"
#include <vector>
#include <stdio.h>
#include <stdlib.h>
/******************************************************************************************\
* *
* DetectAorusGPUControllers *
* *
* Detect devices supported by the Aorus GPU driver *
* * *
\******************************************************************************************/
void DetectAorusGPUControllers(std::vector<RGBController*> &rgb_controllers)
{
RGBController_AorusGPU * aorus_rgb = new RGBController_AorusGPU();
rgb_controllers.push_back(aorus_rgb);
} /* DetectLEDStripControllers() */
+1 -684
View File
@@ -1,660 +1,4 @@
#include "RGBController.h"
#include <cstring>
unsigned char * RGBController::GetDeviceDescription()
{
unsigned int data_ptr = 0;
unsigned int data_size = 0;
/*---------------------------------------------------------*\
| Calculate data size |
\*---------------------------------------------------------*/
unsigned short name_len = strlen(name.c_str()) + 1;
unsigned short description_len = strlen(description.c_str()) + 1;
unsigned short version_len = strlen(version.c_str()) + 1;
unsigned short serial_len = strlen(serial.c_str()) + 1;
unsigned short location_len = strlen(location.c_str()) + 1;
unsigned short num_modes = modes.size();
unsigned short num_zones = zones.size();
unsigned short num_leds = leds.size();
unsigned short num_colors = colors.size();
unsigned short *mode_name_len = new unsigned short[num_modes];
unsigned short *zone_name_len = new unsigned short[num_zones];
unsigned short *led_name_len = new unsigned short[num_leds];
unsigned short *mode_num_colors = new unsigned short[num_modes];
unsigned short *zone_map_rows = new unsigned short[num_zones];
data_size += sizeof(data_size);
data_size += sizeof(device_type);
data_size += name_len + sizeof(name_len);
data_size += description_len + sizeof(description_len);
data_size += version_len + sizeof(version_len);
data_size += serial_len + sizeof(serial_len);
data_size += location_len + sizeof(location_len);
data_size += sizeof(num_modes);
data_size += sizeof(active_mode);
for(int mode_index = 0; mode_index < num_modes; mode_index++)
{
mode_name_len[mode_index] = strlen(modes[mode_index].name.c_str()) + 1;
mode_num_colors[mode_index] = modes[mode_index].colors.size();
data_size += mode_name_len[mode_index] + sizeof(mode_name_len[mode_index]);
data_size += sizeof(modes[mode_index].value);
data_size += sizeof(modes[mode_index].flags);
data_size += sizeof(modes[mode_index].speed_min);
data_size += sizeof(modes[mode_index].speed_max);
data_size += sizeof(modes[mode_index].colors_min);
data_size += sizeof(modes[mode_index].colors_max);
data_size += sizeof(modes[mode_index].speed);
data_size += sizeof(modes[mode_index].direction);
data_size += sizeof(modes[mode_index].color_mode);
data_size += sizeof(mode_num_colors[mode_index]);
data_size += (mode_num_colors[mode_index] * sizeof(RGBColor));
}
data_size += sizeof(num_zones);
for(int zone_index = 0; zone_index < num_zones; zone_index++)
{
zone_name_len[zone_index] = strlen(zones[zone_index].name.c_str()) + 1;
zone_map_rows[zone_index] = zones[zone_index].map.size();
data_size += zone_name_len[zone_index] + sizeof(zone_name_len[zone_index]);
data_size += sizeof(zones[zone_index].type);
data_size += sizeof(zone_map_rows[zone_index]);
for(int row_index = 0; row_index < zone_map_rows[zone_index]; row_index++)
{
data_size += sizeof(unsigned short);
for(int row_led_index = 0; row_led_index < zones[zone_index].map[row_index].size(); row_led_index++)
{
data_size += sizeof(int);
}
}
}
data_size += sizeof(num_leds);
for(int led_index = 0; led_index < num_leds; led_index++)
{
led_name_len[led_index] = strlen(leds[led_index].name.c_str()) + 1;
data_size += led_name_len[led_index] + sizeof(led_name_len[led_index]);
}
data_size += sizeof(num_colors);
data_size += num_colors * sizeof(RGBColor);
/*---------------------------------------------------------*\
| Create data buffer |
\*---------------------------------------------------------*/
unsigned char *data_buf = new unsigned char[data_size];
/*---------------------------------------------------------*\
| Copy in data size |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &data_size, sizeof(data_size));
data_ptr += sizeof(data_size);
/*---------------------------------------------------------*\
| Copy in type |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &type, sizeof(device_type));
data_ptr += sizeof(device_type);
/*---------------------------------------------------------*\
| Copy in name (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &name_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], name.c_str());
data_ptr += name_len;
/*---------------------------------------------------------*\
| Copy in description (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &description_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], description.c_str());
data_ptr += description_len;
/*---------------------------------------------------------*\
| Copy in version (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &version_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], version.c_str());
data_ptr += version_len;
/*---------------------------------------------------------*\
| Copy in serial (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &serial_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], serial.c_str());
data_ptr += serial_len;
/*---------------------------------------------------------*\
| Copy in location (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &location_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], location.c_str());
data_ptr += location_len;
/*---------------------------------------------------------*\
| Copy in number of modes (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &num_modes, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in active mode (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &active_mode, sizeof(active_mode));
data_ptr += sizeof(active_mode);
/*---------------------------------------------------------*\
| Copy in modes |
\*---------------------------------------------------------*/
for(int mode_index = 0; mode_index < num_modes; mode_index++)
{
/*---------------------------------------------------------*\
| Copy in mode name (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &mode_name_len[mode_index], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], modes[mode_index].name.c_str());
data_ptr += mode_name_len[mode_index];
/*---------------------------------------------------------*\
| Copy in mode value (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].value, sizeof(modes[mode_index].value));
data_ptr += sizeof(modes[mode_index].value);
/*---------------------------------------------------------*\
| Copy in mode flags (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].flags, sizeof(modes[mode_index].flags));
data_ptr += sizeof(modes[mode_index].flags);
/*---------------------------------------------------------*\
| Copy in mode speed_min (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].speed_min, sizeof(modes[mode_index].speed_min));
data_ptr += sizeof(modes[mode_index].speed_min);
/*---------------------------------------------------------*\
| Copy in mode speed_max (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].speed_max, sizeof(modes[mode_index].speed_max));
data_ptr += sizeof(modes[mode_index].speed_max);
/*---------------------------------------------------------*\
| Copy in mode colors_min (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].colors_min, sizeof(modes[mode_index].colors_min));
data_ptr += sizeof(modes[mode_index].colors_min);
/*---------------------------------------------------------*\
| Copy in mode colors_max (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].colors_max, sizeof(modes[mode_index].colors_max));
data_ptr += sizeof(modes[mode_index].colors_max);
/*---------------------------------------------------------*\
| Copy in mode speed (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].speed, sizeof(modes[mode_index].speed));
data_ptr += sizeof(modes[mode_index].speed);
/*---------------------------------------------------------*\
| Copy in mode direction (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].direction, sizeof(modes[mode_index].direction));
data_ptr += sizeof(modes[mode_index].direction);
/*---------------------------------------------------------*\
| Copy in mode color_mode (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].color_mode, sizeof(modes[mode_index].color_mode));
data_ptr += sizeof(modes[mode_index].color_mode);
/*---------------------------------------------------------*\
| Copy in mode number of colors |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &mode_num_colors[mode_index], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in mode mode colors |
\*---------------------------------------------------------*/
for(int color_index = 0; color_index < mode_num_colors[mode_index]; color_index++)
{
/*---------------------------------------------------------*\
| Copy in color (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &modes[mode_index].colors[color_index], sizeof(modes[mode_index].colors[color_index]));
data_ptr += sizeof(modes[mode_index].colors[color_index]);
}
}
/*---------------------------------------------------------*\
| Copy in number of zones (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &num_zones, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in zones |
\*---------------------------------------------------------*/
for(int zone_index = 0; zone_index < num_zones; zone_index++)
{
/*---------------------------------------------------------*\
| Copy in zone name (size+data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &zone_name_len[zone_index], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], zones[zone_index].name.c_str());
data_ptr += zone_name_len[zone_index];
/*---------------------------------------------------------*\
| Copy in zone type (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &zones[zone_index].type, sizeof(zones[zone_index].type));
data_ptr += sizeof(zones[zone_index].type);
/*---------------------------------------------------------*\
| Copy in zone map number of rows |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &zone_map_rows[zone_index], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in rows |
\*---------------------------------------------------------*/
for(int row_index = 0; row_index < zone_map_rows[zone_index]; row_index++)
{
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
unsigned short zone_map_row_size = zones[zone_index].map[row_index].size();
memcpy(&data_buf[data_ptr], &zone_map_row_size, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in row LEDs |
\*---------------------------------------------------------*/
for(int row_led_index = 0; row_led_index < zone_map_row_size; row_led_index++)
{
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &zones[zone_index].map[row_index][row_led_index], sizeof(zones[zone_index].map[row_index][row_led_index]));
data_ptr += sizeof(zones[zone_index].map[row_index][row_led_index]);
}
}
}
/*---------------------------------------------------------*\
| Copy in number of LEDs (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &num_leds, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in LEDs |
\*---------------------------------------------------------*/
for(int led_index = 0; led_index < num_leds; led_index++)
{
/*---------------------------------------------------------*\
| Copy in LED name (size+data) |
\*---------------------------------------------------------*/
unsigned short ledname_len = strlen(leds[led_index].name.c_str()) + 1;
memcpy(&data_buf[data_ptr], &ledname_len, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
strcpy((char *)&data_buf[data_ptr], leds[led_index].name.c_str());
data_ptr += ledname_len;
}
/*---------------------------------------------------------*\
| Copy in number of colors (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &num_colors, sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in colors |
\*---------------------------------------------------------*/
for(int color_index = 0; color_index < num_colors; color_index++)
{
/*---------------------------------------------------------*\
| Copy in color (data) |
\*---------------------------------------------------------*/
memcpy(&data_buf[data_ptr], &colors[color_index], sizeof(colors[color_index]));
data_ptr += sizeof(colors[color_index]);
}
delete[] mode_name_len;
delete[] zone_name_len;
delete[] led_name_len;
delete[] mode_num_colors;
delete[] zone_map_rows;
return(data_buf);
}
void RGBController::ReadDeviceDescription(unsigned char* data_buf)
{
unsigned int data_ptr = 0;
data_ptr += sizeof(unsigned int);
/*---------------------------------------------------------*\
| Copy in type |
\*---------------------------------------------------------*/
memcpy(&type, &data_buf[data_ptr], sizeof(device_type));
data_ptr += sizeof(device_type);
/*---------------------------------------------------------*\
| Copy in name |
\*---------------------------------------------------------*/
unsigned short name_len;
memcpy(&name_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
name = (char *)&data_buf[data_ptr];
data_ptr += name_len;
/*---------------------------------------------------------*\
| Copy in description |
\*---------------------------------------------------------*/
unsigned short description_len;
memcpy(&description_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
description = (char *)&data_buf[data_ptr];
data_ptr += description_len;
/*---------------------------------------------------------*\
| Copy in version |
\*---------------------------------------------------------*/
unsigned short version_len;
memcpy(&version_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
version = (char *)&data_buf[data_ptr];
data_ptr += version_len;
/*---------------------------------------------------------*\
| Copy in serial |
\*---------------------------------------------------------*/
unsigned short serial_len;
memcpy(&serial_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
serial = (char *)&data_buf[data_ptr];
data_ptr += serial_len;
/*---------------------------------------------------------*\
| Copy in location |
\*---------------------------------------------------------*/
unsigned short location_len;
memcpy(&location_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
location = (char *)&data_buf[data_ptr];
data_ptr += location_len;
/*---------------------------------------------------------*\
| Copy in number of modes (data) |
\*---------------------------------------------------------*/
unsigned short num_modes;
memcpy(&num_modes, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in active mode (data) |
\*---------------------------------------------------------*/
memcpy(&active_mode, &data_buf[data_ptr], sizeof(active_mode));
data_ptr += sizeof(active_mode);
/*---------------------------------------------------------*\
| Copy in modes |
\*---------------------------------------------------------*/
for(int mode_index = 0; mode_index < num_modes; mode_index++)
{
mode new_mode;
/*---------------------------------------------------------*\
| Copy in mode name (size+data) |
\*---------------------------------------------------------*/
unsigned short modename_len;
memcpy(&modename_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
new_mode.name = (char *)&data_buf[data_ptr];
data_ptr += modename_len;
/*---------------------------------------------------------*\
| Copy in mode value (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.value, &data_buf[data_ptr], sizeof(new_mode.value));
data_ptr += sizeof(new_mode.value);
/*---------------------------------------------------------*\
| Copy in mode flags (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.flags, &data_buf[data_ptr], sizeof(new_mode.flags));
data_ptr += sizeof(new_mode.flags);
/*---------------------------------------------------------*\
| Copy in mode speed_min (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.speed_min, &data_buf[data_ptr], sizeof(new_mode.speed_min));
data_ptr += sizeof(new_mode.speed_min);
/*---------------------------------------------------------*\
| Copy in mode speed_max (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.speed_max, &data_buf[data_ptr], sizeof(new_mode.speed_max));
data_ptr += sizeof(new_mode.speed_max);
/*---------------------------------------------------------*\
| Copy in mode colors_min (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.colors_min, &data_buf[data_ptr], sizeof(new_mode.colors_min));
data_ptr += sizeof(new_mode.colors_min);
/*---------------------------------------------------------*\
| Copy in mode colors_max (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.colors_max, &data_buf[data_ptr], sizeof(new_mode.colors_max));
data_ptr += sizeof(new_mode.colors_max);
/*---------------------------------------------------------*\
| Copy in mode speed (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.speed, &data_buf[data_ptr], sizeof(new_mode.speed));
data_ptr += sizeof(new_mode.speed);
/*---------------------------------------------------------*\
| Copy in mode direction (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.direction, &data_buf[data_ptr], sizeof(new_mode.direction));
data_ptr += sizeof(new_mode.direction);
/*---------------------------------------------------------*\
| Copy in mode color_mode (data) |
\*---------------------------------------------------------*/
memcpy(&new_mode.color_mode, &data_buf[data_ptr], sizeof(new_mode.color_mode));
data_ptr += sizeof(new_mode.color_mode);
/*---------------------------------------------------------*\
| Copy in mode number of colors |
\*---------------------------------------------------------*/
unsigned short mode_num_colors;
memcpy(&mode_num_colors, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in mode mode colors |
\*---------------------------------------------------------*/
for(int color_index = 0; color_index < mode_num_colors; color_index++)
{
/*---------------------------------------------------------*\
| Copy in color (data) |
\*---------------------------------------------------------*/
RGBColor new_color;
memcpy(&new_color, &data_buf[data_ptr], sizeof(RGBColor));
data_ptr += sizeof(modes[mode_index].colors[color_index]);
new_mode.colors.push_back(new_color);
}
modes.push_back(new_mode);
}
/*---------------------------------------------------------*\
| Copy in number of zones (data) |
\*---------------------------------------------------------*/
unsigned short num_zones;
memcpy(&num_zones, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in zones |
\*---------------------------------------------------------*/
for(int zone_index = 0; zone_index < num_zones; zone_index++)
{
zone new_zone;
/*---------------------------------------------------------*\
| Copy in zone name (size+data) |
\*---------------------------------------------------------*/
unsigned short zonename_len;
memcpy(&zonename_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
new_zone.name = (char *)&data_buf[data_ptr];
data_ptr += zonename_len;
/*---------------------------------------------------------*\
| Copy in zone type (data) |
\*---------------------------------------------------------*/
memcpy(&new_zone.type, &data_buf[data_ptr], sizeof(new_zone.type));
data_ptr += sizeof(new_zone.type);
/*---------------------------------------------------------*\
| Copy in zone map number of rows |
\*---------------------------------------------------------*/
unsigned short zone_map_rows;
memcpy(&zone_map_rows, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in rows |
\*---------------------------------------------------------*/
for(int row_index = 0; row_index < zone_map_rows; row_index++)
{
std::vector<int> new_zone_map_row;
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
unsigned short zone_map_row_size;
memcpy(&zone_map_row_size, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in row LEDs |
\*---------------------------------------------------------*/
for(int row_led_index = 0; row_led_index < zone_map_row_size; row_led_index++)
{
int new_index;
/*---------------------------------------------------------*\
| Copy row size |
\*---------------------------------------------------------*/
memcpy(&new_index, &data_buf[data_ptr], sizeof(int));
data_ptr += sizeof(int);
new_zone_map_row.push_back(new_index);
}
new_zone.map.push_back(new_zone_map_row);
}
zones.push_back(new_zone);
}
/*---------------------------------------------------------*\
| Copy in number of LEDs (data) |
\*---------------------------------------------------------*/
unsigned short num_leds;
memcpy(&num_leds, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in LEDs |
\*---------------------------------------------------------*/
for(int led_index = 0; led_index < num_leds; led_index++)
{
led new_led;
/*---------------------------------------------------------*\
| Copy in LED name (size+data) |
\*---------------------------------------------------------*/
unsigned short ledname_len;
memcpy(&ledname_len, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
new_led.name = (char *)&data_buf[data_ptr];
data_ptr += ledname_len;
leds.push_back(new_led);
}
/*---------------------------------------------------------*\
| Copy in number of colors (data) |
\*---------------------------------------------------------*/
unsigned short num_colors;
memcpy(&num_colors, &data_buf[data_ptr], sizeof(unsigned short));
data_ptr += sizeof(unsigned short);
/*---------------------------------------------------------*\
| Copy in colors |
\*---------------------------------------------------------*/
for(int color_index = 0; color_index < num_colors; color_index++)
{
RGBColor new_color;
/*---------------------------------------------------------*\
| Copy in color (data) |
\*---------------------------------------------------------*/
memcpy(&new_color, &data_buf[data_ptr], sizeof(RGBColor));
data_ptr += sizeof(RGBColor);
colors.push_back(new_color);
}
}
RGBColor RGBController::GetLED(int led)
{
@@ -711,31 +55,4 @@ void RGBController::SetMode(int mode)
active_mode = mode;
UpdateMode();
}
std::string device_type_to_str(device_type type)
{
switch(type)
{
case DEVICE_TYPE_MOTHERBOARD:
return "Motherboard";
case DEVICE_TYPE_DRAM:
return "DRAM";
case DEVICE_TYPE_GPU:
return "GPU";
case DEVICE_TYPE_COOLER:
return "Cooler";
case DEVICE_TYPE_LEDSTRIP:
return "LED Strip";
case DEVICE_TYPE_KEYBOARD:
return "Keyboard";
case DEVICE_TYPE_MOUSE:
return "Mouse";
case DEVICE_TYPE_MOUSEMAT:
return "Mousemat";
case DEVICE_TYPE_HEADSET:
return "Headset";
default:
return "Unknown";
}
}
}
-5
View File
@@ -112,8 +112,6 @@ enum
DEVICE_TYPE_UNKNOWN
};
std::string device_type_to_str(device_type type);
typedef struct
{
std::string name; /* Zone name */
@@ -150,9 +148,6 @@ public:
int GetMode();
void SetMode(int mode);
unsigned char * GetDeviceDescription();
void ReadDeviceDescription(unsigned char* data_buf);
/*---------------------------------------------------------*\
| Functions to be implemented in device implementation |
\*---------------------------------------------------------*/
+83
View File
@@ -0,0 +1,83 @@
/*-----------------------------------------*\
| 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 };
void RGBController_AorusGPU::UpdateLEDs()
{
RGBColor color = colors[0];
data[9] = RGBGetRValue(color);
data[10] = RGBGetGValue(color);
data[11] = RGBGetBValue(color);
GvWriteI2C(0x00000000, data, 0x00000000);
}
void RGBController_AorusGPU::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_AorusGPU::UpdateSingleLED(int led)
{
UpdateLEDs();
}
RGBController_AorusGPU::RGBController_AorusGPU()
{
name = "Aorus GPU";
type = DEVICE_TYPE_GPU;
handle = LoadLibrary("GvDisplay.dll");
GvWriteI2C = (_GvWriteI2C)GetProcAddress(handle, "GvWriteI2C");
GvFreeDispLib = (_GvFreeDispLib)GetProcAddress(handle, "GvFreeDispLib");
GvInitDispLib = (_GvInitDispLib)GetProcAddress(handle, "GvInitDispLib");
GvFreeDispLib();
GvInitDispLib();
colors.push_back(0x00000000);
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);
}
void RGBController_AorusGPU::SetCustomMode()
{
}
void RGBController_AorusGPU::UpdateMode()
{
}
+33
View File
@@ -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();
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
_GvWriteI2C GvWriteI2C;
_GvFreeDispLib GvFreeDispLib;
_GvInitDispLib GvInitDispLib;
};
-1
View File
@@ -214,7 +214,6 @@ RGBController_Aura::RGBController_Aura(AuraController * aura_ptr)
led* new_led = new led();
new_led->name = aura->GetChannelName(i);
new_led->name.append(std::to_string(i));
leds.push_back(*new_led);
@@ -0,0 +1,196 @@
/*-----------------------------------------*\
| RGBController_AuraAddressable.cpp |
| |
| Generic RGB Interface for Asus Aura |
| addressable controller driver |
| |
| Adam Honse (CalcProgrammer1) 1/18/2020 |
\*-----------------------------------------*/
#include "RGBController_AuraAddressable.h"
RGBController_AuraAddressable::RGBController_AuraAddressable(AuraAddressableController* aura_ptr)
{
aura = aura_ptr;
name = "Asus Aura Addressable";
type = DEVICE_TYPE_MOTHERBOARD;
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
mode Off;
Off.name = "Off";
Off.value = AURA_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Static;
Static.name = "Static";
Static.value = AURA_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Static.colors_min = 1;
Static.colors_max = 1;
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
Static.colors.resize(1);
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AURA_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Breathing.colors_min = 1;
Breathing.colors_max = 1;
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Breathing.colors.resize(1);
modes.push_back(Breathing);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = AURA_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Flashing.colors_min = 1;
Flashing.colors_max = 1;
Flashing.color_mode = MODE_COLORS_MODE_SPECIFIC;
Flashing.colors.resize(1);
modes.push_back(Flashing);
mode SpectrumCycle;
SpectrumCycle.name = "Spectrum Cycle";
SpectrumCycle.value = AURA_MODE_SPECTRUM_CYCLE;
SpectrumCycle.flags = 0;
SpectrumCycle.color_mode = MODE_COLORS_NONE;
modes.push_back(SpectrumCycle);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = AURA_MODE_RAINBOW;
Rainbow.flags = 0;
Rainbow.color_mode = MODE_COLORS_NONE;
modes.push_back(Rainbow);
mode ChaseFade;
ChaseFade.name = "Chase Fade";
ChaseFade.value = AURA_MODE_CHASE_FADE;
ChaseFade.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
ChaseFade.colors_min = 1;
ChaseFade.colors_max = 1;
ChaseFade.color_mode = MODE_COLORS_MODE_SPECIFIC;
ChaseFade.colors.resize(1);
modes.push_back(ChaseFade);
mode Chase;
Chase.name = "Chase";
Chase.value = AURA_MODE_CHASE;
Chase.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR;
Chase.colors_min = 1;
Chase.colors_max = 1;
Chase.color_mode = MODE_COLORS_MODE_SPECIFIC;
Chase.colors.resize(1);
modes.push_back(Chase);
/*-------------------------------------------------*\
| Set size of colors array |
\*-------------------------------------------------*/
unsigned int led_count = 0;
for (unsigned int channel_idx = 0; channel_idx < 1; channel_idx++)
{
led_count += aura->channel_leds[channel_idx];
}
colors.resize(led_count);
/*-------------------------------------------------*\
| Set zones and leds |
\*-------------------------------------------------*/
unsigned int led_idx = 0;
for (unsigned int channel_idx = 0; channel_idx < 1; channel_idx++)
{
if(aura->channel_leds[channel_idx] > 0)
{
zone* new_zone = new zone;
char ch_idx_string[2];
sprintf(ch_idx_string, "%d", channel_idx + 1);
new_zone->name = "Channel ";
new_zone->name.append(ch_idx_string);
new_zone->type = ZONE_TYPE_LINEAR;
std::vector<int> *new_zone_map = new std::vector<int>();
for (unsigned int led_ch_idx = 0; led_ch_idx < aura->channel_leds[channel_idx]; led_ch_idx++)
{
char led_idx_string[3];
sprintf(led_idx_string, "%d", led_ch_idx + 1);
led new_led;
new_led.name = "Channel ";
new_led.name.append(ch_idx_string);
new_led.name.append(", LED ");
new_led.name.append(led_idx_string);
leds.push_back(new_led);
leds_channel.push_back(channel_idx + 1);
new_zone_map->push_back(led_idx);
led_idx++;
}
new_zone->map.push_back(*new_zone_map);
zones.push_back(*new_zone);
zones_channel.push_back(channel_idx + 1);
}
}
}
RGBController_AuraAddressable::~RGBController_AuraAddressable()
{
}
void RGBController_AuraAddressable::UpdateLEDs()
{
if(modes[active_mode].value == 0xFFFF)
{
aura->SetLEDsDirect(colors);
}
}
void RGBController_AuraAddressable::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_AuraAddressable::UpdateSingleLED(int led)
{
UpdateLEDs();
}
void RGBController_AuraAddressable::SetCustomMode()
{
}
void RGBController_AuraAddressable::UpdateMode()
{
unsigned char red = 0;
unsigned char grn = 0;
unsigned char blu = 0;
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
{
red = RGBGetRValue(modes[active_mode].colors[0]);
grn = RGBGetGValue(modes[active_mode].colors[0]);
blu = RGBGetBValue(modes[active_mode].colors[0]);
}
if(modes[active_mode].value != 0xFFFF)
{
aura->SetMode(modes[active_mode].value, red, grn, blu);
}
}
@@ -0,0 +1,30 @@
/*-----------------------------------------*\
| RGBController_AuraAddressable.h |
| |
| Generic RGB Interface for Asus Aura |
| addressable controller driver |
| |
| Adam Honse (CalcProgrammer1) 1/18/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AuraAddressableController.h"
class RGBController_AuraAddressable : public RGBController
{
public:
RGBController_AuraAddressable(AuraAddressableController* aura_ptr);
~RGBController_AuraAddressable();
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
AuraAddressableController* aura;
std::vector<unsigned int> leds_channel;
std::vector<unsigned int> zones_channel;
};
-176
View File
@@ -1,176 +0,0 @@
/*-----------------------------------------*\
| RGBController_AuraGPU.h |
| |
| Generic RGB Interface for Asus Aura GPU |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#include "RGBController_AuraGPU.h"
int RGBController_AuraGPU::GetDeviceMode()
{
int dev_mode = aura_gpu->AuraGPURegisterRead(AURA_GPU_REG_MODE);
int color_mode = MODE_COLORS_PER_LED;
if(dev_mode == AURA_GPU_MODE_STATIC)
{
if (aura_gpu->direct)
{
dev_mode = AURA_GPU_MODE_DIRECT;
}
}
switch(dev_mode)
{
case AURA_GPU_MODE_OFF:
case AURA_GPU_MODE_SPECTRUM_CYCLE:
color_mode = MODE_COLORS_NONE;
break;
}
for(int mode = 0; mode < modes.size(); mode++)
{
if(modes[mode].value == dev_mode)
{
active_mode = mode;
modes[mode].color_mode = color_mode;
}
}
return(active_mode);
}
void RGBController_AuraGPU::UpdateLEDs()
{
for(std::size_t led = 0; led < colors.size(); led++)
{
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
if (GetMode() == 0)
{
aura_gpu->SetLEDColorsDirect(red, grn, blu);
}
else
{
aura_gpu->SetLEDColorsEffect(red, grn, blu);
}
}
}
void RGBController_AuraGPU::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_AuraGPU::UpdateSingleLED(int led)
{
UpdateLEDs();
}
RGBController_AuraGPU::RGBController_AuraGPU(AuraGPUController * aura_gpu_ptr)
{
aura_gpu = aura_gpu_ptr;
name = aura_gpu->GetDeviceName();
version = "0.00.1";
location = aura_gpu->GetDeviceLocation();
type = DEVICE_TYPE_GPU;
mode Direct;
Direct.name = "Direct";
Direct.value = AURA_GPU_MODE_DIRECT;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
mode Off;
Off.name = "Off";
Off.value = AURA_GPU_MODE_OFF;
Off.flags = 0;
Off.color_mode = MODE_COLORS_NONE;
modes.push_back(Off);
mode Static;
Static.name = "Static";
Static.value = AURA_GPU_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = AURA_GPU_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = AURA_GPU_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Flashing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Flashing);
mode Spectrum_Cycle;
Spectrum_Cycle.name = "Spectrum Cycle";
Spectrum_Cycle.value = AURA_GPU_MODE_SPECTRUM_CYCLE;
Spectrum_Cycle.flags = 0;
Spectrum_Cycle.color_mode = MODE_COLORS_NONE;
modes.push_back(Spectrum_Cycle);
colors.resize(1);
led aura_gpu_led;
aura_gpu_led.name = "GPU";
leds.push_back(aura_gpu_led);
zone aura_gpu_zone;
aura_gpu_zone.name = "GPU";
aura_gpu_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> aura_gpu_zone_map;
aura_gpu_zone_map.push_back(0);
aura_gpu_zone.map.push_back(aura_gpu_zone_map);
zones.push_back(aura_gpu_zone);
unsigned char red = aura_gpu->GetLEDRed();
unsigned char grn = aura_gpu->GetLEDGreen();
unsigned char blu = aura_gpu->GetLEDBlue();
colors[0] = ToRGBColor(red, grn, blu);
active_mode = GetDeviceMode();
}
void RGBController_AuraGPU::SetCustomMode()
{
active_mode = 0;
}
void RGBController_AuraGPU::UpdateMode()
{
int new_mode = modes[active_mode].value;
aura_gpu->direct = false;
switch(new_mode)
{
// Set all LEDs to 0 and Mode to static as a workaround for the non existing Off Mode
case AURA_GPU_MODE_OFF:
aura_gpu->SetLEDColorsEffect(0, 0, 0);
new_mode = AURA_GPU_MODE_STATIC;
break;
// Direct mode is done by switching to Static and not applying color changes
case AURA_GPU_MODE_DIRECT:
aura_gpu->direct = true;
new_mode = AURA_GPU_MODE_STATIC;
break;
}
aura_gpu->SetMode(new_mode);
}
-29
View File
@@ -1,29 +0,0 @@
/*-----------------------------------------*\
| RGBController_AuraGPU.h |
| |
| Generic RGB Interface for Asus Aura GPU |
| |
| Jan Rettig (Klapstuhl) 14.02.2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AuraGPUController.h"
class RGBController_AuraGPU : public RGBController
{
public:
RGBController_AuraGPU(AuraGPUController* aura_gpu_ptr);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
AuraGPUController* aura_gpu;
int GetDeviceMode();
};
-39
View File
@@ -1,39 +0,0 @@
/*-----------------------------------------*\
| RGBController_Dummy.cpp |
| |
| Generic RGB Interface Dummy Class |
| |
| Adam Honse (CalcProgrammer1) 2/25/2020 |
\*-----------------------------------------*/
#include "RGBController_Dummy.h"
RGBController_Dummy::RGBController_Dummy()
{
}
void RGBController_Dummy::UpdateLEDs()
{
}
void RGBController_Dummy::UpdateZoneLEDs(int zone)
{
}
void RGBController_Dummy::UpdateSingleLED(int led)
{
}
void RGBController_Dummy::SetCustomMode()
{
}
void RGBController_Dummy::UpdateMode()
{
}
-23
View File
@@ -1,23 +0,0 @@
/*-----------------------------------------*\
| RGBController_Dummy.h |
| |
| Generic RGB Interface Dummy Class |
| |
| Adam Honse (CalcProgrammer1) 2/25/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
class RGBController_Dummy : public RGBController
{
public:
RGBController_Dummy();
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
};
@@ -9,41 +9,6 @@
#include "RGBController_HyperXKeyboard.h"
//Include thread libraries for Windows or Linux
#ifdef WIN32
#include <process.h>
#else
#include "pthread.h"
#include "unistd.h"
#endif
//Thread functions have different types in Windows and Linux
#ifdef WIN32
#define THREAD static void
#define THREADRETURN
#else
#define THREAD static void*
#define THREADRETURN return(NULL);
#endif
#ifdef WIN32
#include <Windows.h>
#else
#include <unistd.h>
static void Sleep(unsigned int milliseconds)
{
usleep(1000 * milliseconds);
}
#endif
THREAD keepalive_thread(void *param)
{
RGBController_HyperXKeyboard* controller = static_cast<RGBController_HyperXKeyboard*>(param);
controller->KeepaliveThread();
THREADRETURN
}
static const char* zone_names[] =
{
"Keyboard",
@@ -258,19 +223,6 @@ RGBController_HyperXKeyboard::RGBController_HyperXKeyboard(HyperXKeyboardControl
zones.push_back(new_zone);
}
/*-----------------------------------------------------*\
| The Corsair Lighting Node Pro requires a packet within|
| 20 seconds of sending the lighting change in order |
| to not revert back into rainbow mode. Start a thread |
| to continuously send a keepalive packet every 5s |
\*-----------------------------------------------------*/
#ifdef WIN32
_beginthread(keepalive_thread, 0, this);
#else
pthread_t thread;
pthread_create(&thread, NULL, &keepalive_thread, this);
#endif
}
RGBController_HyperXKeyboard::~RGBController_HyperXKeyboard()
@@ -317,15 +269,3 @@ void RGBController_HyperXKeyboard::UpdateMode()
hyperx->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed, temp_colors);
}
}
void RGBController_HyperXKeyboard::KeepaliveThread()
{
while(1)
{
if(active_mode == 0)
{
hyperx->SetLEDsDirect(colors);
}
Sleep(200);
}
}
@@ -23,8 +23,6 @@ public:
void SetCustomMode();
void UpdateMode();
void KeepaliveThread();
private:
HyperXKeyboardController* hyperx;
};
-75
View File
@@ -1,75 +0,0 @@
/*-----------------------------------------*\
| RGBController_MSIRGB.cpp |
| |
| Generic RGB Interface for MSI-RGB |
| |
| Adam Honse (CalcProgrammer1) 2/14/2020 |
\*-----------------------------------------*/
#include "RGBController_MSIRGB.h"
RGBController_MSIRGB::RGBController_MSIRGB(MSIRGBController* msi_ptr)
{
msi = msi_ptr;
name = "MSI Motherboard";
description = "MSI-RGB Device";
type = DEVICE_TYPE_MOTHERBOARD;
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
led msi_led;
msi_led.name = "MSI LED";
leds.push_back(msi_led);
zone msi_zone;
msi_zone.name = "MSI Zone";
msi_zone.type = ZONE_TYPE_SINGLE;
std::vector<int> msi_zone_map;
msi_zone_map.push_back(0);
msi_zone.map.push_back(msi_zone_map);
zones.push_back(msi_zone);
colors.push_back(0x00000000);
}
RGBController_MSIRGB::~RGBController_MSIRGB()
{
}
void RGBController_MSIRGB::UpdateLEDs()
{
RGBColor color = colors[0];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
msi->SetColor(red, grn, blu);
}
void RGBController_MSIRGB::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_MSIRGB::UpdateSingleLED(int led)
{
UpdateLEDs();
}
void RGBController_MSIRGB::SetCustomMode()
{
}
void RGBController_MSIRGB::UpdateMode()
{
}
-27
View File
@@ -1,27 +0,0 @@
/*-----------------------------------------*\
| RGBController_MSIRGB.h |
| |
| Generic RGB Interface for MSI-RGB |
| |
| Adam Honse (CalcProgrammer1) 2/14/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "MSIRGBController.h"
class RGBController_MSIRGB : public RGBController
{
public:
RGBController_MSIRGB(MSIRGBController* msi_ptr);
~RGBController_MSIRGB();
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
MSIRGBController* msi;
};
+1 -5
View File
@@ -348,15 +348,11 @@ RGBController_OpenRazer::RGBController_OpenRazer(std::string dev_path)
for (unsigned int col_id = 0; col_id < device_list[i]->zones[zone_id]->cols; col_id++)
{
char id_buf[8];
snprintf(id_buf, 8, "%d", col_id + 1);
RGBColor new_color = 0x00000000;
colors.push_back(new_color);
led* new_led = new led();
new_led->name = device_list[i]->zones[zone_id]->name + " LED ";
new_led->name.append(id_buf);
new_led->name = device_list[i]->zones[zone_id]->name;
leds.push_back(*new_led);
new_zone_map.push_back(led_count);
+53 -249
View File
@@ -4,187 +4,81 @@
| Generic RGB Interface for OpenRGB |
| Gigabyte RGB Fusion 2.0 Driver |
| |
| jackun 1/8/2020 |
| Adam Honse (CalcProgrammer1) 1/15/2020 |
\*-----------------------------------------*/
#include "RGBController_RGBFusion2.h"
#include <sstream>
#include <array>
enum
{
ZONE_MB,
ZONE_STRIP1,
ZONE_STRIP2,
};
static const std::array<const char *, 3> led_zones
{
"Motherboard",
"LED Strip 1", // WS2812(B) strips
"LED Strip 2",
};
static const KnownChannels known_channels
void RGBController_RGBFusion2::UpdateLEDs()
{
for (std::size_t led = 0; led < colors.size(); led++)
{
"Generic",
{
{
{ "Led 1", 0x20 },
{ "Led 2", 0x21 },
{ "Led 3", 0x22 },
{ "Led 4", 0x23 },
{ "Led 5", 0x24 },
{ "Led 6", 0x25 },
{ "Led 7", 0x26 },
{ "Led 8", 0x27 },
},
// Zone 1
{
{ "LED Strip 1, LED 0", HDR_D_LED1 },
},
// Zone 2
{
{ "LED Strip 2, LED 0", HDR_D_LED2 },
}
}
},
{
"IT8297BX-GBX570",
{
// Zone 0
{
{ "Back I/O", HDR_BACK_IO },
{ "CPU", HDR_CPU },
{ "PCIe", HDR_PCIE },
{ "LED C1/C2", HDR_LED_C1C2 }, // 12VGRB headers seem to be connected
},
// Zone 1
{
{ "LED Strip 1, LED 0", HDR_D_LED1 },
},
// Zone 2
{
{ "LED Strip 2, LED 0", HDR_D_LED2 },
}
}
},
};
RGBColor color = colors[led];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
RGBController_RGBFusion2::RGBController_RGBFusion2(RGBFusion2Controller* controller_ptr)
{
controller = controller_ptr;
name = "RGB Fusion 2 Controller";
type = DEVICE_TYPE_MOTHERBOARD;
description = controller->GetDeviceName();
version = controller->GetFWVersion();
location = controller->GetDeviceLocation();
serial = controller->GetSerial();
auto it = known_channels.find(controller->GetDeviceName());
if (it == known_channels.end())
{
it = known_channels.find("Generic");
rgb_fusion->SetLEDColor(led, red, grn, blu);
}
}
size_t mb_led_cnt = it->second[0].size();
void RGBController_RGBFusion2::UpdateZoneLEDs(int zone)
{
RGBColor color = colors[zone];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
mode Static;
Static.name = "Static";
Static.value = EFFECT_STATIC;
Static.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
rgb_fusion->SetLEDColor(zone, red, grn, blu);
}
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = EFFECT_PULSE;
Breathing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Breathing.speed_min = 0;
Breathing.speed_max = 4;
Breathing.color_mode = MODE_COLORS_PER_LED;
Breathing.speed = 2;
modes.push_back(Breathing);
void RGBController_RGBFusion2::UpdateSingleLED(int led)
{
UpdateZoneLEDs(led);
}
mode Blinking;
Blinking.name = "Blinking";
Blinking.value = EFFECT_BLINKING;
Blinking.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Blinking.speed_min = 0;
Blinking.speed_max = 4;
Blinking.color_mode = MODE_COLORS_PER_LED;
Blinking.speed = 2;
modes.push_back(Blinking);
RGBController_RGBFusion2::RGBController_RGBFusion2(RGBFusion2Controller* rgb_fusion_ptr)
{
rgb_fusion = rgb_fusion_ptr;
mode ColorCycle;
ColorCycle.name = "Color Cycle";
ColorCycle.value = EFFECT_COLORCYCLE;
ColorCycle.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
ColorCycle.speed_min = 0;
ColorCycle.speed_max = 4;
ColorCycle.color_mode = MODE_COLORS_NONE;
ColorCycle.speed = 2;
modes.push_back(ColorCycle);
name = rgb_fusion->GetDeviceName();
description = "RGB Fusion 2.0";
location = rgb_fusion->GetDeviceLocation();
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = 10;
Flashing.flags = MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_RANDOM_COLOR;
Flashing.speed_min = 0;
Flashing.speed_max = 4;
Flashing.color_mode = MODE_COLORS_PER_LED;
Flashing.speed = 2;
modes.push_back(Flashing);
type = DEVICE_TYPE_MOTHERBOARD;
per_strip_led_cnt = 64; // TODO needs GUI option
colors.resize(mb_led_cnt + per_strip_led_cnt * 2, 0x000021FF);
controller->SetLedCount(per_strip_led_cnt);
controller->DisableBuiltinEffect(0, 0x3);
mode Direct;
Direct.name = "Direct";
Direct.value = 0;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
unsigned int led_idx = 0;
std::stringstream ss;
colors.resize(rgb_fusion->GetLEDCount());
for(size_t i = 0; i < led_zones.size(); i++)
// Search through all LEDs and create zones for each channel type
for (unsigned int i = 0; i < rgb_fusion->GetLEDCount(); i++)
{
std::vector<int> new_zone_map;
zone new_zone;
new_zone.name = led_zones[i];
new_zone.type = ZONE_TYPE_LINEAR; // TODO
zone* new_zone = new zone();
led* new_led = new led();
unsigned int zone_led_cnt = mb_led_cnt;
if( i > 0 )
{
zone_led_cnt = per_strip_led_cnt;
}
std::vector<int>* zone_row = new std::vector<int>();
for(unsigned int zone_led_idx = 0; zone_led_idx < zone_led_cnt; zone_led_idx++)
{
led new_led;
// Set zone name to channel name
new_zone->name = "Zone";
new_led->name = "LED";
if( it != known_channels.end() && i < it->second.size() && zone_led_idx < it->second[i].size())
{
new_led.name = it->second[i][zone_led_idx].name;
}
else
{
ss.clear(); ss.str("");
ss << led_zones[i];
if (zone_led_cnt > 1)
{
ss << ", LED " << zone_led_idx;
}
new_led.name = ss.str();
}
zone_row->push_back(i);
leds.push_back(new_led);
new_zone_map.push_back(led_idx);
led_idx++;
}
// Aura devices can be either single or linear, never matrix
// That means only one row is needed
new_zone->map.push_back(*zone_row);
new_zone.map.push_back(new_zone_map);
zones.push_back(new_zone);
// Push new LED to LEDs vector
leds.push_back(*new_led);
// Push new zone to zones vector
zones.push_back(*new_zone);
}
}
@@ -193,97 +87,7 @@ void RGBController_RGBFusion2::SetCustomMode()
active_mode = 0;
}
void RGBController_RGBFusion2::UpdateLEDs()
{
for(size_t i = 0; i < led_zones.size(); i++)
{
UpdateZoneLEDs(i);
}
}
void RGBController_RGBFusion2::UpdateZoneLEDs(int zone)
{
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
auto it = known_channels.find(controller->GetDeviceName());
if (it == known_channels.end())
{
it = known_channels.find("Generic");
}
if (it == known_channels.end() || zone >= (int)it->second.size())
{
return;
}
if(zone == ZONE_MB)
{
std::vector<int>& leds = zones[zone].map[0];
for(size_t i = 0; i < leds.size(); i++)
{
unsigned char red = RGBGetRValue(colors[leds[i]]);
unsigned char grn = RGBGetGValue(colors[leds[i]]);
unsigned char blu = RGBGetBValue(colors[leds[i]]);
controller->SetLEDEffect(it->second[zone][i].header, modes[active_mode].value, modes[active_mode].speed, random, red, grn, blu);
}
controller->ApplyEffect();
}
else // assuming other two zones are LED strips
{
int led = zones[zone].map[0][0];
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
int hdr = it->second[zone].size() ? it->second[zone].front().header : led;
// apply built-in effects to LED strips
controller->DisableBuiltinEffect(0, zone == 1 ? 0x01 : 0x02);
controller->SetLEDEffect(hdr, modes[active_mode].value, modes[active_mode].speed, random, red, grn, blu);
controller->ApplyEffect();
}
}
void RGBController_RGBFusion2::UpdateSingleLED(int led)
{
bool random = (modes[active_mode].color_mode == MODE_COLORS_RANDOM);
if (led >= zones[ZONE_STRIP1].map[0].front() && led <= zones[ZONE_STRIP1].map[0].back())
{
controller->SetStripColors(HDR_D_LED1_RGB,
zones[ZONE_STRIP1].map[0].front(),
zones[ZONE_STRIP1].map[0].back(),
colors, led);
}
else if (led >= zones[ZONE_STRIP2].map[0].front() && led <= zones[ZONE_STRIP2].map[0].back())
{
controller->SetStripColors(HDR_D_LED2_RGB,
zones[ZONE_STRIP2].map[0].front(),
zones[ZONE_STRIP2].map[0].back(),
colors, led);
}
else
{
int header = led;
auto it = known_channels.find(controller->GetDeviceName());
if (it == known_channels.end() || it->second.size() == 0)
header = it->second[ZONE_MB][led].header;
unsigned char red = RGBGetRValue(colors[led]);
unsigned char grn = RGBGetGValue(colors[led]);
unsigned char blu = RGBGetBValue(colors[led]);
controller->SetLEDEffect(header, modes[active_mode].value, modes[active_mode].speed, random, red, grn, blu);
controller->ApplyEffect();
}
}
void RGBController_RGBFusion2::UpdateMode()
{
// XXX Comment out to allow each zone or motherboard LED have different modes
UpdateLEDs();
rgb_fusion->SetMode(modes[active_mode].value);
}
+7 -18
View File
@@ -4,36 +4,25 @@
| Generic RGB Interface for OpenRGB |
| Gigabyte RGB Fusion 2.0 Driver |
| |
| jackun 1/8/2020 |
| Adam Honse (CalcProgrammer1) 1/15/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "RGBFusion2Controller.h"
#include <map>
#include <vector>
struct LedPort
{
const char* name;
int header;
};
typedef std::vector< std::vector<LedPort> > ZoneLeds;
typedef std::map< std::string, ZoneLeds > KnownChannels;
class RGBController_RGBFusion2: public RGBController
class RGBController_RGBFusion2 : public RGBController
{
public:
RGBController_RGBFusion2(RGBFusion2Controller* controller_ptr);
void SetCustomMode();
RGBController_RGBFusion2(RGBFusion2Controller* rgb_fusion_ptr);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
RGBFusion2Controller* controller;
IT8297Report report;
unsigned int per_strip_led_cnt;
RGBFusion2Controller* rgb_fusion;
};
@@ -1,125 +0,0 @@
/*-----------------------------------------*\
| RGBController_RGBFusionGPU.cpp |
| |
| Generic RGB Interface for OpenRGB |
| Gigabyte RGB Fusion GPU Driver |
| |
| Adam Honse (CalcProgrammer1) 2/23/2020 |
\*-----------------------------------------*/
#include "RGBController_RGBFusionGPU.h"
void RGBController_RGBFusionGPU::UpdateLEDs()
{
RGBColor color = colors[0];
unsigned char red = RGBGetRValue(color);
unsigned char grn = RGBGetGValue(color);
unsigned char blu = RGBGetBValue(color);
rgb_fusion->SetColor(red, grn, blu);
}
void RGBController_RGBFusionGPU::UpdateZoneLEDs(int zone)
{
UpdateLEDs();
}
void RGBController_RGBFusionGPU::UpdateSingleLED(int led)
{
UpdateLEDs();
}
RGBController_RGBFusionGPU::RGBController_RGBFusionGPU(RGBFusionGPUController* rgb_fusion_ptr)
{
rgb_fusion = rgb_fusion_ptr;
name = "Gigabyte GPU";
description = "RGB Fusion GPU";
location = rgb_fusion->GetDeviceLocation();
type = DEVICE_TYPE_GPU;
mode Static;
Static.name = "Static";
Static.value = RGB_FUSION_GPU_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = RGB_FUSION_GPU_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Breathing.speed_min = RGB_FUSION_GPU_SPEED_SLOWEST;
Breathing.speed_max = RGB_FUSION_GPU_SPEED_FASTEST;
Breathing.speed = RGB_FUSION_GPU_SPEED_NORMAL;
Breathing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Breathing);
mode Flashing;
Flashing.name = "Flashing";
Flashing.value = RGB_FUSION_GPU_MODE_FLASHING;
Flashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
Flashing.speed_min = RGB_FUSION_GPU_SPEED_SLOWEST;
Flashing.speed_max = RGB_FUSION_GPU_SPEED_FASTEST;
Flashing.speed = RGB_FUSION_GPU_SPEED_NORMAL;
Flashing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Flashing);
mode DualFlashing;
DualFlashing.name = "Dual Flashing";
DualFlashing.value = RGB_FUSION_GPU_MODE_DUAL_FLASHING;
DualFlashing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_PER_LED_COLOR;
DualFlashing.speed_min = RGB_FUSION_GPU_SPEED_SLOWEST;
DualFlashing.speed_max = RGB_FUSION_GPU_SPEED_FASTEST;
DualFlashing.speed = RGB_FUSION_GPU_SPEED_NORMAL;
DualFlashing.color_mode = MODE_COLORS_PER_LED;
modes.push_back(DualFlashing);
mode SpectrumCycle;
SpectrumCycle.name = "Spectrum Cycle";
SpectrumCycle.value = RGB_FUSION_GPU_MODE_SPECTRUM_CYCLE;
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED;
SpectrumCycle.speed_min = RGB_FUSION_GPU_SPEED_SLOWEST;
SpectrumCycle.speed_max = RGB_FUSION_GPU_SPEED_FASTEST;
SpectrumCycle.speed = RGB_FUSION_GPU_SPEED_NORMAL;
SpectrumCycle.color_mode = MODE_COLORS_NONE;
modes.push_back(SpectrumCycle);
colors.resize(1);
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 = "GPU Zone";
new_led->name = "GPU LED";
zone_row->push_back(0);
// 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);
// Initialize active mode
active_mode = 0;
}
void RGBController_RGBFusionGPU::SetCustomMode()
{
active_mode = 0;
}
void RGBController_RGBFusionGPU::UpdateMode()
{
rgb_fusion->SetMode(modes[active_mode].value, modes[active_mode].speed);
}
@@ -1,28 +0,0 @@
/*-----------------------------------------*\
| RGBController_RGBFusionGPU.h |
| |
| Generic RGB Interface for OpenRGB |
| Gigabyte RGB Fusion GPU Driver |
| |
| Adam Honse (CalcProgrammer1) 2/23/2020 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "RGBFusionGPUController.h"
class RGBController_RGBFusionGPU : public RGBController
{
public:
RGBController_RGBFusionGPU(RGBFusionGPUController* rgb_fusion_ptr);
void UpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void SetCustomMode();
void UpdateMode();
private:
RGBFusionGPUController* rgb_fusion;
};
-368
View File
@@ -1,368 +0,0 @@
#include <vector>
#include <cstring>
#include <string>
#include <tuple>
#include <iostream>
#include "OpenRGB.h"
#include "RGBController.h"
#include "i2c_smbus.h"
extern std::vector<i2c_smbus_interface*> busses;
extern std::vector<RGBController*> rgb_controllers;
struct DeviceOptions
{
int device;
std::vector<std::tuple<unsigned char, unsigned char, unsigned char>> colors;
std::string mode;
bool hasOption;
};
struct Options
{
std::vector<DeviceOptions> devices;
// if hasDevice is false, devices above is empty and allDeviceOptions
// shall be applied to all available devices
bool hasDevice;
DeviceOptions allDeviceOptions;
};
void PrintHelp()
{
std::string help_text;
help_text += "OpenRGB ";
help_text += VERSION_STRING;
help_text += ", for controlling RGB lighting.\n";
help_text += "Usage: OpenRGB (--device [--mode] [--color])...\n";
help_text += "\nOptions:\n";
help_text += "--gui\t\t\t\t\t Show GUI, also appears when not passing any parameters\n";
help_text += "-l, --list-devices\t\t\t Lists every compatible device with their number\n";
help_text += "-d, --device [0-9]\t\t\t Selects device to apply colors and/or effect to, or applies to all devices if omitted\n";
help_text += "\t\t\t\t\t Can be specified multiple times with different modes and colors\n";
help_text += "-c, --color \"FFFFFF,00AAFF...\"\t\t Sets colors on each device directly if no effect is specified, and sets the effect color if an effect is specified\n";
help_text += "\t\t\t\t\t If there are more LEDs than colors given, the last color will be applied to the remaining LEDs\n";
help_text += "-m, --mode [breathing | static | ...] Sets the mode to be applied, check --list-devices to see which modes are supported on your device\n";
help_text += "-v, --version\t\t\t\t Display version and software build information\n";
std::cout << help_text << std::endl;
}
void PrintVersion()
{
std::string version_text;
version_text += "OpenRGB ";
version_text += VERSION_STRING;
version_text += ", for controlling RGB lighting.\n";
version_text += " Version:\t\t ";
version_text += VERSION_STRING;
version_text += "\n Build Date\t\t ";
version_text += BUILDDATE_STRING;
version_text += "\n Git Commit ID\t\t ";
version_text += GIT_COMMIT_ID;
version_text += "\n Git Commit Date\t ";
version_text += GIT_COMMIT_DATE;
version_text += "\n Git Branch\t\t ";
version_text += GIT_BRANCH;
version_text += "\n";
std::cout << version_text << std::endl;
}
bool ParseColors(std::string colors_string, DeviceOptions *options)
{
while (colors_string.length() >= 6)
{
int rgb_end = colors_string.find_first_of(',');
std::string color = colors_string.substr(0, rgb_end);
if (color.length() != 6)
break;
try
{
unsigned char r = std::stoi(color.substr(0, 2), nullptr, 16);
unsigned char g = std::stoi(color.substr(2, 2), nullptr, 16);
unsigned char b = std::stoi(color.substr(4, 2), nullptr, 16);
options->colors.push_back(std::make_tuple(r, g, b));
}
catch (...)
{
break;
}
// If there are no more colors
if (rgb_end == std::string::npos)
break;
// Remove the current color and the next color's leading comma
colors_string = colors_string.substr(color.length() + 1);
}
return options->colors.size() > 0;
}
int ParseMode(DeviceOptions& options)
{
auto availableModes = rgb_controllers[options.device]->modes;
for (int i = 0; i < availableModes.size(); i++)
{
if (availableModes[i].name == options.mode)
{
return i;
}
}
std::cout << "Error: Mode '" + options.mode + "' not available for device '" +
rgb_controllers[options.device]->name + "'" << std::endl;
return false;
}
DeviceOptions* GetDeviceOptionsForDevID(Options *opts, int device)
{
if (device == -1)
{
return &opts->allDeviceOptions;
}
for (int i = 0; i < opts->devices.size(); i++)
{
if (opts->devices[i].device == device)
{
return &opts->devices[i];
}
}
// should never happen
std::cout << "Internal error: Tried setting an option on a device that wasn't specified" << std::endl;
abort();
}
std::string QuoteIfNecessary(std::string str)
{
if (str.find(' ') == std::string::npos)
{
return str;
}
else
{
return "'" + str + "'";
}
}
bool ProcessOptions(int argc, char *argv[], Options *res)
{
int arg_index = 1;
int currentDev = -1;
while (arg_index < argc)
{
std::string option = argv[arg_index];
// Handle options that take no arguments
if (option == "--list-devices" || option == "-l")
{
for (int i = 0; i < rgb_controllers.size(); i++)
{
RGBController *c = rgb_controllers[i];
std::cout << i << ": " << c->name << std::endl;
std::cout << " Type: " << device_type_to_str(c->type) << std::endl;
if (!c->serial.empty())
{
std::cout << " Serial: " << c->serial << std::endl;
}
if (!c->description.empty())
{
std::cout << " Description: " << c->description << std::endl;
}
if (!c->modes.empty())
{
std::cout << " Modes:";
int curMode = c->GetMode();
for (int i = 0; i < c->modes.size(); i++)
{
std::string modeStr = QuoteIfNecessary(c->modes[i].name);
if (curMode == i) {
modeStr = "[" + modeStr + "]";
}
std::cout << " " << modeStr;
}
std::cout << std::endl;
}
if (!c->zones.empty())
{
std::cout << " Zones:";
for (int i = 0; i < c->zones.size(); i++)
{
std::cout << " " << QuoteIfNecessary(c->zones[i].name);
}
std::cout << std::endl;
}
if (!c->leds.empty())
{
std::cout << " LEDs:";
for (int i = 0; i < c->leds.size(); i++)
{
std::cout << " " << QuoteIfNecessary(c->leds[i].name);
}
std::cout << std::endl;
}
std::cout << std::endl;
}
exit(0);
}
else if (arg_index + 1 < argc) // Handle options that take an argument
{
std::string argument = argv[arg_index + 1];
if (option == "--device" || option == "-d")
{
try
{
currentDev = std::stoi(argument);
if (rgb_controllers.size() <= currentDev || currentDev < 0)
{
throw;
}
DeviceOptions newDev;
newDev.device = currentDev;
if (!res->hasDevice)
{
res->hasDevice = true;
}
res->devices.push_back(newDev);
}
catch (...)
{
std::cout << "Error: Invalid device ID: " + argument << std::endl;
return false;
}
}
else if (option == "--color" || option == "-c")
{
DeviceOptions* currentDevOpts = GetDeviceOptionsForDevID(res, currentDev);
if (ParseColors(argument, currentDevOpts))
{
currentDevOpts->hasOption = true;
}
else
{
std::cout << "Error: Invalid argument to " + option + ": " + argument << std::endl;
return false;
}
}
else if (option == "--mode" || option == "-m")
{
DeviceOptions* currentDevOpts = GetDeviceOptionsForDevID(res, currentDev);
currentDevOpts->mode = argument;
currentDevOpts->hasOption = true;
}
else
{
std::cout << "Error: Invalid option: " + option << std::endl;
return false;
}
arg_index++;
}
else
{
return false;
}
arg_index++;
}
if (res->hasDevice)
{
for (int i = 0; i < res->devices.size(); i++)
{
if (!res->devices[i].hasOption)
{
std::cout << "Error: Device " + std::to_string(i) + " specified, but neither mode nor color given" << std::endl;
return false;
}
}
}
else
{
return res->allDeviceOptions.hasOption;
}
return true;
}
void ApplyOptions(DeviceOptions& options)
{
RGBController *device = rgb_controllers[options.device];
// Set mode first, in case it's 'direct' (which affects SetLED below)
int mode = ParseMode(options);
device->SetMode(mode);
if (options.colors.size() != 0)
{
int last_set_color;
for (int i = 0; i < device->leds.size(); i++)
{
if (i < options.colors.size())
{
last_set_color = i;
}
device->SetLED(i, ToRGBColor(std::get<0>(options.colors[last_set_color]),
std::get<1>(options.colors[last_set_color]),
std::get<2>(options.colors[last_set_color])));
}
}
}
int cli_main(int argc, char *argv[])
{
if (argc == 2 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h")))
{
PrintHelp();
return 0;
}
if (argc == 2 && (!strcmp(argv[1], "--version") || !strcmp(argv[1], "-v")))
{
PrintVersion();
return 0;
}
DetectRGBControllers();
Options options;
if (!ProcessOptions(argc, argv, &options))
{
PrintHelp();
return -1;
}
if (options.hasDevice)
{
for (int i = 0; i < options.devices.size(); i++)
{
ApplyOptions(options.devices[i]);
}
}
else
{
for (int i = 0; i < rgb_controllers.size(); i++)
{
options.allDeviceOptions.device = i;
ApplyOptions(options.allDeviceOptions);
}
}
return 0;
}
-560
View File
@@ -1,560 +0,0 @@
#define _WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "nvapi.h"
// Constructors for NvAPI structures that just zero the memory and set the right version
NV_DELTA_ENTRY::NV_DELTA_ENTRY()
{
memset(this, 0, sizeof *this);
}
NV_GPU_PSTATES20_V2::NV_GPU_PSTATES20_V2()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_GPU_PSTATES20_V2, 2);
}
NV_CLOCK_FREQUENCIES_V2::NV_CLOCK_FREQUENCIES_V2()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_CLOCK_FREQUENCIES_V2, 2);
}
NV_GPU_PERFORMANCE_TABLE_V1::NV_GPU_PERFORMANCE_TABLE_V1()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_GPU_PERFORMANCE_TABLE_V1, 1);
}
NV_DYNAMIC_PSTATES_V1::NV_DYNAMIC_PSTATES_V1()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_DYNAMIC_PSTATES_V1, 1);
}
NV_GPU_POWER_POLICIES_INFO_V1::NV_GPU_POWER_POLICIES_INFO_V1()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_GPU_POWER_POLICIES_INFO_V1, 1);
}
NV_GPU_POWER_POLICIES_STATUS_V1::NV_GPU_POWER_POLICIES_STATUS_V1()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_GPU_POWER_POLICIES_STATUS_V1, 1);
}
NV_GPU_VOLTAGE_DOMAINS_STATUS_V1::NV_GPU_VOLTAGE_DOMAINS_STATUS_V1()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_GPU_VOLTAGE_DOMAINS_STATUS_V1, 1);
}
NV_GPU_THERMAL_SETTINGS_V2::NV_GPU_THERMAL_SETTINGS_V2()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_GPU_THERMAL_SETTINGS_V2, 2);
}
NV_GPU_THERMAL_POLICIES_INFO_V2::NV_GPU_THERMAL_POLICIES_INFO_V2()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_GPU_THERMAL_POLICIES_INFO_V2, 2);
}
NV_GPU_THERMAL_POLICIES_STATUS_V2::NV_GPU_THERMAL_POLICIES_STATUS_V2()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_GPU_THERMAL_POLICIES_STATUS_V2, 2);
}
NV_GPU_COOLER_SETTINGS_V2::NV_GPU_COOLER_SETTINGS_V2()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_GPU_COOLER_SETTINGS_V2, 2);
}
NV_GPU_COOLER_LEVELS_V1::NV_GPU_COOLER_LEVELS_V1()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_GPU_COOLER_LEVELS_V1, 1);
}
NV_MEMORY_INFO_V2::NV_MEMORY_INFO_V2()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_MEMORY_INFO_V2, 2);
}
NV_DISPLAY_DRIVER_VERSION_V1::NV_DISPLAY_DRIVER_VERSION_V1()
{
memset(this, 0, sizeof *this);
version = NV_STRUCT_VERSION(NV_DISPLAY_DRIVER_VERSION_V1, 1);
}
NV_I2C_INFO_V3::NV_I2C_INFO_V3()
{
memset(this, 0, sizeof * this);
version = NV_STRUCT_VERSION(NV_I2C_INFO_V3, 3);
}
// Interface: 0150E828
static NV_STATUS (*pNvAPI_Initialize)();
// Interface: D22BDD7E
static NV_STATUS (*pNvAPI_Unload)();
// Interface: 9ABDD40D
static NV_STATUS (*pNvAPI_EnumDisplayHandle)(
NV_S32 this_enum,
NV_DISPLAY_HANDLE *display_handle);
// Interface: E5AC921F
static NV_STATUS (*pNvAPI_EnumPhysicalGPUs)(
NV_PHYSICAL_GPU_HANDLE *physical_gpu_handles,
NV_S32 *gpu_count);
// Interface: F951A4D1
static NV_STATUS (*pNvAPI_GetDisplayDriverVersion)(
NV_DISPLAY_HANDLE display_handle,
NV_DISPLAY_DRIVER_VERSION_V1 *display_driver_version);
// Interface: 01053FA5
static NV_STATUS (*pNvAPI_GetInterfaceVersionString)(
NV_SHORT_STRING version);
// Interface: 34EF9506
static NV_STATUS (*pNvAPI_GetPhysicalGPUsFromDisplay)(
NV_DISPLAY_HANDLE display_handle,
NV_PHYSICAL_GPU_HANDLE *gpu_handles,
NV_U32 *gpu_count);
// Interface: 774AA982
static NV_STATUS (*pNvAPI_GetMemoryInfo)(
NV_DISPLAY_HANDLE display_handle,
NV_MEMORY_INFO_V2 *memory_info);
// Interface: 0CEEE8E9F
static NV_STATUS (*pNvAPI_GPU_GetFullName)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_SHORT_STRING name);
// Interface: 6FF81213
static NV_STATUS (*pNvAPI_GPU_GetPStates20)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_PSTATES20_V2 *pstates);
// Interface: 0F4DAE6B
static NV_STATUS (*pNvAPI_GPU_SetPStates20)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_PSTATES20_V2 *pstates);
// Interface: DCB616C3
static NV_STATUS (*pNvAPI_GPU_GetAllClockFrequencies)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_CLOCK_FREQUENCIES_V2 *frequencies);
// Interface: 60DED2ED
static NV_STATUS (*pNvAPI_GPU_GetDynamicPStates)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_DYNAMIC_PSTATES_V1 *dynamic_pstates);
// Interface: 34206D86
static NV_STATUS (*pNvAPI_GPU_GetPowerPoliciesInfo)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_POWER_POLICIES_INFO_V1 *policies_info);
// Interface: 70916171
static NV_STATUS (*pNvAPI_GPU_GetPowerPoliciesStatus)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_POWER_POLICIES_STATUS_V1 *policies_status);
// Interface: 0C16C7E2C
static NV_STATUS (*pNvAPI_GPU_GetVoltageDomainStatus)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_VOLTAGE_DOMAINS_STATUS_V1 *voltage_domains_status);
// Interface: 0E3640A56
static NV_STATUS (*pNvAPI_GPU_GetThermalSettings)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_THERMAL_TARGET sensor_index,
NV_GPU_THERMAL_SETTINGS_V2 *thermal_settings);
// Interface: 014B83A5F
static NV_STATUS (*pNvAPI_GPU_GetSerialNumber)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_SHORT_STRING serial_number);
// Interface: 0AD95F5ED
static NV_STATUS (*pNvAPI_GPU_SetPowerPoliciesStatus)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_POWER_POLICIES_STATUS_V1* policies_status);
// Interface: 00D258BB5
static NV_STATUS (*pNvAPI_GPU_GetThermalPoliciesInfo)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_THERMAL_POLICIES_INFO_V2* thermal_info);
// Interface: 0E9C425A1
static NV_STATUS (*pNvAPI_GPU_GetThermalPoliciesStatus)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_THERMAL_POLICIES_STATUS_V2* thermal_status);
// Interface: 034C0B13D
static NV_STATUS (*pNvAPI_GPU_SetThermalPoliciesStatus)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_THERMAL_POLICIES_STATUS_V2* thermal_status);
// Interface: DA141340
static NV_STATUS (*pNvAPI_GPU_GetCoolerSettings)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_S32 cooler_index,
NV_GPU_COOLER_SETTINGS_V2 *cooler_settings);
// Interface: 891FA0AE
static NV_STATUS (*pNvAPI_GPU_SetCoolerLevels)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_S32 cooler_index,
NV_GPU_COOLER_LEVELS_V1 *cooler_levels);
// Interface: 2DDFB66E
static NV_STATUS (*pNvAPI_GPU_GetPCIIdentifiers)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_U32 *device_id,
NV_U32 *sub_system_id,
NV_U32 *revision_id,
NV_U32 *ext_device_id);
// Interface: 283AC65A
static NV_STATUS (*pNvAPI_I2CWriteEx)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_I2C_INFO_V3* i2c_info,
NV_U32 *unknown);
// Interface: 4D7B0709
static NV_STATUS(*pNvAPI_I2CReadEx)(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_I2C_INFO_V3* i2c_info,
NV_U32 *unknown);
static bool QueryInterfaceOpaque(FARPROC query_interface, NV_U32 id, void **result)
{
void *address = ((void *(*)(NV_U32))query_interface)(id);
if (address) {
*result = address;
return true;
}
return false;
}
template<typename F>
static void QueryInterfaceCast(FARPROC query_interface, NV_U32 id, const char *function_name, F &function_pointer)
{
const bool result = QueryInterfaceOpaque(query_interface, id, (void **)&function_pointer);
////Log::write("%s querying interface '0x%08x' '%s'", result ? "success" : "failure", id, function_name);
}
#define QueryInterface(query_interface, id, function) \
QueryInterfaceCast((query_interface), (id), #function, p ## function)
static void QueryInterfaces(FARPROC query_interface)
{
//Log::write("querying interfaces with '0x%p'", query_interface);
QueryInterface(query_interface, 0x0150E828, NvAPI_Initialize);
QueryInterface(query_interface, 0xD22BDD7E, NvAPI_Unload);
QueryInterface(query_interface, 0x9ABDD40D, NvAPI_EnumDisplayHandle);
QueryInterface(query_interface, 0xE5AC921F, NvAPI_EnumPhysicalGPUs);
QueryInterface(query_interface, 0xF951A4D1, NvAPI_GetDisplayDriverVersion);
QueryInterface(query_interface, 0x01053FA5, NvAPI_GetInterfaceVersionString);
QueryInterface(query_interface, 0x34EF9506, NvAPI_GetPhysicalGPUsFromDisplay);
QueryInterface(query_interface, 0x774AA982, NvAPI_GetMemoryInfo);
QueryInterface(query_interface, 0x0CEEE8E9F, NvAPI_GPU_GetFullName);
QueryInterface(query_interface, 0x6FF81213, NvAPI_GPU_GetPStates20);
QueryInterface(query_interface, 0x0F4DAE6B, NvAPI_GPU_SetPStates20);
QueryInterface(query_interface, 0xDCB616C3, NvAPI_GPU_GetAllClockFrequencies);
QueryInterface(query_interface, 0x60DED2ED, NvAPI_GPU_GetDynamicPStates);
QueryInterface(query_interface, 0x34206D86, NvAPI_GPU_GetPowerPoliciesInfo);
QueryInterface(query_interface, 0x70916171, NvAPI_GPU_GetPowerPoliciesStatus);
QueryInterface(query_interface, 0x0C16C7E2C, NvAPI_GPU_GetVoltageDomainStatus);
QueryInterface(query_interface, 0x0E3640A56, NvAPI_GPU_GetThermalSettings);
QueryInterface(query_interface, 0x014B83A5F, NvAPI_GPU_GetSerialNumber);
QueryInterface(query_interface, 0x0AD95F5ED, NvAPI_GPU_SetPowerPoliciesStatus);
QueryInterface(query_interface, 0x00D258BB5, NvAPI_GPU_GetThermalPoliciesInfo);
QueryInterface(query_interface, 0x0E9C425A1, NvAPI_GPU_GetThermalPoliciesStatus);
QueryInterface(query_interface, 0x034C0B13D, NvAPI_GPU_SetThermalPoliciesStatus);
QueryInterface(query_interface, 0xDA141340, NvAPI_GPU_GetCoolerSettings);
QueryInterface(query_interface, 0x891FA0AE, NvAPI_GPU_SetCoolerLevels);
QueryInterface(query_interface, 0x2DDFB66E, NvAPI_GPU_GetPCIIdentifiers);
QueryInterface(query_interface, 0x283AC65A, NvAPI_I2CWriteEx);
QueryInterface(query_interface, 0x4D7B0709, NvAPI_I2CReadEx);
}
NV_STATUS NvAPI_Initialize()
{
if (!pNvAPI_Initialize) {
const char *name = sizeof(void*) == 4 ? "nvapi.dll" : "nvapi64.dll";
HMODULE nvapi = LoadLibraryA(name);
if (!nvapi) {
//Log::write("failed to load '%s'", name);
return -1;
}
//Log::write("loaded '%s' '0x%p'", name, nvapi);
FARPROC query_interface = GetProcAddress(nvapi, "nvapi_QueryInterface");
if (!query_interface) {
//Log::write("failed to find 'nvapi_QueryInterface'");
return -1;
}
QueryInterfaces(query_interface);
}
return pNvAPI_Initialize
? (*pNvAPI_Initialize)()
: -1;
}
NV_STATUS NvAPI_Unload()
{
return pNvAPI_Unload
? (*pNvAPI_Unload)()
: -1;
}
NV_STATUS NvAPI_EnumDisplayHandle(
NV_S32 this_enum,
NV_DISPLAY_HANDLE *display_handle)
{
return pNvAPI_EnumDisplayHandle
? (*pNvAPI_EnumDisplayHandle)(this_enum, display_handle)
: -1;
}
NV_STATUS NvAPI_EnumPhysicalGPUs(
NV_PHYSICAL_GPU_HANDLE *physical_gpu_handles,
NV_S32 *gpu_count)
{
return pNvAPI_EnumPhysicalGPUs
? (*pNvAPI_EnumPhysicalGPUs)(physical_gpu_handles, gpu_count)
: -1;
}
NV_STATUS NvAPI_GetDisplayDriverVersion(
NV_DISPLAY_HANDLE display_handle,
NV_DISPLAY_DRIVER_VERSION_V1 *display_driver_version)
{
return pNvAPI_GetDisplayDriverVersion
? (*pNvAPI_GetDisplayDriverVersion)(display_handle, display_driver_version)
: -1;
}
NV_STATUS NvAPI_GetInterfaceVersionString(
NV_SHORT_STRING version)
{
return pNvAPI_GetInterfaceVersionString
? (*pNvAPI_GetInterfaceVersionString)(version)
: -1;
}
NV_STATUS NvAPI_GetPhysicalGPUsFromDisplay(
NV_DISPLAY_HANDLE display_handle,
NV_PHYSICAL_GPU_HANDLE *gpu_handles,
NV_U32 *gpu_count)
{
return pNvAPI_GetPhysicalGPUsFromDisplay
? (*pNvAPI_GetPhysicalGPUsFromDisplay)(display_handle, gpu_handles, gpu_count)
: -1;
}
NV_STATUS NvAPI_GetMemoryInfo(
NV_DISPLAY_HANDLE display_handle,
NV_MEMORY_INFO_V2 *memory_info)
{
return pNvAPI_GetMemoryInfo
? (*pNvAPI_GetMemoryInfo)(display_handle, memory_info)
: -1;
}
NV_STATUS NvAPI_GPU_GetFullName(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_SHORT_STRING name)
{
return pNvAPI_GPU_GetFullName
? (*pNvAPI_GPU_GetFullName)(physical_gpu_handle, name)
: -1;
}
NV_STATUS NvAPI_GPU_GetPStates20(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_PSTATES20_V2 *pstates)
{
return pNvAPI_GPU_GetPStates20
? (*pNvAPI_GPU_GetPStates20)(physical_gpu_handle, pstates)
: -1;
}
NV_STATUS NvAPI_GPU_SetPStates20(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_PSTATES20_V2 *pstates)
{
return pNvAPI_GPU_SetPStates20
? (*pNvAPI_GPU_GetPStates20)(physical_gpu_handle, pstates)
: -1;
}
NV_STATUS NvAPI_GPU_GetAllClockFrequencies(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_CLOCK_FREQUENCIES_V2 *frequencies)
{
return pNvAPI_GPU_GetAllClockFrequencies
? (*pNvAPI_GPU_GetAllClockFrequencies)(physical_gpu_handle, frequencies)
: -1;
}
NV_STATUS NvAPI_GPU_GetDynamicPStates(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_DYNAMIC_PSTATES_V1 *dynamic_pstates)
{
return pNvAPI_GPU_GetDynamicPStates
? (*pNvAPI_GPU_GetDynamicPStates)(physical_gpu_handle, dynamic_pstates)
: -1;
}
NV_STATUS NvAPI_GPU_GetPowerPoliciesInfo(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_POWER_POLICIES_INFO_V1 *policies_info)
{
return pNvAPI_GPU_GetPowerPoliciesInfo
? (*pNvAPI_GPU_GetPowerPoliciesInfo)(physical_gpu_handle, policies_info)
: -1;
}
NV_STATUS NvAPI_GPU_GetPowerPoliciesStatus(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_POWER_POLICIES_STATUS_V1 *policies_status)
{
return pNvAPI_GPU_GetPowerPoliciesStatus
? (*NvAPI_GPU_GetPowerPoliciesStatus)(physical_gpu_handle, policies_status)
: -1;
}
NV_STATUS NvAPI_GPU_GetVoltageDomainStatus(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_VOLTAGE_DOMAINS_STATUS_V1 *voltage_domains_status)
{
return pNvAPI_GPU_GetVoltageDomainStatus
? (*pNvAPI_GPU_GetVoltageDomainStatus)(physical_gpu_handle, voltage_domains_status)
: -1;
}
NV_STATUS NvAPI_GPU_GetThermalSettings(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_THERMAL_TARGET sensor_index,
NV_GPU_THERMAL_SETTINGS_V2 *thermal_settings)
{
return pNvAPI_GPU_GetThermalSettings
? (*pNvAPI_GPU_GetThermalSettings)(physical_gpu_handle, sensor_index, thermal_settings)
: -1;
}
NV_STATUS NvAPI_GPU_GetSerialNumber(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_SHORT_STRING serial_number)
{
return pNvAPI_GPU_GetSerialNumber
? (*pNvAPI_GPU_GetSerialNumber)(physical_gpu_handle, serial_number)
: -1;
}
NV_STATUS NvAPI_GPU_SetPowerPoliciesStatus(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_POWER_POLICIES_STATUS_V1* policies_status)
{
return pNvAPI_GPU_SetPowerPoliciesStatus
? (*pNvAPI_GPU_SetPowerPoliciesStatus)(physical_gpu_handle, policies_status)
: -1;
}
NV_STATUS NvAPI_GPU_GetThermalPoliciesInfo(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_THERMAL_POLICIES_INFO_V2* thermal_info)
{
return pNvAPI_GPU_GetThermalPoliciesInfo
? (*pNvAPI_GPU_GetThermalPoliciesInfo)(physical_gpu_handle, thermal_info)
: -1;
}
NV_STATUS NvAPI_GPU_GetThermalPoliciesStatus(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_THERMAL_POLICIES_STATUS_V2* thermal_status)
{
return pNvAPI_GPU_GetThermalPoliciesStatus
? (*pNvAPI_GPU_GetThermalPoliciesStatus)(physical_gpu_handle, thermal_status)
: -1;
}
NV_STATUS NvAPI_GPU_SetThermalPoliciesStatus(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_THERMAL_POLICIES_STATUS_V2* thermal_status)
{
return pNvAPI_GPU_SetThermalPoliciesStatus
? (*pNvAPI_GPU_SetThermalPoliciesStatus)(physical_gpu_handle, thermal_status)
: -1;
}
NV_STATUS NvAPI_GPU_GetCoolerSettings(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_S32 cooler_index,
NV_GPU_COOLER_SETTINGS_V2 *cooler_settings)
{
return pNvAPI_GPU_GetCoolerSettings
? (*pNvAPI_GPU_GetCoolerSettings)(physical_gpu_handle, cooler_index, cooler_settings)
: -1;
}
NV_STATUS NvAPI_GPU_SetCoolerLevels(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_S32 cooler_index,
NV_GPU_COOLER_LEVELS_V1 *cooler_levels)
{
return pNvAPI_GPU_SetCoolerLevels
? (*pNvAPI_GPU_SetCoolerLevels)(physical_gpu_handle, cooler_index, cooler_levels)
: -1;
}
NV_STATUS NvAPI_GPU_GetPCIIdentifiers(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_U32 *device_id,
NV_U32 *sub_system_id,
NV_U32 *revision_id,
NV_U32 *ext_device_id)
{
return pNvAPI_GPU_GetPCIIdentifiers
? (*pNvAPI_GPU_GetPCIIdentifiers)(physical_gpu_handle, device_id, sub_system_id, revision_id, ext_device_id)
: -1;
}
NV_STATUS NvAPI_I2CWriteEx(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_I2C_INFO_V3* i2c_info,
NV_U32 *unknown)
{
return pNvAPI_I2CWriteEx
? (*pNvAPI_I2CWriteEx)(physical_gpu_handle, i2c_info, unknown)
: -1;
}
NV_STATUS NvAPI_I2CReadEx(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_I2C_INFO_V3* i2c_info,
NV_U32 *unknown)
{
return pNvAPI_I2CReadEx
? (*pNvAPI_I2CReadEx)(physical_gpu_handle, i2c_info, unknown)
: -1;
}
-465
View File
@@ -1,465 +0,0 @@
#ifndef NVAPI_H
#define NVAPI_H
#include <stdint.h>
typedef int32_t NV_S32;
typedef uint32_t NV_U32;
typedef uint8_t NV_U8;
typedef NV_S32* NV_HANDLE;
typedef NV_HANDLE NV_PHYSICAL_GPU_HANDLE;
typedef NV_HANDLE NV_VIRTUAL_GPU_HANDLE;
typedef NV_HANDLE NV_UNATTACHED_DISPLAY_HANDLE;
typedef NV_HANDLE NV_DISPLAY_HANDLE;
typedef char NV_SHORT_STRING[64];
typedef NV_S32 NV_STATUS;
#define NV_STRUCT_VERSION(STRUCT, VERSION) \
(((VERSION) << 16) | sizeof(STRUCT))
enum class NV_CLOCK_SYSTEM : NV_S32 {
GPU,
MEMORY,
SHADER
};
enum class NV_DYNAMIC_PSTATES_SYSTEM : NV_S32 {
GPU,
FB,
VID,
BUS
};
struct NV_DELTA_ENTRY {
NV_DELTA_ENTRY();
NV_S32 value;
NV_S32 value_min;
NV_S32 value_max;
};
struct NV_GPU_PSTATES20_V2 {
NV_GPU_PSTATES20_V2();
NV_U32 version;
NV_U32 flags;
NV_U32 state_count;
NV_U32 clock_count;
NV_U32 voltage_count;
struct {
NV_U32 state_num;
NV_U32 flags;
struct {
NV_U32 domain;
NV_U32 type; // NOTE(dweiler): 0 = single frequency, 1 = dynamic frequencu
NV_U32 flags; // NOTE(dweiler): flags don't appear to be enforced by NVAPI
NV_DELTA_ENTRY frequency_delta; // NOTE(dweiler): only valid when type == 1
NV_U32 min_or_single_frequency; // NOTE(dweiler): only valid when type == 0
NV_U32 max_frequency; // NOTE(dweiler): only valid when type == 1
NV_U32 voltage_domain; // NOTE(dweiler): only valid when type == 1
NV_U32 min_voltage; // NOTE(dweiler): only valid when type == 1
NV_U32 max_voltage; // NOTE(dweiler): only valid when type == 1
} clocks[8];
struct {
NV_U32 domain;
NV_U32 flags; // NOTE(dweiler): base voltage can only be changed if bit 0 is set
NV_U32 voltage;
NV_DELTA_ENTRY voltage_delta;
} base_voltages[4]; // NOTE(dweiler): base voltage (resting voltage wheen given a pstate) for all available voltage domains
} states[16];
struct {
NV_U32 voltage_count;
struct {
NV_U32 domain;
NV_U32 flags;
NV_U32 voltage;
NV_DELTA_ENTRY voltage_delta;
} voltages[4];
} over_voltage;
};
enum class NV_CLOCK_FREQUENCY_TYPE : NV_S32 {
CURRENT,
BASE,
BOOST,
LAST
};
struct NV_CLOCK_FREQUENCIES_V2 {
NV_CLOCK_FREQUENCIES_V2();
NV_U32 version;
NV_U32 clock_type;
struct {
NV_U32 present;
NV_U32 frequency;
} entries[32];
};
struct NV_GPU_PERFORMANCE_TABLE_V1 {
NV_GPU_PERFORMANCE_TABLE_V1();
NV_U32 version;
NV_U32 plevel_count;
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_U32 domain_entries;
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_U32 pstate_level;
NV_U32 : 32; // NOTE(dweiler): unknown value
struct {
struct {
NV_U32 domain;
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_U32 clock;
NV_U32 default_clock;
NV_U32 min_clock;
NV_U32 max_clock;
NV_U32 : 32; // NOTE(dweiler): unknown value
} domains[32];
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_U32 setting_flags;
} entries[10];
NV_U32 unknown[450]; // NOTE(dweiler): the following block of memory is completely unknown
};
struct NV_DYNAMIC_PSTATES_V1 {
NV_DYNAMIC_PSTATES_V1();
NV_U32 version;
NV_U32 flags;
struct {
NV_U32 present;
NV_U32 value;
} pstates[8];
};
struct NV_GPU_POWER_POLICIES_INFO_V1 {
NV_GPU_POWER_POLICIES_INFO_V1();
NV_U32 version;
NV_U32 flags;
struct {
NV_U32 pstate;
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_U32 min_power;
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_U32 default_power;
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_U32 max_power;
NV_U32 : 32; // NOTE(dweiler): unknown value
} entries[4];
};
struct NV_GPU_POWER_POLICIES_STATUS_V1 {
NV_GPU_POWER_POLICIES_STATUS_V1();
NV_U32 version;
NV_U32 count;
struct {
NV_U32 pstate; // NOTE(dweiler): assumed?
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_U32 power;
NV_U32 : 32; // NOTE(dweiler): unknown value
} entries[4];
};
struct NV_GPU_VOLTAGE_DOMAINS_STATUS_V1 {
NV_GPU_VOLTAGE_DOMAINS_STATUS_V1();
NV_U32 version;
NV_U32 flags;
NV_U32 count;
struct {
NV_U32 voltage_domain;
NV_U32 current_voltage;
} entries[16];
};
enum class NV_THERMAL_CONTROLLER : NV_S32 {
NONE,
GPU_INTERNAL,
ADM103,
MAX6649,
MAX1617,
LM99,
LM89,
LM64,
ADT7473,
SBMAX6649,
VBIOSEVT,
OS,
UNKNOWN = -1
};
enum class NV_THERMAL_TARGET : NV_S32 {
NONE = 0,
GPU = 1,
MEMORY = 2,
POWER_SUPPLY = 4,
BOARD = 8,
ALL = 15,
UNKNOWN = -1
};
enum class NV_I2C_SPEED : NV_U32 {
NVAPI_I2C_SPEED_DEFAULT,
NVAPI_I2C_SPEED_3KHZ,
NVAPI_I2C_SPEED_10KHZ,
NVAPI_I2C_SPEED_33KHZ,
NVAPI_I2C_SPEED_100KHZ,
NVAPI_I2C_SPEED_200KHZ,
NVAPI_I2C_SPEED_400KHZ
};
struct NV_GPU_THERMAL_SETTINGS_V2 {
NV_GPU_THERMAL_SETTINGS_V2();
NV_U32 version;
NV_U32 count;
struct {
NV_THERMAL_CONTROLLER controller;
NV_S32 default_min;
NV_S32 default_max;
NV_S32 current_temperature;
NV_THERMAL_TARGET target;
} sensor[3];
};
struct NV_GPU_THERMAL_POLICIES_INFO_V2 {
NV_GPU_THERMAL_POLICIES_INFO_V2();
NV_U32 version;
NV_U32 flags;
struct {
NV_U32 controller; // NOTE(dweiler): can't be NV_THERMAL_CONTROLLER since this needs to be unsigned
NV_U32 : 32; // NOTE(dweiler): unknown value
NV_S32 min; // NOTE(dweiler): stored as multiples of 256
NV_S32 default_; // NOTE(dweiler): stored as multiples of 256
NV_S32 max; // NOTE(dweiler): stored as multiples of 256
NV_U32 default_flags; // NOTE(dweiler): bit zero of the flags indicates the thermal priority
} entries[4];
};
struct NV_GPU_THERMAL_POLICIES_STATUS_V2 {
NV_GPU_THERMAL_POLICIES_STATUS_V2();
NV_U32 version;
NV_U32 count;
struct {
NV_U32 controller;
NV_U32 value; // NOTE(dweiler): stored as multiples of 256
NV_U32 flags; // NOTE(dweiler): bit zero of the flags indicates the thermal priority
} entries[4];
};
struct NV_GPU_COOLER_SETTINGS_V2 {
NV_GPU_COOLER_SETTINGS_V2();
NV_U32 version;
NV_U32 count;
struct {
NV_S32 type;
NV_S32 controller;
NV_S32 default_min;
NV_S32 default_max;
NV_S32 current_min;
NV_S32 current_max;
NV_S32 current_level;
NV_S32 default_policy;
NV_S32 current_policy;
NV_S32 target;
NV_S32 control_type;
NV_S32 active;
} coolers[20];
};
struct NV_GPU_COOLER_LEVELS_V1 {
NV_GPU_COOLER_LEVELS_V1();
NV_U32 version;
struct {
NV_S32 level;
NV_S32 policy; // NOTE(dweiler): 0x20 is default policy, 0x01 is user supplied policy
// TODO(dweiler): figure out what other policy values are valid
} levels[20];
};
struct NV_MEMORY_INFO_V2 {
NV_MEMORY_INFO_V2();
NV_U32 version;
NV_U32 values[5];
};
struct NV_DISPLAY_DRIVER_VERSION_V1 {
NV_DISPLAY_DRIVER_VERSION_V1();
NV_U32 version;
NV_U32 driver_version; // NOTE(dweiler): major = (driver_version / 100), minor = (driver_version % 100)
NV_U32 : 32; // NOTE(dweiler): unknown vaue
NV_SHORT_STRING build_branch;
NV_SHORT_STRING adapter;
};
struct NV_I2C_INFO_V3 {
NV_I2C_INFO_V3();
NV_U32 version;
NV_U32 display_mask;
NV_U8 is_ddc_port;
NV_U8 i2c_dev_address;
NV_U8* i2c_reg_address;
NV_U32 reg_addr_size;
NV_U8* data;
NV_U32 size;
NV_U32 i2c_speed;
NV_I2C_SPEED i2c_speed_khz;
NV_U8 port_id;
NV_U32 is_port_id_set;
};
// Interface: 0150E828
NV_STATUS NvAPI_Initialize();
// Interface: D22BDD7E
NV_STATUS NvAPI_Unload();
// Interface: 9ABDD40D
NV_STATUS NvAPI_EnumDisplayHandle(
NV_S32 this_enum,
NV_DISPLAY_HANDLE *display_handle);
// Interface: E5AC921F
NV_STATUS NvAPI_EnumPhysicalGPUs(
NV_PHYSICAL_GPU_HANDLE *physical_gpu_handles,
NV_S32 *gpu_count);
// Interface: F951A4D1
NV_STATUS NvAPI_GetDisplayDriverVersion(
NV_DISPLAY_HANDLE display_handle,
NV_DISPLAY_DRIVER_VERSION_V1 *display_driver_version);
// Interface: 01053FA5
NV_STATUS NvAPI_GetInterfaceVersionString(
NV_SHORT_STRING version);
// Interface: 34EF9506
NV_STATUS NvAPI_GetPhysicalGPUsFromDisplay(
NV_DISPLAY_HANDLE display_handle,
NV_PHYSICAL_GPU_HANDLE *gpu_handles,
NV_U32 *gpu_count);
// Interface: 774AA982
NV_STATUS NvAPI_GetMemoryInfo(
NV_DISPLAY_HANDLE display_handle,
NV_MEMORY_INFO_V2 *memory_info);
// Interface: 0CEEE8E9F
NV_STATUS NvAPI_GPU_GetFullName(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_SHORT_STRING name);
// Interface: 6FF81213
NV_STATUS NvAPI_GPU_GetPStates20(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_PSTATES20_V2 *pstates);
// Interface: 0F4DAE6B
NV_STATUS NvAPI_GPU_SetPStates20(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_PSTATES20_V2 *pstates);
// Get frequencies of all clocks of the GPU
//
// The actual frequencies (current, base, boost) returned is based on the value
// set in frequencies->clock_type before calling this function. The value values
// are part of the NV_CLOCK_FREQUENCY_TYPE enumeration.
//
// Interface: DCB616C3
NV_STATUS NvAPI_GPU_GetAllClockFrequencies(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_CLOCK_FREQUENCIES_V2 *frequencies);
// Interface: 60DED2ED
NV_STATUS NvAPI_GPU_GetDynamicPStates(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_DYNAMIC_PSTATES_V1 *dynamic_pstates);
// Interface: 34206D86
NV_STATUS NvAPI_GPU_GetPowerPoliciesInfo(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_POWER_POLICIES_INFO_V1 *policies_info);
// Interface: 70916171
NV_STATUS NvAPI_GPU_GetPowerPoliciesStatus(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_POWER_POLICIES_STATUS_V1 *policies_status);
// Interface: 0C16C7E2C
NV_STATUS NvAPI_GPU_GetVoltageDomainStatus(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_VOLTAGE_DOMAINS_STATUS_V1 *voltage_domains_status);
// Get the thermal settings of the GPU
//
// The value of [sensor_index] must be one of the values of NV_THERMAL_TARGET,
// either a single sensor, or the special value NV_THERMAL_TARGET::ALL for all
// sensors present on the GPU
//
// Interface: 0E3640A56
NV_STATUS NvAPI_GPU_GetThermalSettings(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_THERMAL_TARGET sensor_index,
NV_GPU_THERMAL_SETTINGS_V2 *thermal_settings);
// Get the serial number of the GPU
//
// The NV_SHORT_STRING will be filled out accordingly
//
// Interface: 014B83A5F
NV_STATUS NvAPI_GPU_GetSerialNumber(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_SHORT_STRING serial_number);
// Interface: 0AD95F5ED
NV_STATUS NvAPI_GPU_SetPowerPoliciesStatus(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_POWER_POLICIES_STATUS_V1* policies_status);
// Interface: 00D258BB5
NV_STATUS NvAPI_GPU_GetThermalPoliciesInfo(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_THERMAL_POLICIES_INFO_V2* thermal_info);
// Interface: 0E9C425A1
NV_STATUS NvAPI_GPU_GetThermalPoliciesStatus(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_THERMAL_POLICIES_STATUS_V2* thermal_status);
// Interface: 034C0B13D
NV_STATUS NvAPI_GPU_SetThermalPoliciesStatus(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_GPU_THERMAL_POLICIES_STATUS_V2* thermal_status);
// Interface: DA141340
NV_STATUS NvAPI_GPU_GetCoolerSettings(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_S32 cooler_index,
NV_GPU_COOLER_SETTINGS_V2 *cooler_settings);
// Interface: 891FA0AE
NV_STATUS NvAPI_GPU_SetCoolerLevels(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_S32 cooler_index,
NV_GPU_COOLER_LEVELS_V1 *cooler_levels);
// Interface: 2DDFB66E
NV_STATUS NvAPI_GPU_GetPCIIdentifiers(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_U32 *device_id,
NV_U32 *sub_system_id,
NV_U32 *revision_id,
NV_U32 *ext_device_id);
// Interface: 283AC65A
NV_STATUS NvAPI_I2CWriteEx(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_I2C_INFO_V3 *i2c_info,
NV_U32 *unknown);
// Interface: 4D7B0709
NV_STATUS NvAPI_I2CReadEx(
NV_PHYSICAL_GPU_HANDLE physical_gpu_handle,
NV_I2C_INFO_V3* i2c_info,
NV_U32 *unknown);
#endif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-1383
View File
File diff suppressed because it is too large Load Diff
+32 -28
View File
@@ -30,7 +30,7 @@
#include <wchar.h>
#ifdef _WIN32
#define HID_API_EXPORT
#define HID_API_EXPORT __declspec(dllexport)
#define HID_API_CALL
#else
#define HID_API_EXPORT /**< API export macro */
@@ -69,9 +69,13 @@ extern "C" {
(Windows/Mac only).*/
unsigned short usage;
/** The USB interface which this logical device
represents. Valid on both Linux implementations
in all cases, and valid on the Windows implementation
only if the device contains more than one interface. */
represents.
* Valid on both Linux implementations in all cases.
* Valid on the Windows implementation only if the device
contains more than one interface.
* Valid on the Mac implementation if and only if the device
is a USB HID device. */
int interface_number;
/** Pointer to the next device */
@@ -125,7 +129,7 @@ extern "C" {
@returns
This function returns a pointer to a linked list of type
struct #hid_device, containing information about the HID devices
struct #hid_device_info, containing information about the HID devices
attached to the system, or NULL in the case of failure. Free
this linked list by calling hid_free_enumeration().
*/
@@ -191,7 +195,7 @@ extern "C" {
the Control Endpoint (Endpoint 0).
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
@param data The data to send, including the report number as
the first byte.
@param length The length in bytes of the data to send.
@@ -200,7 +204,7 @@ extern "C" {
This function returns the actual number of bytes written and
-1 on error.
*/
int HID_API_EXPORT HID_API_CALL hid_write(hid_device *device, const unsigned char *data, size_t length);
int HID_API_EXPORT HID_API_CALL hid_write(hid_device *dev, const unsigned char *data, size_t length);
/** @brief Read an Input report from a HID device with timeout.
@@ -209,7 +213,7 @@ extern "C" {
contain the Report number if the device uses numbered reports.
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
@param data A buffer to put the read data into.
@param length The number of bytes to read. For devices with
multiple reports, make sure to read an extra byte for
@@ -230,7 +234,7 @@ extern "C" {
contain the Report number if the device uses numbered reports.
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
@param data A buffer to put the read data into.
@param length The number of bytes to read. For devices with
multiple reports, make sure to read an extra byte for
@@ -241,7 +245,7 @@ extern "C" {
-1 on error. If no packet was available to be read and
the handle is in non-blocking mode, this function returns 0.
*/
int HID_API_EXPORT HID_API_CALL hid_read(hid_device *device, unsigned char *data, size_t length);
int HID_API_EXPORT HID_API_CALL hid_read(hid_device *dev, unsigned char *data, size_t length);
/** @brief Set the device handle to be non-blocking.
@@ -253,7 +257,7 @@ extern "C" {
Nonblocking can be turned on and off at any time.
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
@param nonblock enable or not the nonblocking reads
- 1 to enable nonblocking
- 0 to disable nonblocking.
@@ -261,7 +265,7 @@ extern "C" {
@returns
This function returns 0 on success and -1 on error.
*/
int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *device, int nonblock);
int HID_API_EXPORT HID_API_CALL hid_set_nonblocking(hid_device *dev, int nonblock);
/** @brief Send a Feature report to the device.
@@ -279,7 +283,7 @@ extern "C" {
in would be 17.
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
@param data The data to send, including the report number as
the first byte.
@param length The length in bytes of the data to send, including
@@ -289,7 +293,7 @@ extern "C" {
This function returns the actual number of bytes written and
-1 on error.
*/
int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *device, const unsigned char *data, size_t length);
int HID_API_EXPORT HID_API_CALL hid_send_feature_report(hid_device *dev, const unsigned char *data, size_t length);
/** @brief Get a feature report from a HID device.
@@ -300,7 +304,7 @@ extern "C" {
start in data[1].
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
@param data A buffer to put the read data into, including
the Report ID. Set the first byte of @p data[] to the
Report ID of the report to be read, or set it to zero
@@ -314,55 +318,55 @@ extern "C" {
one for the report ID (which is still in the first
byte), or -1 on error.
*/
int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *device, unsigned char *data, size_t length);
int HID_API_EXPORT HID_API_CALL hid_get_feature_report(hid_device *dev, unsigned char *data, size_t length);
/** @brief Close a HID device.
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
*/
void HID_API_EXPORT HID_API_CALL hid_close(hid_device *device);
void HID_API_EXPORT HID_API_CALL hid_close(hid_device *dev);
/** @brief Get The Manufacturer String from a HID device.
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
@param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t.
@returns
This function returns 0 on success and -1 on error.
*/
int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen);
int HID_API_EXPORT_CALL hid_get_manufacturer_string(hid_device *dev, wchar_t *string, size_t maxlen);
/** @brief Get The Product String from a HID device.
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
@param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t.
@returns
This function returns 0 on success and -1 on error.
*/
int HID_API_EXPORT_CALL hid_get_product_string(hid_device *device, wchar_t *string, size_t maxlen);
int HID_API_EXPORT_CALL hid_get_product_string(hid_device *dev, wchar_t *string, size_t maxlen);
/** @brief Get The Serial Number String from a HID device.
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
@param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t.
@returns
This function returns 0 on success and -1 on error.
*/
int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *device, wchar_t *string, size_t maxlen);
int HID_API_EXPORT_CALL hid_get_serial_number_string(hid_device *dev, wchar_t *string, size_t maxlen);
/** @brief Get a string from a HID device, based on its string index.
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
@param string_index The index of the string to get.
@param string A wide string buffer to put the data into.
@param maxlen The length of the buffer in multiples of wchar_t.
@@ -370,18 +374,18 @@ extern "C" {
@returns
This function returns 0 on success and -1 on error.
*/
int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *device, int string_index, wchar_t *string, size_t maxlen);
int HID_API_EXPORT_CALL hid_get_indexed_string(hid_device *dev, int string_index, wchar_t *string, size_t maxlen);
/** @brief Get a string describing the last error which occurred.
@ingroup API
@param device A device handle returned from hid_open().
@param dev A device handle returned from hid_open().
@returns
This function returns a string containing the last error
which occurred or NULL if none has occurred.
*/
HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *device);
HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *dev);
#ifdef __cplusplus
}
-32
View File
@@ -1,32 +0,0 @@
#pragma once
//Functions exported from DLL.
//For easy inclusion is user projects.
//Original InpOut32 function support
void _stdcall Out32(short PortAddress, short data);
short _stdcall Inp32(short PortAddress);
//My extra functions for making life easy
BOOL _stdcall IsInpOutDriverOpen(); //Returns TRUE if the InpOut driver was opened successfully
BOOL _stdcall IsXP64Bit(); //Returns TRUE if the OS is 64bit (x64) Windows.
//DLLPortIO function support
UCHAR _stdcall DlPortReadPortUchar (USHORT port);
void _stdcall DlPortWritePortUchar(USHORT port, UCHAR Value);
USHORT _stdcall DlPortReadPortUshort (USHORT port);
void _stdcall DlPortWritePortUshort(USHORT port, USHORT Value);
ULONG _stdcall DlPortReadPortUlong(ULONG port);
void _stdcall DlPortWritePortUlong(ULONG port, ULONG Value);
//WinIO function support (Untested and probably does NOT work - esp. on x64!)
PBYTE _stdcall MapPhysToLin(PBYTE pbPhysAddr, DWORD dwPhysSize, HANDLE *pPhysicalMemoryHandle);
BOOL _stdcall UnmapPhysicalMemory(HANDLE PhysicalMemoryHandle, PBYTE pbLinAddr);
BOOL _stdcall GetPhysLong(PBYTE pbPhysAddr, PDWORD pdwPhysVal);
BOOL _stdcall SetPhysLong(PBYTE pbPhysAddr, DWORD dwPhysVal);
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3 -1
View File
@@ -12,6 +12,8 @@
#include <Windows.h>
#include "inpout32.h"
#pragma comment(lib, "inpout32.lib")
/* Return negative errno on error. */
s32 i2c_smbus_i801::i801_access(u16 addr, char read_write, u8 command, int size, i2c_smbus_data *data)
{
@@ -478,4 +480,4 @@ int i2c_smbus_i801::i801_wait_intr()
s32 i2c_smbus_i801::i2c_smbus_xfer(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data)
{
return i801_access(addr, read_write, command, size, data);
}
}
+3 -1
View File
@@ -10,6 +10,8 @@
#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;
@@ -155,4 +157,4 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
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);
}
}
-102
View File
@@ -1,102 +0,0 @@
/*-----------------------------------------*\
| i2c_smbus_nvapi.cpp |
| |
| NVidia NvAPI I2C driver for Windows |
| |
| Adam Honse (CalcProgrammer1) 2/21/2020 |
\*-----------------------------------------*/
#include "i2c_smbus_nvapi.h"
i2c_smbus_nvapi::i2c_smbus_nvapi(NV_PHYSICAL_GPU_HANDLE handle)
{
this->handle = handle;
}
s32 i2c_smbus_nvapi::i2c_smbus_xfer(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data)
{
NV_STATUS ret;
unsigned int unknown = 0;
NV_I2C_INFO_V3 i2c_data;
uint8_t data_buf[8];
uint8_t chip_addr;
// Set up chip register address to command, one byte in length
chip_addr = command;
i2c_data.i2c_reg_address = &chip_addr;
i2c_data.reg_addr_size = 1;
// Set up data buffer, zero bytes in length
i2c_data.data = data_buf;
i2c_data.size = 0;
// Always use GPU port 1 - this is where RGB controllers are attached
i2c_data.is_ddc_port = 0;
i2c_data.port_id = 1;
i2c_data.is_port_id_set = 1;
// Use default speed
i2c_data.i2c_speed = 0xFFFF;
i2c_data.i2c_speed_khz = NV_I2C_SPEED::NVAPI_I2C_SPEED_DEFAULT;
// Load device address
i2c_data.i2c_dev_address = (addr << 1) | read_write;
switch (size)
{
case I2C_SMBUS_QUICK:
// This is not supported by the driver it seems
i2c_data.reg_addr_size = 0;
i2c_data.size = 0;
break;
case I2C_SMBUS_BYTE:
// One byte of data with no register address
i2c_data.reg_addr_size = 0;
data_buf[0] = command;
i2c_data.size = 1;
break;
case I2C_SMBUS_BYTE_DATA:
// One byte of data with one byte of register address
data_buf[0] = data->byte;
i2c_data.size = 1;
break;
case I2C_SMBUS_WORD_DATA:
// One word of data with one byte of register address
data_buf[0] = (data->word & 0x00ff);
data_buf[1] = (data->word & 0xff00) >> 8;
i2c_data.size = 2;
break;
// Not supported
case I2C_SMBUS_BLOCK_DATA:
return -1;
break;
default:
return -1;
}
// Perform read or write
if(read_write == I2C_SMBUS_WRITE)
{
ret = NvAPI_I2CWriteEx(handle, &i2c_data, &unknown);
}
else
{
ret = NvAPI_I2CReadEx(handle, &i2c_data, &unknown);
if(i2c_data.size == 1)
{
data->byte = i2c_data.data[0];
}
else
{
data->word = (i2c_data.data[0] | (i2c_data.data[1] << 8));
}
}
return(ret);
}
-24
View File
@@ -1,24 +0,0 @@
/*-----------------------------------------*\
| i2c_smbus_nvapi.h |
| |
| Definitions and types for NVidia NvAPI |
| I2C driver |
| |
| Adam Honse (CalcProgrammer1) 2/21/2020 |
\*-----------------------------------------*/
#include "i2c_smbus.h"
#include "nvapi.h"
#pragma once
class i2c_smbus_nvapi : public i2c_smbus_interface
{
public:
i2c_smbus_nvapi(NV_PHYSICAL_GPU_HANDLE handle);
private:
s32 i2c_smbus_xfer(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data);
NV_PHYSICAL_GPU_HANDLE handle;
};
+3 -1
View File
@@ -12,6 +12,8 @@
#include <Windows.h>
#include "inpout32.h"
#pragma comment(lib, "inpout32.lib")
//Logic adapted from piix4_transaction() in i2c-piix4.c
int i2c_smbus_piix4::piix4_transaction()
{
@@ -167,4 +169,4 @@ s32 i2c_smbus_piix4::piix4_access(u16 addr, char read_write, u8 command, int siz
s32 i2c_smbus_piix4::i2c_smbus_xfer(u8 addr, char read_write, u8 command, int size, i2c_smbus_data* data)
{
return piix4_access(addr, read_write, command, size, data);
}
}
-8
View File
@@ -19,9 +19,6 @@
extern std::vector<i2c_smbus_interface*> busses;
extern std::vector<RGBController*> rgb_controllers;
// See cli.cpp
extern int cli_main(int argc, char *argv[]);
/******************************************************************************************\
* *
* main *
@@ -32,11 +29,6 @@ extern int cli_main(int argc, char *argv[]);
int main(int argc, char* argv[])
{
if (argc > 1 && strcmp(argv[1], "--gui"))
{
return cli_main(argc, argv);
}
DetectRGBControllers();
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.7 KiB

+32 -1
View File
@@ -8,7 +8,38 @@ OpenRGBDeviceInfoPage::OpenRGBDeviceInfoPage(RGBController *dev, QWidget *parent
{
ui->setupUi(this);
ui->TypeValue->setText(device_type_to_str(dev->type).c_str());
switch(dev->type)
{
case DEVICE_TYPE_MOTHERBOARD:
ui->TypeValue->setText("Motherboard");
break;
case DEVICE_TYPE_DRAM:
ui->TypeValue->setText("DRAM");
break;
case DEVICE_TYPE_GPU:
ui->TypeValue->setText("GPU");
break;
case DEVICE_TYPE_COOLER:
ui->TypeValue->setText("Cooler");
break;
case DEVICE_TYPE_LEDSTRIP:
ui->TypeValue->setText("LED Strip");
break;
case DEVICE_TYPE_KEYBOARD:
ui->TypeValue->setText("Keyboard");
break;
case DEVICE_TYPE_MOUSE:
ui->TypeValue->setText("Mouse");
break;
case DEVICE_TYPE_MOUSEMAT:
ui->TypeValue->setText("Mousemat");
break;
case DEVICE_TYPE_HEADSET:
ui->TypeValue->setText("Headset");
break;
default:
ui->TypeValue->setText("Unknown");
}
ui->NameValue->setText(QString::fromStdString(dev->name));
ui->DescriptionValue->setText(QString::fromStdString(dev->description));
-14
View File
@@ -597,11 +597,6 @@ void Ui::OpenRGBDevicePage::UpdateMode()
| Change device mode |
\*-----------------------------------------------------*/
device->SetMode(current_mode);
if(device->modes[current_mode].color_mode == MODE_COLORS_PER_LED)
{
device->UpdateLEDs();
}
}
}
}
@@ -618,15 +613,6 @@ void Ui::OpenRGBDevicePage::SetDevice(unsigned char red, unsigned char green, un
on_SetDeviceButton_clicked();
}
void Ui::OpenRGBDevicePage::UpdateDevice()
{
ui->ModeBox->blockSignals(true);
ui->ModeBox->setCurrentIndex(device->active_mode);
ui->ModeBox->blockSignals(false);
UpdateModeUi();
UpdateMode();
}
void Ui::OpenRGBDevicePage::SetCustomMode()
{
device->SetCustomMode();
-1
View File
@@ -20,7 +20,6 @@ public:
void SetDevice(unsigned char red, unsigned char green, unsigned char blue);
void SetCustomMode();
void UpdateDevice();
void UpdateMode();
void UpdateModeUi();
+1 -384
View File
@@ -1,18 +1,9 @@
#include <fstream>
#include "OpenRGBDialog2.h"
#include "OpenRGBDevicePage.h"
#include "OpenRGBDeviceInfoPage.h"
#include "OpenRGBSoftwareInfoPage.h"
#include "OpenRGBSystemInfoPage.h"
#include "OpenRGBProfileSaveDialog.h"
#include "RGBController_Dummy.h"
#include <QLabel>
#include <QTabBar>
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
#include <experimental/filesystem>
#include <iostream>
namespace fs = std::experimental::filesystem;
using namespace Ui;
@@ -23,44 +14,6 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
QIcon logo(":OpenRGB.png");
setWindowIcon(logo);
/*---------------------------------------------------------*\
| Load profiles by looking for .orp files in current dir |
\*---------------------------------------------------------*/
for(const auto & entry : fs::directory_iterator("."))
{
std::string filename = entry.path().filename().string();
if(filename.find(".orp") != std::string::npos)
{
/*---------------------------------------------------------*\
| Open input file in binary mode |
\*---------------------------------------------------------*/
std::ifstream profile_file(filename, std::ios::in | std::ios::binary);
/*---------------------------------------------------------*\
| Read and verify file header |
\*---------------------------------------------------------*/
char header_string[16];
unsigned int header_version;
profile_file.read(header_string, 16);
profile_file.read((char *)&header_version, sizeof(unsigned int));
if(strcmp(header_string, "OPENRGB_PROFILE") == 0)
{
if(header_version == 1)
{
/*---------------------------------------------------------*\
| Add this profile to the list |
\*---------------------------------------------------------*/
ui->comboBox->addItem(filename.c_str());
}
}
profile_file.close();
}
}
/*-----------------------------------------------------*\
| Set up tray icon menu |
\*-----------------------------------------------------*/
@@ -72,18 +25,6 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
connect(actionShowHide, SIGNAL(triggered()), this, SLOT(on_ShowHide()));
trayIconMenu->addAction(actionShowHide);
QMenu* profileMenu = new QMenu("Profiles", this);
for(int profile_index = 0; profile_index < ui->comboBox->count(); profile_index++)
{
QAction* actionProfileSelected = new QAction(ui->comboBox->itemText(profile_index), this);
actionProfileSelected->setObjectName(ui->comboBox->itemText(profile_index));
connect(actionProfileSelected, SIGNAL(triggered()), this, SLOT(on_ProfileSelected()));
profileMenu->addAction(actionProfileSelected);
}
trayIconMenu->addMenu(profileMenu);
QMenu* quickColorsMenu = new QMenu("Quick Colors", this);
QAction* actionQuickRed = new QAction("Red", this);
@@ -259,25 +200,6 @@ OpenRGBDialog2::OpenRGBDialog2(std::vector<i2c_smbus_interface *>& bus, std::vec
SystemTabLabel->setGeometry(0, 0, 200, 20);
InformationTabBar->setTabButton(control.size(), QTabBar::LeftSide, SystemTabLabel);
OpenRGBSoftwareInfoPage *SoftInfoPage = new OpenRGBSoftwareInfoPage();
ui->InformationTabBar->addTab(SoftInfoPage, "");
/*-----------------------------------------------------*\
| Use Qt's HTML capabilities to display both icon and |
| text in the tab label. Choose icon based on device |
| type and append device name string. |
\*-----------------------------------------------------*/
QString SoftwareLabelString = "<html><table><tr><td width='30'><img src='";
SoftwareLabelString += ":/keyboard.svg";
SoftwareLabelString += "' height='15' width='15'></td><td>Software</td></tr></table></html>";
QLabel *SoftwareTabLabel = new QLabel();
SoftwareTabLabel->setText(SoftwareLabelString);
SoftwareTabLabel->setIndent(20);
SoftwareTabLabel->setGeometry(0, 0, 200, 20);
InformationTabBar->setTabButton(control.size() + 1, QTabBar::LeftSide, SoftwareTabLabel);
}
OpenRGBDialog2::~OpenRGBDialog2()
@@ -354,309 +276,4 @@ void OpenRGBDialog2::on_ShowHide()
{
hide();
}
}
void Ui::OpenRGBDialog2::on_ProfileSelected()
{
std::vector<RGBController*> temp_controllers;
unsigned int controller_size;
unsigned int controller_offset = 0;
std::string filename = QObject::sender()->objectName().toStdString();
/*---------------------------------------------------------*\
| Open input file in binary mode |
\*---------------------------------------------------------*/
std::ifstream controller_file(filename, std::ios::in | std::ios::binary);
/*---------------------------------------------------------*\
| Read and verify file header |
\*---------------------------------------------------------*/
char header_string[16];
unsigned int header_version;
controller_file.read(header_string, 16);
controller_file.read((char *)&header_version, sizeof(unsigned int));
controller_offset += 16 + sizeof(unsigned int);
controller_file.seekg(controller_offset);
if(strcmp(header_string, "OPENRGB_PROFILE") == 0)
{
if(header_version == 1)
{
/*---------------------------------------------------------*\
| Read controller data from file until EOF |
\*---------------------------------------------------------*/
while(!(controller_file.peek() == EOF))
{
controller_file.read((char *)&controller_size, sizeof(controller_size));
unsigned char *controller_data = new unsigned char[controller_size];
controller_file.seekg(controller_offset);
controller_file.read((char *)controller_data, controller_size);
RGBController_Dummy *temp_controller = new RGBController_Dummy();
temp_controller->ReadDeviceDescription(controller_data);
temp_controllers.push_back(temp_controller);
delete[] controller_data;
controller_offset += controller_size;
controller_file.seekg(controller_offset);
}
for(int controller_index = 0; controller_index < controllers.size(); controller_index++)
{
RGBController *temp_controller = temp_controllers[controller_index];
RGBController *controller_ptr = controllers[controller_index];
/*---------------------------------------------------------*\
| Test if saved controller data matches this controller |
\*---------------------------------------------------------*/
if((temp_controller->type == controller_ptr->type )
&&(temp_controller->name == controller_ptr->name )
&&(temp_controller->description == controller_ptr->description)
&&(temp_controller->version == controller_ptr->version )
&&(temp_controller->serial == controller_ptr->serial )
&&(temp_controller->location == controller_ptr->location ))
{
/*---------------------------------------------------------*\
| Update all modes |
\*---------------------------------------------------------*/
if(temp_controller->modes.size() == controller_ptr->modes.size())
{
for(int mode_index = 0; mode_index < temp_controller->modes.size(); mode_index++)
{
if((temp_controller->modes[mode_index].name == controller_ptr->modes[mode_index].name )
&&(temp_controller->modes[mode_index].value == controller_ptr->modes[mode_index].value )
&&(temp_controller->modes[mode_index].flags == controller_ptr->modes[mode_index].flags )
&&(temp_controller->modes[mode_index].speed_min == controller_ptr->modes[mode_index].speed_min )
&&(temp_controller->modes[mode_index].speed_max == controller_ptr->modes[mode_index].speed_max )
&&(temp_controller->modes[mode_index].colors_min == controller_ptr->modes[mode_index].colors_min)
&&(temp_controller->modes[mode_index].colors_max == controller_ptr->modes[mode_index].colors_max))
{
controller_ptr->modes[mode_index].speed = temp_controller->modes[mode_index].speed;
controller_ptr->modes[mode_index].direction = temp_controller->modes[mode_index].direction;
controller_ptr->modes[mode_index].color_mode = temp_controller->modes[mode_index].color_mode;
controller_ptr->modes[mode_index].colors.resize(temp_controller->modes[mode_index].colors.size());
for(int mode_color_index = 0; mode_color_index < temp_controller->modes[mode_index].colors.size(); mode_color_index++)
{
controller_ptr->modes[mode_index].colors[mode_color_index] = temp_controller->modes[mode_index].colors[mode_color_index];
}
}
}
controller_ptr->active_mode = temp_controller->active_mode;
}
/*---------------------------------------------------------*\
| Update all colors |
\*---------------------------------------------------------*/
if(temp_controller->colors.size() == controller_ptr->colors.size())
{
for(int color_index = 0; color_index < temp_controller->colors.size(); color_index++)
{
controller_ptr->colors[color_index] = temp_controller->colors[color_index];
}
}
}
}
}
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->UpdateDevice();
}
}
}
void Ui::OpenRGBDialog2::on_ButtonSaveProfile_clicked()
{
OpenRGBProfileSaveDialog dialog;
/*---------------------------------------------------------*\
| Open Profile Name Dialog |
\*---------------------------------------------------------*/
std::string profile_name = dialog.show();
/*---------------------------------------------------------*\
| If a name was entered, save the profile file |
\*---------------------------------------------------------*/
if(profile_name != "")
{
/*---------------------------------------------------------*\
| Extension .orp - OpenRgb Profile |
\*---------------------------------------------------------*/
std::string filename = profile_name + ".orp";
/*---------------------------------------------------------*\
| Open an output file in binary mode |
\*---------------------------------------------------------*/
std::ofstream controller_file(filename, std::ios::out | std::ios::binary);
/*---------------------------------------------------------*\
| Write header |
| 16 bytes - "OPENRGB_PROFILE" |
| 4 bytes - Version, unsigned int |
\*---------------------------------------------------------*/
unsigned int profile_version = 1;
controller_file.write("OPENRGB_PROFILE", 16);
controller_file.write((char *)&profile_version, sizeof(unsigned int));
/*---------------------------------------------------------*\
| Write controller data for each controller |
\*---------------------------------------------------------*/
for(int controller_index = 0; controller_index < controllers.size(); controller_index++)
{
unsigned char *controller_data = controllers[controller_index]->GetDeviceDescription();
unsigned int controller_size;
memcpy(&controller_size, controller_data, sizeof(controller_size));
controller_file.write((const char *)controller_data, controller_size);
}
/*---------------------------------------------------------*\
| Close the file when done |
\*---------------------------------------------------------*/
controller_file.close();
/*---------------------------------------------------------*\
| Add the new file to the profile list |
\*---------------------------------------------------------*/
ui->comboBox->addItem(filename.c_str());
}
}
void Ui::OpenRGBDialog2::on_ButtonLoadProfile_clicked()
{
std::vector<RGBController*> temp_controllers;
unsigned int controller_size;
unsigned int controller_offset = 0;
/*---------------------------------------------------------*\
| Get the profile filename from the profiles list |
\*---------------------------------------------------------*/
std::string filename = ui->comboBox->currentText().toStdString();
/*---------------------------------------------------------*\
| Open input file in binary mode |
\*---------------------------------------------------------*/
std::ifstream controller_file(filename, std::ios::in | std::ios::binary);
/*---------------------------------------------------------*\
| Read and verify file header |
\*---------------------------------------------------------*/
char header_string[16];
unsigned int header_version;
controller_file.read(header_string, 16);
controller_file.read((char *)&header_version, sizeof(unsigned int));
controller_offset += 16 + sizeof(unsigned int);
controller_file.seekg(controller_offset);
if(strcmp(header_string, "OPENRGB_PROFILE") == 0)
{
if(header_version == 1)
{
/*---------------------------------------------------------*\
| Read controller data from file until EOF |
\*---------------------------------------------------------*/
while(!(controller_file.peek() == EOF))
{
controller_file.read((char *)&controller_size, sizeof(controller_size));
unsigned char *controller_data = new unsigned char[controller_size];
controller_file.seekg(controller_offset);
controller_file.read((char *)controller_data, controller_size);
RGBController_Dummy *temp_controller = new RGBController_Dummy();
temp_controller->ReadDeviceDescription(controller_data);
temp_controllers.push_back(temp_controller);
delete[] controller_data;
controller_offset += controller_size;
controller_file.seekg(controller_offset);
}
for(int controller_index = 0; controller_index < controllers.size(); controller_index++)
{
RGBController *temp_controller = temp_controllers[controller_index];
RGBController *controller_ptr = controllers[controller_index];
/*---------------------------------------------------------*\
| Test if saved controller data matches this controller |
\*---------------------------------------------------------*/
if((temp_controller->type == controller_ptr->type )
&&(temp_controller->name == controller_ptr->name )
&&(temp_controller->description == controller_ptr->description)
&&(temp_controller->version == controller_ptr->version )
&&(temp_controller->serial == controller_ptr->serial )
&&(temp_controller->location == controller_ptr->location ))
{
/*---------------------------------------------------------*\
| Update all modes |
\*---------------------------------------------------------*/
if(temp_controller->modes.size() == controller_ptr->modes.size())
{
for(int mode_index = 0; mode_index < temp_controller->modes.size(); mode_index++)
{
if((temp_controller->modes[mode_index].name == controller_ptr->modes[mode_index].name )
&&(temp_controller->modes[mode_index].value == controller_ptr->modes[mode_index].value )
&&(temp_controller->modes[mode_index].flags == controller_ptr->modes[mode_index].flags )
&&(temp_controller->modes[mode_index].speed_min == controller_ptr->modes[mode_index].speed_min )
&&(temp_controller->modes[mode_index].speed_max == controller_ptr->modes[mode_index].speed_max )
&&(temp_controller->modes[mode_index].colors_min == controller_ptr->modes[mode_index].colors_min)
&&(temp_controller->modes[mode_index].colors_max == controller_ptr->modes[mode_index].colors_max))
{
controller_ptr->modes[mode_index].speed = temp_controller->modes[mode_index].speed;
controller_ptr->modes[mode_index].direction = temp_controller->modes[mode_index].direction;
controller_ptr->modes[mode_index].color_mode = temp_controller->modes[mode_index].color_mode;
controller_ptr->modes[mode_index].colors.resize(temp_controller->modes[mode_index].colors.size());
for(int mode_color_index = 0; mode_color_index < temp_controller->modes[mode_index].colors.size(); mode_color_index++)
{
controller_ptr->modes[mode_index].colors[mode_color_index] = temp_controller->modes[mode_index].colors[mode_color_index];
}
}
}
controller_ptr->active_mode = temp_controller->active_mode;
}
/*---------------------------------------------------------*\
| Update all colors |
\*---------------------------------------------------------*/
if(temp_controller->colors.size() == controller_ptr->colors.size())
{
for(int color_index = 0; color_index < temp_controller->colors.size(); color_index++)
{
controller_ptr->colors[color_index] = temp_controller->colors[color_index];
}
}
}
}
}
for(int device = 0; device < ui->DevicesTabBar->count(); device++)
{
qobject_cast<OpenRGBDevicePage *>(ui->DevicesTabBar->widget(device))->UpdateDevice();
}
}
}
}
-3
View File
@@ -48,9 +48,6 @@ private slots:
void on_QuickWhite();
void on_SetAllDevices(unsigned char red, unsigned char green, unsigned char blue);
void on_ShowHide();
void on_ProfileSelected();
void on_ButtonSaveProfile_clicked();
void on_ButtonLoadProfile_clicked();
};
#endif // OPENRGBDIALOG2_H
+2 -19
View File
@@ -15,24 +15,7 @@
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="1">
<widget class="QPushButton" name="ButtonLoadProfile">
<property name="text">
<string>Load Profile</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="ButtonSaveProfile">
<property name="text">
<string>Save Profile</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QComboBox" name="comboBox"/>
</item>
<item row="2" column="0" colspan="3">
<item row="0" column="0">
<widget class="QTabWidget" name="MainTabBar">
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
@@ -51,7 +34,7 @@
<string>Devices</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<item row="0" column="0">
<widget class="QTabWidget" name="DevicesTabBar">
<property name="tabPosition">
<enum>QTabWidget::West</enum>
-31
View File
@@ -1,31 +0,0 @@
#include "OpenRGBProfileSaveDialog.h"
#include "ui_OpenRGBProfileSaveDialog.h"
Ui::OpenRGBProfileSaveDialog::OpenRGBProfileSaveDialog(QWidget *parent) :
QDialog(parent), ui(new Ui::OpenRGBProfileSaveDialogUi)
{
ui->setupUi(this);
}
Ui::OpenRGBProfileSaveDialog::~OpenRGBProfileSaveDialog()
{
delete ui;
}
std::string Ui::OpenRGBProfileSaveDialog::show()
{
std::string return_string;
int result = this->exec();
if(result == QDialog::Rejected)
{
return_string = "";
}
else
{
return_string = ui->lineEdit->text().toStdString();
}
return(return_string);
}
-26
View File
@@ -1,26 +0,0 @@
#ifndef OPENRGBPROFILESAVEDIALOG_H
#define OPENRGBPROFILESAVEDIALOG_H
#include <QDialog>
#include "ui_OpenRGBProfileSaveDialog.h"
namespace Ui
{
class OpenRGBProfileSaveDialog;
}
class Ui::OpenRGBProfileSaveDialog : public QDialog
{
Q_OBJECT
public:
explicit OpenRGBProfileSaveDialog(QWidget *parent = nullptr);
~OpenRGBProfileSaveDialog();
std::string show();
private:
Ui::OpenRGBProfileSaveDialogUi *ui;
};
#endif // OPENRGBPROFILESAVEDIALOG_H
-91
View File
@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBProfileSaveDialogUi</class>
<widget class="QDialog" name="OpenRGBProfileSaveDialogUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>160</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>30</x>
<y>120</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLineEdit" name="lineEdit">
<property name="geometry">
<rect>
<x>30</x>
<y>70</y>
<width>341</width>
<height>20</height>
</rect>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>30</x>
<y>20</y>
<width>341</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>New Profile Name:</string>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>OpenRGBProfileSaveDialogUi</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>OpenRGBProfileSaveDialogUi</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
-21
View File
@@ -1,21 +0,0 @@
#include "OpenRGBSoftwareInfoPage.h"
using namespace Ui;
OpenRGBSoftwareInfoPage::OpenRGBSoftwareInfoPage(QWidget *parent) :
QFrame(parent),
ui(new Ui::OpenRGBSoftwareInfoPageUi)
{
ui->setupUi(this);
ui->VersionValue->setText(VERSION_STRING);
ui->BuildDateValue->setText(BUILDDATE_STRING);
ui->GitCommitIDValue->setText(GIT_COMMIT_ID);
ui->GitCommitDateValue->setText(GIT_COMMIT_DATE);
ui->GitBranchValue->setText(GIT_BRANCH);
}
OpenRGBSoftwareInfoPage::~OpenRGBSoftwareInfoPage()
{
delete ui;
}
-23
View File
@@ -1,23 +0,0 @@
#ifndef OPENRGBSOFTWAREINFOPAGE_H
#define OPENRGBSOFTWAREINFOPAGE_H
#include <QFrame>
#include "ui_OpenRGBSoftwareInfoPage.h"
namespace Ui {
class OpenRGBSoftwareInfoPage;
}
class Ui::OpenRGBSoftwareInfoPage : public QFrame
{
Q_OBJECT
public:
explicit OpenRGBSoftwareInfoPage(QWidget *parent = nullptr);
~OpenRGBSoftwareInfoPage();
private:
Ui::OpenRGBSoftwareInfoPageUi *ui;
};
#endif // OPENRGBSOFTWAREINFOPAGE_H
-91
View File
@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>OpenRGBSoftwareInfoPageUi</class>
<widget class="QFrame" name="OpenRGBSoftwareInfoPageUi">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>500</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="4" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="GitBranchLabel">
<property name="text">
<string>Git Branch:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="GitCommitIDValue">
<property name="text">
<string>Git Commit ID Value</string>
</property>
</widget>
</item>
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="VersionLabel">
<property name="text">
<string>Version:</string>
</property>
</widget>
</item>
<item row="1" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="BuildDateLabel">
<property name="text">
<string>Build Date:</string>
</property>
</widget>
</item>
<item row="3" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="GitCommitDateLabel">
<property name="text">
<string>Git Commit Date:</string>
</property>
</widget>
</item>
<item row="2" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="GitCommitIDLabel">
<property name="text">
<string>Git Commit ID:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="BuildDateValue">
<property name="text">
<string>Build Date Value</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="GitBranchValue">
<property name="text">
<string>Git Branch Value</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="GitCommitDateValue">
<property name="text">
<string>Git Commit Date Value</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="VersionValue">
<property name="text">
<string>Version Value</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+6 -5
View File
@@ -12,6 +12,7 @@
#include <Windows.h>
#include "inpout32.h"
#pragma comment(lib, "inpout32.lib")
#else
#include <unistd.h>
#include <sys/types.h>
@@ -36,9 +37,9 @@ void superio_enter(int ioreg)
#else
unsigned char temp = 0x87;
dev_port_fd = open("/dev/port", O_RDWR, "rw");
lseek(dev_port_fd, ioreg, SEEK_SET);
lseek(dev_port_fd, ioreg, SEEK_CUR);
write(dev_port_fd, &temp, 1);
lseek(dev_port_fd, ioreg, SEEK_SET);
lseek(dev_port_fd, ioreg, SEEK_CUR);
write(dev_port_fd, &temp, 1);
close(dev_port_fd);
#endif
@@ -60,7 +61,7 @@ void superio_outb(int ioreg, int reg, int val)
Out32(ioreg + 1, val);
#else
dev_port_fd = open("/dev/port", O_RDWR, "rw");
lseek(dev_port_fd, ioreg, SEEK_SET);
lseek(dev_port_fd, ioreg, SEEK_CUR);
write(dev_port_fd, &reg, 1);
write(dev_port_fd, &val, 1);
close(dev_port_fd);
@@ -84,10 +85,10 @@ int superio_inb(int ioreg, int reg)
#else
unsigned char temp;
dev_port_fd = open("/dev/port", O_RDWR, "rw");
lseek(dev_port_fd, ioreg, SEEK_SET);
lseek(dev_port_fd, ioreg, SEEK_CUR);
write(dev_port_fd, &reg, 1);
read(dev_port_fd, &temp, 1);
close(dev_port_fd);
return((int)temp);
#endif
}
}