Implement ability to use high bw mode for Optimize - Add ability to not scan for some 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 -DCMAKE_PARALLEL_MSVC=TRUE 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 -DCMAKE_PARALLEL_MSVC=TRUE 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 -DCMAKE_PARALLEL_MSVC=TRUE 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:
Lorenzooone 2025-05-01 00:30:40 +02:00
parent d5ec7b4d61
commit 4189884ded
25 changed files with 208 additions and 107 deletions

View File

@ -8,7 +8,7 @@
#include "display_structs.hpp"
#include "devicecapture.hpp"
void list_devices_ftd3(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list);
void list_devices_ftd3(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan);
bool connect_ftd3(bool print_failed, CaptureData* capture_data, CaptureDevice* device);
void ftd3_capture_main_loop(CaptureData* capture_data);
void ftd3_capture_cleanup(CaptureData* capture_data);

View File

@ -10,7 +10,7 @@
#define FTD2_OLDDS_SYNCH_VALUES 0x4321
void list_devices_ftd2_shared(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list);
void list_devices_ftd2_shared(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan);
bool connect_ftd2_shared(bool print_failed, CaptureData* capture_data, CaptureDevice* device);
void ftd2_capture_main_loop_shared(CaptureData* capture_data);
void ftd2_capture_cleanup_shared(CaptureData* capture_data);

View File

@ -8,7 +8,7 @@
#include "display_structs.hpp"
#include "devicecapture.hpp"
void list_devices_is_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list);
void list_devices_is_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan);
bool is_device_connect_usb(bool print_failed, CaptureData* capture_data, CaptureDevice* device);
void is_device_acquisition_main_loop(CaptureData* capture_data);
void usb_is_device_acquisition_cleanup(CaptureData* capture_data);

View File

@ -55,6 +55,7 @@ struct isd_async_callback_data {
struct is_device_usb_device {
std::string name;
std::string long_name;
PossibleCaptureDevices index_in_allowed_scan;
int vid;
int pid;
int default_config;

View File

@ -7,7 +7,7 @@
#include "usb_is_device_communications.hpp"
#include "usb_is_device_acquisition_general.hpp"
void is_driver_list_devices(std::vector<CaptureDevice>& devices_list, bool* not_supported_elems, int* curr_serial_extra_id_is_device, const size_t num_is_device_desc);
void is_driver_list_devices(std::vector<CaptureDevice>& devices_list, bool* not_supported_elems, int* curr_serial_extra_id_is_device, std::vector<const is_device_usb_device*> &device_descriptions);
is_device_device_handlers* is_driver_serial_reconnection(CaptureDevice* device);
void is_driver_end_connection(is_device_device_handlers* handlers);
bool is_driver_prepare_ctrl_in_handle(is_device_device_handlers* handlers);

View File

@ -5,7 +5,7 @@
#include "capture_structs.hpp"
#include "usb_is_device_communications.hpp"
void is_device_libusb_list_devices(std::vector<CaptureDevice>& devices_list, bool* no_access_elems, bool* not_supported_elems, int* curr_serial_extra_id_is_device, const size_t num_is_device_desc);
void is_device_libusb_list_devices(std::vector<CaptureDevice>& devices_list, bool* no_access_elems, bool* not_supported_elems, int* curr_serial_extra_id_is_device, std::vector<const is_device_usb_device*> &device_descriptions);
is_device_device_handlers* is_device_libusb_serial_reconnection(const is_device_usb_device* usb_device_desc, CaptureDevice* device, int& curr_serial_extra_id);
void is_device_libusb_end_connection(is_device_device_handlers* handlers, const is_device_usb_device* device_desc, bool interface_claimed);
int is_device_libusb_bulk_out(is_device_device_handlers* handlers, const is_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);

View File

@ -8,7 +8,7 @@
#include "display_structs.hpp"
#include "devicecapture.hpp"
void list_devices_cyni_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list);
void list_devices_cyni_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan);
bool cyni_device_connect_usb(bool print_failed, CaptureData* capture_data, CaptureDevice* device);
uint64_t cyni_device_get_video_in_size(CaptureStatus* status);
uint64_t cyni_device_get_video_in_size(CaptureData* capture_data);

View File

@ -23,6 +23,7 @@ struct cyni_device_usb_device {
size_t firmware_size;
cypress_nisetro_device_type next_device;
bool has_bcd_device_serial;
PossibleCaptureDevices index_in_allowed_scan;
cy_device_usb_device usb_device_info;
};

View File

@ -8,7 +8,7 @@
#include "display_structs.hpp"
#include "devicecapture.hpp"
void list_devices_cyop_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list);
void list_devices_cyop_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan);
bool cyop_device_connect_usb(bool print_failed, CaptureData* capture_data, CaptureDevice* device);
uint64_t cyop_device_get_video_in_size(CaptureStatus* status, bool is_3d, InputVideoDataType video_data_type);
uint64_t cyop_device_get_video_in_size(CaptureData* capture_data, bool is_3d, InputVideoDataType video_data_type);

View File

