Support for Asus Strix Claw

This commit is contained in:
Mola19 2022-08-08 15:06:53 +00:00 committed by Adam Honse
parent f1860bf742
commit f637d64dcb
6 changed files with 334 additions and 0 deletions

View file

@ -0,0 +1,26 @@
#include "Detector.h"
#include "AsusStrixClawController.h"
#include "RGBController.h"
#include "RGBController_AsusStrixClaw.h"
#include <stdexcept>
#include <hidapi/hidapi.h>
#include "dependencies/dmiinfo.h"
#define ASUS_LEGACY_USB_VID 0x195D
#define ASUS_ROG_STRIX_CLAW_PID 0x1016
void DetectAsusStrixClaw(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
StrixClawController* controller = new StrixClawController(dev, info->path);
RGBController_StrixClaw* rgb_controller = new RGBController_StrixClaw(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR_IPU("ASUS ROG Strix Claw", DetectAsusStrixClaw, ASUS_LEGACY_USB_VID, ASUS_ROG_STRIX_CLAW_PID, 0, 0xFF01, 1);

View file

@ -0,0 +1,97 @@
/*-----------------------------------------*\
| AsusStrixClawController.cpp |
| |
| Driver for ASUS Strix USB |
| lighting controller |
| |
| Mola19 08/06/2022 |
\*-----------------------------------------*/
#include "AsusStrixClawController.h"
#include <cstring>
#include <string>
StrixClawController::StrixClawController(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
}
StrixClawController::~StrixClawController()
{
hid_close(dev);
}
std::string StrixClawController::GetDeviceLocation()
{
return("HID: " + location);
}
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("");
}
std::wstring return_wstring = serial_string;
std::string return_string(return_wstring.begin(), return_wstring.end());
return(return_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);
}

View file

@ -0,0 +1,35 @@
/*-----------------------------------------*\
| AsusStrixClawController.h |
| |
| Definitions and types for ASUS |
| Legacy USB RGB lighting controller |
| |
| Mola19 08/06/2022 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <string>
#include <hidapi/hidapi.h>
#pragma once
#define HID_MAX_STR 255
class StrixClawController
{
public:
StrixClawController(hid_device* dev_handle, const char* path);
virtual ~StrixClawController();
std::string GetDeviceLocation();
std::string GetSerialString();
std::string GetVersion();
void SetScrollWheelLED(bool OnOff);
void SetLogoLED(uint8_t brightness);
private:
hid_device* dev;
std::string location;
};

View file

@ -0,0 +1,137 @@
/*-----------------------------------------*\
| RGBController_AsusStrixClaw.cpp |
| |
| Generic RGB Interface for Asus |
| Legacy USB controller driver |
| |
| Mola19 08/06/2022 |
\*-----------------------------------------*/
#include "RGBController_AsusStrixClaw.h"
/**------------------------------------------------------------------*\
@name Asus Aura Strix Evolve
@category Mouse
@type USB
@save :robot:
@direct :x:
@effects :tools:
@detectors DetectAsusAuraUSBStrixEvolve
@comment
\*-------------------------------------------------------------------*/
RGBController_StrixClaw::RGBController_StrixClaw(StrixClawController* controller_ptr)
{
controller = controller_ptr;
name = "ASUS ROG Strix Claw";
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::SetCustomMode()
{
}
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);
}
}

View file

@ -0,0 +1,34 @@
/*-----------------------------------------*\
| RGBController_AsusStrixClaw.h |
| |
| Generic RGB Interface for Asus |
| Legacy USB controller driver |
| |
| Mola19 08/06/2022 |
\*-----------------------------------------*/
#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 SetCustomMode();
void DeviceUpdateMode();
private:
StrixClawController* controller;
};

View file

@ -284,6 +284,8 @@ HEADERS +=
Controllers/AsusAuraUSBController/RGBController_AsusAuraUSB.h \
Controllers/AsusAuraUSBController/RGBController_ROGStrixLC_Controller.h \
Controllers/AsusAuraUSBController/ROGStrixLC_Controller.h \
Controllers/AsusLegacyUSBController/AsusStrixClawController.h \
Controllers/AsusLegacyUSBController/RGBController_AsusStrixClaw.h \
Controllers/BlinkyTapeController/BlinkyTapeController.h \
Controllers/BlinkyTapeController/RGBController_BlinkyTape.h \
Controllers/CoolerMasterController/CMARGBcontroller.h \
@ -758,6 +760,9 @@ SOURCES +=
Controllers/AsusAuraUSBController/RGBController_AsusAuraUSB.cpp \
Controllers/AsusAuraUSBController/RGBController_ROGStrixLC_Controller.cpp \
Controllers/AsusAuraUSBController/ROGStrixLC_Controller.cpp \
Controllers/AsusLegacyUSBController/AsusStrixClawController.cpp \
Controllers/AsusLegacyUSBController/AsusLegacyUSBControllerDetect.cpp \
Controllers/AsusLegacyUSBController/RGBController_AsusStrixClaw.cpp \
Controllers/BlinkyTapeController/BlinkyTapeController.cpp \
Controllers/BlinkyTapeController/BlinkyTapeControllerDetect.cpp \
Controllers/BlinkyTapeController/RGBController_BlinkyTape.cpp \