summaryrefslogtreecommitdiffhomepage
path: root/proto-vjoystick/vjoystick.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-02-11 22:12:47 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-02-11 22:12:47 +0100
commitc0da74ccd25837186ebb48af5e21ec250d2a6bdf (patch)
tree1f4fc234e75784910c03e2f237a896046ee5eec4 /proto-vjoystick/vjoystick.h
parent85fc6ac25d350950be56ba47b06c247216f2e22a (diff)
proto/vjoystick: fix threading issue
Acquiring given joystick id must be done on the same thread as the feeder apparently. Provide diagnostics on failure. Issue: #860
Diffstat (limited to 'proto-vjoystick/vjoystick.h')
-rw-r--r--proto-vjoystick/vjoystick.h41
1 files changed, 14 insertions, 27 deletions
diff --git a/proto-vjoystick/vjoystick.h b/proto-vjoystick/vjoystick.h
index 96d10e9e..7e119b21 100644
--- a/proto-vjoystick/vjoystick.h
+++ b/proto-vjoystick/vjoystick.h
@@ -10,45 +10,32 @@
#include "api/plugin-api.hpp"
#include "compat/macros.hpp"
-#include <optional>
-
-enum class state : int
+enum status
{
- notent = -1,
- fail = -2,
- 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 ) override;
+ QString game_name() override { return tr("Virtual joystick"); }
private:
- state joy_state = state::notent;
long axis_min[6] {};
long axis_max[6] {};
[[nodiscard]] bool init();
-public:
- handle();
- ~handle();
- state get_state() const { return joy_state; }
- [[nodiscard]] bool to_axis_value(unsigned axis_id, double val, int& ret) const;
-};
+ int to_axis_value(unsigned axis_id, double val) const;
-class vjoystick_proto : public TR, public IProtocol
-{
- Q_OBJECT
+ static constexpr unsigned axis_count = 6;
+ static const unsigned char axis_ids[axis_count];
- std::optional<handle> h;
-public:
- vjoystick_proto();
- ~vjoystick_proto() override;
- module_status initialize() override;
- void pose( const double *headpose ) override;
- QString game_name() override { return tr("Virtual joystick"); }
-private:
+ bool status = false;
+ bool first_run = true;
};
class vjoystick_dialog final : public IProtocolDialog