From 1515e135e5434ab7c334214ff10165e484536906 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Wed, 8 Feb 2023 10:12:48 +0000 Subject: [PATCH] Fix for old hidapi without version info. --- usbcontroller.cpp | 4 ++-- usbcontroller.h | 38 +++++++++++++++++++------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/usbcontroller.cpp b/usbcontroller.cpp index 22b7abf..de8600e 100644 --- a/usbcontroller.cpp +++ b/usbcontroller.cpp @@ -42,7 +42,7 @@ void usbController::init(int sens) { sensitivity = sens; emit sendSensitivity(sensitivity); - +#ifdef HID_API_VERSION_MAJOR if (HID_API_VERSION == HID_API_MAKE_VERSION(hid_version()->major, hid_version()->minor, hid_version()->patch)) { qInfo(logUsbControl) << QString("Compile-time version matches runtime version of hidapi: %0.%1.%2") .arg(hid_version()->major) @@ -58,7 +58,7 @@ void usbController::init(int sens) .arg(hid_version()->minor) .arg(hid_version()->patch); } - +#endif hidStatus = hid_init(); if (hidStatus) { qInfo(logUsbControl()) << "Failed to intialize HID Devices"; diff --git a/usbcontroller.h b/usbcontroller.h index 9f1601e..0b16e85 100644 --- a/usbcontroller.h +++ b/usbcontroller.h @@ -16,28 +16,28 @@ #endif #if defined(USB_CONTROLLER) -#ifndef Q_OS_WIN -#include "hidapi/hidapi.h" -#else -#include "hidapi.h" -#endif + #ifndef Q_OS_WIN + #include "hidapi/hidapi.h" + #else + #include "hidapi.h" + #endif -#ifndef HID_API_MAKE_VERSION -#define HID_API_MAKE_VERSION(mj, mn, p) (((mj) << 24) | ((mn) << 8) | (p)) -#endif -#ifndef HID_API_VERSION -#define HID_API_VERSION HID_API_MAKE_VERSION(HID_API_VERSION_MAJOR, HID_API_VERSION_MINOR, HID_API_VERSION_PATCH) -#endif + #ifdef HID_API_VERSION_MAJOR + #ifndef HID_API_MAKE_VERSION + #define HID_API_MAKE_VERSION(mj, mn, p) (((mj) << 24) | ((mn) << 8) | (p)) + #endif + #ifndef HID_API_VERSION + #define HID_API_VERSION HID_API_MAKE_VERSION(HID_API_VERSION_MAJOR, HID_API_VERSION_MINOR, HID_API_VERSION_PATCH) + #endif + #if defined(__APPLE__) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0) + #include + #endif -#if defined(__APPLE__) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0) -#include -#endif - -#if defined(USING_HIDAPI_LIBUSB) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0) -#include -#endif - + #if defined(USING_HIDAPI_LIBUSB) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0) + #include + #endif + #endif #endif #ifndef Q_OS_WIN