From 926b2b16c8df2e7c54de10780860176d2277e9b1 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 6 Apr 2016 16:25:05 +0200 Subject: proto/ft: make clear registry path on quit optional Make clearing the dll path optional, defaulting to false. See previous commit. It has a side effect of games started before opentrack not seeing any dll path, and loading nothing. That is, opentrack only functions when tracking is started before a game is started. Issue: #332 --- proto-ft/ftnoir_ftcontrols.ui | 121 +++++++++++++++++++++++++-------- proto-ft/ftnoir_protocol_ft.cpp | 4 ++ proto-ft/ftnoir_protocol_ft.h | 6 +- proto-ft/ftnoir_protocol_ft_dialog.cpp | 1 + proto-ft/mutex.cpp | 14 +++- 5 files changed, 111 insertions(+), 35 deletions(-) mode change 100644 => 100755 proto-ft/ftnoir_ftcontrols.ui mode change 100644 => 100755 proto-ft/ftnoir_protocol_ft_dialog.cpp (limited to 'proto-ft') diff --git a/proto-ft/ftnoir_ftcontrols.ui b/proto-ft/ftnoir_ftcontrols.ui old mode 100644 new mode 100755 index 5356d2e5..b63d92a1 --- a/proto-ft/ftnoir_ftcontrols.ui +++ b/proto-ft/ftnoir_ftcontrols.ui @@ -12,8 +12,8 @@ 0 0 - 422 - 305 + 511 + 413 @@ -42,10 +42,47 @@ false + + + + + 0 + 0 + + + + Select interface + + + Qt::AlignJustify|Qt::AlignTop + + + false + + + + 9 + + + + + + + + Disable one of the protocols if game is confused by presence of both at the same time. + + + true + + + + + + - + 0 0 @@ -59,18 +96,24 @@ false - - + + + 9 + + - - Qt::RightToLeft + + + 0 + 0 + Memory hacks - + Only for very old and buggy old games such as CFS3. @@ -92,7 +135,7 @@ - + 0 0 @@ -106,18 +149,29 @@ false - - + + + 9 + + Locate DLL - + + + + 0 + 0 + + - Replace the registry entry if you want to use other software with the NPClient protocol and it doesn't work automatically. + Replace the registry entry if you want to use other software with the NPClient protocol and it doesn't work automatically. + +Starting tracking will again overwrite the DLL locations. true @@ -127,38 +181,45 @@ - + QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - + + - + 0 0 - Select interface - - - Qt::AlignJustify|Qt::AlignTop - - - false + Disable tracking for games on exit - - - + + + 9 + + + + + + 0 + 0 + + + + Disable on protocol exit + + - - + + - Disable one of the protocols if game is confused by presence of both at the same time. + Use this for games that disable mouselook when opentrack isn't running, and you're not running opentrack that much. true diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp index 134ffc53..121da494 100755 --- a/proto-ft/ftnoir_protocol_ft.cpp +++ b/proto-ft/ftnoir_protocol_ft.cpp @@ -16,6 +16,10 @@ FTNoIR_Protocol::FTNoIR_Protocol() : viewsStop(nullptr), intGameID(0) { + runonce_check->set_enabled(s.close_protocols_on_exit); + QObject::connect(&s.close_protocols_on_exit, + static_cast(&value::valueChanged), + [] (bool flag) -> void { runonce_check->set_enabled(flag); }); runonce_check->try_runonce(); } diff --git a/proto-ft/ftnoir_protocol_ft.h b/proto-ft/ftnoir_protocol_ft.h index 8940e5d8..b5b802bd 100755 --- a/proto-ft/ftnoir_protocol_ft.h +++ b/proto-ft/ftnoir_protocol_ft.h @@ -27,11 +27,12 @@ using namespace options; struct settings : opts { value intUsedInterface; - value useTIRViews; + value useTIRViews, close_protocols_on_exit; settings() : opts("proto-freetrack"), intUsedInterface(b, "used-interfaces", 0), - useTIRViews(b, "use-memory-hacks", false) + useTIRViews(b, "use-memory-hacks", false), + close_protocols_on_exit(b, "close-protocols-on-exit", false) {} }; @@ -45,6 +46,7 @@ struct runonce virtual void try_exit() = 0; virtual bool is_first_run() = 0; virtual ~runonce() {} + virtual void set_enabled(bool flag) = 0; }; class FTNoIR_Protocol : public IProtocol diff --git a/proto-ft/ftnoir_protocol_ft_dialog.cpp b/proto-ft/ftnoir_protocol_ft_dialog.cpp old mode 100644 new mode 100755 index 25f3a4cb..da00a03a --- a/proto-ft/ftnoir_protocol_ft_dialog.cpp +++ b/proto-ft/ftnoir_protocol_ft_dialog.cpp @@ -21,6 +21,7 @@ FTControls::FTControls() connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); tie_setting(s.useTIRViews, ui.chkTIRViews); + tie_setting(s.close_protocols_on_exit, ui.close_on_exit); ui.cbxSelectInterface->addItem("Enable both"); ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); diff --git a/proto-ft/mutex.cpp b/proto-ft/mutex.cpp index 0d50c9bd..34f5f518 100755 --- a/proto-ft/mutex.cpp +++ b/proto-ft/mutex.cpp @@ -5,6 +5,7 @@ class check_for_first_run : public runonce { bool checked_for_first_run; bool is_first_instance; + bool enabled; public: bool is_first_run() override @@ -12,11 +13,17 @@ public: return checked_for_first_run && is_first_instance; } + void set_enabled(bool flag) override + { + enabled = flag; + qDebug() << "ft runonce:" << "enabled" << flag; + } + void try_runonce() override { constexpr const char* name = "opentrack-freetrack-runonce"; - if (checked_for_first_run) + if (checked_for_first_run || !enabled) return; // just leak it, no issue @@ -44,7 +51,7 @@ public: void try_exit() override { - if (is_first_instance) + if (is_first_instance && enabled) { qDebug() << "ft runonce: removing registry keys"; FTNoIR_Protocol::set_protocols(false, false); @@ -52,9 +59,10 @@ public: } public: - check_for_first_run() : checked_for_first_run(false), is_first_instance(false) + check_for_first_run() : checked_for_first_run(false), is_first_instance(false), enabled(false) { } + ~check_for_first_run() { try_exit(); -- cgit v1.2.3