From 9840f0a8b6fd14481e8ed76aa1b1ca57838ff245 Mon Sep 17 00:00:00 2001 From: Adam Honse Date: Sat, 18 Apr 2020 00:24:35 -0500 Subject: [PATCH] Initial driver for ROG Aura Core laptop keyboards. Untested. --- .../AuraCoreController/AuraCoreController.cpp | 125 ++++++++++++++++++ .../AuraCoreController/AuraCoreController.h | 76 +++++++++++ .../AuraCoreControllerDetect.cpp | 45 +++++++ OpenRGB.cpp | 2 + OpenRGB.pro | 6 + RGBController/RGBController_AuraCore.cpp | 105 +++++++++++++++ RGBController/RGBController_AuraCore.h | 33 +++++ 7 files changed, 392 insertions(+) create mode 100644 Controllers/AuraCoreController/AuraCoreController.cpp create mode 100644 Controllers/AuraCoreController/AuraCoreController.h create mode 100644 Controllers/AuraCoreController/AuraCoreControllerDetect.cpp create mode 100644 RGBController/RGBController_AuraCore.cpp create mode 100644 RGBController/RGBController_AuraCore.h diff --git a/Controllers/AuraCoreController/AuraCoreController.cpp b/Controllers/AuraCoreController/AuraCoreController.cpp new file mode 100644 index 000000000..b37d19675 --- /dev/null +++ b/Controllers/AuraCoreController/AuraCoreController.cpp @@ -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 + +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); +} diff --git a/Controllers/AuraCoreController/AuraCoreController.h b/Controllers/AuraCoreController/AuraCoreController.h new file mode 100644 index 000000000..d71ddaff2 --- /dev/null +++ b/Controllers/AuraCoreController/AuraCoreController.h @@ -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 +#include + +#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; + +}; diff --git a/Controllers/AuraCoreController/AuraCoreControllerDetect.cpp b/Controllers/AuraCoreController/AuraCoreControllerDetect.cpp new file mode 100644 index 000000000..92200fa92 --- /dev/null +++ b/Controllers/AuraCoreController/AuraCoreControllerDetect.cpp @@ -0,0 +1,45 @@ +#include "AuraCoreController.h" +#include "RGBController.h" +#include "RGBController_AuraCore.h" +#include +#include + +#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& 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); + } + } +} diff --git a/OpenRGB.cpp b/OpenRGB.cpp index 449bd3e6e..344ea13aa 100644 --- a/OpenRGB.cpp +++ b/OpenRGB.cpp @@ -296,6 +296,7 @@ void DetectRGBFusionGPUControllers(std::vector& busses, st void DetectMSIMysticLightControllers(std::vector &rgb_controllers); void DetectMSIRGBControllers(std::vector &rgb_controllers); void DetectAuraAddressableControllers(std::vector &rgb_controllers); +void DetectAuraCoreControllers(std::vector &rgb_controllers); void DetectLEDStripControllers(std::vector &rgb_controllers); void DetectHue2Controllers(std::vector &rgb_controllers); void DetectHuePlusControllers(std::vector &rgb_controllers); @@ -340,6 +341,7 @@ void DetectRGBControllers(void) DetectMSIRGBControllers(rgb_controllers); DetectAuraAddressableControllers(rgb_controllers); + DetectAuraCoreControllers(rgb_controllers); DetectLEDStripControllers(rgb_controllers); DetectHue2Controllers(rgb_controllers); DetectHuePlusControllers(rgb_controllers); diff --git a/OpenRGB.pro b/OpenRGB.pro index 5379ab75a..106d58241 100644 --- a/OpenRGB.pro +++ b/OpenRGB.pro @@ -32,6 +32,7 @@ INCLUDEPATH += \ super_io/ \ Controllers/AMDWraithPrismController/ \ Controllers/AuraAddressableController/ \ + Controllers/AuraCoreController/ \ Controllers/AuraGPUController/ \ Controllers/AuraSMBusController/ \ Controllers/CorsairPeripheralController/ \ @@ -85,6 +86,8 @@ SOURCES += \ Controllers/AMDWraithPrismController/AMDWraithPrismControllerDetect.cpp \ Controllers/AuraAddressableController/AuraAddressableController.cpp \ Controllers/AuraAddressableController/AuraAddressableControllerDetect.cpp \ + Controllers/AuraCoreController/AuraCoreController.cpp \ + Controllers/AuraCoreController/AuraCoreControllerDetect.cpp \ Controllers/AuraGPUController/AuraGPUController.cpp \ Controllers/AuraGPUController/AuraGPUControllerDetect.cpp \ Controllers/AuraSMBusController/AuraSMBusController.cpp \ @@ -138,6 +141,7 @@ SOURCES += \ RGBController/E131ControllerDetect.cpp \ RGBController/RGBController_AMDWraithPrism.cpp \ RGBController/RGBController_AuraAddressable.cpp \ + RGBController/RGBController_AuraCore.cpp \ RGBController/RGBController_AuraGPU.cpp \ RGBController/RGBController_AuraSMBus.cpp \ RGBController/RGBController_CorsairLightingNode.cpp \ @@ -185,6 +189,7 @@ HEADERS += \ super_io/super_io.h \ Controllers/AMDWraithPrismController/AMDWraithPrismController.h \ Controllers/AuraAddressableController/AuraAddressableController.h \ + Controllers/AuraCoreController/AuraCoreController.h \ Controllers/AuraGPUController/AuraGPUController.h \ Controllers/AuraSMBusController/AuraSMBusController.h \ Controllers/CorsairLightingNodeController/CorsairLightingNodeController.h \ @@ -212,6 +217,7 @@ HEADERS += \ RGBController/RGBController.h \ RGBController/RGBController_AMDWraithPrism.h \ RGBController/RGBController_AuraAddressable.h \ + RGBController/RGBController_AuraCore.h \ RGBController/RGBController_AuraGPU.h \ RGBController/RGBController_AuraSMBus.h \ RGBController/RGBController_CorsairLightingNode.h \ diff --git a/RGBController/RGBController_AuraCore.cpp b/RGBController/RGBController_AuraCore.cpp new file mode 100644 index 000000000..1ba3498eb --- /dev/null +++ b/RGBController/RGBController_AuraCore.cpp @@ -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(); +} diff --git a/RGBController/RGBController_AuraCore.h b/RGBController/RGBController_AuraCore.h new file mode 100644 index 000000000..a602b36e2 --- /dev/null +++ b/RGBController/RGBController_AuraCore.h @@ -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; + +};