restore USB functionality with altered implementation

This commit is contained in:
2023-08-03 19:06:21 +02:00
parent 458806c6af
commit c3915336dd
9 changed files with 165 additions and 21 deletions

View File

@@ -0,0 +1,34 @@
#pragma once
#include <sys/types.h>
#include <cstdint>
#include "libusb.h"
#include "libusbwrap/LibUsbTypes.hpp"
namespace libusbwrap {
namespace device {
enum class Speed {
UNKNOWN = LIBUSB_SPEED_UNKNOWN,
LOW = LIBUSB_SPEED_LOW,
FULL = LIBUSB_SPEED_FULL,
HIGH = LIBUSB_SPEED_HIGH,
SUPER = LIBUSB_SPEED_SUPER,
SUPER_PLUS = LIBUSB_SPEED_SUPER_PLUS
};
} // namespace device
class IUsbDevice {
public:
virtual Error open() = 0;
virtual void close() = 0;
// getters
virtual uint16_t getVid() = 0;
virtual uint16_t getPid() = 0;
virtual device::Speed getSpeed() = 0;
virtual uint8_t getBusNumber() = 0;
virtual uint8_t getPortNumber() = 0;
};
} // namespace libusbwrap

View File

@@ -0,0 +1,15 @@
#pragma once
#include <cstdint>
#include <memory>
#include <vector>
#include "libusbwrap/interface/IUsbDevice.hpp"
namespace libusbwrap {
class IUsbDeviceFactory {
public:
virtual std::vector<std::shared_ptr<IUsbDevice>> findAllDevices() = 0;
virtual std::vector<std::shared_ptr<IUsbDevice>> findDevices(uint16_t vid, uint16_t pid) = 0;
};
} // namespace libusbwrap