Publish LumaOps source
This commit is contained in:
+294
@@ -0,0 +1,294 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_ThermaltakePoseidonZRGB.cpp |
|
||||
| |
|
||||
| RGBController for Thermaltake Poseidon Z RGB |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 25 Dec 2019 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include "RGBControllerKeyNames.h"
|
||||
#include "RGBController_ThermaltakePoseidonZRGB.h"
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
|
||||
static unsigned int matrix_map[6][23] =
|
||||
{ { 0, NA, 8, 15, 22, 29, NA, 37, 44, 51, 58, NA, 65, 73, 81, 88, 94, 100, 102, NA, NA, NA, NA },
|
||||
{ 1, 9, 16, 23, 30, 38, 45, 52, 59, 66, 74, NA, 82, 89, 103, NA, 7, 21, 36, 50, 64, 80, 93 },
|
||||
{ 2, NA, 10, 17, 24, 31, NA, 39, 46, 53, 60, 67, 75, 83, 90, 95, 14, 28, 43, 57, 72, 87, 86 },
|
||||
{ 3, NA, 11, 18, 25, 32, NA, 40, 47, 54, 61, 68, 76, 84, 96, NA, NA, NA, NA, 35, 99, 63, NA },
|
||||
{ 4, NA, 26, 33, 41, 48, NA, 55, NA, 62, 69, 77, 85, 91, 101, NA, NA, 27, NA, 42, 49, 71, 98 },
|
||||
{ 5, 12, 19, NA, NA, NA, NA, 34, NA, NA, NA, NA, 70, 78, 92, 97, 6, 13, 20, 56, NA, 79, NA } };
|
||||
|
||||
static const char* zone_names[] =
|
||||
{
|
||||
ZONE_EN_KEYBOARD
|
||||
};
|
||||
|
||||
static zone_type zone_types[] =
|
||||
{
|
||||
ZONE_TYPE_MATRIX,
|
||||
};
|
||||
|
||||
static const unsigned int zone_sizes[] =
|
||||
{
|
||||
104
|
||||
};
|
||||
|
||||
static const char* led_names[] =
|
||||
{
|
||||
KEY_EN_ESCAPE,
|
||||
KEY_EN_BACK_TICK,
|
||||
KEY_EN_TAB,
|
||||
KEY_EN_CAPS_LOCK,
|
||||
KEY_EN_LEFT_SHIFT,
|
||||
KEY_EN_LEFT_CONTROL,
|
||||
KEY_EN_LEFT_ARROW,
|
||||
KEY_EN_INSERT,
|
||||
KEY_EN_F1,
|
||||
KEY_EN_1,
|
||||
KEY_EN_Q,
|
||||
KEY_EN_A,
|
||||
KEY_EN_LEFT_WINDOWS,
|
||||
KEY_EN_DOWN_ARROW,
|
||||
KEY_EN_DELETE,
|
||||
KEY_EN_F2,
|
||||
KEY_EN_2,
|
||||
KEY_EN_W,
|
||||
KEY_EN_S,
|
||||
KEY_EN_LEFT_ALT,
|
||||
KEY_EN_RIGHT_ARROW,
|
||||
KEY_EN_HOME,
|
||||
KEY_EN_F3,
|
||||
KEY_EN_3,
|
||||
KEY_EN_E,
|
||||
KEY_EN_D,
|
||||
KEY_EN_Z,
|
||||
KEY_EN_UP_ARROW,
|
||||
KEY_EN_END,
|
||||
KEY_EN_F4,
|
||||
KEY_EN_4,
|
||||
KEY_EN_R,
|
||||
KEY_EN_F,
|
||||
KEY_EN_X,
|
||||
KEY_EN_SPACE,
|
||||
KEY_EN_NUMPAD_4,
|
||||
KEY_EN_PAGE_UP,
|
||||
KEY_EN_F5,
|
||||
KEY_EN_5,
|
||||
KEY_EN_T,
|
||||
KEY_EN_G,
|
||||
KEY_EN_C,
|
||||
KEY_EN_NUMPAD_1,
|
||||
KEY_EN_PAGE_DOWN,
|
||||
KEY_EN_F6,
|
||||
KEY_EN_6,
|
||||
KEY_EN_Y,
|
||||
KEY_EN_H,
|
||||
KEY_EN_V,
|
||||
KEY_EN_NUMPAD_2,
|
||||
KEY_EN_NUMPAD_LOCK,
|
||||
KEY_EN_F7,
|
||||
KEY_EN_7,
|
||||
KEY_EN_U,
|
||||
KEY_EN_J,
|
||||
KEY_EN_B,
|
||||
KEY_EN_NUMPAD_0,
|
||||
KEY_EN_NUMPAD_7,
|
||||
KEY_EN_F8,
|
||||
KEY_EN_8,
|
||||
KEY_EN_I,
|
||||
KEY_EN_K,
|
||||
KEY_EN_N,
|
||||
KEY_EN_NUMPAD_6,
|
||||
KEY_EN_NUMPAD_DIVIDE,
|
||||
KEY_EN_F9,
|
||||
KEY_EN_9,
|
||||
KEY_EN_O,
|
||||
KEY_EN_L,
|
||||
KEY_EN_M,
|
||||
KEY_EN_RIGHT_ALT,
|
||||
KEY_EN_NUMPAD_3,
|
||||
KEY_EN_NUMPAD_8,
|
||||
KEY_EN_F10,
|
||||
KEY_EN_0,
|
||||
KEY_EN_P,
|
||||
KEY_EN_SEMICOLON,
|
||||
KEY_EN_COMMA,
|
||||
KEY_EN_RIGHT_FUNCTION,
|
||||
KEY_EN_NUMPAD_PERIOD,
|
||||
KEY_EN_NUMPAD_TIMES,
|
||||
KEY_EN_F11,
|
||||
KEY_EN_MINUS,
|
||||
KEY_EN_LEFT_BRACKET,
|
||||
KEY_EN_QUOTE,
|
||||
KEY_EN_PERIOD,
|
||||
KEY_EN_NUMPAD_PLUS,
|
||||
KEY_EN_NUMPAD_9,
|
||||
KEY_EN_F12,
|
||||
KEY_EN_EQUALS,
|
||||
KEY_EN_RIGHT_BRACKET,
|
||||
KEY_EN_FORWARD_SLASH,
|
||||
KEY_EN_MENU,
|
||||
KEY_EN_NUMPAD_MINUS,
|
||||
KEY_EN_PRINT_SCREEN,
|
||||
KEY_EN_ANSI_BACK_SLASH,
|
||||
KEY_EN_ANSI_ENTER,
|
||||
KEY_EN_RIGHT_CONTROL,
|
||||
KEY_EN_NUMPAD_ENTER,
|
||||
KEY_EN_NUMPAD_5,
|
||||
KEY_EN_SCROLL_LOCK,
|
||||
KEY_EN_RIGHT_SHIFT,
|
||||
KEY_EN_PAUSE_BREAK,
|
||||
KEY_EN_BACKSPACE
|
||||
};
|
||||
|
||||
/**------------------------------------------------------------------*\
|
||||
@name Thermaltake PoseidonZ
|
||||
@category Keyboard
|
||||
@type USB
|
||||
@save :x:
|
||||
@direct :white_check_mark:
|
||||
@effects :white_check_mark:
|
||||
@detectors DetectPoseidonZRGBControllers
|
||||
@comment
|
||||
\*-------------------------------------------------------------------*/
|
||||
|
||||
RGBController_PoseidonZRGB::RGBController_PoseidonZRGB(PoseidonZRGBController* controller_ptr)
|
||||
{
|
||||
controller = controller_ptr;
|
||||
|
||||
name = "Thermaltake Poseidon Z RGB";
|
||||
vendor = "Thermaltake";
|
||||
type = DEVICE_TYPE_KEYBOARD;
|
||||
description = "Thermaltake Poseidon Z RGB Device";
|
||||
location = controller->GetDeviceLocation();
|
||||
serial = controller->GetSerialString();
|
||||
|
||||
mode Direct;
|
||||
Direct.name = "Direct";
|
||||
Direct.value = POSEIDONZ_MODE_STATIC;
|
||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Direct);
|
||||
|
||||
mode Static;
|
||||
Static.name = "Static";
|
||||
Static.value = POSEIDONZ_MODE_STATIC;
|
||||
Static.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Static.color_mode = MODE_COLORS_PER_LED;
|
||||
modes.push_back(Static);
|
||||
|
||||
mode Wave;
|
||||
Wave.name = "Wave";
|
||||
Wave.value = POSEIDONZ_MODE_WAVE;
|
||||
Wave.flags = MODE_FLAG_HAS_SPEED | MODE_FLAG_HAS_DIRECTION_LR | MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Wave.speed_min = POSEIDONZ_SPEED_SLOW;
|
||||
Wave.speed_max = POSEIDONZ_SPEED_FAST;
|
||||
Wave.color_mode = MODE_COLORS_NONE;
|
||||
Wave.speed = POSEIDONZ_SPEED_FAST;
|
||||
Wave.direction = MODE_DIRECTION_LEFT;
|
||||
modes.push_back(Wave);
|
||||
|
||||
mode Ripple;
|
||||
Ripple.name = "Ripple";
|
||||
Ripple.value = POSEIDONZ_MODE_RIPPLE;
|
||||
Ripple.flags = MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Ripple.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Ripple);
|
||||
|
||||
mode Reactive;
|
||||
Reactive.name = "Reactive";
|
||||
Reactive.value = POSEIDONZ_MODE_REACTIVE;
|
||||
Reactive.flags = MODE_FLAG_AUTOMATIC_SAVE;
|
||||
Reactive.color_mode = MODE_COLORS_NONE;
|
||||
modes.push_back(Reactive);
|
||||
|
||||
SetupZones();
|
||||
}
|
||||
|
||||
RGBController_PoseidonZRGB::~RGBController_PoseidonZRGB()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Delete the matrix map |
|
||||
\*---------------------------------------------------------*/
|
||||
for(unsigned int zone_index = 0; zone_index < zones.size(); zone_index++)
|
||||
{
|
||||
if(zones[zone_index].matrix_map != NULL)
|
||||
{
|
||||
delete zones[zone_index].matrix_map;
|
||||
}
|
||||
}
|
||||
|
||||
delete controller;
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::SetupZones()
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up zones |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned int total_led_count = 0;
|
||||
for(unsigned int zone_idx = 0; zone_idx < 1; zone_idx++)
|
||||
{
|
||||
zone new_zone;
|
||||
new_zone.name = zone_names[zone_idx];
|
||||
new_zone.type = zone_types[zone_idx];
|
||||
new_zone.leds_min = zone_sizes[zone_idx];
|
||||
new_zone.leds_max = zone_sizes[zone_idx];
|
||||
new_zone.leds_count = zone_sizes[zone_idx];
|
||||
new_zone.matrix_map = new matrix_map_type;
|
||||
new_zone.matrix_map->height = 6;
|
||||
new_zone.matrix_map->width = 23;
|
||||
new_zone.matrix_map->map = (unsigned int *)&matrix_map;
|
||||
zones.push_back(new_zone);
|
||||
|
||||
total_led_count += zone_sizes[zone_idx];
|
||||
}
|
||||
|
||||
for(unsigned int led_idx = 0; led_idx < total_led_count; led_idx++)
|
||||
{
|
||||
led new_led;
|
||||
new_led.name = led_names[led_idx];
|
||||
leds.push_back(new_led);
|
||||
}
|
||||
|
||||
SetupColors();
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::ResizeZone(int /*zone*/, int /*new_size*/)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| This device does not support resizing zones |
|
||||
\*---------------------------------------------------------*/
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::DeviceUpdateLEDs()
|
||||
{
|
||||
if(active_mode == 0)
|
||||
{
|
||||
controller->SetLEDsDirect(colors);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller->SetLEDs(colors);
|
||||
}
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::UpdateZoneLEDs(int /*zone*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::UpdateSingleLED(int /*led*/)
|
||||
{
|
||||
DeviceUpdateLEDs();
|
||||
}
|
||||
|
||||
void RGBController_PoseidonZRGB::DeviceUpdateMode()
|
||||
{
|
||||
controller->SetMode(modes[active_mode].value, modes[active_mode].direction, modes[active_mode].speed);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_ThermaltakePoseidonZRGB.h |
|
||||
| |
|
||||
| RGBController for Thermaltake Poseidon Z RGB |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 25 Dec 2019 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "ThermaltakePoseidonZRGBController.h"
|
||||
|
||||
class RGBController_PoseidonZRGB : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_PoseidonZRGB(PoseidonZRGBController* controller_ptr);
|
||||
~RGBController_PoseidonZRGB();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
PoseidonZRGBController* controller;
|
||||
};
|
||||
@@ -0,0 +1,253 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ThermaltakePoseidonZRGBController.cpp |
|
||||
| |
|
||||
| Driver for Thermaltake Poseidon Z RGB |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 25 Dec 2019 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "StringUtils.h"
|
||||
#include "ThermaltakePoseidonZRGBController.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static unsigned int keys[] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x15,
|
||||
0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23,
|
||||
0x24, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 0x31,
|
||||
0x32, 0x33, 0x34, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3E, 0x3F, 0x40,
|
||||
0x41, 0x42, 0x43, 0x44, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C,
|
||||
0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x66, 0x67, 0x68, 0x69, 0x6A,
|
||||
0x6C, 0x6D, 0x6F, 0x70, 0x72, 0x73, 0x75, 0x76, 0x77, 0x78, 0x7C, 0x80, 0x81 };
|
||||
|
||||
PoseidonZRGBController::PoseidonZRGBController(hid_device* dev_handle, const char* path)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
}
|
||||
|
||||
PoseidonZRGBController::~PoseidonZRGBController()
|
||||
{
|
||||
hid_close(dev);
|
||||
}
|
||||
|
||||
std::string PoseidonZRGBController::GetDeviceLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string PoseidonZRGBController::GetSerialString()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
void PoseidonZRGBController::SetMode(unsigned char mode, unsigned char direction, unsigned char speed)
|
||||
{
|
||||
active_mode = mode;
|
||||
active_direction = direction;
|
||||
active_speed = speed;
|
||||
|
||||
SendControl
|
||||
(
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
active_direction,
|
||||
active_mode,
|
||||
POSEIDONZ_BRIGHTNESS_MAX,
|
||||
active_speed
|
||||
);
|
||||
|
||||
std::this_thread::sleep_for(200ms);
|
||||
}
|
||||
|
||||
void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_grn_buf[264];
|
||||
unsigned char blu_buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffers |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(red_grn_buf, 0x00, sizeof(red_grn_buf));
|
||||
memset(blu_buf, 0x00, sizeof(blu_buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Direct packets |
|
||||
\*-----------------------------------------------------*/
|
||||
red_grn_buf[0] = 0x07;
|
||||
red_grn_buf[1] = POSEIDONZ_PACKET_ID_SET_DIRECT;
|
||||
red_grn_buf[2] = POSEIDONZ_PROFILE_P1;
|
||||
red_grn_buf[3] = POSEIDONZ_DIRECT_RED_GREEN;
|
||||
red_grn_buf[4] = 0x00;
|
||||
red_grn_buf[5] = 0x00;
|
||||
red_grn_buf[6] = 0x00;
|
||||
red_grn_buf[7] = 0x00;
|
||||
|
||||
blu_buf[0] = 0x07;
|
||||
blu_buf[1] = POSEIDONZ_PACKET_ID_SET_DIRECT;
|
||||
blu_buf[2] = POSEIDONZ_PROFILE_P1;
|
||||
blu_buf[3] = POSEIDONZ_DIRECT_BLUE;
|
||||
blu_buf[4] = 0x00;
|
||||
blu_buf[5] = 0x00;
|
||||
blu_buf[6] = 0x00;
|
||||
blu_buf[7] = 0x00;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(std::size_t i = 0; i < 104; i++)
|
||||
{
|
||||
red_grn_buf[keys[i] ] = RGBGetRValue(colors[i]);
|
||||
red_grn_buf[keys[i] + 128] = RGBGetGValue(colors[i]);
|
||||
blu_buf[ keys[i] ] = RGBGetBValue(colors[i]);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packets |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, red_grn_buf, 264);
|
||||
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
hid_send_feature_report(dev, blu_buf, 264);
|
||||
}
|
||||
|
||||
void PoseidonZRGBController::SetLEDs(std::vector<RGBColor> colors)
|
||||
{
|
||||
unsigned char red_color_data[104];
|
||||
unsigned char grn_color_data[104];
|
||||
unsigned char blu_color_data[104];
|
||||
|
||||
for(std::size_t i = 0; i < 104; i++)
|
||||
{
|
||||
red_color_data[i] = RGBGetRValue(colors[i]);
|
||||
grn_color_data[i] = RGBGetGValue(colors[i]);
|
||||
blu_color_data[i] = RGBGetBValue(colors[i]);
|
||||
}
|
||||
|
||||
SendColor
|
||||
(
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
POSEIDONZ_COLOR_RED,
|
||||
red_color_data
|
||||
);
|
||||
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
POSEIDONZ_COLOR_GREEN,
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
POSEIDONZ_COLOR_BLUE,
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
SendControl
|
||||
(
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
POSEIDONZ_PROFILE_P1,
|
||||
active_direction,
|
||||
active_mode,
|
||||
POSEIDONZ_BRIGHTNESS_MAX,
|
||||
active_speed
|
||||
);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------------*\
|
||||
| Private packet sending functions. |
|
||||
\*-------------------------------------------------------------------------------------------------*/
|
||||
|
||||
void PoseidonZRGBController::SendColor
|
||||
(
|
||||
unsigned char profile_to_edit,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
)
|
||||
{
|
||||
unsigned char buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Color packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = POSEIDONZ_PACKET_ID_SET_COLOR;
|
||||
buf[0x02] = profile_to_edit;
|
||||
buf[0x03] = color_channel;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Fill in color data |
|
||||
\*-----------------------------------------------------*/
|
||||
for(int i = 0; i < 104; i++)
|
||||
{
|
||||
buf[keys[i]] = color_data[i];
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
|
||||
void PoseidonZRGBController::SendControl
|
||||
(
|
||||
unsigned char profile_to_activate,
|
||||
unsigned char profile_to_edit,
|
||||
unsigned char direction,
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char speed
|
||||
)
|
||||
{
|
||||
unsigned char buf[264];
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Zero out buffer |
|
||||
\*-----------------------------------------------------*/
|
||||
memset(buf, 0x00, sizeof(buf));
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Set up Effect packet |
|
||||
\*-----------------------------------------------------*/
|
||||
buf[0x00] = 0x07;
|
||||
buf[0x01] = POSEIDONZ_PACKET_ID_SET_EFFECT;
|
||||
buf[0x02] = profile_to_activate;
|
||||
buf[0x08] = profile_to_edit;
|
||||
buf[0x0A] = direction;
|
||||
buf[0x0C] = mode;
|
||||
buf[0x0D] = brightness;
|
||||
buf[0x10] = 0x08;
|
||||
buf[0x12] = speed;
|
||||
buf[0x13] = 0x50;
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, buf, 264);
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ThermaltakePoseidonZRGBController.h |
|
||||
| |
|
||||
| Driver for Thermaltake Poseidon Z RGB |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 25 Dec 2019 |
|
||||
| |
|
||||
| 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 POSEIDONZ_START 0x07
|
||||
#define POSEIDONZ_PROFILE 0x01
|
||||
#define POSEIDONZ_LED_CMD 0x0E
|
||||
#define POSEIDONZ_RED_GRN_CH 0x01
|
||||
#define POSEIDONZ_BLU_CH 0x02
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_PACKET_ID_SET_EFFECT = 0x02, /* Set profile effect packet */
|
||||
POSEIDONZ_PACKET_ID_SET_COLOR = 0x09, /* Set profile color packet */
|
||||
POSEIDONZ_PACKET_ID_SET_DIRECT = 0x0E, /* Set direct color packet */
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_MODE_STATIC = 0x00,
|
||||
POSEIDONZ_MODE_REACTIVE = 0x01,
|
||||
POSEIDONZ_MODE_ARROW_FLOW = 0x02,
|
||||
POSEIDONZ_MODE_WAVE = 0x03,
|
||||
POSEIDONZ_MODE_RIPPLE = 0x04
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_PROFILE_P1 = 0x01,
|
||||
POSEIDONZ_PROFILE_P2 = 0x02,
|
||||
POSEIDONZ_PROFILE_P3 = 0x03,
|
||||
POSEIDONZ_PROFILE_P4 = 0x04,
|
||||
POSEIDONZ_PROFILE_P5 = 0x05
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_BRIGHTNESS_MIN = 0x00,
|
||||
POSEIDONZ_BRIGHTNESS_MAX = 0x04
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_COLOR_RED = 0x01,
|
||||
POSEIDONZ_COLOR_GREEN = 0x02,
|
||||
POSEIDONZ_COLOR_BLUE = 0x03
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_DIRECT_RED_GREEN = 0x01,
|
||||
POSEIDONZ_DIRECT_BLUE = 0x02
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
POSEIDONZ_SPEED_SLOW = 0x10,
|
||||
POSEIDONZ_SPEED_FAST = 0x05
|
||||
};
|
||||
|
||||
class PoseidonZRGBController
|
||||
{
|
||||
public:
|
||||
PoseidonZRGBController(hid_device* dev_handle, const char* path);
|
||||
~PoseidonZRGBController();
|
||||
|
||||
std::string GetDeviceLocation();
|
||||
std::string GetSerialString();
|
||||
|
||||
void SetMode(unsigned char mode, unsigned char direction, unsigned char speed);
|
||||
void SetLEDsDirect(std::vector<RGBColor> colors);
|
||||
void SetLEDs(std::vector<RGBColor> colors);
|
||||
|
||||
private:
|
||||
hid_device* dev;
|
||||
unsigned char active_mode;
|
||||
unsigned char active_direction;
|
||||
unsigned char active_speed;
|
||||
std::string location;
|
||||
|
||||
void SendControl
|
||||
(
|
||||
unsigned char profile_to_activate,
|
||||
unsigned char profile_to_edit,
|
||||
unsigned char direction,
|
||||
unsigned char mode,
|
||||
unsigned char brightness,
|
||||
unsigned char speed
|
||||
);
|
||||
|
||||
void SendColor
|
||||
(
|
||||
unsigned char profile_to_edit,
|
||||
unsigned char color_channel,
|
||||
unsigned char* color_data
|
||||
);
|
||||
};
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| ThermaltakePoseidonZRGBControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Thermaltake Poseidon Z RGB |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 25 Dec 2019 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <hidapi.h>
|
||||
#include "Detector.h"
|
||||
#include "ThermaltakePoseidonZRGBController.h"
|
||||
#include "RGBController_ThermaltakePoseidonZRGB.h"
|
||||
|
||||
#define TT_POSEIDON_Z_RGB_VID 0x264A
|
||||
#define TT_POSEIDON_Z_RGB_PID 0x3006
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
* DetectPoseidonZRGBControllers *
|
||||
* *
|
||||
* Tests the USB address to see if a Thermaltake Poseidon Z RGB Keyboard controller *
|
||||
* exists there. *
|
||||
* *
|
||||
\******************************************************************************************/
|
||||
|
||||
void DetectPoseidonZRGBControllers(hid_device_info* info, const std::string&)
|
||||
{
|
||||
hid_device* dev = hid_open_path(info->path);
|
||||
if( dev )
|
||||
{
|
||||
PoseidonZRGBController* controller = new PoseidonZRGBController(dev, info->path);
|
||||
RGBController_PoseidonZRGB* rgb_controller = new RGBController_PoseidonZRGB(controller);
|
||||
// Constructor sets the name
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
}
|
||||
} /* DetectPoseidonZRGBControllers() */
|
||||
|
||||
REGISTER_HID_DETECTOR_IP("Thermaltake Poseidon Z RGB", DetectPoseidonZRGBControllers, TT_POSEIDON_Z_RGB_VID, TT_POSEIDON_Z_RGB_PID, 1, 0xFF01);
|
||||
Reference in New Issue
Block a user