Initial driver for ROG Aura Core laptop keyboards. Untested.
parent
69539432b5
commit
9840f0a8b6
@ -0,0 +1,125 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraCoreController.cpp |
|
||||
| |
|
||||
| Driver for ASUS ROG Aura Core RGB |
|
||||
| lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/13/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "AuraCoreController.h"
|
||||
#include <cstring>
|
||||
|
||||
AuraCoreController::AuraCoreController(hid_device* dev_handle)
|
||||
{
|
||||
dev = dev_handle;
|
||||
}
|
||||
|
||||
AuraCoreController::~AuraCoreController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AuraCoreController::SendBrightness
|
||||
(
|
||||
unsigned char brightness
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5A;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_BRIGHTNESS;
|
||||
usb_buf[0x02] = 0xC5;
|
||||
usb_buf[0x03] = 0xC4;
|
||||
usb_buf[0x04] = brightness;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
|
||||
void AuraCoreController::SendUpdate
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5D;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_UPDATE;
|
||||
usb_buf[0x02] = zone;
|
||||
usb_buf[0x03] = mode;
|
||||
usb_buf[0x04] = red;
|
||||
usb_buf[0x05] = green;
|
||||
usb_buf[0x06] = blue;
|
||||
usb_buf[0x07] = speed;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
|
||||
void AuraCoreController::SendSet()
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5D;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_SET;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
|
||||
void AuraCoreController::SendApply()
|
||||
{
|
||||
unsigned char usb_buf[17];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up message packet |
|
||||
\*-----------------------------------------------------*/
|
||||
usb_buf[0x00] = 0x5D;
|
||||
usb_buf[0x01] = AURA_CORE_COMMAND_APPLY;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, 17);
|
||||
}
|
||||
@ -0,0 +1,76 @@
|
||||
/*-----------------------------------------*\
|
||||
| AuraCoreController.h |
|
||||
| |
|
||||
| Definitions and types for ASUS ROG Aura |
|
||||
| Core RGB lighting controller |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/13/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController.h"
|
||||
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_MODE_STATIC = 0, /* Static color mode */
|
||||
AURA_CORE_MODE_BREATHING = 1, /* Breathing effect mode */
|
||||
AURA_CORE_MODE_SPECTRUM_CYCLE = 2, /* Spectrum Cycle mode */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_COMMAND_UPDATE = 0xB3, /* Update mode and color */
|
||||
AURA_CORE_COMMAND_SET = 0xB5, /* Set command */
|
||||
AURA_CORE_COMMAND_APPLY = 0xB4, /* Apply command */
|
||||
AURA_CORE_COMMAND_BRIGHTNESS = 0xBA, /* Brightness command */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_ZONE_IDX_ALL = 0x00, /* Update all zones */
|
||||
AURA_CORE_ZONE_IDX_1 = 0x01, /* Update zone 1 */
|
||||
AURA_CORE_ZONE_IDX_2 = 0x02, /* Update zone 2 */
|
||||
AURA_CORE_ZONE_IDX_3 = 0x03, /* Update zone 3 */
|
||||
AURA_CORE_ZONE_IDX_4 = 0x04, /* Update zone 4 */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_CORE_SPEED_SLOW = 0xE1, /* Slowest speed */
|
||||
AURA_CORE_SPEED_NORMAL = 0xEB, /* Normal speed */
|
||||
AURA_CORE_SPEED_FAST = 0xF5, /* Fastest speed */
|
||||
};
|
||||
|
||||
class AuraCoreController
|
||||
{
|
||||
public:
|
||||
AuraCoreController(hid_device* dev_handle);
|
||||
~AuraCoreController();
|
||||
|
||||
void SendBrightness
|
||||
(
|
||||
unsigned char brightness
|
||||
);
|
||||
|
||||
void SendUpdate
|
||||
(
|
||||
unsigned char zone,
|
||||
unsigned char mode,
|
||||
unsigned char speed,
|
||||
unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue
|
||||
);
|
||||
|
||||
void SendSet();
|
||||
|
||||
void SendApply();
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
|
||||
};
|
||||
@ -0,0 +1,45 @@
|
||||
#include "AuraCoreController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_AuraCore.h"
|
||||
#include <vector>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define AURA_CORE_VID 0x0B05
|
||||
|
||||
#define NUM_PIDS 3
|
||||
static const unsigned short pid_table[] =
|
||||
{
|
||||
0x1854,
|
||||
0x1869,
|
||||
0x1866
|
||||
};
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectAuraCoreControllers *
|
||||
* *
|
||||
* Tests the USB address to see if an Asus ROG Aura Core controller exists there *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectAuraCoreControllers(std::vector<RGBController*>& rgb_controllers)
|
||||
{
|
||||
hid_device* dev;
|
||||
|
||||
//Look for Asus ROG Aura Core RGB controller
|
||||
hid_init();
|
||||
|
||||
for(int pid_idx = 0; pid_idx < NUM_PIDS; pid_idx++)
|
||||
{
|
||||
dev = hid_open(AURA_CORE_VID, pid_table[pid_idx], 0);
|
||||
|
||||
if( dev )
|
||||
{
|
||||
AuraCoreController* controller = new AuraCoreController(dev);
|
||||
|
||||
RGBController_AuraCore* rgb_controller = new RGBController_AuraCore(controller);
|
||||
|
||||
rgb_controllers.push_back(rgb_controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,105 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AuraCore.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for ROG Aura Core |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/17/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_AuraCore.h"
|
||||
|
||||
RGBController_AuraCore::RGBController_AuraCore(AuraCoreController* aura_ptr)
|
||||
{
|
||||
aura = aura_ptr;
|
||||
|
||||
name = "ASUS Aura Core";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "ASUS Aura Core Device";
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_CORE_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_CORE_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode ColorCycle;
|
||||
ColorCycle.name = "Color Cycle";
|
||||
ColorCycle.value = AURA_CORE_MODE_SPECTRUM_CYCLE;
|
||||
ColorCycle.flags = 0;
|
||||
ColorCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(ColorCycle);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::SetupZones()
|
||||
{
|
||||
zone Keyboard;
|
||||
Keyboard.name = "Keyboard";
|
||||
Keyboard.type = ZONE_TYPE_SINGLE;
|
||||
Keyboard.leds_min = 4;
|
||||
Keyboard.leds_max = 4;
|
||||
Keyboard.leds_count = 4;
|
||||
zones.push_back(Keyboard);
|
||||
|
||||
for(int led_idx = 0; led_idx < Keyboard.leds_count; led_idx++)
|
||||
{
|
||||
led KeyLED;
|
||||
KeyLED.name = "Keyboard LED ";
|
||||
KeyLED.name.append(std::to_string(led_idx + 1));
|
||||
leds.push_back(KeyLED);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::UpdateLEDs()
|
||||
{
|
||||
UpdateZoneLEDs(0);
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
for(int led_idx = 0; led_idx < leds.size(); led_idx++)
|
||||
{
|
||||
UpdateSingleLED(led_idx);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::UpdateSingleLED(int led)
|
||||
{
|
||||
aura->SendUpdate
|
||||
(
|
||||
led + 1,
|
||||
modes[active_mode].value,
|
||||
AURA_CORE_SPEED_NORMAL,
|
||||
RGBGetRValue(colors[led]),
|
||||
RGBGetGValue(colors[led]),
|
||||
RGBGetBValue(colors[led])
|
||||
);
|
||||
aura->SendSet();
|
||||
aura->SendApply();
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_AuraCore::UpdateMode()
|
||||
{
|
||||
UpdateLEDs();
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
/*-----------------------------------------*\
|
||||
| RGBController_AuraCore.h |
|
||||
| |
|
||||
| Generic RGB Interface for ROG Aura Core |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 4/17/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AuraCoreController.h"
|
||||
|
||||
class RGBController_AuraCore : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AuraCore(AuraCoreController* aura_ptr);
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void UpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void UpdateMode();
|
||||
|
||||
private:
|
||||
AuraCoreController* aura;
|
||||
|
||||
};
|
||||
Loading…
Reference in New Issue