summaryrefslogtreecommitdiffhomepage
path: root/proto-vjoystick/vjoystick.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-01-16 06:21:48 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-01-16 07:49:13 +0100
commitbdbab6bbfef596011302b595cab9b09aec147c55 (patch)
tree05696f23bad81498bf131f9fe5a93d0ef6bc5809 /proto-vjoystick/vjoystick.h
parentb8ea949f768e47624d938d73a5de58b230d59f71 (diff)
proto/mouse: add legacy input method
Diffstat (limited to 'proto-vjoystick/vjoystick.h')
-rw-r--r--proto-vjoystick/vjoystick.h25
1 files changed, 12 insertions, 13 deletions
diff --git a/proto-vjoystick/vjoystick.h b/proto-vjoystick/vjoystick.h
index 0de86638..96d10e9e 100644
--- a/proto-vjoystick/vjoystick.h
+++ b/proto-vjoystick/vjoystick.h
@@ -10,13 +10,13 @@
#include "api/plugin-api.hpp"
#include "compat/macros.hpp"
-#include <windows.h>
+#include <optional>
-enum state : signed char
+enum class state : int
{
- state_notent = -1,
- state_fail = -2,
- state_success = 1,
+ notent = -1,
+ fail = -2,
+ success = 1,
};
class handle final
@@ -26,23 +26,22 @@ public:
static const unsigned char axis_ids[axis_count];
private:
- state joy_state;
- LONG axis_min[6] {};
- LONG axis_max[6] {};
-
- void init();
+ state joy_state = state::notent;
+ long axis_min[6] {};
+ long axis_max[6] {};
+ [[nodiscard]] bool init();
public:
handle();
~handle();
- state get_state() { return joy_state; }
- LONG to_axis_value(unsigned axis_id, double val);
+ state get_state() const { return joy_state; }
+ [[nodiscard]] bool to_axis_value(unsigned axis_id, double val, int& ret) const;
};
class vjoystick_proto : public TR, public IProtocol
{
Q_OBJECT
- handle h;
+ std::optional<handle> h;
public:
vjoystick_proto();
~vjoystick_proto() override;