diff options
Diffstat (limited to 'proto-vjoystick/vjoystick.h')
-rw-r--r-- | proto-vjoystick/vjoystick.h | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/proto-vjoystick/vjoystick.h b/proto-vjoystick/vjoystick.h index 72dde0f0..82ebd3e6 100644 --- a/proto-vjoystick/vjoystick.h +++ b/proto-vjoystick/vjoystick.h @@ -8,46 +8,33 @@ #pragma once #include "ui_vjoystick.h" #include "api/plugin-api.hpp" -#include "compat/macros.hpp" -#include <windows.h> - -enum state : signed char +enum status { - state_notent = -1, - state_fail = -2, - state_success = 1, }; -class handle final +class vjoystick : public TR, public IProtocol { + Q_OBJECT + public: - static constexpr unsigned axis_count = 6; - static const unsigned char axis_ids[axis_count]; + vjoystick(); + ~vjoystick() override; + module_status initialize() override; + void pose(const double* headpose, const double*) override; + QString game_name() override { return tr("Virtual joystick"); } private: - state joy_state; - LONG axis_min[6]; - LONG axis_max[6]; + long axis_min[6] {}; + long axis_max[6] {}; + [[nodiscard]] bool init(); + int to_axis_value(unsigned axis_id, double val) const; - void init(); -public: - handle(); - ~handle(); - state get_state() { return joy_state; } - LONG to_axis_value(unsigned axis_id, double val); -}; + static constexpr unsigned axis_count = 6; + static const unsigned char axis_ids[axis_count]; -class vjoystick_proto : public IProtocol -{ - handle h; -public: - vjoystick_proto(); - ~vjoystick_proto() override; - module_status initialize() override; - void pose( const double *headpose ) override; - QString game_name() override { return otr_tr("Virtual joystick"); } -private: + bool status = false; + bool first_run = true; }; class vjoystick_dialog final : public IProtocolDialog @@ -64,7 +51,8 @@ private: class vjoystick_metadata : public Metadata { -public: - QString name() { return otr_tr("Joystick emulation -- vjoystick"); } - QIcon icon() { return QIcon(":/images/vjoystick.png"); } + Q_OBJECT + + QString name() override { return tr("Joystick emulation -- vjoystick"); } + QIcon icon() override { return QIcon(":/images/vjoystick.png"); } }; |