Formatting...

This commit is contained in:
2022-11-12 18:37:24 +01:00
parent d7dfdc4739
commit f09e4ab5c8
6 changed files with 37 additions and 36 deletions

View File

@@ -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;