Publish LumaOps source
This commit is contained in:
+157
@@ -0,0 +1,157 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AsusAuraHeadsetStandController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Aura headset stand |
|
||||
| |
|
||||
| Mola19 06 Apr 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "AsusAuraHeadsetStandController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
AuraHeadsetStandController::AuraHeadsetStandController(hid_device* dev_handle, const char* path, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
AuraHeadsetStandController::~AuraHeadsetStandController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string AuraHeadsetStandController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string AuraHeadsetStandController::GetName()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string AuraHeadsetStandController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
std::string AuraHeadsetStandController::GetVersion()
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = 0x12;
|
||||
usb_buf[0x02] = 0x00;
|
||||
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
unsigned char usb_buf_out[65];
|
||||
hid_read(dev, usb_buf_out, 65);
|
||||
|
||||
char version[5];
|
||||
snprintf(version, 5, "%04X", (usb_buf_out[6] << 8) | usb_buf_out[7]);
|
||||
return std::string(version);
|
||||
}
|
||||
|
||||
void AuraHeadsetStandController::UpdateLeds
|
||||
(
|
||||
std::vector<RGBColor> colors
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf_0[365];
|
||||
|
||||
memset(usb_buf_0, 0x00, sizeof(usb_buf_0));
|
||||
|
||||
usb_buf_0[0x00] = 0x00;
|
||||
usb_buf_0[0x01] = 0xC0;
|
||||
usb_buf_0[0x02] = 0x81;
|
||||
usb_buf_0[0x03] = 0x00;
|
||||
usb_buf_0[0x04] = 0x00;
|
||||
|
||||
for(unsigned int i = 0; i < 60; i += 4)
|
||||
{
|
||||
usb_buf_0[5 + i] = 0x00;
|
||||
usb_buf_0[6 + i] = RGBGetRValue(colors[i / 4]);
|
||||
usb_buf_0[7 + i] = RGBGetGValue(colors[i / 4]);
|
||||
usb_buf_0[8 + i] = RGBGetBValue(colors[i / 4]);
|
||||
}
|
||||
|
||||
hid_write(dev, usb_buf_0, 65);
|
||||
|
||||
unsigned char usb_buf_1[65];
|
||||
|
||||
memset(usb_buf_1, 0x00, sizeof(usb_buf_1));
|
||||
|
||||
usb_buf_1[0x00] = 0x00;
|
||||
usb_buf_1[0x01] = 0xC0;
|
||||
usb_buf_1[0x02] = 0x81;
|
||||
usb_buf_1[0x03] = 0x01;
|
||||
usb_buf_1[0x04] = 0x00;
|
||||
|
||||
for(unsigned int i = 0; i < 12; i += 4)
|
||||
{
|
||||
usb_buf_1[5 + i] = 0x00;
|
||||
usb_buf_1[6 + i] = RGBGetRValue(colors[(i / 4) + 15]);
|
||||
usb_buf_1[7 + i] = RGBGetGValue(colors[(i / 4) + 15]);
|
||||
usb_buf_1[8 + i] = RGBGetBValue(colors[(i / 4) + 15]);
|
||||
}
|
||||
|
||||
hid_write(dev, usb_buf_1, 65);
|
||||
}
|
||||
|
||||
void AuraHeadsetStandController::UpdateDevice
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu,
|
||||
unsigned char speed,
|
||||
unsigned char brightness
|
||||
)
|
||||
{
|
||||
unsigned char usb_buf[65];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
usb_buf[0x00] = 0x00;
|
||||
usb_buf[0x01] = 0x51;
|
||||
usb_buf[0x02] = 0x28;
|
||||
usb_buf[0x03] = 0x00;
|
||||
usb_buf[0x04] = 0x00;
|
||||
usb_buf[0x05] = mode;
|
||||
usb_buf[0x06] = speed;
|
||||
usb_buf[0x07] = brightness;
|
||||
usb_buf[0x08] = 0x00;
|
||||
usb_buf[0x09] = 0x00;
|
||||
usb_buf[0x0a] = red;
|
||||
usb_buf[0x0b] = grn;
|
||||
usb_buf[0x0c] = blu;
|
||||
hid_write(dev, usb_buf, 65);
|
||||
|
||||
}
|
||||
|
||||
void AuraHeadsetStandController::SaveMode()
|
||||
{
|
||||
unsigned char usb_save_buf[65];
|
||||
|
||||
memset(usb_save_buf, 0x00, sizeof(usb_save_buf));
|
||||
|
||||
usb_save_buf[0x00] = 0x00;
|
||||
usb_save_buf[0x01] = 0x50;
|
||||
usb_save_buf[0x02] = 0x55;
|
||||
|
||||
hid_write(dev, usb_save_buf, 65);
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AsusAuraHeadsetStandController.h |
|
||||
| |
|
||||
| Driver for ASUS Aura headset stand |
|
||||
| |
|
||||
| Mola19 06 Apr 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_HEADSET_STAND_ZONE_UNDERGLOW = 0,
|
||||
AURA_HEADSET_STAND_ZONE_LOGO = 1
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_HEADSET_STAND_MODE_DIRECT = 0,
|
||||
AURA_HEADSET_STAND_MODE_STATIC = 1,
|
||||
AURA_HEADSET_STAND_MODE_BREATHING = 2,
|
||||
AURA_HEADSET_STAND_MODE_STROBING = 3,
|
||||
AURA_HEADSET_STAND_MODE_COLOR_CYCLE = 4,
|
||||
AURA_HEADSET_STAND_MODE_RAINBOW = 5
|
||||
};
|
||||
|
||||
class AuraHeadsetStandController
|
||||
{
|
||||
public:
|
||||
AuraHeadsetStandController(hid_device* dev_handle, const char* path, std::string dev_name);
|
||||
virtual ~AuraHeadsetStandController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetName();
|
||||
std::string GetSerialString();
|
||||
std::string GetVersion();
|
||||
|
||||
void UpdateLeds
|
||||
(
|
||||
std::vector<RGBColor> colors
|
||||
);
|
||||
|
||||
void UpdateDevice
|
||||
(
|
||||
unsigned char mode,
|
||||
unsigned char red,
|
||||
unsigned char grn,
|
||||
unsigned char blu,
|
||||
unsigned char speed,
|
||||
unsigned char brightness
|
||||
);
|
||||
|
||||
void SaveMode();
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
std::string name;
|
||||
};
|
||||
+211
@@ -0,0 +1,211 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_AsusAuraHeadsetStand.cpp |
|
||||
| |
|
||||
| RGBController for ASUS Aura headset stand |
|
||||
| |
|
||||
| Mola19 06 Apr 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_AsusAuraHeadsetStand.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Asus Aura Headset Stand
|
||||
@category HeadsetStand
|
||||
@type USB
|
||||
@save :white_check_mark:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectAsusAuraUSBHeadsetStand
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_AuraHeadsetStand::RGBController_AuraHeadsetStand(AuraHeadsetStandController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetName();
|
||||
vendor = "ASUS";
|
||||
type = DEVICE_TYPE_HEADSET_STAND;
|
||||
description = "ASUS Aura Headset Stand Device";
|
||||
version = controller->GetVersion();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = AURA_HEADSET_STAND_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = AURA_HEADSET_STAND_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_MANUAL_SAVE;
|
||||
Static.brightness_min = AURA_HEADSETSTAND_BRIGHTNESS_MIN;
|
||||
Static.brightness_max = AURA_HEADSETSTAND_BRIGHTNESS_MAX;
|
||||
Static.brightness = AURA_HEADSETSTAND_BRIGHTNESS_DEFAULT;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = AURA_HEADSET_STAND_MODE_BREATHING;
|
||||
Breathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_MANUAL_SAVE;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.speed_min = AURA_HEADSETSTAND_SPEED_MIN;
|
||||
Breathing.speed_max = AURA_HEADSETSTAND_SPEED_MAX;
|
||||
Breathing.speed = AURA_HEADSETSTAND_SPEED_DEFAULT;
|
||||
Breathing.brightness_min = AURA_HEADSETSTAND_BRIGHTNESS_MIN;
|
||||
Breathing.brightness_max = AURA_HEADSETSTAND_BRIGHTNESS_MAX;
|
||||
Breathing.brightness = AURA_HEADSETSTAND_BRIGHTNESS_DEFAULT;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Strobing;
|
||||
Strobing.name = "Flashing";
|
||||
Strobing.value = AURA_HEADSET_STAND_MODE_STROBING;
|
||||
Strobing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_MANUAL_SAVE;
|
||||
Strobing.brightness_min = AURA_HEADSETSTAND_BRIGHTNESS_MIN;
|
||||
Strobing.brightness_max = AURA_HEADSETSTAND_BRIGHTNESS_MAX;
|
||||
Strobing.brightness = AURA_HEADSETSTAND_BRIGHTNESS_DEFAULT;
|
||||
Strobing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Strobing.colors_min = 1;
|
||||
Strobing.colors_max = 1;
|
||||
Strobing.colors.resize(1);
|
||||
modes.push_back(Strobing);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = AURA_HEADSET_STAND_MODE_COLOR_CYCLE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_MANUAL_SAVE;
|
||||
SpectrumCycle.speed_min = AURA_HEADSETSTAND_SPEED_MIN;
|
||||
SpectrumCycle.speed_max = AURA_HEADSETSTAND_SPEED_MAX;
|
||||
SpectrumCycle.speed = AURA_HEADSETSTAND_SPEED_DEFAULT;
|
||||
SpectrumCycle.brightness_min = AURA_HEADSETSTAND_BRIGHTNESS_MIN;
|
||||
SpectrumCycle.brightness_max = AURA_HEADSETSTAND_BRIGHTNESS_MAX;
|
||||
SpectrumCycle.brightness = AURA_HEADSETSTAND_BRIGHTNESS_DEFAULT;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode Rainbow;
|
||||
Rainbow.name = "Rainbow Wave";
|
||||
Rainbow.value = AURA_HEADSET_STAND_MODE_RAINBOW;
|
||||
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_MANUAL_SAVE;
|
||||
Rainbow.speed_min = AURA_HEADSETSTAND_SPEED_MIN;
|
||||
Rainbow.speed_max = AURA_HEADSETSTAND_SPEED_MAX;
|
||||
Rainbow.speed = AURA_HEADSETSTAND_SPEED_DEFAULT;
|
||||
Rainbow.brightness_min = AURA_HEADSETSTAND_BRIGHTNESS_MIN;
|
||||
Rainbow.brightness_max = AURA_HEADSETSTAND_BRIGHTNESS_MAX;
|
||||
Rainbow.brightness = AURA_HEADSETSTAND_BRIGHTNESS_DEFAULT;
|
||||
modes.push_back(Rainbow);
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_AuraHeadsetStand::~RGBController_AuraHeadsetStand()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_AuraHeadsetStand::SetupZones()
|
||||
{
|
||||
zone underglow_zone;
|
||||
|
||||
underglow_zone.name = "Underglow";
|
||||
underglow_zone.type = ZONE_TYPE_LINEAR;
|
||||
underglow_zone.leds_min = 17;
|
||||
underglow_zone.leds_max = 17;
|
||||
underglow_zone.leds_count = 17;
|
||||
underglow_zone.matrix_map = NULL;
|
||||
|
||||
zones.push_back(underglow_zone);
|
||||
|
||||
for(unsigned int i = 0; i < 17; i++)
|
||||
{
|
||||
led underglow_led;
|
||||
|
||||
underglow_led.name = "Underglow LED " + std::to_string(i);
|
||||
|
||||
leds.push_back(underglow_led);
|
||||
}
|
||||
|
||||
zone logo_zone;
|
||||
|
||||
logo_zone.name = "Logo";
|
||||
logo_zone.type = ZONE_TYPE_SINGLE;
|
||||
logo_zone.leds_min = 1;
|
||||
logo_zone.leds_max = 1;
|
||||
logo_zone.leds_count = 1;
|
||||
logo_zone.matrix_map = NULL;
|
||||
|
||||
zones.push_back(logo_zone);
|
||||
|
||||
led logo_led;
|
||||
|
||||
logo_led.name = "Logo LED";
|
||||
|
||||
leds.push_back(logo_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_AuraHeadsetStand::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_AuraHeadsetStand::DeviceUpdateLEDs()
|
||||
{
|
||||
controller->UpdateLeds(std::vector<RGBColor>(colors));
|
||||
}
|
||||
|
||||
void RGBController_AuraHeadsetStand::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AuraHeadsetStand::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_AuraHeadsetStand::DeviceUpdateMode()
|
||||
{
|
||||
unsigned char red = 0;
|
||||
unsigned char grn = 0;
|
||||
unsigned char blu = 0;
|
||||
switch(modes[active_mode].value)
|
||||
{
|
||||
case 0:
|
||||
controller->UpdateLeds(std::vector<RGBColor>(colors));
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
red = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
grn = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
blu = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
controller->UpdateDevice(modes[active_mode].value, red, grn, blu, modes[active_mode].speed, modes[active_mode].brightness);
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
controller->UpdateDevice(modes[active_mode].value, red, grn, blu, modes[active_mode].speed, modes[active_mode].brightness);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_AuraHeadsetStand::DeviceSaveMode()
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
controller->SaveMode();
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_AsusAuraHeadsetStand.h |
|
||||
| |
|
||||
| RGBController for ASUS Aura headset stand |
|
||||
| |
|
||||
| Mola19 06 Apr 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AsusAuraHeadsetStandController.h"
|
||||
|
||||
enum
|
||||
{
|
||||
AURA_HEADSETSTAND_BRIGHTNESS_MIN = 0,
|
||||
AURA_HEADSETSTAND_BRIGHTNESS_MAX = 4,
|
||||
AURA_HEADSETSTAND_BRIGHTNESS_DEFAULT = 4,
|
||||
AURA_HEADSETSTAND_SPEED_MIN = 0,
|
||||
AURA_HEADSETSTAND_SPEED_MAX = 255,
|
||||
AURA_HEADSETSTAND_SPEED_DEFAULT = 127,
|
||||
};
|
||||
|
||||
class RGBController_AuraHeadsetStand : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_AuraHeadsetStand(AuraHeadsetStandController* controller_ptr);
|
||||
~RGBController_AuraHeadsetStand();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
AuraHeadsetStandController* controller;
|
||||
};
|
||||
Reference in New Issue
Block a user