Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 32 additions & 21 deletions Controllers/EVisionKeyboardController/EVisionKeyboardController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,28 @@ void EVisionKeyboardController::SendKeyboardModeEx
unsigned char blue
)
{
unsigned char parameter_data[8];

parameter_data[0] = mode;
parameter_data[1] = brightness;
parameter_data[2] = speed;
parameter_data[3] = direction;
parameter_data[4] = random_flag;
parameter_data[5] = red;
parameter_data[6] = green;
parameter_data[7] = blue;

SendKeyboardParameter(0, 8, parameter_data);
/*-----------------------------------------------------*\
| Build 27-byte compound parameter (param_id = 0x00) |
| as observed in Windows firmware captures |
\*-----------------------------------------------------*/
unsigned char profile[27];

memset(profile, 0x00, sizeof(profile));
profile[0] = 0x00; /* profile index */
profile[1] = mode;
profile[2] = brightness;
profile[3] = speed;
profile[4] = direction;
profile[5] = random_flag;
profile[6] = red;
profile[7] = green;
profile[8] = blue;
profile[18] = 0x03;
profile[22] = 0x03;

SendKeyboardBegin();
SendKeyboardParameter(EVISION_KB_PARAMETER_MODE, sizeof(profile), profile);
SendKeyboardEnd();
}

/*-------------------------------------------------------------------------------------------------*\
Expand Down Expand Up @@ -158,7 +168,7 @@ void EVisionKeyboardController::SendKeyboardBegin()
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_read(dev, (unsigned char *)usb_buf, 64);
hid_read_timeout(dev, (unsigned char *)usb_buf, 64, 100);
}

void EVisionKeyboardController::SendKeyboardEnd()
Expand All @@ -184,14 +194,14 @@ void EVisionKeyboardController::SendKeyboardEnd()
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_read(dev, (unsigned char *)usb_buf, 64);
hid_read_timeout(dev, (unsigned char *)usb_buf, 64, 100);
}

void EVisionKeyboardController::SendKeyboardData
(
unsigned char * data,
unsigned char data_size,
unsigned short data_offset
unsigned int data_offset
)
{
char usb_buf[64];
Expand All @@ -202,14 +212,15 @@ void EVisionKeyboardController::SendKeyboardData
memset(usb_buf, 0x00, sizeof(usb_buf));

/*-----------------------------------------------------*\
| Set up Keyboard Color Data (0x11) packet |
| Set up Keyboard Color Data (0x12) packet |
\*-----------------------------------------------------*/
usb_buf[0x00] = 0x04;
usb_buf[0x03] = 0x11;
usb_buf[0x03] = 0x12;

usb_buf[0x04] = data_size;
usb_buf[0x05] = data_offset & 0x00FF;
usb_buf[0x06] = data_offset >> 8;
usb_buf[0x05] = data_offset & 0xFF;
usb_buf[0x06] = (data_offset >> 8) & 0xFF;
usb_buf[0x07] = (data_offset >> 16) & 0xFF;

/*-----------------------------------------------------*\
| Copy in data bytes |
Expand All @@ -225,7 +236,7 @@ void EVisionKeyboardController::SendKeyboardData
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_read(dev, (unsigned char *)usb_buf, 64);
hid_read_timeout(dev, (unsigned char *)usb_buf, 64, 100);
}

void EVisionKeyboardController::SendKeyboardParameter
Expand Down Expand Up @@ -264,5 +275,5 @@ void EVisionKeyboardController::SendKeyboardParameter
| Send packet |
\*-----------------------------------------------------*/
hid_write(dev, (unsigned char *)usb_buf, 64);
hid_read(dev, (unsigned char *)usb_buf, 64);
hid_read_timeout(dev, (unsigned char *)usb_buf, 64, 100);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <hidapi.h>
#include "RGBController.h"

#define EVISION_KB_MAX_PACKET_SIZE ( 0x36 )/* max packet size for color*/
#define EVISION_KB_MAX_PACKET_SIZE ( 0x38 )/* max packet size for color*/
/* update packets */
enum
{
Expand Down Expand Up @@ -130,7 +130,7 @@ class EVisionKeyboardController
(
unsigned char * data,
unsigned char data_size,
unsigned short data_offset
unsigned int data_offset
);

void SendKeyboardEnd();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,17 +322,17 @@ void RGBController_EVisionKeyboard::SetupZones()

new_zone.name = "Keyboard";
new_zone.type = ZONE_TYPE_MATRIX;
new_zone.leds_min = 126;
new_zone.leds_max = 126;
new_zone.leds_count = 126;
new_zone.leds_min = 128;
new_zone.leds_max = 128;
new_zone.leds_count = 128;
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);

for(int led_idx = 0; led_idx < 126; led_idx++)
for(int led_idx = 0; led_idx < 128; led_idx++)
{
led new_led;

Expand All @@ -354,9 +354,9 @@ void RGBController_EVisionKeyboard::ResizeZone(int /*zone*/, int /*new_size*/)

void RGBController_EVisionKeyboard::DeviceUpdateLEDs()
{
unsigned char color_data[7*0x36];
unsigned char color_data[128 * 3];

for(int led_idx = 0; led_idx < 126; led_idx++)
for(int led_idx = 0; led_idx < 128; led_idx++)
{
color_data[(3 * led_idx) + 0] = RGBGetRValue(colors[led_idx]);
color_data[(3 * led_idx) + 1] = RGBGetGValue(colors[led_idx]);
Expand All @@ -366,7 +366,7 @@ void RGBController_EVisionKeyboard::DeviceUpdateLEDs()
controller->SetKeyboardColors
(
color_data,
0x36 * 7
128 * 3
);
}

Expand Down