Splitting out the WootingTwoKeyboardController

* Added WootingOneKeyboardController.h
* Added WootingOneKeyboardController.cpp
* Added WootingTwoKeyboardController.h
* Added WootingTwoKeyboardController.cpp
* Unified the WootingKeyboardController as a virtual class
* Modified WootingKeyboardControllerDetect to use the new controllers
* Wooting One & Two use the old controller
* Wooting Two LE & HE use the new controller
* Adding Udev rules for the WootingTwo LE & HE
This commit is contained in:
Chris 2021-07-16 10:20:35 +10:00 committed by Adam Honse
parent 41ac14dd41
commit 84de7ebc3e
10 changed files with 498 additions and 307 deletions

View file

@ -1,5 +1,6 @@
#include "Detector.h"
#include "WootingKeyboardController.h"
#include "WootingOneKeyboardController.h"
#include "WootingTwoKeyboardController.h"
#include "RGBController.h"
#include "RGBController_WootingKeyboard.h"
#include "LogManager.h"
@ -20,9 +21,10 @@
#define WOOTING_TWO_LE_PID 0x1210
#define WOOTING_TWO_HE_PID 0x1220
void DetectWootingKeyboardControllers(hid_device_info* info, const std::string& name)
void DetectWootingOneKeyboardControllers(hid_device_info* info, const std::string& name)
{
LOG_DEBUG("[Wooting KB] Interface %i\tPage %04X\tUsage %i\tPath %s", info->interface_number, info->usage_page, info->usage, info->path);
static const char* controller_name = "WootingONE";
LOG_DEBUG("[%s] Interface %i\tPage %04X\tUsage %i\tPath %s", controller_name, info->interface_number, info->usage_page, info->usage, info->path);
hid_device* dev = hid_open_path(info->path);
@ -30,19 +32,40 @@ void DetectWootingKeyboardControllers(hid_device_info* info, const std::string&
{
uint8_t wooting_type = (info->product_id == WOOTING_ONE_PID) ? WOOTING_KB_TKL : WOOTING_KB_FULL;
LOG_DEBUG("[Wooting KB] Device type %i opened - creating Controller", wooting_type);
WootingKeyboardController* controller = new WootingKeyboardController(dev, info->path, wooting_type);
LOG_DEBUG("[%s] Device type %i opened - creating Controller", controller_name, wooting_type);
WootingOneKeyboardController* controller = new WootingOneKeyboardController(dev, info->path, wooting_type);
LOG_DEBUG("[Wooting KB] Controller created - creating RGBController");
RGBController_WootingKeyboard* rgb_controller = new RGBController_WootingKeyboard(controller);
LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name);
RGBController_WootingKeyboard* rgb_controller = new RGBController_WootingKeyboard(controller);
rgb_controller->name = name;
LOG_DEBUG("[Wooting KB] Initialization complete - Registering controller\t%s", name.c_str());
LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str());
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
} /* DetectWootingKeyboardControllers */
}
REGISTER_HID_DETECTOR_PU("Wooting ONE Keyboard", DetectWootingKeyboardControllers, WOOTING_OLD_VID, WOOTING_ONE_PID, 0x1337, 1);
REGISTER_HID_DETECTOR_PU("Wooting TWO Keyboard", DetectWootingKeyboardControllers, WOOTING_OLD_VID, WOOTING_TWO_PID, 0x1337, 1);
REGISTER_HID_DETECTOR_PU("Wooting TWO Keyboard LE", DetectWootingKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_LE_PID, 0x1337, 1);
REGISTER_HID_DETECTOR_PU("Wooting TWO Keyboard HE", DetectWootingKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_HE_PID, 0x1337, 1);
void DetectWootingTwoKeyboardControllers(hid_device_info* info, const std::string& name)
{
static const char* controller_name = "WootingTWO";
LOG_DEBUG("[%s] Interface %i\tPage %04X\tUsage %i\tPath %s", controller_name, info->interface_number, info->usage_page, info->usage, info->path);
hid_device* dev = hid_open_path(info->path);
if(dev)
{
LOG_DEBUG("[%s] Device type %i opened - creating Controller", controller_name, WOOTING_KB_FULL);
WootingTwoKeyboardController* controller = new WootingTwoKeyboardController(dev, info->path, WOOTING_KB_FULL);
LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name);
RGBController_WootingKeyboard* rgb_controller = new RGBController_WootingKeyboard(controller);
rgb_controller->name = name;
LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str());
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
REGISTER_HID_DETECTOR_PU("Wooting ONE Keyboard", DetectWootingOneKeyboardControllers, WOOTING_OLD_VID, WOOTING_ONE_PID, 0x1337, 1);
REGISTER_HID_DETECTOR_PU("Wooting TWO Keyboard", DetectWootingOneKeyboardControllers, WOOTING_OLD_VID, WOOTING_TWO_PID, 0x1337, 1);
REGISTER_HID_DETECTOR_PU("Wooting TWO Keyboard LE", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_LE_PID, 0x1337, 1);
REGISTER_HID_DETECTOR_PU("Wooting TWO Keyboard HE", DetectWootingTwoKeyboardControllers, WOOTING_NEW_VID, WOOTING_TWO_HE_PID, 0x1337, 1);