Publish LumaOps source
This commit is contained in:
+102
@@ -0,0 +1,102 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AsusStrixClawController.cpp |
|
||||
| |
|
||||
| Driver for ASUS Strix Claw mouse |
|
||||
| |
|
||||
| Mola19 06 Aug 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include "AsusStrixClawController.h"
|
||||
#include "StringUtils.h"
|
||||
|
||||
StrixClawController::StrixClawController(hid_device* dev_handle, const char* path, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
}
|
||||
|
||||
StrixClawController::~StrixClawController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string StrixClawController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string StrixClawController::GetDeviceName()
|
||||
{
|
||||
return(name);
|
||||
}
|
||||
|
||||
std::string StrixClawController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[HID_MAX_STR];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, HID_MAX_STR);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
std::string StrixClawController::GetVersion()
|
||||
{
|
||||
|
||||
// asking the device to prepare version information
|
||||
unsigned char usb_buf_out[9];
|
||||
|
||||
memset(usb_buf_out, 0x00, 9);
|
||||
|
||||
usb_buf_out[0x00] = 0x07;
|
||||
usb_buf_out[0x01] = 0x80;
|
||||
|
||||
hid_send_feature_report(dev, usb_buf_out, 9);
|
||||
|
||||
// retrieving the version information
|
||||
unsigned char usb_buf_in[9];
|
||||
|
||||
memset(usb_buf_in, 0x00, 9);
|
||||
|
||||
usb_buf_in[0x00] = 0x07;
|
||||
|
||||
hid_get_feature_report(dev, usb_buf_in, 9);
|
||||
|
||||
return (std::to_string(usb_buf_in[1]) + std::to_string(usb_buf_in[2]));
|
||||
}
|
||||
|
||||
void StrixClawController::SetScrollWheelLED(bool OnOff)
|
||||
{
|
||||
unsigned char usb_buf[9];
|
||||
|
||||
memset(usb_buf, 0x00, 9);
|
||||
|
||||
usb_buf[0x00] = 0x07;
|
||||
usb_buf[0x01] = 0x07;
|
||||
usb_buf[0x02] = 0x01;
|
||||
usb_buf[0x03] = OnOff;
|
||||
hid_send_feature_report(dev, usb_buf, 9);
|
||||
}
|
||||
|
||||
void StrixClawController::SetLogoLED(uint8_t brightness)
|
||||
{
|
||||
unsigned char usb_buf[9];
|
||||
|
||||
memset(usb_buf, 0x00, 9);
|
||||
|
||||
usb_buf[0x00] = 0x07;
|
||||
usb_buf[0x01] = 0x0a;
|
||||
usb_buf[0x02] = 0x01;
|
||||
usb_buf[0x03] = 0x00;
|
||||
usb_buf[0x04] = brightness;
|
||||
hid_send_feature_report(dev, usb_buf, 9);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| AsusStrixClawController.h |
|
||||
| |
|
||||
| Driver for ASUS Strix Claw mouse |
|
||||
| |
|
||||
| Mola19 06 Aug 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 HID_MAX_STR 255
|
||||
|
||||
class StrixClawController
|
||||
{
|
||||
public:
|
||||
StrixClawController(hid_device* dev_handle, const char* path, std::string dev_name);
|
||||
virtual ~StrixClawController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerialString();
|
||||
std::string GetVersion();
|
||||
|
||||
void SetScrollWheelLED(bool OnOff);
|
||||
void SetLogoLED(uint8_t brightness);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
std::string location;
|
||||
std::string name;
|
||||
};
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_AsusStrixClaw.cpp |
|
||||
| |
|
||||
| RGBController for ASUS Strix Claw mouse |
|
||||
| |
|
||||
| Mola19 06 Aug 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_AsusStrixClaw.h"
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Asus Strix Claw
|
||||
@category Mouse
|
||||
@type USB
|
||||
@save :robot:
|
||||
@direct :x:
|
||||
@effects :tools:
|
||||
@detectors DetectAsusStrixClaw
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_StrixClaw::RGBController_StrixClaw(StrixClawController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = controller->GetDeviceName();
|
||||
vendor = "ASUS";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = "ASUS Legacy Mouse Device";
|
||||
version = controller->GetVersion();
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.value = 0;
|
||||
Off.flags = MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode On;
|
||||
On.name = "On";
|
||||
On.value = 1;
|
||||
On.flags = MODE_FLAG_AUTOMATIC_SAVE;
|
||||
On.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(On);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_StrixClaw::~RGBController_StrixClaw()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_StrixClaw::SetupZones()
|
||||
{
|
||||
zone scroll_wheel_zone;
|
||||
|
||||
scroll_wheel_zone.name = "Scroll Wheel";
|
||||
scroll_wheel_zone.type = ZONE_TYPE_SINGLE;
|
||||
scroll_wheel_zone.leds_min = 1;
|
||||
scroll_wheel_zone.leds_max = 1;
|
||||
scroll_wheel_zone.leds_count = 1;
|
||||
scroll_wheel_zone.matrix_map = NULL;
|
||||
|
||||
zones.push_back(scroll_wheel_zone);
|
||||
|
||||
led scroll_wheel_led;
|
||||
|
||||
scroll_wheel_led.name = "Scroll Wheel LED";
|
||||
scroll_wheel_led.value = 1;
|
||||
|
||||
leds.push_back(scroll_wheel_led);
|
||||
|
||||
zone logo_zone;
|
||||
|
||||
logo_zone.name = "Logo";
|
||||
logo_zone.type = ZONE_TYPE_SINGLE;
|
||||
logo_zone.leds_min = 1;
|
||||
logo_zone.leds_max = 1;
|
||||
logo_zone.leds_count = 1;
|
||||
logo_zone.matrix_map = NULL;
|
||||
|
||||
zones.push_back(logo_zone);
|
||||
|
||||
led logo_led;
|
||||
|
||||
logo_led.name = "Logo LED";
|
||||
logo_led.value = 1;
|
||||
|
||||
leds.push_back(logo_led);
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_StrixClaw::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_StrixClaw::DeviceUpdateLEDs()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_StrixClaw::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_StrixClaw::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void RGBController_StrixClaw::DeviceUpdateMode()
|
||||
{
|
||||
if(modes[active_mode].value == 0)
|
||||
{
|
||||
controller->SetScrollWheelLED(false);
|
||||
controller->SetLogoLED(0);
|
||||
|
||||
}
|
||||
else if(modes[active_mode].value == 1)
|
||||
{
|
||||
controller->SetScrollWheelLED(true);
|
||||
controller->SetLogoLED(255);
|
||||
}
|
||||
}
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_AsusStrixClaw.h |
|
||||
| |
|
||||
| RGBController for ASUS Strix Claw mouse |
|
||||
| |
|
||||
| Mola19 06 Aug 2022 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "AsusStrixClawController.h"
|
||||
|
||||
class RGBController_StrixClaw : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_StrixClaw(StrixClawController* controller_ptr);
|
||||
~RGBController_StrixClaw();
|
||||
|
||||
void SetupZones();
|
||||
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
StrixClawController* controller;
|
||||
};
|
||||
Reference in New Issue
Block a user