mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-14 01:24:39 -04:00
@@ -805,6 +805,11 @@ SUBSYSTEMS=="usb", ATTR{idVendor}=="264a", ATTR{idProduct}=="1FA[A-F]", TAG+="ua
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="264a", ATTR{idProduct}=="1FB[0-5]", TAG+="uaccess"
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="264a", ATTR{idProduct}=="226[0-3]", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# ThingM Controllers #
|
||||
#---------------------------------------------------------------#
|
||||
SUBSYSTEMS=="usb", ATTR{idVendor}=="27B8", ATTR{idProduct}=="01ED", TAG+="uaccess"
|
||||
|
||||
#---------------------------------------------------------------#
|
||||
# Wooting Devices #
|
||||
#---------------------------------------------------------------#
|
||||
|
||||
78
Controllers/ThingMController/BlinkController.cpp
Normal file
78
Controllers/ThingMController/BlinkController.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| BlinkController.cpp |
|
||||
| |
|
||||
| Driver for ThingM Blink device |
|
||||
| |
|
||||
| Eric S (edbgon) 1st Oct 2021 |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "BlinkController.h"
|
||||
#include <cstring>
|
||||
|
||||
BlinkController::BlinkController(hid_device* dev_handle, char *_path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = _path;
|
||||
|
||||
const int szTemp = 256;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
std::wstring wName = std::wstring(tmpName);
|
||||
device_name = std::string(wName.begin(), wName.end());
|
||||
|
||||
hid_get_product_string(dev, tmpName, szTemp);
|
||||
wName = std::wstring(tmpName);
|
||||
device_name.append(" ").append(std::string(wName.begin(), wName.end()));
|
||||
|
||||
hid_get_serial_number_string(dev, tmpName, szTemp);
|
||||
wName = std::wstring(tmpName);
|
||||
serial = std::string(wName.begin(), wName.end());
|
||||
|
||||
}
|
||||
|
||||
BlinkController::~BlinkController()
|
||||
{
|
||||
if(dev)
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
}
|
||||
|
||||
std::string BlinkController::GetDeviceName()
|
||||
{
|
||||
return device_name;
|
||||
}
|
||||
|
||||
std::string BlinkController::GetSerial()
|
||||
{
|
||||
return serial;
|
||||
}
|
||||
|
||||
std::string BlinkController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
void BlinkController::SendUpdate(unsigned char led, unsigned char red, unsigned char green, unsigned char blue, unsigned int speed)
|
||||
{
|
||||
|
||||
unsigned char buffer[BLINK_PACKET_SIZE] = { 0x00 };
|
||||
memset(buffer, 0x00, BLINK_PACKET_SIZE);
|
||||
|
||||
buffer[0x00] = 0x01;
|
||||
buffer[0x01] = 0x63;
|
||||
buffer[0x02] = red;
|
||||
buffer[0x03] = green;
|
||||
buffer[0x04] = blue;
|
||||
|
||||
if(speed > 0)
|
||||
{
|
||||
buffer[0x05] = (speed & 0xff00) >> 8;
|
||||
buffer[0x06] = speed & 0x00ff;
|
||||
}
|
||||
|
||||
buffer[0x07] = led;
|
||||
|
||||
hid_send_feature_report(dev, buffer, BLINK_PACKET_SIZE);
|
||||
}
|
||||
49
Controllers/ThingMController/BlinkController.h
Normal file
49
Controllers/ThingMController/BlinkController.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| BlinkController.h |
|
||||
| |
|
||||
| Driver for ThingM Blink device |
|
||||
| |
|
||||
| Eric S (edbgon) 1st Oct 2021 |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include <string>
|
||||
#include <array>
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#pragma once
|
||||
|
||||
#define BLINK_PACKET_SIZE 9 //Includes extra first byte for non HID Report packets
|
||||
|
||||
#define BLINK_MODE_OFF 0
|
||||
#define BLINK_MODE_DIRECT 1
|
||||
#define BLINK_MODE_FADE 2
|
||||
|
||||
class BlinkController
|
||||
{
|
||||
public:
|
||||
BlinkController(hid_device* dev_handle, char *_path);
|
||||
~BlinkController();
|
||||
|
||||
std::string GetDeviceName();
|
||||
std::string GetSerial();
|
||||
std::string GetLocation();
|
||||
|
||||
unsigned char GetLedRed();
|
||||
unsigned char GetLedGreen();
|
||||
unsigned char GetLedBlue();
|
||||
unsigned char GetLedSpeed();
|
||||
unsigned char GetBrightness();
|
||||
void SendUpdate(unsigned char led, unsigned char red, unsigned char green, unsigned char blue, unsigned int speed);
|
||||
|
||||
private:
|
||||
std::string device_name;
|
||||
std::string serial;
|
||||
std::string location;
|
||||
hid_device* dev;
|
||||
|
||||
unsigned char current_red;
|
||||
unsigned char current_green;
|
||||
unsigned char current_blue;
|
||||
|
||||
void SendUpdate();
|
||||
};
|
||||
123
Controllers/ThingMController/RGBController_BlinkController.cpp
Normal file
123
Controllers/ThingMController/RGBController_BlinkController.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_BlinkController.cpp |
|
||||
| |
|
||||
| Driver for ThingM Blink device |
|
||||
| |
|
||||
| Eric S (edbgon) 1st Oct 2021 |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#include "RGBController_BlinkController.h"
|
||||
|
||||
RGBController_BlinkController::RGBController_BlinkController(BlinkController* blink_ptr)
|
||||
{
|
||||
Blink = blink_ptr;
|
||||
|
||||
name = "Blink";
|
||||
vendor = "ThingM";
|
||||
type = DEVICE_TYPE_LEDSTRIP;
|
||||
description = Blink->GetDeviceName();
|
||||
version = "1.0";
|
||||
serial = Blink->GetSerial();
|
||||
location = Blink->GetLocation();
|
||||
|
||||
mode Off;
|
||||
Off.name = "Off";
|
||||
Off.flags = 0;
|
||||
Off.value = BLINK_MODE_OFF;
|
||||
Off.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Off);
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = BLINK_MODE_DIRECT;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
Direct.colors_min = 1;
|
||||
Direct.colors_max = 1;
|
||||
Direct.colors.resize(1);
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Fade;
|
||||
Fade.name = "Fade";
|
||||
Fade.value = BLINK_MODE_FADE;
|
||||
Fade.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_SPEED;
|
||||
Fade.color_mode = MODE_COLORS_PER_LED;
|
||||
Fade.speed_min = 0xFFFF;
|
||||
Fade.speed = 0x0000;
|
||||
Fade.speed_max = 0x0000;
|
||||
Fade.colors_min = 1;
|
||||
Fade.colors_max = 1;
|
||||
Fade.colors.resize(1);
|
||||
modes.push_back(Fade);
|
||||
|
||||
SetupZones();
|
||||
active_mode = 1;
|
||||
}
|
||||
|
||||
RGBController_BlinkController::~RGBController_BlinkController()
|
||||
{
|
||||
delete Blink;
|
||||
}
|
||||
|
||||
void RGBController_BlinkController::SetupZones()
|
||||
{
|
||||
zone Blink_zone;
|
||||
Blink_zone.name = "blink(1) mk2";
|
||||
Blink_zone.type = ZONE_TYPE_SINGLE;
|
||||
Blink_zone.leds_min = 2;
|
||||
Blink_zone.leds_max = 2;
|
||||
Blink_zone.leds_count = 2;
|
||||
Blink_zone.matrix_map = NULL;
|
||||
zones.push_back(Blink_zone);
|
||||
|
||||
led Blink_led;
|
||||
Blink_led.name = "LED A";
|
||||
Blink_led.value = 1;
|
||||
leds.push_back(Blink_led);
|
||||
|
||||
Blink_led.name = "LED B";
|
||||
Blink_led.value = 2;
|
||||
leds.push_back(Blink_led);
|
||||
|
||||
SetupColors();
|
||||
|
||||
}
|
||||
|
||||
void RGBController_BlinkController::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_BlinkController::DeviceUpdateLEDs()
|
||||
{
|
||||
for (std::size_t led = 0; led < colors.size(); led++)
|
||||
{
|
||||
UpdateSingleLED(led);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_BlinkController::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_BlinkController::UpdateSingleLED(int led)
|
||||
{
|
||||
unsigned char red = RGBGetRValue(colors[led]);
|
||||
unsigned char grn = RGBGetGValue(colors[led]);
|
||||
unsigned char blu = RGBGetBValue(colors[led]);
|
||||
|
||||
Blink->SendUpdate(leds[led].value, red, grn, blu, modes[active_mode].speed);
|
||||
}
|
||||
|
||||
void RGBController_BlinkController::SetCustomMode()
|
||||
{
|
||||
active_mode = 1;
|
||||
}
|
||||
|
||||
void RGBController_BlinkController::DeviceUpdateMode()
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
32
Controllers/ThingMController/RGBController_BlinkController.h
Normal file
32
Controllers/ThingMController/RGBController_BlinkController.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*-------------------------------------------------------------------*\
|
||||
| RGBController_BlinkController.h |
|
||||
| |
|
||||
| Driver for ThingM Blink device |
|
||||
| |
|
||||
| Eric S (edbgon) 1st Oct 2021 |
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
#include "RGBController.h"
|
||||
#include "BlinkController.h"
|
||||
|
||||
class RGBController_BlinkController : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_BlinkController(BlinkController* blink_ptr);
|
||||
~RGBController_BlinkController();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void SetCustomMode();
|
||||
void DeviceUpdateMode();
|
||||
private:
|
||||
BlinkController* Blink;
|
||||
|
||||
int GetDeviceMode();
|
||||
};
|
||||
31
Controllers/ThingMController/ThingMControllerDetect.cpp
Normal file
31
Controllers/ThingMController/ThingMControllerDetect.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "Detector.h"
|
||||
#include "BlinkController.h"
|
||||
#include "RGBController.h"
|
||||
#include "RGBController_BlinkController.h"
|
||||
#include <hidapi/hidapi.h>
|
||||
|
||||
#define THINGM_VID 0x27B8
|
||||
|
||||
#define THINGM_BLINK_PID 0x01ED
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectThingMControllers *
|
||||
* *
|
||||
* Tests the USB address to see if any CoolerMaster controllers exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectThingMBlink(hid_device_info* info, const std::string&)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if(dev)
|
||||
{
|
||||
BlinkController* controller = new BlinkController(dev, info->path);
|
||||
RGBController_BlinkController* rgb_controller = new RGBController_BlinkController(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_HID_DETECTOR_IPU ("ThingM blink(1) mk2", DetectThingMBlink, THINGM_VID, THINGM_BLINK_PID, 1, 0xFF00, 0x01);
|
||||
@@ -442,6 +442,8 @@ HEADERS +=
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingController.h \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingQuadController.h \
|
||||
Controllers/ThermaltakeRiingController/RGBController_ThermaltakeRiing.h \
|
||||
Controllers/ThingMController/BlinkController.h \
|
||||
Controllers/ThingMController/RGBController_BlinkController.h \
|
||||
Controllers/WootingKeyboardController/WootingKeyboardController.h \
|
||||
Controllers/WootingKeyboardController/WootingOneKeyboardController.h \
|
||||
Controllers/WootingKeyboardController/WootingTwoKeyboardController.h \
|
||||
@@ -841,6 +843,9 @@ SOURCES +=
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingQuadController.cpp \
|
||||
Controllers/ThermaltakeRiingController/ThermaltakeRiingControllerDetect.cpp \
|
||||
Controllers/ThermaltakeRiingController/RGBController_ThermaltakeRiing.cpp \
|
||||
Controllers/ThingMController/ThingMControllerDetect.cpp \
|
||||
Controllers/ThingMController/BlinkController.cpp \
|
||||
Controllers/ThingMController/RGBController_BlinkController.cpp \
|
||||
Controllers/WootingKeyboardController/WootingKeyboardController.cpp \
|
||||
Controllers/WootingKeyboardController/WootingKeyboardControllerDetect.cpp \
|
||||
Controllers/WootingKeyboardController/WootingOneKeyboardController.cpp \
|
||||
|
||||
Reference in New Issue
Block a user