From 87150072c88b78419b7785351b0b1de19f85ffa7 Mon Sep 17 00:00:00 2001 From: Martin Hartl Date: Wed, 7 Apr 2021 18:28:33 +0200 Subject: [PATCH] Asus Mainboard: Fix send color Byte 3 of the send color message is currently sending the channel id. Byte 4 is set to a hard coded 0xff and 0x00 for mainboard LEDs and addressable LEDs respectively. Apparently this is a 16 bit mask to select the colors to be updated instead. Commit amended for code style by Adam Honse --- .../AsusAuraMainboardController.cpp | 20 +++++++++++-------- .../AsusAuraMainboardController.h | 5 +++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Controllers/AsusAuraUSBController/AsusAuraMainboardController.cpp b/Controllers/AsusAuraUSBController/AsusAuraMainboardController.cpp index 92eb92fd6..4f7104b01 100644 --- a/Controllers/AsusAuraUSBController/AsusAuraMainboardController.cpp +++ b/Controllers/AsusAuraUSBController/AsusAuraMainboardController.cpp @@ -102,11 +102,15 @@ void AuraMainboardController::SetMode channel, start_led, device_info[channel].num_leds, - led_data, - device_info[channel].device_type == AuraDeviceType::FIXED + led_data ); } +unsigned short AuraMainboardController::GetMask(int start, int size) +{ + return(((1 << size) - 1) << start); +} + void AuraMainboardController::SendEffect ( unsigned char channel, @@ -141,11 +145,11 @@ void AuraMainboardController::SendColor unsigned char channel, unsigned char start_led, unsigned char led_count, - unsigned char* led_data, - bool fixed + unsigned char* led_data ) { - unsigned char usb_buf[65]; + unsigned short mask = GetMask(start_led, led_count); + unsigned char usb_buf[65]; /*-----------------------------------------------------*\ | Zero out buffer | @@ -157,8 +161,8 @@ void AuraMainboardController::SendColor \*-----------------------------------------------------*/ usb_buf[0x00] = 0xEC; usb_buf[0x01] = AURA_MAINBOARD_CONTROL_MODE_EFFECT_COLOR; - usb_buf[0x02] = channel; - usb_buf[0x03] = fixed ? 0xFF : 0x00; + usb_buf[0x02] = mask >> 8; + usb_buf[0x03] = mask & 0xff; usb_buf[0x04] = 0x00; /*-----------------------------------------------------*\ @@ -192,4 +196,4 @@ void AuraMainboardController::SendCommit() | Send packet | \*-----------------------------------------------------*/ hid_write(dev, usb_buf, 65); -} +} \ No newline at end of file diff --git a/Controllers/AsusAuraUSBController/AsusAuraMainboardController.h b/Controllers/AsusAuraUSBController/AsusAuraMainboardController.h index 19087433e..47788bcc3 100644 --- a/Controllers/AsusAuraUSBController/AsusAuraMainboardController.h +++ b/Controllers/AsusAuraUSBController/AsusAuraMainboardController.h @@ -47,6 +47,8 @@ public: private: unsigned int mode; + unsigned short GetMask(int start, int size); + void SendEffect ( unsigned char channel, @@ -58,8 +60,7 @@ private: unsigned char channel, unsigned char start_led, unsigned char led_count, - unsigned char* led_data, - bool fixed + unsigned char* led_data ); void SendCommit();