2019-10-31 18:00:42 +00:00
|
|
|
#pragma once
|
|
|
|
#include "SwitchUSBEndpoint.h"
|
2019-11-13 11:16:13 +00:00
|
|
|
#include "IUSBInterface.h"
|
2019-10-31 18:00:42 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class SwitchUSBInterface : public IUSBInterface
|
|
|
|
{
|
|
|
|
private:
|
2019-11-25 12:58:23 +00:00
|
|
|
UsbHsClientIfSession m_session;
|
|
|
|
UsbHsInterface m_interface;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
2019-11-04 12:32:43 +00:00
|
|
|
std::array<std::unique_ptr<IUSBEndpoint>, 15> m_inEndpoints;
|
|
|
|
std::array<std::unique_ptr<IUSBEndpoint>, 15> m_outEndpoints;
|
|
|
|
|
2019-10-31 18:00:42 +00:00
|
|
|
public:
|
|
|
|
//Pass the specified interface to allow for opening the session
|
|
|
|
SwitchUSBInterface(UsbHsInterface &interface);
|
|
|
|
~SwitchUSBInterface();
|
|
|
|
|
|
|
|
// Open and close the interface
|
2019-11-13 11:27:43 +00:00
|
|
|
virtual Result Open() override;
|
|
|
|
virtual void Close() override;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
2019-11-13 11:27:43 +00:00
|
|
|
virtual Result ControlTransfer(u8 bmRequestType, u8 bmRequest, u16 wValue, u16 wIndex, u16 wLength, void *buffer) override;
|
2019-11-21 22:49:51 +00:00
|
|
|
virtual Result ControlTransfer(u8 bmRequestType, u8 bmRequest, u16 wValue, u16 wIndex, u16 wLength, const void *buffer) override;
|
2019-11-04 12:32:43 +00:00
|
|
|
|
2019-10-31 18:00:42 +00:00
|
|
|
// There are a total of 15 endpoints on a switch interface for each direction, get them by passing the desired parameters
|
2019-11-13 11:27:43 +00:00
|
|
|
virtual IUSBEndpoint *GetEndpoint(IUSBEndpoint::Direction direction, uint8_t index) override;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
|
|
|
// Reset the device
|
2019-11-13 11:27:43 +00:00
|
|
|
virtual Result Reset() override;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
|
|
|
//Get the unique session ID for this interface
|
|
|
|
inline s32 GetID() { return m_session.ID; }
|
|
|
|
//Get the raw interface
|
|
|
|
inline UsbHsInterface &GetInterface() { return m_interface; }
|
|
|
|
//Get the raw session
|
|
|
|
inline UsbHsClientIfSession &GetSession() { return m_session; }
|
|
|
|
|
2019-11-13 11:27:43 +00:00
|
|
|
virtual InterfaceDescriptor *GetDescriptor() override { return reinterpret_cast<InterfaceDescriptor *>(&m_interface.inf.interface_desc); }
|
2019-10-31 18:00:42 +00:00
|
|
|
};
|