Adds Trust GXT 114 support
This commit is contained in:
parent
6709cfb735
commit
e1f0cd785d
7 changed files with 387 additions and 0 deletions
|
|
@ -848,6 +848,11 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="264a", ATTR{idProduct}=="226[0-3]", TAG+="ua
|
|||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="27b8", ATTR{idProduct}=="01ed", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Trust Controllers #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="145f", ATTR{idProduct}=="026d", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Wooting Devices #
|
||||
#---------------------------------------------------------------#
|
||||
|
|
|
|||
126
Controllers/TrustGXT114Controller/RGBController_TrustGXT114.cpp
Normal file
126
Controllers/TrustGXT114Controller/RGBController_TrustGXT114.cpp
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_TrustGXT114.cpp |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| Trust GXT 114 USB Driver |
|
||||
| |
|
||||
| Guimard Morgan (morg) 1/24/2022 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "RGBController_TrustGXT114.h"
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
RGBController_TrustGXT114::RGBController_TrustGXT114(TrustGXT114Controller* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
name = "Trust GXT 114";
|
||||
vendor = "Trust";
|
||||
type = DEVICE_TYPE_MOUSE;
|
||||
description = name;
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
version = controller->GetFirmwareVersion();
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = STATIC_MODE_VALUE;
|
||||
Static.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_BRIGHTNESS | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Static.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Static.colors_min = 1;
|
||||
Static.colors_max = 1;
|
||||
Static.brightness_min = TRUST_GXT_114_BRIGHTNESS_MIN;
|
||||
Static.brightness_max = TRUST_GXT_114_BRIGHTNESS_MAX;
|
||||
Static.brightness = TRUST_GXT_114_BRIGHTNESS_MAX;
|
||||
Static.colors.resize(1);
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Breathing;
|
||||
Breathing.name = "Breathing";
|
||||
Breathing.value = BREATHING_MODE_VALUE;
|
||||
Breathing.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Breathing.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Breathing.colors_min = 1;
|
||||
Breathing.colors_max = 1;
|
||||
Breathing.speed_min = TRUST_GXT_114_SPEED_MIN;
|
||||
Breathing.speed_max = TRUST_GXT_114_SPEED_MAX;
|
||||
Breathing.speed = TRUST_GXT_114_SPEED_MIN;
|
||||
Breathing.colors.resize(1);
|
||||
modes.push_back(Breathing);
|
||||
|
||||
mode Blink;
|
||||
Blink.name = "Blink";
|
||||
Blink.value = BLINK_MODE_VALUE;
|
||||
Blink.flags = MODE_FLAG_HAS_MODE_SPECIFIC_COLOR | MODE_FLAG_HAS_SPEED | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Blink.color_mode = MODE_COLORS_MODE_SPECIFIC;
|
||||
Blink.colors_min = 1;
|
||||
Blink.colors_max = 1;
|
||||
Blink.speed_min = TRUST_GXT_114_SPEED_MIN;
|
||||
Blink.speed_max = TRUST_GXT_114_SPEED_MAX;
|
||||
Blink.speed = TRUST_GXT_114_SPEED_MIN;
|
||||
Blink.colors.resize(1);
|
||||
modes.push_back(Blink);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_TrustGXT114::~RGBController_TrustGXT114()
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_TrustGXT114::SetupZones()
|
||||
{
|
||||
zone new_zone;
|
||||
|
||||
new_zone.name = "Mouse";
|
||||
new_zone.type = ZONE_TYPE_LINEAR;
|
||||
new_zone.leds_min = TRUST_GXT_114_NUMBER_OF_LEDS;
|
||||
new_zone.leds_max = TRUST_GXT_114_NUMBER_OF_LEDS;
|
||||
new_zone.leds_count = TRUST_GXT_114_NUMBER_OF_LEDS;
|
||||
new_zone.matrix_map = nullptr;
|
||||
|
||||
zones.emplace_back(new_zone);
|
||||
|
||||
leds.resize(new_zone.leds_count);
|
||||
|
||||
for(unsigned int i = 0; i < TRUST_GXT_114_NUMBER_OF_LEDS; i++)
|
||||
{
|
||||
leds[i].name = "LED " + std::to_string(i);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_TrustGXT114::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_TrustGXT114::DeviceUpdateLEDs()
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_TrustGXT114::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_TrustGXT114::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateMode();
|
||||
}
|
||||
|
||||
void RGBController_TrustGXT114::SetCustomMode()
|
||||
{
|
||||
active_mode = 0;
|
||||
}
|
||||
|
||||
void RGBController_TrustGXT114::DeviceUpdateMode()
|
||||
{
|
||||
controller->SetMode(modes[active_mode].colors[0], modes[active_mode].brightness, modes[active_mode].speed, modes[active_mode].value);
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
/*-----------------------------------------*\
|
||||
| RGBController_TrustGXT114.h |
|
||||
| |
|
||||
| Generic RGB Interface for OpenRGB |
|
||||
| Trust GXT 114 USB Driver |
|
||||
| |
|
||||
| Guimard Morgan (morg) 1/24/2022 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "TrustGXT114Controller.h"
|
||||
|
||||
class RGBController_TrustGXT114 : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_TrustGXT114(TrustGXT114Controller* controller_ptr);
|
||||
~RGBController_TrustGXT114();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
void DeviceUpdateMode();
|
||||
void SetCustomMode();
|
||||
|
||||
private:
|
||||
TrustGXT114Controller* controller;
|
||||
};
|
||||
126
Controllers/TrustGXT114Controller/TrustGXT114Controller.cpp
Normal file
126
Controllers/TrustGXT114Controller/TrustGXT114Controller.cpp
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
/*-----------------------------------------*\
|
||||
| TrustGXT114Controller.cpp |
|
||||
| |
|
||||
| Driver for Trust GXT 114 controller |
|
||||
| |
|
||||
| Guimard Morgan (morg) 1/24/2022 |
|
||||
\*-----------------------------------------*/
|
||||
#include "TrustGXT114Controller.h"
|
||||
#include <string.h>
|
||||
|
||||
TrustGXT114Controller::TrustGXT114Controller(hid_device* dev_handle, const hid_device_info& info)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = info.path;
|
||||
version = "";
|
||||
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
serial_number = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring return_wstring = serial_string;
|
||||
serial_number = std::string(return_wstring.begin(), return_wstring.end());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TrustGXT114Controller::~TrustGXT114Controller()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string TrustGXT114Controller::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string TrustGXT114Controller::GetSerialString()
|
||||
{
|
||||
return(serial_number);
|
||||
}
|
||||
|
||||
std::string TrustGXT114Controller::GetFirmwareVersion()
|
||||
{
|
||||
return(version);
|
||||
}
|
||||
|
||||
bool TrustGXT114Controller::Test()
|
||||
{
|
||||
/*-----------------------------------------*\
|
||||
| Send a get feature report, filtering out |
|
||||
| hid devices that do not anwser. |
|
||||
\*-----------------------------------------*/
|
||||
uint8_t usb_buf[TRUST_GXT_114_REPORT_SIZE] = { TRUST_GXT_114_REPORT_ID };
|
||||
return hid_get_feature_report(dev, usb_buf, TRUST_GXT_114_REPORT_SIZE) > 0;
|
||||
}
|
||||
|
||||
void TrustGXT114Controller::SetMode(RGBColor color, unsigned char brightness, unsigned char speed, unsigned char mode_value)
|
||||
{
|
||||
unsigned char speed_bright = mode_value == STATIC_MODE_VALUE ? brightness : speed;
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Create and zero out the buffer |
|
||||
\*-----------------------------------------*/
|
||||
unsigned char usb_buf[TRUST_GXT_114_REPORT_SIZE];
|
||||
memset(usb_buf, 0x00, sizeof(usb_buf));
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Fill dynamic data |
|
||||
\*-----------------------------------------*/
|
||||
usb_buf[0] = TRUST_GXT_114_REPORT_ID;
|
||||
|
||||
usb_buf[93] = mode_value;
|
||||
usb_buf[94] = 0x00; // freq (extra param, let's default it)
|
||||
usb_buf[95] = 0x00; // times (extra param, let's default it)
|
||||
usb_buf[96] = speed_bright; // speed or brightness depending on the mode
|
||||
|
||||
usb_buf[103] = RGBGetRValue(color); // r
|
||||
usb_buf[104] = RGBGetGValue(color); // g
|
||||
usb_buf[105] = RGBGetBValue(color); // b
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Fill the constant data bytes |
|
||||
\*-----------------------------------------*/
|
||||
for(unsigned int i = 79 ; i <= 89; i++)
|
||||
{
|
||||
usb_buf[i] = 0x80;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> values_FF =
|
||||
{
|
||||
101, 108, 109, 113, 114, 115, 117, 118, 119, 124, 127, 128,
|
||||
131, 134, 135, 138, 139, 141, 142, 143, 144
|
||||
};
|
||||
|
||||
for(unsigned i = 0; i < values_FF.size(); i ++)
|
||||
{
|
||||
usb_buf[values_FF[i]] = 0xff;
|
||||
}
|
||||
|
||||
usb_buf[8] = 0x4c; // constant data
|
||||
|
||||
usb_buf[71] = 0x11; // constant data
|
||||
usb_buf[72] = 0xb0; // constant data
|
||||
usb_buf[74] = 0x89; // constant data
|
||||
usb_buf[75] = 0x0e; // constant data
|
||||
usb_buf[76] = 0x9d; // constant data
|
||||
usb_buf[77] = 0xa7; // constant data
|
||||
usb_buf[78] = 0xb7; // constant data
|
||||
|
||||
usb_buf[148] = 0x58; // constant data
|
||||
usb_buf[149] = 0x30; // constant data
|
||||
usb_buf[150] = 0x31; // constant data
|
||||
usb_buf[151] = 0x30; // constant data
|
||||
usb_buf[152] = 0x31; // constant data
|
||||
usb_buf[153] = 0x30; // constant data
|
||||
|
||||
/*-----------------------------------------*\
|
||||
| Send the feature report |
|
||||
\*-----------------------------------------*/
|
||||
hid_send_feature_report(dev, usb_buf, TRUST_GXT_114_REPORT_SIZE);
|
||||
}
|
||||
57
Controllers/TrustGXT114Controller/TrustGXT114Controller.h
Normal file
57
Controllers/TrustGXT114Controller/TrustGXT114Controller.h
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*-----------------------------------------*\
|
||||
| TrustGXT114Controller.h |
|
||||
| |
|
||||
| Driver for Trust GXT 114 |
|
||||
| controller - header file |
|
||||
| |
|
||||
| Guimard Morgan (morg) 1/24/2022 |
|
||||
\*-----------------------------------------*/
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include <string>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define TRUST_GXT_114_REPORT_SIZE 154
|
||||
#define TRUST_GXT_114_NUMBER_OF_LEDS 1
|
||||
#define TRUST_GXT_114_REPORT_ID 0x04
|
||||
|
||||
enum
|
||||
{
|
||||
STATIC_MODE_VALUE = 0x28,
|
||||
BREATHING_MODE_VALUE = 0x22,
|
||||
BLINK_MODE_VALUE = 0x42
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TRUST_GXT_114_BRIGHTNESS_MIN = 0x12,
|
||||
TRUST_GXT_114_BRIGHTNESS_MAX = 0xA2
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TRUST_GXT_114_SPEED_MIN = 0x12,
|
||||
TRUST_GXT_114_SPEED_MAX = 0x62
|
||||
};
|
||||
|
||||
class TrustGXT114Controller
|
||||
{
|
||||
public:
|
||||
TrustGXT114Controller(hid_device* dev_handle, const hid_device_info& info);
|
||||
~TrustGXT114Controller();
|
||||
|
||||
std::string GetSerialString();
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetFirmwareVersion();
|
||||
bool Test();
|
||||
void SetMode(RGBColor color, unsigned char brightness, unsigned char speed, unsigned char mode_value);
|
||||
|
||||
protected:
|
||||
hid_device* dev;
|
||||
|
||||
private:
|
||||
std::string location;
|
||||
std::string serial_number;
|
||||
std::string version;
|
||||
};
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
#include "Detector.h"
|
||||
#include "TrustGXT114Controller.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_TrustGXT114.h"
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Trust vendor ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define TRUST_VID 0x145F
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Product ID |
|
||||
\*---------------------------------------------------------*/
|
||||
#define TRUST_GXT_114_PID 0x026D
|
||||
|
||||
void DetectTrustGXT114ControllerControllers(hid_device_info* info, const std::string& name)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
|
||||
if(dev)
|
||||
{
|
||||
TrustGXT114Controller* controller = new TrustGXT114Controller(dev, *info);
|
||||
|
||||
if(controller->Test())
|
||||
{
|
||||
RGBController_TrustGXT114* rgb_controller = new RGBController_TrustGXT114(controller);
|
||||
rgb_controller->name = name;
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete controller;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU("Trust GXT 114", DetectTrustGXT114ControllerControllers, TRUST_VID, TRUST_GXT_114_PID, 1, 0xFF00, 1);
|
||||
|
|
@ -485,6 +485,8 @@ HEADERS +=
|
|||
Controllers/ThermaltakeRiingController/RGBController_ThermaltakeRiing.h \
|
||||
Controllers/ThingMController/BlinkController.h \
|
||||
Controllers/ThingMController/RGBController_BlinkController.h \
|
||||
Controllers/TrustGXT114Controller/RGBController_TrustGXT114.h \
|
||||
Controllers/TrustGXT114Controller/TrustGXT114Controller.h \
|
||||
Controllers/WootingKeyboardController/WootingKeyboardController.h \
|
||||
Controllers/WootingKeyboardController/WootingOneKeyboardController.h \
|
||||
Controllers/WootingKeyboardController/WootingTwoKeyboardController.h \
|
||||
|
|
@ -926,6 +928,9 @@ SOURCES +=
|
|||
Controllers/ThingMController/ThingMControllerDetect.cpp \
|
||||
Controllers/ThingMController/BlinkController.cpp \
|
||||
Controllers/ThingMController/RGBController_BlinkController.cpp \
|
||||
Controllers/TrustGXT114Controller/TrustGXT114Controller.cpp \
|
||||
Controllers/TrustGXT114Controller/TrustGXT114ControllerDetect.cpp \
|
||||
Controllers/TrustGXT114Controller/RGBController_TrustGXT114.cpp \
|
||||
Controllers/WootingKeyboardController/WootingKeyboardController.cpp \
|
||||
Controllers/WootingKeyboardController/WootingKeyboardControllerDetect.cpp \
|
||||
Controllers/WootingKeyboardController/WootingOneKeyboardController.cpp \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue