#ifndef usbController_H #define usbController_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined(USB_CONTROLLER) && QT_VERSION < QT_VERSION_CHECK(6,0,0) #include #endif #if defined(USB_CONTROLLER) #ifndef Q_OS_WIN #include "hidapi/hidapi.h" #else #include "hidapi.h" #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(USING_HIDAPI_LIBUSB) && HID_API_VERSION >= HID_API_MAKE_VERSION(0, 12, 0) #include #endif #endif #endif #ifndef Q_OS_WIN #include #endif // Include these so we have the various enums #include "rigidentities.h" using namespace std; #define HIDDATALENGTH 64 #define MAX_STR 255 struct USBDEVICE { usbDeviceType usbDevice = usbNone; bool connected = false; hid_device* handle = NULL; QString product = ""; QString manufacturer = ""; QString serial = ""; QString deviceId = ""; QString path = ""; quint16 vendorId = 0; quint16 productId = 0; int sensitivity = 1; unsigned char jogpos=0; unsigned char shutpos=0; unsigned char shutMult = 0; int jogCounter = 0; quint32 buttons = 0; quint32 knobs = 0; QList knobValues; QList knobPrevious; QList knobSend; QTime lastusbController = QTime::currentTime(); QByteArray lastData = QByteArray(8,0x0); unsigned char lastDialPos=0; QUuid uuid; }; struct COMMAND { COMMAND() {} COMMAND(int index, QString text, usbCommandType cmdType, int command, unsigned char suffix) : index(index), text(text), cmdType(cmdType), command(command), suffix(suffix) {} COMMAND(int index, QString text, usbCommandType cmdType, int command, availableBands band) : index(index), text(text), cmdType(cmdType), command(command), band(band) {} COMMAND(int index, QString text, usbCommandType cmdType, int command, mode_kind mode) : index(index), text(text), cmdType(cmdType), command(command), mode(mode) {} int index=0; QString text; usbCommandType cmdType = commandButton; int command=0; unsigned char suffix=0x0; int value=0; availableBands band=bandGen; mode_kind mode=modeLSB; }; struct BUTTON { BUTTON() {} BUTTON(usbDeviceType dev, int num, QRect pos, const QColor textColour, COMMAND* on, COMMAND* off) : dev(dev), num(num), name(""), pos(pos), textColour(textColour), onCommand(on), offCommand(off) {} BUTTON(usbDeviceType dev, QString name, QRect pos, const QColor textColour, COMMAND* on, COMMAND* off) : dev(dev), num(-1), name(name), pos(pos), textColour(textColour), onCommand(on), offCommand(off) {} usbDeviceType dev; int num; QString name; QRect pos; QColor textColour; const COMMAND* onCommand = Q_NULLPTR; const COMMAND* offCommand = Q_NULLPTR; QGraphicsTextItem* onText; QGraphicsTextItem* offText; QString on; QString off; QString devicePath; }; struct KNOB { KNOB() {} KNOB(usbDeviceType dev, int num, QRect pos, const QColor textColour, COMMAND* command) : dev(dev), num(num), name(""), pos(pos), textColour(textColour), command(command) {} usbDeviceType dev; int num; QString name; QRect pos; QColor textColour; const COMMAND* command = Q_NULLPTR; QGraphicsTextItem* text; QString cmd; QString devicePath; }; struct CONTROLLER { int sensitivity=1; quint8 speed=2; quint8 timeout=30; quint8 brightness=2; quint8 orientation=0; QColor color=Qt::white; }; typedef QMap usbMap; #if defined(USB_CONTROLLER) class usbController : public QObject { Q_OBJECT public: usbController(); ~usbController(); public slots: void init(QMutex* mut,usbMap* prefs ,QVector