Formatting...
This commit is contained in:
23
src/Usb.cpp
23
src/Usb.cpp
@@ -1,9 +1,9 @@
|
||||
#include "Usb.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <optional>
|
||||
#include <spdlog/spdlog.h>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
|
||||
namespace ptprnt::driver {
|
||||
|
||||
@@ -11,28 +11,29 @@ Usb::Usb() {
|
||||
spdlog::debug("Usb constructing");
|
||||
libusb_init(NULL);
|
||||
}
|
||||
|
||||
Usb::~Usb() {
|
||||
spdlog::debug("Usb destructing");
|
||||
}
|
||||
|
||||
std::optional<std::vector<UsbDevice>> Usb::getDevices() {
|
||||
libusb_device ** devs;
|
||||
libusb_device *dev;
|
||||
libusb_device** devs;
|
||||
libusb_device* dev;
|
||||
struct libusb_device_descriptor desc;
|
||||
int r,i=0;
|
||||
int r, i = 0;
|
||||
|
||||
mDevices.clear();
|
||||
|
||||
libusb_get_device_list(NULL, &devs);
|
||||
|
||||
while ((dev=devs[i++]) != NULL) {
|
||||
while ((dev = devs[i++]) != NULL) {
|
||||
UsbDevice newDev;
|
||||
|
||||
if ((r=libusb_get_device_descriptor(dev, &desc)) < 0) {
|
||||
spdlog::error("failed to open device");
|
||||
libusb_free_device_list(devs, 1);
|
||||
if ((r = libusb_get_device_descriptor(dev, &desc)) < 0) {
|
||||
spdlog::error("failed to open device");
|
||||
libusb_free_device_list(devs, 1);
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
newDev.vendorId = desc.idVendor;
|
||||
newDev.productId = desc.idProduct;
|
||||
|
Reference in New Issue
Block a user