summaryrefslogtreecommitdiffhomepage
path: root/logic
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-05-30 02:32:23 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-05-30 02:32:23 +0200
commitc52b5ad0a8340012fab7982f0c670a46c3e5d93d (patch)
treeb54b567b006d4f2981285e320845dc1e05e47ff5 /logic
parent5b819219889e78093e0dd32615adb6dcdc66cbcb (diff)
logic/tracker: allow for "hold-toggle" hold-enable
Must press "keypress-toggle" to toggle (uh) that mode.
Diffstat (limited to 'logic')
-rw-r--r--logic/tracker.cpp13
-rw-r--r--logic/tracker.h21
2 files changed, 21 insertions, 13 deletions
diff --git a/logic/tracker.cpp b/logic/tracker.cpp
index e09000e2..1a37a8a1 100644
--- a/logic/tracker.cpp
+++ b/logic/tracker.cpp
@@ -132,7 +132,7 @@ void Tracker::logic()
Pose tmp;
libs.pTracker->data(tmp);
- if (get(f_enabled))
+ if (get(f_enabled_p) ^ !get(f_enabled_h))
for (int i = 0; i < 6; i++)
newpose[i] = elide_nan(tmp(i), newpose(i));
}
@@ -445,6 +445,14 @@ void Tracker::raw_and_mapped_pose(double* mapped, double* raw) const
}
}
+void Tracker::center() { set(f_center, true); }
+
+void Tracker::set_toggle(bool value) { set(f_enabled_h, value); }
+void Tracker::set_zero(bool value) { set(f_zero, value); }
+
+void Tracker::zero() { negate(f_zero); }
+void Tracker::toggle_enabled() { negate(f_enabled_p); }
+
void bits::set(bits::flags flag_, bool val_)
{
@@ -486,7 +494,8 @@ bool bits::get(bits::flags flag)
bits::bits() : b(0u)
{
set(f_center, true);
- set(f_enabled, true);
+ set(f_enabled_p, true);
+ set(f_enabled_h, true);
set(f_zero, false);
set(f_should_quit, false);
}
diff --git a/logic/tracker.h b/logic/tracker.h
index 2e6350d7..79961378 100644
--- a/logic/tracker.h
+++ b/logic/tracker.h
@@ -35,11 +35,12 @@ using Pose = Mat<double, 6, 1>;
struct bits
{
- enum flags {
+ enum flags : unsigned {
f_center = 1 << 0,
- f_enabled = 1 << 1,
- f_zero = 1 << 2,
- f_should_quit = 1 << 3,
+ f_enabled_h = 1 << 1,
+ f_enabled_p = 1 << 2,
+ f_zero = 1 << 3,
+ f_should_quit = 1 << 4,
};
std::atomic<unsigned> b;
@@ -108,13 +109,11 @@ public:
void raw_and_mapped_pose(double* mapped, double* raw) const;
void start() { QThread::start(); }
- void center() { set(f_center, true); }
-
- void set_toggle(bool value) { set(f_enabled, value); }
- void set_zero(bool value) { set(f_zero, value); }
-
- void zero() { negate(f_zero); }
- void toggle_enabled() { negate(f_enabled); }
+ void center();
+ void set_toggle(bool value);
+ void set_zero(bool value);
+ void zero();
+ void toggle_enabled();
};
} // ns impl