@ -29,6 +29,7 @@ struct cyop_device_usb_device {
bool is_new_device;
cypress_optimize_device_type next_device;
bool has_bcd_device_serial;
PossibleCaptureDevices index_in_allowed_scan;
cy_device_usb_device usb_device_info;
};
@ -40,7 +41,7 @@ const cy_device_usb_device* get_cy_usb_info(const cyop_device_usb_device* usb_de
bool has_to_load_firmware(const cyop_device_usb_device* device);
bool load_firmware(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, uint8_t patch_id);
int capture_start(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, bool is_first_load, bool is_rgb888);
int StartCaptureDma(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, bool is_rgb888);
int StartCaptureDma(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, bool is_rgb888, bool is_3d);
int capture_end(cy_device_device_handlers* handlers, const cyop_device_usb_device* device);
int ReadFrame(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cyop_device_usb_device* device_desc);
int ReadFrameAsync(cy_device_device_handlers* handlers, uint8_t* buf, int length, const cyop_device_usb_device* device_desc, cy_async_callback_data* cb_data);

View File

@ -10,7 +10,7 @@
#define SIMPLE_DS_FRAME_SKIP
void list_devices_usb_ds_3ds(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list);
void list_devices_usb_ds_3ds(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan);
bool connect_usb(bool print_failed, CaptureData* capture_data, CaptureDevice* device);
void usb_capture_main_loop(CaptureData* capture_data);
void usb_capture_cleanup(CaptureData* capture_data);

View File

@ -26,6 +26,7 @@ enum CaptureConnectionType { CAPTURE_CONN_FTD3, CAPTURE_CONN_USB, CAPTURE_CONN_F
enum InputVideoDataType { VIDEO_DATA_RGB, VIDEO_DATA_BGR, VIDEO_DATA_RGB16, VIDEO_DATA_BGR16 };
enum CaptureScreensType { CAPTURE_SCREENS_BOTH, CAPTURE_SCREENS_TOP, CAPTURE_SCREENS_BOTTOM, CAPTURE_SCREENS_ENUM_END };
enum CaptureSpeedsType { CAPTURE_SPEEDS_FULL, CAPTURE_SPEEDS_HALF, CAPTURE_SPEEDS_THIRD, CAPTURE_SPEEDS_QUARTER, CAPTURE_SPEEDS_ENUM_END };
enum PossibleCaptureDevices { CC_LOOPY_OLD_DS, CC_LOOPY_NEW_DS, CC_LOOPY_OLD_3DS, CC_LOOPY_NEW_N3DSXL, CC_IS_NITRO_EMULATOR, CC_IS_NITRO_CAPTURE, CC_IS_TWL_CAPTURE, CC_NISETRO_DS, CC_OPTIMIZE_O3DS, CC_OPTIMIZE_N3DS, CC_POSSIBLE_DEVICES_END };
// Readers are Audio and Video. So 2.
// Use 6 extra buffers. 5 for async writing in case the other 2 are busy,
@ -325,10 +326,13 @@ struct CaptureStatus {
volatile int curr_delay = 0;
volatile bool reset_hardware = false;
bool requested_3d = false;
bool request_low_bw_format = true;
CaptureScreensType capture_type;
CaptureSpeedsType capture_speed;
int battery_percentage;
bool ac_adapter_connected;
// Needed for Nisetro DS(i) and Old Optimize 3DS
bool devices_allowed_scan[CC_POSSIBLE_DEVICES_END];
ConsumerMutex video_wait;
ConsumerMutex audio_wait;
};

View File

@ -31,7 +31,10 @@ void ftd3_insert_device(std::vector<CaptureDevice> &devices_list, std::string se
devices_list.emplace_back(ftd3_get_serial(serial_string, curr_serial_extra_id), short_name, long_name, CAPTURE_CONN_FTD3, (void*)NULL, true, true, true, HEIGHT_3DS, TOP_WIDTH_3DS + BOT_WIDTH_3DS, HEIGHT_3DS, (TOP_WIDTH_3DS * 2) + BOT_WIDTH_3DS, N3DSXL_SAMPLES_IN, 90, BOT_WIDTH_3DS, 0, BOT_WIDTH_3DS + TOP_WIDTH_3DS, 0, 0, 0, false, VIDEO_DATA_RGB, usb_speed);
}
void list_devices_ftd3(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list) {
void list_devices_ftd3(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan) {
// If more devices used this, it would need to be expanded...
if(!devices_allowed_scan[CC_LOOPY_NEW_N3DSXL])
return;
ftd3_list_devices_compat(devices_list, no_access_list, valid_3dscapture_descriptions);
}

View File

@ -69,7 +69,10 @@ void insert_device_ftd2_shared(std::vector<CaptureDevice> &devices_list, char* d
}
}
void list_devices_ftd2_shared(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list) {
void list_devices_ftd2_shared(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan) {
// If more devices used this, it would need to be expanded...
if(!devices_allowed_scan[CC_LOOPY_NEW_DS])
return;
list_devices_ftd2_compatibility(devices_list, no_access_list);
}

View File

@ -87,28 +87,33 @@ static is_device_device_handlers* usb_find_by_serial_number(const is_device_usb_
return final_handlers;
}
void list_devices_is_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list) {
void list_devices_is_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan) {
const size_t num_is_device_desc = GetNumISDeviceDesc();
int* curr_serial_extra_id_is_device = new int[num_is_device_desc];
bool* no_access_elems = new bool[num_is_device_desc];
bool* not_supported_elems = new bool[num_is_device_desc];
std::vector<const is_device_usb_device*> device_descriptions;
for(size_t i = 0; i < num_is_device_desc; i++) {
no_access_elems[i] = false;
not_supported_elems[i] = false;
curr_serial_extra_id_is_device[i] = 0;
const is_device_usb_device* usb_device_desc = GetISDeviceDesc((int)i);
if(devices_allowed_scan[usb_device_desc->index_in_allowed_scan])
device_descriptions.push_back(usb_device_desc);
}
is_device_libusb_list_devices(devices_list, no_access_elems, not_supported_elems, curr_serial_extra_id_is_device, num_is_device_desc);
is_device_libusb_list_devices(devices_list, no_access_elems, not_supported_elems, curr_serial_extra_id_is_device, device_descriptions);
bool any_not_supported = false;
for(size_t i = 0; i < num_is_device_desc; i++)
any_not_supported |= not_supported_elems[i];
for(size_t i = 0; i < num_is_device_desc; i++)
if(no_access_elems[i]) {
const is_device_usb_device* usb_device = GetISDeviceDesc((int)i);
const is_device_usb_device* usb_device = device_descriptions[i];
no_access_list.emplace_back(usb_device->vid, usb_device->pid);
}
if(any_not_supported)
is_driver_list_devices(devices_list, not_supported_elems, curr_serial_extra_id_is_device, num_is_device_desc);
is_driver_list_devices(devices_list, not_supported_elems, curr_serial_extra_id_is_device, device_descriptions);
delete[] curr_serial_extra_id_is_device;
delete[] no_access_elems;

View File

@ -174,6 +174,7 @@ struct PACKED is_twl_capture_information_packet {
static const is_device_usb_device usb_is_nitro_emu_rare_desc = {
.name = "ISNEr", .long_name = "IS Nitro Emulator(R)",
.index_in_allowed_scan = CC_IS_NITRO_EMULATOR,
.vid = 0x0f6e, .pid = 0x0400,
.default_config = 1, .default_interface = 0,
.bulk_timeout = 500,
@ -186,6 +187,7 @@ static const is_device_usb_device usb_is_nitro_emu_rare_desc = {
static const is_device_usb_device usb_is_nitro_emu_common_desc = {
.name = "ISNE", .long_name = "IS Nitro Emulator",
.index_in_allowed_scan = CC_IS_NITRO_EMULATOR,
.vid = 0x0f6e, .pid = 0x0404,
.default_config = 1, .default_interface = 0,
.bulk_timeout = 500,
@ -198,6 +200,7 @@ static const is_device_usb_device usb_is_nitro_emu_common_desc = {
static const is_device_usb_device usb_is_nitro_cap_desc = {
.name = "ISNC", .long_name = "IS Nitro Capture",
.index_in_allowed_scan = CC_IS_NITRO_CAPTURE,
.vid = 0x0f6e, .pid = 0x0403,
.default_config = 1, .default_interface = 0,
.bulk_timeout = 500,
@ -210,6 +213,7 @@ static const is_device_usb_device usb_is_nitro_cap_desc = {
static const is_device_usb_device usb_is_twl_cap_desc = {
.name = "ISTCD", .long_name = "IS TWL Capture (Dev)",
.index_in_allowed_scan = CC_IS_TWL_CAPTURE,
.vid = 0x0f6e, .pid = 0x0501,
.default_config = 1, .default_interface = 0,
.bulk_timeout = 500,
@ -222,6 +226,7 @@ static const is_device_usb_device usb_is_twl_cap_desc = {
static const is_device_usb_device usb_is_twl_cap_desc_2 = {
.name = "ISTCR", .long_name = "IS TWL Capture (Ret)",
.index_in_allowed_scan = CC_IS_TWL_CAPTURE,
.vid = 0x0f6e, .pid = 0x0502,
.default_config = 1, .default_interface = 0,
.bulk_timeout = 500,

View File

@ -230,7 +230,7 @@ void is_driver_end_connection(is_device_device_handlers* handlers) {
#endif
}
void is_driver_list_devices(std::vector<CaptureDevice> &devices_list, bool* not_supported_elems, int *curr_serial_extra_id_is_device, const size_t num_is_device_desc) {
void is_driver_list_devices(std::vector<CaptureDevice> &devices_list, bool* not_supported_elems, int *curr_serial_extra_id_is_device, std::vector<const is_device_usb_device*> &device_descriptions) {
#ifdef _WIN32
HDEVINFO DeviceInfoSet = SetupDiGetClassDevs(
&is_device_driver_guid,
@ -250,8 +250,8 @@ void is_driver_list_devices(std::vector<CaptureDevice> &devices_list, bool* not_
uint16_t pid = 0;
if(!is_driver_get_device_pid_vid(path, vid, pid))
continue;
for(size_t j = 0; j < num_is_device_desc; j++) {
const is_device_usb_device* usb_device_desc = GetISDeviceDesc((int)j);
for(size_t j = 0; j < device_descriptions.size(); j++) {
const is_device_usb_device* usb_device_desc = device_descriptions[j];
if(not_supported_elems[j] && (usb_device_desc->vid == vid) && (usb_device_desc->pid == pid)) {
is_device_device_handlers handlers;
if(is_driver_setup_connection(&handlers, path, usb_device_desc->read_pipe, usb_device_desc->write_pipe, usb_device_desc->do_pipe_clear_reset))

View File

@ -106,7 +106,7 @@ void is_device_libusb_end_connection(is_device_device_handlers* handlers, const
handlers->usb_handle = NULL;
}
void is_device_libusb_list_devices(std::vector<CaptureDevice> &devices_list, bool* no_access_elems, bool* not_supported_elems, int* curr_serial_extra_id_is_device, const size_t num_is_device_desc) {
void is_device_libusb_list_devices(std::vector<CaptureDevice> &devices_list, bool* no_access_elems, bool* not_supported_elems, int* curr_serial_extra_id_is_device, std::vector<const is_device_usb_device*> &device_descriptions) {
if(!usb_is_initialized())
return;
libusb_device **usb_devices;
@ -117,8 +117,8 @@ void is_device_libusb_list_devices(std::vector<CaptureDevice> &devices_list, boo
int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor);
if(result < 0)
continue;
for (size_t j = 0; j < num_is_device_desc; j++) {
result = is_device_libusb_insert_device(devices_list, GetISDeviceDesc((int)j), usb_devices[i], &usb_descriptor, curr_serial_extra_id_is_device[j]);
for (size_t j = 0; j < device_descriptions.size(); j++) {
result = is_device_libusb_insert_device(devices_list, device_descriptions[j], usb_devices[i], &usb_descriptor, curr_serial_extra_id_is_device[j]);
if (result != LIBUSB_ERROR_NOT_FOUND) {
if (result == LIBUSB_ERROR_ACCESS)
no_access_elems[j] = true;

View File

@ -118,7 +118,7 @@ static void cypress_nisetro_connection_end(cy_device_device_handlers* handlers,
delete handlers;
}
void list_devices_cyni_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list) {
void list_devices_cyni_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan) {
const size_t num_cyni_device_desc = GetNumCyNiDeviceDesc();
int* curr_serial_extra_id_cyni_device = new int[num_cyni_device_desc];
bool* no_access_elems = new bool[num_cyni_device_desc];
@ -129,7 +129,8 @@ void list_devices_cyni_device(std::vector<CaptureDevice> &devices_list, std::vec
not_supported_elems[i] = false;
curr_serial_extra_id_cyni_device[i] = 0;
const cyni_device_usb_device* curr_device_desc = GetCyNiDeviceDesc((int)i);
usb_devices_to_check.push_back(get_cy_usb_info(curr_device_desc));
if(devices_allowed_scan[curr_device_desc->index_in_allowed_scan])
usb_devices_to_check.push_back(get_cy_usb_info(curr_device_desc));
}
cypress_libusb_list_devices(devices_list, no_access_elems, not_supported_elems, curr_serial_extra_id_cyni_device, usb_devices_to_check);

View File

@ -33,12 +33,13 @@
#define NISETRO_DS_WANTED_VALUE_BASE 0xFF00
static const cyni_device_usb_device cypress_fx2_generic_device = {
.name = "EZ-USB -> Nisetro DS", .long_name = "EZ-USB -> Nisetro DS",
.name = "NiseTro DS(i)", .long_name = "NiseTro DS(i)",
.device_type = CYPRESS_NISETRO_BLANK_DEVICE,
.video_data_type = VIDEO_DATA_RGB,
.firmware_to_load = nisetro_ds_fw, .firmware_size = nisetro_ds_fw_len,
.next_device = CYPRESS_NISETRO_DS_DEVICE,
.has_bcd_device_serial = false,
.index_in_allowed_scan = CC_NISETRO_DS,
.usb_device_info = {
.vid = 0x04B4, .pid = 0x8613,
.default_config = 1, .default_interface = 0,
@ -57,12 +58,13 @@ static const cyni_device_usb_device cypress_fx2_generic_device = {
};
static const cyni_device_usb_device cypress_fx2_nisetro_ds_device = {
.name = "Nisetro DS", .long_name = "Nisetro DS",
.name = "Nisetro DS(i)", .long_name = "Nisetro DS(i)",
.device_type = CYPRESS_NISETRO_DS_DEVICE,
.video_data_type = VIDEO_DATA_RGB,
.firmware_to_load = NULL, .firmware_size = 0,
.next_device = CYPRESS_NISETRO_DS_DEVICE,
.has_bcd_device_serial = true,
.index_in_allowed_scan = CC_NISETRO_DS,
.usb_device_info = {
.vid = 0x04B4, .pid = 0x1004,
.default_config = 1, .default_interface = 0,

View File

@ -126,7 +126,7 @@ static void cypress_optimize_3ds_connection_end(cy_device_device_handlers* handl
delete handlers;
}
void list_devices_cyop_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list) {
void list_devices_cyop_device(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan) {
const size_t num_cyop_device_desc = GetNumCyOpDeviceDesc();
int* curr_serial_extra_id_cyop_device = new int[num_cyop_device_desc];
bool* no_access_elems = new bool[num_cyop_device_desc];
@ -137,7 +137,8 @@ void list_devices_cyop_device(std::vector<CaptureDevice> &devices_list, std::vec
not_supported_elems[i] = false;
curr_serial_extra_id_cyop_device[i] = 0;
const cyop_device_usb_device* curr_device_desc = GetCyOpDeviceDesc((int)i);
usb_devices_to_check.push_back(get_cy_usb_info(curr_device_desc));
if(devices_allowed_scan[curr_device_desc->index_in_allowed_scan])
usb_devices_to_check.push_back(get_cy_usb_info(curr_device_desc));
}
cypress_libusb_list_devices(devices_list, no_access_elems, not_supported_elems, curr_serial_extra_id_cyop_device, usb_devices_to_check);
@ -224,6 +225,14 @@ uint64_t cyop_device_get_video_in_size(CaptureData* capture_data, bool is_3d, In
return cyop_device_get_video_in_size(&capture_data->status, is_3d, video_data_type);
}
static InputVideoDataType extract_wanted_input_video_data_type(CaptureStatus* capture_status) {
return capture_status->request_low_bw_format ? VIDEO_DATA_RGB16 : VIDEO_DATA_RGB;
}
static InputVideoDataType extract_wanted_input_video_data_type(CaptureData* capture_data) {
return extract_wanted_input_video_data_type(&capture_data->status);
}
static int cypress_device_read_frame_request(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, uint32_t index, bool is_3d, InputVideoDataType video_data_type) {
if(cypress_device_capture_recv_data == NULL)
return LIBUSB_SUCCESS;
@ -614,7 +623,7 @@ static void reset_buffer_processing_data(CypressOptimize3DSDeviceCaptureReceived
}
}
static int timeout_error_handler(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, uint32_t &index, InputVideoDataType &stored_video_data_type, bool &stored_is_3d) {
static int restart_captures_cc_reads(CaptureData* capture_data, CypressOptimize3DSDeviceCaptureReceivedData* cypress_device_capture_recv_data, uint32_t &index, InputVideoDataType &stored_video_data_type, bool &stored_is_3d) {
cy_device_device_handlers* handlers = (cy_device_device_handlers*)capture_data->handle;
const cyop_device_usb_device* usb_device_desc = (const cyop_device_usb_device*)capture_data->status.device.descriptor;
int retval = end_capture_from_capture_data(capture_data);
@ -623,12 +632,32 @@ static int timeout_error_handler(CaptureData* capture_data, CypressOptimize3DSDe
error_cypress_device_status(cypress_device_capture_recv_data, 0);
default_sleep(100);
InputVideoDataType wanted_input_video_data_type = extract_wanted_input_video_data_type(capture_data);
bool set_max_again = false;
if(wanted_input_video_data_type != stored_video_data_type) {
set_max_again = true;
stored_video_data_type = wanted_input_video_data_type;
retval = capture_start(handlers, usb_device_desc, true, stored_video_data_type == VIDEO_DATA_RGB);
capture_data->status.device.video_data_type = stored_video_data_type;
if(retval < 0)
return retval;
}
bool is_new_3d = false;
if(is_new_3d != stored_is_3d) {
set_max_again = true;
stored_is_3d = is_new_3d;
}
if(set_max_again)
CypressSetMaxTransferSize(handlers, get_cy_usb_info(usb_device_desc), (size_t)cyop_device_get_video_in_size_extra_header(stored_is_3d, stored_video_data_type));
index = 0;
reset_buffer_processing_data(cypress_device_capture_recv_data);
if(!schedule_all_reads(capture_data, cypress_device_capture_recv_data, index, stored_video_data_type, stored_is_3d, ""))
return -1;
StartCaptureDma(handlers, usb_device_desc, stored_video_data_type == VIDEO_DATA_RGB);
StartCaptureDma(handlers, usb_device_desc, stored_video_data_type == VIDEO_DATA_RGB, stored_is_3d);
return 0;
}
@ -637,6 +666,7 @@ static bool cyop_device_acquisition_loop(CaptureData* capture_data, CypressOptim
const cyop_device_usb_device* usb_device_desc = (const cyop_device_usb_device*)capture_data->status.device.descriptor;
uint32_t index = 0;
int ret = capture_start(handlers, usb_device_desc, true, stored_video_data_type == VIDEO_DATA_RGB);
capture_data->status.device.video_data_type = stored_video_data_type;
if (ret < 0) {
capture_error_print(true, capture_data, "Capture Start: Failed");
return false;
@ -645,7 +675,7 @@ static bool cyop_device_acquisition_loop(CaptureData* capture_data, CypressOptim
if(!schedule_all_reads(capture_data, cypress_device_capture_recv_data, index, stored_video_data_type, stored_is_3d, "Initial Reads: Failed"))
return false;
StartCaptureDma(handlers, usb_device_desc, stored_video_data_type == VIDEO_DATA_RGB);
StartCaptureDma(handlers, usb_device_desc, stored_video_data_type == VIDEO_DATA_RGB, stored_is_3d);
while (capture_data->status.connected && capture_data->status.running) {
ret = get_cypress_device_status(cypress_device_capture_recv_data);
if(ret < 0) {
@ -653,7 +683,7 @@ static bool cyop_device_acquisition_loop(CaptureData* capture_data, CypressOptim
wait_all_cypress_device_buffers_free(capture_data, cypress_device_capture_recv_data);
bool has_recovered = false;
if(cause_error == LIBUSB_ERROR_TIMEOUT) {
int timeout_ret = timeout_error_handler(capture_data, cypress_device_capture_recv_data, index, stored_video_data_type, stored_is_3d);
int timeout_ret = restart_captures_cc_reads(capture_data, cypress_device_capture_recv_data, index, stored_video_data_type, stored_is_3d);
if(timeout_ret >= 0)
has_recovered = true;
}
@ -662,6 +692,16 @@ static bool cyop_device_acquisition_loop(CaptureData* capture_data, CypressOptim
return false;
}
}
bool is_new_3d = false;
InputVideoDataType wanted_input_video_data_type = extract_wanted_input_video_data_type(capture_data);
if((wanted_input_video_data_type != stored_video_data_type) || (is_new_3d != stored_is_3d)) {
wait_all_cypress_device_buffers_free(capture_data, cypress_device_capture_recv_data);
ret = restart_captures_cc_reads(capture_data, cypress_device_capture_recv_data, index, stored_video_data_type, stored_is_3d);
if(ret < 0) {
capture_error_print(true, capture_data, "Disconnected: Update mode error");
return false;
}
}
if(!get_buffer_and_schedule_read(capture_data, cypress_device_capture_recv_data, index, stored_video_data_type, stored_is_3d, "Setup Read: Failed"))
return false;
}
@ -678,7 +718,7 @@ void cyop_device_acquisition_main_loop(CaptureData* capture_data) {
uint32_t last_index = -1;
int status = 0;
InputVideoDataType stored_video_data_type = capture_data->status.device.video_data_type;
InputVideoDataType stored_video_data_type = extract_wanted_input_video_data_type(capture_data);
bool stored_is_3d = false;
uint8_t *ring_slice_buffer = new uint8_t[NUM_TOTAL_OPTIMIZE_3DS_CYPRESS_BUFFERS * SINGLE_RING_BUFFER_SLICE_SIZE];

View File

@ -38,7 +38,7 @@ const uint8_t start_capture_third_buffer_565_old[] = { 0x61, 0x07, 0x00, 0x26, 0
const uint8_t start_capture_third_buffer_888_old[] = { 0x61, 0x07, 0x00, 0xA6, 0x00, 0x20, 0x00, 0x98, 0x00, 0x08, 0x00, 0xDE, 0x00, 0xF9, 0x18, 0x0F };
static const cyop_device_usb_device cypress_optimize_new_3ds_generic_device = {
.name = "EZ-USB -> Optimize New 3DS", .long_name = "EZ-USB -> Optimize New 3DS",
.name = "Optimize New 3DS", .long_name = "Optimize New 3DS",
.device_type = CYPRESS_OPTIMIZE_NEW_3DS_BLANK_DEVICE,
.firmware_to_load = optimize_new_3ds_fw, .firmware_size = optimize_new_3ds_fw_len,
.fpga_pl_565 = NULL, .fpga_pl_565_size = 0,
@ -46,6 +46,7 @@ static const cyop_device_usb_device cypress_optimize_new_3ds_generic_device = {
.is_new_device = true,
.next_device = CYPRESS_OPTIMIZE_NEW_3DS_INSTANTIATED_DEVICE,
.has_bcd_device_serial = false,
.index_in_allowed_scan = CC_OPTIMIZE_N3DS,
.usb_device_info = {
.vid = 0x0752, .pid = 0x8613,
.default_config = 1, .default_interface = 0,
@ -72,6 +73,7 @@ static const cyop_device_usb_device cypress_optimize_new_3ds_instantiated_device
.is_new_device = true,
.next_device = CYPRESS_OPTIMIZE_NEW_3DS_INSTANTIATED_DEVICE,
.has_bcd_device_serial = true,
.index_in_allowed_scan = CC_OPTIMIZE_N3DS,
.usb_device_info = {
.vid = 0x04B4, .pid = 0x1004,
.default_config = 1, .default_interface = 0,
@ -90,7 +92,7 @@ static const cyop_device_usb_device cypress_optimize_new_3ds_instantiated_device
};
static const cyop_device_usb_device cypress_optimize_old_3ds_generic_device = {
.name = "EZ-USB -> Optimize Old 3DS", .long_name = "EZ-USB -> Optimize Old 3DS",
.name = "Optimize Old 3DS", .long_name = "Optimize Old 3DS",
.device_type = CYPRESS_OPTIMIZE_OLD_3DS_BLANK_DEVICE,
.firmware_to_load = optimize_old_3ds_fw, .firmware_size = optimize_old_3ds_fw_len,
.fpga_pl_565 = NULL, .fpga_pl_565_size = 0,
@ -98,6 +100,7 @@ static const cyop_device_usb_device cypress_optimize_old_3ds_generic_device = {
.is_new_device = false,
.next_device = CYPRESS_OPTIMIZE_OLD_3DS_INSTANTIATED_DEVICE,
.has_bcd_device_serial = false,
.index_in_allowed_scan = CC_OPTIMIZE_O3DS,
.usb_device_info = {
.vid = 0x04B4, .pid = 0x8613,
.default_config = 1, .default_interface = 0,
@ -124,6 +127,7 @@ static const cyop_device_usb_device cypress_optimize_old_3ds_instantiated_device
.is_new_device = false,
.next_device = CYPRESS_OPTIMIZE_OLD_3DS_INSTANTIATED_DEVICE,
.has_bcd_device_serial = true,
.index_in_allowed_scan = CC_OPTIMIZE_O3DS,
.usb_device_info = {
.vid = 0x04B4, .pid = 0x1004,
.default_config = 1, .default_interface = 0,
@ -494,7 +498,7 @@ static const uint8_t* get_start_capture_third_buffer(const cyop_device_usb_devic
return start_capture_third_buffer_565_old;
}
int StartCaptureDma(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, bool is_rgb888) {
int StartCaptureDma(cy_device_device_handlers* handlers, const cyop_device_usb_device* device, bool is_rgb888, bool is_3d) {
const uint8_t mono_buffer[] = { 0x40 };
int transferred = 0;
int ret = cypress_ctrl_bulk_out_transfer(handlers, get_cy_usb_info(device), mono_buffer, sizeof(mono_buffer), &transferred);

View File

@ -41,6 +41,7 @@ struct usb_device {
int cmdout_i2c_write;
int i2caddr_3dsconfig;
int bitstream_3dscfg_ver;
PossibleCaptureDevices index_in_allowed_scan;
};
static const usb_device usb_3ds_desc = {
@ -52,7 +53,8 @@ static const usb_device usb_3ds_desc = {
.cmdin_status = 0, .cmdin_frameinfo = 0,
.cmdout_capture_start = 0x40, .cmdout_capture_stop = 0,
.cmdin_i2c_read = 0x21, .cmdout_i2c_write = 0x21,
.i2caddr_3dsconfig = 0x14, .bitstream_3dscfg_ver = 1
.i2caddr_3dsconfig = 0x14, .bitstream_3dscfg_ver = 1,
.index_in_allowed_scan = CC_LOOPY_OLD_3DS
};
static const usb_device usb_old_ds_desc = {
@ -64,7 +66,8 @@ static const usb_device usb_old_ds_desc = {
.cmdin_status = 0x31, .cmdin_frameinfo = 0x30,
.cmdout_capture_start = 0x30, .cmdout_capture_stop = 0x31,
.cmdin_i2c_read = 0, .cmdout_i2c_write = 0,
.i2caddr_3dsconfig = 0, .bitstream_3dscfg_ver = 0
.i2caddr_3dsconfig = 0, .bitstream_3dscfg_ver = 0,
.index_in_allowed_scan = CC_LOOPY_OLD_DS
};
static const usb_device* usb_devices_desc_list[] = {
@ -323,7 +326,7 @@ static void process_usb_capture_result(usb_capture_status result, std::chrono::t
capture_data->data_buffers.ReleaseWriterBuffer(0, false);
}
void list_devices_usb_ds_3ds(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list) {
void list_devices_usb_ds_3ds(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list, bool* devices_allowed_scan) {
if(!usb_is_initialized())
return;
libusb_device **usb_devices;
@ -341,12 +344,15 @@ void list_devices_usb_ds_3ds(std::vector<CaptureDevice> &devices_list, std::vect
int result = libusb_get_device_descriptor(usb_devices[i], &usb_descriptor);
if(result < 0)
continue;
for(size_t j = 0; j < num_usb_desc; j++)
for(size_t j = 0; j < num_usb_desc; j++) {
if(!devices_allowed_scan[usb_devices_desc_list[j]->index_in_allowed_scan])
continue;
if(insert_device(devices_list, usb_devices_desc_list[j], usb_devices[i], &usb_descriptor, curr_serial_extra_ids[j]) != LIBUSB_ERROR_NOT_FOUND) {
if (result == LIBUSB_ERROR_ACCESS)
no_access_elems[j] = true;
break;
}
}
}
if(num_devices >= 0)

View File

@ -139,72 +139,87 @@ static bool load(const std::string path, const std::string name, ScreenInfo &top
std::istringstream kvp(line);
std::string key;
if(std::getline(kvp, key, '=')) {
std::string value;
if(!std::getline(kvp, key, '='))
continue;
if(std::getline(kvp, value)) {
std::string value;
if(!std::getline(kvp, value))
continue;
if(load_screen_info(key, value, "bot_", bottom_info))
continue;
if(load_screen_info(key, value, "joint_", joint_info))
continue;
if(load_screen_info(key, value, "top_", top_info))
continue;
if(load_screen_info(key, value, "bot_", bottom_info))
continue;
if(load_screen_info(key, value, "joint_", joint_info))
continue;
if(load_screen_info(key, value, "top_", top_info))
continue;
if(key == "split") {
bool split = std::stoi(value);
joint_info.window_enabled = !split;
top_info.window_enabled = split;
bottom_info.window_enabled = split;
continue;
}
if(key == "requested_3d") {
set_3d_enabled(capture_status, std::stoi(value));
loaded_3d_request = true;
continue;
}
if(key == "interleaved_3d") {
display_data.interleaved_3d = std::stoi(value);
continue;
}
if(key == "last_connected_ds") {
display_data.last_connected_ds = std::stoi(value);
continue;
}
if(key == "is_screen_capture_type") {
capture_status->capture_type = static_cast<CaptureScreensType>(std::stoi(value) % CaptureScreensType::CAPTURE_SCREENS_ENUM_END);
continue;
}
if(key == "is_speed_capture") {
capture_status->capture_speed = static_cast<CaptureSpeedsType>(std::stoi(value) % CaptureSpeedsType::CAPTURE_SPEEDS_ENUM_END);
continue;
}
if(key == "is_battery_percentage") {
capture_status->battery_percentage = std::stoi(value);
// Even though 1 is allowed, it spam-resets the Hardware...
// So don't allow it as the initial value!
if(capture_status->battery_percentage <= 5)
capture_status->battery_percentage = 5;
if(capture_status->battery_percentage > 100)
capture_status->battery_percentage = 100;
continue;
}
if(key == "is_ac_adapter_connected") {
capture_status->ac_adapter_connected = std::stoi(value);
continue;
}
if(audio_data->load_audio_data(key, value))
continue;
}
if(key == "split") {
bool split = std::stoi(value);
joint_info.window_enabled = !split;
top_info.window_enabled = split;
bottom_info.window_enabled = split;
continue;
}
if(key == "requested_3d") {
set_3d_enabled(capture_status, std::stoi(value));
loaded_3d_request = true;
continue;
}
if(key == "interleaved_3d") {
display_data.interleaved_3d = std::stoi(value);
continue;
}
if(key == "request_low_bw_format") {
capture_status->request_low_bw_format = std::stoi(value);
continue;
}
if(key == "last_connected_ds") {
display_data.last_connected_ds = std::stoi(value);
continue;
}
if(key == "is_screen_capture_type") {
capture_status->capture_type = static_cast<CaptureScreensType>(std::stoi(value) % CaptureScreensType::CAPTURE_SCREENS_ENUM_END);
continue;
}
if(key == "is_speed_capture") {
capture_status->capture_speed = static_cast<CaptureSpeedsType>(std::stoi(value) % CaptureSpeedsType::CAPTURE_SPEEDS_ENUM_END);
continue;
}
if(key == "is_battery_percentage") {
capture_status->battery_percentage = std::stoi(value);
// Even though 1 is allowed, it spam-resets the Hardware...
// So don't allow it as the initial value!
if(capture_status->battery_percentage <= 5)
capture_status->battery_percentage = 5;
if(capture_status->battery_percentage > 100)
capture_status->battery_percentage = 100;
continue;
}
if(key == "is_ac_adapter_connected") {
capture_status->ac_adapter_connected = std::stoi(value);
continue;
}
if(key == "optimize_o3ds_scan_for") {
capture_status->devices_allowed_scan[CC_OPTIMIZE_O3DS] = std::stoi(value);
continue;
}
if(key == "nisetro_ds_scan_for") {
capture_status->devices_allowed_scan[CC_NISETRO_DS] = std::stoi(value);
continue;
}
if(audio_data->load_audio_data(key, value))
continue;
}
if(!loaded_3d_request)
set_3d_enabled(capture_status, false);
@ -223,6 +238,9 @@ static void defaults_reload(FrontendData *frontend_data, AudioData* audio_data,
capture_status->capture_speed = CAPTURE_SPEEDS_FULL;
capture_status->battery_percentage = 100;
capture_status->ac_adapter_connected = true;
capture_status->request_low_bw_format = true;
for(int i = 0; i < CC_POSSIBLE_DEVICES_END; i++)
capture_status->devices_allowed_scan[i] = true;
reset_screen_info(frontend_data->top_screen->m_info);
reset_screen_info(frontend_data->bot_screen->m_info);
reset_screen_info(frontend_data->joint_screen->m_info);
@ -305,11 +323,14 @@ static bool save(const std::string path, const std::string name, const std::stri
file << save_screen_info("top_", top_info);
file << "requested_3d=" << capture_status->requested_3d << std::endl;
file << "interleaved_3d=" << display_data.interleaved_3d << std::endl;
file << "request_low_bw_format=" << capture_status->request_low_bw_format << std::endl;
file << "last_connected_ds=" << display_data.last_connected_ds << std::endl;
file << "is_screen_capture_type=" << capture_status->capture_type << std::endl;
file << "is_speed_capture=" << capture_status->capture_speed << std::endl;
file << "is_battery_percentage=" << capture_status->battery_percentage << std::endl;
file << "is_ac_adapter_connected=" << capture_status->ac_adapter_connected << std::endl;
file << "optimize_o3ds_scan_for=" << capture_status->devices_allowed_scan[CC_OPTIMIZE_O3DS] << std::endl;
file << "nisetro_ds_scan_for=" << capture_status->devices_allowed_scan[CC_NISETRO_DS] << std::endl;
file << audio_data->save_audio_data();
file.close();

View File

@ -85,23 +85,27 @@ bool connect(bool print_failed, CaptureData* capture_data, FrontendData* fronten
// Device Listing
std::vector<CaptureDevice> devices_list;
std::vector<no_access_recap_data> no_access_list;
bool devices_allowed_scan[CC_POSSIBLE_DEVICES_END];
for(int i = 0; i < CC_POSSIBLE_DEVICES_END; i++)
devices_allowed_scan[i] = capture_data->status.devices_allowed_scan[i];
#ifdef USE_CYNI_USB
list_devices_cyni_device(devices_list, no_access_list);
list_devices_cyni_device(devices_list, no_access_list, devices_allowed_scan);
#endif
#ifdef USE_CYPRESS_OPTIMIZE
list_devices_cyop_device(devices_list, no_access_list);
list_devices_cyop_device(devices_list, no_access_list, devices_allowed_scan);
#endif
#ifdef USE_FTD3
list_devices_ftd3(devices_list, no_access_list);
list_devices_ftd3(devices_list, no_access_list, devices_allowed_scan);
#endif
#ifdef USE_FTD2
list_devices_ftd2_shared(devices_list, no_access_list);
list_devices_ftd2_shared(devices_list, no_access_list, devices_allowed_scan);
#endif
#ifdef USE_DS_3DS_USB
list_devices_usb_ds_3ds(devices_list, no_access_list);
list_devices_usb_ds_3ds(devices_list, no_access_list, devices_allowed_scan);
#endif
#ifdef USE_IS_DEVICES_USB
list_devices_is_device(devices_list, no_access_list);
list_devices_is_device(devices_list, no_access_list, devices_allowed_scan);
#endif
if(devices_list.size() <= 0) {