summaryrefslogtreecommitdiffhomepage
path: root/proto-vjoystick
diff options
context:
space:
mode:
Diffstat (limited to 'proto-vjoystick')
-rw-r--r--proto-vjoystick/CMakeLists.txt2
-rw-r--r--proto-vjoystick/lang/nl_NL.ts47
-rw-r--r--proto-vjoystick/lang/ru_RU.ts47
-rw-r--r--proto-vjoystick/lang/stub.ts47
-rw-r--r--proto-vjoystick/lang/zh_CN.ts47
-rw-r--r--proto-vjoystick/vjoystick.cpp143
-rw-r--r--proto-vjoystick/vjoystick.h48
-rw-r--r--proto-vjoystick/vjoystick.ui21
-rw-r--r--proto-vjoystick/vjoystick_dialog.cpp1
9 files changed, 232 insertions, 171 deletions
diff --git a/proto-vjoystick/CMakeLists.txt b/proto-vjoystick/CMakeLists.txt
index 41af2883..3dbf5bea 100644
--- a/proto-vjoystick/CMakeLists.txt
+++ b/proto-vjoystick/CMakeLists.txt
@@ -1,4 +1,4 @@
-if(WIN32)
+if(WIN32 AND opentrack-intel)
set(SDK_VJOYSTICK "" CACHE PATH "vjoystick SDK path")
if(SDK_VJOYSTICK)
if(opentrack-64bit)
diff --git a/proto-vjoystick/lang/nl_NL.ts b/proto-vjoystick/lang/nl_NL.ts
index 46d0398d..22644924 100644
--- a/proto-vjoystick/lang/nl_NL.ts
+++ b/proto-vjoystick/lang/nl_NL.ts
@@ -4,53 +4,66 @@
<context>
<name>vjoystick</name>
<message>
- <source>VJoy</source>
+ <source>vjoystick won&apos;t work without the driver installed.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Go to the &lt;a href=&quot;http://vjoystick.sourceforge.net/site/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;vjoystick&lt;/span&gt;&lt;/a&gt; project site or &lt;a href=&quot;https://sourceforge.net/projects/vjoystick/files/latest/download&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;download directly&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <source>Download the driver</source>
<translation type="unfinished"></translation>
</message>
-</context>
-<context>
- <name>vjoystick_metadata</name>
<message>
- <source>Joystick emulation -- vjoystick</source>
+ <source>Visit project site</source>
<translation type="unfinished"></translation>
</message>
-</context>
-<context>
- <name>vjoystick_proto</name>
<message>
- <source>vjoystick driver missing</source>
+ <source>Virtual joystick</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>vjoystick won&apos;t work without the driver installed.</source>
+ <source>driver/SDK version mismatch</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Download the driver</source>
+ <source>BUG: joystick claims it&apos;s in use</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Visit project site</source>
+ <source>Virtual joystick already in use</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>vjoystick not installed or disabled</source>
+ <source>Device missing. Add joystick #1.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>can&apos;t initialize vjoystick</source>
+ <source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>unknown error</source>
+ <source>Unknown error #%1</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Virtual joystick</source>
+ <source>vjoystick driver problem</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Driver problem.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>vjoystick</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Go to the &lt;a href=&quot;http://vjoystick.sourceforge.net/site/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;vjoystick&lt;/span&gt;&lt;/a&gt; project site or &lt;a href=&quot;https://sourceforge.net/projects/vjoystick/files/latest/download&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;download directly&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>vjoystick_metadata</name>
+ <message>
+ <source>Joystick emulation -- vjoystick</source>
<translation type="unfinished"></translation>
</message>
</context>
diff --git a/proto-vjoystick/lang/ru_RU.ts b/proto-vjoystick/lang/ru_RU.ts
index 6a618904..b02030e3 100644
--- a/proto-vjoystick/lang/ru_RU.ts
+++ b/proto-vjoystick/lang/ru_RU.ts
@@ -4,53 +4,66 @@
<context>
<name>vjoystick</name>
<message>
- <source>VJoy</source>
+ <source>vjoystick won&apos;t work without the driver installed.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Go to the &lt;a href=&quot;http://vjoystick.sourceforge.net/site/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;vjoystick&lt;/span&gt;&lt;/a&gt; project site or &lt;a href=&quot;https://sourceforge.net/projects/vjoystick/files/latest/download&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;download directly&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <source>Download the driver</source>
<translation type="unfinished"></translation>
</message>
-</context>
-<context>
- <name>vjoystick_metadata</name>
<message>
- <source>Joystick emulation -- vjoystick</source>
+ <source>Visit project site</source>
<translation type="unfinished"></translation>
</message>
-</context>
-<context>
- <name>vjoystick_proto</name>
<message>
- <source>vjoystick driver missing</source>
+ <source>Virtual joystick</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>vjoystick won&apos;t work without the driver installed.</source>
+ <source>driver/SDK version mismatch</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Download the driver</source>
+ <source>BUG: joystick claims it&apos;s in use</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Visit project site</source>
+ <source>Virtual joystick already in use</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>vjoystick not installed or disabled</source>
+ <source>Device missing. Add joystick #1.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>can&apos;t initialize vjoystick</source>
+ <source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>unknown error</source>
+ <source>Unknown error #%1</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Virtual joystick</source>
+ <source>vjoystick driver problem</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Driver problem.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>vjoystick</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Go to the &lt;a href=&quot;http://vjoystick.sourceforge.net/site/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;vjoystick&lt;/span&gt;&lt;/a&gt; project site or &lt;a href=&quot;https://sourceforge.net/projects/vjoystick/files/latest/download&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;download directly&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>vjoystick_metadata</name>
+ <message>
+ <source>Joystick emulation -- vjoystick</source>
<translation type="unfinished"></translation>
</message>
</context>
diff --git a/proto-vjoystick/lang/stub.ts b/proto-vjoystick/lang/stub.ts
index c8909cfe..0fe38ef2 100644
--- a/proto-vjoystick/lang/stub.ts
+++ b/proto-vjoystick/lang/stub.ts
@@ -4,53 +4,66 @@
<context>
<name>vjoystick</name>
<message>
- <source>VJoy</source>
+ <source>vjoystick won&apos;t work without the driver installed.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Go to the &lt;a href=&quot;http://vjoystick.sourceforge.net/site/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;vjoystick&lt;/span&gt;&lt;/a&gt; project site or &lt;a href=&quot;https://sourceforge.net/projects/vjoystick/files/latest/download&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;download directly&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <source>Download the driver</source>
<translation type="unfinished"></translation>
</message>
-</context>
-<context>
- <name>vjoystick_metadata</name>
<message>
- <source>Joystick emulation -- vjoystick</source>
+ <source>Visit project site</source>
<translation type="unfinished"></translation>
</message>
-</context>
-<context>
- <name>vjoystick_proto</name>
<message>
- <source>vjoystick driver missing</source>
+ <source>Virtual joystick</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>vjoystick won&apos;t work without the driver installed.</source>
+ <source>driver/SDK version mismatch</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Download the driver</source>
+ <source>BUG: joystick claims it&apos;s in use</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Visit project site</source>
+ <source>Virtual joystick already in use</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>vjoystick not installed or disabled</source>
+ <source>Device missing. Add joystick #1.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>can&apos;t initialize vjoystick</source>
+ <source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>unknown error</source>
+ <source>Unknown error #%1</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Virtual joystick</source>
+ <source>vjoystick driver problem</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Driver problem.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>vjoystick</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Go to the &lt;a href=&quot;http://vjoystick.sourceforge.net/site/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;vjoystick&lt;/span&gt;&lt;/a&gt; project site or &lt;a href=&quot;https://sourceforge.net/projects/vjoystick/files/latest/download&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;download directly&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>vjoystick_metadata</name>
+ <message>
+ <source>Joystick emulation -- vjoystick</source>
<translation type="unfinished"></translation>
</message>
</context>
diff --git a/proto-vjoystick/lang/zh_CN.ts b/proto-vjoystick/lang/zh_CN.ts
index c8909cfe..0fe38ef2 100644
--- a/proto-vjoystick/lang/zh_CN.ts
+++ b/proto-vjoystick/lang/zh_CN.ts
@@ -4,53 +4,66 @@
<context>
<name>vjoystick</name>
<message>
- <source>VJoy</source>
+ <source>vjoystick won&apos;t work without the driver installed.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Go to the &lt;a href=&quot;http://vjoystick.sourceforge.net/site/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;vjoystick&lt;/span&gt;&lt;/a&gt; project site or &lt;a href=&quot;https://sourceforge.net/projects/vjoystick/files/latest/download&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;download directly&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <source>Download the driver</source>
<translation type="unfinished"></translation>
</message>
-</context>
-<context>
- <name>vjoystick_metadata</name>
<message>
- <source>Joystick emulation -- vjoystick</source>
+ <source>Visit project site</source>
<translation type="unfinished"></translation>
</message>
-</context>
-<context>
- <name>vjoystick_proto</name>
<message>
- <source>vjoystick driver missing</source>
+ <source>Virtual joystick</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>vjoystick won&apos;t work without the driver installed.</source>
+ <source>driver/SDK version mismatch</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Download the driver</source>
+ <source>BUG: joystick claims it&apos;s in use</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Visit project site</source>
+ <source>Virtual joystick already in use</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>vjoystick not installed or disabled</source>
+ <source>Device missing. Add joystick #1.</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>can&apos;t initialize vjoystick</source>
+ <source>Unknown error</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>unknown error</source>
+ <source>Unknown error #%1</source>
<translation type="unfinished"></translation>
</message>
<message>
- <source>Virtual joystick</source>
+ <source>vjoystick driver problem</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Driver problem.</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>vjoystick</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Go to the &lt;a href=&quot;http://vjoystick.sourceforge.net/site/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;vjoystick&lt;/span&gt;&lt;/a&gt; project site or &lt;a href=&quot;https://sourceforge.net/projects/vjoystick/files/latest/download&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;download directly&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>vjoystick_metadata</name>
+ <message>
+ <source>Joystick emulation -- vjoystick</source>
<translation type="unfinished"></translation>
</message>
</context>
diff --git a/proto-vjoystick/vjoystick.cpp b/proto-vjoystick/vjoystick.cpp
index bb0f0f51..268fa343 100644
--- a/proto-vjoystick/vjoystick.cpp
+++ b/proto-vjoystick/vjoystick.cpp
@@ -26,7 +26,7 @@
#define OPENTRACK_VJOYSTICK_ID 1
-const unsigned char handle::axis_ids[6] =
+const unsigned char vjoystick::axis_ids[6] =
{
HID_USAGE_X,
HID_USAGE_Y,
@@ -39,7 +39,7 @@ const unsigned char handle::axis_ids[6] =
// HID_USAGE_WHL,
};
-static const double val_minmax[6] =
+static constexpr double val_minmax[6] =
{
50,
50,
@@ -49,69 +49,96 @@ static const double val_minmax[6] =
180
};
-void handle::init()
+bool vjoystick::init()
{
+ if (!AcquireVJD(OPENTRACK_VJOYSTICK_ID))
+ return false;
+
+ unsigned cnt = 0;
+
for (unsigned i = 0; i < axis_count; i++)
{
- if (!GetVJDAxisExist(OPENTRACK_VJOYSTICK_ID, axis_ids[i]))
+ bool status = true;
+
+ status &= !!GetVJDAxisExist(OPENTRACK_VJOYSTICK_ID, axis_ids[i]);
+ status &= !!GetVJDAxisMin(OPENTRACK_VJOYSTICK_ID, axis_ids[i], &axis_min[i]);
+ status &= !!GetVJDAxisMax(OPENTRACK_VJOYSTICK_ID, axis_ids[i], &axis_max[i]);
+
+ if (!status)
{
- // avoid floating point division by zero
axis_min[i] = 0;
- axis_max[i] = 1;
- continue;
+ axis_max[i] = 0;
}
- GetVJDAxisMin(OPENTRACK_VJOYSTICK_ID, axis_ids[i], &axis_min[i]);
- GetVJDAxisMax(OPENTRACK_VJOYSTICK_ID, axis_ids[i], &axis_max[i]);
- }
- (void) ResetVJD(OPENTRACK_VJOYSTICK_ID);
-}
-
-handle::handle()
-{
- const bool ret = AcquireVJD(OPENTRACK_VJOYSTICK_ID);
- if (!ret)
- {
- if (!isVJDExists(OPENTRACK_VJOYSTICK_ID))
- joy_state = state_notent;
else
- joy_state = state_fail;
- }
- else
- {
- joy_state = state_success;
- init();
+ cnt++;
}
-}
-handle::~handle()
-{
- if (joy_state == state_success)
+ if (!cnt)
{
- (void) RelinquishVJD(OPENTRACK_VJOYSTICK_ID);
- joy_state = state_fail;
+ RelinquishVJD(OPENTRACK_VJOYSTICK_ID);
+ return false;
}
+ else
+ return true;
}
-LONG handle::to_axis_value(unsigned axis_id, double val)
+int vjoystick::to_axis_value(unsigned axis_id, double val) const
{
const double minmax = val_minmax[axis_id];
const double min = axis_min[axis_id];
const double max = axis_max[axis_id];
- return LONG(clamp((val+minmax) * max / (2*minmax) - min, min, max));
+ return (int)(clamp((val+minmax) * max / (2*minmax) - min, min, max));
}
-vjoystick_proto::vjoystick_proto() = default;
-vjoystick_proto::~vjoystick_proto() = default;
+vjoystick::vjoystick() = default;
+vjoystick::~vjoystick()
+{
+ if (status)
+ RelinquishVJD(OPENTRACK_VJOYSTICK_ID);
+}
-module_status vjoystick_proto::initialize()
+module_status vjoystick::initialize()
{
- if (h.get_state() != state_success)
+ QString msg;
+
+ if (!vJoyEnabled())
+ msg = tr("vjoystick won't work without the driver installed.");
+ else if (WORD VerDll, VerDrv; !DriverMatch(&VerDll, &VerDrv))
+ msg = tr("driver/SDK version mismatch");
+ else
+ {
+ int code;
+ switch (code = GetVJDStatus(OPENTRACK_VJOYSTICK_ID))
+ {
+ case VJD_STAT_OWN:
+ msg = tr("BUG: handle leak.");
+ break;
+ case VJD_STAT_FREE:
+ break;
+ case VJD_STAT_BUSY:
+ msg = tr("Virtual joystick already in use.");
+ break;
+ case VJD_STAT_MISS:
+ msg = tr("Device missing. Add joystick #1.");
+ break;
+ case VJD_STAT_UNKN:
+ msg = tr("Unknown error.");
+ break;
+ default:
+ msg = tr("Unknown error #%1.").arg(code);
+ break;
+ }
+ }
+
+ status = msg.isNull();
+
+ if (!status)
{
QMessageBox msgbox;
msgbox.setIcon(QMessageBox::Critical);
- msgbox.setText(tr("vjoystick driver missing"));
- msgbox.setInformativeText(tr("vjoystick won't work without the driver installed."));
+ msgbox.setText(tr("vjoystick driver problem"));
+ msgbox.setInformativeText(msg);
QPushButton* driver_button = msgbox.addButton(tr("Download the driver"), QMessageBox::ActionRole);
QPushButton* project_site_button = msgbox.addButton(tr("Visit project site"), QMessageBox::ActionRole);
@@ -131,28 +158,32 @@ module_status vjoystick_proto::initialize()
}
}
- switch (h.get_state())
- {
- case state_notent:
- return error(tr("vjoystick not installed or disabled"));
- case state_fail:
- return error(tr("can't initialize vjoystick"));
- case state_success:
- return status_ok();
- default:
- return error(tr("unknown error"));
- }
+ if (!status)
+ return error(tr("Driver problem."));
+ else
+ return {};
}
-void vjoystick_proto::pose(const double *pose)
+void vjoystick::pose(const double *pose)
{
- if (h.get_state() != state_success)
+ if (first_run)
+ {
+ status = init();
+ //status &= !!ResetVJD(OPENTRACK_VJOYSTICK_ID);
+ first_run = false;
+ }
+
+ if (!status)
return;
- for (unsigned i = 0; i < handle::axis_count; i++)
+ for (unsigned i = 0; i < vjoystick::axis_count; i++)
{
- SetAxis(h.to_axis_value(i, pose[i]), OPENTRACK_VJOYSTICK_ID, handle::axis_ids[i]);
+ if (axis_min[i] == axis_max[i])
+ continue;
+
+ int val = to_axis_value(i, pose[i]);
+ SetAxis(val, OPENTRACK_VJOYSTICK_ID, vjoystick::axis_ids[i]);
}
}
-OPENTRACK_DECLARE_PROTOCOL(vjoystick_proto, vjoystick_dialog, vjoystick_metadata)
+OPENTRACK_DECLARE_PROTOCOL(vjoystick, vjoystick_dialog, vjoystick_metadata)
diff --git a/proto-vjoystick/vjoystick.h b/proto-vjoystick/vjoystick.h
index 81f70a7f..7e119b21 100644
--- a/proto-vjoystick/vjoystick.h
+++ b/proto-vjoystick/vjoystick.h
@@ -10,46 +10,32 @@
#include "api/plugin-api.hpp"
#include "compat/macros.hpp"
-#include <windows.h>
-
-enum state : signed char
-{
- state_notent = -1,
- state_fail = -2,
- state_success = 1,
-};
-
-class handle final
+enum status
{
-public:
- static constexpr unsigned axis_count = 6;
- static const unsigned char axis_ids[axis_count];
-
-private:
- 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 TR, public IProtocol
+class vjoystick : public TR, public IProtocol
{
Q_OBJECT
- handle h;
public:
- vjoystick_proto();
- ~vjoystick_proto() override;
+ vjoystick();
+ ~vjoystick() override;
module_status initialize() override;
void pose( const double *headpose ) override;
QString game_name() override { return tr("Virtual joystick"); }
+
private:
+ long axis_min[6] {};
+ long axis_max[6] {};
+ [[nodiscard]] bool init();
+ int to_axis_value(unsigned axis_id, double val) const;
+
+ static constexpr unsigned axis_count = 6;
+ static const unsigned char axis_ids[axis_count];
+
+ bool status = false;
+ bool first_run = true;
};
class vjoystick_dialog final : public IProtocolDialog
@@ -68,6 +54,6 @@ class vjoystick_metadata : public Metadata
{
Q_OBJECT
- QString name() { return tr("Joystick emulation -- vjoystick"); }
- QIcon icon() { return QIcon(":/images/vjoystick.png"); }
+ QString name() override { return tr("Joystick emulation -- vjoystick"); }
+ QIcon icon() override { return QIcon(":/images/vjoystick.png"); }
};
diff --git a/proto-vjoystick/vjoystick.ui b/proto-vjoystick/vjoystick.ui
index 6e6a2b33..5bfdb02a 100644
--- a/proto-vjoystick/vjoystick.ui
+++ b/proto-vjoystick/vjoystick.ui
@@ -2,9 +2,6 @@
<ui version="4.0">
<class>vjoystick</class>
<widget class="QWidget" name="vjoystick">
- <property name="windowModality">
- <enum>Qt::NonModal</enum>
- </property>
<property name="geometry">
<rect>
<x>0</x>
@@ -14,23 +11,17 @@
</rect>
</property>
<property name="windowTitle">
- <string>VJoy</string>
+ <string>vjoystick</string>
</property>
<property name="windowIcon">
<iconset resource="vjoystick.qrc">
<normaloff>:/images/vjoystick.png</normaloff>:/images/vjoystick.png</iconset>
</property>
- <property name="layoutDirection">
- <enum>Qt::LeftToRight</enum>
- </property>
- <property name="autoFillBackground">
- <bool>false</bool>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Go to the &lt;a href=&quot;http://vjoystick.sourceforge.net/site/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;vjoystick&lt;/span&gt;&lt;/a&gt; project site or &lt;a href=&quot;https://sourceforge.net/projects/vjoystick/files/latest/download&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;download directly&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Go to the &lt;a href=&quot;http://vjoystick.sourceforge.net/site/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;vjoystick&lt;/span&gt;&lt;/a&gt; project site or &lt;a href=&quot;https://sourceforge.net/projects/vjoystick/files/latest/download&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;download directly&lt;/span&gt;&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
@@ -40,10 +31,10 @@
</property>
</widget>
</item>
- <item>
+ <item row="1" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
- <set>QDialogButtonBox::Ok</set>
+ <set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
diff --git a/proto-vjoystick/vjoystick_dialog.cpp b/proto-vjoystick/vjoystick_dialog.cpp
index 0a1fa9b0..382d8fb3 100644
--- a/proto-vjoystick/vjoystick_dialog.cpp
+++ b/proto-vjoystick/vjoystick_dialog.cpp
@@ -7,4 +7,5 @@ vjoystick_dialog::vjoystick_dialog()
{
ui.setupUi(this);
connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &QWidget::close);
+ connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &QWidget::close);
}