diff --git a/include/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared_general.hpp b/include/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared_general.hpp index 1e7e91a..7ffb8b6 100644 --- a/include/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared_general.hpp +++ b/include/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared_general.hpp @@ -7,7 +7,7 @@ uint64_t ftd3_get_capture_size(CaptureData* capture_data); std::string ftd3_get_serial(std::string serial_string, int &curr_serial_extra_id); -void ftd3_insert_device(std::vector &devices_list, std::string serial_string, int &curr_serial_extra_id, bool is_driver); +void ftd3_insert_device(std::vector &devices_list, std::string serial_string, int &curr_serial_extra_id, uint32_t usb_speed, bool is_driver); void data_output_update(int inner_index, size_t read_data, CaptureData* capture_data, std::chrono::time_point &base_time); #endif diff --git a/include/capture_structs.hpp b/include/capture_structs.hpp index a08bc8e..ecac5a1 100755 --- a/include/capture_structs.hpp +++ b/include/capture_structs.hpp @@ -169,12 +169,13 @@ union CaptureReceived { }; struct CaptureDevice { - CaptureDevice(std::string serial_number, std::string name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(""), video_data_type(video_data_type), firmware_id(0), is_rgb_888(false), long_name(name) {} - CaptureDevice(std::string serial_number, std::string name, std::string long_name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(""), video_data_type(video_data_type), firmware_id(0), is_rgb_888(false), long_name(long_name) {} - CaptureDevice(std::string serial_number, std::string name, std::string long_name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type, int firmware_id, bool is_rgb_888) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(""), video_data_type(video_data_type), firmware_id(firmware_id), is_rgb_888(is_rgb_888), long_name(name) {} - CaptureDevice(std::string serial_number, std::string name, std::string long_name, std::string path, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type, int firmware_id, bool is_rgb_888) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(path), video_data_type(video_data_type), firmware_id(firmware_id), is_rgb_888(is_rgb_888), long_name(long_name) {} - CaptureDevice(std::string serial_number, std::string name, std::string long_name, std::string path, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(path), video_data_type(video_data_type), firmware_id(0), is_rgb_888(false), long_name(long_name) {} - CaptureDevice(): serial_number(""), name(""), cc_type(CAPTURE_CONN_USB), descriptor(NULL), is_3ds(false), has_3d(false), has_audio(false), width(0), height(0), max_samples_in(0), base_rotation(0), top_screen_x(0), top_screen_y(0), bot_screen_x(0), bot_screen_y(0), path(""), firmware_id(0), video_data_type(VIDEO_DATA_RGB), is_rgb_888(false), long_name("") {} + CaptureDevice(std::string serial_number, std::string name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(""), video_data_type(video_data_type), firmware_id(0), is_rgb_888(false), long_name(name), usb_speed(0x200) {} + CaptureDevice(std::string serial_number, std::string name, std::string long_name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(""), video_data_type(video_data_type), firmware_id(0), is_rgb_888(false), long_name(long_name), usb_speed(0x200) {} + CaptureDevice(std::string serial_number, std::string name, std::string long_name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type, uint32_t usb_speed) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(""), video_data_type(video_data_type), firmware_id(0), is_rgb_888(false), long_name(long_name), usb_speed(usb_speed) {} + CaptureDevice(std::string serial_number, std::string name, std::string long_name, std::string path, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type, int firmware_id, bool is_rgb_888) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(path), video_data_type(video_data_type), firmware_id(firmware_id), is_rgb_888(is_rgb_888), long_name(long_name), usb_speed(0x200) {} + CaptureDevice(std::string serial_number, std::string name, std::string long_name, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type, int firmware_id, bool is_rgb_888) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(""), video_data_type(video_data_type), firmware_id(firmware_id), is_rgb_888(is_rgb_888), long_name(long_name), usb_speed(0x200) {} + CaptureDevice(std::string serial_number, std::string name, std::string long_name, std::string path, CaptureConnectionType cc_type, const void* descriptor, bool is_3ds, bool has_3d, bool has_audio, int width, int height, int max_samples_in, int base_rotation, int top_screen_x, int top_screen_y, int bot_screen_x, int bot_screen_y, InputVideoDataType video_data_type) : serial_number(serial_number), name(name), cc_type(cc_type), descriptor(descriptor), is_3ds(is_3ds), has_3d(has_3d), has_audio(has_audio), width(width), height(height), max_samples_in(max_samples_in), base_rotation(base_rotation), top_screen_x(top_screen_x), top_screen_y(top_screen_y), bot_screen_x(bot_screen_x), bot_screen_y(bot_screen_y), path(path), video_data_type(video_data_type), firmware_id(0), is_rgb_888(false), long_name(long_name), usb_speed(0x200) {} + CaptureDevice(): serial_number(""), name(""), cc_type(CAPTURE_CONN_USB), descriptor(NULL), is_3ds(false), has_3d(false), has_audio(false), width(0), height(0), max_samples_in(0), base_rotation(0), top_screen_x(0), top_screen_y(0), bot_screen_x(0), bot_screen_y(0), path(""), firmware_id(0), video_data_type(VIDEO_DATA_RGB), is_rgb_888(false), long_name(""), usb_speed(0) {} std::string serial_number; std::string name; @@ -195,6 +196,7 @@ struct CaptureDevice { int bot_screen_x; int bot_screen_y; int firmware_id; + uint32_t usb_speed; bool is_rgb_888; }; diff --git a/include/devicecapture.hpp b/include/devicecapture.hpp index eaaccfa..513b9a4 100755 --- a/include/devicecapture.hpp +++ b/include/devicecapture.hpp @@ -24,4 +24,5 @@ void capture_error_print(bool print_failed, CaptureData* capture_data, std::stri uint64_t get_audio_n_samples(CaptureData* capture_data, uint64_t read); uint64_t get_video_in_size(CaptureData* capture_data); std::string get_name_of_device(CaptureStatus* capture_status, bool use_long = false); +int get_usb_speed_of_device(CaptureStatus* capture_status); #endif diff --git a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_comms.cpp b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_comms.cpp index 204b13d..dde344f 100644 --- a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_comms.cpp +++ b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_driver_comms.cpp @@ -95,7 +95,7 @@ void ftd3_driver_list_devices(std::vector &devices_list, int *cur ftStatus = FT_Create(SerialNumber, FT_OPEN_BY_SERIAL_NUMBER, &ftHandle); if(FT_FAILED(ftStatus)) break; - ftd3_insert_device(devices_list, std::string(SerialNumber), *curr_serial_extra_id_ftd3, true); + ftd3_insert_device(devices_list, std::string(SerialNumber), *curr_serial_extra_id_ftd3, (Flags & FT_FLAGS_SUPERSPEED) ? 0x300 : 0x200, true); FT_Close(ftHandle); break; } diff --git a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_comms.cpp b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_comms.cpp index 01e52d6..cedfb6d 100644 --- a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_comms.cpp +++ b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_libusb_comms.cpp @@ -225,8 +225,12 @@ static int ftd3_libusb_insert_device(std::vector &devices_list, l bool claimed_cmd = false; bool claimed_bulk = false; bool result_setup = ftd3_libusb_setup_connection(handle, &claimed_cmd, &claimed_bulk); + uint32_t usb_speed = 0x200; + libusb_speed read_speed = (libusb_speed)libusb_get_device_speed(usb_device); + if((read_speed >= LIBUSB_SPEED_SUPER) || ((read_speed == LIBUSB_SPEED_UNKNOWN) && (usb_descriptor->bcdUSB >= 0x300))) + usb_speed = 0x300; if(result_setup) - ftd3_insert_device(devices_list, (std::string)(serial), curr_serial_extra_id, false); + ftd3_insert_device(devices_list, (std::string)(serial), curr_serial_extra_id, usb_speed, false); if(claimed_cmd) libusb_release_interface(handle, FTD3_COMMAND_INTERFACE); if(claimed_bulk) diff --git a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared.cpp b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared.cpp index 1ac4cde..89cb04a 100644 --- a/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared.cpp +++ b/source/CaptureDeviceSpecific/3DSCapture_FTD3/3dscapture_ftd3_shared.cpp @@ -18,14 +18,14 @@ std::string ftd3_get_serial(std::string serial_string, int &curr_serial_extra_id return std::to_string(curr_serial_extra_id++); } -void ftd3_insert_device(std::vector &devices_list, std::string serial_string, int &curr_serial_extra_id, bool is_driver) { +void ftd3_insert_device(std::vector &devices_list, std::string serial_string, int &curr_serial_extra_id, uint32_t usb_speed, bool is_driver) { std::string short_name = "N3DSXL"; std::string long_name = short_name; if(is_driver) long_name += ".d"; else long_name += ".l"; - 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, N3DSXL_SAMPLES_IN, 90, 0, 0, TOP_WIDTH_3DS, 0, VIDEO_DATA_RGB); + 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, N3DSXL_SAMPLES_IN, 90, 0, 0, TOP_WIDTH_3DS, 0, VIDEO_DATA_RGB, usb_speed); } void list_devices_ftd3(std::vector &devices_list, std::vector &no_access_list) { diff --git a/source/Menus/StatusMenu.cpp b/source/Menus/StatusMenu.cpp index b1f5dec..c0a4b06 100755 --- a/source/Menus/StatusMenu.cpp +++ b/source/Menus/StatusMenu.cpp @@ -10,6 +10,7 @@ enum StatusMenuID { STATUS_MENU_FPS_POLL, STATUS_MENU_FPS_DRAW, STATUS_MENU_CONNECTION, + STATUS_MENU_USB_CONNECTION, }; struct StatusMenuOptionInfo { @@ -42,9 +43,14 @@ static const StatusMenuOptionInfo status_curr_device_option = { .base_name = "", .is_inc = false, .id = STATUS_MENU_CONNECTION}; +static const StatusMenuOptionInfo status_usb_connection_option = { +.base_name = "", .is_inc = false, +.id = STATUS_MENU_USB_CONNECTION}; + static const StatusMenuOptionInfo* pollable_options[] = { &status_name_version_option, &status_curr_device_option, +&status_usb_connection_option, &status_url_option, &status_fps_in_option, &status_fps_poll_option, @@ -64,7 +70,7 @@ StatusMenu::~StatusMenu() { } void StatusMenu::class_setup() { - this->num_options_per_screen = 5; + this->num_options_per_screen = 6; this->min_elements_text_scaling_factor = num_options_per_screen + 2; this->width_factor_menu = 16; this->width_divisor_menu = 9; @@ -119,6 +125,12 @@ bool StatusMenu::is_option_selectable(int index, int action) { return false; } +static std::string get_usb_speed_text(int usb_speed) { + if(usb_speed <= 0) + return ""; + return "Connection: USB " + std::to_string(usb_speed); +} + void StatusMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_y, double in_fps, double poll_fps, double draw_fps, CaptureStatus* capture_status) { if(!this->do_update) { auto curr_time = std::chrono::high_resolution_clock::now(); @@ -145,6 +157,9 @@ void StatusMenu::prepare(float menu_scaling_factor, int view_size_x, int view_si case STATUS_MENU_CONNECTION: this->labels[index]->setText(get_name_of_device(capture_status, true)); break; + case STATUS_MENU_USB_CONNECTION: + this->labels[index]->setText(get_usb_speed_text(get_usb_speed_of_device(capture_status))); + break; case STATUS_MENU_FPS_IN: this->labels[index + INC_ACTION]->setText(get_float_str_decimals(in_fps, 2)); break; diff --git a/source/devicecapture.cpp b/source/devicecapture.cpp index ba3bff4..dab1a88 100755 --- a/source/devicecapture.cpp +++ b/source/devicecapture.cpp @@ -261,6 +261,12 @@ std::string get_name_of_device(CaptureStatus* capture_status, bool use_long) { return capture_status->device.long_name + " - " + capture_status->device.serial_number; } +int get_usb_speed_of_device(CaptureStatus* capture_status) { + if(!capture_status->connected) + return 0; + return capture_status->device.usb_speed >> 8; +} + void capture_init() { #ifdef USE_DS_3DS_USB usb_ds_3ds_init();