From 68a3cc43d9fabb9f2c5c5455c38ea2c2d4645dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AF=BA=E8=AF=BA?= <2777618756@qq.com> Date: Thu, 16 Nov 2023 17:25:41 +0000 Subject: [PATCH] Add new Controller Nollie16 --- .../NollieController/NollieController.cpp | 16 +++++++------- .../NollieController/NollieController.h | 2 ++ .../NollieControllerDetect.cpp | 3 ++- .../NollieController/RGBController_Nollie.cpp | 21 +++++++++++++++---- .../NollieController/RGBController_Nollie.h | 13 ++++++++---- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/Controllers/NollieController/NollieController.cpp b/Controllers/NollieController/NollieController.cpp index 1a615768..35be7606 100644 --- a/Controllers/NollieController/NollieController.cpp +++ b/Controllers/NollieController/NollieController.cpp @@ -11,14 +11,11 @@ using namespace std::chrono_literals; -NollieController::NollieController(hid_device* dev_handle, const char* path, unsigned short /*pid*/) +NollieController::NollieController(hid_device* dev_handle, const char* path, unsigned short pid) { - dev = dev_handle; - location = path; - /*-----------------------------------------------------*\ - | PID may be used in the future, here is to pass | - | arguments not to do storage | - \*-----------------------------------------------------*/ + dev = dev_handle; + location = path; + usb_pid = pid; } std::string NollieController::GetLocationString() @@ -42,6 +39,11 @@ std::string NollieController::GetSerialString() return(return_string); } +unsigned short NollieController::GetUSBPID() +{ + return(usb_pid); +} + void NollieController::SetMos(bool mos) { unsigned char usb_buf[65]; diff --git a/Controllers/NollieController/NollieController.h b/Controllers/NollieController/NollieController.h index e46c159b..3795ba41 100644 --- a/Controllers/NollieController/NollieController.h +++ b/Controllers/NollieController/NollieController.h @@ -19,10 +19,12 @@ public: NollieController(hid_device* dev_handle, const char* path, unsigned short pid); std::string GetLocationString(); std::string GetSerialString(); + unsigned short GetUSBPID(); void SetMos(bool mos); void SetChannelLEDs(unsigned char channel, RGBColor * colors, unsigned int num_colors); private: hid_device* dev; std::string location; + unsigned short usb_pid; void SendPacket(unsigned char channel,RGBColor * colors,unsigned int num_colors); }; diff --git a/Controllers/NollieController/NollieControllerDetect.cpp b/Controllers/NollieController/NollieControllerDetect.cpp index bc563759..3eaf2750 100644 --- a/Controllers/NollieController/NollieControllerDetect.cpp +++ b/Controllers/NollieController/NollieControllerDetect.cpp @@ -34,4 +34,5 @@ void DetectNollieControllers(hid_device_info* info, const std::string& name) } } -REGISTER_HID_DETECTOR("Nollie 32CH", DetectNollieControllers, NOLLIE_32_VID, NOLLIE_32_PID); +REGISTER_HID_DETECTOR("Nollie 32CH", DetectNollieControllers, NOLLIE32_VID, NOLLIE32_PID); +REGISTER_HID_DETECTOR("Nollie 16CH", DetectNollieControllers, NOLLIE16_VID, NOLLIE16_PID); diff --git a/Controllers/NollieController/RGBController_Nollie.cpp b/Controllers/NollieController/RGBController_Nollie.cpp index 03c43ce9..e7909429 100644 --- a/Controllers/NollieController/RGBController_Nollie.cpp +++ b/Controllers/NollieController/RGBController_Nollie.cpp @@ -13,8 +13,9 @@ #include #include -int channel_index[32] = {5, 4, 3, 2, 1, 0, 15, 14, 26, 27, 28, 29, 30, 31, 8, 9, 19, 18, 17, 16, 7, 6, 25, 24, 23, 22, 21, 20, 13, 12, 11, 10}; - +int channel_index[32] = {0}; +int ch32[32] = {5, 4, 3, 2, 1, 0, 15, 14, 26, 27, 28, 29, 30, 31, 8, 9, 19, 18, 17, 16, 7, 6, 25, 24, 23, 22, 21, 20, 13, 12, 11, 10}; +int ch16[32] = {19, 18, 17, 16, 24, 25, 26, 27, 20, 21, 22, 23, 31, 30, 29, 28, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; RGBController_Nollie::RGBController_Nollie(NollieController* controller_ptr) { controller = controller_ptr; @@ -44,14 +45,26 @@ RGBController_Nollie::~RGBController_Nollie() void RGBController_Nollie::SetupZones() { bool first_run = false; + unsigned int channels_num = 0; if(zones.size() == 0) { first_run = true; } leds.clear(); colors.clear(); - zones.resize(NOLLIE_CHANNELS_NUM); - for(unsigned int channel_idx = 0; channel_idx < NOLLIE_CHANNELS_NUM; channel_idx++) + switch(controller->GetUSBPID()) + { + case NOLLIE32_PID: + channels_num = 32; + memcpy(channel_index,ch32,sizeof(ch32)); + break; + default: + channels_num = 16; + memcpy(channel_index,ch16,sizeof(ch16)); + break; + } + zones.resize(channels_num); + for(unsigned int channel_idx = 0; channel_idx < channels_num; channel_idx++) { if(channel_idx > 27 ) { diff --git a/Controllers/NollieController/RGBController_Nollie.h b/Controllers/NollieController/RGBController_Nollie.h index d2f30387..76e3e15b 100644 --- a/Controllers/NollieController/RGBController_Nollie.h +++ b/Controllers/NollieController/RGBController_Nollie.h @@ -11,10 +11,15 @@ #include "RGBController.h" #include "NollieController.h" -#define NOLLIE_CHANNELS_LED_NUM 256 -#define NOLLIE_CHANNELS_NUM 32 -#define NOLLIE_32_PID 0x4714 -#define NOLLIE_32_VID 0x3061 +#define NOLLIE_CHANNELS_LED_NUM 256 + +#define NOLLIE32_CHANNELS_NUM 32 +#define NOLLIE32_PID 0x4714 +#define NOLLIE32_VID 0x3061 + +#define NOLLIE16_CHANNELS_NUM 16 +#define NOLLIE16_PID 0x4716 +#define NOLLIE16_VID 0x3061 class RGBController_Nollie : public RGBController {