mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-05 22:41:18 +12:00
nsyshid: Add backends for cross platform USB passthrough support (#950)
This commit is contained in:
parent
2a735f1fb7
commit
98b5a8758a
17 changed files with 2298 additions and 524 deletions
66
src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h
Normal file
66
src/Cafe/OS/libs/nsyshid/BackendWindowsHID.h
Normal file
|
@ -0,0 +1,66 @@
|
|||
#ifndef CEMU_NSYSHID_BACKEND_WINDOWS_HID_H
|
||||
#define CEMU_NSYSHID_BACKEND_WINDOWS_HID_H
|
||||
|
||||
#include "nsyshid.h"
|
||||
|
||||
#if NSYSHID_ENABLE_BACKEND_WINDOWS_HID
|
||||
|
||||
#include "Backend.h"
|
||||
|
||||
namespace nsyshid::backend::windows
|
||||
{
|
||||
class BackendWindowsHID : public nsyshid::Backend {
|
||||
public:
|
||||
BackendWindowsHID();
|
||||
|
||||
~BackendWindowsHID();
|
||||
|
||||
bool IsInitialisedOk() override;
|
||||
|
||||
protected:
|
||||
void AttachVisibleDevices() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Device> CheckAndCreateDevice(wchar_t* devicePath, HANDLE hDevice);
|
||||
};
|
||||
|
||||
class DeviceWindowsHID : public nsyshid::Device {
|
||||
public:
|
||||
DeviceWindowsHID(uint16 vendorId,
|
||||
uint16 productId,
|
||||
uint8 interfaceIndex,
|
||||
uint8 interfaceSubClass,
|
||||
uint8 protocol,
|
||||
wchar_t* devicePath);
|
||||
|
||||
~DeviceWindowsHID();
|
||||
|
||||
bool Open() override;
|
||||
|
||||
void Close() override;
|
||||
|
||||
bool IsOpened() override;
|
||||
|
||||
ReadResult Read(uint8* data, sint32 length, sint32& bytesRead) override;
|
||||
|
||||
WriteResult Write(uint8* data, sint32 length, sint32& bytesWritten) override;
|
||||
|
||||
bool GetDescriptor(uint8 descType, uint8 descIndex, uint8 lang, uint8* output, uint32 outputMaxLength) override;
|
||||
|
||||
bool SetProtocol(uint32 ifIndef, uint32 protocol) override;
|
||||
|
||||
bool SetReport(uint8* reportData, sint32 length, uint8* originalData, sint32 originalLength) override;
|
||||
|
||||
private:
|
||||
wchar_t* m_devicePath;
|
||||
HANDLE m_hFile;
|
||||
};
|
||||
|
||||
HANDLE OpenDevice(wchar_t* devicePath);
|
||||
|
||||
void _debugPrintHex(std::string prefix, uint8* data, size_t len);
|
||||
} // namespace nsyshid::backend::windows
|
||||
|
||||
#endif // NSYSHID_ENABLE_BACKEND_WINDOWS_HID
|
||||
|
||||
#endif // CEMU_NSYSHID_BACKEND_WINDOWS_HID_H
|
Loading…
Add table
Add a link
Reference in a new issue