#if defined(USB_CONTROLLER) #include "usbcontroller.h" #ifdef Q_OS_WIN #pragma comment (lib, "Setupapi.lib") #endif #include #include "logcategories.h" usbController::usbController() { qInfo(logUsbControl()) << "Starting usbController()"; } usbController::~usbController() { qInfo(logUsbControl) << "Ending usbController()"; if (handle) { if (usbDevice == RC28) { ledControl(false, 3); } hid_close(handle); } hid_exit(); #if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) if (gamepad != Q_NULLPTR) { delete gamepad; gamepad = Q_NULLPTR; } #endif } void usbController::init() { hidStatus = hid_init(); if (hidStatus) { qInfo(logUsbControl()) << "Failed to intialize HID Devices"; } else { #if defined(__APPLE__) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0) hid_darwin_set_open_exclusive(1); #endif qInfo(logUsbControl()) << "Found available HID devices (not all will be suitable for use):"; struct hid_device_info* devs; devs = hid_enumerate(0x0, 0x0); while (devs) { qInfo(logUsbControl()) << QString("Manufacturer: %0 Product: %1") .arg(QString::fromWCharArray(devs->manufacturer_string)) .arg(QString::fromWCharArray(devs->product_string)); devs = devs->next; } hid_free_enumeration(devs); } } void usbController::receiveCommands(QVector* cmds) { qDebug(logUsbControl()) << "Receiving commands"; commands = cmds; } void usbController::receiveButtons(QVector