Publish LumaOps source
This commit is contained in:
@@ -0,0 +1,196 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_WushiL50USB.cpp |
|
||||
| |
|
||||
| RGBController for Wushi L50 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_WushiL50USB.h"
|
||||
|
||||
RGBController_WushiL50USB::RGBController_WushiL50USB(WushiL50USBController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->getName();
|
||||
type = DEVICE_TYPE_ACCESSORY;
|
||||
description = "Wushi L50 device";
|
||||
vendor = "Wushi";
|
||||
location = controller->getLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = WUSHI_L50_EFFECT_STATIC;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.brightness_min = 1;
|
||||
Direct.brightness_max = 2;
|
||||
Direct.brightness = 2;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Breath;
|
||||
Breath.name = "Breathing";
|
||||
Breath.value = WUSHI_L50_EFFECT_BREATH;
|
||||
Breath.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Breath.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breath.speed_min = 1;
|
||||
Breath.speed_max = 4;
|
||||
Breath.speed = 3;
|
||||
Breath.colors_min = 1;
|
||||
Breath.colors_max = 1;
|
||||
Breath.colors.resize(1);
|
||||
modes.push_back(Breath);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Rainbow Wave";
|
||||
Wave.value = WUSHI_L50_EFFECT_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_SPEED;
|
||||
Wave.color_mode = MODE_COLORS_RANDOM;
|
||||
Wave.speed_min = 1;
|
||||
Wave.speed_max = 4;
|
||||
Wave.speed = 3;
|
||||
modes.push_back(Wave);
|
||||
|
||||
mode Smooth;
|
||||
Smooth.name = "Spectrum Cycle";
|
||||
Smooth.value = WUSHI_L50_EFFECT_SMOOTH;
|
||||
Smooth.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Smooth.color_mode = MODE_COLORS_RANDOM;
|
||||
Smooth.speed_min = 1;
|
||||
Smooth.speed_max = 4;
|
||||
Smooth.speed = 3;
|
||||
modes.push_back(Smooth);
|
||||
|
||||
mode Race;
|
||||
Race.name = "Race Cycle";
|
||||
Race.value = WUSHI_L50_EFFECT_RACE;
|
||||
Race.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_SPEED;
|
||||
Race.color_mode = MODE_COLORS_RANDOM;
|
||||
Race.speed_min = 1;
|
||||
Race.speed_max = 4;
|
||||
Race.speed = 3;
|
||||
modes.push_back(Race);
|
||||
|
||||
mode Stack;
|
||||
Stack.name = "Stacking";
|
||||
Stack.value = WUSHI_L50_EFFECT_STACK;
|
||||
Stack.flags = MODE_FLAG_HAS_RANDOM_COLOR | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
|
||||
Stack.color_mode = MODE_COLORS_RANDOM;
|
||||
Stack.brightness_min = 1;
|
||||
Stack.brightness_max = 2;
|
||||
Stack.brightness = 2;
|
||||
Stack.speed_min = 1;
|
||||
Stack.speed_max = 4;
|
||||
Stack.speed = 3;
|
||||
modes.push_back(Stack);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_WushiL50USB::~RGBController_WushiL50USB()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_WushiL50USB::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = "Dock";
|
||||
new_zone.type = ZONE_TYPE_SINGLE;
|
||||
new_zone.leds_count = WUSHI_L50_NUM_LEDS;
|
||||
new_zone.leds_max = new_zone.leds_count;
|
||||
new_zone.leds_min = new_zone.leds_count;
|
||||
new_zone.matrix_map = NULL;
|
||||
|
||||
zones.push_back(new_zone);
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < WUSHI_L50_NUM_LEDS; led_idx++ )
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = "Dock Zone ";
|
||||
new_led.name.append(std::to_string(led_idx + 1));
|
||||
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_WushiL50USB::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_WushiL50USB::DeviceUpdateLEDs()
|
||||
{
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
state.SetColors(colors);
|
||||
}
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
state.zone0_rgb[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
state.zone0_rgb[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
state.zone0_rgb[2] = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
controller->setMode(&state);
|
||||
}
|
||||
|
||||
void RGBController_WushiL50USB::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_WushiL50USB::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_WushiL50USB::DeviceUpdateMode()
|
||||
{
|
||||
state.Reset();
|
||||
|
||||
state.effect = modes[active_mode].value;
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_PER_LED)
|
||||
{
|
||||
state.SetColors(colors);
|
||||
}
|
||||
|
||||
if(modes[active_mode].color_mode == MODE_COLORS_MODE_SPECIFIC)
|
||||
{
|
||||
state.zone0_rgb[0] = RGBGetRValue(modes[active_mode].colors[0]);
|
||||
state.zone0_rgb[1] = RGBGetGValue(modes[active_mode].colors[0]);
|
||||
state.zone0_rgb[2] = RGBGetBValue(modes[active_mode].colors[0]);
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_DIRECTION_LR)
|
||||
{
|
||||
state.wave_ltr = modes[active_mode].direction ? 0 : 1;
|
||||
state.wave_rtl = modes[active_mode].direction ? 1 : 0;
|
||||
}
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_SPEED)
|
||||
{
|
||||
state.speed = modes[active_mode].speed;
|
||||
}
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_BRIGHTNESS)
|
||||
{
|
||||
state.brightness = modes[active_mode].brightness;
|
||||
}
|
||||
|
||||
controller->setMode(&state);
|
||||
}
|
||||
|
||||
void RGBController_WushiL50USB::DeviceSaveMode()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support saving or multiple modes |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_WushiL50USB.h |
|
||||
| |
|
||||
| RGBController for Wushi L50 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "WushiL50USBController.h"
|
||||
#include "RGBController.h"
|
||||
|
||||
class RGBController_WushiL50USB : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_WushiL50USB(WushiL50USBController* controller_ptr);
|
||||
~RGBController_WushiL50USB();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
void DeviceSaveMode();
|
||||
|
||||
private:
|
||||
WushiL50USBController * controller;
|
||||
WushiL50State state;
|
||||
};
|
||||
@@ -0,0 +1,88 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WushiL50USBController.cpp |
|
||||
| |
|
||||
| Driver for Wushi L50 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "StringUtils.h"
|
||||
#include "WushiL50USBController.h"
|
||||
|
||||
WushiL50USBController::WushiL50USBController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, const char* path, std::string dev_name)
|
||||
{
|
||||
wrapper = hid_wrapper;
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
WushiL50USBController::~WushiL50USBController()
|
||||
{
|
||||
wrapper.hid_close(dev);
|
||||
}
|
||||
|
||||
std::string WushiL50USBController::getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string WushiL50USBController::getLocation()
|
||||
{
|
||||
return location;
|
||||
}
|
||||
|
||||
std::string WushiL50USBController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = wrapper.hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
void WushiL50USBController::setMode(WushiL50State * in_mode)
|
||||
{
|
||||
unsigned char usb_buf[WUSHI_L50_HID_PACKET_SIZE];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up custom lighting packet |
|
||||
\*-----------------------------------------------------*/
|
||||
#ifdef _WIN32
|
||||
#define OFFSET 1
|
||||
usb_buf[0x00] = 0xCC;
|
||||
#else
|
||||
#define OFFSET 0
|
||||
#endif
|
||||
usb_buf[0x00 + OFFSET] = 0x16;
|
||||
usb_buf[0x01 + OFFSET] = in_mode->effect;
|
||||
usb_buf[0x02 + OFFSET] = in_mode->speed;
|
||||
usb_buf[0x03 + OFFSET] = in_mode->brightness;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Copy in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
memcpy(&usb_buf[0x04 + OFFSET], in_mode->zone0_rgb, 3);
|
||||
memcpy(&usb_buf[0x07 + OFFSET], in_mode->zone1_rgb, 3);
|
||||
memcpy(&usb_buf[0x0A + OFFSET], in_mode->zone2_rgb, 3);
|
||||
memcpy(&usb_buf[0x0D + OFFSET], in_mode->zone3_rgb, 3);
|
||||
|
||||
usb_buf[0x11 + OFFSET] = in_mode->wave_ltr;
|
||||
usb_buf[0x12 + OFFSET] = in_mode->wave_rtl;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
wrapper.hid_send_feature_report(dev, usb_buf, WUSHI_L50_HID_PACKET_SIZE);
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WushiL50USBController.h |
|
||||
| |
|
||||
| Driver for Wushi L50 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
#include "hidapi_wrapper.h"
|
||||
|
||||
#ifndef HID_MAX_STR
|
||||
#define HID_MAX_STR 255
|
||||
#endif
|
||||
|
||||
#define WUSHI_L50_HID_PACKET_SIZE 65
|
||||
#define WUSHI_L50_NUM_LEDS 4
|
||||
|
||||
enum WUSHI_L50_EFFECT
|
||||
{
|
||||
WUSHI_L50_EFFECT_STATIC = 1, /* Static mode */
|
||||
WUSHI_L50_EFFECT_BREATH = 3, /* Breathing mode */
|
||||
WUSHI_L50_EFFECT_WAVE = 4, /* Wave mode */
|
||||
WUSHI_L50_EFFECT_SMOOTH = 6, /* Smooth mode */
|
||||
WUSHI_L50_EFFECT_RACE = 8, /* Race mode */
|
||||
WUSHI_L50_EFFECT_STACK = 10, /* Stack mode */
|
||||
};
|
||||
|
||||
enum WUSHI_L50_BRIGHTNESS
|
||||
{
|
||||
WUSHI_L50_BRIGHTNESS_LOW = 1, /* Low brightness */
|
||||
WUSHI_L50_BRIGHTNESS_HIGH = 2, /* High brightness */
|
||||
};
|
||||
|
||||
enum WUSHI_L50_SPEED
|
||||
{
|
||||
WUSHI_L50_SPEED_SLOWEST = 1, /* Slowest speed */
|
||||
WUSHI_L50_SPEED_SLOW = 2, /* Slow speed */
|
||||
WUSHI_L50_SPEED_FAST = 3, /* Fast speed */
|
||||
WUSHI_L50_SPEED_FASTEST = 4, /* Fastest speed */
|
||||
};
|
||||
|
||||
enum WUSHI_L50_Direction
|
||||
{
|
||||
WUSHI_L50_Direction_LEFT = 1, /* Left direction */
|
||||
WUSHI_L50_Direction_RIGHT = 2, /* Right direction */
|
||||
};
|
||||
|
||||
class WushiL50State
|
||||
{
|
||||
public:
|
||||
uint8_t effect = WUSHI_L50_EFFECT_STATIC;
|
||||
uint8_t speed = WUSHI_L50_SPEED_SLOWEST;
|
||||
uint8_t brightness = WUSHI_L50_BRIGHTNESS_LOW;
|
||||
uint8_t zone0_rgb[3] = {0xFF, 0xFF, 0xFF};
|
||||
uint8_t zone1_rgb[3] = {0xFF, 0xFF, 0xFF};
|
||||
uint8_t zone2_rgb[3] = {0xFF, 0xFF, 0xFF};
|
||||
uint8_t zone3_rgb[3] = {0xFF, 0xFF, 0xFF};
|
||||
uint8_t wave_ltr = 0;
|
||||
uint8_t wave_rtl = 0;
|
||||
|
||||
void Reset()
|
||||
{
|
||||
effect = WUSHI_L50_EFFECT_STATIC;
|
||||
speed = WUSHI_L50_SPEED_SLOWEST;
|
||||
brightness = WUSHI_L50_BRIGHTNESS_LOW;
|
||||
wave_ltr = 0;
|
||||
wave_rtl = 0;
|
||||
}
|
||||
|
||||
void SetColors(std::vector<RGBColor> group_colors)
|
||||
{
|
||||
zone0_rgb[0] = RGBGetRValue(group_colors[0]);
|
||||
zone0_rgb[1] = RGBGetGValue(group_colors[0]);
|
||||
zone0_rgb[2] = RGBGetBValue(group_colors[0]);
|
||||
zone1_rgb[0] = RGBGetRValue(group_colors[1]);
|
||||
zone1_rgb[1] = RGBGetGValue(group_colors[1]);
|
||||
zone1_rgb[2] = RGBGetBValue(group_colors[1]);
|
||||
zone2_rgb[0] = RGBGetRValue(group_colors[2]);
|
||||
zone2_rgb[1] = RGBGetGValue(group_colors[2]);
|
||||
zone2_rgb[2] = RGBGetBValue(group_colors[2]);
|
||||
zone3_rgb[0] = RGBGetRValue(group_colors[3]);
|
||||
zone3_rgb[1] = RGBGetGValue(group_colors[3]);
|
||||
zone3_rgb[2] = RGBGetBValue(group_colors[3]);
|
||||
|
||||
wave_rtl = 0;
|
||||
}
|
||||
};
|
||||
|
||||
class WushiL50USBController
|
||||
{
|
||||
public:
|
||||
WushiL50USBController(hidapi_wrapper hid_wrapper, hid_device* dev_handle, const char* path, std::string dev_name);
|
||||
~WushiL50USBController();
|
||||
|
||||
std::string getName();
|
||||
std::string getLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
void setMode(WushiL50State * in_mode);
|
||||
|
||||
private:
|
||||
hidapi_wrapper wrapper;
|
||||
hid_device * dev;
|
||||
std::string location;
|
||||
std::string name;
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WushiL50USBControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Wushi L50 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <hidapi.h>
|
||||
#include "Detector.h"
|
||||
#include "WushiL50USBController.h"
|
||||
#include "RGBController_WushiL50USB.h"
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Wushi vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define WUSHI_VID 0x306F
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Wushi device ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define WUSHI_PID 0x1234
|
||||
|
||||
void DetectWushiL50USBControllers(hidapi_wrapper wrapper, hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = wrapper.hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
WushiL50USBController* controller = new WushiL50USBController(wrapper, dev, info->path, name);
|
||||
RGBController_WushiL50USB* rgb_controller = new RGBController_WushiL50USB(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_WRAPPED_DETECTOR("JSAUX RGB Docking Station", DetectWushiL50USBControllers, WUSHI_VID, WUSHI_PID);
|
||||
Reference in New Issue
Block a user