summaryrefslogtreecommitdiffhomepage
path: root/logic
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-03-10 18:09:07 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-03-10 18:35:13 +0100
commit96ac77abb5c4f8cd22135034c8a1270cf946ceca (patch)
treed27b71df408b924c1e93e1b5c7066c1a5674fbbc /logic
parentae1913228833d10b66636f2ff4d2b7ecc70ef142 (diff)
logic/pipeline: implement held center
Requested by: CAHEK on the Russian IL-2 Sturmovik forum
Diffstat (limited to 'logic')
-rw-r--r--logic/pipeline.cpp12
-rw-r--r--logic/pipeline.hpp8
-rw-r--r--logic/shortcuts.h4
-rw-r--r--logic/work.cpp5
4 files changed, 23 insertions, 6 deletions
diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp
index 494d93ff..9b490f44 100644
--- a/logic/pipeline.cpp
+++ b/logic/pipeline.cpp
@@ -305,7 +305,7 @@ void pipeline::maybe_set_center_pose(const Pose& value, bool own_center_logic)
//scaled_rotation.rotation = euler_to_rmat(c_div * tmp);
rotation.rotation = euler_to_rmat(tmp);
- if (get(f_center))
+ if (get(f_center | f_held_center))
{
if (libs.pFilter)
libs.pFilter->center();
@@ -449,7 +449,7 @@ void pipeline::logic()
logger.reset_dt();
// we must center prior to getting data from the tracker
- const bool center_ordered = get(f_center) && tracking_started;
+ const bool center_ordered = get(f_center | f_held_center) && tracking_started;
const bool own_center_logic = center_ordered && libs.pTracker->center();
Pose value, raw;
@@ -623,6 +623,11 @@ void pipeline::raw_and_mapped_pose(double* mapped, double* raw) const
void pipeline::set_center() { set(f_center, true); }
+void pipeline::set_held_center(bool value)
+{
+ set(f_held_center, value);
+}
+
void pipeline::set_enabled(bool value) { set(f_enabled_h, value); }
void pipeline::set_zero(bool value) { set(f_zero, value); }
@@ -661,7 +666,7 @@ void bits::negate(flags flag_)
}
}
-bool bits::get(flags flag)
+bool bits::get(unsigned flag)
{
return !!(b & flag);
}
@@ -669,6 +674,7 @@ bool bits::get(flags flag)
bits::bits() : b(0u)
{
set(f_center, true);
+ set(f_held_center, false);
set(f_enabled_p, true);
set(f_enabled_h, true);
set(f_zero, false);
diff --git a/logic/pipeline.hpp b/logic/pipeline.hpp
index 7132a36b..f71a8963 100644
--- a/logic/pipeline.hpp
+++ b/logic/pipeline.hpp
@@ -73,9 +73,10 @@ struct OTR_LOGIC_EXPORT bits
{
enum flags : unsigned {
f_center = 1 << 0,
- f_enabled_h = 1 << 1,
- f_enabled_p = 1 << 2,
- f_zero = 1 << 3,
+ f_held_center = 1 << 1,
+ f_enabled_h = 1 << 2,
+ f_enabled_p = 1 << 3,
+ f_zero = 1 << 4,
};
std::atomic<unsigned> b;
@@ -149,6 +150,7 @@ public:
void toggle_enabled();
void set_center();
+ void set_held_center(bool value);
void set_enabled(bool value);
void set_zero(bool value);
};
diff --git a/logic/shortcuts.h b/logic/shortcuts.h
index 046e68de..dc62ba63 100644
--- a/logic/shortcuts.h
+++ b/logic/shortcuts.h
@@ -24,6 +24,10 @@
#include <vector>
#include <functional>
+#if !defined __APPLE__
+# define OTR_HAS_KEY_UP_SUPPORT
+#endif
+
namespace shortcuts_impl {
using namespace options;
diff --git a/logic/work.cpp b/logic/work.cpp
index 11ec9912..99e4f709 100644
--- a/logic/work.cpp
+++ b/logic/work.cpp
@@ -65,8 +65,13 @@ Work::Work(Mappings& m, event_handler& ev, QFrame* frame, std::shared_ptr<dylib
tracker(std::make_shared<pipeline>(m, libs, ev, *logger)),
sc(std::make_shared<Shortcuts>()),
keys {
+#if defined OTR_HAS_KEY_UP_SUPPORT
+ key_tuple(s.key_center1, [&](bool x) { tracker->set_held_center(x); }, false),
+ key_tuple(s.key_center2, [&](bool x) { tracker->set_held_center(x); }, false),
+#else
key_tuple(s.key_center1, [&](bool) { tracker->set_center(); }, true),
key_tuple(s.key_center2, [&](bool) { tracker->set_center(); }, true),
+#endif
key_tuple(s.key_toggle1, [&](bool) { tracker->toggle_enabled(); }, true),
key_tuple(s.key_toggle2, [&](bool) { tracker->toggle_enabled(); }, true),