Publish LumaOps source
This commit is contained in:
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user