Move HID detector calls to RunHIDDetector/RunHIDWrappedDetector functions and return controller list from detector functions

This commit is contained in:
Adam Honse
2026-01-12 19:05:21 -06:00
parent c46540339a
commit 8f29ad126e
191 changed files with 4362 additions and 4242 deletions

View File

@@ -14,20 +14,18 @@
#include "RGBController_WinbondGamingKeyboard.h"
#include "LogManager.h"
/*-----------------------------------------------------*\
| Winbond vendor ID |
\*-----------------------------------------------------*/
#define WINBOND_VID 0x0416
/*---------------------------------------------------------*\
| Winbond vendor ID |
\*---------------------------------------------------------*/
#define WINBOND_VID 0x0416
/*-----------------------------------------------------*\
| Winbond product ID |
\*-----------------------------------------------------*/
#define WINBOND_GAMING_KEYBOARD_PID 0xB23C
/*---------------------------------------------------------*\
| Winbond product ID |
\*---------------------------------------------------------*/
#define WINBOND_GAMING_KEYBOARD_PID 0xB23C
void DetectWinbondGamingKeyboard(hid_device_info* info, const std::string& name)
DetectedControllers DetectWinbondGamingKeyboard(hid_device_info* info, const std::string& name)
{
hid_device* dev = hid_open_path(info->path);
/*--------------------------------------------------------------------------------------------------*\
| NOTE: according to https://4pda.to/forum/index.php?showtopic=1061923, |
| the "KT108" keyboard, which has the same VID:PID, uses the product_string "KT108 keyboard" |
@@ -47,20 +45,26 @@ void DetectWinbondGamingKeyboard(hid_device_info* info, const std::string& name)
| or product_string, much less about its protocol (even if it uses the same firmware, |
| I don't know which key corresponds to which bytes in the HID message that sets the per-key colors) |
\*--------------------------------------------------------------------------------------------------*/
DetectedControllers detected_controllers;
hid_device* dev;
dev = hid_open_path(info->path);
if(dev)
{
LOG_INFO("Detected WinbondGamingKeyboard at %s, product_string is %ls name is %s", info->path, info->product_string, name.c_str());
WinbondGamingKeyboardController* controller = new WinbondGamingKeyboardController(dev, *info, name);
RGBController* rgb_controller = new RGBController_WinbondGamingKeyboard(controller);
WinbondGamingKeyboardController* controller = new WinbondGamingKeyboardController(dev, *info, name);
RGBController* rgb_controller = new RGBController_WinbondGamingKeyboard(controller);
DetectionManager::get()->RegisterRGBController(rgb_controller);
detected_controllers.push_back(rgb_controller);
}
else
{
LOG_WARNING("Couldn't open hid dev %s: %ls", info->path, hid_error(NULL));
}
return(detected_controllers);
}
REGISTER_HID_DETECTOR_PU("Winbond Gaming Keyboard", DetectWinbondGamingKeyboard, WINBOND_VID, WINBOND_GAMING_KEYBOARD_PID, 0xFF1B, 0x91);