mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-14 15:46:19 +00:00
Massive fmtlib refactor
This commit is contained in:
@@ -61,7 +61,6 @@ class HIDDeviceUdev final : public IHIDDevice {
|
||||
|
||||
static void _threadProcUSBLL(std::shared_ptr<HIDDeviceUdev> device) {
|
||||
int i;
|
||||
char errStr[256];
|
||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||
udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.data());
|
||||
|
||||
@@ -69,8 +68,8 @@ class HIDDeviceUdev final : public IHIDDevice {
|
||||
const char* dp = udev_device_get_devnode(udevDev);
|
||||
int fd = open(dp, O_RDWR);
|
||||
if (fd < 0) {
|
||||
snprintf(errStr, 256, "Unable to open %s@%s: %s\n", device->m_token.getProductName().data(), dp, strerror(errno));
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
udev_device_unref(udevDev);
|
||||
@@ -142,7 +141,6 @@ class HIDDeviceUdev final : public IHIDDevice {
|
||||
}
|
||||
|
||||
static void _threadProcHID(std::shared_ptr<HIDDeviceUdev> device) {
|
||||
char errStr[256];
|
||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||
udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.data());
|
||||
|
||||
@@ -150,8 +148,8 @@ class HIDDeviceUdev final : public IHIDDevice {
|
||||
const char* dp = udev_device_get_devnode(udevDev);
|
||||
int fd = open(dp, O_RDWR | O_NONBLOCK);
|
||||
if (fd < 0) {
|
||||
snprintf(errStr, 256, "Unable to open %s@%s: %s\n", device->m_token.getProductName().data(), dp, strerror(errno));
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
udev_device_unref(udevDev);
|
||||
@@ -167,9 +165,8 @@ class HIDDeviceUdev final : public IHIDDevice {
|
||||
/* Report descriptor size */
|
||||
int reportDescSize;
|
||||
if (ioctl(fd, HIDIOCGRDESCSIZE, &reportDescSize) == -1) {
|
||||
snprintf(errStr, 256, "Unable to ioctl(HIDIOCGRDESCSIZE) %s@%s: %s\n", device->m_token.getProductName().data(),
|
||||
dp, strerror(errno));
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt("Unable to ioctl(HIDIOCGRDESCSIZE) {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
@@ -178,9 +175,8 @@ class HIDDeviceUdev final : public IHIDDevice {
|
||||
hidraw_report_descriptor reportDesc;
|
||||
reportDesc.size = reportDescSize;
|
||||
if (ioctl(fd, HIDIOCGRDESC, &reportDesc) == -1) {
|
||||
snprintf(errStr, 256, "Unable to ioctl(HIDIOCGRDESC) %s@%s: %s\n", device->m_token.getProductName().data(), dp,
|
||||
strerror(errno));
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt("Unable to ioctl(HIDIOCGRDESC) {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
@@ -275,7 +271,7 @@ public:
|
||||
else if (dType == DeviceType::HID)
|
||||
m_thread = std::thread(_threadProcHID, std::static_pointer_cast<HIDDeviceUdev>(shared_from_this()));
|
||||
else {
|
||||
fprintf(stderr, "invalid token supplied to device constructor");
|
||||
fmt::print(stderr, fmt("invalid token supplied to device constructor"));
|
||||
abort();
|
||||
}
|
||||
m_initCond.wait(lk);
|
||||
|
||||
Reference in New Issue
Block a user