summaryrefslogtreecommitdiffhomepage
path: root/proto-vjoystick/vjoystick.h
diff options
context:
space:
mode:
Diffstat (limited to 'proto-vjoystick/vjoystick.h')
-rw-r--r--proto-vjoystick/vjoystick.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/proto-vjoystick/vjoystick.h b/proto-vjoystick/vjoystick.h
new file mode 100644
index 00000000..6d4062f0
--- /dev/null
+++ b/proto-vjoystick/vjoystick.h
@@ -0,0 +1,68 @@
+/* Copyright (c) 2016, Stanislaw Halik <sthalik@misaki.pl>
+
+ * Permission to use, copy, modify, and/or distribute this
+ * software for any purpose with or without fee is hereby granted,
+ * provided that the above copyright notice and this permission
+ * notice appear in all copies.
+ */
+#pragma once
+#include "ui_vjoystick.h"
+#include "opentrack/plugin-api.hpp"
+
+#include <QObject>
+#include <QString>
+
+#include <windows.h>
+
+enum state : signed char
+{
+ state_notent = -1,
+ state_fail = -2,
+ state_success = 1,
+};
+
+class handle final
+{
+ state joy_state;
+ LONG axis_min[6] {};
+ LONG axis_max[6] {};
+
+ void init();
+public:
+ handle();
+ ~handle();
+ state get_state() { return joy_state; }
+ LONG to_axis_value(unsigned axis_id, double val);
+};
+
+class vjoystick_proto : public QObject, public IProtocol
+{
+ Q_OBJECT
+
+ handle h;
+public:
+ vjoystick_proto();
+ ~vjoystick_proto() override;
+ bool correct() override;
+ void pose( const double *headpose ) override;
+ QString game_name() override { return tr("Virtual joystick"); }
+private:
+};
+
+class vjoystick_dialog final : public IProtocolDialog
+{
+ Q_OBJECT
+public:
+
+ vjoystick_dialog();
+ void register_protocol(IProtocol *) override {}
+ void unregister_protocol() override {}
+private:
+ Ui::vjoystick ui;
+};
+
+class vjoystick_metadata : public Metadata
+{
+ QString name() override { return "Joystick emulation -- vjoystick"; }
+ QIcon icon() override { return QIcon(":/images/vjoystick.png"); }
+};