Initial support for ASUS ROG Ally

This commit is contained in:
Adam Honse 2023-06-15 03:44:07 -07:00
parent 4f30868a3b
commit cc407379fc
6 changed files with 352 additions and 0 deletions

View file

@ -6,6 +6,7 @@
#include "AsusAuraMainboardController.h"
#include "AsusAuraMouseController.h"
#include "AsusAuraMousematController.h"
#include "AsusROGAllyController.h"
#include "AsusAuraStrixEvolveController.h"
#include "AsusAuraMonitorController.h"
#include "AsusAuraRyuoAIOController.h"
@ -16,6 +17,7 @@
#include "RGBController_AsusAuraTUFKeyboard.h"
#include "RGBController_AsusAuraMouse.h"
#include "RGBController_AsusAuraMousemat.h"
#include "RGBController_AsusROGAlly.h"
#include "RGBController_ROGStrixLC_Controller.h"
#include "RGBController_AsusAuraStrixEvolve.h"
#include "RGBController_AsusAuraMonitor.h"
@ -92,6 +94,7 @@
#define AURA_TERMINAL_PID 0x1889
#define ROG_STRIX_LC120_PID 0x879E
#define AURA_RYUO_AIO_PID 0x1887
#define ASUS_ROG_ALLY_PID 0x1ABE
AuraKeyboardMappingLayoutType GetKeyboardMappingLayoutType(int pid)
{
@ -294,6 +297,19 @@ void DetectAsusAuraUSBMonitor(hid_device_info* info, const std::string& name)
}
}
void DetectAsusROGAlly(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
if(dev)
{
ROGAllyController* controller = new ROGAllyController(dev, info->path);
RGBController_AsusROGAlly* rgb_controller = new RGBController_AsusROGAlly(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
/*-----------------------------------------------------------------*\
| MOTHERBOARDS |
\*-----------------------------------------------------------------*/
@ -388,3 +404,4 @@ REGISTER_HID_DETECTOR_PU ("ASUS ROG Ryuo AIO", DetectAs
REGISTER_HID_DETECTOR_I ("ASUS ROG Throne", DetectAsusAuraUSBHeadsetStand, AURA_USB_VID, AURA_ROG_THRONE_PID, 0);
REGISTER_HID_DETECTOR_I ("ASUS ROG Throne QI", DetectAsusAuraUSBHeadsetStand, AURA_USB_VID, AURA_ROG_THRONE_QI_PID, 0);
REGISTER_HID_DETECTOR_I ("ASUS ROG Throne QI GUNDAM", DetectAsusAuraUSBHeadsetStand, AURA_USB_VID, AURA_ROG_THRONE_QI_GUNDAM_PID, 0);
REGISTER_HID_DETECTOR_IPU("ASUS ROG Ally", DetectAsusROGAlly, AURA_USB_VID, ASUS_ROG_ALLY_PID, 2, 0xFF31, 0x0076);

View file

@ -0,0 +1,111 @@
/*-----------------------------------------*\
| AsusROGAllyController.cpp |
| |
| Driver for ASUS ROG Ally lighting |
| controller |
| |
| Adam Honse (CalcProgrammer1) 6/12/2023 |
\*-----------------------------------------*/
#include "AsusROGAllyController.h"
#include <cstring>
ROGAllyController::ROGAllyController(hid_device* dev_handle, const char* path)
{
dev = dev_handle;
location = path;
}
ROGAllyController::~ROGAllyController()
{
hid_close(dev);
}
std::string ROGAllyController::GetDeviceLocation()
{
return("HID: " + location);
}
std::string ROGAllyController::GetSerialString()
{
wchar_t serial_string[128];
int ret = hid_get_serial_number_string(dev, serial_string, 128);
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 ROGAllyController::GetVersion()
{
return("");
}
void ROGAllyController::UpdateLeds
(
std::vector<RGBColor> colors
)
{
unsigned char usb_buf[64];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x5A;
usb_buf[0x01] = 0xD1;
usb_buf[0x02] = 0x08;
usb_buf[0x03] = 0x0C;
for(unsigned int color_idx = 0; color_idx < colors.size(); color_idx++)
{
usb_buf[color_idx * 3 + 4] = RGBGetRValue(colors[color_idx]);
usb_buf[color_idx * 3 + 5] = RGBGetGValue(colors[color_idx]);
usb_buf[color_idx * 3 + 6] = RGBGetBValue(colors[color_idx]);
}
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
}
void ROGAllyController::UpdateDevice
(
unsigned char mode,
std::vector<RGBColor> colors,
unsigned char speed,
unsigned char brightness,
unsigned char pattern
)
{
unsigned char usb_buf[64];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x5A;
usb_buf[0x01] = 0xB3;
usb_buf[0x02] = 0x00;
usb_buf[0x03] = mode;
if(colors.size() > 0)
{
usb_buf[0x04] = RGBGetRValue(colors[0]);
usb_buf[0x05] = RGBGetGValue(colors[0]);
usb_buf[0x06] = RGBGetBValue(colors[0]);
}
usb_buf[0x07] = speed;
if(colors.size() > 1)
{
usb_buf[0x0A] = RGBGetRValue(colors[1]);
usb_buf[0x0B] = RGBGetGValue(colors[1]);
usb_buf[0x0C] = RGBGetBValue(colors[1]);
}
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
}
void ROGAllyController::SaveMode()
{
}

View file

@ -0,0 +1,54 @@
/*-----------------------------------------*\
| AsusROGAllyController.h |
| |
| Definitions and types for ASUS ROG Ally |
| lighting controller |
| |
| Adam Honse (CalcProgrammer1) 6/12/2023 |
\*-----------------------------------------*/
#include "RGBController.h"
#include <hidapi/hidapi.h>
#pragma once
enum
{
ROG_ALLY_MODE_STATIC = 0,
ROG_ALLY_MODE_BREATHING = 1,
ROG_ALLY_MODE_COLOR_CYCLE = 2,
ROG_ALLY_MODE_WAVE = 3,
ROG_ALLY_MODE_STROBING = 10,
ROG_ALLY_MODE_DIRECT = 0xFF,
};
class ROGAllyController
{
public:
ROGAllyController(hid_device* dev_handle, const char* path);
virtual ~ROGAllyController();
std::string GetDeviceLocation();
std::string GetSerialString();
std::string GetVersion();
void UpdateLeds
(
std::vector<RGBColor> colors
);
void UpdateDevice
(
unsigned char mode,
std::vector<RGBColor> colors,
unsigned char speed,
unsigned char brightness,
unsigned char pattern
);
void SaveMode();
private:
hid_device* dev;
std::string location;
};

View file

@ -0,0 +1,132 @@
/*-----------------------------------------*\
| RGBController_AsusROGAlly.cpp |
| |
| Generic RGB Interface for Asus ROG Ally |
| controller driver |
| |
| Adam Honse (CalcProgrammer1) 6/12/2023 |
\*-----------------------------------------*/
#include "RGBController_AsusROGAlly.h"
/**------------------------------------------------------------------*\
@name Asus ROG Ally
@category Gamepad
@type USB
@save :x:
@direct :white_check_mark:
@effects :x:
@detectors DetectAsusROGAlly
@comment
\*-------------------------------------------------------------------*/
RGBController_AsusROGAlly::RGBController_AsusROGAlly(ROGAllyController* controller_ptr)
{
controller = controller_ptr;
name = "ASUS ROG Ally";
vendor = "ASUS";
type = DEVICE_TYPE_GAMEPAD;
description = "ASUS ROG Ally Device";
version = controller->GetVersion();
location = controller->GetDeviceLocation();
serial = controller->GetSerialString();
mode Direct;
Direct.name = "Direct";
Direct.value = 0xFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct);
SetupZones();
}
RGBController_AsusROGAlly::~RGBController_AsusROGAlly()
{
delete controller;
}
void RGBController_AsusROGAlly::SetupZones()
{
zone left_stick_zone;
left_stick_zone.name = "Left Stick";
left_stick_zone.type = ZONE_TYPE_SINGLE;
left_stick_zone.leds_min = 2;
left_stick_zone.leds_max = 2;
left_stick_zone.leds_count = 2;
left_stick_zone.matrix_map = NULL;
zones.push_back(left_stick_zone);
for(unsigned int i = 0; i < 2; i++)
{
led left_stick_led;
left_stick_led.name = "Left Stick LED " + std::to_string(i);
leds.push_back(left_stick_led);
}
zone right_stick_zone;
right_stick_zone.name = "Left Stick";
right_stick_zone.type = ZONE_TYPE_SINGLE;
right_stick_zone.leds_min = 2;
right_stick_zone.leds_max = 2;
right_stick_zone.leds_count = 2;
right_stick_zone.matrix_map = NULL;
zones.push_back(right_stick_zone);
for(unsigned int i = 0; i < 2; i++)
{
led right_stick_led;
right_stick_led.name = "Right Stick LED " + std::to_string(i);
leds.push_back(right_stick_led);
}
SetupColors();
}
void RGBController_AsusROGAlly::ResizeZone(int /*zone*/, int /*new_size*/)
{
/*---------------------------------------------------------*\
| This device does not support resizing zones |
\*---------------------------------------------------------*/
}
void RGBController_AsusROGAlly::DeviceUpdateLEDs()
{
if(modes[active_mode].value == 0xFF)
{
controller->UpdateLeds(std::vector<RGBColor>(colors));
}
}
void RGBController_AsusROGAlly::UpdateZoneLEDs(int /*zone*/)
{
DeviceUpdateLEDs();
}
void RGBController_AsusROGAlly::UpdateSingleLED(int /*led*/)
{
DeviceUpdateLEDs();
}
void RGBController_AsusROGAlly::DeviceUpdateMode()
{
if(modes[active_mode].value == 0xFF)
{
DeviceUpdateLEDs();
}
}
void RGBController_AsusROGAlly::DeviceSaveMode()
{
DeviceUpdateMode();
controller->SaveMode();
}

View file

@ -0,0 +1,34 @@
/*-----------------------------------------*\
| RGBController_AsusROGAlly.cpp |
| |
| Generic RGB Interface for Asus ROG Ally |
| controller driver |
| |
| Adam Honse (CalcProgrammer1) 6/12/2023 |
\*-----------------------------------------*/
#pragma once
#include "RGBController.h"
#include "AsusROGAllyController.h"
class RGBController_AsusROGAlly : public RGBController
{
public:
RGBController_AsusROGAlly(ROGAllyController* controller_ptr);
~RGBController_AsusROGAlly();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceSaveMode();
private:
ROGAllyController* controller;
};

View file

@ -199,6 +199,8 @@ contains(QMAKE_PLATFORM, freebsd) {
HEADERS += \
Colors.h \
Controllers/AsusAuraUSBController/AsusROGAllyController.h \
Controllers/AsusAuraUSBController/RGBController_AsusROGAlly.h \
dependencies/ColorWheel/ColorWheel.h \
dependencies/Swatches/swatches.h \
dependencies/json/json.hpp \
@ -742,6 +744,8 @@ contains(QMAKE_PLATFORM, freebsd) {
}
SOURCES += \
Controllers/AsusAuraUSBController/AsusROGAllyController.cpp \
Controllers/AsusAuraUSBController/RGBController_AsusROGAlly.cpp \
dependencies/Swatches/swatches.cpp \
dependencies/dmiinfo.cpp \
dependencies/ColorWheel/ColorWheel.cpp \