#ifndef CONTROLLERCONTROLLER_H #define CONTROLLERCONTROLLER_H #include "usbcontroller.h" #include #include #include #include #include #include #include #include #include #include #include // Forward declarations struct BUTTON; struct KNOB; struct COMMAND; /** * @brief Model for USB controller devices */ class DeviceModel : public QAbstractListModel { Q_OBJECT public: enum DeviceRoles { DeviceNameRole = Qt::UserRole + 1, DevicePathRole, ConnectedRole, CurrentPageRole, TotalPagesRole, DisabledRole, SensitivityRole, BrightnessRole, SpeedRole, OrientationRole, TimeoutRole, ShowSensitivityRole, ShowBrightnessRole, ShowSpeedRole, ShowOrientationRole, ShowColorRole, ShowTimeoutRole }; explicit DeviceModel(QObject *parent = nullptr); int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QHash roleNames() const override; Q_INVOKABLE QVariantMap get(int row) const; void addDevice(USBDEVICE *dev); void removeDevice(const QString &path); void updateDevice(const QString &path); void reset(); USBDEVICE *getDevice(const QString &path); USBDEVICE *getDevice(int index); private: QVector devices; QMap pathToIndex; }; /** * @brief Model for command items */ class CommandModel : public QAbstractListModel { Q_OBJECT public: enum CommandRoles { TextRole = Qt::UserRole + 1, IndexRole, IsSeparatorRole }; explicit CommandModel(QObject *parent = nullptr); int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QHash roleNames() const override; void setCommands(QVector *commandList, bool buttonCommands); private: QVector commandItems; }; /** * @brief Controller for managing USB controller settings in QML */ class ControllerController : public QObject { Q_OBJECT Q_PROPERTY(DeviceModel *deviceModel READ deviceModel CONSTANT) Q_PROPERTY(CommandModel *commandModel READ commandModel CONSTANT) Q_PROPERTY(CommandModel *knobCommandModel READ knobCommandModel CONSTANT) public: explicit ControllerController(QObject *parent = nullptr); ~ControllerController(); DeviceModel *deviceModel() { return deviceModelObject; } CommandModel *commandModel() { return commandModelObject; } CommandModel *knobCommandModel() { return knobCommandModelObject; } // Initialize with data from main application Q_INVOKABLE void init(usbDevMap *deviceMap, QVector