Publish LumaOps source
This commit is contained in:
@@ -0,0 +1,140 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AresonController.cpp |
|
||||
| |
|
||||
| Driver for Areson mice |
|
||||
| |
|
||||
| Morgan Guimard (morg) 29 Jan 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <string.h>
|
||||
#include "StringUtils.h"
|
||||
#include "AresonController.h"
|
||||
|
||||
AresonController::AresonController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = info.path;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
AresonController::~AresonController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string AresonController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string AresonController::GetNameString()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string AresonController::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));
|
||||
}
|
||||
|
||||
unsigned char AresonController::GetSpeedValue(unsigned char speed, unsigned char mode_value)
|
||||
{
|
||||
unsigned char speed_values_lookup_high[ARESON_SPEED_MAX] =
|
||||
{
|
||||
0xFF, 0xE6, 0xD2, 0xBe, 0xAA, 0x96, 0x82, 0x6E, 0x46, 0x28
|
||||
};
|
||||
|
||||
unsigned char speed_values_lookup_low[ARESON_SPEED_MAX] =
|
||||
{
|
||||
0x2D, 0x28, 0x23, 0x1E, 0x19, 0x13, 0x0F, 0x0A, 0x05, 0x03
|
||||
};
|
||||
|
||||
switch (mode_value)
|
||||
{
|
||||
case BREATHING_MODE_VALUE:
|
||||
case SPECRTUM_CYCLE_MODE_VALUE:
|
||||
case SINGLE_COLOR_WAVE_MODE_VALUE:
|
||||
case BREATHING_COLORFUL_MODE_VALUE:
|
||||
return speed_values_lookup_high[speed -1];
|
||||
|
||||
case RAINBOW_WAVE_MODE_VALUE:
|
||||
return speed_values_lookup_low[speed -1];
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void AresonController::SetMode(RGBColor color, unsigned char brightness, unsigned char speed, unsigned char mode_value)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Init the packet buffer |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned char usb_buf[ARESON_PACKET_SIZE];
|
||||
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*---------------------------------------------------------*\œ
|
||||
| Constant data |
|
||||
\*---------------------------------------------------------*/
|
||||
usb_buf[0x00] = ARESON_REPORT_ID;
|
||||
usb_buf[0x01] = 0x07;
|
||||
usb_buf[0x04] = 0xA0;
|
||||
usb_buf[0x05] = 0x07;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set the mode |
|
||||
\*---------------------------------------------------------*/
|
||||
usb_buf[0x06] = mode_value;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set the color |
|
||||
\*---------------------------------------------------------*/
|
||||
usb_buf[0x07] = RGBGetRValue(color);
|
||||
usb_buf[0x08] = RGBGetGValue(color);
|
||||
usb_buf[0x09] = RGBGetBValue(color);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set speed if needed |
|
||||
\*---------------------------------------------------------*/
|
||||
usb_buf[0x0A] = GetSpeedValue(speed, mode_value);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set brightness if needed |
|
||||
\*---------------------------------------------------------*/
|
||||
if(mode_value != OFF_MODE_VALUE)
|
||||
{
|
||||
unsigned char brightness_values[ARESON_BRIGHTNESS_MAX] =
|
||||
{
|
||||
0x19, 0x32, 0x4B, 0x64, 0x7D, 0x96, 0xAF, 0xC8, 0xE1, 0xFF
|
||||
};
|
||||
|
||||
usb_buf[0x0B] = brightness_values[brightness - 1];
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Custom CRC - thanks to Vaker for this <3 |
|
||||
\*---------------------------------------------------------*/
|
||||
usb_buf[0x0C] = 0x55 - usb_buf[0x06] - usb_buf[0x07] - usb_buf[0x08] - usb_buf[0x09] - usb_buf[0x0A] - usb_buf[0x0B];
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Constant data |
|
||||
\*---------------------------------------------------------*/
|
||||
usb_buf[0x10] = ARESON_PACKET_END;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Send the report |
|
||||
\*---------------------------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, ARESON_PACKET_SIZE);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AresonController.h |
|
||||
| |
|
||||
| Driver for Areson mice |
|
||||
| |
|
||||
| Morgan Guimard (morg) 29 Jan 2022 |
|
||||
| |
|
||||
| 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"
|
||||
|
||||
#define ARESON_PACKET_SIZE 17
|
||||
#define ARESON_REPORT_ID 0x08
|
||||
#define ARESON_PACKET_END 0x4A
|
||||
|
||||
enum
|
||||
{
|
||||
RAINBOW_WAVE_MODE_VALUE = 0x00,
|
||||
BREATHING_MODE_VALUE = 0x01,
|
||||
STATIC_MODE_VALUE = 0x02,
|
||||
SPECRTUM_CYCLE_MODE_VALUE = 0x03,
|
||||
OFF_MODE_VALUE = 0x04,
|
||||
SINGLE_COLOR_WAVE_MODE_VALUE = 0x05,
|
||||
BREATHING_COLORFUL_MODE_VALUE = 0x07,
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
ARESON_BRIGHTNESS_MIN = 1,
|
||||
ARESON_BRIGHTNESS_MAX = 10,
|
||||
ARESON_SPEED_MIN = 1,
|
||||
ARESON_SPEED_MAX = 10
|
||||
};
|
||||
|
||||
class AresonController
|
||||
{
|
||||
public:
|
||||
AresonController(hid_device* dev_handle, const hid_device_info& info, std::string dev_name);
|
||||
~AresonController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetNameString();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SetMode(RGBColor color, unsigned char brightness, unsigned char speed, unsigned char mode_value);
|
||||
|
||||
protected:
|
||||
hid_device* dev;
|
||||
|
||||
private:
|
||||
std::string location;
|
||||
std::string name;
|
||||
unsigned char GetSpeedValue(unsigned char speed, unsigned char mode_value);
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AresonControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Areson mice |
|
||||
| |
|
||||
| Morgan Guimard (morg) 29 Jan 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "Detector.h"
|
||||
#include "AresonController.h"
|
||||
#include "RGBController_Areson.h"
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Areson vendor ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define ARESON_VID 0x25A7
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Product ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define ZET_GAMING_EDGE_AIR_PRO_WIRELESS_PID 0xFA3F
|
||||
#define ZET_GAMING_EDGE_AIR_PRO_PID 0xFA40
|
||||
#define ZET_GAMING_EDGE_AIR_ELIT_WIRELESS_PID 0xFA48
|
||||
#define ZET_GAMING_EDGE_AIR_ELIT_PID 0xFA49
|
||||
#define REDRAGON_M914_PID 0xFA7B
|
||||
#define REDRAGON_M914_WIRELESS_PID 0xFA7C
|
||||
|
||||
void DetectAresonControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
AresonController* controller = new AresonController(dev, *info, name);
|
||||
RGBController_Areson* rgb_controller = new RGBController_Areson(controller);
|
||||
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU("ZET GAMING Edge Air Pro (Wireless)", DetectAresonControllers, ARESON_VID, ZET_GAMING_EDGE_AIR_PRO_WIRELESS_PID, 1, 0xFF02, 2);
|
||||
REGISTER_HID_DETECTOR_IPU("ZET GAMING Edge Air Pro", DetectAresonControllers, ARESON_VID, ZET_GAMING_EDGE_AIR_PRO_PID, 1, 0xFF02, 2);
|
||||
REGISTER_HID_DETECTOR_IPU("ZET GAMING Edge Air Elit (Wireless)", DetectAresonControllers, ARESON_VID, ZET_GAMING_EDGE_AIR_ELIT_WIRELESS_PID, 1, 0xFF02, 2);
|
||||
REGISTER_HID_DETECTOR_IPU("ZET GAMING Edge Air Elit", DetectAresonControllers, ARESON_VID, ZET_GAMING_EDGE_AIR_ELIT_PID, 1, 0xFF02, 2);
|
||||
REGISTER_HID_DETECTOR_IPU("Redragon M914 NIX (Wireless)", DetectAresonControllers, ARESON_VID, REDRAGON_M914_WIRELESS_PID, 1, 0xFF02, 2);
|
||||
REGISTER_HID_DETECTOR_IPU("Redragon M914 NIX", DetectAresonControllers, ARESON_VID, REDRAGON_M914_PID, 1, 0xFF02, 2);
|
||||
@@ -0,0 +1,189 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_Areson.cpp |
|
||||
| |
|
||||
| RGBController for Areson mice |
|
||||
| |
|
||||
| Morgan Guimard (morg) 29 Jan 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include "RGBController_Areson.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Areson
|
||||
@category Mouse
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :x:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectAresonControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_Areson::RGBController_Areson(AresonController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetNameString();
|
||||
vendor = "Areson";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "Areson mouse";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = STATIC_MODE_VALUE;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
Static.brightness_min = ARESON_BRIGHTNESS_MIN;
|
||||
Static.brightness_max = ARESON_BRIGHTNESS_MAX;
|
||||
Static.brightness = ARESON_BRIGHTNESS_MAX;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode RainbowWave;
|
||||
RainbowWave.name = "Rainbow Wave";
|
||||
RainbowWave.value = RAINBOW_WAVE_MODE_VALUE;
|
||||
RainbowWave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
RainbowWave.color_mode = MODE_COLORS_NONE;
|
||||
RainbowWave.brightness_min = ARESON_BRIGHTNESS_MIN;
|
||||
RainbowWave.brightness_max = ARESON_BRIGHTNESS_MAX;
|
||||
RainbowWave.brightness = ARESON_BRIGHTNESS_MAX;
|
||||
RainbowWave.speed_min = ARESON_SPEED_MIN;
|
||||
RainbowWave.speed_max = ARESON_SPEED_MAX;
|
||||
RainbowWave.speed = ARESON_SPEED_MAX;
|
||||
modes.push_back(RainbowWave);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = BREATHING_MODE_VALUE;
|
||||
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Breathing.color_mode = MODE_COLORS_PER_LED;
|
||||
Breathing.brightness_min = ARESON_BRIGHTNESS_MIN;
|
||||
Breathing.brightness_max = ARESON_BRIGHTNESS_MAX;
|
||||
Breathing.brightness = ARESON_BRIGHTNESS_MAX;
|
||||
Breathing.speed_min = ARESON_SPEED_MIN;
|
||||
Breathing.speed_max = ARESON_SPEED_MAX;
|
||||
Breathing.speed = ARESON_SPEED_MIN;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode SpectrumCycle;
|
||||
SpectrumCycle.name = "Spectrum Cycle";
|
||||
SpectrumCycle.value = SPECRTUM_CYCLE_MODE_VALUE;
|
||||
SpectrumCycle.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
SpectrumCycle.color_mode = MODE_COLORS_NONE;
|
||||
SpectrumCycle.brightness_min = ARESON_BRIGHTNESS_MIN;
|
||||
SpectrumCycle.brightness_max = ARESON_BRIGHTNESS_MAX;
|
||||
SpectrumCycle.brightness = ARESON_BRIGHTNESS_MAX;
|
||||
SpectrumCycle.speed_min = ARESON_SPEED_MIN;
|
||||
SpectrumCycle.speed_max = ARESON_SPEED_MAX;
|
||||
SpectrumCycle.speed = ARESON_SPEED_MAX;
|
||||
modes.push_back(SpectrumCycle);
|
||||
|
||||
mode SingleColorWave;
|
||||
SingleColorWave.name = "Single Color Wave";
|
||||
SingleColorWave.value = SINGLE_COLOR_WAVE_MODE_VALUE;
|
||||
SingleColorWave.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
SingleColorWave.color_mode = MODE_COLORS_PER_LED;
|
||||
SingleColorWave.brightness_min = ARESON_BRIGHTNESS_MIN;
|
||||
SingleColorWave.brightness_max = ARESON_BRIGHTNESS_MAX;
|
||||
SingleColorWave.brightness = ARESON_BRIGHTNESS_MAX;
|
||||
SingleColorWave.speed_min = ARESON_SPEED_MIN;
|
||||
SingleColorWave.speed_max = ARESON_SPEED_MAX;
|
||||
SingleColorWave.speed = ARESON_SPEED_MAX;
|
||||
SingleColorWave.colors.resize(1);
|
||||
modes.push_back(SingleColorWave);
|
||||
|
||||
mode ColorfulBreathing;
|
||||
ColorfulBreathing.name = "Colorful Breathing";
|
||||
ColorfulBreathing.value = BREATHING_COLORFUL_MODE_VALUE;
|
||||
ColorfulBreathing.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
ColorfulBreathing.color_mode = MODE_COLORS_NONE;
|
||||
ColorfulBreathing.brightness_min = ARESON_BRIGHTNESS_MIN;
|
||||
ColorfulBreathing.brightness_max = ARESON_BRIGHTNESS_MAX;
|
||||
ColorfulBreathing.brightness = ARESON_BRIGHTNESS_MAX;
|
||||
ColorfulBreathing.speed_min = ARESON_SPEED_MIN;
|
||||
ColorfulBreathing.speed_max = ARESON_SPEED_MAX;
|
||||
ColorfulBreathing.speed = ARESON_SPEED_MAX;
|
||||
ColorfulBreathing.colors.resize(1);
|
||||
modes.push_back(ColorfulBreathing);
|
||||
|
||||
mode OFF;
|
||||
OFF.name = "Off";
|
||||
OFF.value = OFF_MODE_VALUE;
|
||||
OFF.flags = MODE_FLAG_AUTOMATIC_SAVE;
|
||||
OFF.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(OFF);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_Areson::~RGBController_Areson()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_Areson::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Mouse";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = 1;
|
||||
new_zone.leds_max = 1;
|
||||
new_zone.leds_count = 1;
|
||||
new_zone.matrix_map = nullptr;
|
||||
|
||||
zones.emplace_back(new_zone);
|
||||
|
||||
leds.resize(1);
|
||||
|
||||
led new_led;
|
||||
new_led.name = "LED 1";
|
||||
leds[0] = new_led;
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_Areson::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_Areson::DeviceUpdateLEDs()
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_Areson::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_Areson::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_Areson::DeviceUpdateMode()
|
||||
{
|
||||
RGBColor color;
|
||||
|
||||
if(modes[active_mode].flags & MODE_FLAG_HAS_PER_LED_COLOR)
|
||||
{
|
||||
color = colors[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
color = ToRGBColor(0,0,0);
|
||||
}
|
||||
|
||||
controller->SetMode(color, modes[active_mode].brightness, modes[active_mode].speed, modes[active_mode].value);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_Areson.h |
|
||||
| |
|
||||
| RGBController for Areson mice |
|
||||
| |
|
||||
| Morgan Guimard (morg) 29 Jan 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AresonController.h"
|
||||
|
||||
class RGBController_Areson : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_Areson(AresonController* controller_ptr);
|
||||
~RGBController_Areson();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
AresonController* controller;
|
||||
};
|
||||
Reference in New Issue
Block a user