You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.6 KiB
83 lines
2.6 KiB
#ifndef ConsoleButton_H
|
|
#define ConsoleButton_H
|
|
|
|
#include <QObject>
|
|
#include <QtXml>
|
|
#include <QMap>
|
|
#include <QMutex>
|
|
#include <QtConcurrent/QtConcurrent>
|
|
#include <QMetaType>
|
|
|
|
#include "model/csm/core/consoleComponent/ControlAbstract.h"
|
|
#include "model/csm/core/consoleComponent/Button.h"
|
|
#include "model/csm/core/consoleComponent/Rotary.h"
|
|
#include "model/csm/core/consoleComponent/Led.h"
|
|
#include "model/csm/dto/HidPacket.h"
|
|
#include "model/csm/utils/XmlConsoleConfigReader.h"
|
|
|
|
#define LONG_PRESS_TIME_MS 1000
|
|
|
|
/*****************************************************************************/
|
|
/**
|
|
* @brief this class is a code vision of each console's item in real
|
|
* @author Mohammad Mohsen Talaie
|
|
* @details this class modifing the leds, rotary and buttons of each item
|
|
* @date 12 jan 2021
|
|
*/
|
|
/*****************************************************************************/
|
|
class ConsoleButton : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
private:
|
|
QString _name;
|
|
|
|
Button _push;
|
|
Button _up;
|
|
Button _down;
|
|
Rotary _rotary;
|
|
|
|
QMutex _longPressLocker;
|
|
QList<quint8> _functionCodes; //init inside ctor
|
|
|
|
QList<Led_t> _ledList;
|
|
|
|
//this list contain fuction code and corespond commands information.
|
|
QMap<quint8, QList<CommandControl_t> > _controlCommandList;
|
|
QMap<quint8, QList<CommandControl_t> > _controlLongPressCommandList;
|
|
|
|
EConsole::eConsoleButtonType _ConsolebuttonType;
|
|
|
|
void pushDownCheck(Button* btn, const HidPacket_t& data);
|
|
|
|
void checkPushUp(Button& btn, const HidPacket_t& data);
|
|
|
|
void longPressThread(Button* btn, const HidPacket_t& data);
|
|
|
|
int updateControlsEnablity(const Led_t& led);
|
|
|
|
public:
|
|
//ctor
|
|
ConsoleButton(const QDomElement& btnElement);
|
|
|
|
EConsole::eConsoleButtonType getConsoleButtonType() const;
|
|
QList<quint8> getFunctionCodes();
|
|
QString getName() const;
|
|
|
|
void prepareControlComandList(ControlAbstract* control,
|
|
const EConsole::eConsoleState& consoleState);
|
|
|
|
signals:
|
|
void sendLedStatusToHID(const QMap<quint8, quint8>& ledStatus);
|
|
void sendControlCommandToConsoleCore(const QList<CommandControl_t>& commands,
|
|
const quint8& functionCode);
|
|
void sendControlLongPressCommandToConsoleCore(const QList<CommandControl_t>& commands,
|
|
const quint8& functionCode);
|
|
//uncrustify off
|
|
public slots:
|
|
//uncrustify on
|
|
void recievePush(const HidPacket_t& data);
|
|
void recieveConsoleState(const EConsole::eConsoleState& consoleState, const QString& probType);
|
|
};
|
|
|
|
#endif //ConsoleButton_H
|
|
|