2019-10-31 18:00:42 +00:00
|
|
|
#pragma once
|
|
|
|
#include "switch.h"
|
2019-11-13 11:16:13 +00:00
|
|
|
#include "IUSBEndpoint.h"
|
2019-10-31 18:00:42 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class SwitchUSBEndpoint : public IUSBEndpoint
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
UsbHsClientEpSession m_epSession{};
|
2019-11-06 12:28:56 +00:00
|
|
|
UsbHsClientIfSession *m_ifSession;
|
|
|
|
usb_endpoint_descriptor *m_descriptor;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
2019-11-25 12:58:01 +00:00
|
|
|
void *m_buffer = nullptr;
|
|
|
|
|
2019-10-31 18:00:42 +00:00
|
|
|
public:
|
|
|
|
//Pass the necessary information to be able to open the endpoint
|
|
|
|
SwitchUSBEndpoint(UsbHsClientIfSession &if_session, usb_endpoint_descriptor &desc);
|
|
|
|
~SwitchUSBEndpoint();
|
|
|
|
|
|
|
|
//Open and close the endpoint
|
2019-11-13 11:27:43 +00:00
|
|
|
virtual Result Open(int maxPacketSize = 0) override;
|
|
|
|
virtual void Close() override;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
|
|
|
//buffer should point to the data array, and only the specified size will be read.
|
2019-11-13 11:27:43 +00:00
|
|
|
virtual Result Write(const void *inBuffer, size_t bufferSize) override;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
|
|
|
//The data received will be put in the outBuffer array for the length of the specified size.
|
2019-11-13 11:27:43 +00:00
|
|
|
virtual Result Read(void *outBuffer, size_t bufferSize) override;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
|
|
|
//Gets the direction of this endpoint (IN or OUT)
|
2019-11-13 11:27:43 +00:00
|
|
|
virtual IUSBEndpoint::Direction GetDirection() override;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
|
|
|
//get the endpoint descriptor
|
2019-11-13 11:27:43 +00:00
|
|
|
virtual IUSBEndpoint::EndpointDescriptor *GetDescriptor() override;
|
2019-10-31 18:00:42 +00:00
|
|
|
|
|
|
|
// Get the current EpSession (after it was opened)
|
|
|
|
inline UsbHsClientEpSession &GetSession() { return m_epSession; }
|
|
|
|
};
|