summaryrefslogtreecommitdiffhomepage
path: root/trackmouse
diff options
context:
space:
mode:
Diffstat (limited to 'trackmouse')
-rw-r--r--trackmouse/CMakeLists.txt9
-rw-r--r--trackmouse/images/start.pngbin0 -> 1400 bytes
-rw-r--r--trackmouse/images/stop.pngbin0 -> 5790 bytes
-rw-r--r--trackmouse/lang/nl_NL.ts74
-rw-r--r--trackmouse/lang/ru_RU.ts74
-rw-r--r--trackmouse/lang/stub.ts74
-rw-r--r--trackmouse/lang/zh_CN.ts74
-rw-r--r--trackmouse/main.cpp18
-rw-r--r--trackmouse/trackmouse-res.qrc6
-rw-r--r--trackmouse/trackmouse-settings.cpp132
-rw-r--r--trackmouse/trackmouse.icobin0 -> 67134 bytes
-rw-r--r--trackmouse/trackmouse.rc2
-rw-r--r--trackmouse/window.cpp388
-rw-r--r--trackmouse/window.hpp94
-rw-r--r--trackmouse/window.ui458
15 files changed, 1403 insertions, 0 deletions
diff --git a/trackmouse/CMakeLists.txt b/trackmouse/CMakeLists.txt
new file mode 100644
index 00000000..6240d4b3
--- /dev/null
+++ b/trackmouse/CMakeLists.txt
@@ -0,0 +1,9 @@
+otr_module(executable EXECUTABLE BIN)
+
+set_target_properties(opentrack-executable PROPERTIES
+ SUFFIX "${opentrack-binary-suffix}"
+ OUTPUT_NAME "trackmouse"
+ PREFIX ""
+)
+
+target_link_libraries(${self} opentrack-user-interface opentrack-version)
diff --git a/trackmouse/images/start.png b/trackmouse/images/start.png
new file mode 100644
index 00000000..b8e6f271
--- /dev/null
+++ b/trackmouse/images/start.png
Binary files differ
diff --git a/trackmouse/images/stop.png b/trackmouse/images/stop.png
new file mode 100644
index 00000000..0ff13bd5
--- /dev/null
+++ b/trackmouse/images/stop.png
Binary files differ
diff --git a/trackmouse/lang/nl_NL.ts b/trackmouse/lang/nl_NL.ts
new file mode 100644
index 00000000..92f790af
--- /dev/null
+++ b/trackmouse/lang/nl_NL.ts
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="nl_NL">
+<context>
+ <name>main_window</name>
+ <message>
+ <source>The Octopus is sad</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source> :: </source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Check permissions for your .ini directory:
+
+%1&quot;%2
+
+Exiting now.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>window</name>
+ <message>
+ <source>trackmouse prototype</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Keyboard shortcuts</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>start/stop tracking</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F10</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>center</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F11</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F12</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Sensitivity</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>100%</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Start</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Stop</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>freeze toggle</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/trackmouse/lang/ru_RU.ts b/trackmouse/lang/ru_RU.ts
new file mode 100644
index 00000000..dd9011c4
--- /dev/null
+++ b/trackmouse/lang/ru_RU.ts
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1" language="ru_RU">
+<context>
+ <name>main_window</name>
+ <message>
+ <source>The Octopus is sad</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source> :: </source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Check permissions for your .ini directory:
+
+%1&quot;%2
+
+Exiting now.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>window</name>
+ <message>
+ <source>trackmouse prototype</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Keyboard shortcuts</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>start/stop tracking</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F10</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>center</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F11</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F12</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Sensitivity</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>100%</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Start</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Stop</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>freeze toggle</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/trackmouse/lang/stub.ts b/trackmouse/lang/stub.ts
new file mode 100644
index 00000000..968e31c5
--- /dev/null
+++ b/trackmouse/lang/stub.ts
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1">
+<context>
+ <name>main_window</name>
+ <message>
+ <source>The Octopus is sad</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source> :: </source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Check permissions for your .ini directory:
+
+%1&quot;%2
+
+Exiting now.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>window</name>
+ <message>
+ <source>trackmouse prototype</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Keyboard shortcuts</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>start/stop tracking</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F10</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>center</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F11</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F12</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Sensitivity</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>100%</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Start</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Stop</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>freeze toggle</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/trackmouse/lang/zh_CN.ts b/trackmouse/lang/zh_CN.ts
new file mode 100644
index 00000000..968e31c5
--- /dev/null
+++ b/trackmouse/lang/zh_CN.ts
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1">
+<context>
+ <name>main_window</name>
+ <message>
+ <source>The Octopus is sad</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source> :: </source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Check permissions for your .ini directory:
+
+%1&quot;%2
+
+Exiting now.</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>window</name>
+ <message>
+ <source>trackmouse prototype</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Keyboard shortcuts</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>start/stop tracking</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F10</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>center</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F11</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Alt+F12</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Sensitivity</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>100%</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Start</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>Stop</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <source>freeze toggle</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/trackmouse/main.cpp b/trackmouse/main.cpp
new file mode 100644
index 00000000..2313e1ac
--- /dev/null
+++ b/trackmouse/main.cpp
@@ -0,0 +1,18 @@
+#include "gui/init.hpp"
+#include "window.hpp"
+
+#if defined _WIN32
+# include <windows.h>
+#endif
+
+int main(int argc, char** argv)
+{
+ return run_application(argc, argv, []() { return new main_window; });
+}
+
+#if defined _MSC_VER
+int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR, int /* nCmdShow */)
+{
+ return main(__argc, __argv);
+}
+#endif
diff --git a/trackmouse/trackmouse-res.qrc b/trackmouse/trackmouse-res.qrc
new file mode 100644
index 00000000..f351b3f2
--- /dev/null
+++ b/trackmouse/trackmouse-res.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/images">
+ <file>images/start.png</file>
+ <file>images/stop.png</file>
+ </qresource>
+</RCC>
diff --git a/trackmouse/trackmouse-settings.cpp b/trackmouse/trackmouse-settings.cpp
new file mode 100644
index 00000000..45ec36a5
--- /dev/null
+++ b/trackmouse/trackmouse-settings.cpp
@@ -0,0 +1,132 @@
+#include "logic/main-settings.hpp"
+#include "logic/mappings.hpp"
+
+#include "tracker-pt/pt-settings.hpp"
+#include "filter-accela/accela-settings.hpp"
+#include "proto-mouse/mouse-settings.hpp"
+
+#include "options/options.hpp"
+
+#include <QSettings>
+
+using namespace options;
+
+static void force_spline_settings()
+{
+ main_settings main;
+
+ axis_opts** all_axis_opts = main.all_axis_opts;
+ Mappings mappings { all_axis_opts };
+
+ for (unsigned k = 0; k < 6; k++)
+ {
+ Map& map = mappings(k);
+ const QString& prefix = all_axis_opts[k]->prefix();
+
+ const QString& name1 = map.name;
+ const QString& name2 = map.alt_name;
+
+ bundle b = make_bundle(prefix);
+
+ spline_detail::settings s1(b, name1, Axis(k));
+ spline_detail::settings s2(b, name2, Axis(k));
+
+ s1.points = QList<QPointF> { { 180, 180 } };
+ s2.points = QList<QPointF> { { 180, 180 } };
+
+ b->save();
+ }
+}
+
+static void force_main_settings()
+{
+ main_settings s;
+ s.center_at_startup = true;
+ s.reltrans_mode = reltrans_disabled;
+ s.neck_enable = false;
+
+ module_settings m;
+
+ m.tracker_dll = "pt";
+ m.protocol_dll = "win32-mouse";
+ m.filter_dll = "accela";
+
+ s.b->save();
+ s.b_map->save();
+}
+
+static void force_pt_settings()
+{
+ pt_settings s("tracker-pt");
+
+ enum { Clip = 0 };
+
+ s.active_model_panel = Clip;
+ // XXX TODO these are Mini Clip Right sizes
+ s.clip_by = 60;
+ s.clip_bz = 38.2;
+ s.clip_ty = 42.2;
+ s.clip_tz = 12.6;
+
+ s.cam_fps = 60;
+ s.cam_res_x = 640;
+ s.cam_res_y = 480;
+ s.camera_name = "PS3Eye Camera";
+
+ s.min_point_size = 3.7;
+ s.max_point_size = 10;
+
+ // XXX TODO auto threshold slider position
+ s.auto_threshold = true;
+ s.threshold_slider = slider_value(82., s.threshold_slider->min(), s.threshold_slider->max());
+
+ s.t_MH_x = 0, s.t_MH_y = 0, s.t_MH_z = 0;
+ s.blob_color = pt_color_natural;
+ s.fov = 56;
+ s.dynamic_pose = false;
+
+ s.b->save();
+}
+
+static void force_mouse_settings()
+{
+
+ mouse_settings s;
+
+ s.Mouse_X = Yaw + 1;
+ s.Mouse_Y = Pitch + 1;
+
+ s.b->save();
+}
+
+static void force_accela_settings()
+{
+ // XXX TODO
+}
+
+static void force_shortcut_settings()
+{
+ main_settings s;
+ s.key_toggle_tracking1.keycode = "Ins";
+ s.key_center1.keycode = "PgUp";
+ s.key_toggle1.keycode = "PgDown";
+
+ for (key_opts* k : { &s.key_toggle_tracking1, &s.key_center1, &s.key_toggle_press1 })
+ {
+ k->button = -1;
+ k->guid = {};
+ }
+ s.b->save();
+}
+
+void force_trackmouse_settings()
+{
+ options::globals::with_settings_object([](QSettings&) {
+ force_main_settings();
+ force_spline_settings();
+ force_pt_settings();
+ force_mouse_settings();
+ force_accela_settings();
+ force_shortcut_settings();
+ });
+}
diff --git a/trackmouse/trackmouse.ico b/trackmouse/trackmouse.ico
new file mode 100644
index 00000000..5cac8da1
--- /dev/null
+++ b/trackmouse/trackmouse.ico
Binary files differ
diff --git a/trackmouse/trackmouse.rc b/trackmouse/trackmouse.rc
new file mode 100644
index 00000000..8df1e9b1
--- /dev/null
+++ b/trackmouse/trackmouse.rc
@@ -0,0 +1,2 @@
+#include <windows.h>
+IDI_ICON1 ICON "trackmouse.ico"
diff --git a/trackmouse/window.cpp b/trackmouse/window.cpp
new file mode 100644
index 00000000..d6c8a8dd
--- /dev/null
+++ b/trackmouse/window.cpp
@@ -0,0 +1,388 @@
+/* Copyright (c) 2013-2018, 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 "window.hpp"
+#include "options/options.hpp"
+#include "migration/migration.hpp"
+#include "compat/check-visible.hpp"
+#include "compat/sleep.hpp"
+#include "compat/macros.hpp"
+#include "compat/library-path.hpp"
+#include "compat/math.hpp"
+
+#include <algorithm>
+#include <iterator>
+#include <utility>
+
+#include <QMessageBox>
+#include <QDir>
+#include <QFile>
+#include <QString>
+#include <QList>
+#include <QEventLoop>
+#include <QApplication>
+
+extern "C" const char* const opentrack_version;
+
+using namespace options::globals;
+using namespace options;
+
+#if !defined EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+#endif
+
+#if !defined EXIT_FAILURE
+# define EXIT_FAILURE 1
+#endif
+
+/* FreeBSD sysexits(3)
+ *
+ * The input data was incorrect in some way. This
+ * should only be used for user's data and not system
+ * files.
+ */
+
+#if !defined EX_OSFILE
+# define EX_OSFILE 72
+#endif
+
+void force_trackmouse_settings();
+
+main_window::main_window() : State(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH)
+{
+ ui.setupUi(this);
+
+ update_button_state(false, false);
+
+ // ctrl+q exits
+ connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit()));
+
+ if (!set_profile())
+ {
+ die_on_config_not_writable();
+ exit(EX_OSFILE);
+ return;
+ }
+
+ // only tie and connect main screen options after migrations are done
+ // below is fine, set_profile() is called already
+
+ connect(this, &main_window::start_tracker,
+ this, [&] { qDebug() << "start tracker"; start_tracker_(); },
+ Qt::QueuedConnection);
+
+ connect(this, &main_window::stop_tracker,
+ this, [&] { qDebug() << "stop tracker"; stop_tracker_(); },
+ Qt::QueuedConnection);
+
+ connect(this, &main_window::toggle_tracker,
+ this, [&] { qDebug() << "toggle tracker"; toggle_tracker_(); },
+ Qt::QueuedConnection);
+
+ connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(start_tracker_()));
+ connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stop_tracker_()));
+
+ {
+ tie_setting(mouse.sensitivity_x, ui.sensitivity_slider);
+ tie_setting(mouse.sensitivity_x, ui.sensitivity_label,
+ [](double x) { return QString::number(x) + QStringLiteral("%"); });
+ // one-way only
+ tie_setting(mouse.sensitivity_x, this,
+ [this](double x) { mouse.sensitivity_y = *mouse.sensitivity_x; });
+
+ // no "ok" button, gotta save on timer
+ auto save = [this] {
+ qDebug() << "trackmouse: saving settings";
+ mouse.b->save();
+ save_settings_timer.stop();
+ };
+
+ auto start_save_timer = [this](double) {
+ save_settings_timer.start();
+ };
+
+ save_settings_timer.setInterval(save_settings_interval_ms);
+ save_settings_timer.setSingleShot(true);
+
+ ui.sensitivity_slider->setTracking(false);
+ connect(&save_settings_timer, &QTimer::timeout, this, save, Qt::DirectConnection);
+#if 1
+ // this doesn't fire the timer on application load
+ connect(ui.sensitivity_slider, &QSlider::valueChanged, this, start_save_timer, Qt::DirectConnection);
+#else
+ // but this does so let's not not use it
+ tie_setting(mouse.sensitivity_x, this, start_save_timer);
+#endif
+ }
+
+ force_trackmouse_settings();
+
+ register_shortcuts();
+ kbd_quit.setEnabled(true);
+
+ setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | windowFlags());
+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ adjustSize();
+
+ setVisible(true);
+ show();
+}
+
+void main_window::register_shortcuts()
+{
+ global_shortcuts.reload({
+ { s.key_toggle_tracking1, [this](bool) { main_window::toggle_tracker(); }, true },
+ });
+
+ if (work)
+ work->reload_shortcuts();
+}
+
+void main_window::die_on_config_not_writable()
+{
+ stop_tracker_();
+
+ static const QString pad(16, QChar(' '));
+
+ QMessageBox::critical(this,
+ tr("The Octopus is sad"),
+ tr("Check permissions for your .ini directory:\n\n%1\"%2\n\n"
+ "Exiting now."
+ ).arg(ini_directory(), pad),
+ QMessageBox::Close, QMessageBox::NoButton);
+
+ exit(EX_OSFILE);
+}
+
+bool main_window::maybe_die_on_config_not_writable(const QString& current)
+{
+ const bool writable =
+ with_settings_object([&](QSettings& s) {
+ return s.isWritable();
+ });
+
+ if (writable)
+ return false;
+
+ if (!QFile(ini_combine(current)).open(QFile::ReadWrite))
+ {
+ die_on_config_not_writable();
+ return true;
+ }
+
+ return false;
+}
+
+main_window::~main_window()
+{
+ // stupid ps3 eye has LED issues
+ if (work)
+ {
+ stop_tracker_();
+ close();
+
+ constexpr int inc = 100, max = 2000;
+
+ for (int k = 0; k < max; k += inc)
+ {
+ QEventLoop ev;
+ ev.processEvents();
+ portable::sleep(inc);
+ }
+ }
+
+ exit();
+}
+
+void main_window::set_working_directory()
+{
+ QDir::setCurrent(OPENTRACK_BASE_PATH);
+}
+
+void main_window::save_modules()
+{
+ m.b->save();
+}
+
+std::tuple<main_window::dylib_ptr, int>
+main_window::module_by_name(const QString& name, Modules::dylib_list& list)
+{
+ auto it = std::find_if(list.cbegin(), list.cend(), [&name](const dylib_ptr& lib) {
+ if (!lib)
+ return name.isEmpty();
+ else
+ return name == lib->module_name;
+ });
+
+ if (it == list.cend())
+ return { nullptr, -1 };
+ else
+ return { *it, std::distance(list.cbegin(), it) };
+}
+
+main_window::dylib_ptr main_window::current_tracker()
+{
+ auto [ptr, idx] = module_by_name(m.tracker_dll, modules.trackers());
+ return ptr;
+}
+
+main_window::dylib_ptr main_window::current_protocol()
+{
+ auto [ptr, idx] = module_by_name(m.protocol_dll, modules.protocols());
+ return ptr;
+}
+
+main_window::dylib_ptr main_window::current_filter()
+{
+ auto [ptr, idx] = module_by_name(m.filter_dll, modules.filters());
+ return ptr;
+}
+
+void main_window::update_button_state(bool running, bool inertialp)
+{
+ bool not_running = !running;
+#if 0
+ ui.iconcomboProfile->setEnabled(not_running);
+ ui.btnStartTracker->setEnabled(not_running);
+ ui.btnStopTracker->setEnabled(running);
+ ui.iconcomboProtocol->setEnabled(not_running);
+ ui.iconcomboFilter->setEnabled(not_running);
+ ui.iconcomboTrackerSource->setEnabled(not_running);
+ ui.profile_button->setEnabled(not_running);
+#endif
+ ui.video_frame_label->setVisible(not_running || inertialp);
+ if(not_running)
+ {
+ ui.video_frame_label->setPixmap(QPixmap(":/images/tracking-not-started.png"));
+ }
+ else {
+ ui.video_frame_label->setPixmap(QPixmap(":/images/no-feed.png"));
+ }
+}
+
+void main_window::start_tracker_()
+{
+ if (work)
+ return;
+
+ work = std::make_shared<Work>(pose, ev, ui.video_frame, current_tracker(), current_protocol(), current_filter());
+
+ if (!work->is_ok())
+ {
+ work = nullptr;
+ return;
+ }
+
+ if (pTrackerDialog)
+ pTrackerDialog->register_tracker(work->libs.pTracker.get());
+
+ if (pFilterDialog)
+ pFilterDialog->register_filter(work->libs.pFilter.get());
+
+ if (pProtocolDialog)
+ pProtocolDialog->register_protocol(work->libs.pProtocol.get());
+
+ // NB check valid since SelectedLibraries ctor called
+ // trackers take care of layout state updates
+ const bool is_inertial = ui.video_frame->layout() == nullptr;
+ update_button_state(true, is_inertial);
+
+ ui.btnStopTracker->setFocus();
+}
+
+void main_window::stop_tracker_()
+{
+ if (!work)
+ return;
+
+ with_tracker_teardown sentinel;
+
+ if (pTrackerDialog)
+ pTrackerDialog->unregister_tracker();
+
+ if (pProtocolDialog)
+ pProtocolDialog->unregister_protocol();
+
+ if (pFilterDialog)
+ pFilterDialog->unregister_filter();
+
+ work = nullptr;
+
+ update_button_state(false, false);
+ set_title();
+ ui.btnStartTracker->setFocus();
+}
+
+void main_window::set_title(const QString& game_title)
+{
+ static const QString version{opentrack_version};
+ static const QString sep { tr(" :: ") };
+ static const QString pat1{ version + sep + "%1" + sep + "%2" };
+ static const QString pat2{ version + sep + "%1" };
+
+ const QString current = ini_filename();
+
+ if (game_title.isEmpty())
+ setWindowTitle(pat2.arg(current));
+ else
+ setWindowTitle(pat1.arg(current, game_title));
+}
+
+void main_window::exit(int status)
+{
+ if (exiting_already)
+ return;
+ exiting_already = true;
+
+ qDebug() << "trackmouse: saving settings on app exit";
+ save_settings_timer.stop();
+ mouse.b->save();
+
+ //close();
+ QApplication::setQuitOnLastWindowClosed(true);
+ QApplication::exit(status);
+}
+
+bool main_window::set_profile()
+{
+ if (maybe_die_on_config_not_writable(OPENTRACK_DEFAULT_CONFIG))
+ return false;
+
+ set_profile_in_registry();
+
+ options::detail::bundler::refresh_all_bundles();
+
+ // migrations are for config layout changes and other user-visible
+ // incompatibilities in future versions
+ run_migrations();
+
+ set_title();
+
+ return true;
+}
+
+void main_window::closeEvent(QCloseEvent*)
+{
+ exit();
+}
+
+void main_window::set_profile_in_registry()
+{
+ with_global_settings_object([&](QSettings& s) {
+ s.setValue(OPENTRACK_CONFIG_FILENAME_KEY, OPENTRACK_DEFAULT_CONFIG);
+ });
+}
+
+void main_window::toggle_tracker_()
+{
+ qDebug() << "toggle tracker";
+ if (work)
+ stop_tracker_();
+ else
+ start_tracker_();
+}
diff --git a/trackmouse/window.hpp b/trackmouse/window.hpp
new file mode 100644
index 00000000..2c196852
--- /dev/null
+++ b/trackmouse/window.hpp
@@ -0,0 +1,94 @@
+#pragma once
+
+/* Copyright (c) 2013-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_window.h"
+#include "proto-mouse/mouse-settings.hpp"
+
+#include "api/plugin-support.hpp"
+#include "logic/main-settings.hpp"
+#include "logic/pipeline.hpp"
+#include "logic/shortcuts.h"
+#include "logic/work.hpp"
+#include "logic/state.hpp"
+#include "options/options.hpp"
+
+#include <tuple>
+#include <memory>
+
+#include <QMainWindow>
+#include <QKeySequence>
+#include <QShortcut>
+#include <QPixmap>
+#include <QTimer>
+#include <QString>
+
+class main_window final : public QMainWindow, private State
+{
+ Q_OBJECT
+
+ Ui::window ui;
+
+ QTimer save_settings_timer { this };
+
+ Shortcuts global_shortcuts;
+ module_settings m;
+ mouse_settings mouse;
+
+ QShortcut kbd_quit { QKeySequence("Ctrl+Q"), this };
+ std::unique_ptr<IFilterDialog> pFilterDialog;
+ std::unique_ptr<IProtocolDialog> pProtocolDialog;
+ std::unique_ptr<ITrackerDialog> pTrackerDialog;
+ bool exiting_already { false };
+
+ using dylib_ptr = Modules::dylib_ptr;
+ using dylib_list = Modules::dylib_list;
+
+ static std::tuple<dylib_ptr, int> module_by_name(const QString& name, Modules::dylib_list& list);
+
+ dylib_ptr current_tracker();
+ dylib_ptr current_protocol();
+ dylib_ptr current_filter();
+
+ void update_button_state(bool running, bool inertialp);
+
+ void set_title(const QString& game_title = QString());
+
+ void set_profile_in_registry();
+ void register_shortcuts();
+
+ void closeEvent(QCloseEvent *event) override;
+
+ bool maybe_die_on_config_not_writable(const QString& current);
+ void die_on_config_not_writable();
+
+ static constexpr int save_settings_interval_ms = 2500;
+
+private slots:
+ void save_modules();
+ void exit(int status = EXIT_SUCCESS);
+ bool set_profile();
+
+ void start_tracker_();
+ void stop_tracker_();
+ void toggle_tracker_();
+
+ static void set_working_directory();
+
+signals:
+ void start_tracker();
+ void stop_tracker();
+ void toggle_tracker();
+
+public:
+ main_window();
+ ~main_window() override;
+};
diff --git a/trackmouse/window.ui b/trackmouse/window.ui
new file mode 100644
index 00000000..c79ae846
--- /dev/null
+++ b/trackmouse/window.ui
@@ -0,0 +1,458 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>window</class>
+ <widget class="QMainWindow" name="window">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>755</width>
+ <height>240</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>240</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>trackmouse prototype</string>
+ </property>
+ <widget class="QWidget" name="frame">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>240</height>
+ </size>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>12</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QFrame" name="video_feed">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>320</width>
+ <height>240</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>320</width>
+ <height>240</height>
+ </size>
+ </property>
+ <widget class="QFrame" name="video_frame">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>240</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>320</width>
+ <height>240</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>320</width>
+ <height>240</height>
+ </size>
+ </property>
+ <widget class="QLabel" name="video_frame_label">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>240</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>320</width>
+ <height>240</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>320</width>
+ <height>240</height>
+ </size>
+ </property>
+ <property name="font">
+ <font>
+ <family>Candara</family>
+ <pointsize>37</pointsize>
+ <weight>50</weight>
+ <bold>false</bold>
+ <kerning>true</kerning>
+ </font>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="pixmap">
+ <pixmap resource="../../gui/opentrack-res.qrc">:/images/tracking-not-started.png</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" name="widget_3" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="spacing">
+ <number>12</number>
+ </property>
+ <property name="leftMargin">
+ <number>8</number>
+ </property>
+ <property name="topMargin">
+ <number>12</number>
+ </property>
+ <property name="rightMargin">
+ <number>12</number>
+ </property>
+ <property name="bottomMargin">
+ <number>12</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="groupBox_3">
+ <property name="title">
+ <string>Keyboard shortcuts</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>12</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ <stylestrategy>PreferAntialias</stylestrategy>
+ <kerning>false</kerning>
+ </font>
+ </property>
+ <property name="text">
+ <string>start/stop tracking</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>12</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ <stylestrategy>PreferAntialias</stylestrategy>
+ <kerning>false</kerning>
+ </font>
+ </property>
+ <property name="text">
+ <string>Insert</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>12</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ <stylestrategy>PreferAntialias</stylestrategy>
+ <kerning>false</kerning>
+ </font>
+ </property>
+ <property name="text">
+ <string>center</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>12</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ <stylestrategy>PreferAntialias</stylestrategy>
+ <kerning>false</kerning>
+ </font>
+ </property>
+ <property name="text">
+ <string>Page Up</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>12</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ <stylestrategy>PreferAntialias</stylestrategy>
+ <kerning>false</kerning>
+ </font>
+ </property>
+ <property name="text">
+ <string>freeze toggle</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="label_7">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>12</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ <stylestrategy>PreferAntialias</stylestrategy>
+ <kerning>false</kerning>
+ </font>
+ </property>
+ <property name="text">
+ <string>Page Down</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Sensitivity</string>
+ </property>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QSlider" name="sensitivity_slider">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Maximum">
+ <horstretch>10</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximum">
+ <number>475</number>
+ </property>
+ <property name="pageStep">
+ <number>1</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TicksAbove</enum>
+ </property>
+ <property name="tickInterval">
+ <number>50</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="sensitivity_label">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>2</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>100%</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QWidget" name="widget" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="topMargin">
+ <number>3</number>
+ </property>
+ <property name="bottomMargin">
+ <number>3</number>
+ </property>
+ <item>
+ <widget class="QCommandLinkButton" name="btnStartTracker">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Start</string>
+ </property>
+ <property name="icon">
+ <iconset resource="trackmouse-res.qrc">
+ <normaloff>:/images/images/start.png</normaloff>:/images/images/start.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>43</width>
+ <height>20</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCommandLinkButton" name="btnStopTracker">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Stop</string>
+ </property>
+ <property name="icon">
+ <iconset resource="trackmouse-res.qrc">
+ <normaloff>:/images/images/stop.png</normaloff>:/images/images/stop.png</iconset>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <resources>
+ <include location="trackmouse-res.qrc"/>
+ <include location="../../gui/opentrack-res.qrc"/>
+ </resources>
+ <connections/>
+</ui>