Publish LumaOps source

This commit is contained in:
LumaOps release export
2026-09-03 01:18:36 +02:00
commit 7f1c0e5f71
2363 changed files with 501543 additions and 0 deletions
@@ -0,0 +1,120 @@
/*---------------------------------------------------------*\
| HoltekA070Controller.cpp |
| |
| Driver for Holtek mouse |
| |
| Santeri Pikarinen (santeri3700) 01 Aug 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "HoltekA070Controller.h"
#include "StringUtils.h"
HoltekA070Controller::HoltekA070Controller(hid_device* dev_handle, const char* path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
HoltekA070Controller::~HoltekA070Controller()
{
hid_close(dev);
}
std::string HoltekA070Controller::GetDeviceLocation()
{
return("HID: " + location);
}
std::string HoltekA070Controller::GetNameString()
{
return(name);
}
std::string HoltekA070Controller::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));
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void HoltekA070Controller::SendCustomColor
(
unsigned char red,
unsigned char green,
unsigned char blue
)
{
char usb_buf[8];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up RGB Control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x07; // PACKET SIZE?
usb_buf[0x01] = 0x0a; // SET RGB
usb_buf[0x02] = 0x00; // SAVE (does not work with SET RGB)
usb_buf[0x03] = red; // RED
usb_buf[0x04] = green; // GREEN
usb_buf[0x05] = blue; // BLUE
usb_buf[0x06] = 0x00; // PADDING?
usb_buf[0x07] = 0x00; // PADDING?
// So far no saving function has been discovered for the "SET RGB" command.
// Such functionality might not even exist for the A070 series.
// The chosen RGB color will therefore reset after a power cycle.
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, (unsigned char *)usb_buf, sizeof(usb_buf));
}
void HoltekA070Controller::SendMode
(
unsigned char mode
)
{
char usb_buf[8];
/*-----------------------------------------------------*\
| Zero out buffer |
\*-----------------------------------------------------*/
memset(usb_buf, 0x00, sizeof(usb_buf));
/*-----------------------------------------------------*\
| Set up lighting mode control packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x07; // PACKET SIZE?
usb_buf[0x01] = 0x0b; // SET LIGHTING MODE
usb_buf[0x02] = 0x01; // SAVE
usb_buf[0x03] = mode; // MODE 01-04
usb_buf[0x04] = 0x00; // PADDING?
usb_buf[0x05] = 0x00; // PADDING?
usb_buf[0x06] = 0x00; // PADDING?
usb_buf[0x07] = 0x00; // PADDING?
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, (unsigned char *)usb_buf, sizeof(usb_buf));
}
@@ -0,0 +1,51 @@
/*---------------------------------------------------------*\
| HoltekA070Controller.h |
| |
| Driver for Holtek mouse |
| |
| Santeri Pikarinen (santeri3700) 01 Aug 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <hidapi.h>
enum
{
HOLTEK_A070_MODE_STATIC = 0x01,
HOLTEK_A070_MODE_BREATHING_SLOW = 0x02,
HOLTEK_A070_MODE_BREATHING_MEDIUM = 0x03,
HOLTEK_A070_MODE_BREATHING_FAST = 0x04
};
class HoltekA070Controller
{
public:
HoltekA070Controller(hid_device* dev_handle, const char* path, std::string dev_name);
~HoltekA070Controller();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
void SendCustomColor
(
unsigned char red,
unsigned char green,
unsigned char blue
);
void SendMode
(
unsigned char mode
);
private:
hid_device* dev;
std::string location;
std::string name;
};
@@ -0,0 +1,107 @@
/*---------------------------------------------------------*\
| RGBController_HoltekA070.cpp |
| |
| RGBController for Holtek mouse |
| |
| Santeri Pikarinen (santeri3700) 01 Aug 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_HoltekA070.h"
/**------------------------------------------------------------------*\
@name Holtek A070
@category Mouse
@type USB
@save :x:
@direct :x:
@effects :white_check_mark:
@detectors DetectHoltekControllers
@comment
\*-------------------------------------------------------------------*/
RGBController_HoltekA070::RGBController_HoltekA070(HoltekA070Controller* controller_ptr)
{
controller = controller_ptr;
name = controller->GetNameString();
vendor = "Holtek";
type = DEVICE_TYPE_MOUSE;
description = "Holtek USB Gaming Mouse Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Static;
Static.name = "Static";
Static.speed = HOLTEK_A070_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Static.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Breathing.color_mode = MODE_COLORS_PER_LED;
Breathing.speed_min = HOLTEK_A070_MODE_BREATHING_SLOW;
Breathing.speed_max = HOLTEK_A070_MODE_BREATHING_FAST;
Breathing.speed = HOLTEK_A070_MODE_BREATHING_MEDIUM;
modes.push_back(Breathing);
SetupZones();
}
RGBController_HoltekA070::~RGBController_HoltekA070()
{
delete controller;
}
void RGBController_HoltekA070::SetupZones()
{
zone mouse_zone;
mouse_zone.name = "Mouse";
mouse_zone.type = ZONE_TYPE_SINGLE;
mouse_zone.leds_min = 1;
mouse_zone.leds_max = 1;
mouse_zone.leds_count = 1;
mouse_zone.matrix_map = NULL;
zones.push_back(mouse_zone);
led mouse_led;
mouse_led.name = "Mouse";
leds.push_back(mouse_led);
SetupColors();
}
void RGBController_HoltekA070::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HoltekA070::DeviceUpdateLEDs()
{
unsigned char red = RGBGetRValue(colors[0]);
unsigned char green = RGBGetGValue(colors[0]);
unsigned char blue = RGBGetBValue(colors[0]);
controller->SendCustomColor(red, green, blue);
}
void RGBController_HoltekA070::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_HoltekA070::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_HoltekA070::DeviceUpdateMode()
{
controller->SendMode(modes[active_mode].speed);
}
@@ -0,0 +1,34 @@
/*---------------------------------------------------------*\
| RGBController_HoltekA070.h |
| |
| RGBController for Holtek mouse |
| |
| Santeri Pikarinen (santeri3700) 01 Aug 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "HoltekA070Controller.h"
class RGBController_HoltekA070 : public RGBController
{
public:
RGBController_HoltekA070(HoltekA070Controller* controller_ptr);
~RGBController_HoltekA070();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
HoltekA070Controller* controller;
};
@@ -0,0 +1,75 @@
/*---------------------------------------------------------*\
| HoltekA1FAController.cpp |
| |
| Driver for Holtek mousemat |
| |
| Edoardo Ridolfi (edo2313) 26 Dec 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include "HoltekA1FAController.h"
#include "StringUtils.h"
HoltekA1FAController::HoltekA1FAController(hid_device *dev_handle, const char *path, std::string dev_name)
{
dev = dev_handle;
location = path;
name = dev_name;
}
HoltekA1FAController::~HoltekA1FAController()
{
hid_close(dev);
}
std::string HoltekA1FAController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string HoltekA1FAController::GetNameString()
{
return(name);
}
std::string HoltekA1FAController::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));
}
/*-------------------------------------------------------------------------------------------------*\
| Private packet sending functions. |
\*-------------------------------------------------------------------------------------------------*/
void HoltekA1FAController::SendData(unsigned char mode, unsigned char brightness, unsigned char speed, unsigned char preset, unsigned char red, unsigned char green, unsigned char blue)
{
char usb_buf[9] = {0x00};
/*-----------------------------------------------------*\
| Set up RGB Control packet |
\*-----------------------------------------------------*/
usb_buf[HOLTEK_A1FA_BYTE_COMMAND] = 0x08;
usb_buf[HOLTEK_A1FA_BYTE_MODE] = mode;
usb_buf[HOLTEK_A1FA_BYTE_BRIGHTNESS] = brightness;
usb_buf[HOLTEK_A1FA_BYTE_SPEED] = speed;
usb_buf[HOLTEK_A1FA_BYTE_PRESET] = preset;
usb_buf[HOLTEK_A1FA_BYTE_RED] = red;
usb_buf[HOLTEK_A1FA_BYTE_GREEN] = green;
usb_buf[HOLTEK_A1FA_BYTE_BLUE] = blue;
/*-----------------------------------------------------*\
| Send packet |
\*-----------------------------------------------------*/
hid_send_feature_report(dev, (unsigned char *)usb_buf, sizeof(usb_buf));
}
@@ -0,0 +1,65 @@
/*---------------------------------------------------------*\
| HoltekA1FAController.h |
| |
| Driver for Holtek mousemat |
| |
| Edoardo Ridolfi (edo2313) 26 Dec 2020 |
| |
| 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"
enum
{
HOLTEK_A1FA_BYTE_COMMAND = 1,
HOLTEK_A1FA_BYTE_MODE = 2,
HOLTEK_A1FA_BYTE_BRIGHTNESS = 3,
HOLTEK_A1FA_BYTE_SPEED = 4,
HOLTEK_A1FA_BYTE_PRESET = 5,
HOLTEK_A1FA_BYTE_RED = 6,
HOLTEK_A1FA_BYTE_GREEN = 7,
HOLTEK_A1FA_BYTE_BLUE = 8
};
enum
{
HOLTEK_A1FA_MODE_STATIC = 0x00,
HOLTEK_A1FA_MODE_BREATHING = 0x01,
HOLTEK_A1FA_MODE_NEON = 0x02,
HOLTEK_A1FA_MODE_RAINBOW = 0x03
};
enum
{
HOLTEK_A1FA_SPEED_SLOWEST = 0x00, /* Slowest speed */
HOLTEK_A1FA_SPEED_SLOWER = 0x01, /* Slower speed */
HOLTEK_A1FA_SPEED_SLOW = 0x02, /* Slow speed */
HOLTEK_A1FA_SPEED_NORMAL = 0x03, /* Normal speed */
HOLTEK_A1FA_SPEED_FAST = 0x04, /* Fast speed */
HOLTEK_A1FA_SPEED_FASTEST = 0x05 /* Fastest speed */
};
class HoltekA1FAController
{
public:
HoltekA1FAController(hid_device *dev_handle, const char *path, std::string dev_name);
~HoltekA1FAController();
std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString();
void SendData(unsigned char mode, unsigned char brightness, unsigned char speed, unsigned char preset, unsigned char red, unsigned char green, unsigned char blue);
private:
hid_device *dev;
std::string location;
std::string name;
};
@@ -0,0 +1,150 @@
/*---------------------------------------------------------*\
| RGBController_HoltekA1FA.cpp |
| |
| RGBController for Holtek mousemat |
| |
| Edoardo Ridolfi (edo2313) 26 Dec 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include "RGBController_HoltekA1FA.h"
/**------------------------------------------------------------------*\
@name Holtek A1FA
@category Mouse
@type USB
@save :x:
@direct :x:
@effects :white_check_mark:
@detectors DetectHoltekMousemats
@comment
\*-------------------------------------------------------------------*/
RGBController_HoltekA1FA::RGBController_HoltekA1FA(HoltekA1FAController* controller_ptr)
{
controller = controller_ptr;
name = controller->GetNameString();
vendor = "Holtek";
type = DEVICE_TYPE_MOUSEMAT;
description = "Holtek Mousemat Device";
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Static;
Static.name = "Static";
Static.value = HOLTEK_A1FA_MODE_STATIC;
Static.speed = HOLTEK_A1FA_MODE_STATIC;
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS;
Static.color_mode = MODE_COLORS_PER_LED;
Static.colors_min = 1;
Static.colors_max = 7;
Static.colors.resize(7);
modes.push_back(Static);
mode Breathing;
Breathing.name = "Breathing";
Breathing.value = HOLTEK_A1FA_MODE_BREATHING;
Breathing.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_HAS_RANDOM_COLOR;
Breathing.color_mode = MODE_COLORS_PER_LED;
Breathing.speed_min = HOLTEK_A1FA_SPEED_SLOWEST;
Breathing.speed_max = HOLTEK_A1FA_SPEED_FASTEST;
Breathing.speed = HOLTEK_A1FA_SPEED_NORMAL;
Breathing.colors_min = 1;
Breathing.colors_max = 7;
Breathing.colors.resize(7);
modes.push_back(Breathing);
mode Neon;
Neon.name = "Neon";
Neon.value = HOLTEK_A1FA_MODE_NEON;
Neon.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Neon.color_mode = MODE_COLORS_NONE;
Neon.speed_min = HOLTEK_A1FA_SPEED_SLOWEST;
Neon.speed_max = HOLTEK_A1FA_SPEED_FASTEST;
Neon.speed = HOLTEK_A1FA_SPEED_NORMAL;
modes.push_back(Neon);
mode Rainbow;
Rainbow.name = "Rainbow";
Rainbow.value = HOLTEK_A1FA_MODE_RAINBOW;
Rainbow.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_BRIGHTNESS;
Rainbow.color_mode = MODE_COLORS_NONE;
Rainbow.speed_min = HOLTEK_A1FA_SPEED_SLOWEST;
Rainbow.speed_max = HOLTEK_A1FA_SPEED_FASTEST;
Rainbow.speed = HOLTEK_A1FA_SPEED_NORMAL;
modes.push_back(Rainbow);
SetupZones();
}
RGBController_HoltekA1FA::~RGBController_HoltekA1FA()
{
delete controller;
}
void RGBController_HoltekA1FA::SetupZones()
{
zone mouse_zone;
mouse_zone.name = "Mousemat";
mouse_zone.type = ZONE_TYPE_SINGLE;
mouse_zone.leds_min = 1;
mouse_zone.leds_max = 1;
mouse_zone.leds_count = 1;
mouse_zone.matrix_map = NULL;
zones.push_back(mouse_zone);
led mouse_led;
mouse_led.name = "Mousemat";
leds.push_back(mouse_led);
SetupColors();
}
void RGBController_HoltekA1FA::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_HoltekA1FA::DeviceUpdateLEDs()
{
unsigned char mode = modes[active_mode].value;
unsigned char brightness = 0x20; /*When brightness support is added, change this */
unsigned char speed = modes[active_mode].speed;
unsigned char preset = (modes[active_mode].color_mode == MODE_COLORS_RANDOM) ? 0x70 : 0x00;
unsigned char red = RGBGetRValue(colors[0]);
unsigned char green = RGBGetGValue(colors[0]);
unsigned char blue = RGBGetBValue(colors[0]);
controller->SendData(mode, brightness, speed, preset, red, green, blue);
}
void RGBController_HoltekA1FA::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_HoltekA1FA::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_HoltekA1FA::DeviceUpdateMode()
{
if((active_mode < HOLTEK_A1FA_MODE_NEON) && (previous_mode < HOLTEK_A1FA_MODE_NEON))
{
//If we're switching from and to static and breathing then sync the mode colors
for(unsigned int i = 0; i < modes[active_mode].colors_max; i++)
{
modes[active_mode].colors[i] = modes[previous_mode].colors[i];
}
}
previous_mode = active_mode;
DeviceUpdateLEDs();
}
@@ -0,0 +1,36 @@
/*---------------------------------------------------------*\
| RGBController_HoltekA1FA.h |
| |
| RGBController for Holtek mousemat |
| |
| Edoardo Ridolfi (edo2313) 26 Dec 2020 |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "HoltekA1FAController.h"
class RGBController_HoltekA1FA : public RGBController
{
public:
RGBController_HoltekA1FA(HoltekA1FAController* controller_ptr);
~RGBController_HoltekA1FA();
int previous_mode = 0; /* previous mode */
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
private:
HoltekA1FAController* controller;
};
@@ -0,0 +1,57 @@
/*---------------------------------------------------------*\
| HoltekControllerDetect.cpp |
| |
| Detector for Holtek devices |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <hidapi.h>
#include "Detector.h"
#include "HoltekA070Controller.h"
#include "RGBController_HoltekA070.h"
#include "HoltekA1FAController.h"
#include "RGBController_HoltekA1FA.h"
/*-----------------------------------------------------*\
| Holtek Semiconductor Inc. vendor ID |
\*-----------------------------------------------------*/
#define HOLTEK_VID 0x04D9
/*-----------------------------------------------------*\
| Mouse product IDs |
\*-----------------------------------------------------*/
#define HOLTEK_A070_PID 0xA070
/*-----------------------------------------------------*\
| Mousemats product IDs |
\*-----------------------------------------------------*/
#define HOLTEK_A1FA_PID 0xA1FA
void DetectHoltekControllers(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
HoltekA070Controller* controller = new HoltekA070Controller(dev, info->path, name);
RGBController_HoltekA070* rgb_controller = new RGBController_HoltekA070(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
} /* DetectHoltekControllers() */
void DetectHoltekMousemats(hid_device_info *info, const std::string &name)
{
hid_device *dev = hid_open_path(info->path);
if(dev)
{
HoltekA1FAController* controller = new HoltekA1FAController(dev, info->path, name);
RGBController_HoltekA1FA* rgb_controller = new RGBController_HoltekA1FA(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
} /* DetectHoltekMousemats() */
REGISTER_HID_DETECTOR_IPU("Holtek USB Gaming Mouse", DetectHoltekControllers, HOLTEK_VID, HOLTEK_A070_PID, 1, 0xFF00, 2);
REGISTER_HID_DETECTOR_IPU("Holtek Mousemat", DetectHoltekMousemats, HOLTEK_VID, HOLTEK_A1FA_PID, 2, 0xFF00, 0xFF00);