51 lines
982 B
C++
51 lines
982 B
C++
#ifndef TRAINJS_H
|
|
#define TRAINJS_H
|
|
|
|
#include <QObject>
|
|
#include <QTimer>
|
|
#include <memory>
|
|
#include <vector>
|
|
#include "items/item.h"
|
|
#include "QJoysticks.h"
|
|
|
|
class TrainJs: public QObject
|
|
{
|
|
Q_OBJECT
|
|
private:
|
|
static constexpr char JOYSTICK_NAME[] = "UVOS UsbJoy";
|
|
|
|
inline static std::vector<std::shared_ptr<TrainJs>> js_;
|
|
|
|
int id_ = -1;
|
|
int axis_ = -1;
|
|
|
|
bool handleRelease = false;
|
|
bool wantsNewItem = true;
|
|
bool inhibitUntillZero = true;
|
|
|
|
std::weak_ptr<Item> item_;
|
|
TrainJs(int id, int axis);
|
|
TrainJs() = default;
|
|
|
|
private slots:
|
|
void axisChanged(const int id, const int axis, const qreal value);
|
|
void buttonChanged(const int id, const int button, const bool pressed);
|
|
|
|
signals:
|
|
void reqNewItem();
|
|
|
|
public:
|
|
~TrainJs();
|
|
static std::vector<std::shared_ptr<TrainJs>> getJsDevices();
|
|
static void init();
|
|
std::weak_ptr<Item> getItem();
|
|
void setItem(std::weak_ptr<Item>);
|
|
bool itemIsSet();
|
|
bool getWantsNewItem()
|
|
{
|
|
return wantsNewItem;
|
|
}
|
|
};
|
|
|
|
#endif // TRAINJS_H
|