Publish curated LumaOps source from c85ee9ef8f1454f5c305398902afbb9e6738de40
Managed validation / full (push) Failing after 8s
Managed validation / full (push) Failing after 8s
This commit is contained in:
1 parent
91f8b3e3c1
commit
def7920856
2271 files changed
+501225
-501178
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -1,34 +1,34 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_WootingKeyboard.h |
|
||||
| |
|
||||
| RGBController for Wooting keyboard |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "WootingKeyboardController.h"
|
||||
|
||||
class RGBController_WootingKeyboard : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_WootingKeyboard(WootingKeyboardController* controller_ptr);
|
||||
~RGBController_WootingKeyboard();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
WootingKeyboardController* controller;
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| RGBController_WootingKeyboard.h |
|
||||
| |
|
||||
| RGBController for Wooting keyboard |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RGBController.h"
|
||||
#include "WootingKeyboardController.h"
|
||||
|
||||
class RGBController_WootingKeyboard : public RGBController
|
||||
{
|
||||
public:
|
||||
RGBController_WootingKeyboard(WootingKeyboardController* controller_ptr);
|
||||
~RGBController_WootingKeyboard();
|
||||
|
||||
void SetupZones();
|
||||
void ResizeZone(int zone, int new_size);
|
||||
|
||||
void DeviceUpdateLEDs();
|
||||
void UpdateZoneLEDs(int zone);
|
||||
void UpdateSingleLED(int led);
|
||||
|
||||
void DeviceUpdateMode();
|
||||
|
||||
private:
|
||||
WootingKeyboardController* controller;
|
||||
};
|
||||
@@ -1,90 +1,90 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingKeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Wooting keyboard |
|
||||
| |
|
||||
| Chris M (Dr_No) 09 Jul 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "StringUtils.h"
|
||||
#include "WootingKeyboardController.h"
|
||||
|
||||
WootingKeyboardController::WootingKeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
WootingKeyboardController::~WootingKeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string WootingKeyboardController::GetName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string WootingKeyboardController::GetVendor()
|
||||
{
|
||||
return vendor;
|
||||
}
|
||||
|
||||
std::string WootingKeyboardController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string WootingKeyboardController::GetDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
std::string WootingKeyboardController::GetSerial()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
WOOTING_DEVICE_TYPE WootingKeyboardController::GetWootingType()
|
||||
{
|
||||
return wooting_type;
|
||||
}
|
||||
|
||||
void WootingKeyboardController::SendInitialize()
|
||||
{
|
||||
wooting_usb_send_feature(WOOTING_COLOR_INIT_COMMAND, 0,0,0,0);
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
}
|
||||
|
||||
bool WootingKeyboardController::wooting_usb_send_feature(uint8_t commandId, uint8_t parameter0, uint8_t parameter1, uint8_t parameter2, uint8_t parameter3)
|
||||
{
|
||||
uint8_t feature_buffer[WOOTING_COMMAND_SIZE] = { 0, 0xD0, 0xDA };
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up the Send Feature packet |
|
||||
\*---------------------------------------------------------*/
|
||||
feature_buffer[3] = commandId;
|
||||
feature_buffer[4] = parameter3;
|
||||
feature_buffer[5] = parameter2;
|
||||
feature_buffer[6] = parameter1;
|
||||
feature_buffer[7] = parameter0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*---------------------------------------------------------*/
|
||||
uint8_t report_size = hid_send_feature_report(dev, feature_buffer, WOOTING_COMMAND_SIZE);
|
||||
LOG_DEBUG("%sSend feature returned - %04i expected %04i", WOOTING_CONTROLLER_NAME, report_size, WOOTING_COMMAND_SIZE);
|
||||
return (report_size == WOOTING_COMMAND_SIZE);
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingKeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Wooting keyboard |
|
||||
| |
|
||||
| Chris M (Dr_No) 09 Jul 2021 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "StringUtils.h"
|
||||
#include "WootingKeyboardController.h"
|
||||
|
||||
WootingKeyboardController::WootingKeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
WootingKeyboardController::~WootingKeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string WootingKeyboardController::GetName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string WootingKeyboardController::GetVendor()
|
||||
{
|
||||
return vendor;
|
||||
}
|
||||
|
||||
std::string WootingKeyboardController::GetLocation()
|
||||
{
|
||||
return("HID: " + location);
|
||||
}
|
||||
|
||||
std::string WootingKeyboardController::GetDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
std::string WootingKeyboardController::GetSerial()
|
||||
{
|
||||
wchar_t serial_string[128];
|
||||
int ret = hid_get_serial_number_string(dev, serial_string, 128);
|
||||
|
||||
if(ret != 0)
|
||||
{
|
||||
return("");
|
||||
}
|
||||
|
||||
return(StringUtils::wstring_to_string(serial_string));
|
||||
}
|
||||
|
||||
WOOTING_DEVICE_TYPE WootingKeyboardController::GetWootingType()
|
||||
{
|
||||
return wooting_type;
|
||||
}
|
||||
|
||||
void WootingKeyboardController::SendInitialize()
|
||||
{
|
||||
wooting_usb_send_feature(WOOTING_COLOR_INIT_COMMAND, 0,0,0,0);
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||
}
|
||||
|
||||
bool WootingKeyboardController::wooting_usb_send_feature(uint8_t commandId, uint8_t parameter0, uint8_t parameter1, uint8_t parameter2, uint8_t parameter3)
|
||||
{
|
||||
uint8_t feature_buffer[WOOTING_COMMAND_SIZE] = { 0, 0xD0, 0xDA };
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up the Send Feature packet |
|
||||
\*---------------------------------------------------------*/
|
||||
feature_buffer[3] = commandId;
|
||||
feature_buffer[4] = parameter3;
|
||||
feature_buffer[5] = parameter2;
|
||||
feature_buffer[6] = parameter1;
|
||||
feature_buffer[7] = parameter0;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*---------------------------------------------------------*/
|
||||
uint8_t report_size = hid_send_feature_report(dev, feature_buffer, WOOTING_COMMAND_SIZE);
|
||||
LOG_DEBUG("%sSend feature returned - %04i expected %04i", WOOTING_CONTROLLER_NAME, report_size, WOOTING_COMMAND_SIZE);
|
||||
return (report_size == WOOTING_COMMAND_SIZE);
|
||||
}
|
||||
@@ -1,83 +1,83 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingKeyboardController.h |
|
||||
| |
|
||||
| Driver for Wooting keyboard |
|
||||
| |
|
||||
| Chris M (Dr_No) 09 Jul 2021 |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
#define WOOTING_COMMAND_SIZE 8
|
||||
#define WOOTING_RAW_COLORS_REPORT 11
|
||||
#define WOOTING_SINGLE_COLOR_COMMAND 30
|
||||
#define WOOTING_SINGLE_RESET_COMMAND 31
|
||||
#define WOOTING_RESET_ALL_COMMAND 32
|
||||
#define WOOTING_COLOR_INIT_COMMAND 33
|
||||
|
||||
|
||||
#define WOOTING_RGB_ROWS 6
|
||||
#define WOOTING_RGB_COLUMNS 21
|
||||
|
||||
#define WOOTING_ONE_RGB_COLUMNS 17
|
||||
#define WOOTING_TWO_RGB_COLUMNS 21
|
||||
#define WOOTING_60_RGB_COLUMNS 14
|
||||
#define WOOTING_3PAD_RGB_COLUMNS 7
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Placeholder for compilation. Redefined by each subclass |
|
||||
\*---------------------------------------------------------*/
|
||||
#define WOOTING_CONTROLLER_NAME "[Wooting] "
|
||||
|
||||
enum WOOTING_DEVICE_TYPE
|
||||
{
|
||||
WOOTING_KB_TKL = 0,
|
||||
WOOTING_KB_FULL = 1,
|
||||
WOOTING_KB_60PER = 2,
|
||||
WOOTING_KB_3PAD = 3,
|
||||
WOOTING_KB_80PER = 4,
|
||||
};
|
||||
|
||||
enum RGB_PARTS
|
||||
{
|
||||
PART0,
|
||||
PART1,
|
||||
PART2,
|
||||
PART3,
|
||||
PART4
|
||||
};
|
||||
|
||||
class WootingKeyboardController
|
||||
{
|
||||
public:
|
||||
WootingKeyboardController();
|
||||
virtual ~WootingKeyboardController();
|
||||
|
||||
hid_device* dev;
|
||||
std::string name;
|
||||
std::string vendor;
|
||||
std::string description;
|
||||
std::string location;
|
||||
WOOTING_DEVICE_TYPE wooting_type;
|
||||
|
||||
std::string GetName();
|
||||
std::string GetVendor();
|
||||
std::string GetDescription();
|
||||
std::string GetLocation();
|
||||
std::string GetSerial();
|
||||
WOOTING_DEVICE_TYPE GetWootingType();
|
||||
bool wooting_usb_send_feature(uint8_t command, uint8_t param0,
|
||||
uint8_t param1, uint8_t param2, uint8_t param3);
|
||||
|
||||
virtual void SendDirect(RGBColor* colors, uint8_t color_count) = 0;
|
||||
virtual void SendInitialize();
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingKeyboardController.h |
|
||||
| |
|
||||
| Driver for Wooting keyboard |
|
||||
| |
|
||||
| Chris M (Dr_No) 09 Jul 2021 |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <hidapi.h>
|
||||
#include "RGBController.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
#define WOOTING_COMMAND_SIZE 8
|
||||
#define WOOTING_RAW_COLORS_REPORT 11
|
||||
#define WOOTING_SINGLE_COLOR_COMMAND 30
|
||||
#define WOOTING_SINGLE_RESET_COMMAND 31
|
||||
#define WOOTING_RESET_ALL_COMMAND 32
|
||||
#define WOOTING_COLOR_INIT_COMMAND 33
|
||||
|
||||
|
||||
#define WOOTING_RGB_ROWS 6
|
||||
#define WOOTING_RGB_COLUMNS 21
|
||||
|
||||
#define WOOTING_ONE_RGB_COLUMNS 17
|
||||
#define WOOTING_TWO_RGB_COLUMNS 21
|
||||
#define WOOTING_60_RGB_COLUMNS 14
|
||||
#define WOOTING_3PAD_RGB_COLUMNS 7
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Placeholder for compilation. Redefined by each subclass |
|
||||
\*---------------------------------------------------------*/
|
||||
#define WOOTING_CONTROLLER_NAME "[Wooting] "
|
||||
|
||||
enum WOOTING_DEVICE_TYPE
|
||||
{
|
||||
WOOTING_KB_TKL = 0,
|
||||
WOOTING_KB_FULL = 1,
|
||||
WOOTING_KB_60PER = 2,
|
||||
WOOTING_KB_3PAD = 3,
|
||||
WOOTING_KB_80PER = 4,
|
||||
};
|
||||
|
||||
enum RGB_PARTS
|
||||
{
|
||||
PART0,
|
||||
PART1,
|
||||
PART2,
|
||||
PART3,
|
||||
PART4
|
||||
};
|
||||
|
||||
class WootingKeyboardController
|
||||
{
|
||||
public:
|
||||
WootingKeyboardController();
|
||||
virtual ~WootingKeyboardController();
|
||||
|
||||
hid_device* dev;
|
||||
std::string name;
|
||||
std::string vendor;
|
||||
std::string description;
|
||||
std::string location;
|
||||
WOOTING_DEVICE_TYPE wooting_type;
|
||||
|
||||
std::string GetName();
|
||||
std::string GetVendor();
|
||||
std::string GetDescription();
|
||||
std::string GetLocation();
|
||||
std::string GetSerial();
|
||||
WOOTING_DEVICE_TYPE GetWootingType();
|
||||
bool wooting_usb_send_feature(uint8_t command, uint8_t param0,
|
||||
uint8_t param1, uint8_t param2, uint8_t param3);
|
||||
|
||||
virtual void SendDirect(RGBColor* colors, uint8_t color_count) = 0;
|
||||
virtual void SendInitialize();
|
||||
};
|
||||
@@ -1,186 +1,186 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingKeyboardControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Wooting keyboard |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <hidapi.h>
|
||||
#include "Detector.h"
|
||||
#include "WootingV1KeyboardController.h"
|
||||
#include "WootingV2KeyboardController.h"
|
||||
#include "WootingV3KeyboardController.h"
|
||||
#include "RGBController_WootingKeyboard.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
#define WOOTING_CONFIG_USAGE_PAGE_V2 0x1337
|
||||
#define WOOTING_CONFIG_USAGE_PAGE_V3 0xFF55
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Wooting vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define WOOTING_OLD_VID 0x03EB
|
||||
#define WOOTING_NEW_VID 0x31E3
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Keyboard product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define WOOTING_ONE_LEGACY_PID 0xFF01
|
||||
#define WOOTING_TWO_LEGACY_PID 0xFF02
|
||||
#define WOOTING_ONE_PID 0x1100
|
||||
#define WOOTING_TWO_PID 0x1200
|
||||
#define WOOTING_TWO_LE_PID 0x1210
|
||||
#define WOOTING_TWO_HE_PID 0x1220
|
||||
#define WOOTING_TWO_HE_ARM_PID 0x1230
|
||||
#define WOOTING_60HE_PID 0x1300
|
||||
#define WOOTING_60HE_ARM_PID 0x1310
|
||||
#define WOOTING_60HE_PLUS_PID 0x1320
|
||||
#define WOOTING_60HE_V2_PID 0x1340
|
||||
#define WOOTING_80HE_PID 0x1400
|
||||
#define WOOTING_UWU_RGB_PID 0x1510
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Product ID helpers |
|
||||
| XINP: Xbox input emulation enabled |
|
||||
| DINP: Classic DirectInput emulation enabled |
|
||||
| NONE: Controller emulation disabled |
|
||||
\*-----------------------------------------------------*/
|
||||
#define XINP_PID(pid) (pid | 0x0000)
|
||||
#define DINP_PID(pid) (pid | 0x0001)
|
||||
#define NONE_PID(pid) (pid | 0x0002)
|
||||
|
||||
void DetectWootingControllers(hid_device_info *info, const std::string &name)
|
||||
{
|
||||
static const char *controller_name = "Wooting";
|
||||
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)
|
||||
return;
|
||||
|
||||
WOOTING_DEVICE_TYPE wooting_type;
|
||||
uint16_t pid = info->product_id;
|
||||
|
||||
if(pid == WOOTING_ONE_LEGACY_PID)
|
||||
{
|
||||
wooting_type = WOOTING_KB_TKL;
|
||||
}
|
||||
else if(pid == WOOTING_TWO_LEGACY_PID)
|
||||
{
|
||||
wooting_type = WOOTING_KB_FULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
//on modern devices, mask out the last nibble to get base PID
|
||||
switch(pid & 0xFFF0)
|
||||
{
|
||||
case WOOTING_ONE_LEGACY_PID:
|
||||
case WOOTING_ONE_PID:
|
||||
wooting_type = WOOTING_KB_TKL;
|
||||
break;
|
||||
case WOOTING_TWO_LEGACY_PID:
|
||||
case WOOTING_TWO_PID:
|
||||
case WOOTING_TWO_LE_PID:
|
||||
case WOOTING_TWO_HE_PID:
|
||||
case WOOTING_TWO_HE_ARM_PID:
|
||||
wooting_type = WOOTING_KB_FULL;
|
||||
break;
|
||||
case WOOTING_60HE_PID:
|
||||
case WOOTING_60HE_ARM_PID:
|
||||
case WOOTING_60HE_PLUS_PID:
|
||||
case WOOTING_60HE_V2_PID:
|
||||
wooting_type = WOOTING_KB_60PER;
|
||||
break;
|
||||
case WOOTING_80HE_PID:
|
||||
wooting_type = WOOTING_KB_80PER;
|
||||
break;
|
||||
case WOOTING_UWU_RGB_PID:
|
||||
wooting_type = WOOTING_KB_3PAD;
|
||||
break;
|
||||
default:
|
||||
//default to largest keyboard if unknown
|
||||
wooting_type = WOOTING_KB_FULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("[%s] Detected Wooting device type %i for device at path %s", controller_name, wooting_type, info->path);
|
||||
|
||||
//V1 firmware used the ATMEL VID, and uses the V1 controller
|
||||
if(info->vendor_id == WOOTING_OLD_VID && info->usage_page == WOOTING_CONFIG_USAGE_PAGE_V2)
|
||||
{
|
||||
LOG_DEBUG("[%s] Old VID detected - creating V1 Controller", controller_name);
|
||||
WootingV1KeyboardController *controller = new WootingV1KeyboardController(dev, info->path, wooting_type, name);
|
||||
|
||||
LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name);
|
||||
RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller);
|
||||
|
||||
LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str());
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
return;
|
||||
}
|
||||
|
||||
//V2-V2.11 firmware uses the V2 protocol indicated by the V2 usage page
|
||||
if(info->usage_page == WOOTING_CONFIG_USAGE_PAGE_V2)
|
||||
{
|
||||
LOG_DEBUG("[%s] V2 usage page detected - creating V2 Controller", controller_name);
|
||||
WootingV2KeyboardController *controller = new WootingV2KeyboardController(dev, info->path, wooting_type, name);
|
||||
|
||||
LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name);
|
||||
RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller);
|
||||
|
||||
LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str());
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
return;
|
||||
}
|
||||
|
||||
//V2.12+ firmware uses the new report structure indicated by the V3 usage page
|
||||
if(info->usage_page == WOOTING_CONFIG_USAGE_PAGE_V3)
|
||||
{
|
||||
LOG_DEBUG("[%s] V3 usage page detected - creating V3 Controller", controller_name);
|
||||
WootingV3KeyboardController *controller = new WootingV3KeyboardController(dev, info->path, wooting_type, name);
|
||||
|
||||
LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name);
|
||||
RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller);
|
||||
|
||||
LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str());
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
return;
|
||||
}
|
||||
|
||||
hid_close(dev);
|
||||
|
||||
LOG_TRACE("[%s] No compatible Wooting controller found for device at path %s", controller_name, info->path);
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| Wooting keyboards use different PIDs based on which |
|
||||
| gamepad emulation mode is selected. We can use their |
|
||||
| base PID, and set the last nibble to get the modes. |
|
||||
\*-----------------------------------------------------*/
|
||||
#define REGISTER_WOOTING_DETECTOR(name, vid, pid) \
|
||||
static HIDDeviceDetector detector_wooting_##vid##_##pid##_base(name, DetectWootingControllers, vid, NONE_PID(pid), HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY); \
|
||||
static HIDDeviceDetector detector_wooting_##vid##_##pid##_xinp(name, DetectWootingControllers, vid, XINP_PID(pid), HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY); \
|
||||
static HIDDeviceDetector detector_wooting_##vid##_##pid##_dinp(name, DetectWootingControllers, vid, DINP_PID(pid), HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY)
|
||||
|
||||
|
||||
// Legacy devices with V1 firmware
|
||||
REGISTER_HID_DETECTOR_P("Wooting One (Legacy)", DetectWootingControllers, WOOTING_OLD_VID, WOOTING_ONE_LEGACY_PID, WOOTING_CONFIG_USAGE_PAGE_V2);
|
||||
REGISTER_HID_DETECTOR_P("Wooting Two (Legacy)", DetectWootingControllers, WOOTING_OLD_VID, WOOTING_TWO_LEGACY_PID, WOOTING_CONFIG_USAGE_PAGE_V2);
|
||||
|
||||
// All other devices
|
||||
REGISTER_WOOTING_DETECTOR("Wooting One", WOOTING_NEW_VID, WOOTING_ONE_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting Two", WOOTING_NEW_VID, WOOTING_TWO_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting Two Lekker Edition", WOOTING_NEW_VID, WOOTING_TWO_LE_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting Two HE", WOOTING_NEW_VID, WOOTING_TWO_HE_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting Two HE (ARM)", WOOTING_NEW_VID, WOOTING_TWO_HE_ARM_PID);
|
||||
REGISTER_WOOTING_DETECTOR("Wooting 60HE", WOOTING_NEW_VID, WOOTING_60HE_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting 60HE (ARM)", WOOTING_NEW_VID, WOOTING_60HE_ARM_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting 60HE+", WOOTING_NEW_VID, WOOTING_60HE_PLUS_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting 60HEv2", WOOTING_NEW_VID, WOOTING_60HE_V2_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting 80HE", WOOTING_NEW_VID, WOOTING_80HE_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting UwU RGB", WOOTING_NEW_VID, WOOTING_UWU_RGB_PID );
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingKeyboardControllerDetect.cpp |
|
||||
| |
|
||||
| Detector for Wooting keyboard |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <hidapi.h>
|
||||
#include "Detector.h"
|
||||
#include "WootingV1KeyboardController.h"
|
||||
#include "WootingV2KeyboardController.h"
|
||||
#include "WootingV3KeyboardController.h"
|
||||
#include "RGBController_WootingKeyboard.h"
|
||||
#include "LogManager.h"
|
||||
|
||||
#define WOOTING_CONFIG_USAGE_PAGE_V2 0x1337
|
||||
#define WOOTING_CONFIG_USAGE_PAGE_V3 0xFF55
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Wooting vendor ID |
|
||||
\*-----------------------------------------------------*/
|
||||
#define WOOTING_OLD_VID 0x03EB
|
||||
#define WOOTING_NEW_VID 0x31E3
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Keyboard product IDs |
|
||||
\*-----------------------------------------------------*/
|
||||
#define WOOTING_ONE_LEGACY_PID 0xFF01
|
||||
#define WOOTING_TWO_LEGACY_PID 0xFF02
|
||||
#define WOOTING_ONE_PID 0x1100
|
||||
#define WOOTING_TWO_PID 0x1200
|
||||
#define WOOTING_TWO_LE_PID 0x1210
|
||||
#define WOOTING_TWO_HE_PID 0x1220
|
||||
#define WOOTING_TWO_HE_ARM_PID 0x1230
|
||||
#define WOOTING_60HE_PID 0x1300
|
||||
#define WOOTING_60HE_ARM_PID 0x1310
|
||||
#define WOOTING_60HE_PLUS_PID 0x1320
|
||||
#define WOOTING_60HE_V2_PID 0x1340
|
||||
#define WOOTING_80HE_PID 0x1400
|
||||
#define WOOTING_UWU_RGB_PID 0x1510
|
||||
|
||||
/*-----------------------------------------------------*\
|
||||
| Product ID helpers |
|
||||
| XINP: Xbox input emulation enabled |
|
||||
| DINP: Classic DirectInput emulation enabled |
|
||||
| NONE: Controller emulation disabled |
|
||||
\*-----------------------------------------------------*/
|
||||
#define XINP_PID(pid) (pid | 0x0000)
|
||||
#define DINP_PID(pid) (pid | 0x0001)
|
||||
#define NONE_PID(pid) (pid | 0x0002)
|
||||
|
||||
void DetectWootingControllers(hid_device_info *info, const std::string &name)
|
||||
{
|
||||
static const char *controller_name = "Wooting";
|
||||
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)
|
||||
return;
|
||||
|
||||
WOOTING_DEVICE_TYPE wooting_type;
|
||||
uint16_t pid = info->product_id;
|
||||
|
||||
if(pid == WOOTING_ONE_LEGACY_PID)
|
||||
{
|
||||
wooting_type = WOOTING_KB_TKL;
|
||||
}
|
||||
else if(pid == WOOTING_TWO_LEGACY_PID)
|
||||
{
|
||||
wooting_type = WOOTING_KB_FULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
//on modern devices, mask out the last nibble to get base PID
|
||||
switch(pid & 0xFFF0)
|
||||
{
|
||||
case WOOTING_ONE_LEGACY_PID:
|
||||
case WOOTING_ONE_PID:
|
||||
wooting_type = WOOTING_KB_TKL;
|
||||
break;
|
||||
case WOOTING_TWO_LEGACY_PID:
|
||||
case WOOTING_TWO_PID:
|
||||
case WOOTING_TWO_LE_PID:
|
||||
case WOOTING_TWO_HE_PID:
|
||||
case WOOTING_TWO_HE_ARM_PID:
|
||||
wooting_type = WOOTING_KB_FULL;
|
||||
break;
|
||||
case WOOTING_60HE_PID:
|
||||
case WOOTING_60HE_ARM_PID:
|
||||
case WOOTING_60HE_PLUS_PID:
|
||||
case WOOTING_60HE_V2_PID:
|
||||
wooting_type = WOOTING_KB_60PER;
|
||||
break;
|
||||
case WOOTING_80HE_PID:
|
||||
wooting_type = WOOTING_KB_80PER;
|
||||
break;
|
||||
case WOOTING_UWU_RGB_PID:
|
||||
wooting_type = WOOTING_KB_3PAD;
|
||||
break;
|
||||
default:
|
||||
//default to largest keyboard if unknown
|
||||
wooting_type = WOOTING_KB_FULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_INFO("[%s] Detected Wooting device type %i for device at path %s", controller_name, wooting_type, info->path);
|
||||
|
||||
//V1 firmware used the ATMEL VID, and uses the V1 controller
|
||||
if(info->vendor_id == WOOTING_OLD_VID && info->usage_page == WOOTING_CONFIG_USAGE_PAGE_V2)
|
||||
{
|
||||
LOG_DEBUG("[%s] Old VID detected - creating V1 Controller", controller_name);
|
||||
WootingV1KeyboardController *controller = new WootingV1KeyboardController(dev, info->path, wooting_type, name);
|
||||
|
||||
LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name);
|
||||
RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller);
|
||||
|
||||
LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str());
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
return;
|
||||
}
|
||||
|
||||
//V2-V2.11 firmware uses the V2 protocol indicated by the V2 usage page
|
||||
if(info->usage_page == WOOTING_CONFIG_USAGE_PAGE_V2)
|
||||
{
|
||||
LOG_DEBUG("[%s] V2 usage page detected - creating V2 Controller", controller_name);
|
||||
WootingV2KeyboardController *controller = new WootingV2KeyboardController(dev, info->path, wooting_type, name);
|
||||
|
||||
LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name);
|
||||
RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller);
|
||||
|
||||
LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str());
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
return;
|
||||
}
|
||||
|
||||
//V2.12+ firmware uses the new report structure indicated by the V3 usage page
|
||||
if(info->usage_page == WOOTING_CONFIG_USAGE_PAGE_V3)
|
||||
{
|
||||
LOG_DEBUG("[%s] V3 usage page detected - creating V3 Controller", controller_name);
|
||||
WootingV3KeyboardController *controller = new WootingV3KeyboardController(dev, info->path, wooting_type, name);
|
||||
|
||||
LOG_DEBUG("[%s] Controller created - creating RGBController", controller_name);
|
||||
RGBController_WootingKeyboard *rgb_controller = new RGBController_WootingKeyboard(controller);
|
||||
|
||||
LOG_DEBUG("[%s] Initialization complete - Registering controller\t%s", controller_name, name.c_str());
|
||||
ResourceManager::get()->RegisterRGBController(rgb_controller);
|
||||
return;
|
||||
}
|
||||
|
||||
hid_close(dev);
|
||||
|
||||
LOG_TRACE("[%s] No compatible Wooting controller found for device at path %s", controller_name, info->path);
|
||||
}
|
||||
/*-----------------------------------------------------*\
|
||||
| Wooting keyboards use different PIDs based on which |
|
||||
| gamepad emulation mode is selected. We can use their |
|
||||
| base PID, and set the last nibble to get the modes. |
|
||||
\*-----------------------------------------------------*/
|
||||
#define REGISTER_WOOTING_DETECTOR(name, vid, pid) \
|
||||
static HIDDeviceDetector detector_wooting_##vid##_##pid##_base(name, DetectWootingControllers, vid, NONE_PID(pid), HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY); \
|
||||
static HIDDeviceDetector detector_wooting_##vid##_##pid##_xinp(name, DetectWootingControllers, vid, XINP_PID(pid), HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY); \
|
||||
static HIDDeviceDetector detector_wooting_##vid##_##pid##_dinp(name, DetectWootingControllers, vid, DINP_PID(pid), HID_INTERFACE_ANY, HID_USAGE_PAGE_ANY, HID_USAGE_ANY)
|
||||
|
||||
|
||||
// Legacy devices with V1 firmware
|
||||
REGISTER_HID_DETECTOR_P("Wooting One (Legacy)", DetectWootingControllers, WOOTING_OLD_VID, WOOTING_ONE_LEGACY_PID, WOOTING_CONFIG_USAGE_PAGE_V2);
|
||||
REGISTER_HID_DETECTOR_P("Wooting Two (Legacy)", DetectWootingControllers, WOOTING_OLD_VID, WOOTING_TWO_LEGACY_PID, WOOTING_CONFIG_USAGE_PAGE_V2);
|
||||
|
||||
// All other devices
|
||||
REGISTER_WOOTING_DETECTOR("Wooting One", WOOTING_NEW_VID, WOOTING_ONE_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting Two", WOOTING_NEW_VID, WOOTING_TWO_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting Two Lekker Edition", WOOTING_NEW_VID, WOOTING_TWO_LE_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting Two HE", WOOTING_NEW_VID, WOOTING_TWO_HE_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting Two HE (ARM)", WOOTING_NEW_VID, WOOTING_TWO_HE_ARM_PID);
|
||||
REGISTER_WOOTING_DETECTOR("Wooting 60HE", WOOTING_NEW_VID, WOOTING_60HE_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting 60HE (ARM)", WOOTING_NEW_VID, WOOTING_60HE_ARM_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting 60HE+", WOOTING_NEW_VID, WOOTING_60HE_PLUS_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting 60HEv2", WOOTING_NEW_VID, WOOTING_60HE_V2_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting 80HE", WOOTING_NEW_VID, WOOTING_80HE_PID );
|
||||
REGISTER_WOOTING_DETECTOR("Wooting UwU RGB", WOOTING_NEW_VID, WOOTING_UWU_RGB_PID );
|
||||
+213
-213
@@ -1,213 +1,213 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV1KeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v1 firmware |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "StringUtils.h"
|
||||
#include "WootingV1KeyboardController.h"
|
||||
|
||||
#undef WOOTING_CONTROLLER_NAME
|
||||
#define WOOTING_CONTROLLER_NAME "[WootingONE] "
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
#define RGB_RAW_BUFFER_SIZE 96
|
||||
|
||||
static const unsigned int rgb_led_index[WOOTING_RGB_ROWS][WOOTING_RGB_COLUMNS] =
|
||||
{
|
||||
{ 0, NA, 11, 12, 23, 24, 36, 47, 85, 84, 49, 48, 59, 61, 73, 81, 80, 113, 114, 115, 116 },
|
||||
{ 2, 1, 14, 13, 26, 25, 35, 38, 37, 87, 86, 95, 51, 63, 75, 72, 74, 96, 97, 98, 99 },
|
||||
{ 3, 4, 15, 16, 27, 28, 39, 42, 40, 88, 89, 52, 53, 71, 76, 83, 77, 102, 103, 104, 100 },
|
||||
{ 5, 6, 17, 18, 29, 30, 41, 46, 44, 90, 93, 54, 57, 65, NA, NA, NA, 105, 106, 107, NA },
|
||||
{ 9, 8, 19, 20, 31, 34, 32, 45, 43, 91, 92, 55, NA, 66, NA, 78, NA, 108, 109, 110, 101 },
|
||||
{ 10, 22, 21, NA, NA, NA, 33, NA, NA, NA, 94, 58, 67, 68, 70, 79, 82, NA, 111, 112, NA }
|
||||
};
|
||||
|
||||
static uint16_t getCrc16ccitt(const uint8_t* buffer, uint16_t size)
|
||||
{
|
||||
uint16_t crc = 0;
|
||||
|
||||
while(size--)
|
||||
{
|
||||
crc ^= (*buffer++ << 8);
|
||||
|
||||
for(uint8_t i = 0; i < 8; ++i)
|
||||
{
|
||||
if(crc & 0x8000)
|
||||
{
|
||||
crc = (crc << 1) ^ 0x1021;
|
||||
}
|
||||
else
|
||||
{
|
||||
crc = crc << 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
WootingV1KeyboardController::WootingV1KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
this->wooting_type = wooting_type;
|
||||
key_code_limit = WOOTING_TWO_KEY_CODE_LIMIT;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device HID manufacturer and product strings |
|
||||
\*---------------------------------------------------------*/
|
||||
const int szTemp = 256;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
vendor = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
hid_get_product_string(dev, tmpName, szTemp);
|
||||
description = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
SendInitialize();
|
||||
}
|
||||
|
||||
WootingV1KeyboardController::~WootingV1KeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WootingV1KeyboardController::SendDirect(RGBColor* colors, uint8_t colour_count)
|
||||
{
|
||||
const uint8_t pwm_mem_map[48] =
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D
|
||||
};
|
||||
|
||||
unsigned char buffer0[RGB_RAW_BUFFER_SIZE] = {0};
|
||||
unsigned char buffer1[RGB_RAW_BUFFER_SIZE] = {0};
|
||||
unsigned char buffer2[RGB_RAW_BUFFER_SIZE] = {0};
|
||||
unsigned char buffer3[RGB_RAW_BUFFER_SIZE] = {0};
|
||||
unsigned char buffer4[RGB_RAW_BUFFER_SIZE] = {0};
|
||||
|
||||
for(uint8_t index = 0; index < colour_count; index++)
|
||||
{
|
||||
unsigned char row = index / WOOTING_RGB_COLUMNS;
|
||||
unsigned char col = index % WOOTING_RGB_COLUMNS;
|
||||
unsigned char led_index = rgb_led_index[row][col];
|
||||
|
||||
if(led_index > key_code_limit)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned char *buffer_pointer = buffer0;
|
||||
|
||||
if(led_index >= 96)
|
||||
{
|
||||
buffer_pointer = buffer4;
|
||||
}
|
||||
else if(led_index >= 72)
|
||||
{
|
||||
buffer_pointer = buffer3;
|
||||
}
|
||||
else if(led_index >= 48)
|
||||
{
|
||||
buffer_pointer = buffer2;
|
||||
}
|
||||
else if(led_index >= 24)
|
||||
{
|
||||
buffer_pointer = buffer1;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer_pointer = buffer0;
|
||||
}
|
||||
|
||||
unsigned char buffer_index = pwm_mem_map[led_index % 24];
|
||||
buffer_pointer[buffer_index + 0x00] = RGBGetRValue(colors[index]);
|
||||
buffer_pointer[buffer_index + 0x10] = RGBGetGValue(colors[index]);
|
||||
buffer_pointer[buffer_index + 0x20] = RGBGetBValue(colors[index]);
|
||||
}
|
||||
|
||||
wooting_usb_send_buffer(RGB_PARTS::PART0, buffer0);
|
||||
wooting_usb_send_buffer(RGB_PARTS::PART1, buffer1);
|
||||
wooting_usb_send_buffer(RGB_PARTS::PART2, buffer2);
|
||||
wooting_usb_send_buffer(RGB_PARTS::PART3, buffer3);
|
||||
if(key_code_limit > WOOTING_ONE_KEY_CODE_LIMIT)
|
||||
{
|
||||
wooting_usb_send_buffer(RGB_PARTS::PART4, buffer4);
|
||||
}
|
||||
}
|
||||
|
||||
bool WootingV1KeyboardController::wooting_usb_send_buffer(RGB_PARTS part_number, uint8_t* rgb_buffer)
|
||||
{
|
||||
unsigned char report_buffer[WOOTING_REPORT_SIZE] = {0};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up the Send Buffer packet |
|
||||
\*---------------------------------------------------------*/
|
||||
report_buffer[0] = 0; // HID report index (unused)
|
||||
report_buffer[1] = 0xD0; // Magic word
|
||||
report_buffer[2] = 0xDA; // Magic word
|
||||
report_buffer[3] = WOOTING_RAW_COLORS_REPORT; // Report ID
|
||||
|
||||
switch(part_number)
|
||||
{
|
||||
case PART0:
|
||||
report_buffer[4] = 0; // Slave nr
|
||||
report_buffer[5] = 0; // Reg start address
|
||||
break;
|
||||
|
||||
case PART1:
|
||||
report_buffer[4] = 0; // Slave nr
|
||||
report_buffer[5] = RGB_RAW_BUFFER_SIZE; // Reg start address
|
||||
break;
|
||||
|
||||
case PART2:
|
||||
report_buffer[4] = 1; // Slave nr
|
||||
report_buffer[5] = 0; // Reg start address
|
||||
break;
|
||||
|
||||
case PART3:
|
||||
report_buffer[4] = 1; // Slave nr
|
||||
report_buffer[5] = RGB_RAW_BUFFER_SIZE; // Reg start address
|
||||
break;
|
||||
|
||||
case PART4:
|
||||
report_buffer[4] = 2; // Slave nr
|
||||
report_buffer[5] = 0; // Reg start address
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in the buffer data |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&report_buffer[6], rgb_buffer, RGB_RAW_BUFFER_SIZE);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Calculate the CRC and append it to the packet |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned short crc = getCrc16ccitt((unsigned char*)&report_buffer, WOOTING_REPORT_SIZE - 2);
|
||||
report_buffer[127] = (unsigned char)crc;
|
||||
report_buffer[128] = crc >> 8;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*---------------------------------------------------------*/
|
||||
hid_write(dev, report_buffer, WOOTING_REPORT_SIZE);
|
||||
|
||||
return true;
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV1KeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v1 firmware |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "StringUtils.h"
|
||||
#include "WootingV1KeyboardController.h"
|
||||
|
||||
#undef WOOTING_CONTROLLER_NAME
|
||||
#define WOOTING_CONTROLLER_NAME "[WootingONE] "
|
||||
|
||||
//0xFFFFFFFF indicates an unused entry in matrix
|
||||
#define NA 0xFFFFFFFF
|
||||
#define RGB_RAW_BUFFER_SIZE 96
|
||||
|
||||
static const unsigned int rgb_led_index[WOOTING_RGB_ROWS][WOOTING_RGB_COLUMNS] =
|
||||
{
|
||||
{ 0, NA, 11, 12, 23, 24, 36, 47, 85, 84, 49, 48, 59, 61, 73, 81, 80, 113, 114, 115, 116 },
|
||||
{ 2, 1, 14, 13, 26, 25, 35, 38, 37, 87, 86, 95, 51, 63, 75, 72, 74, 96, 97, 98, 99 },
|
||||
{ 3, 4, 15, 16, 27, 28, 39, 42, 40, 88, 89, 52, 53, 71, 76, 83, 77, 102, 103, 104, 100 },
|
||||
{ 5, 6, 17, 18, 29, 30, 41, 46, 44, 90, 93, 54, 57, 65, NA, NA, NA, 105, 106, 107, NA },
|
||||
{ 9, 8, 19, 20, 31, 34, 32, 45, 43, 91, 92, 55, NA, 66, NA, 78, NA, 108, 109, 110, 101 },
|
||||
{ 10, 22, 21, NA, NA, NA, 33, NA, NA, NA, 94, 58, 67, 68, 70, 79, 82, NA, 111, 112, NA }
|
||||
};
|
||||
|
||||
static uint16_t getCrc16ccitt(const uint8_t* buffer, uint16_t size)
|
||||
{
|
||||
uint16_t crc = 0;
|
||||
|
||||
while(size--)
|
||||
{
|
||||
crc ^= (*buffer++ << 8);
|
||||
|
||||
for(uint8_t i = 0; i < 8; ++i)
|
||||
{
|
||||
if(crc & 0x8000)
|
||||
{
|
||||
crc = (crc << 1) ^ 0x1021;
|
||||
}
|
||||
else
|
||||
{
|
||||
crc = crc << 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
WootingV1KeyboardController::WootingV1KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
this->wooting_type = wooting_type;
|
||||
key_code_limit = WOOTING_TWO_KEY_CODE_LIMIT;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device HID manufacturer and product strings |
|
||||
\*---------------------------------------------------------*/
|
||||
const int szTemp = 256;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
vendor = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
hid_get_product_string(dev, tmpName, szTemp);
|
||||
description = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
SendInitialize();
|
||||
}
|
||||
|
||||
WootingV1KeyboardController::~WootingV1KeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WootingV1KeyboardController::SendDirect(RGBColor* colors, uint8_t colour_count)
|
||||
{
|
||||
const uint8_t pwm_mem_map[48] =
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D,
|
||||
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D,
|
||||
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D
|
||||
};
|
||||
|
||||
unsigned char buffer0[RGB_RAW_BUFFER_SIZE] = {0};
|
||||
unsigned char buffer1[RGB_RAW_BUFFER_SIZE] = {0};
|
||||
unsigned char buffer2[RGB_RAW_BUFFER_SIZE] = {0};
|
||||
unsigned char buffer3[RGB_RAW_BUFFER_SIZE] = {0};
|
||||
unsigned char buffer4[RGB_RAW_BUFFER_SIZE] = {0};
|
||||
|
||||
for(uint8_t index = 0; index < colour_count; index++)
|
||||
{
|
||||
unsigned char row = index / WOOTING_RGB_COLUMNS;
|
||||
unsigned char col = index % WOOTING_RGB_COLUMNS;
|
||||
unsigned char led_index = rgb_led_index[row][col];
|
||||
|
||||
if(led_index > key_code_limit)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned char *buffer_pointer = buffer0;
|
||||
|
||||
if(led_index >= 96)
|
||||
{
|
||||
buffer_pointer = buffer4;
|
||||
}
|
||||
else if(led_index >= 72)
|
||||
{
|
||||
buffer_pointer = buffer3;
|
||||
}
|
||||
else if(led_index >= 48)
|
||||
{
|
||||
buffer_pointer = buffer2;
|
||||
}
|
||||
else if(led_index >= 24)
|
||||
{
|
||||
buffer_pointer = buffer1;
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer_pointer = buffer0;
|
||||
}
|
||||
|
||||
unsigned char buffer_index = pwm_mem_map[led_index % 24];
|
||||
buffer_pointer[buffer_index + 0x00] = RGBGetRValue(colors[index]);
|
||||
buffer_pointer[buffer_index + 0x10] = RGBGetGValue(colors[index]);
|
||||
buffer_pointer[buffer_index + 0x20] = RGBGetBValue(colors[index]);
|
||||
}
|
||||
|
||||
wooting_usb_send_buffer(RGB_PARTS::PART0, buffer0);
|
||||
wooting_usb_send_buffer(RGB_PARTS::PART1, buffer1);
|
||||
wooting_usb_send_buffer(RGB_PARTS::PART2, buffer2);
|
||||
wooting_usb_send_buffer(RGB_PARTS::PART3, buffer3);
|
||||
if(key_code_limit > WOOTING_ONE_KEY_CODE_LIMIT)
|
||||
{
|
||||
wooting_usb_send_buffer(RGB_PARTS::PART4, buffer4);
|
||||
}
|
||||
}
|
||||
|
||||
bool WootingV1KeyboardController::wooting_usb_send_buffer(RGB_PARTS part_number, uint8_t* rgb_buffer)
|
||||
{
|
||||
unsigned char report_buffer[WOOTING_REPORT_SIZE] = {0};
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Set up the Send Buffer packet |
|
||||
\*---------------------------------------------------------*/
|
||||
report_buffer[0] = 0; // HID report index (unused)
|
||||
report_buffer[1] = 0xD0; // Magic word
|
||||
report_buffer[2] = 0xDA; // Magic word
|
||||
report_buffer[3] = WOOTING_RAW_COLORS_REPORT; // Report ID
|
||||
|
||||
switch(part_number)
|
||||
{
|
||||
case PART0:
|
||||
report_buffer[4] = 0; // Slave nr
|
||||
report_buffer[5] = 0; // Reg start address
|
||||
break;
|
||||
|
||||
case PART1:
|
||||
report_buffer[4] = 0; // Slave nr
|
||||
report_buffer[5] = RGB_RAW_BUFFER_SIZE; // Reg start address
|
||||
break;
|
||||
|
||||
case PART2:
|
||||
report_buffer[4] = 1; // Slave nr
|
||||
report_buffer[5] = 0; // Reg start address
|
||||
break;
|
||||
|
||||
case PART3:
|
||||
report_buffer[4] = 1; // Slave nr
|
||||
report_buffer[5] = RGB_RAW_BUFFER_SIZE; // Reg start address
|
||||
break;
|
||||
|
||||
case PART4:
|
||||
report_buffer[4] = 2; // Slave nr
|
||||
report_buffer[5] = 0; // Reg start address
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Copy in the buffer data |
|
||||
\*---------------------------------------------------------*/
|
||||
memcpy(&report_buffer[6], rgb_buffer, RGB_RAW_BUFFER_SIZE);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Calculate the CRC and append it to the packet |
|
||||
\*---------------------------------------------------------*/
|
||||
unsigned short crc = getCrc16ccitt((unsigned char*)&report_buffer, WOOTING_REPORT_SIZE - 2);
|
||||
report_buffer[127] = (unsigned char)crc;
|
||||
report_buffer[128] = crc >> 8;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Send packet |
|
||||
\*---------------------------------------------------------*/
|
||||
hid_write(dev, report_buffer, WOOTING_REPORT_SIZE);
|
||||
|
||||
return true;
|
||||
}
|
||||
+32
-32
@@ -1,32 +1,32 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV1KeyboardController.h |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v1 firmware |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "WootingKeyboardController.h"
|
||||
|
||||
#define WOOTING_REPORT_SIZE 129
|
||||
#define WOOTING_ONE_KEY_CODE_LIMIT 95
|
||||
#define WOOTING_TWO_KEY_CODE_LIMIT 116
|
||||
|
||||
class WootingV1KeyboardController : public WootingKeyboardController
|
||||
{
|
||||
public:
|
||||
WootingV1KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name);
|
||||
~WootingV1KeyboardController();
|
||||
|
||||
uint8_t key_code_limit;
|
||||
|
||||
void SendDirect(RGBColor* colors, uint8_t colour_count);
|
||||
|
||||
private:
|
||||
bool wooting_usb_send_buffer(RGB_PARTS part_number, uint8_t* report_buffer);
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV1KeyboardController.h |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v1 firmware |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "WootingKeyboardController.h"
|
||||
|
||||
#define WOOTING_REPORT_SIZE 129
|
||||
#define WOOTING_ONE_KEY_CODE_LIMIT 95
|
||||
#define WOOTING_TWO_KEY_CODE_LIMIT 116
|
||||
|
||||
class WootingV1KeyboardController : public WootingKeyboardController
|
||||
{
|
||||
public:
|
||||
WootingV1KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name);
|
||||
~WootingV1KeyboardController();
|
||||
|
||||
uint8_t key_code_limit;
|
||||
|
||||
void SendDirect(RGBColor* colors, uint8_t colour_count);
|
||||
|
||||
private:
|
||||
bool wooting_usb_send_buffer(RGB_PARTS part_number, uint8_t* report_buffer);
|
||||
};
|
||||
+72
-72
@@ -1,72 +1,72 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV2KeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v2 firmware |
|
||||
| |
|
||||
| Chris M (Dr_No) 09 Jul 2021 |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "StringUtils.h"
|
||||
#include "WootingV2KeyboardController.h"
|
||||
|
||||
#define WOOTING_TWO_REPORT_SIZE 257
|
||||
|
||||
#undef WOOTING_CONTROLLER_NAME
|
||||
#define WOOTING_CONTROLLER_NAME "[WootingTWO] "
|
||||
|
||||
//Indicates an unused entry in matrix
|
||||
#define NA 0x7D
|
||||
|
||||
//WootingTwo uses a 16bit color space
|
||||
typedef uint16_t R5G6B5_color;
|
||||
#define RGB888ToRGBcolor16(r, g, b) ((R5G6B5_color)((red & 0xF8) << 8 | (green & 0xFC) << 3 | (b & 0xF8) >> 3))
|
||||
#define RGB32ToRGBcolor16(color32) ((R5G6B5_color)((color32 & 0xF8) << 8 | (color32 & 0xFC00) >> 5 | (color32 & 0xF80000) >> 19))
|
||||
|
||||
WootingV2KeyboardController::WootingV2KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
this->wooting_type = wooting_type;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device HID manufacturer and product strings |
|
||||
\*---------------------------------------------------------*/
|
||||
const int szTemp = 256;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
vendor = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
hid_get_product_string(dev, tmpName, szTemp);
|
||||
description = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
SendInitialize();
|
||||
}
|
||||
|
||||
WootingV2KeyboardController::~WootingV2KeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WootingV2KeyboardController::SendDirect(RGBColor* colors, uint8_t color_count)
|
||||
{
|
||||
uint8_t rgb_buffer[WOOTING_TWO_REPORT_SIZE] = { 0, 0xD0, 0xDA, WOOTING_RAW_COLORS_REPORT};
|
||||
|
||||
for(std::size_t index = 0; index < color_count; index++)
|
||||
{
|
||||
size_t buffer_index = 4 + (index * 2);
|
||||
R5G6B5_color color16 = RGB32ToRGBcolor16(colors[index]);
|
||||
|
||||
rgb_buffer[buffer_index] = color16 & 0xFF;
|
||||
rgb_buffer[buffer_index+1] = color16 >> 8;
|
||||
}
|
||||
|
||||
uint16_t report_size = hid_write(dev, rgb_buffer, WOOTING_TWO_REPORT_SIZE);
|
||||
LOG_DEBUG("%sSend buffer returned - %04i expected %04i", WOOTING_CONTROLLER_NAME, report_size, WOOTING_TWO_REPORT_SIZE);
|
||||
}
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV2KeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v2 firmware |
|
||||
| |
|
||||
| Chris M (Dr_No) 09 Jul 2021 |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "StringUtils.h"
|
||||
#include "WootingV2KeyboardController.h"
|
||||
|
||||
#define WOOTING_TWO_REPORT_SIZE 257
|
||||
|
||||
#undef WOOTING_CONTROLLER_NAME
|
||||
#define WOOTING_CONTROLLER_NAME "[WootingTWO] "
|
||||
|
||||
//Indicates an unused entry in matrix
|
||||
#define NA 0x7D
|
||||
|
||||
//WootingTwo uses a 16bit color space
|
||||
typedef uint16_t R5G6B5_color;
|
||||
#define RGB888ToRGBcolor16(r, g, b) ((R5G6B5_color)((red & 0xF8) << 8 | (green & 0xFC) << 3 | (b & 0xF8) >> 3))
|
||||
#define RGB32ToRGBcolor16(color32) ((R5G6B5_color)((color32 & 0xF8) << 8 | (color32 & 0xFC00) >> 5 | (color32 & 0xF80000) >> 19))
|
||||
|
||||
WootingV2KeyboardController::WootingV2KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
this->wooting_type = wooting_type;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device HID manufacturer and product strings |
|
||||
\*---------------------------------------------------------*/
|
||||
const int szTemp = 256;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
vendor = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
hid_get_product_string(dev, tmpName, szTemp);
|
||||
description = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
SendInitialize();
|
||||
}
|
||||
|
||||
WootingV2KeyboardController::~WootingV2KeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WootingV2KeyboardController::SendDirect(RGBColor* colors, uint8_t color_count)
|
||||
{
|
||||
uint8_t rgb_buffer[WOOTING_TWO_REPORT_SIZE] = { 0, 0xD0, 0xDA, WOOTING_RAW_COLORS_REPORT};
|
||||
|
||||
for(std::size_t index = 0; index < color_count; index++)
|
||||
{
|
||||
size_t buffer_index = 4 + (index * 2);
|
||||
R5G6B5_color color16 = RGB32ToRGBcolor16(colors[index]);
|
||||
|
||||
rgb_buffer[buffer_index] = color16 & 0xFF;
|
||||
rgb_buffer[buffer_index+1] = color16 >> 8;
|
||||
}
|
||||
|
||||
uint16_t report_size = hid_write(dev, rgb_buffer, WOOTING_TWO_REPORT_SIZE);
|
||||
LOG_DEBUG("%sSend buffer returned - %04i expected %04i", WOOTING_CONTROLLER_NAME, report_size, WOOTING_TWO_REPORT_SIZE);
|
||||
}
|
||||
+24
-24
@@ -1,24 +1,24 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV2KeyboardController.h |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v2 firmware |
|
||||
| |
|
||||
| Chris M (Dr_No) 09 Jul 2021 |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "WootingKeyboardController.h"
|
||||
|
||||
class WootingV2KeyboardController : public WootingKeyboardController
|
||||
{
|
||||
public:
|
||||
WootingV2KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name);
|
||||
~WootingV2KeyboardController();
|
||||
|
||||
void SendDirect(RGBColor* colors, uint8_t colour_count);
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV2KeyboardController.h |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v2 firmware |
|
||||
| |
|
||||
| Chris M (Dr_No) 09 Jul 2021 |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "WootingKeyboardController.h"
|
||||
|
||||
class WootingV2KeyboardController : public WootingKeyboardController
|
||||
{
|
||||
public:
|
||||
WootingV2KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name);
|
||||
~WootingV2KeyboardController();
|
||||
|
||||
void SendDirect(RGBColor* colors, uint8_t colour_count);
|
||||
};
|
||||
+76
-76
@@ -1,76 +1,76 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV3KeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v3 firmware |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "StringUtils.h"
|
||||
#include "WootingV3KeyboardController.h"
|
||||
|
||||
#define WOOTING_V3_REPORT_SIZE 2046
|
||||
|
||||
#undef WOOTING_CONTROLLER_NAME
|
||||
#define WOOTING_CONTROLLER_NAME "[WootingTWO] "
|
||||
|
||||
//Indicates an unused entry in matrix
|
||||
#define NA 0x7D
|
||||
|
||||
//WootingTwo uses a 16bit color space
|
||||
typedef uint16_t R5G6B5_color;
|
||||
#define RGB888ToRGBcolor16(r, g, b) ((R5G6B5_color)((red & 0xF8) << 8 | (green & 0xFC) << 3 | (b & 0xF8) >> 3))
|
||||
#define RGB32ToRGBcolor16(color32) ((R5G6B5_color)((color32 & 0xF8) << 8 | (color32 & 0xFC00) >> 5 | (color32 & 0xF80000) >> 19))
|
||||
|
||||
WootingV3KeyboardController::WootingV3KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
this->wooting_type = wooting_type;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device HID manufacturer and product strings |
|
||||
\*---------------------------------------------------------*/
|
||||
const int szTemp = 256;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
vendor = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
hid_get_product_string(dev, tmpName, szTemp);
|
||||
description = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
SendInitialize();
|
||||
}
|
||||
|
||||
WootingV3KeyboardController::~WootingV3KeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WootingV3KeyboardController::SendDirect(RGBColor* colors, uint8_t color_count)
|
||||
{
|
||||
uint8_t rgb_buffer[WOOTING_V3_REPORT_SIZE] = {0};
|
||||
rgb_buffer[0] = 4;
|
||||
rgb_buffer[1] = 0xD1;
|
||||
rgb_buffer[2] = 0xDA;
|
||||
rgb_buffer[3] = WOOTING_RAW_COLORS_REPORT;
|
||||
|
||||
for(std::size_t index = 0; index < color_count; index++)
|
||||
{
|
||||
size_t buffer_index = 4 + (index * 2);
|
||||
R5G6B5_color color16 = RGB32ToRGBcolor16(colors[index]);
|
||||
|
||||
rgb_buffer[buffer_index] = color16 & 0xFF;
|
||||
rgb_buffer[buffer_index+1] = color16 >> 8;
|
||||
}
|
||||
|
||||
uint16_t report_size = hid_write(dev, rgb_buffer, WOOTING_V3_REPORT_SIZE);
|
||||
LOG_DEBUG("%sSend buffer returned - %04i expected %04i", WOOTING_CONTROLLER_NAME, report_size, WOOTING_V3_REPORT_SIZE);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV3KeyboardController.cpp |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v3 firmware |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#include <cstring>
|
||||
#include "StringUtils.h"
|
||||
#include "WootingV3KeyboardController.h"
|
||||
|
||||
#define WOOTING_V3_REPORT_SIZE 2046
|
||||
|
||||
#undef WOOTING_CONTROLLER_NAME
|
||||
#define WOOTING_CONTROLLER_NAME "[WootingTWO] "
|
||||
|
||||
//Indicates an unused entry in matrix
|
||||
#define NA 0x7D
|
||||
|
||||
//WootingTwo uses a 16bit color space
|
||||
typedef uint16_t R5G6B5_color;
|
||||
#define RGB888ToRGBcolor16(r, g, b) ((R5G6B5_color)((red & 0xF8) << 8 | (green & 0xFC) << 3 | (b & 0xF8) >> 3))
|
||||
#define RGB32ToRGBcolor16(color32) ((R5G6B5_color)((color32 & 0xF8) << 8 | (color32 & 0xFC00) >> 5 | (color32 & 0xF80000) >> 19))
|
||||
|
||||
WootingV3KeyboardController::WootingV3KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name)
|
||||
{
|
||||
dev = dev_handle;
|
||||
location = path;
|
||||
name = dev_name;
|
||||
this->wooting_type = wooting_type;
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Get device HID manufacturer and product strings |
|
||||
\*---------------------------------------------------------*/
|
||||
const int szTemp = 256;
|
||||
wchar_t tmpName[szTemp];
|
||||
|
||||
hid_get_manufacturer_string(dev, tmpName, szTemp);
|
||||
vendor = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
hid_get_product_string(dev, tmpName, szTemp);
|
||||
description = std::string(StringUtils::wstring_to_string(tmpName));
|
||||
|
||||
SendInitialize();
|
||||
}
|
||||
|
||||
WootingV3KeyboardController::~WootingV3KeyboardController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void WootingV3KeyboardController::SendDirect(RGBColor* colors, uint8_t color_count)
|
||||
{
|
||||
uint8_t rgb_buffer[WOOTING_V3_REPORT_SIZE] = {0};
|
||||
rgb_buffer[0] = 4;
|
||||
rgb_buffer[1] = 0xD1;
|
||||
rgb_buffer[2] = 0xDA;
|
||||
rgb_buffer[3] = WOOTING_RAW_COLORS_REPORT;
|
||||
|
||||
for(std::size_t index = 0; index < color_count; index++)
|
||||
{
|
||||
size_t buffer_index = 4 + (index * 2);
|
||||
R5G6B5_color color16 = RGB32ToRGBcolor16(colors[index]);
|
||||
|
||||
rgb_buffer[buffer_index] = color16 & 0xFF;
|
||||
rgb_buffer[buffer_index+1] = color16 >> 8;
|
||||
}
|
||||
|
||||
uint16_t report_size = hid_write(dev, rgb_buffer, WOOTING_V3_REPORT_SIZE);
|
||||
LOG_DEBUG("%sSend buffer returned - %04i expected %04i", WOOTING_CONTROLLER_NAME, report_size, WOOTING_V3_REPORT_SIZE);
|
||||
}
|
||||
|
||||
+23
-23
@@ -1,23 +1,23 @@
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV3KeyboardController.h |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v3 firmware |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "WootingKeyboardController.h"
|
||||
|
||||
class WootingV3KeyboardController : public WootingKeyboardController
|
||||
{
|
||||
public:
|
||||
WootingV3KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name);
|
||||
~WootingV3KeyboardController();
|
||||
|
||||
void SendDirect(RGBColor* colors, uint8_t colour_count);
|
||||
};
|
||||
/*---------------------------------------------------------*\
|
||||
| WootingV3KeyboardController.h |
|
||||
| |
|
||||
| Driver for Wooting keyboards with v3 firmware |
|
||||
| |
|
||||
| Diogo Trindade (diogotr7) 25 Dec 2025 |
|
||||
| |
|
||||
| This file is part of the OpenRGB project |
|
||||
| SPDX-License-Identifier: GPL-2.0-or-later |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "WootingKeyboardController.h"
|
||||
|
||||
class WootingV3KeyboardController : public WootingKeyboardController
|
||||
{
|
||||
public:
|
||||
WootingV3KeyboardController(hid_device* dev_handle, const char *path, WOOTING_DEVICE_TYPE wooting_type, std::string dev_name);
|
||||
~WootingV3KeyboardController();
|
||||
|
||||
void SendDirect(RGBColor* colors, uint8_t colour_count);
|
||||
};
|
||||
Reference in new issue
Block a user