Store name in DasKeyboardController to avoid setting it in detector
This commit is contained in:
parent
e6190ec275
commit
718962c188
4 changed files with 41 additions and 80 deletions
|
|
@ -15,10 +15,11 @@
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
DasKeyboardController::DasKeyboardController(hid_device *dev_handle, const char *path)
|
DasKeyboardController::DasKeyboardController(hid_device *dev_handle, const char *path, std::string dev_name)
|
||||||
{
|
{
|
||||||
dev = dev_handle;
|
dev = dev_handle;
|
||||||
location = path;
|
location = path;
|
||||||
|
name = dev_name;
|
||||||
version = "";
|
version = "";
|
||||||
useTraditionalSendData = false;
|
useTraditionalSendData = false;
|
||||||
|
|
||||||
|
|
@ -30,11 +31,36 @@ DasKeyboardController::~DasKeyboardController()
|
||||||
hid_close(dev);
|
hid_close(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DasKeyboardController::GetDeviceLocation()
|
std::string DasKeyboardController::GetLayoutString()
|
||||||
|
{
|
||||||
|
/*-----------------------------------------------------------*\
|
||||||
|
| Experimental for now; should be '16 or 63' for US and '28' |
|
||||||
|
| for EU layout |
|
||||||
|
\*-----------------------------------------------------------*/
|
||||||
|
if(version.length() < 17)
|
||||||
|
{
|
||||||
|
return("NONE");
|
||||||
|
}
|
||||||
|
std::string layout_id = version.substr(3, 2);
|
||||||
|
|
||||||
|
if(layout_id == "16" || layout_id == "63")
|
||||||
|
{
|
||||||
|
return("US");
|
||||||
|
}
|
||||||
|
|
||||||
|
return("EU");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string DasKeyboardController::GetLocationString()
|
||||||
{
|
{
|
||||||
return("HID: " + location);
|
return("HID: " + location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string DasKeyboardController::GetNameString()
|
||||||
|
{
|
||||||
|
return(name);
|
||||||
|
}
|
||||||
|
|
||||||
std::string DasKeyboardController::GetSerialString()
|
std::string DasKeyboardController::GetSerialString()
|
||||||
{
|
{
|
||||||
wchar_t serial_string[128];
|
wchar_t serial_string[128];
|
||||||
|
|
@ -64,26 +90,6 @@ std::string DasKeyboardController::GetVersionString()
|
||||||
return(fw_version);
|
return(fw_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DasKeyboardController::GetLayoutString()
|
|
||||||
{
|
|
||||||
/*-----------------------------------------------------------*\
|
|
||||||
| Experimental for now; should be '16 or 63' for US and '28' |
|
|
||||||
| for EU layout |
|
|
||||||
\*-----------------------------------------------------------*/
|
|
||||||
if(version.length() < 17)
|
|
||||||
{
|
|
||||||
return("NONE");
|
|
||||||
}
|
|
||||||
std::string layout_id = version.substr(3, 2);
|
|
||||||
|
|
||||||
if(layout_id == "16" || layout_id == "63")
|
|
||||||
{
|
|
||||||
return("US");
|
|
||||||
}
|
|
||||||
|
|
||||||
return("EU");
|
|
||||||
}
|
|
||||||
|
|
||||||
void DasKeyboardController::SendColors(unsigned char key_id, unsigned char mode,
|
void DasKeyboardController::SendColors(unsigned char key_id, unsigned char mode,
|
||||||
unsigned char red, unsigned char green, unsigned char blue)
|
unsigned char red, unsigned char green, unsigned char blue)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -18,26 +18,24 @@
|
||||||
class DasKeyboardController
|
class DasKeyboardController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DasKeyboardController(hid_device *dev_handle, const char *path);
|
DasKeyboardController(hid_device *dev_handle, const char *path, std::string dev_name);
|
||||||
|
|
||||||
~DasKeyboardController();
|
~DasKeyboardController();
|
||||||
|
|
||||||
std::string GetDeviceLocation();
|
std::string GetLayoutString();
|
||||||
|
std::string GetLocationString();
|
||||||
|
std::string GetNameString();
|
||||||
std::string GetSerialString();
|
std::string GetSerialString();
|
||||||
|
|
||||||
std::string GetVersionString();
|
std::string GetVersionString();
|
||||||
|
|
||||||
std::string GetLayoutString();
|
void SendColors(unsigned char key_id, unsigned char mode, unsigned char red, unsigned char green, unsigned char blue);
|
||||||
|
|
||||||
void SendColors(unsigned char key_id, unsigned char mode,
|
|
||||||
unsigned char red, unsigned char green, unsigned char blue);
|
|
||||||
|
|
||||||
void SendApply();
|
void SendApply();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
hid_device *dev;
|
hid_device *dev;
|
||||||
std::string location;
|
std::string location;
|
||||||
|
std::string name;
|
||||||
std::string version;
|
std::string version;
|
||||||
bool useTraditionalSendData;
|
bool useTraditionalSendData;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,33 +35,13 @@
|
||||||
* *
|
* *
|
||||||
\******************************************************************************************/
|
\******************************************************************************************/
|
||||||
|
|
||||||
void DetectDasKeyboardControllers(hid_device_info *info_in, const std::string &name)
|
void DetectDasKeyboardControllers(hid_device_info *info, const std::string &name)
|
||||||
{
|
{
|
||||||
hid_device_info *info = info_in;
|
|
||||||
|
|
||||||
while(info)
|
|
||||||
{
|
|
||||||
if(info->vendor_id == DAS_KEYBOARD_VID &&
|
|
||||||
(info->product_id == DAS_KEYBOARD_Q4_PID ||
|
|
||||||
info->product_id == DAS_KEYBOARD_Q5_PID ||
|
|
||||||
info->product_id == DAS_KEYBOARD_Q5S_PID) &&
|
|
||||||
info->interface_number == 1)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
info = info->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!info)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
hid_device *dev = hid_open_path(info->path);
|
hid_device *dev = hid_open_path(info->path);
|
||||||
|
|
||||||
if(dev)
|
if(dev)
|
||||||
{
|
{
|
||||||
DasKeyboardController *controller = new DasKeyboardController(dev, info->path);
|
DasKeyboardController *controller = new DasKeyboardController(dev, info->path, name);
|
||||||
|
|
||||||
if(controller->GetLayoutString() == "NONE")
|
if(controller->GetLayoutString() == "NONE")
|
||||||
{
|
{
|
||||||
|
|
@ -70,37 +50,12 @@ void DetectDasKeyboardControllers(hid_device_info *info_in, const std::string &n
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RGBController_DasKeyboard *rgb_controller = new RGBController_DasKeyboard(controller);
|
RGBController_DasKeyboard *rgb_controller = new RGBController_DasKeyboard(controller);
|
||||||
rgb_controller->SetupZones();
|
|
||||||
rgb_controller->name = name;
|
|
||||||
|
|
||||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} /* DetectDasKeyboardControllers() */
|
} /* DetectDasKeyboardControllers() */
|
||||||
|
|
||||||
void DetectDas4QKeyboard(hid_device_info *info, const std::string &name)
|
REGISTER_HID_DETECTOR_IPU("Das Keyboard Q4 RGB", DetectDasKeyboardControllers, DAS_KEYBOARD_VID, DAS_KEYBOARD_Q4_PID, 1, 0x01, 0x80);
|
||||||
{
|
|
||||||
hid_device *dev = hid_open_path(info->path);
|
|
||||||
|
|
||||||
if(dev)
|
|
||||||
{
|
|
||||||
DasKeyboardController *controller = new DasKeyboardController(dev, info->path);
|
|
||||||
|
|
||||||
if(controller->GetLayoutString() == "NONE")
|
|
||||||
{
|
|
||||||
delete controller;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RGBController_DasKeyboard *rgb_controller = new RGBController_DasKeyboard(controller);
|
|
||||||
rgb_controller->SetupZones();
|
|
||||||
rgb_controller->name = name;
|
|
||||||
|
|
||||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} /* DetectDas4QKeyboard() */
|
|
||||||
|
|
||||||
REGISTER_HID_DETECTOR_IPU("Das Keyboard Q4 RGB", DetectDas4QKeyboard, DAS_KEYBOARD_VID, DAS_KEYBOARD_Q4_PID, 1, 0x01, 0x80);
|
|
||||||
REGISTER_HID_DETECTOR_I ("Das Keyboard Q5 RGB", DetectDasKeyboardControllers, DAS_KEYBOARD_VID, DAS_KEYBOARD_Q5_PID, 1);
|
REGISTER_HID_DETECTOR_I ("Das Keyboard Q5 RGB", DetectDasKeyboardControllers, DAS_KEYBOARD_VID, DAS_KEYBOARD_Q5_PID, 1);
|
||||||
REGISTER_HID_DETECTOR_I ("Das Keyboard Q5S RGB", DetectDasKeyboardControllers, DAS_KEYBOARD_VID, DAS_KEYBOARD_Q5S_PID, 1);
|
REGISTER_HID_DETECTOR_I ("Das Keyboard Q5S RGB", DetectDasKeyboardControllers, DAS_KEYBOARD_VID, DAS_KEYBOARD_Q5S_PID, 1);
|
||||||
|
|
|
||||||
|
|
@ -214,11 +214,11 @@ RGBController_DasKeyboard::RGBController_DasKeyboard(DasKeyboardController* cont
|
||||||
|
|
||||||
updateDevice = true;
|
updateDevice = true;
|
||||||
|
|
||||||
name = "Das Keyboard Device";
|
name = controller->GetNameString();
|
||||||
vendor = "Metadot";
|
vendor = "Metadot";
|
||||||
type = DEVICE_TYPE_KEYBOARD;
|
type = DEVICE_TYPE_KEYBOARD;
|
||||||
description = "Das Keyboard Device";
|
description = "Das Keyboard Device";
|
||||||
location = controller->GetDeviceLocation();
|
location = controller->GetLocationString();
|
||||||
serial = controller->GetSerialString();
|
serial = controller->GetSerialString();
|
||||||
version = controller->GetVersionString();
|
version = controller->GetVersionString();
|
||||||
|
|
||||||
|
|
@ -242,6 +242,8 @@ RGBController_DasKeyboard::RGBController_DasKeyboard(DasKeyboardController* cont
|
||||||
modes[3].value = DAS_KEYBOARD_MODE_SPECTRUM_CYCLE;
|
modes[3].value = DAS_KEYBOARD_MODE_SPECTRUM_CYCLE;
|
||||||
modes[3].flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
modes[3].flags = MODE_FLAG_HAS_PER_LED_COLOR;
|
||||||
modes[3].color_mode = MODE_COLORS_PER_LED;
|
modes[3].color_mode = MODE_COLORS_PER_LED;
|
||||||
|
|
||||||
|
SetupZones();
|
||||||
}
|
}
|
||||||
|
|
||||||
RGBController_DasKeyboard::~RGBController_DasKeyboard()
|
RGBController_DasKeyboard::~RGBController_DasKeyboard()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue