Publish curated LumaOps source from c85ee9ef8f1454f5c305398902afbb9e6738de40
Managed validation / full (push) Failing after 8s

This commit is contained in:
Public Source Publisher committed 2026-09-30 00:26:45 +00:00
1 parent 91f8b3e3c1
commit def7920856
2271 files changed
+501225 -501178

No files matched your search

@@ -1,260 +1,260 @@
/*---------------------------------------------------------*\
| JGINYUEInternalUSBV2Controller.cpp |
| |
| Driver for JGINYUE USB motherboard V2 |
| |
| Tong R (tcr020) 08 Aug 2024 |
| Liu ShiMeng(Moon dream stars) 09 Aug 2023 |
| Dongguan Yonghang Electronic Technology Co., Ltd |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include <string>
#include <stdio.h>
#include "RGBController.h"
#include "ResourceManager.h"
#include "SettingsManager.h"
#include "JGINYUEInternalUSBV2Controller.h"
#include "LogManager.h"
#include "dmiinfo.h"
#define JGINYUE_V2_HID_GENERAL_COMMAND_HEADER 0x01
#define JGINYUE_V2_CDC_COMMAND_HEADER 0x10
#define JGINYUE_V2_HID_REQUEST_MCU_STATUS 0x21
#define JGINYUE_V2_HID_REQUEST_MCUID 0x22
#define JGINYUE_V2_HID_REQUEST_UNLOCK 0x23
#define JGINYUE_V2_HID_DOWNLOAD_SKU 0x24
#define JGINYUE_V2_HID_REQUEST_MCU_STATUS_EX 0x0F
#define JGINYUE_V2_HID_DOWNLOAD_ARGB_SETTING 0x01
#define JGINYUE_V2_HID_DOWNLOAD_GLOBAL_SETTING 0x02
#define JGINYUE_V2_HID_REQUEST_ARGB_SETTING 0x11
#define JGINYUE_V2_HID_REQUEST_GLOBAL_SETTING 0x12
#define FUNCTION_ID_CDC_ARGB 0x01
using namespace std::chrono_literals;
JGINYUEInternalUSBV2Controller::JGINYUEInternalUSBV2Controller(hid_device* jy_hid_device, const char* path,serial_port* jy_cdc_device)
{
DMIInfo dmi;
jy_hid_interface = jy_hid_device;
jy_cdc_interface = jy_cdc_device;
location = path;
device_name = "JGINYUE " + dmi.getMainboard() + " Internal USB Controller V2";
ZoneCount = 0;
support_Global_zone = false;
Init_device();
}
JGINYUEInternalUSBV2Controller::~JGINYUEInternalUSBV2Controller()
{
hid_close(jy_hid_interface);
if(jy_cdc_interface != nullptr)
{
delete jy_cdc_interface;
}
}
unsigned int JGINYUEInternalUSBV2Controller::GetZoneCount()
{
return(ZoneCount);
}
std::string JGINYUEInternalUSBV2Controller::GetDeviceLocation()
{
return("HID:" + location);
}
std::string JGINYUEInternalUSBV2Controller::GetDeviceName()
{
return(device_name);
}
std::string JGINYUEInternalUSBV2Controller::GetSerialString()
{
return("");
}
std::string JGINYUEInternalUSBV2Controller::GetDeviceFWVersion()
{
return("");
}
void JGINYUEInternalUSBV2Controller::Init_device()
{
unsigned char usb_buf[64];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0] = JGINYUE_V2_HID_GENERAL_COMMAND_HEADER;
usb_buf[1] = 0x0F;
int write_result = hid_write(jy_hid_interface, usb_buf, 64);
if(write_result < 0)
{
LOG_ERROR("[JGINYUEInternalUSBV2Controller] Failed to write to JGINYUE device during initialization");
ZoneCount = 0x00;
memset(device_config, 0x00, sizeof(device_config));
memset(&device_config_Global, 0x00, sizeof(device_config_Global));
return;
}
std::this_thread::sleep_for(20ms);
int bytes_read = hid_read_timeout(jy_hid_interface, usb_buf, 64, 1000);
if(bytes_read <= 0 || usb_buf[1] != 0x0F)
{
LOG_ERROR("[JGINYUEInternalUSBV2Controller] JGINYUE device did not respond or invalid response (bytes read: %d)", bytes_read);
ZoneCount = 0x00;
memset(device_config, 0x00, sizeof(device_config));
memset(&device_config_Global, 0x00, sizeof(device_config_Global));
return;
}
unsigned char Zone_Info = usb_buf[4];
for(unsigned char i = 0; i < 8; i ++)
{
if(Zone_Info & (1<<i))
{
device_config[ZoneCount].Area_ID = (1<<i);
device_config[ZoneCount].Max_LED_numbers = usb_buf[5+i];
Init_Zone(ZoneCount);
ZoneCount++;
}
}
if(ZoneCount == 0)
{
return;
}
if(support_Global_zone == true)
{
ZoneCount++;
//TODO: Get Global zone information
}
}
void JGINYUEInternalUSBV2Controller::Init_Zone(int zone)
{
unsigned char usb_buf[64];
unsigned char Area_ID = device_config[zone].Area_ID;
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0] = JGINYUE_V2_HID_GENERAL_COMMAND_HEADER;
usb_buf[1] = JGINYUE_V2_HID_REQUEST_ARGB_SETTING;
usb_buf[2] = Area_ID;
int write_result = hid_write(jy_hid_interface, usb_buf, 64);
if(write_result < 0)
{
LOG_ERROR("[JGINYUEInternalUSBV2Controller] Failed to write to JGINYUE device for zone %d", zone);
return;
}
std::this_thread::sleep_for(20ms);
int bytes_read = hid_read_timeout(jy_hid_interface, usb_buf, 64, 1000);
if(bytes_read <= 0)
{
LOG_ERROR("[JGINYUEInternalUSBV2Controller] Failed to read zone %d config from JGINYUE device (bytes read: %d)", zone, bytes_read);
return;
}
if((usb_buf[1] != JGINYUE_V2_HID_REQUEST_ARGB_SETTING) || (usb_buf[2] != Area_ID))
{
LOG_ERROR("[JGINYUEInternalUSBV2Controller] Invalid response for zone %d from JGINYUE device", zone);
return;
}
device_config[zone].Mode_active = usb_buf[3];
device_config[zone].User_LED_numbers = usb_buf[4];
unsigned char Color_num = ((usb_buf[5] &0x0F)<8 ? (usb_buf[5] &0x0F): 8);
device_config[zone].Color_num = Color_num;
device_config[zone].Direction = (usb_buf[5]&0x10)>>4;
device_config[zone].Speed = usb_buf[6];
device_config[zone].Brightness = usb_buf[7];
memcpy(&(device_config[zone].Color_Array[0]),&(usb_buf[8]),Color_num*3);
return;
}
void JGINYUEInternalUSBV2Controller::WriteZoneMode
(
unsigned char Area,
unsigned char Mode,
unsigned char Num_LED,
std::vector<RGBColor> rgb,
unsigned char Speed,
unsigned char Brightness,
unsigned char Direction
)
{
unsigned char usb_buf[64];
memset(usb_buf, 0x00, sizeof(usb_buf));
unsigned char num_color = (unsigned char)rgb.size();
num_color = (num_color < 8) ? num_color : 8;
usb_buf[0] = JGINYUE_V2_HID_GENERAL_COMMAND_HEADER;
usb_buf[1] = JGINYUE_V2_HID_DOWNLOAD_ARGB_SETTING;
usb_buf[2] = Area;
usb_buf[3] = Mode;
usb_buf[4] = Num_LED;
usb_buf[5] = (num_color&0x0F)|((Direction&0x01)<<4);
usb_buf[6] = Speed;
usb_buf[7] = Brightness;
for(unsigned char i = 0; i < num_color; i++)
{
RGBColor color = rgb[i];
usb_buf[8+i*3] = RGBGetRValue(color);
usb_buf[9+i*3] = RGBGetGValue(color);
usb_buf[10+i*3] = RGBGetBValue(color);
}
hid_write(jy_hid_interface, usb_buf, 64);
std::this_thread::sleep_for(10ms);
}
void JGINYUEInternalUSBV2Controller::DirectLEDControl
(
RGBColor* colors,
unsigned char num_LEDs,
unsigned char Area
)
{
/*-----------------------------------------------------*\
| Direct mode requires CDC interface |
| If CDC is not available, log error and return |
\*-----------------------------------------------------*/
if(jy_cdc_interface == nullptr)
{
LOG_WARNING("[JGINYUEInternalUSBV2Controller] Direct mode requires serial port (CDC) which is not available. Use other modes instead.");
return;
}
unsigned char cdc_buf[512];
memset(cdc_buf, 0x00, sizeof(cdc_buf));
cdc_buf[0] = JGINYUE_V2_CDC_COMMAND_HEADER;
cdc_buf[1] = FUNCTION_ID_CDC_ARGB;
cdc_buf[2] = Area;
cdc_buf[3] = 0x20;
cdc_buf[4] = num_LEDs;
for(unsigned char i = 0; i < num_LEDs; i++)
{
cdc_buf[8+i*3] = RGBGetRValue(colors[i]);
cdc_buf[9+i*3] = RGBGetGValue(colors[i]);
cdc_buf[10+i*3] = RGBGetBValue(colors[i]);
}
int TX_len = 10 + num_LEDs*3;
if(TX_len%64 == 0)
{
TX_len = TX_len+2;
}
jy_cdc_interface->serial_write((char*)cdc_buf,TX_len);
}
/*---------------------------------------------------------*\
| JGINYUEInternalUSBV2Controller.cpp |
| |
| Driver for JGINYUE USB motherboard V2 |
| |
| Tong R (tcr020) 08 Aug 2024 |
| Liu ShiMeng(Moon dream stars) 09 Aug 2023 |
| Dongguan Yonghang Electronic Technology Co., Ltd |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <cstring>
#include <string>
#include <stdio.h>
#include "RGBController.h"
#include "ResourceManager.h"
#include "SettingsManager.h"
#include "JGINYUEInternalUSBV2Controller.h"
#include "LogManager.h"
#include "dmiinfo.h"
#define JGINYUE_V2_HID_GENERAL_COMMAND_HEADER 0x01
#define JGINYUE_V2_CDC_COMMAND_HEADER 0x10
#define JGINYUE_V2_HID_REQUEST_MCU_STATUS 0x21
#define JGINYUE_V2_HID_REQUEST_MCUID 0x22
#define JGINYUE_V2_HID_REQUEST_UNLOCK 0x23
#define JGINYUE_V2_HID_DOWNLOAD_SKU 0x24
#define JGINYUE_V2_HID_REQUEST_MCU_STATUS_EX 0x0F
#define JGINYUE_V2_HID_DOWNLOAD_ARGB_SETTING 0x01
#define JGINYUE_V2_HID_DOWNLOAD_GLOBAL_SETTING 0x02
#define JGINYUE_V2_HID_REQUEST_ARGB_SETTING 0x11
#define JGINYUE_V2_HID_REQUEST_GLOBAL_SETTING 0x12
#define FUNCTION_ID_CDC_ARGB 0x01
using namespace std::chrono_literals;
JGINYUEInternalUSBV2Controller::JGINYUEInternalUSBV2Controller(hid_device* jy_hid_device, const char* path,serial_port* jy_cdc_device)
{
DMIInfo dmi;
jy_hid_interface = jy_hid_device;
jy_cdc_interface = jy_cdc_device;
location = path;
device_name = "JGINYUE " + dmi.getMainboard() + " Internal USB Controller V2";
ZoneCount = 0;
support_Global_zone = false;
Init_device();
}
JGINYUEInternalUSBV2Controller::~JGINYUEInternalUSBV2Controller()
{
hid_close(jy_hid_interface);
if(jy_cdc_interface != nullptr)
{
delete jy_cdc_interface;
}
}
unsigned int JGINYUEInternalUSBV2Controller::GetZoneCount()
{
return(ZoneCount);
}
std::string JGINYUEInternalUSBV2Controller::GetDeviceLocation()
{
return("HID:" + location);
}
std::string JGINYUEInternalUSBV2Controller::GetDeviceName()
{
return(device_name);
}
std::string JGINYUEInternalUSBV2Controller::GetSerialString()
{
return("");
}
std::string JGINYUEInternalUSBV2Controller::GetDeviceFWVersion()
{
return("");
}
void JGINYUEInternalUSBV2Controller::Init_device()
{
unsigned char usb_buf[64];
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0] = JGINYUE_V2_HID_GENERAL_COMMAND_HEADER;
usb_buf[1] = 0x0F;
int write_result = hid_write(jy_hid_interface, usb_buf, 64);
if(write_result < 0)
{
LOG_ERROR("[JGINYUEInternalUSBV2Controller] Failed to write to JGINYUE device during initialization");
ZoneCount = 0x00;
memset(device_config, 0x00, sizeof(device_config));
memset(&device_config_Global, 0x00, sizeof(device_config_Global));
return;
}
std::this_thread::sleep_for(20ms);
int bytes_read = hid_read_timeout(jy_hid_interface, usb_buf, 64, 1000);
if(bytes_read <= 0 || usb_buf[1] != 0x0F)
{
LOG_ERROR("[JGINYUEInternalUSBV2Controller] JGINYUE device did not respond or invalid response (bytes read: %d)", bytes_read);
ZoneCount = 0x00;
memset(device_config, 0x00, sizeof(device_config));
memset(&device_config_Global, 0x00, sizeof(device_config_Global));
return;
}
unsigned char Zone_Info = usb_buf[4];
for(unsigned char i = 0; i < 8; i ++)
{
if(Zone_Info & (1<<i))
{
device_config[ZoneCount].Area_ID = (1<<i);
device_config[ZoneCount].Max_LED_numbers = usb_buf[5+i];
Init_Zone(ZoneCount);
ZoneCount++;
}
}
if(ZoneCount == 0)
{
return;
}
if(support_Global_zone == true)
{
ZoneCount++;
//TODO: Get Global zone information
}
}
void JGINYUEInternalUSBV2Controller::Init_Zone(int zone)
{
unsigned char usb_buf[64];
unsigned char Area_ID = device_config[zone].Area_ID;
memset(usb_buf, 0x00, sizeof(usb_buf));
usb_buf[0] = JGINYUE_V2_HID_GENERAL_COMMAND_HEADER;
usb_buf[1] = JGINYUE_V2_HID_REQUEST_ARGB_SETTING;
usb_buf[2] = Area_ID;
int write_result = hid_write(jy_hid_interface, usb_buf, 64);
if(write_result < 0)
{
LOG_ERROR("[JGINYUEInternalUSBV2Controller] Failed to write to JGINYUE device for zone %d", zone);
return;
}
std::this_thread::sleep_for(20ms);
int bytes_read = hid_read_timeout(jy_hid_interface, usb_buf, 64, 1000);
if(bytes_read <= 0)
{
LOG_ERROR("[JGINYUEInternalUSBV2Controller] Failed to read zone %d config from JGINYUE device (bytes read: %d)", zone, bytes_read);
return;
}
if((usb_buf[1] != JGINYUE_V2_HID_REQUEST_ARGB_SETTING) || (usb_buf[2] != Area_ID))
{
LOG_ERROR("[JGINYUEInternalUSBV2Controller] Invalid response for zone %d from JGINYUE device", zone);
return;
}
device_config[zone].Mode_active = usb_buf[3];
device_config[zone].User_LED_numbers = usb_buf[4];
unsigned char Color_num = ((usb_buf[5] &0x0F)<8 ? (usb_buf[5] &0x0F): 8);
device_config[zone].Color_num = Color_num;
device_config[zone].Direction = (usb_buf[5]&0x10)>>4;
device_config[zone].Speed = usb_buf[6];
device_config[zone].Brightness = usb_buf[7];
memcpy(&(device_config[zone].Color_Array[0]),&(usb_buf[8]),Color_num*3);
return;
}
void JGINYUEInternalUSBV2Controller::WriteZoneMode
(
unsigned char Area,
unsigned char Mode,
unsigned char Num_LED,
std::vector<RGBColor> rgb,
unsigned char Speed,
unsigned char Brightness,
unsigned char Direction
)
{
unsigned char usb_buf[64];
memset(usb_buf, 0x00, sizeof(usb_buf));
unsigned char num_color = (unsigned char)rgb.size();
num_color = (num_color < 8) ? num_color : 8;
usb_buf[0] = JGINYUE_V2_HID_GENERAL_COMMAND_HEADER;
usb_buf[1] = JGINYUE_V2_HID_DOWNLOAD_ARGB_SETTING;
usb_buf[2] = Area;
usb_buf[3] = Mode;
usb_buf[4] = Num_LED;
usb_buf[5] = (num_color&0x0F)|((Direction&0x01)<<4);
usb_buf[6] = Speed;
usb_buf[7] = Brightness;
for(unsigned char i = 0; i < num_color; i++)
{
RGBColor color = rgb[i];
usb_buf[8+i*3] = RGBGetRValue(color);
usb_buf[9+i*3] = RGBGetGValue(color);
usb_buf[10+i*3] = RGBGetBValue(color);
}
hid_write(jy_hid_interface, usb_buf, 64);
std::this_thread::sleep_for(10ms);
}
void JGINYUEInternalUSBV2Controller::DirectLEDControl
(
RGBColor* colors,
unsigned char num_LEDs,
unsigned char Area
)
{
/*-----------------------------------------------------*\
| Direct mode requires CDC interface |
| If CDC is not available, log error and return |
\*-----------------------------------------------------*/
if(jy_cdc_interface == nullptr)
{
LOG_WARNING("[JGINYUEInternalUSBV2Controller] Direct mode requires serial port (CDC) which is not available. Use other modes instead.");
return;
}
unsigned char cdc_buf[512];
memset(cdc_buf, 0x00, sizeof(cdc_buf));
cdc_buf[0] = JGINYUE_V2_CDC_COMMAND_HEADER;
cdc_buf[1] = FUNCTION_ID_CDC_ARGB;
cdc_buf[2] = Area;
cdc_buf[3] = 0x20;
cdc_buf[4] = num_LEDs;
for(unsigned char i = 0; i < num_LEDs; i++)
{
cdc_buf[8+i*3] = RGBGetRValue(colors[i]);
cdc_buf[9+i*3] = RGBGetGValue(colors[i]);
cdc_buf[10+i*3] = RGBGetBValue(colors[i]);
}
int TX_len = 10 + num_LEDs*3;
if(TX_len%64 == 0)
{
TX_len = TX_len+2;
}
jy_cdc_interface->serial_write((char*)cdc_buf,TX_len);
}
@@ -1,139 +1,139 @@
/*---------------------------------------------------------*\
| JGINYUEInternalUSBV2Controller.h |
| |
| Driver for JGINYUE USB motherboard V2 |
| |
| Tong R (tcr020) 09 Aug 2023 |
| Liu ShiMeng(Moon dream stars) 06 Aug 2024 |
| Dongguan Yonghang Electronic Technology Co., Ltd |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <hidapi.h>
#include "serial_port.h"
#include "RGBController.h"
#define JGINYUE_MAX_ZONES 2
#define JGINYUE_ADDRESSABLE_MAX_LEDS 100
enum
{
JGINYUE_USB_V2_MODE_SYNC = 0x0F,
JGINYUE_USB_V2_MODE_OFF = 0x10,
JGINYUE_USB_V2_MODE_STATIC = 0x11,
JGINYUE_USB_V2_MODE_BREATHING = 0x12,
JGINYUE_USB_V2_MODE_CYCLING = 0x14,
JGINYUE_USB_V2_MODE_RANDOM = 0x15,
JGINYUE_USB_V2_MODE_SPRING = 0x16,
JGINYUE_USB_V2_MODE_WAVE = 0x17,
JGINYUE_USB_V2_MODE_WATER = 0x19,
JGINYUE_USB_V2_MODE_RAINBOW = 0x1A,
JGINYUE_USB_V2_MODE_MULTICOLOR_WAVE = 0x1B,
JGINYUE_USB_V2_MODE_MULTICOLOR_CYCLING = 0x1C,
JGINYUE_USB_V2_MODE_SUNRISE = 0x1D,
JGINYUE_USB_V2_MODE_ROTATE_STAR = 0x1E,
JGINYUE_USB_V2_MODE_METEOR = 0x1F,
JGINYUE_USB_V2_MODE_DIRECT = 0x20,
JGINYUE_USB_V2_MODE_CYCLING_BREATHING = 0x21,
JGINYUE_USB_V2_MODE_CYCLING_RAINING = 0x22,
JGINYUE_USB_V2_MODE_MULTICOLOR_WATER_2 = 0x23,
JGINYUE_USB_V2_MODE_MULTICOLOR_WATER_1 = 0x24,
JGINYUE_USB_V2_MODE_HOURGLASS = 0x25
};
enum
{
JGINYUE_USB_SPEED_MAX = 0xFF,
JGINYUE_USB_SPEED_MIN = 0x00,
JGINYUE_USB_SPEED_DEFAULT = 0x80
};
enum
{
JGINYUE_DIRECTION_RIGHT = 0x00,
JGINYUE_DIRECTION_LEFT = 0x01
};
enum
{
JGINYUE_USB_BRIGHTNESS_MAX = 0xFF,
JGINYUE_USB_BRIGHTNESS_MIN = 0x00,
JGINYUE_USB_BRIGHTNESS_DEFAULT = 0xFF
};
enum
{
JGINYUE_USB_V2_ARGB_STRIP_1 = 0x01,
JGINYUE_USB_V2_ARGB_STRIP_2 = 0x02,
JGINYUE_USB_V2_ARGB_FAN_1 = 0x04,
JGINYUE_USB_V2_ARGB_FAN_2 = 0x08,
JGINYUE_USB_V2_ARGB_FAN_3 = 0x10,
JGINYUE_USB_V2_ARGB_FAN_4 = 0x20,
JGINYUE_USB_V2_ARGB_FAN_5 = 0x40,
};
struct AreaConfigurationV2
{
unsigned char Area_ID;
unsigned char Max_LED_numbers;
unsigned char User_LED_numbers;
unsigned char Direction;
unsigned char Direct_Mode_control; /* 0x00 = Disabled, 0x01 = Enabled */
unsigned char Mode_active;
unsigned char Color_num;
unsigned char Color_Array[30];
unsigned char Brightness;
unsigned char Speed;
};
class JGINYUEInternalUSBV2Controller
{
public:
JGINYUEInternalUSBV2Controller(hid_device* jy_hid_device, const char* path,serial_port* jy_cdc_device);
~JGINYUEInternalUSBV2Controller();
unsigned int GetZoneCount();
std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString();
std::string GetDeviceFWVersion();
void WriteZoneMode
(
unsigned char Area,
unsigned char Mode,
unsigned char Num_LED,
std::vector<RGBColor> rgb,
unsigned char Speed,
unsigned char Brightness,
unsigned char Direction
);
void DirectLEDControl
(
RGBColor* colors,
unsigned char num_LEDs,
unsigned char Area
);
AreaConfigurationV2 device_config[8];
//TODO,When the perzone mode is supported, these parameters will be used to download device configuartion from the device
AreaConfigurationV2 device_config_Global;
//TODO,Can sync its data to other zones,will be used once the perzone mode is supported
bool support_Global_zone;
private:
void Init_device();
void Init_Zone(int zone);
unsigned char ZoneCount;
hid_device* jy_hid_interface;
serial_port* jy_cdc_interface;
std::string location;
std::string device_name;
};
/*---------------------------------------------------------*\
| JGINYUEInternalUSBV2Controller.h |
| |
| Driver for JGINYUE USB motherboard V2 |
| |
| Tong R (tcr020) 09 Aug 2023 |
| Liu ShiMeng(Moon dream stars) 06 Aug 2024 |
| Dongguan Yonghang Electronic Technology Co., Ltd |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include <string>
#include <hidapi.h>
#include "serial_port.h"
#include "RGBController.h"
#define JGINYUE_MAX_ZONES 2
#define JGINYUE_ADDRESSABLE_MAX_LEDS 100
enum
{
JGINYUE_USB_V2_MODE_SYNC = 0x0F,
JGINYUE_USB_V2_MODE_OFF = 0x10,
JGINYUE_USB_V2_MODE_STATIC = 0x11,
JGINYUE_USB_V2_MODE_BREATHING = 0x12,
JGINYUE_USB_V2_MODE_CYCLING = 0x14,
JGINYUE_USB_V2_MODE_RANDOM = 0x15,
JGINYUE_USB_V2_MODE_SPRING = 0x16,
JGINYUE_USB_V2_MODE_WAVE = 0x17,
JGINYUE_USB_V2_MODE_WATER = 0x19,
JGINYUE_USB_V2_MODE_RAINBOW = 0x1A,
JGINYUE_USB_V2_MODE_MULTICOLOR_WAVE = 0x1B,
JGINYUE_USB_V2_MODE_MULTICOLOR_CYCLING = 0x1C,
JGINYUE_USB_V2_MODE_SUNRISE = 0x1D,
JGINYUE_USB_V2_MODE_ROTATE_STAR = 0x1E,
JGINYUE_USB_V2_MODE_METEOR = 0x1F,
JGINYUE_USB_V2_MODE_DIRECT = 0x20,
JGINYUE_USB_V2_MODE_CYCLING_BREATHING = 0x21,
JGINYUE_USB_V2_MODE_CYCLING_RAINING = 0x22,
JGINYUE_USB_V2_MODE_MULTICOLOR_WATER_2 = 0x23,
JGINYUE_USB_V2_MODE_MULTICOLOR_WATER_1 = 0x24,
JGINYUE_USB_V2_MODE_HOURGLASS = 0x25
};
enum
{
JGINYUE_USB_SPEED_MAX = 0xFF,
JGINYUE_USB_SPEED_MIN = 0x00,
JGINYUE_USB_SPEED_DEFAULT = 0x80
};
enum
{
JGINYUE_DIRECTION_RIGHT = 0x00,
JGINYUE_DIRECTION_LEFT = 0x01
};
enum
{
JGINYUE_USB_BRIGHTNESS_MAX = 0xFF,
JGINYUE_USB_BRIGHTNESS_MIN = 0x00,
JGINYUE_USB_BRIGHTNESS_DEFAULT = 0xFF
};
enum
{
JGINYUE_USB_V2_ARGB_STRIP_1 = 0x01,
JGINYUE_USB_V2_ARGB_STRIP_2 = 0x02,
JGINYUE_USB_V2_ARGB_FAN_1 = 0x04,
JGINYUE_USB_V2_ARGB_FAN_2 = 0x08,
JGINYUE_USB_V2_ARGB_FAN_3 = 0x10,
JGINYUE_USB_V2_ARGB_FAN_4 = 0x20,
JGINYUE_USB_V2_ARGB_FAN_5 = 0x40,
};
struct AreaConfigurationV2
{
unsigned char Area_ID;
unsigned char Max_LED_numbers;
unsigned char User_LED_numbers;
unsigned char Direction;
unsigned char Direct_Mode_control; /* 0x00 = Disabled, 0x01 = Enabled */
unsigned char Mode_active;
unsigned char Color_num;
unsigned char Color_Array[30];
unsigned char Brightness;
unsigned char Speed;
};
class JGINYUEInternalUSBV2Controller
{
public:
JGINYUEInternalUSBV2Controller(hid_device* jy_hid_device, const char* path,serial_port* jy_cdc_device);
~JGINYUEInternalUSBV2Controller();
unsigned int GetZoneCount();
std::string GetDeviceLocation();
std::string GetDeviceName();
std::string GetSerialString();
std::string GetDeviceFWVersion();
void WriteZoneMode
(
unsigned char Area,
unsigned char Mode,
unsigned char Num_LED,
std::vector<RGBColor> rgb,
unsigned char Speed,
unsigned char Brightness,
unsigned char Direction
);
void DirectLEDControl
(
RGBColor* colors,
unsigned char num_LEDs,
unsigned char Area
);
AreaConfigurationV2 device_config[8];
//TODO,When the perzone mode is supported, these parameters will be used to download device configuartion from the device
AreaConfigurationV2 device_config_Global;
//TODO,Can sync its data to other zones,will be used once the perzone mode is supported
bool support_Global_zone;
private:
void Init_device();
void Init_Zone(int zone);
unsigned char ZoneCount;
hid_device* jy_hid_interface;
serial_port* jy_cdc_interface;
std::string location;
std::string device_name;
};
@@ -1,99 +1,99 @@
/*---------------------------------------------------------*\
| JGINYUEInternalUSBV2ControllerDetect.cpp |
| |
| Detector for JGINYUE USB motherboard V2 |
| |
| Tong R (tcr020) 06 Aug 2024 |
| Liu ShiMeng(Moon dream stars) 09 Aug 2023 |
| Dongguan Yonghang Electronic Technology Co., Ltd |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <hidapi.h>
#include "serial_port.h"
#include "find_usb_serial_port.h"
#include "RGBController_JGINYUEInternalUSBV2.h"
#include "JGINYUEInternalUSBV2Controller.h"
#include "RGBController.h"
#include "Detector.h"
#include "dmiinfo.h"
#include "LogManager.h"
/*---------------------------------------------------------*\
| JGINYUE vendor ID |
\*---------------------------------------------------------*/
#define JGINYUE_VID_V2 0x1A86
/*---------------------------------------------------------*\
| JGINYUE product ID |
\*---------------------------------------------------------*/
#define JGINYUE_MOTHERBOARD_PID_V2 0xE30B
void DetectJGINYUEInternalUSBV2Controller(hid_device_info* info,const std::string& /*name*/)
{
hid_device* hid_dev = hid_open_path(info->path);
if(hid_dev == nullptr )
{
return;
}
DMIInfo dmi_info;
std::string manufacturer = dmi_info.getManufacturer();
std::transform(manufacturer.begin(), manufacturer.end(), manufacturer.begin(), ::toupper);
if(manufacturer.find("JGINYUE") == std::string::npos)
{
LOG_INFO("[JGINYUEInternalUSBV2ControllerDetect] JGINYUE Internal USB ControllerV2 not found,error manufacturer name:%s",manufacturer.c_str());
hid_close(hid_dev);
return;
}
LOG_INFO("[JGINYUEInternalUSBV2ControllerDetect] Pass manufacture name check.Start to init HID and CDC interface");
if(hid_dev != nullptr )
{
serial_port *port = nullptr;
std::vector<std::string*> serial_ports = find_usb_serial_port(JGINYUE_VID_V2, JGINYUE_MOTHERBOARD_PID_V2);
if(serial_ports.size() == 0)
{
LOG_WARNING("[JGINYUEInternalUSBV2ControllerDetect] JGINYUE device found but no serial port detected - Direct mode will be unavailable");
}
else if(serial_ports.size() > 1)
{
LOG_WARNING("[JGINYUEInternalUSBV2ControllerDetect] Multiple serial ports found for JGINYUE device, using first one");
}
if(serial_ports.size() >= 1)
{
port = new serial_port();
if(!port->serial_open(serial_ports[0]->c_str(), 115200))
{
LOG_WARNING("[JGINYUEInternalUSBV2ControllerDetect] Failed to open serial port %s - Direct mode will be unavailable. HID modes will still work.", serial_ports[0]->c_str());
delete port;
port = nullptr;
}
}
/*-----------------------------------------------------*\
| Clean up serial port string vector |
\*-----------------------------------------------------*/
for(std::string* str_ptr : serial_ports)
{
delete str_ptr;
}
JGINYUEInternalUSBV2Controller *controller = new JGINYUEInternalUSBV2Controller(hid_dev, info->path, port);
RGBController_JGINYUEInternalUSBV2 *rgb_controller = new RGBController_JGINYUEInternalUSBV2(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
#ifdef _WIN32
REGISTER_HID_DETECTOR("JGINYUE Internal USB ControllerV2", DetectJGINYUEInternalUSBV2Controller, JGINYUE_VID_V2, JGINYUE_MOTHERBOARD_PID_V2);
#else
REGISTER_HID_DETECTOR_IPU("JGINYUE Internal USB ControllerV2", DetectJGINYUEInternalUSBV2Controller, JGINYUE_VID_V2, JGINYUE_MOTHERBOARD_PID_V2, 0, 0xFF00, 1);
#endif
/*---------------------------------------------------------*\
| JGINYUEInternalUSBV2ControllerDetect.cpp |
| |
| Detector for JGINYUE USB motherboard V2 |
| |
| Tong R (tcr020) 06 Aug 2024 |
| Liu ShiMeng(Moon dream stars) 09 Aug 2023 |
| Dongguan Yonghang Electronic Technology Co., Ltd |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <hidapi.h>
#include "serial_port.h"
#include "find_usb_serial_port.h"
#include "RGBController_JGINYUEInternalUSBV2.h"
#include "JGINYUEInternalUSBV2Controller.h"
#include "RGBController.h"
#include "Detector.h"
#include "dmiinfo.h"
#include "LogManager.h"
/*---------------------------------------------------------*\
| JGINYUE vendor ID |
\*---------------------------------------------------------*/
#define JGINYUE_VID_V2 0x1A86
/*---------------------------------------------------------*\
| JGINYUE product ID |
\*---------------------------------------------------------*/
#define JGINYUE_MOTHERBOARD_PID_V2 0xE30B
void DetectJGINYUEInternalUSBV2Controller(hid_device_info* info,const std::string& /*name*/)
{
hid_device* hid_dev = hid_open_path(info->path);
if(hid_dev == nullptr )
{
return;
}
DMIInfo dmi_info;
std::string manufacturer = dmi_info.getManufacturer();
std::transform(manufacturer.begin(), manufacturer.end(), manufacturer.begin(), ::toupper);
if(manufacturer.find("JGINYUE") == std::string::npos)
{
LOG_INFO("[JGINYUEInternalUSBV2ControllerDetect] JGINYUE Internal USB ControllerV2 not found,error manufacturer name:%s",manufacturer.c_str());
hid_close(hid_dev);
return;
}
LOG_INFO("[JGINYUEInternalUSBV2ControllerDetect] Pass manufacture name check.Start to init HID and CDC interface");
if(hid_dev != nullptr )
{
serial_port *port = nullptr;
std::vector<std::string*> serial_ports = find_usb_serial_port(JGINYUE_VID_V2, JGINYUE_MOTHERBOARD_PID_V2);
if(serial_ports.size() == 0)
{
LOG_WARNING("[JGINYUEInternalUSBV2ControllerDetect] JGINYUE device found but no serial port detected - Direct mode will be unavailable");
}
else if(serial_ports.size() > 1)
{
LOG_WARNING("[JGINYUEInternalUSBV2ControllerDetect] Multiple serial ports found for JGINYUE device, using first one");
}
if(serial_ports.size() >= 1)
{
port = new serial_port();
if(!port->serial_open(serial_ports[0]->c_str(), 115200))
{
LOG_WARNING("[JGINYUEInternalUSBV2ControllerDetect] Failed to open serial port %s - Direct mode will be unavailable. HID modes will still work.", serial_ports[0]->c_str());
delete port;
port = nullptr;
}
}
/*-----------------------------------------------------*\
| Clean up serial port string vector |
\*-----------------------------------------------------*/
for(std::string* str_ptr : serial_ports)
{
delete str_ptr;
}
JGINYUEInternalUSBV2Controller *controller = new JGINYUEInternalUSBV2Controller(hid_dev, info->path, port);
RGBController_JGINYUEInternalUSBV2 *rgb_controller = new RGBController_JGINYUEInternalUSBV2(controller);
ResourceManager::get()->RegisterRGBController(rgb_controller);
}
}
#ifdef _WIN32
REGISTER_HID_DETECTOR("JGINYUE Internal USB ControllerV2", DetectJGINYUEInternalUSBV2Controller, JGINYUE_VID_V2, JGINYUE_MOTHERBOARD_PID_V2);
#else
REGISTER_HID_DETECTOR_IPU("JGINYUE Internal USB ControllerV2", DetectJGINYUEInternalUSBV2Controller, JGINYUE_VID_V2, JGINYUE_MOTHERBOARD_PID_V2, 0, 0xFF00, 1);
#endif
File diff suppressed because it is too large. Load diff
@@ -1,39 +1,39 @@
/*---------------------------------------------------------*\
| RGBController_JGINYUEInternalUSBV2.h |
| |
| RGBController for JGINYUE USB motherboard V2 |
| |
| Tong R (tcr020) 03 July 2023 |
| Liu ShiMeng(Moon dream stars) 06 Aug 2024 |
| Dongguan Yonghang Electronic Technology Co., Ltd |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "JGINYUEInternalUSBV2Controller.h"
class RGBController_JGINYUEInternalUSBV2 : public RGBController
{
public:
RGBController_JGINYUEInternalUSBV2(JGINYUEInternalUSBV2Controller* controller_ptr);
~RGBController_JGINYUEInternalUSBV2();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceUpdateZoneMode(int zone);
private:
JGINYUEInternalUSBV2Controller* controller;
void InitZones();
};
/*---------------------------------------------------------*\
| RGBController_JGINYUEInternalUSBV2.h |
| |
| RGBController for JGINYUE USB motherboard V2 |
| |
| Tong R (tcr020) 03 July 2023 |
| Liu ShiMeng(Moon dream stars) 06 Aug 2024 |
| Dongguan Yonghang Electronic Technology Co., Ltd |
| |
| This file is part of the OpenRGB project |
| SPDX-License-Identifier: GPL-2.0-or-later |
\*---------------------------------------------------------*/
#pragma once
#include "RGBController.h"
#include "JGINYUEInternalUSBV2Controller.h"
class RGBController_JGINYUEInternalUSBV2 : public RGBController
{
public:
RGBController_JGINYUEInternalUSBV2(JGINYUEInternalUSBV2Controller* controller_ptr);
~RGBController_JGINYUEInternalUSBV2();
void SetupZones();
void ResizeZone(int zone, int new_size);
void DeviceUpdateLEDs();
void UpdateZoneLEDs(int zone);
void UpdateSingleLED(int led);
void DeviceUpdateMode();
void DeviceUpdateZoneMode(int zone);
private:
JGINYUEInternalUSBV2Controller* controller;
void InitZones();
};