summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-11-22 15:50:46 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-11-22 15:55:45 +0100
commit119671e4e7f4dc07c1fb20eb999a0a7fcfbbdba8 (patch)
tree0b90e43ed648217dd75a15e73dee93e477103903
parent86f1df90b405b56b46d698b4059ed2c6b10df8b3 (diff)
api/shortcuts, tracker/joy: adapt to synchronized joy api
-rw-r--r--opentrack/keybinding-worker.cpp2
-rw-r--r--opentrack/keybinding-worker.hpp2
-rw-r--r--tracker-joystick/ftnoir_tracker_joystick.cpp11
-rw-r--r--tracker-joystick/ftnoir_tracker_joystick.h2
-rw-r--r--tracker-joystick/ftnoir_tracker_joystick_dialog.cpp9
5 files changed, 18 insertions, 8 deletions
diff --git a/opentrack/keybinding-worker.cpp b/opentrack/keybinding-worker.cpp
index d876d5a1..5f42f44e 100644
--- a/opentrack/keybinding-worker.cpp
+++ b/opentrack/keybinding-worker.cpp
@@ -27,7 +27,7 @@ KeybindingWorker::~KeybindingWorker() {
din->Release();
}
-KeybindingWorker::KeybindingWorker() : should_quit(true)
+KeybindingWorker::KeybindingWorker() : joy_ctx(win32_joy_ctx::make()), should_quit(true)
{
if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&din, NULL) != DI_OK) {
qDebug() << "setup DirectInput8 Creation failed!" << GetLastError();
diff --git a/opentrack/keybinding-worker.hpp b/opentrack/keybinding-worker.hpp
index 5a73b1b1..551be144 100644
--- a/opentrack/keybinding-worker.hpp
+++ b/opentrack/keybinding-worker.hpp
@@ -59,7 +59,7 @@ struct OPENTRACK_EXPORT KeybindingWorker : private QThread
private:
LPDIRECTINPUT8 din;
LPDIRECTINPUTDEVICE8 dinkeyboard;
- win32_joy_ctx joy_ctx;
+ win32_joy_ctx& joy_ctx;
volatile bool should_quit;
using fun = std::function<void(Key&)>;
std::vector<fun> receivers;
diff --git a/tracker-joystick/ftnoir_tracker_joystick.cpp b/tracker-joystick/ftnoir_tracker_joystick.cpp
index 4c180eaa..112f20ca 100644
--- a/tracker-joystick/ftnoir_tracker_joystick.cpp
+++ b/tracker-joystick/ftnoir_tracker_joystick.cpp
@@ -8,8 +8,17 @@
#include "opentrack/plugin-api.hpp"
#include <QMutexLocker>
-FTNoIR_Tracker::FTNoIR_Tracker()
+FTNoIR_Tracker::FTNoIR_Tracker() : joy_ctx(win32_joy_ctx::make())
{
+ if (static_cast<QString>(s.guid) == "")
+ {
+ std::vector<win32_joy_ctx::joy_info> info = joy_ctx.get_joy_info();
+ if (info.size())
+ {
+ s.guid = info[0].guid;
+ s.b->save();
+ }
+ }
}
FTNoIR_Tracker::~FTNoIR_Tracker()
diff --git a/tracker-joystick/ftnoir_tracker_joystick.h b/tracker-joystick/ftnoir_tracker_joystick.h
index 18ac349e..e94e2ee7 100644
--- a/tracker-joystick/ftnoir_tracker_joystick.h
+++ b/tracker-joystick/ftnoir_tracker_joystick.h
@@ -47,7 +47,7 @@ public:
settings s;
QString guid;
static constexpr int AXIS_MAX = win32_joy_ctx::joy_axis_size - 1;
- win32_joy_ctx joy_ctx;
+ win32_joy_ctx& joy_ctx;
};
class TrackerControls: public ITrackerDialog
diff --git a/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp b/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp
index 28846809..1ca1441c 100644
--- a/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp
+++ b/tracker-joystick/ftnoir_tracker_joystick_dialog.cpp
@@ -10,20 +10,21 @@ TrackerControls::TrackerControls() : tracker(nullptr)
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
{
- win32_joy_ctx joy_ctx;
+ win32_joy_ctx& joy_ctx(win32_joy_ctx::make());
_joys = QList<joys>();
- for (auto& j : joy_ctx.joys())
- _joys.push_back(joys { j.second->name, j.first });
+ for (auto j : joy_ctx.get_joy_info())
+ _joys.push_back(joys { j.name, j.guid });
}
{
+ const QString guid = s.guid;
int idx = 0;
for (int i = 0; i < _joys.size(); i++)
{
const joys& j = _joys[i];
- if (j.guid == s.guid && j.name == s.joyid)
+ if (j.guid == guid)
idx = i;
ui.joylist->addItem(j.name + " " + j.guid);
}