Add new Controller Nollie16

This commit is contained in:
诺诺 2023-11-16 17:25:41 +00:00 committed by Adam Honse
parent 999bb03a45
commit 68a3cc43d9
5 changed files with 39 additions and 16 deletions

View file

@ -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 |
\*-----------------------------------------------------*/
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];

View file

@ -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);
};

View file

@ -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);

View file

@ -13,8 +13,9 @@
#include <algorithm>
#include <iostream>
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 )
{

View file

@ -12,9 +12,14 @@
#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 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
{