Compare commits

...
2 Commits
Author SHA1 Message Date
Adam Honse 8b9c4ec68c More poseidon z rework 2020-02-02 19:10:49 -06:00
Adam Honse af7c185e43 Poseidon z rework in progress 2020-01-28 20:27:31 -06:00
4 changed files with 162 additions and 71 deletions
@@ -9,6 +9,8 @@
#include "PoseidonZRGBController.h"
#include <cstring>
#ifdef WIN32
#include <Windows.h>
#else
@@ -47,10 +49,10 @@ char* PoseidonZRGBController::GetDeviceName()
void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
{
unsigned char red_grn_buf[264];
unsigned char blu_buf[264];
unsigned char red_grn_buf[265];
unsigned char blu_buf[265];
for(int i = 0; i < 264; i++)
for(int i = 0; i < 265; i++)
{
red_grn_buf[i] = 0x00;
blu_buf[i] = 0x00;
@@ -91,83 +93,109 @@ void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
void PoseidonZRGBController::SetLEDs(std::vector<RGBColor> colors)
{
unsigned char buf[264] = {0};
//Send Red Packet
for(int i = 0; i < 264; i++)
{
buf[i] = 0xFF;
}
buf[0] = 0x07;
buf[1] = 0x09;
buf[2] = 0x01;
buf[3] = 0x01;
unsigned char red_color_data[104];
unsigned char grn_color_data[104];
unsigned char blu_color_data[104];
for(int i = 0; i < 104; i++)
{
buf[keys[i]] = RGBGetRValue(colors[i]);
red_color_data[keys[i] - 8] = RGBGetRValue(colors[i]);
grn_color_data[keys[i] - 8] = RGBGetGValue(colors[i]);
blu_color_data[keys[i] - 8] = RGBGetBValue(colors[i]);
}
hid_send_feature_report(dev, buf, 264);
SendColor
(
POSEIDONZ_PROFILE_P1,
POSEIDONZ_COLOR_RED,
red_color_data
);
Sleep(10);
//Send Green Packet
for(int i = 0; i < 264; i++)
{
buf[i] = 0x00;
}
buf[0] = 0x07;
buf[1] = 0x09;
buf[2] = 0x01;
buf[3] = 0x02;
buf[8] = 0xFF;
for(int i = 0; i < 104; i++)
{
buf[keys[i]] = RGBGetGValue(colors[i]);
}
hid_send_feature_report(dev, buf, 264);
SendColor
(
POSEIDONZ_PROFILE_P1,
POSEIDONZ_COLOR_GREEN,
grn_color_data
);
Sleep(10);
//Send Blue Packet
for(int i = 0; i < 264; i++)
{
buf[i] = 0x11;
}
buf[0] = 0x07;
buf[1] = 0x09;
buf[2] = 0x01;
buf[3] = 0x03;
for(int i = 0; i < 104; i++)
{
buf[keys[i]] = RGBGetBValue(colors[i]);
}
hid_send_feature_report(dev, buf, 264);
SendColor
(
POSEIDONZ_PROFILE_P1,
POSEIDONZ_COLOR_BLUE,
blu_color_data
);
Sleep(10);
//Send Update Packet
for(int i = 0; i < 264; i++)
{
buf[i] = 0x00;
}
buf[0] = 0x07;
buf[1] = 0x02;
buf[2] = 0x01;
buf[8] = 0x01; //Preset to save
buf[13] = 0x04; //Brightness?
buf[16] = 0x08;
buf[22] = 0x03;
hid_send_feature_report(dev, buf, 264);
SendControl
(
POSEIDONZ_PROFILE_P1,
POSEIDONZ_PROFILE_P1,
0,
POSEIDONZ_MODE_STATIC,
POSEIDONZ_BRIGHTNESS_MAX
);
}
void PoseidonZRGBController::SendColor
(
unsigned char profile_to_edit,
unsigned char color_channel,
unsigned char* color_data
)
{
unsigned char usb_buf[265];
switch(color_channel)
{
case POSEIDONZ_COLOR_RED:
memset(usb_buf, 0xFF, sizeof(usb_buf));
break;
case POSEIDONZ_COLOR_GREEN:
memset(usb_buf, 0x00, sizeof(usb_buf));
break;
case POSEIDONZ_COLOR_BLUE:
memset(usb_buf, 0x11, sizeof(usb_buf));
break;
}
usb_buf[0x00] = 0x07;
usb_buf[0x01] = 0x07;
usb_buf[0x02] = 0x09;
usb_buf[0x03] = profile_to_edit;
memcpy(&usb_buf[0x08], color_data, 104);
hid_send_feature_report(dev, &usb_buf[1], 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 usb_buf[265];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0x00] = 0x07;
usb_buf[0x01] = 0x07;
usb_buf[0x02] = 0x02;
usb_buf[0x03] = profile_to_activate;
usb_buf[0x09] = profile_to_edit;
usb_buf[0x0B] = direction;
usb_buf[0x0D] = mode;
usb_buf[0x0E] = brightness;
usb_buf[0x11] = 0x08;
hid_send_feature_report(dev, &usb_buf[1], 264);
}
@@ -21,6 +21,37 @@
#define POSEIDONZ_RED_GRN_CH 0x01
#define POSEIDONZ_BLU_CH 0x02
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
};
class PoseidonZRGBController
{
public:
@@ -35,4 +66,20 @@ public:
private:
char device_name[32];
hid_device* dev;
void SendControl
(
unsigned char profile_to_activate,
unsigned char profile_to_edit,
unsigned char direction,
unsigned char mode,
unsigned char brightness
);
void SendColor
(
unsigned char profile_to_edit,
unsigned char color_channel,
unsigned char* color_data
);
};
@@ -18,12 +18,28 @@
void DetectPoseidonZRGBControllers(std::vector<RGBController*>& rgb_controllers)
{
hid_device_info* info;
hid_device* dev;
//Look for Thermaltake Poseidon Z RGB Keyboard
hid_init();
dev = hid_open(TT_POSEIDON_Z_RGB_VID, TT_POSEIDON_Z_RGB_PID, 0);
info = hid_enumerate(TT_POSEIDON_Z_RGB_VID, TT_POSEIDON_Z_RGB_PID);
//Look for Thermaltake Poseidon Z RGB Keyboard
while(info)
{
if((info->vendor_id == TT_POSEIDON_Z_RGB_VID)
&&(info->product_id == TT_POSEIDON_Z_RGB_PID)
&&(info->interface_number == 0))
{
dev = hid_open_path(info->path);
break;
}
else
{
info = info->next;
}
}
if( dev )
{
+1 -1
View File
@@ -29,7 +29,7 @@ RGBController_PoseidonZRGB::~RGBController_PoseidonZRGB()
void RGBController_PoseidonZRGB::UpdateLEDs()
{
poseidon->SetLEDs(colors);
poseidon->SetLEDsDirect(colors);
}
void RGBController_PoseidonZRGB::UpdateZoneLEDs(int zone)