mirror of
https://github.com/Lorenzooone/cc3dsfs.git
synced 2026-08-16 21:57:36 -05:00
Refactor IS Nitro to IS Devices
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
#ifndef __USB_IS_DEVICE_ACQUISITION_HPP
|
||||
#define __USB_IS_DEVICE_ACQUISITION_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "utils.hpp"
|
||||
#include "hw_defs.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
#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);
|
||||
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);
|
||||
uint64_t usb_is_device_get_video_in_size(CaptureData* capture_data);
|
||||
uint64_t usb_is_device_get_video_in_size(CaptureStatus* capture_status);
|
||||
bool is_device_is_capture(CaptureDevice* device);
|
||||
bool is_device_is_nitro(CaptureDevice* device);
|
||||
void usb_is_device_init();
|
||||
void usb_is_device_close();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef __USB_IS_DEVICE_ACQUISITION_GENERAL_HPP
|
||||
#define __USB_IS_DEVICE_ACQUISITION_GENERAL_HPP
|
||||
|
||||
#include "usb_is_device_communications.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
#include "display_structs.hpp"
|
||||
|
||||
#define NUM_CAPTURE_RECEIVED_DATA_BUFFERS 4
|
||||
|
||||
struct ISDeviceCaptureReceivedData {
|
||||
volatile bool in_use;
|
||||
uint32_t index;
|
||||
CaptureReceived buffer;
|
||||
SharedConsumerMutex* is_buffer_free_shared_mutex;
|
||||
int* status;
|
||||
uint32_t* last_index;
|
||||
CaptureData* capture_data;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock>* clock_start;
|
||||
CaptureScreensType curr_capture_type;
|
||||
isd_async_callback_data cb_data;
|
||||
};
|
||||
|
||||
int set_acquisition_mode(is_device_device_handlers* handlers, CaptureScreensType capture_type, CaptureSpeedsType capture_speed, const is_device_usb_device* usb_device_desc);
|
||||
int EndAcquisition(CaptureData* capture_data, ISDeviceCaptureReceivedData* is_device_capture_recv_data, bool do_drain_frames, int start_frames, CaptureScreensType capture_type);
|
||||
int EndAcquisition(const is_device_usb_device* usb_device_desc, is_device_device_handlers* handlers, bool do_drain_frames, int start_frames, CaptureScreensType capture_type);
|
||||
int is_device_read_frame_and_output(CaptureData* capture_data, CaptureReceived* capture_buf, CaptureScreensType curr_capture_type, std::chrono::time_point<std::chrono::high_resolution_clock> &clock_start);
|
||||
void is_device_read_frame_request(CaptureData* capture_data, ISDeviceCaptureReceivedData* is_device_capture_recv_data, CaptureScreensType curr_capture_type, uint32_t index);
|
||||
uint64_t usb_is_device_get_video_in_size(CaptureScreensType capture_type, is_device_type device_type);
|
||||
|
||||
ISDeviceCaptureReceivedData* is_device_get_free_buffer(CaptureData* capture_data, ISDeviceCaptureReceivedData* is_device_capture_recv_data);
|
||||
bool is_device_are_buffers_all_free(ISDeviceCaptureReceivedData* is_device_capture_recv_data);
|
||||
int is_device_get_num_free_buffers(ISDeviceCaptureReceivedData* is_device_capture_recv_data);
|
||||
void wait_all_is_device_transfers_done(CaptureData* capture_data, ISDeviceCaptureReceivedData* is_device_capture_recv_data);
|
||||
void wait_all_is_device_buffers_free(CaptureData* capture_data, ISDeviceCaptureReceivedData* is_device_capture_recv_data);
|
||||
void wait_one_is_device_buffer_free(CaptureData* capture_data, ISDeviceCaptureReceivedData* is_device_capture_recv_data);
|
||||
int get_is_device_status(ISDeviceCaptureReceivedData* is_device_capture_recv_data);
|
||||
void reset_is_device_status(ISDeviceCaptureReceivedData* is_device_capture_recv_data);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,102 @@
|
||||
#ifndef __USB_IS_DEVICE_COMMUNICATIONS_HPP
|
||||
#define __USB_IS_DEVICE_COMMUNICATIONS_HPP
|
||||
|
||||
#include <libusb.h>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include "utils.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
|
||||
#define IS_DEVICE_REAL_SERIAL_NUMBER_SIZE 10
|
||||
|
||||
enum is_device_type {
|
||||
IS_NITRO_EMULATOR_DEVICE,
|
||||
IS_NITRO_CAPTURE_DEVICE,
|
||||
};
|
||||
|
||||
enum is_device_forward_config_values_colors {
|
||||
IS_DEVICE_FORWARD_CONFIG_COLOR_RGB24 = 0,
|
||||
};
|
||||
|
||||
enum is_device_forward_config_values_screens {
|
||||
IS_DEVICE_FORWARD_CONFIG_MODE_BOTH = 0,
|
||||
IS_DEVICE_FORWARD_CONFIG_MODE_TOP = 1,
|
||||
IS_DEVICE_FORWARD_CONFIG_MODE_BOTTOM = 2,
|
||||
};
|
||||
|
||||
enum is_device_forward_config_values_rate {
|
||||
IS_DEVICE_FORWARD_CONFIG_RATE_FULL = 0,
|
||||
IS_DEVICE_FORWARD_CONFIG_RATE_HALF = 1,
|
||||
IS_DEVICE_FORWARD_CONFIG_RATE_THIRD = 2,
|
||||
IS_DEVICE_FORWARD_CONFIG_RATE_QUARTER = 3,
|
||||
};
|
||||
|
||||
typedef void (*isd_async_callback_function)(void* user_data, int transfer_length, int transfer_status);
|
||||
|
||||
struct isd_async_callback_data {
|
||||
isd_async_callback_function function;
|
||||
void* actual_user_data;
|
||||
void* transfer_data;
|
||||
void* handle;
|
||||
void* base_transfer_data;
|
||||
std::mutex transfer_data_access;
|
||||
SharedConsumerMutex* is_transfer_done_mutex;
|
||||
SharedConsumerMutex* is_transfer_data_ready_mutex;
|
||||
size_t requested_length;
|
||||
uint8_t* buffer;
|
||||
size_t actual_length;
|
||||
int status_value;
|
||||
bool is_data_ready;
|
||||
int internal_index;
|
||||
};
|
||||
|
||||
struct is_device_usb_device {
|
||||
std::string name;
|
||||
std::string long_name;
|
||||
int vid;
|
||||
int pid;
|
||||
int default_config;
|
||||
int default_interface;
|
||||
int bulk_timeout;
|
||||
int ep2_in;
|
||||
int ep1_out;
|
||||
int product_id;
|
||||
int manufacturer_id;
|
||||
is_device_type device_type;
|
||||
InputVideoDataType video_data_type;
|
||||
};
|
||||
|
||||
struct is_device_device_handlers {
|
||||
libusb_device_handle* usb_handle;
|
||||
void* read_handle;
|
||||
void* write_handle;
|
||||
void* mutex;
|
||||
};
|
||||
|
||||
int GetNumISDeviceDesc(void);
|
||||
const is_device_usb_device* GetISDeviceDesc(int index);
|
||||
int DisableLca2(is_device_device_handlers* handlers, const is_device_usb_device* device_desc);
|
||||
int StartUsbCaptureDma(is_device_device_handlers* handlers, const is_device_usb_device* device_desc);
|
||||
int StopUsbCaptureDma(is_device_device_handlers* handlers, const is_device_usb_device* device_desc);
|
||||
int SetForwardFrameCount(is_device_device_handlers* handlers, uint16_t count, const is_device_usb_device* device_desc);
|
||||
int SetForwardFramePermanent(is_device_device_handlers* handlers, const is_device_usb_device* device_desc);
|
||||
int GetFrameCounter(is_device_device_handlers* handlers, uint16_t* out, const is_device_usb_device* device_desc);
|
||||
int GetDeviceSerial(is_device_device_handlers* handlers, uint8_t* buf, const is_device_usb_device* device_desc);
|
||||
int UpdateFrameForwardConfig(is_device_device_handlers* handlers, is_device_forward_config_values_colors colors, is_device_forward_config_values_screens screens, is_device_forward_config_values_rate rate, const is_device_usb_device* device_desc);
|
||||
int UpdateFrameForwardEnable(is_device_device_handlers* handlers, bool enable, bool restart, const is_device_usb_device* device_desc);
|
||||
int ReadLidState(is_device_device_handlers* handlers, bool* out, const is_device_usb_device* device_desc);
|
||||
int ReadDebugButtonState(is_device_device_handlers* handlers, bool* out, const is_device_usb_device* device_desc);
|
||||
int ReadPowerButtonState(is_device_device_handlers* handlers, bool* out, const is_device_usb_device* device_desc);
|
||||
int ResetCPUStart(is_device_device_handlers* handlers, const is_device_usb_device* device_desc);
|
||||
int ResetCPUEnd(is_device_device_handlers* handlers, const is_device_usb_device* device_desc);
|
||||
int ResetFullHardware(is_device_device_handlers* handlers, const is_device_usb_device* device_desc);
|
||||
int ReadFrame(is_device_device_handlers* handlers, uint8_t* buf, int length, const is_device_usb_device* device_desc);
|
||||
void ReadFrameAsync(is_device_device_handlers* handlers, uint8_t* buf, int length, const is_device_usb_device* device_desc, isd_async_callback_data* cb_data);
|
||||
void CloseAsyncRead(is_device_device_handlers* handlers, isd_async_callback_data* cb_data);
|
||||
int ResetUSBDevice(is_device_device_handlers* handlers);
|
||||
|
||||
void SetupISDeviceAsyncThread(is_device_device_handlers* handlers, void* user_data, std::thread* thread_ptr, bool* keep_going, ConsumerMutex* is_data_ready);
|
||||
void EndISDeviceAsyncThread(is_device_device_handlers* handlers, void* user_data, std::thread* thread_ptr, bool* keep_going, ConsumerMutex* is_data_ready);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef __USB_IS_DEVICE_IS_DRIVER_HPP
|
||||
#define __USB_IS_DEVICE_IS_DRIVER_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "capture_structs.hpp"
|
||||
#include "utils.hpp"
|
||||
#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);
|
||||
is_device_device_handlers* is_driver_serial_reconnection(CaptureDevice* device);
|
||||
void is_driver_end_connection(is_device_device_handlers* handlers);
|
||||
int is_driver_bulk_out(is_device_device_handlers* handlers, const is_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int is_driver_bulk_in(is_device_device_handlers* handlers, const is_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int is_drive_async_in_start(is_device_device_handlers* handlers, const is_device_usb_device* usb_device_desc, uint8_t* buf, int length, isd_async_callback_data* cb_data);
|
||||
void is_device_is_driver_cancel_callback(isd_async_callback_data* cb_data);
|
||||
int is_device_is_driver_reset_device(is_device_device_handlers* handlers);
|
||||
|
||||
void is_device_is_driver_start_thread(std::thread* thread_ptr, bool* usb_thread_run, ISDeviceCaptureReceivedData* is_device_capture_recv_data, is_device_device_handlers* handlers, ConsumerMutex* AsyncMutexPtr);
|
||||
void is_device_is_driver_close_thread(std::thread* thread_ptr, bool* usb_thread_run, ISDeviceCaptureReceivedData* is_device_capture_recv_data);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef __USB_IS_DEVICE_LIBUSB_HPP
|
||||
#define __USB_IS_DEVICE_LIBUSB_HPP
|
||||
|
||||
#include <vector>
|
||||
#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);
|
||||
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);
|
||||
int is_device_libusb_bulk_in(is_device_device_handlers* handlers, const is_device_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
void is_device_libusb_async_in_start(is_device_device_handlers* handlers, const is_device_usb_device* usb_device_desc, uint8_t* buf, int length, isd_async_callback_data* cb_data);
|
||||
void is_device_libusb_cancell_callback(isd_async_callback_data* cb_data);
|
||||
int is_device_libusb_reset_device(is_device_device_handlers* handlers);
|
||||
|
||||
void is_device_libusb_start_thread(std::thread* thread_ptr, bool* usb_thread_run);
|
||||
void is_device_libusb_close_thread(std::thread* thread_ptr, bool* usb_thread_run);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef __USB_IS_DEVICE_SETUP_GENERAL_HPP
|
||||
#define __USB_IS_DEVICE_SETUP_GENERAL_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "capture_structs.hpp"
|
||||
#include "usb_is_device_communications.hpp"
|
||||
|
||||
std::string get_serial(const is_device_usb_device* usb_device_desc, is_device_device_handlers* handlers, int& curr_serial_extra_id);
|
||||
void is_device_insert_device(std::vector<CaptureDevice>& devices_list, is_device_device_handlers* handlers, const is_device_usb_device* usb_device_desc, int& curr_serial_extra_id_is_device, std::string path);
|
||||
void is_device_insert_device(std::vector<CaptureDevice>& devices_list, is_device_device_handlers* handlers, const is_device_usb_device* usb_device_desc, int& curr_serial_extra_id_is_device);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef __USB_IS_NITRO_ACQUISITION_CAPTURE_HPP
|
||||
#define __USB_IS_NITRO_ACQUISITION_CAPTURE_HPP
|
||||
|
||||
#include "usb_is_device_communications.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
|
||||
int initial_cleanup_capture(const is_device_usb_device* usb_device_desc, is_device_device_handlers* handlers);
|
||||
int EndAcquisitionCapture(CaptureData* capture_data, ISDeviceCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
int EndAcquisitionCapture(const is_device_usb_device* usb_device_desc, is_device_device_handlers* handlers);
|
||||
void is_nitro_acquisition_capture_main_loop(CaptureData* capture_data, ISDeviceCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef __USB_IS_NITRO_ACQUISITION_EMULATOR_HPP
|
||||
#define __USB_IS_NITRO_ACQUISITION_EMULATOR_HPP
|
||||
|
||||
#include "usb_is_device_communications.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
|
||||
int initial_cleanup_emulator(const is_device_usb_device* usb_device_desc, is_device_device_handlers* handlers);
|
||||
int EndAcquisitionEmulator(CaptureData* capture_data, ISDeviceCaptureReceivedData* is_nitro_capture_recv_data, bool do_drain_frames, int start_frames, CaptureScreensType capture_type);
|
||||
int EndAcquisitionEmulator(const is_device_usb_device* usb_device_desc, is_device_device_handlers* handlers, bool do_drain_frames, int start_frames, CaptureScreensType capture_type);
|
||||
void is_nitro_acquisition_emulator_main_loop(CaptureData* capture_data, ISDeviceCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
|
||||
#endif
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef __USB_IS_NITRO_ACQUISITION_HPP
|
||||
#define __USB_IS_NITRO_ACQUISITION_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "utils.hpp"
|
||||
#include "hw_defs.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
#include "display_structs.hpp"
|
||||
#include "devicecapture.hpp"
|
||||
|
||||
void list_devices_is_nitro(std::vector<CaptureDevice> &devices_list, std::vector<no_access_recap_data> &no_access_list);
|
||||
bool is_nitro_connect_usb(bool print_failed, CaptureData* capture_data, CaptureDevice* device);
|
||||
void is_nitro_acquisition_main_loop(CaptureData* capture_data);
|
||||
void usb_is_nitro_acquisition_cleanup(CaptureData* capture_data);
|
||||
uint64_t usb_is_nitro_get_video_in_size(CaptureData* capture_data);
|
||||
uint64_t usb_is_nitro_get_video_in_size(CaptureScreensType capture_type);
|
||||
bool is_nitro_is_capture(CaptureDevice* device);
|
||||
void usb_is_nitro_init();
|
||||
void usb_is_nitro_close();
|
||||
|
||||
#endif
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef __USB_IS_NITRO_ACQUISITION_CAPTURE_HPP
|
||||
#define __USB_IS_NITRO_ACQUISITION_CAPTURE_HPP
|
||||
|
||||
#include "usb_is_nitro_communications.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
|
||||
int initial_cleanup_capture(const is_nitro_usb_device* usb_device_desc, is_nitro_device_handlers* handlers);
|
||||
int EndAcquisitionCapture(CaptureData* capture_data, ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
int EndAcquisitionCapture(const is_nitro_usb_device* usb_device_desc, is_nitro_device_handlers* handlers);
|
||||
void is_nitro_acquisition_capture_main_loop(CaptureData* capture_data, ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
|
||||
#endif
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef __USB_IS_NITRO_ACQUISITION_EMULATOR_HPP
|
||||
#define __USB_IS_NITRO_ACQUISITION_EMULATOR_HPP
|
||||
|
||||
#include "usb_is_nitro_communications.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
|
||||
int initial_cleanup_emulator(const is_nitro_usb_device* usb_device_desc, is_nitro_device_handlers* handlers);
|
||||
int EndAcquisitionEmulator(CaptureData* capture_data, ISNitroCaptureReceivedData* is_nitro_capture_recv_data, bool do_drain_frames, int start_frames, CaptureScreensType capture_type);
|
||||
int EndAcquisitionEmulator(const is_nitro_usb_device* usb_device_desc, is_nitro_device_handlers* handlers, bool do_drain_frames, int start_frames, CaptureScreensType capture_type);
|
||||
void is_nitro_acquisition_emulator_main_loop(CaptureData* capture_data, ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
|
||||
#endif
|
||||
@@ -1,39 +0,0 @@
|
||||
#ifndef __USB_IS_NITRO_ACQUISITION_GENERAL_HPP
|
||||
#define __USB_IS_NITRO_ACQUISITION_GENERAL_HPP
|
||||
|
||||
#include "usb_is_nitro_communications.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "capture_structs.hpp"
|
||||
#include "display_structs.hpp"
|
||||
|
||||
#define NUM_CAPTURE_RECEIVED_DATA_BUFFERS 4
|
||||
|
||||
struct ISNitroCaptureReceivedData {
|
||||
volatile bool in_use;
|
||||
uint32_t index;
|
||||
CaptureReceived buffer;
|
||||
SharedConsumerMutex* is_buffer_free_shared_mutex;
|
||||
int* status;
|
||||
uint32_t* last_index;
|
||||
CaptureData* capture_data;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock>* clock_start;
|
||||
CaptureScreensType curr_capture_type;
|
||||
isn_async_callback_data cb_data;
|
||||
};
|
||||
|
||||
int set_acquisition_mode(is_nitro_device_handlers* handlers, CaptureScreensType capture_type, CaptureSpeedsType capture_speed, const is_nitro_usb_device* usb_device_desc);
|
||||
int EndAcquisition(CaptureData* capture_data, ISNitroCaptureReceivedData* is_nitro_capture_recv_data, bool do_drain_frames, int start_frames, CaptureScreensType capture_type);
|
||||
int EndAcquisition(const is_nitro_usb_device* usb_device_desc, is_nitro_device_handlers* handlers, bool do_drain_frames, int start_frames, CaptureScreensType capture_type);
|
||||
int is_nitro_read_frame_and_output(CaptureData* capture_data, CaptureReceived* capture_buf, CaptureScreensType curr_capture_type, std::chrono::time_point<std::chrono::high_resolution_clock> &clock_start);
|
||||
void is_nitro_read_frame_request(CaptureData* capture_data, ISNitroCaptureReceivedData* is_nitro_capture_recv_data, CaptureScreensType curr_capture_type, uint32_t index);
|
||||
|
||||
ISNitroCaptureReceivedData* is_nitro_get_free_buffer(CaptureData* capture_data, ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
bool is_nitro_are_buffers_all_free(ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
int is_nitro_get_num_free_buffers(ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
void wait_all_is_nitro_transfers_done(CaptureData* capture_data, ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
void wait_all_is_nitro_buffers_free(CaptureData* capture_data, ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
void wait_one_is_nitro_buffer_free(CaptureData* capture_data, ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
int get_is_nitro_status(ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
void reset_is_nitro_status(ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
|
||||
#endif
|
||||
@@ -1,94 +0,0 @@
|
||||
#ifndef __USB_IS_NITRO_COMMUNICATIONS_HPP
|
||||
#define __USB_IS_NITRO_COMMUNICATIONS_HPP
|
||||
|
||||
#include <libusb.h>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include "utils.hpp"
|
||||
|
||||
#define IS_NITRO_REAL_SERIAL_NUMBER_SIZE 10
|
||||
|
||||
enum is_nitro_forward_config_values_colors {
|
||||
IS_NITRO_FORWARD_CONFIG_COLOR_RGB24 = 0,
|
||||
};
|
||||
|
||||
enum is_nitro_forward_config_values_screens {
|
||||
IS_NITRO_FORWARD_CONFIG_MODE_BOTH = 0,
|
||||
IS_NITRO_FORWARD_CONFIG_MODE_TOP = 1,
|
||||
IS_NITRO_FORWARD_CONFIG_MODE_BOTTOM = 2,
|
||||
};
|
||||
|
||||
enum is_nitro_forward_config_values_rate {
|
||||
IS_NITRO_FORWARD_CONFIG_RATE_FULL = 0,
|
||||
IS_NITRO_FORWARD_CONFIG_RATE_HALF = 1,
|
||||
IS_NITRO_FORWARD_CONFIG_RATE_THIRD = 2,
|
||||
IS_NITRO_FORWARD_CONFIG_RATE_QUARTER = 3,
|
||||
};
|
||||
|
||||
typedef void (*isn_async_callback_function)(void* user_data, int transfer_length, int transfer_status);
|
||||
|
||||
struct isn_async_callback_data {
|
||||
isn_async_callback_function function;
|
||||
void* actual_user_data;
|
||||
void* transfer_data;
|
||||
void* handle;
|
||||
void* base_transfer_data;
|
||||
std::mutex transfer_data_access;
|
||||
SharedConsumerMutex* is_transfer_done_mutex;
|
||||
SharedConsumerMutex* is_transfer_data_ready_mutex;
|
||||
size_t requested_length;
|
||||
uint8_t* buffer;
|
||||
size_t actual_length;
|
||||
int status_value;
|
||||
bool is_data_ready;
|
||||
int internal_index;
|
||||
};
|
||||
|
||||
struct is_nitro_usb_device {
|
||||
std::string name;
|
||||
std::string long_name;
|
||||
int vid;
|
||||
int pid;
|
||||
int default_config;
|
||||
int default_interface;
|
||||
int bulk_timeout;
|
||||
int ep2_in;
|
||||
int ep1_out;
|
||||
int product_id;
|
||||
int manufacturer_id;
|
||||
bool is_capture;
|
||||
};
|
||||
|
||||
struct is_nitro_device_handlers {
|
||||
libusb_device_handle* usb_handle;
|
||||
void* read_handle;
|
||||
void* write_handle;
|
||||
void* mutex;
|
||||
};
|
||||
|
||||
int GetNumISNitroDesc(void);
|
||||
const is_nitro_usb_device* GetISNitroDesc(int index);
|
||||
int DisableLca2(is_nitro_device_handlers* handlers, const is_nitro_usb_device* device_desc);
|
||||
int StartUsbCaptureDma(is_nitro_device_handlers* handlers, const is_nitro_usb_device* device_desc);
|
||||
int StopUsbCaptureDma(is_nitro_device_handlers* handlers, const is_nitro_usb_device* device_desc);
|
||||
int SetForwardFrameCount(is_nitro_device_handlers* handlers, uint16_t count, const is_nitro_usb_device* device_desc);
|
||||
int SetForwardFramePermanent(is_nitro_device_handlers* handlers, const is_nitro_usb_device* device_desc);
|
||||
int GetFrameCounter(is_nitro_device_handlers* handlers, uint16_t* out, const is_nitro_usb_device* device_desc);
|
||||
int GetDeviceSerial(is_nitro_device_handlers* handlers, uint8_t* buf, const is_nitro_usb_device* device_desc);
|
||||
int UpdateFrameForwardConfig(is_nitro_device_handlers* handlers, is_nitro_forward_config_values_colors colors, is_nitro_forward_config_values_screens screens, is_nitro_forward_config_values_rate rate, const is_nitro_usb_device* device_desc);
|
||||
int UpdateFrameForwardEnable(is_nitro_device_handlers* handlers, bool enable, bool restart, const is_nitro_usb_device* device_desc);
|
||||
int ReadLidState(is_nitro_device_handlers* handlers, bool* out, const is_nitro_usb_device* device_desc);
|
||||
int ReadDebugButtonState(is_nitro_device_handlers* handlers, bool* out, const is_nitro_usb_device* device_desc);
|
||||
int ReadPowerButtonState(is_nitro_device_handlers* handlers, bool* out, const is_nitro_usb_device* device_desc);
|
||||
int ResetCPUStart(is_nitro_device_handlers* handlers, const is_nitro_usb_device* device_desc);
|
||||
int ResetCPUEnd(is_nitro_device_handlers* handlers, const is_nitro_usb_device* device_desc);
|
||||
int ResetFullHardware(is_nitro_device_handlers* handlers, const is_nitro_usb_device* device_desc);
|
||||
int ReadFrame(is_nitro_device_handlers* handlers, uint8_t* buf, int length, const is_nitro_usb_device* device_desc);
|
||||
void ReadFrameAsync(is_nitro_device_handlers* handlers, uint8_t* buf, int length, const is_nitro_usb_device* device_desc, isn_async_callback_data* cb_data);
|
||||
void CloseAsyncRead(is_nitro_device_handlers* handlers, isn_async_callback_data* cb_data);
|
||||
|
||||
void SetupISNitroAsyncThread(is_nitro_device_handlers* handlers, void* user_data, std::thread* thread_ptr, bool* keep_going, ConsumerMutex* is_data_ready);
|
||||
void EndISNitroAsyncThread(is_nitro_device_handlers* handlers, void* user_data, std::thread* thread_ptr, bool* keep_going, ConsumerMutex* is_data_ready);
|
||||
|
||||
#endif
|
||||
@@ -1,21 +0,0 @@
|
||||
#ifndef __USB_IS_NITRO_IS_DRIVER_HPP
|
||||
#define __USB_IS_NITRO_IS_DRIVER_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "capture_structs.hpp"
|
||||
#include "utils.hpp"
|
||||
#include "usb_is_nitro_communications.hpp"
|
||||
#include "usb_is_nitro_acquisition_general.hpp"
|
||||
|
||||
void is_driver_list_devices(std::vector<CaptureDevice>& devices_list, bool* not_supported_elems, int* curr_serial_extra_id_is_nitro, const size_t num_is_nitro_desc);
|
||||
is_nitro_device_handlers* is_driver_serial_reconnection(CaptureDevice* device);
|
||||
void is_driver_end_connection(is_nitro_device_handlers* handlers);
|
||||
int is_driver_bulk_out(is_nitro_device_handlers* handlers, const is_nitro_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int is_driver_bulk_in(is_nitro_device_handlers* handlers, const is_nitro_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int is_drive_async_in_start(is_nitro_device_handlers* handlers, const is_nitro_usb_device* usb_device_desc, uint8_t* buf, int length, isn_async_callback_data* cb_data);
|
||||
void is_nitro_is_driver_cancel_callback(isn_async_callback_data* cb_data);
|
||||
|
||||
void is_nitro_is_driver_start_thread(std::thread* thread_ptr, bool* usb_thread_run, ISNitroCaptureReceivedData* is_nitro_capture_recv_data, is_nitro_device_handlers* handlers, ConsumerMutex* AsyncMutexPtr);
|
||||
void is_nitro_is_driver_close_thread(std::thread* thread_ptr, bool* usb_thread_run, ISNitroCaptureReceivedData* is_nitro_capture_recv_data);
|
||||
|
||||
#endif
|
||||
@@ -1,19 +0,0 @@
|
||||
#ifndef __USB_IS_NITRO_LIBUSB_HPP
|
||||
#define __USB_IS_NITRO_LIBUSB_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "capture_structs.hpp"
|
||||
#include "usb_is_nitro_communications.hpp"
|
||||
|
||||
void is_nitro_libusb_list_devices(std::vector<CaptureDevice>& devices_list, bool* no_access_elems, bool* not_supported_elems, int* curr_serial_extra_id_is_nitro, const size_t num_is_nitro_desc);
|
||||
is_nitro_device_handlers* is_nitro_libusb_serial_reconnection(const is_nitro_usb_device* usb_device_desc, CaptureDevice* device, int& curr_serial_extra_id);
|
||||
void is_nitro_libusb_end_connection(is_nitro_device_handlers* handlers, const is_nitro_usb_device* device_desc, bool interface_claimed);
|
||||
int is_nitro_libusb_bulk_out(is_nitro_device_handlers* handlers, const is_nitro_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
int is_nitro_libusb_bulk_in(is_nitro_device_handlers* handlers, const is_nitro_usb_device* usb_device_desc, uint8_t* buf, int length, int* transferred);
|
||||
void is_nitro_libusb_async_in_start(is_nitro_device_handlers* handlers, const is_nitro_usb_device* usb_device_desc, uint8_t* buf, int length, isn_async_callback_data* cb_data);
|
||||
void is_nitro_libusb_cancell_callback(isn_async_callback_data* cb_data);
|
||||
|
||||
void is_nitro_libusb_start_thread(std::thread* thread_ptr, bool* usb_thread_run);
|
||||
void is_nitro_libusb_close_thread(std::thread* thread_ptr, bool* usb_thread_run);
|
||||
|
||||
#endif
|
||||
@@ -1,12 +0,0 @@
|
||||
#ifndef __USB_IS_NITRO_SETUP_GENERAL_HPP
|
||||
#define __USB_IS_NITRO_SETUP_GENERAL_HPP
|
||||
|
||||
#include <vector>
|
||||
#include "capture_structs.hpp"
|
||||
#include "usb_is_nitro_communications.hpp"
|
||||
|
||||
std::string get_serial(const is_nitro_usb_device* usb_device_desc, is_nitro_device_handlers* handlers, int& curr_serial_extra_id);
|
||||
void is_nitro_insert_device(std::vector<CaptureDevice>& devices_list, is_nitro_device_handlers* handlers, const is_nitro_usb_device* usb_device_desc, int& curr_serial_extra_id_is_nitro, std::string path);
|
||||
void is_nitro_insert_device(std::vector<CaptureDevice>& devices_list, is_nitro_device_handlers* handlers, const is_nitro_usb_device* usb_device_desc, int& curr_serial_extra_id_is_nitro);
|
||||
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef __USB_GENERIC_HPP
|
||||
#define __USB_GENERIC_HPP
|
||||
|
||||
#if defined(USE_IS_NITRO_USB) || defined(USE_DS_3DS_USB)
|
||||
#ifdef USE_LIBUSB
|
||||
#include <libusb.h>
|
||||
libusb_context* get_usb_ctx();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user