Store name in OKSKeyboardController to avoid setting it in detector
This commit is contained in:
parent
e418aa7f95
commit
2c630a5218
4 changed files with 54 additions and 47 deletions
|
|
@ -13,10 +13,11 @@
|
||||||
#include "OKSKeyboardController.h"
|
#include "OKSKeyboardController.h"
|
||||||
#include "StringUtils.h"
|
#include "StringUtils.h"
|
||||||
|
|
||||||
OKSKeyboardController::OKSKeyboardController(hid_device* dev_handle, const char* path, const unsigned short pid)
|
OKSKeyboardController::OKSKeyboardController(hid_device* dev_handle, const char* path, const unsigned short pid, std::string dev_name)
|
||||||
{
|
{
|
||||||
dev = dev_handle;
|
dev = dev_handle;
|
||||||
location = path;
|
location = path;
|
||||||
|
name = dev_name;
|
||||||
usb_pid = pid;
|
usb_pid = pid;
|
||||||
|
|
||||||
SendInitialize();
|
SendInitialize();
|
||||||
|
|
@ -32,6 +33,11 @@ std::string OKSKeyboardController::GetDeviceLocation()
|
||||||
return("HID: " + location);
|
return("HID: " + location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string OKSKeyboardController::GetNameString()
|
||||||
|
{
|
||||||
|
return(name);
|
||||||
|
}
|
||||||
|
|
||||||
std::string OKSKeyboardController::GetSerialString()
|
std::string OKSKeyboardController::GetSerialString()
|
||||||
{
|
{
|
||||||
wchar_t serial_string[128];
|
wchar_t serial_string[128];
|
||||||
|
|
|
||||||
|
|
@ -67,26 +67,28 @@ union uint32_kb2
|
||||||
class OKSKeyboardController
|
class OKSKeyboardController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OKSKeyboardController(hid_device* dev_handle, const char* path, const unsigned short pid);
|
OKSKeyboardController(hid_device* dev_handle, const char* path, const unsigned short pid, std::string dev_name);
|
||||||
~OKSKeyboardController();
|
~OKSKeyboardController();
|
||||||
|
|
||||||
std::string GetDeviceLocation();
|
std::string GetDeviceLocation();
|
||||||
|
std::string GetNameString();
|
||||||
std::string GetSerialString();
|
std::string GetSerialString();
|
||||||
unsigned short GetUSBPID();
|
unsigned short GetUSBPID();
|
||||||
|
|
||||||
void SendColors(unsigned char* color_data, unsigned int color_data_size);
|
void SendColors(unsigned char* color_data, unsigned int color_data_size);
|
||||||
void SendKeyboardModeEx(const mode &m, unsigned char red, unsigned char green, unsigned char blue);
|
void SendKeyboardModeEx(const mode &m, unsigned char red, unsigned char green, unsigned char blue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
hid_device* dev;
|
hid_device* dev;
|
||||||
std::string location;
|
std::string location;
|
||||||
unsigned short usb_pid;
|
std::string name;
|
||||||
|
unsigned short usb_pid;
|
||||||
|
|
||||||
void Send(const uint8_t bin[64], const uint16_t len);
|
void Send(const uint8_t bin[64], const uint16_t len);
|
||||||
void SendInitialize();
|
void SendInitialize();
|
||||||
uint8_t kb2_ComputeChecksum(const union kb2_port_t* const Pack);
|
uint8_t kb2_ComputeChecksum(const union kb2_port_t* const Pack);
|
||||||
int kb2_add_32b(union kb2_port_t* const Pack, const uint32_t value);
|
int kb2_add_32b(union kb2_port_t* const Pack, const uint32_t value);
|
||||||
void kb2M_init(union kb2_port_t* const Pack, const enum kb2_cmd cmd);
|
void kb2M_init(union kb2_port_t* const Pack, const enum kb2_cmd cmd);
|
||||||
void kb2M_wrgb(union kb2_port_t* const Pack, const uint8_t bright, const uint8_t mode, const uint8_t speed, const uint8_t dir);
|
void kb2M_wrgb(union kb2_port_t* const Pack, const uint8_t bright, const uint8_t mode, const uint8_t speed, const uint8_t dir);
|
||||||
void kb2M_wled(union kb2_port_t* const Pack, const uint32_t irgb[14]);
|
void kb2M_wled(union kb2_port_t* const Pack, const uint32_t irgb[14]);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ void DetectOKSKeyboardControllers(hid_device_info* info, const std::string& name
|
||||||
|
|
||||||
if(dev)
|
if(dev)
|
||||||
{
|
{
|
||||||
OKSKeyboardController* controller = new OKSKeyboardController(dev, info->path, info->product_id);
|
OKSKeyboardController* controller = new OKSKeyboardController(dev, info->path, info->product_id, name);
|
||||||
RGBController_OKSKeyboard* rgb_controller = new RGBController_OKSKeyboard(controller);
|
RGBController_OKSKeyboard* rgb_controller = new RGBController_OKSKeyboard(controller);
|
||||||
rgb_controller->name = name;
|
|
||||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||||
}
|
}
|
||||||
} /* DetectOKSKeyboardControllers() */
|
} /* DetectOKSKeyboardControllers() */
|
||||||
|
|
|
||||||
|
|
@ -109,47 +109,46 @@ enum
|
||||||
|
|
||||||
RGBController_OKSKeyboard::RGBController_OKSKeyboard(OKSKeyboardController* controller_ptr)
|
RGBController_OKSKeyboard::RGBController_OKSKeyboard(OKSKeyboardController* controller_ptr)
|
||||||
{
|
{
|
||||||
controller = controller_ptr;
|
controller = controller_ptr;
|
||||||
|
|
||||||
|
name = controller->GetNameString();
|
||||||
name = "OKS Keyboard Device";
|
vendor = "OKS";
|
||||||
vendor = "OKS";
|
type = DEVICE_TYPE_KEYBOARD;
|
||||||
type = DEVICE_TYPE_KEYBOARD;
|
description = "OKS Keyboard Device";
|
||||||
description = "OKS Keyboard Device";
|
location = controller->GetDeviceLocation();
|
||||||
location = controller->GetDeviceLocation();
|
serial = controller->GetSerialString();
|
||||||
serial = controller->GetSerialString();
|
|
||||||
|
|
||||||
mode Direct;
|
mode Direct;
|
||||||
Direct.name = "Direct";
|
Direct.name = "Direct";
|
||||||
Direct.value = UP_RGB_MODES_DIRECT;
|
Direct.value = UP_RGB_MODES_DIRECT;
|
||||||
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS ;
|
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR | MODE_FLAG_HAS_BRIGHTNESS ;
|
||||||
Direct.brightness_min = 0;
|
Direct.brightness_min = 0;
|
||||||
Direct.brightness_max = 5;
|
Direct.brightness_max = 5;
|
||||||
Direct.brightness = 2;
|
Direct.brightness = 2;
|
||||||
Direct.color_mode = MODE_COLORS_PER_LED;
|
Direct.color_mode = MODE_COLORS_PER_LED;
|
||||||
Direct.speed_min = OKS_SPEED_FASTEST;
|
Direct.speed_min = OKS_SPEED_FASTEST;
|
||||||
Direct.speed_max = OKS_SPEED_SLOWEST;
|
Direct.speed_max = OKS_SPEED_SLOWEST;
|
||||||
Direct.speed = OKS_SPEED_NORMAL;
|
Direct.speed = OKS_SPEED_NORMAL;
|
||||||
Direct.direction = MODE_DIRECTION_RIGHT;
|
Direct.direction = MODE_DIRECTION_RIGHT;
|
||||||
modes.push_back(Direct);
|
modes.push_back(Direct);
|
||||||
|
|
||||||
mode udef = Direct;
|
mode udef = Direct;
|
||||||
udef.name = "User mode1";
|
udef.name = "User mode1";
|
||||||
udef.value = UP_RGB_MODES_UDEF1;
|
udef.value = UP_RGB_MODES_UDEF1;
|
||||||
udef.direction = MODE_DIRECTION_LEFT;
|
udef.direction = MODE_DIRECTION_LEFT;
|
||||||
udef.speed = 0;
|
udef.speed = 0;
|
||||||
modes.push_back(udef);
|
modes.push_back(udef);
|
||||||
udef.name = "User mode2";
|
udef.name = "User mode2";
|
||||||
udef.value = UP_RGB_MODES_UDEF2;
|
udef.value = UP_RGB_MODES_UDEF2;
|
||||||
modes.push_back(udef);
|
modes.push_back(udef);
|
||||||
udef.name = "User mode3";
|
udef.name = "User mode3";
|
||||||
udef.value = UP_RGB_MODES_UDEF3;
|
udef.value = UP_RGB_MODES_UDEF3;
|
||||||
modes.push_back(udef);
|
modes.push_back(udef);
|
||||||
udef.name = "User mode4";
|
udef.name = "User mode4";
|
||||||
udef.value = UP_RGB_MODES_UDEF4;
|
udef.value = UP_RGB_MODES_UDEF4;
|
||||||
modes.push_back(udef);
|
modes.push_back(udef);
|
||||||
udef.name = "User mode5";
|
udef.name = "User mode5";
|
||||||
udef.value = UP_RGB_MODES_UDEF5;
|
udef.value = UP_RGB_MODES_UDEF5;
|
||||||
modes.push_back(udef);
|
modes.push_back(udef);
|
||||||
/*---------------------------------------------------------*\
|
/*---------------------------------------------------------*\
|
||||||
| Delete the "Horse race lamp","Breathing"... mode |
|
| Delete the "Horse race lamp","Breathing"... mode |
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue