mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-08 21:17:50 +00:00
Update fmtlib
This commit is contained in:
@@ -15,7 +15,7 @@ DeviceFinder* DeviceFinder::skDevFinder = nullptr;
|
||||
|
||||
DeviceFinder::DeviceFinder(std::unordered_set<uint64_t> types) {
|
||||
if (skDevFinder) {
|
||||
fmt::print(stderr, fmt("only one instance of CDeviceFinder may be constructed"));
|
||||
fmt::print(stderr, FMT_STRING("only one instance of CDeviceFinder may be constructed"));
|
||||
std::abort();
|
||||
}
|
||||
skDevFinder = this;
|
||||
|
||||
@@ -79,7 +79,7 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||
}
|
||||
|
||||
static void _threadProcUSBLL(std::shared_ptr<HIDDeviceIOKit> device) {
|
||||
pthread_setname_np(fmt::format(fmt("{} Transfer Thread"), device->m_token.getProductName()).c_str());
|
||||
pthread_setname_np(fmt::format(FMT_STRING("{} Transfer Thread"), device->m_token.getProductName()).c_str());
|
||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||
|
||||
/* Get the HID element's parent (USB interrupt transfer-interface) */
|
||||
@@ -95,7 +95,7 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||
}
|
||||
}
|
||||
if (!interfaceEntry) {
|
||||
device->m_devImp->deviceError(fmt("Unable to find interface for {}@{}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to find interface for {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath);
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -109,7 +109,7 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||
err = IOCreatePlugInInterfaceForService(interfaceEntry.get(), kIOUSBInterfaceUserClientTypeID,
|
||||
kIOCFPlugInInterfaceID, &iodev, &score);
|
||||
if (err) {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath);
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -120,7 +120,7 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||
IUnknownPointer<IOUSBInterfaceInterface> intf;
|
||||
err = iodev.As(&intf, kIOUSBInterfaceInterfaceID);
|
||||
if (err) {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath);
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -132,10 +132,10 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||
err = intf->USBInterfaceOpen(intf.storage());
|
||||
if (err != kIOReturnSuccess) {
|
||||
if (err == kIOReturnExclusiveAccess) {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: someone else using it\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}: someone else using it\n"),
|
||||
device->m_token.getProductName(), device->m_devPath);
|
||||
} else {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath);
|
||||
}
|
||||
lk.unlock();
|
||||
@@ -199,14 +199,14 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||
}
|
||||
|
||||
static void _threadProcHID(std::shared_ptr<HIDDeviceIOKit> device) {
|
||||
pthread_setname_np(fmt::format(fmt("{} Transfer Thread"), device->m_token.getProductName()).c_str());
|
||||
pthread_setname_np(fmt::format(FMT_STRING("{} Transfer Thread"), device->m_token.getProductName()).c_str());
|
||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||
|
||||
/* Get the HID element's object (HID device interface) */
|
||||
IOObjectPointer<io_service_t> interfaceEntry =
|
||||
IORegistryEntryFromPath(kIOMasterPortDefault, device->m_devPath.data());
|
||||
if (!IOObjectConformsTo(interfaceEntry.get(), "IOHIDDevice")) {
|
||||
device->m_devImp->deviceError(fmt("Unable to find interface for {}@{}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to find interface for {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath);
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -215,7 +215,7 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||
|
||||
device->m_hidIntf = IOHIDDeviceCreate(nullptr, interfaceEntry.get());
|
||||
if (!device->m_hidIntf) {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath);
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -226,10 +226,10 @@ class HIDDeviceIOKit : public IHIDDevice {
|
||||
IOReturn err = IOHIDDeviceOpen(device->m_hidIntf.get(), kIOHIDOptionsTypeNone);
|
||||
if (err != kIOReturnSuccess) {
|
||||
if (err == kIOReturnExclusiveAccess) {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: someone else using it\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}: someone else using it\n"),
|
||||
device->m_token.getProductName(), device->m_devPath);
|
||||
} else {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath);
|
||||
}
|
||||
lk.unlock();
|
||||
@@ -292,7 +292,7 @@ public:
|
||||
else if (dType == DeviceType::HID)
|
||||
m_thread = std::thread(_threadProcHID, std::static_pointer_cast<HIDDeviceIOKit>(shared_from_this()));
|
||||
else {
|
||||
fmt::print(stderr, fmt("invalid token supplied to device constructor\n"));
|
||||
fmt::print(stderr, FMT_STRING("invalid token supplied to device constructor\n"));
|
||||
return;
|
||||
}
|
||||
m_initCond.wait(lk);
|
||||
|
||||
@@ -69,7 +69,7 @@ class HIDDeviceUdev final : public IHIDDevice {
|
||||
const char* dp = udev_device_get_devnode(udevDev);
|
||||
int fd = open(dp, O_RDWR);
|
||||
if (fd < 0) {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -149,7 +149,7 @@ class HIDDeviceUdev final : public IHIDDevice {
|
||||
const char* dp = udev_device_get_devnode(udevDev);
|
||||
int fd = open(dp, O_RDWR | O_NONBLOCK);
|
||||
if (fd < 0) {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -166,7 +166,7 @@ class HIDDeviceUdev final : public IHIDDevice {
|
||||
/* Report descriptor size */
|
||||
int reportDescSize;
|
||||
if (ioctl(fd, HIDIOCGRDESCSIZE, &reportDescSize) == -1) {
|
||||
device->m_devImp->deviceError(fmt("Unable to ioctl(HIDIOCGRDESCSIZE) {}@{}: {}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to ioctl(HIDIOCGRDESCSIZE) {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
close(fd);
|
||||
return;
|
||||
@@ -176,7 +176,7 @@ class HIDDeviceUdev final : public IHIDDevice {
|
||||
hidraw_report_descriptor reportDesc;
|
||||
reportDesc.size = reportDescSize;
|
||||
if (ioctl(fd, HIDIOCGRDESC, &reportDesc) == -1) {
|
||||
device->m_devImp->deviceError(fmt("Unable to ioctl(HIDIOCGRDESC) {}@{}: {}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to ioctl(HIDIOCGRDESC) {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
close(fd);
|
||||
return;
|
||||
@@ -272,7 +272,7 @@ public:
|
||||
else if (dType == DeviceType::HID)
|
||||
m_thread = std::thread(_threadProcHID, std::static_pointer_cast<HIDDeviceUdev>(shared_from_this()));
|
||||
else {
|
||||
fmt::print(stderr, fmt("invalid token supplied to device constructor"));
|
||||
fmt::print(stderr, FMT_STRING("invalid token supplied to device constructor"));
|
||||
abort();
|
||||
}
|
||||
m_initCond.wait(lk);
|
||||
|
||||
@@ -72,7 +72,7 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
||||
CreateFileA(device->m_devPath.data(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, nullptr,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, nullptr);
|
||||
if (INVALID_HANDLE_VALUE == device->m_devHandle) {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath, GetLastError());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -80,7 +80,7 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
||||
}
|
||||
|
||||
if (!WinUsb_Initialize(device->m_devHandle, &device->m_usbHandle)) {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath, GetLastError());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -91,7 +91,7 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
||||
/* Enumerate device pipes */
|
||||
USB_INTERFACE_DESCRIPTOR ifDesc = {0};
|
||||
if (!WinUsb_QueryInterfaceSettings(device->m_usbHandle, 0, &ifDesc)) {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath, GetLastError());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -156,7 +156,7 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
||||
CreateFileA(device->m_devPath.data(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, nullptr,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, nullptr);
|
||||
if (INVALID_HANDLE_VALUE == device->m_hidHandle) {
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath, GetLastError());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -164,7 +164,7 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
||||
}
|
||||
|
||||
if (!HidD_GetPreparsedData(device->m_hidHandle, &device->m_preparsedData)) {
|
||||
device->m_devImp->deviceError(fmt("Unable get preparsed data of {}@{}: {}\n"),
|
||||
device->m_devImp->deviceError(FMT_STRING("Unable get preparsed data of {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath, GetLastError());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
@@ -233,14 +233,14 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
||||
}
|
||||
|
||||
if (Error != ERROR_IO_PENDING) {
|
||||
fmt::print(stderr, fmt("Write Failed {:08X}\n"), int(Error));
|
||||
fmt::print(stderr, FMT_STRING("Write Failed {:08X}\n"), int(Error));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!GetOverlappedResult(m_hidHandle, &Overlapped, &BytesWritten, TRUE)) {
|
||||
DWORD Error = GetLastError();
|
||||
fmt::print(stderr, fmt("Write Failed {:08X}\n"), int(Error));
|
||||
fmt::print(stderr, FMT_STRING("Write Failed {:08X}\n"), int(Error));
|
||||
return false;
|
||||
}
|
||||
} else if (tp == HIDReportType::Feature) {
|
||||
@@ -309,7 +309,7 @@ public:
|
||||
m_runningTransferLoop = false;
|
||||
return;
|
||||
} else if (Error != ERROR_IO_PENDING) {
|
||||
fmt::print(stderr, fmt("Read Failed: {:08X}\n"), int(Error));
|
||||
fmt::print(stderr, FMT_STRING("Read Failed: {:08X}\n"), int(Error));
|
||||
return;
|
||||
} else if (!GetOverlappedResultEx(m_hidHandle, &m_overlapped, &BytesRead, 10, TRUE)) {
|
||||
return;
|
||||
|
||||
@@ -84,14 +84,14 @@ class HIDListenerIOKit : public IHIDListener {
|
||||
err = IOCreatePlugInInterfaceForService(obj.get(), kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID,
|
||||
&devServ, &score);
|
||||
if (err != kIOReturnSuccess) {
|
||||
fmt::print(stderr, fmt("unable to open IOKit plugin interface\n"));
|
||||
fmt::print(stderr, FMT_STRING("unable to open IOKit plugin interface\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
IUnknownPointer<IOUSBDeviceInterface182> dev;
|
||||
err = devServ.As(&dev, kIOUSBDeviceInterfaceID182);
|
||||
if (err != kIOReturnSuccess) {
|
||||
fmt::print(stderr, fmt("unable to open IOKit device interface\n"));
|
||||
fmt::print(stderr, FMT_STRING("unable to open IOKit device interface\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ class HIDListenerIOKit : public IHIDListener {
|
||||
|
||||
listener->m_finder._insertToken(std::make_unique<DeviceToken>(DeviceType::USB, vid, pid, vstr, pstr, devPath));
|
||||
|
||||
// fmt::print(fmt("ADDED {:08X} {}\n"), obj.get(), devPath);
|
||||
// fmt::print(FMT_STRING("ADDED {:08X} {}\n"), obj.get(), devPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class HIDListenerIOKit : public IHIDListener {
|
||||
if (IORegistryEntryGetPath(obj.get(), kIOServicePlane, devPath) != 0)
|
||||
continue;
|
||||
listener->m_finder._removeToken(devPath);
|
||||
// fmt::print(fmt("REMOVED {:08X} {}\n"), obj.get(), devPath);
|
||||
// fmt::print(FMT_STRING("REMOVED {:08X} {}\n"), obj.get(), devPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,14 +147,14 @@ class HIDListenerIOKit : public IHIDListener {
|
||||
err =
|
||||
IOCreatePlugInInterfaceForService(obj.get(), kIOHIDDeviceTypeID, kIOCFPlugInInterfaceID, &devServ, &score);
|
||||
if (err != kIOReturnSuccess) {
|
||||
fmt::print(stderr, fmt("unable to open IOKit plugin interface\n"));
|
||||
fmt::print(stderr, FMT_STRING("unable to open IOKit plugin interface\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
IUnknownPointer<IOHIDDeviceDeviceInterface> dev;
|
||||
err = devServ.As(&dev, kIOHIDDeviceDeviceInterfaceID);
|
||||
if (err != kIOReturnSuccess) {
|
||||
fmt::print(stderr, fmt("unable to open IOKit device interface\n"));
|
||||
fmt::print(stderr, FMT_STRING("unable to open IOKit device interface\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ class HIDListenerIOKit : public IHIDListener {
|
||||
|
||||
listener->m_finder._insertToken(std::make_unique<DeviceToken>(DeviceType::HID, vidv, pidv, vstr, pstr, devPath));
|
||||
|
||||
// fmt::print(fmt("ADDED {:08X} {}\n"), obj, devPath);
|
||||
// fmt::print(FMT_STRING("ADDED {:08X} {}\n"), obj, devPath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ class HIDListenerIOKit : public IHIDListener {
|
||||
if (IORegistryEntryGetPath(obj.get(), kIOServicePlane, devPath) != 0)
|
||||
continue;
|
||||
listener->m_finder._removeToken(devPath);
|
||||
// fmt::print(fmt("REMOVED {:08X} {}\n"), obj, devPath);
|
||||
// fmt::print(FMT_STRING("REMOVED {:08X} {}\n"), obj, devPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ class HIDListenerUdev final : public IHIDListener {
|
||||
{
|
||||
const char* name = udev_list_entry_get_name(att);
|
||||
const char* val = udev_list_entry_get_value(att);
|
||||
fmt::print(stderr, fmt("{} {}\n"), name, val);
|
||||
fmt::print(stderr, FMT_STRING("{} {}\n"), name, val);
|
||||
}
|
||||
std::fputs("\n\n", stderr);
|
||||
#endif
|
||||
@@ -170,7 +170,7 @@ public:
|
||||
/* Setup hotplug events */
|
||||
m_udevMon = udev_monitor_new_from_netlink(GetUdev(), "udev");
|
||||
if (!m_udevMon) {
|
||||
fmt::print(stderr, fmt("unable to init udev_monitor"));
|
||||
fmt::print(stderr, FMT_STRING("unable to init udev_monitor"));
|
||||
abort();
|
||||
}
|
||||
udev_monitor_filter_add_match_subsystem_devtype(m_udevMon, "usb", "usb_device");
|
||||
|
||||
Reference in New Issue
Block a user