1
0
mirror of https://github.com/cathery/sys-con.git synced 2024-07-05 10:48:46 +00:00
sys-con/SwitchUSB/include/SwitchUSBEndpoint.h

38 lines
1.2 KiB
C
Raw Normal View History

2019-10-31 18:00:42 +00:00
#pragma once
#include "IUSBEndpoint.h"
#include "switch.h"
#include <memory>
class SwitchUSBEndpoint : public IUSBEndpoint
{
private:
UsbHsClientEpSession m_epSession{};
UsbHsClientIfSession m_ifSession;
usb_endpoint_descriptor m_descriptor;
void *m_buffer;
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
virtual Result Open();
virtual void Close();
//buffer should point to the data array, and only the specified size will be read.
virtual Result Write(void *inBuffer, size_t bufferSize);
//The data received will be put in the outBuffer array for the length of the specified size.
virtual Result Read(void *outBuffer, size_t bufferSize);
//Gets the direction of this endpoint (IN or OUT)
virtual IUSBEndpoint::Direction GetDirection();
//get the endpoint descriptor
virtual IUSBEndpoint::EndpointDescriptor *GetDescriptor();
// Get the current EpSession (after it was opened)
inline UsbHsClientEpSession &GetSession() { return m_epSession; }
};