Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e95334a216 | ||
|
|
57060577bf | ||
|
|
694ad92beb |
@@ -0,0 +1,117 @@
|
|||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| AirgooLustrousCommanderController.cpp |
|
||||||
|
| |
|
||||||
|
| Driver for Airgoo Lustrous Commander |
|
||||||
|
| |
|
||||||
|
| Zacahry Guinn 07 Feb 2022 |
|
||||||
|
| |
|
||||||
|
| This file is part of the OpenRGB project |
|
||||||
|
| SPDX-License-Identifier: GPL-2.0-only |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include "AirgooLustrousCommanderController.h"
|
||||||
|
|
||||||
|
AirgooLustrousCommanderController::AirgooLustrousCommanderController(hid_device* dev_handle, const char* path)
|
||||||
|
{
|
||||||
|
dev = dev_handle;
|
||||||
|
location = path;
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Initialize controller |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
InitController();
|
||||||
|
}
|
||||||
|
|
||||||
|
AirgooLustrousCommanderController::~AirgooLustrousCommanderController()
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Close HID device |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
hid_close(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AirgooLustrousCommanderController::InitController()
|
||||||
|
{
|
||||||
|
unsigned char usb_buf[AIRGOO_LUSTROUS_COMMANDER_PACKET_SIZE];
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Send initialization packet |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||||
|
|
||||||
|
usb_buf[0x00] = 0x00;
|
||||||
|
usb_buf[0x01] = 0x03;
|
||||||
|
usb_buf[0x02] = 0x55;
|
||||||
|
usb_buf[0x03] = 0xAA;
|
||||||
|
|
||||||
|
hid_write(dev, usb_buf, AIRGOO_LUSTROUS_COMMANDER_PACKET_SIZE);
|
||||||
|
|
||||||
|
//expecting the device to return AA 55 01
|
||||||
|
hid_read(dev, usb_buf, AIRGOO_LUSTROUS_COMMANDER_PACKET_SIZE);
|
||||||
|
|
||||||
|
usb_buf[0x00] = 0x00;
|
||||||
|
usb_buf[0x01] = 0x03;
|
||||||
|
usb_buf[0x02] = 0x55;
|
||||||
|
usb_buf[0x03] = 0xAA;
|
||||||
|
usb_buf[0x04] = 0x01;
|
||||||
|
|
||||||
|
//looks like the client software awknolleges? it returns a 0x01 in pos 4 of the buffer array
|
||||||
|
hid_write(dev, usb_buf, AIRGOO_LUSTROUS_COMMANDER_PACKET_SIZE);
|
||||||
|
|
||||||
|
//device will send aa 55 00 back and it seems that we should be ready to send commands at this point
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string AirgooLustrousCommanderController::GetLocationString()
|
||||||
|
{
|
||||||
|
return("HID: " + location);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AirgooLustrousCommanderController::UpdateDevice
|
||||||
|
(
|
||||||
|
unsigned char mode,
|
||||||
|
unsigned char red,
|
||||||
|
unsigned char grn,
|
||||||
|
unsigned char blu,
|
||||||
|
unsigned char speed
|
||||||
|
)
|
||||||
|
{
|
||||||
|
unsigned char usb_buf[65];
|
||||||
|
|
||||||
|
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||||
|
|
||||||
|
/*-----------------------------------------------------*\
|
||||||
|
| Set up message packet with leading 00 |
|
||||||
|
\*-----------------------------------------------------*/
|
||||||
|
usb_buf[0x00] = 0x00;
|
||||||
|
|
||||||
|
switch(mode)
|
||||||
|
{
|
||||||
|
case 1: //static
|
||||||
|
usb_buf[0x01] = 0x09; //number of bytes in package
|
||||||
|
usb_buf[0x02] = 0xFF;
|
||||||
|
usb_buf[0x03] = 0x00;
|
||||||
|
usb_buf[0x04] = 0xF0;
|
||||||
|
usb_buf[0x05] = red; //Red
|
||||||
|
usb_buf[0x06] = grn; //Green
|
||||||
|
usb_buf[0x07] = blu; //Blue
|
||||||
|
usb_buf[0x08] = 0x05;
|
||||||
|
usb_buf[0x09] = 0x05;
|
||||||
|
usb_buf[0x0A] = 0xFE;
|
||||||
|
break;
|
||||||
|
case 2://rainbow
|
||||||
|
usb_buf[0x01] = 0x05; //number of bytes in package
|
||||||
|
usb_buf[0x02] = 0xFF;
|
||||||
|
usb_buf[0x03] = 0x06;
|
||||||
|
usb_buf[0x04] = 0x01; //type like wheel or rolling
|
||||||
|
usb_buf[0x05] = speed; //speed
|
||||||
|
usb_buf[0x06] = 0xFE;
|
||||||
|
}
|
||||||
|
|
||||||
|
hid_write(dev, usb_buf, AIRGOO_LUSTROUS_COMMANDER_PACKET_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AirgooLustrousCommanderController::SetFanMode()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| AirgooLustrousCommanderController.h |
|
||||||
|
| |
|
||||||
|
| Driver for Airgoo Lustrous Commander |
|
||||||
|
| |
|
||||||
|
| Zacahry Guinn 07 Feb 2022 |
|
||||||
|
| |
|
||||||
|
| This file is part of the OpenRGB project |
|
||||||
|
| SPDX-License-Identifier: GPL-2.0-only |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <hidapi.h>
|
||||||
|
#include "RGBController.h"
|
||||||
|
|
||||||
|
#define AIRGOO_LUSTROUS_COMMANDER_PACKET_SIZE 65
|
||||||
|
#define AIRGOO_LUSTROUS_COMMANDER_NUM_RGB_CHANNELS 2
|
||||||
|
#define AIRGOO_LUSTROUS_COMMANDER_NUM_FAN_CHANNELS 4
|
||||||
|
|
||||||
|
class AirgooLustrousCommanderController
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AirgooLustrousCommanderController(hid_device* dev_handle, const char* path);
|
||||||
|
~AirgooLustrousCommanderController();
|
||||||
|
|
||||||
|
std::string GetLocationString();
|
||||||
|
|
||||||
|
void SetFanMode();
|
||||||
|
void UpdateDevice
|
||||||
|
(
|
||||||
|
unsigned char mode,
|
||||||
|
unsigned char red,
|
||||||
|
unsigned char grn,
|
||||||
|
unsigned char blu,
|
||||||
|
unsigned char speed
|
||||||
|
);
|
||||||
|
|
||||||
|
private:
|
||||||
|
hid_device* dev;
|
||||||
|
std::string location;
|
||||||
|
|
||||||
|
void InitController();
|
||||||
|
};
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| AirgooLustrousCommanderControllerDetect.cpp |
|
||||||
|
| |
|
||||||
|
| Detector for Airgoo Lustrous Commander |
|
||||||
|
| |
|
||||||
|
| Zacahry Guinn 07 Feb 2022 |
|
||||||
|
| |
|
||||||
|
| This file is part of the OpenRGB project |
|
||||||
|
| SPDX-License-Identifier: GPL-2.0-only |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <hidapi.h>
|
||||||
|
#include "Detector.h"
|
||||||
|
#include "AirgooLustrousCommanderController.h"
|
||||||
|
#include "RGBController.h"
|
||||||
|
#include "RGBController_AirgooLustrousCommander.h"
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Airgoo vendor ID |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
#define AIRGOO_VID 0x1A86
|
||||||
|
|
||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| Lustrous Commander product IDs |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
#define AIRGOO_LUSTROUS_COMMANDER_PID 0xE6E0
|
||||||
|
|
||||||
|
/******************************************************************************************\
|
||||||
|
* *
|
||||||
|
* DetectAirgooCommanderControllers *
|
||||||
|
* *
|
||||||
|
* Tests the USB address to see if a Airgoo RGB controller exists there. *
|
||||||
|
* *
|
||||||
|
\******************************************************************************************/
|
||||||
|
|
||||||
|
void DetectAirgooLustrousCommanderHIDControllers(hid_device_info* info, const std::string& name)
|
||||||
|
{
|
||||||
|
hid_device* dev = hid_open_path(info->path);
|
||||||
|
|
||||||
|
if(dev)
|
||||||
|
{
|
||||||
|
AirgooLustrousCommanderController* controller = new AirgooLustrousCommanderController(dev, info->path);
|
||||||
|
RGBController_AirgooLustrousCommander* rgb_controller = new RGBController_AirgooLustrousCommander(controller);
|
||||||
|
rgb_controller->name = name;
|
||||||
|
|
||||||
|
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
REGISTER_HID_DETECTOR("Airgoo Lustrous Commander", DetectAirgooLustrousCommanderHIDControllers, AIRGOO_VID, AIRGOO_LUSTROUS_COMMANDER_PID);
|
||||||
+192
@@ -0,0 +1,192 @@
|
|||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| RGBController_AirgooLustrousCommander.cpp |
|
||||||
|
| |
|
||||||
|
| RGBController for Airgoo Lustrous Commander |
|
||||||
|
| |
|
||||||
|
| Zacahry Guinn 07 Feb 2022 |
|
||||||
|
| |
|
||||||
|
| This file is part of the OpenRGB project |
|
||||||
|
| SPDX-License-Identifier: GPL-2.0-only |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "RGBController_AirgooLustrousCommander.h"
|
||||||
|
|
||||||
|
RGBController_AirgooLustrousCommander::RGBController_AirgooLustrousCommander(AirgooLustrousCommanderController* controller_ptr)
|
||||||
|
{
|
||||||
|
controller = controller_ptr;
|
||||||
|
|
||||||
|
vendor = "Airgoo";
|
||||||
|
description = "Lustrous Commander";
|
||||||
|
type = DEVICE_TYPE_LEDSTRIP;
|
||||||
|
location = controller->GetLocationString();
|
||||||
|
|
||||||
|
mode Static;
|
||||||
|
Static.name = "Static";
|
||||||
|
Static.value = 1;
|
||||||
|
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 Shift;
|
||||||
|
// Shift.name = "Shift";
|
||||||
|
// Shift.value = 1;
|
||||||
|
// Shift.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_SPEED;
|
||||||
|
// Shift.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||||
|
// Shift.colors_min = 1;
|
||||||
|
// Shift.colors_max = 16;
|
||||||
|
// Shift.colors.resize(Shift.colors_max);
|
||||||
|
// Shift.speed_min = 0;
|
||||||
|
// Shift.speed_max = 255;
|
||||||
|
// Shift.speed = 05;
|
||||||
|
// Shift.brightness_min = 100;
|
||||||
|
// Shift.brightness_max = 0;
|
||||||
|
// Shift.brightness = 0;
|
||||||
|
// modes.push_back(Shift);
|
||||||
|
|
||||||
|
// mode Pulse;
|
||||||
|
// Pulse.name = "Pulse";
|
||||||
|
// Pulse.value = 2;
|
||||||
|
// Pulse.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||||
|
// Pulse.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||||
|
// modes.push_back(Pulse);
|
||||||
|
|
||||||
|
// mode Gradual;
|
||||||
|
// Gradual.name = "Gradual";
|
||||||
|
// Gradual.value = 3;
|
||||||
|
// Gradual.flags = MODE_FLAstd::cout << "@@@@@@@Init Contoller@@@@@@@" << std::endl;ORS_MODE_SPECIFIC;
|
||||||
|
// modes.push_back(Gradual);
|
||||||
|
|
||||||
|
// mode StarLight;
|
||||||
|
// StarLight.name = "StarLight";
|
||||||
|
// StarLight.value = 4;
|
||||||
|
// StarLight.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||||
|
// StarLight.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||||
|
// modes.push_back(StarLight);
|
||||||
|
|
||||||
|
mode Rainbow;
|
||||||
|
Rainbow.name = "Rainbow";
|
||||||
|
Rainbow.value = 2;
|
||||||
|
Rainbow.flags = MODE_FLAG_HAS_SPEED;
|
||||||
|
Rainbow.speed_min = 1;
|
||||||
|
Rainbow.speed_max = 255;
|
||||||
|
Rainbow.speed = 50;
|
||||||
|
Rainbow.color_mode = MODE_COLORS_NONE;
|
||||||
|
modes.push_back(Rainbow);
|
||||||
|
|
||||||
|
// mode ColorWave;
|
||||||
|
// ColorWave.name = "Color Wave";
|
||||||
|
// ColorWave.value = 6;
|
||||||
|
// ColorWave.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||||
|
// ColorWave.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||||
|
// modes.push_back(ColorWave);
|
||||||
|
|
||||||
|
// mode ColorPulse;
|
||||||
|
// ColorPulse.name = "Color Pulse";
|
||||||
|
// ColorPulse.value = 7;
|
||||||
|
// ColorPulse.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||||
|
// ColorPulse.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||||
|
// modes.push_back(ColorPulse);
|
||||||
|
|
||||||
|
// mode ColorMeteor;
|
||||||
|
// ColorMeteor.name = "Color Meteor";
|
||||||
|
// ColorMeteor.value = 8;
|
||||||
|
// ColorMeteor.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||||
|
// ColorMeteor.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||||
|
// modes.push_back(ColorMeteor);
|
||||||
|
|
||||||
|
SetupZones();
|
||||||
|
}
|
||||||
|
|
||||||
|
RGBController_AirgooLustrousCommander::~RGBController_AirgooLustrousCommander()
|
||||||
|
{
|
||||||
|
delete controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBController_AirgooLustrousCommander::SetupZones()
|
||||||
|
{
|
||||||
|
std::atomic<bool> first_run;
|
||||||
|
first_run = 0;
|
||||||
|
|
||||||
|
if(zones.size() == 0)
|
||||||
|
{
|
||||||
|
first_run = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
zones.resize(3);
|
||||||
|
|
||||||
|
for(unsigned int i = 1; i < (AIRGOO_LUSTROUS_COMMANDER_NUM_RGB_CHANNELS + 1); i++)
|
||||||
|
{
|
||||||
|
zones[i].name = "RGB Port " + std::to_string(i);
|
||||||
|
zones[i].type = ZONE_TYPE_LINEAR;
|
||||||
|
zones[i].leds_min = 0;
|
||||||
|
zones[i].leds_max = 34;
|
||||||
|
|
||||||
|
if(first_run)
|
||||||
|
{
|
||||||
|
zones[i].leds_count = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
leds.clear();
|
||||||
|
colors.clear();
|
||||||
|
|
||||||
|
for(unsigned int zone_idx = 0; zone_idx < zones.size(); zone_idx++)
|
||||||
|
{
|
||||||
|
for (unsigned int led_idx = 0; led_idx < zones[zone_idx].leds_count; led_idx++)
|
||||||
|
{
|
||||||
|
led new_led;
|
||||||
|
new_led.name = zones[zone_idx].name + " LED " + std::to_string(led_idx+1);
|
||||||
|
|
||||||
|
leds.push_back(new_led);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetupColors();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBController_AirgooLustrousCommander::ResizeZone(int zone, int new_size)
|
||||||
|
{
|
||||||
|
if((size_t) zone >= zones.size())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(((unsigned int)new_size >= zones[zone].leds_min) && ((unsigned int)new_size <= zones[zone].leds_max))
|
||||||
|
{
|
||||||
|
zones[zone].leds_count = new_size;
|
||||||
|
|
||||||
|
SetupZones();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBController_AirgooLustrousCommander::DeviceUpdateLEDs()
|
||||||
|
{
|
||||||
|
DeviceUpdateMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBController_AirgooLustrousCommander::UpdateZoneLEDs(int /*zone*/)
|
||||||
|
{
|
||||||
|
DeviceUpdateLEDs();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBController_AirgooLustrousCommander::UpdateSingleLED(int /*led*/)
|
||||||
|
{
|
||||||
|
DeviceUpdateLEDs();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RGBController_AirgooLustrousCommander::DeviceUpdateMode()
|
||||||
|
{
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
controller->UpdateDevice(modes[active_mode].value, red, grn, blu, modes[active_mode].speed);
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*---------------------------------------------------------*\
|
||||||
|
| RGBController_AirgooLustrousCommander.cpp |
|
||||||
|
| |
|
||||||
|
| RGBController for Airgoo Lustrous Commander |
|
||||||
|
| |
|
||||||
|
| Zacahry Guinn 07 Feb 2022 |
|
||||||
|
| |
|
||||||
|
| This file is part of the OpenRGB project |
|
||||||
|
| SPDX-License-Identifier: GPL-2.0-only |
|
||||||
|
\*---------------------------------------------------------*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "RGBController.h"
|
||||||
|
#include "AirgooLustrousCommanderController.h"
|
||||||
|
|
||||||
|
class RGBController_AirgooLustrousCommander : public RGBController
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RGBController_AirgooLustrousCommander(AirgooLustrousCommanderController* controller_ptr);
|
||||||
|
~RGBController_AirgooLustrousCommander();
|
||||||
|
|
||||||
|
void SetupZones();
|
||||||
|
void ResizeZone(int zone, int new_size);
|
||||||
|
|
||||||
|
void DeviceUpdateLEDs();
|
||||||
|
void UpdateZoneLEDs(int zone);
|
||||||
|
void UpdateSingleLED(int led);
|
||||||
|
|
||||||
|
void DeviceUpdateMode();
|
||||||
|
|
||||||
|
private:
|
||||||
|
AirgooLustrousCommanderController* controller;
|
||||||
|
std::vector<int> fanleds{0};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user