summaryrefslogtreecommitdiffhomepage
path: root/tracker-qt-gamepad/test.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-11-21 11:09:37 +0100
committerStanislaw Halik <sthalik@misaki.pl>2016-11-21 11:09:37 +0100
commitda9c3080111b0cd31b48696c3c67ac46e4843ee8 (patch)
tree8cbc3146bffa1b3ea76c388bc377b010663a863b /tracker-qt-gamepad/test.cpp
parentdaa0cc1348c40d7f654621f6a82b01934129a79f (diff)
tracker/qt-gamepad: add stub
Diffstat (limited to 'tracker-qt-gamepad/test.cpp')
-rw-r--r--tracker-qt-gamepad/test.cpp99
1 files changed, 99 insertions, 0 deletions
diff --git a/tracker-qt-gamepad/test.cpp b/tracker-qt-gamepad/test.cpp
new file mode 100644
index 00000000..4f2c8daa
--- /dev/null
+++ b/tracker-qt-gamepad/test.cpp
@@ -0,0 +1,99 @@
+/* Copyright (c) 2014, 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.
+ */
+
+#include "test.h"
+#include "api/plugin-api.hpp"
+#include <cmath>
+
+#include <QDebug>
+
+const double gamepad_tracker::incr[6] =
+{
+ 50, 40, 80,
+ 70, 5, 3
+};
+
+gamepad_tracker::gamepad_tracker() :
+ last_x { 0, 0, 0, 0, 0, 0 }
+{
+}
+
+gamepad_tracker::~gamepad_tracker()
+{
+}
+
+void gamepad_tracker::start_tracker(QFrame*)
+{
+ t.start();
+}
+
+#ifdef EMIT_NAN
+# include <cstdlib>
+#endif
+
+void gamepad_tracker::data(double *data)
+{
+ using std::fmod;
+ using std::sin;
+ using std::fabs;
+ using std::copysign;
+
+ const double dt = t.elapsed_seconds();
+ t.start();
+
+#ifdef EMIT_NAN
+ if ((rand()%4) == 0)
+ {
+ for (int i = 0; i < 6; i++)
+ data[i] = 0./0.;
+ }
+ else
+#endif
+ for (int i = 0; i < 6; i++)
+ {
+ double x = fmod(last_x[i] + incr[i] * d2r * dt, 2 * M_PI);
+ last_x[i] = x;
+
+ if (i >= 3)
+ {
+#ifdef DISCONTINUITY
+ if (x > pi + pi/2)
+ x -= M_PI;
+ else if (x > pi/2 && x < pi)
+ x += M_PI;
+#endif
+
+ data[i] = sin(x) * 180;
+ }
+ else
+ {
+ data[i] = sin(x) * 100;
+ }
+ }
+}
+
+gamepad_dialog::gamepad_dialog()
+{
+ ui.setupUi(this);
+
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
+}
+
+void gamepad_dialog::doOK()
+{
+ //s.b->save();
+ close();
+}
+
+void gamepad_dialog::doCancel()
+{
+ close();
+}
+
+OPENTRACK_DECLARE_TRACKER(gamepad_tracker, gamepad_dialog, gamepad_metadata)