-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLibUsbDevice.hpp
39 lines (27 loc) · 989 Bytes
/
LibUsbDevice.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
#include <cstddef>
#include <cstdint>
#include <stdexcept>
#include "libusb/libusb.h"
#include "LibUsb.hpp"
class LibUsbDevice {
public:
class OpenError : public LibUsb::LibUsbError {
public:
OpenError(int errorCode);
};
private:
libusb_device_handle* mDeviceHandle;
public:
LibUsbDevice(const LibUsbDevice&) = delete;
LibUsbDevice& operator=(const LibUsbDevice&) = delete;
LibUsbDevice(LibUsbDevice&& other) noexcept;
LibUsbDevice& operator=(LibUsbDevice&& other) noexcept;
LibUsbDevice(const LibUsb& libusb, std::uint_fast16_t VendorId, std::uint_fast16_t ProductId);
virtual ~LibUsbDevice();
operator libusb_device_handle*() const;
libusb_device_handle* GetDeviceHandle() const;
void ClaimInterface(int interfaceNumber);
void Send(std::uint_fast8_t endpoint, std::byte* data, std::size_t dataSize, unsigned int timeout);
void Receive(std::uint_fast8_t endpoint, std::byte* data, std::size_t dataSize, unsigned int timeout);
};