Store name in GaiZhongGaiControllers to avoid setting it in detector

This commit is contained in:
Adam Honse 2025-08-08 11:26:55 -05:00
parent 0afcdbd0ca
commit 2927135cdd
4 changed files with 68 additions and 77 deletions

View file

@ -22,10 +22,11 @@
| https://oshwhub.com/morempty/CH552gyin-liang-xuan-niu | | https://oshwhub.com/morempty/CH552gyin-liang-xuan-niu |
\*---------------------------------------------------------------*/ \*---------------------------------------------------------------*/
GaiZhongGaiKeyboardController::GaiZhongGaiKeyboardController(hid_device* dev_handle, hid_device_info* info) GaiZhongGaiKeyboardController::GaiZhongGaiKeyboardController(hid_device* dev_handle, hid_device_info* info, std::string dev_name)
{ {
dev = dev_handle; dev = dev_handle;
location = info->path; location = info->path;
name = dev_name;
usb_pid = info->product_id; usb_pid = info->product_id;
/*-----------------------------------------------------*\ /*-----------------------------------------------------*\
| Obtaining the Firmware Version | | Obtaining the Firmware Version |
@ -163,6 +164,11 @@ std::string GaiZhongGaiKeyboardController::GetDeviceLocation()
return("HID: " + location); return("HID: " + location);
} }
std::string GaiZhongGaiKeyboardController::GetNameString()
{
return(name);
}
std::string GaiZhongGaiKeyboardController::GetSerialString() std::string GaiZhongGaiKeyboardController::GetSerialString()
{ {
wchar_t serial_string[128]; wchar_t serial_string[128];

View file

@ -40,10 +40,11 @@
class GaiZhongGaiKeyboardController class GaiZhongGaiKeyboardController
{ {
public: public:
GaiZhongGaiKeyboardController(hid_device* dev_handle, hid_device_info* info); GaiZhongGaiKeyboardController(hid_device* dev_handle, hid_device_info* info, std::string dev_name);
~GaiZhongGaiKeyboardController(); ~GaiZhongGaiKeyboardController();
std::string GetDeviceLocation(); std::string GetDeviceLocation();
std::string GetNameString();
std::string GetSerialString(); std::string GetSerialString();
std::string GetVersion(); std::string GetVersion();
unsigned short GetUSBPID(); unsigned short GetUSBPID();
@ -60,6 +61,7 @@ public:
private: private:
hid_device* dev; hid_device* dev;
std::string location; std::string location;
std::string name;
std::string version; std::string version;
unsigned short usb_pid; unsigned short usb_pid;
uint8_t data_flash[128]; uint8_t data_flash[128];

View file

@ -25,11 +25,12 @@
void DetectGaiZhongGaiKeyboardControllers(hid_device_info* info, const std::string& name) void DetectGaiZhongGaiKeyboardControllers(hid_device_info* info, const std::string& name)
{ {
hid_device* dev = hid_open_path(info->path); hid_device* dev = hid_open_path(info->path);
if( dev )
if(dev)
{ {
GaiZhongGaiKeyboardController* controller = new GaiZhongGaiKeyboardController(dev, info); GaiZhongGaiKeyboardController* controller = new GaiZhongGaiKeyboardController(dev, info, name);
RGBController_GaiZhongGaiKeyboard* rgb_controller = new RGBController_GaiZhongGaiKeyboard(controller); RGBController_GaiZhongGaiKeyboard* rgb_controller = new RGBController_GaiZhongGaiKeyboard(controller);
rgb_controller->name = name;
ResourceManager::get()->RegisterRGBController(rgb_controller); ResourceManager::get()->RegisterRGBController(rgb_controller);
} }
} /* DetectGaiZhongGaiKeyboardControllers() */ } /* DetectGaiZhongGaiKeyboardControllers() */

View file

@ -383,85 +383,67 @@ uint16_t LightBoard_init(uint8_t* p_in)
RGBController_GaiZhongGaiKeyboard::RGBController_GaiZhongGaiKeyboard(GaiZhongGaiKeyboardController* controller_ptr) RGBController_GaiZhongGaiKeyboard::RGBController_GaiZhongGaiKeyboard(GaiZhongGaiKeyboardController* controller_ptr)
{ {
controller = controller_ptr; controller = controller_ptr;
name = controller->GetNameString();
switch(controller->GetUSBPID()) switch(controller->GetUSBPID())
{ {
case GAIZHONGGAI_68_PRO_PID: case GAIZHONGGAI_68_PRO_PID:
{ type = DEVICE_TYPE_KEYBOARD;
name = "GaiZhongGai Keyboard Device"; description = "https://oshwhub.com/yangzen/zui-gai68-/";
type = DEVICE_TYPE_KEYBOARD; break;
description = "https://oshwhub.com/yangzen/zui-gai68-/";
} case GAIZHONGGAI_42_PRO_PID:
break; type = DEVICE_TYPE_KEYBOARD;
case GAIZHONGGAI_42_PRO_PID: description = "https://oshwhub.com/myng/42-jian-pan/";
{ break;
name = "GaiZhongGai Keyboard Device";
type = DEVICE_TYPE_KEYBOARD; case GAIZHONGGAI_17_TOUCH_PRO_PID:
description = "https://oshwhub.com/myng/42-jian-pan/"; type = DEVICE_TYPE_KEYPAD;
} description = "https://oshwhub.com/yangzen/xing-huo-ji-hua-zui-gai-17-4-chu-mo-ji-xie-jian-pan-pro/";
break; break;
case GAIZHONGGAI_17_TOUCH_PRO_PID:
{ case GAIZHONGGAI_17_PRO_PID:
name = "GaiZhongGai Keyboard Device"; type = DEVICE_TYPE_KEYPAD;
type = DEVICE_TYPE_KEYPAD; description = "https://oshwhub.com/hivisme/17jian-shuo-zi-xiao-jian-pan/";
description = "https://oshwhub.com/yangzen/xing-huo-ji-hua-zui-gai-17-4-chu-mo-ji-xie-jian-pan-pro/"; break;
}
break; case GAIZHONGGAI_20_PRO_PID:
case GAIZHONGGAI_17_PRO_PID: type = DEVICE_TYPE_KEYPAD;
{ description = "https://oshwhub.com/runkuny/19keys_pad_normal/";
name = "GaiZhongGai Keyboard Device"; break;
type = DEVICE_TYPE_KEYPAD;
description = "https://oshwhub.com/hivisme/17jian-shuo-zi-xiao-jian-pan/"; case GAIZHONGGAI_LIGHT_BOARD_PID:
} type = DEVICE_TYPE_ACCESSORY;
break; description = "https://oshwhub.com/yangzen/xing-huo-2-qi-guang-ban-qu-dong-/";
case GAIZHONGGAI_20_PRO_PID: break;
{
name = "GaiZhongGai Keyboard Device"; case GAIZHONGGAI_RGB_HUB_GREEN_PID:
type = DEVICE_TYPE_KEYPAD; type = DEVICE_TYPE_LEDSTRIP;
description = "https://oshwhub.com/runkuny/19keys_pad_normal/"; description = "https://oshwhub.com/yangzen/album/gai-zhong-gai-jian-pan-ge-ji/";
} break;
break;
case GAIZHONGGAI_LIGHT_BOARD_PID: case GAIZHONGGAI_RGB_HUB_BLUE_PID:
{ type = DEVICE_TYPE_LEDSTRIP;
name = "GaiZhongGai Controller Device"; description = "https://oshwhub.com/yangzen/album/gai-zhong-gai-jian-pan-ge-ji/";
type = DEVICE_TYPE_ACCESSORY; break;
description = "https://oshwhub.com/yangzen/xing-huo-2-qi-guang-ban-qu-dong-/";
} case GAIZHONGGAI_DIAL_PID:
break; type = DEVICE_TYPE_UNKNOWN;
case GAIZHONGGAI_RGB_HUB_GREEN_PID: description = "https://oshwhub.com/morempty/CH552gyin-liang-xuan-niu/";
{ break;
name = "GaiZhongGai Controller Device";
type = DEVICE_TYPE_LEDSTRIP;
description = "https://oshwhub.com/yangzen/album/gai-zhong-gai-jian-pan-ge-ji/";
}
break;
case GAIZHONGGAI_RGB_HUB_BLUE_PID:
{
name = "GaiZhongGai Controller Device";
type = DEVICE_TYPE_LEDSTRIP;
description = "https://oshwhub.com/yangzen/album/gai-zhong-gai-jian-pan-ge-ji/";
}
break;
case GAIZHONGGAI_DIAL_PID:
{
name = "GaiZhongGai DIAL Device";
type = DEVICE_TYPE_UNKNOWN;
description = "https://oshwhub.com/morempty/CH552gyin-liang-xuan-niu/";
}
break;
} }
vendor = "Yang"; vendor = "Yang";
version = controller->GetVersion(); version = controller->GetVersion();
location = controller->GetDeviceLocation(); location = controller->GetDeviceLocation();
serial = controller->GetSerialString(); serial = controller->GetSerialString();
mode Direct; mode Direct;
Direct.name = "Direct"; Direct.name = "Direct";
Direct.value = 0xFFFF; Direct.value = 0xFFFF;
Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR; Direct.flags = MODE_FLAG_HAS_PER_LED_COLOR;
Direct.color_mode = MODE_COLORS_PER_LED; Direct.color_mode = MODE_COLORS_PER_LED;
modes.push_back(Direct); modes.push_back(Direct);
SetupZones(); SetupZones();