mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2026-09-08 08:35:28 -05:00
Add mask based filtering for cypress devices
Some checks are pending
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux32 flags:32 name:Linux GCC 32 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux64 flags:64 name:Linux GCC x64 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm32 flags:arm32 name:Linux GCC ARM 32 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm64 flags:arm64 name:Linux GCC ARM 64 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:macos name:macOS Apple Silicon os:macos-14]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win32 flags:-A Win32 name:Windows VS2022 Win32 os:windows-2022]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win64 flags:-A x64 name:Windows VS2022 x64 os:windows-2022]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:winarm64 flags:-A ARM64 name:Windows VS2022 ARM os:windows-2022]) (push) Waiting to run
CD / Create Pi Mono Setup (push) Blocked by required conditions
CD / Publishing (push) Blocked by required conditions
Some checks are pending
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux32 flags:32 name:Linux GCC 32 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux64 flags:64 name:Linux GCC x64 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm32 flags:arm32 name:Linux GCC ARM 32 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm64 flags:arm64 name:Linux GCC ARM 64 os:ubuntu-latest]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:macos name:macOS Apple Silicon os:macos-14]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win32 flags:-A Win32 name:Windows VS2022 Win32 os:windows-2022]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win64 flags:-A x64 name:Windows VS2022 x64 os:windows-2022]) (push) Waiting to run
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:winarm64 flags:-A ARM64 name:Windows VS2022 ARM os:windows-2022]) (push) Waiting to run
CD / Create Pi Mono Setup (push) Blocked by required conditions
CD / Publishing (push) Blocked by required conditions
This commit is contained in:
@@ -333,7 +333,7 @@ static std::string cypress_driver_get_device_path(HDEVINFO DeviceInfoSet, SP_DEV
|
||||
return result;
|
||||
}
|
||||
|
||||
static bool cypress_driver_get_device_pid_vid_ids(HANDLE handle, uint16_t& out_vid, uint16_t& out_pid, UCHAR &imanufacturer, UCHAR &iproduct, UCHAR &iserial, USHORT &bcdDevice) {
|
||||
static bool cypress_driver_get_device_pid_vid_ids(HANDLE handle, uint16_t& out_vid, uint16_t& out_pid, UCHAR &imanufacturer, UCHAR &iserial, USHORT &bcdDevice) {
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
USB_DEVICE_DESCRIPTOR out_descriptor;
|
||||
@@ -345,27 +345,30 @@ static bool cypress_driver_get_device_pid_vid_ids(HANDLE handle, uint16_t& out_v
|
||||
out_vid = out_descriptor.idVendor;
|
||||
out_pid = out_descriptor.idProduct;
|
||||
imanufacturer = out_descriptor.iManufacturer;
|
||||
iproduct = out_descriptor.iProduct;
|
||||
//iproduct = out_descriptor.iProduct;
|
||||
iserial = out_descriptor.iSerialNumber;
|
||||
bcdDevice = out_descriptor.bcdDevice;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cypress_driver_get_device_pid_vid_manufacturer_product_serial_number(std::string path, uint16_t& out_vid, uint16_t& out_pid, std::string &manufacturer, std::string &product, std::string &serial, uint16_t& bcd_device) {
|
||||
static bool cypress_driver_get_device_pid_vid_imanufacturer_iserial_number(std::string path, uint16_t& out_vid, uint16_t& out_pid, UCHAR &imanufacturer, UCHAR &iserial, USHORT &bcd_device) {
|
||||
HANDLE handle = CreateFile(path.c_str(), (GENERIC_READ | GENERIC_WRITE), (FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
UCHAR imanufacturer;
|
||||
UCHAR iproduct;
|
||||
UCHAR iserial;
|
||||
if(!cypress_driver_get_device_pid_vid_ids(handle, out_vid, out_pid, imanufacturer, iproduct, iserial, bcd_device)) {
|
||||
CloseHandle(handle);
|
||||
bool result = cypress_driver_get_device_pid_vid_ids(handle, out_vid, out_pid, imanufacturer, iserial, bcd_device);
|
||||
CloseHandle(handle);
|
||||
if(!result)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool cypress_driver_get_device_string_manufacturer_product_serial_number(std::string path, std::string &manufacturer, std::string &serial, UCHAR &imanufacturer, UCHAR &iserial) {
|
||||
HANDLE handle = CreateFile(path.c_str(), (GENERIC_READ | GENERIC_WRITE), (FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (handle == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
}
|
||||
USHORT language = 0;
|
||||
cypress_driver_get_string_language_info(handle, language);
|
||||
cypress_driver_get_string_info(handle, imanufacturer, language, manufacturer);
|
||||
cypress_driver_get_string_info(handle, iproduct, language, product);
|
||||
cypress_driver_get_string_info(handle, iserial, language, serial);
|
||||
CloseHandle(handle);
|
||||
return true;
|
||||
@@ -461,15 +464,20 @@ void cypress_driver_list_devices(std::vector<CaptureDevice> &devices_list, bool*
|
||||
continue;
|
||||
uint16_t vid = 0;
|
||||
uint16_t pid = 0;
|
||||
uint16_t bcd_device = 0;
|
||||
std::string manufacturer;
|
||||
std::string product;
|
||||
std::string serial;
|
||||
if(!cypress_driver_get_device_pid_vid_manufacturer_product_serial_number(path, vid, pid, manufacturer, product, serial, bcd_device))
|
||||
USHORT bcd_device = 0;
|
||||
UCHAR imanufacturer = 0;
|
||||
UCHAR iserial = 0;
|
||||
if(!cypress_driver_get_device_pid_vid_imanufacturer_iserial_number(path, vid, pid, imanufacturer, iserial, bcd_device))
|
||||
continue;
|
||||
for (int j = 0; j < device_descriptions.size(); j++) {
|
||||
const cy_device_usb_device* usb_device_desc = device_descriptions[j];
|
||||
if(not_supported_elems[j] && (usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && ((!usb_device_desc->filter_for_product) || (usb_device_desc->wanted_product_str == product))) {
|
||||
uint16_t masked_wanted_bcd_device = usb_device_desc->bcd_device_mask & usb_device_desc->bcd_device_wanted_value;
|
||||
if(not_supported_elems[j] && (usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && (masked_wanted_bcd_device == (bcd_device & usb_device_desc->bcd_device_mask))) {
|
||||
std::string manufacturer;
|
||||
std::string serial;
|
||||
bool result = cypress_driver_get_device_string_manufacturer_product_serial_number(path, manufacturer, serial, imanufacturer, iserial);
|
||||
if(!result)
|
||||
continue;
|
||||
cy_device_device_handlers handlers;
|
||||
bool result_conn_check = cypress_driver_setup_connection(&handlers, path, usb_device_desc->do_pipe_clear_reset);
|
||||
cypress_driver_end_connection(&handlers);
|
||||
@@ -501,6 +509,7 @@ cy_device_device_handlers* cypress_driver_find_by_serial_number(const cy_device_
|
||||
ZeroMemory(&DeviceInterfaceData, sizeof(SP_DEVICE_INTERFACE_DATA));
|
||||
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
uint32_t i = 0;
|
||||
uint16_t masked_wanted_bcd_device = usb_device_desc->bcd_device_mask & usb_device_desc->bcd_device_wanted_value;
|
||||
while(SetupDiEnumDeviceInterfaces(DeviceInfoSet, NULL, to_check_guid, i++, &DeviceInterfaceData)) {
|
||||
std::string path = cypress_driver_get_device_path(DeviceInfoSet, &DeviceInterfaceData);
|
||||
if (path == "")
|
||||
@@ -508,13 +517,18 @@ cy_device_device_handlers* cypress_driver_find_by_serial_number(const cy_device_
|
||||
uint16_t vid = 0;
|
||||
uint16_t pid = 0;
|
||||
uint16_t bcd_device = 0;
|
||||
std::string manufacturer;
|
||||
std::string product;
|
||||
std::string serial;
|
||||
if(!cypress_driver_get_device_pid_vid_manufacturer_product_serial_number(path, vid, pid, manufacturer, product, serial, bcd_device))
|
||||
UCHAR imanufacturer = 0;
|
||||
UCHAR iserial = 0;
|
||||
if(!cypress_driver_get_device_pid_vid_imanufacturer_iserial_number(path, vid, pid, imanufacturer, iserial, bcd_device))
|
||||
continue;
|
||||
std::string read_serial = cypress_get_serial(usb_device_desc, serial, bcd_device, curr_serial_extra_id);
|
||||
if((usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && (wanted_serial_number == read_serial) && ((!usb_device_desc->filter_for_product) || (usb_device_desc->wanted_product_str == product))) {
|
||||
if((usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && (masked_wanted_bcd_device == (bcd_device & usb_device_desc->bcd_device_mask))) {
|
||||
std::string manufacturer;
|
||||
std::string serial;
|
||||
if(!cypress_driver_get_device_string_manufacturer_product_serial_number(path, manufacturer, serial, imanufacturer, iserial))
|
||||
continue;
|
||||
std::string read_serial = cypress_get_serial(usb_device_desc, serial, bcd_device, curr_serial_extra_id);
|
||||
if(wanted_serial_number != read_serial)
|
||||
continue;
|
||||
cy_device_device_handlers handlers;
|
||||
if(cypress_driver_setup_connection(&handlers, path, usb_device_desc->do_pipe_clear_reset)) {
|
||||
final_handlers = new cy_device_device_handlers;
|
||||
@@ -634,6 +648,7 @@ void cypress_driver_find_used_serial(const cy_device_usb_device* usb_device_desc
|
||||
ZeroMemory(&DeviceInterfaceData, sizeof(SP_DEVICE_INTERFACE_DATA));
|
||||
DeviceInterfaceData.cbSize = sizeof(SP_DEVICE_INTERFACE_DATA);
|
||||
uint32_t i = 0;
|
||||
uint16_t masked_wanted_bcd_device = usb_device_desc->bcd_device_mask & usb_device_desc->bcd_device_wanted_value;
|
||||
while(SetupDiEnumDeviceInterfaces(DeviceInfoSet, NULL, to_check_guid, i++, &DeviceInterfaceData)) {
|
||||
std::string path = cypress_driver_get_device_path(DeviceInfoSet, &DeviceInterfaceData);
|
||||
if (path == "")
|
||||
@@ -641,13 +656,16 @@ void cypress_driver_find_used_serial(const cy_device_usb_device* usb_device_desc
|
||||
uint16_t vid = 0;
|
||||
uint16_t pid = 0;
|
||||
uint16_t bcd_device = 0;
|
||||
std::string manufacturer;
|
||||
std::string product;
|
||||
std::string serial;
|
||||
if(!cypress_driver_get_device_pid_vid_manufacturer_product_serial_number(path, vid, pid, manufacturer, product, serial, bcd_device))
|
||||
UCHAR imanufacturer = 0;
|
||||
UCHAR iserial = 0;
|
||||
if(!cypress_driver_get_device_pid_vid_imanufacturer_iserial_number(path, vid, pid, imanufacturer, iserial, bcd_device))
|
||||
continue;
|
||||
std::string read_serial = cypress_get_serial(usb_device_desc, serial, bcd_device, curr_serial_extra_id);
|
||||
if((usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && ((!usb_device_desc->filter_for_product) || (usb_device_desc->wanted_product_str == product))) {
|
||||
if((usb_device_desc->vid == vid) && (usb_device_desc->pid == pid) && (masked_wanted_bcd_device == (bcd_device & usb_device_desc->bcd_device_mask))) {
|
||||
std::string manufacturer;
|
||||
std::string serial;
|
||||
if(!cypress_driver_get_device_string_manufacturer_product_serial_number(path, manufacturer, serial, imanufacturer, iserial))
|
||||
continue;
|
||||
std::string read_serial = cypress_get_serial(usb_device_desc, serial, bcd_device, curr_serial_extra_id);
|
||||
try {
|
||||
int pos = std::stoi(read_serial);
|
||||
if((pos < 0) || (pos >= num_free_fw_ids))
|
||||
|
||||
Reference in New Issue
Block a user