implement joystick item switching

This commit is contained in:
2022-02-02 13:36:30 +01:00
parent 00bfa72455
commit 7a61dc9368
8 changed files with 61 additions and 41 deletions

View File

@ -13,15 +13,15 @@ class TrainJs: public QObject
Q_OBJECT
private:
static constexpr char JOYSTICK_NAME[] = "UVOS UsbJoy";
static constexpr int LONGPRESS_TIME = 500;
inline static std::vector<std::shared_ptr<TrainJs>> js_;
int id_ = -1;
int axis_ = -1;
QTimer longpressTimer_;
bool handleRelease = false;
bool wantsNewItem = true;
bool inhibitUntillZero = true;
std::weak_ptr<Item> item_;
TrainJs(int id, int axis);
@ -30,7 +30,6 @@ private:
private slots:
void axisChanged(const int id, const int axis, const qreal value);
void buttonChanged(const int id, const int button, const bool pressed);
void longpressTimeout();
signals:
void reqNewItem();
@ -42,6 +41,7 @@ public:
std::weak_ptr<Item> getItem();
void setItem(std::weak_ptr<Item>);
bool itemIsSet();
bool getWantsNewItem() {return wantsNewItem;}
};
#endif // TRAINJS_H