Compare commits

..
20 changed files with 578 additions and 366 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);
}
}
@@ -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, 0xFE);
}
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,42 +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);
printf("Super IO DevID: %04X", val);
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() */
+2 -2
View File
@@ -260,7 +260,7 @@ 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 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);
@@ -297,8 +297,8 @@ void DetectRGBControllers(void)
DetectPatriotViperControllers(busses, rgb_controllers);
DetectPolychromeControllers(busses, rgb_controllers);
DetectRGBFusionControllers(busses, rgb_controllers);
DetectMSIRGBControllers(rgb_controllers);
DetectAuraAddressableControllers(rgb_controllers);
DetectLEDStripControllers(rgb_controllers);
DetectHue2Controllers(rgb_controllers);
DetectHuePlusControllers(rgb_controllers);
+13 -30
View File
@@ -13,6 +13,7 @@ INCLUDEPATH += \
serial_port/ \
super_io/ \
Controllers/AMDWraithPrismController/ \
Controllers/AuraAddressableController/ \
Controllers/AuraController/ \
Controllers/CorsairController/ \
Controllers/CorsairCmdrProController/ \
@@ -26,7 +27,6 @@ INCLUDEPATH += \
Controllers/HyperXKeyboardController/ \
Controllers/LEDStripController/ \
Controllers/MSI3ZoneController/ \
Controllers/MSIRGBController/ \
Controllers/PatriotViperController/ \
Controllers/PolychromeController/ \
Controllers/PoseidonZRGBController/ \
@@ -53,6 +53,8 @@ SOURCES += \
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/CorsairController/CorsairController.cpp \
@@ -79,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 \
@@ -97,6 +97,7 @@ SOURCES += \
RGBController/E131ControllerDetect.cpp \
RGBController/RGBController_AMDWraithPrism.cpp \
RGBController/RGBController_Aura.cpp \
RGBController/RGBController_AuraAddressable.cpp \
RGBController/RGBController_Corsair.cpp \
RGBController/RGBController_CorsairCmdrPro.cpp \
RGBController/RGBController_CorsairKeyboard.cpp \
@@ -110,7 +111,6 @@ 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 \
@@ -132,6 +132,7 @@ HEADERS += \
super_io/super_io.h \
Controllers/AMDWraithPrismController/AMDWraithPrismController.h \
Controllers/AuraController/AuraController.h \
Controllers/AuraAddressableController/AuraAddressableController.h \
Controllers/CorsairController/CorsairController.h \
Controllers/CorsairCmdrProController/CorsairCmdrProController.h \
Controllers/CorsairKeyboardController/CorsairKeyboardController.h \
@@ -144,7 +145,6 @@ 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 \
@@ -154,6 +154,7 @@ HEADERS += \
RGBController/RGBController.h \
RGBController/RGBController_AMDWraithPrism.h \
RGBController/RGBController_Aura.h \
RGBController/RGBController_AuraAddressable.h \
RGBController/RGBController_Corsair.h \
RGBController/RGBController_CorsairCmdrPro.h \
RGBController/RGBController_CorsairNodePro.h \
@@ -166,7 +167,6 @@ 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 \
@@ -214,21 +214,11 @@ win32:HEADERS += \
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 \
-L"$$PWD/dependencies/hidapi-win/x64/" -lhidapi
}
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 \
-L"$$PWD/dependencies/hidapi-win/x86/" -lhidapi
}
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
@@ -241,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)
@@ -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;
};
-70
View File
@@ -1,70 +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;
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;
};
-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.
+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);
}
}
+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);
}
}
+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
}
}