mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-18 11:35:21 -04:00
Fix: [Epomaker TH80 Pro] Windows compat fix
This commit is contained in:
@@ -10,9 +10,11 @@
|
||||
#include "EpomakerController.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "LogManager.h"
|
||||
|
||||
EpomakerController::EpomakerController(hid_device* dev_handle, char *_path)
|
||||
{
|
||||
const int szTemp = 256;
|
||||
const int szTemp = 128;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
dev = dev_handle;
|
||||
@@ -31,11 +33,11 @@ EpomakerController::EpomakerController(hid_device* dev_handle, char *_path)
|
||||
|
||||
location = _path;
|
||||
|
||||
current_mode = Epomaker_MODE_ALWAYS_ON;
|
||||
current_speed = Epomaker_SPEED_DEFAULT;
|
||||
current_brightness = Epomaker_BRIGHTNESS_DEFAULT;
|
||||
current_dazzle = Epomaker_OPTION_DAZZLE_OFF;
|
||||
current_option = Epomaker_OPTION_DEFAULT;
|
||||
current_mode = EPOMAKER_MODE_ALWAYS_ON;
|
||||
current_speed = EPOMAKER_SPEED_DEFAULT;
|
||||
current_brightness = EPOMAKER_BRIGHTNESS_DEFAULT;
|
||||
current_dazzle = EPOMAKER_OPTION_DAZZLE_OFF;
|
||||
current_option = EPOMAKER_OPTION_DEFAULT;
|
||||
|
||||
}
|
||||
|
||||
@@ -81,11 +83,11 @@ void EpomakerController::SetDazzle(bool is_dazzle)
|
||||
{
|
||||
if(is_dazzle)
|
||||
{
|
||||
current_dazzle = Epomaker_OPTION_DAZZLE_ON;
|
||||
current_dazzle = EPOMAKER_OPTION_DAZZLE_ON;
|
||||
}
|
||||
else
|
||||
{
|
||||
current_dazzle = Epomaker_OPTION_DAZZLE_OFF;
|
||||
current_dazzle = EPOMAKER_OPTION_DAZZLE_OFF;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,33 +98,32 @@ void EpomakerController::SetOption(unsigned char option)
|
||||
|
||||
void EpomakerController::SendUpdate()
|
||||
{
|
||||
unsigned char command[Epomaker_PACKET_LENGTH] = { 0x00 };
|
||||
command[0] = 0xf6;
|
||||
command[1] = 0x0a;
|
||||
unsigned char buffer[EPOMAKER_PACKET_LENGTH + 1] = { 0x00 };
|
||||
|
||||
unsigned char buffer[Epomaker_PACKET_LENGTH] = { 0x00 };
|
||||
int buffer_size = (sizeof(buffer) / sizeof(buffer[0]));
|
||||
|
||||
buffer[Epomaker_BYTE_COMMAND] = Epomaker_COMMAND_RGB;
|
||||
buffer[Epomaker_BYTE_MODE] = current_mode;
|
||||
buffer[Epomaker_BYTE_SPEED] = current_speed;
|
||||
buffer[Epomaker_BYTE_BRIGHTNESS] = current_brightness;
|
||||
buffer[Epomaker_BYTE_FLAGS] = current_option | current_dazzle;
|
||||
buffer[Epomaker_BYTE_RED] = current_red;
|
||||
buffer[Epomaker_BYTE_GREEN] = current_green;
|
||||
buffer[Epomaker_BYTE_BLUE] = current_blue;
|
||||
buffer[EPOMAKER_BYTE_COMMAND] = EPOMAKER_COMMAND_RGB;
|
||||
buffer[EPOMAKER_BYTE_MODE] = current_mode;
|
||||
buffer[EPOMAKER_BYTE_SPEED] = current_speed;
|
||||
buffer[EPOMAKER_BYTE_BRIGHTNESS] = current_brightness;
|
||||
buffer[EPOMAKER_BYTE_FLAGS] = current_option | current_dazzle;
|
||||
buffer[EPOMAKER_BYTE_RED] = current_red;
|
||||
buffer[EPOMAKER_BYTE_GREEN] = current_green;
|
||||
buffer[EPOMAKER_BYTE_BLUE] = current_blue;
|
||||
|
||||
int sum_bits = 0;
|
||||
for (int i=Epomaker_BYTE_COMMAND; i<=Epomaker_BYTE_BLUE; i++)
|
||||
for(int i = EPOMAKER_BYTE_COMMAND; i <= EPOMAKER_BYTE_BLUE; i++)
|
||||
{
|
||||
sum_bits += buffer[i];
|
||||
}
|
||||
|
||||
int next_pow2 = pow(2, ceil(log2(sum_bits)));
|
||||
int next_pow2 = (int)(pow(2, ceil(log2((double)(sum_bits)))));
|
||||
int filler = next_pow2 - sum_bits - 1;
|
||||
|
||||
buffer[Epomaker_BYTE_FILLER] = filler;
|
||||
buffer[EPOMAKER_BYTE_FILLER] = filler;
|
||||
|
||||
int send_buffer_result = hid_send_feature_report(dev, buffer, (sizeof(buffer) / sizeof(buffer[0])));
|
||||
if(send_buffer_result<0)
|
||||
{
|
||||
LOG_ERROR("[EPOMAKER]: Send Buffer Error. HIDAPI Error: %ls", hid_error(dev));
|
||||
}
|
||||
|
||||
hid_send_feature_report(dev, command, buffer_size);
|
||||
hid_send_feature_report(dev, buffer, buffer_size);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user