summaryrefslogtreecommitdiffhomepage
path: root/tracker-linux-joystick/ftnoir_tracker_linux_joystick_dialog.cpp
diff options
context:
space:
mode:
authorRussell Sim <russell.sim@gmail.com>2020-06-19 21:04:22 +0200
committerRussell Sim <russell.sim@gmail.com>2020-06-25 20:09:20 +0200
commitbd7ce1df885dba290111cc9317adf951a90519c1 (patch)
treeeef1f4a1da941012f9dcfe06e3977a10414c896e /tracker-linux-joystick/ftnoir_tracker_linux_joystick_dialog.cpp
parent6d9e24c5b98f5b2cce01fa4d99255bbeff8ee2f1 (diff)
Add Linux Joystick Support
Add support for Linux joystick devices, this allows things like the EDTracker to work, and possibly other devices.
Diffstat (limited to 'tracker-linux-joystick/ftnoir_tracker_linux_joystick_dialog.cpp')
-rw-r--r--tracker-linux-joystick/ftnoir_tracker_linux_joystick_dialog.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/tracker-linux-joystick/ftnoir_tracker_linux_joystick_dialog.cpp b/tracker-linux-joystick/ftnoir_tracker_linux_joystick_dialog.cpp
new file mode 100644
index 00000000..1cf75bc1
--- /dev/null
+++ b/tracker-linux-joystick/ftnoir_tracker_linux_joystick_dialog.cpp
@@ -0,0 +1,40 @@
+#include "ftnoir_tracker_linux_joystick.h"
+#include "api/plugin-api.hpp"
+
+dialog_joystick::dialog_joystick() : tracker(nullptr)
+{
+ ui.setupUi( this );
+
+ // Connect Qt signals to member-functions
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
+
+ QList<::linux_joystick> joysticks = getJoysticks();
+
+ for (int i = 0; i < joysticks.size(); i++) {
+ ::linux_joystick joy = joysticks[i];
+ joys_.push_back(joys { joy.name, joy.device_id});
+ ui.joylist->addItem(QString("%1 | %2").arg(joy.dev).arg(joy.name));
+ if (joysticks[i].device_id == s.guid) ui.joylist->setCurrentIndex(i);
+ }
+
+ tie_setting(s.joy_1, ui.joy_1);
+ tie_setting(s.joy_2, ui.joy_2);
+ tie_setting(s.joy_3, ui.joy_3);
+ tie_setting(s.joy_4, ui.joy_4);
+ tie_setting(s.joy_5, ui.joy_5);
+ tie_setting(s.joy_6, ui.joy_6);
+}
+
+void dialog_joystick::doOK() {
+ int idx = ui.joylist->currentIndex();
+ static const joys def { {}, {} };
+ auto val = joys_.value(idx, def);
+ s.guid = val.guid;
+ s.b->save();
+ close();
+}
+
+void dialog_joystick::doCancel() {
+ close();
+}