summaryrefslogtreecommitdiffhomepage
path: root/logic
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-06 08:05:57 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-12-06 08:11:01 +0100
commit3fd39cf892250545b4510065fe16e39d494faa44 (patch)
tree7f52c9a4a5257778cdd8cb3c46e038a368eb2768 /logic
parent94600f2c5f234dddf826c9d6d9db91952832220a (diff)
cruft only
Diffstat (limited to 'logic')
-rw-r--r--logic/main-settings.cpp59
-rw-r--r--logic/main-settings.hpp77
-rw-r--r--logic/pipeline.cpp83
-rw-r--r--logic/pipeline.hpp2
4 files changed, 91 insertions, 130 deletions
diff --git a/logic/main-settings.cpp b/logic/main-settings.cpp
index 2bf0ad1f..19bb692d 100644
--- a/logic/main-settings.cpp
+++ b/logic/main-settings.cpp
@@ -4,57 +4,8 @@ namespace main_settings_impl {
using namespace options;
-main_settings::main_settings() :
- b(make_bundle("opentrack-ui")),
- b_map(make_bundle("opentrack-mappings")),
- a_x("x", TX),
- a_y("y", TY),
- a_z("z", TZ),
- a_yaw("yaw", Yaw),
- a_pitch("pitch", Pitch),
- a_roll("roll", Roll),
- all_axis_opts { &a_x, &a_y, &a_z, &a_yaw, &a_pitch, &a_roll },
- reltrans_disable_tx(b, "compensate-translation-disable-x-axis", false),
- reltrans_disable_ty(b, "compensate-translation-disable-y-axis", false),
- reltrans_disable_tz(b, "compensate-translation-disable-z-axis", false),
- reltrans_disable_src_yaw(b, "compensate-translation-disable-source-yaw", false),
- reltrans_disable_src_pitch(b, "compensate-translation-disable-source-pitch", false),
- reltrans_disable_src_roll(b, "compensate-translation-disable-source-roll", false),
- tray_enabled(b, "use-system-tray", false),
- tray_start(b, "start-in-tray", false),
- center_at_startup(b, "center-at-startup", true),
- neck_z(b, "neck-depth", 0),
- neck_enable(b, "neck-enable", false),
- key_start_tracking1(b, "start-tracking"),
- key_start_tracking2(b, "start-tracking-alt"),
- key_stop_tracking1(b, "stop-tracking"),
- key_stop_tracking2(b, "stop-tracking-alt"),
- key_toggle_tracking1(b, "toggle-tracking"),
- key_toggle_tracking2(b, "toggle-tracking-alt"),
- key_restart_tracking1(b, "restart-tracking"),
- key_restart_tracking2(b, "restart-tracking-alt"),
- key_center1(b, "center"),
- key_center2(b, "center-alt"),
- key_toggle1(b, "toggle"),
- key_toggle2(b, "toggle-alt"),
- key_zero1(b, "zero"),
- key_zero2(b, "zero-alt"),
- key_toggle_press1(b, "toggle-press"),
- key_toggle_press2(b, "toggle-press-alt"),
- key_zero_press1(b, "zero-press"),
- key_zero_press2(b, "zero-press-alt"),
- tracklogging_enabled(b, "tracklogging-enabled", false),
- tracklogging_filename(b, "tracklogging-filename", QString())
-{
-}
-
-module_settings::module_settings() :
- b(make_bundle("modules")),
- tracker_dll(b, "tracker-dll", "pt"),
- filter_dll(b, "filter-dll", "accela"),
- protocol_dll(b, "protocol-dll", "freetrack")
-{
-}
+main_settings::main_settings() = default;
+module_settings::module_settings() = default;
key_opts::key_opts(bundle b, const QString& name) :
keycode(b, QString("keycode-%1").arg(name), ""),
@@ -66,9 +17,9 @@ key_opts& key_opts::operator=(const key_opts& x)
{
if (&x != this)
{
- keycode = x.keycode();
- guid = x.guid();
- button = x.button();
+ keycode = *x.keycode;
+ guid = *x.guid;
+ button = *x.button;
}
return *this;
diff --git a/logic/main-settings.hpp b/logic/main-settings.hpp
index 41edf3e6..8fef7ea7 100644
--- a/logic/main-settings.hpp
+++ b/logic/main-settings.hpp
@@ -37,36 +37,67 @@ struct OTR_LOGIC_EXPORT key_opts
struct OTR_LOGIC_EXPORT module_settings
{
- bundle b;
- value<QString> tracker_dll, filter_dll, protocol_dll;
+ bundle b { make_bundle("modules") };
+ value<QString> tracker_dll { b, "tracker-dll", "pt" };
+ value<QString> filter_dll { b, "filter-dll", "accela" };
+ value<QString> protocol_dll { b, "protocol-dll", "freetrack" };
module_settings();
};
struct OTR_LOGIC_EXPORT main_settings final
{
- bundle b, b_map;
- axis_opts a_x, a_y, a_z;
- axis_opts a_yaw, a_pitch, a_roll;
- axis_opts* all_axis_opts[6];
+ bundle b { make_bundle("opentrack-ui") };
+ bundle b_map { make_bundle("opentrack-mappings") };
+ axis_opts a_x{ "x", TX }, a_y { "y", TY }, a_z { "z", TZ };
+ axis_opts a_yaw{ "yaw", Yaw }, a_pitch { "pitch", Pitch }, a_roll { "roll", Roll };
+ axis_opts* all_axis_opts[6] { &a_x, &a_y, &a_z, &a_yaw, &a_pitch, &a_roll };
value<reltrans_state> reltrans_mode { b, "relative-translation-mode", reltrans_disabled };
- value<bool> reltrans_disable_tx, reltrans_disable_ty, reltrans_disable_tz;
- value<bool> reltrans_disable_src_yaw, reltrans_disable_src_pitch, reltrans_disable_src_roll;
- value<bool> tray_enabled, tray_start;
- value<bool> center_at_startup;
+
+ value<bool> reltrans_disable_tx { b, "compensate-translation-disable-x-axis", false };
+ value<bool> reltrans_disable_ty { b, "compensate-translation-disable-y-axis", false };
+ value<bool> reltrans_disable_tz { b, "compensate-translation-disable-z-axis", false };
+
+ value<bool> reltrans_disable_src_yaw { b, "compensate-translation-disable-source-yaw", false };
+ value<bool> reltrans_disable_src_pitch { b, "compensate-translation-disable-source-pitch", false };
+ value<bool> reltrans_disable_src_roll { b, "compensate-translation-disable-source-roll", false };
+
+ value<bool> tray_enabled { b, "use-system-tray", false };
+ value<bool> tray_start { b, "start-in-tray", false };
+
+ value<bool> center_at_startup { b, "center-at-startup", true };
//value<int> center_method;
- value<int> neck_z;
- value<bool> neck_enable;
- key_opts key_start_tracking1, key_start_tracking2;
- key_opts key_stop_tracking1, key_stop_tracking2;
- key_opts key_toggle_tracking1, key_toggle_tracking2;
- key_opts key_restart_tracking1, key_restart_tracking2;
- key_opts key_center1, key_center2;
- key_opts key_toggle1, key_toggle2;
- key_opts key_zero1, key_zero2;
- key_opts key_toggle_press1, key_toggle_press2;
- key_opts key_zero_press1, key_zero_press2;
- value<bool> tracklogging_enabled;
- value<QString> tracklogging_filename;
+ value<int> neck_z { b, "neck-depth", 0 };
+ value<bool> neck_enable { b, "neck-enable", false };
+
+ key_opts key_start_tracking1 { b, "start-tracking" };
+ key_opts key_start_tracking2 { b, "start-tracking-alt" };
+
+ key_opts key_stop_tracking1 { b, "stop-tracking" };
+ key_opts key_stop_tracking2 { b, "stop-tracking-alt" };
+
+ key_opts key_toggle_tracking1 { b, "toggle-tracking" };
+ key_opts key_toggle_tracking2 { b, "toggle-tracking-alt" };
+
+ key_opts key_restart_tracking1 { b, "restart-tracking" };
+ key_opts key_restart_tracking2 { b, "restart-tracking-alt" };
+
+ key_opts key_center1 { b, "center" };
+ key_opts key_center2 { b, "center-alt" };
+
+ key_opts key_toggle1 { b, "toggle" };
+ key_opts key_toggle2 { b, "toggle-alt" };
+
+ key_opts key_zero1 { b, "zero" };
+ key_opts key_zero2 { b, "zero-alt" };
+
+ key_opts key_toggle_press1 { b, "toggle-press" };
+ key_opts key_toggle_press2 { b, "toggle-press-alt" };
+
+ key_opts key_zero_press1 { b, "zero-press" };
+ key_opts key_zero_press2 { b, "zero-press-alt" };
+
+ value<bool> tracklogging_enabled { b, "tracklogging-enabled", false };
+ value<QString> tracklogging_filename { b, "tracklogging-filename", {} };
main_settings();
};
diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp
index 021a576b..eb5ac17a 100644
--- a/logic/pipeline.cpp
+++ b/logic/pipeline.cpp
@@ -26,12 +26,7 @@
#ifdef _WIN32
# include <windows.h>
-#endif
-
-#if defined __llvm__
-# pragma clang diagnostic push
-# pragma clang diagnostic ignored "-Wlanguage-extension-token"
-# pragma clang diagnostic ignored "-Wunknown-pragmas"
+# include <mmsystem.h>
#endif
namespace pipeline_impl {
@@ -45,7 +40,7 @@ void reltrans::on_center()
{
interp_pos = { 0, 0, 0 };
in_zone = false;
- cur = false;
+ moving_to_reltans = false;
}
euler_t reltrans::rotate(const rmat& R, const euler_t& in, vec3_bool disable) const
@@ -83,20 +78,17 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value,
if (state != reltrans_disabled)
{
- const bool in_zone_ = progn(
- if (state == reltrans_non_center)
- {
- const bool looking_down = value(Pitch) < 20;
- return looking_down ? std::fabs(value(Yaw)) > 35 : std::fabs(value(Yaw)) > 65;
- }
- else
- return true;
- );
+ bool in_zone_ = true;
+ if (state == reltrans_non_center)
+ {
+ const bool looking_down = value(Pitch) < 20;
+ in_zone_ = looking_down ? std::fabs(value(Yaw)) > 35 : std::fabs(value(Yaw)) > 65;
+ }
- if (!cur && in_zone != in_zone_)
+ if (!moving_to_reltans && in_zone != in_zone_)
{
//qDebug() << "reltrans-interp: START" << tcomp_in_zone_;
- cur = true;
+ moving_to_reltans = true;
interp_timer.start();
interp_phase_timer.start();
RC_stage = 0;
@@ -124,7 +116,7 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value,
}
}
- if (cur)
+ if (moving_to_reltans)
{
const double dt = interp_timer.elapsed_seconds();
@@ -156,7 +148,7 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value,
if (delta < eps)
{
//qDebug() << "reltrans-interp: STOP";
- cur = false;
+ moving_to_reltans = false;
}
}
else
@@ -164,7 +156,7 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value,
}
else
{
- cur = false;
+ moving_to_reltans = false;
in_zone = false;
}
@@ -213,10 +205,11 @@ double pipeline::map(double pos, Map& axis)
#ifndef NO_NAN_CHECK
template<int u, int w>
-static bool is_nan(const dmat<u,w>& r)
+static cc_forceinline
+bool is_nan(const dmat<u,w>& r)
{
- for (int i = 0; i < u; i++)
- for (int j = 0; j < w; j++)
+ for (unsigned i = 0; i < u; i++)
+ for (unsigned j = 0; j < w; j++)
{
int val = std::fpclassify(r(i, j));
if (val == FP_NAN || val == FP_INFINITE)
@@ -226,21 +219,8 @@ static bool is_nan(const dmat<u,w>& r)
return false;
}
-template<typename x>
-static inline
-bool nan_check_(const x& datum)
-{
- return is_nan(datum);
-}
-
-template<typename x, typename y, typename... xs>
-static inline
-bool nan_check_(const x& datum, const y& next, const xs&... rest)
-{
- return nan_check_(datum) || nan_check_(next, rest...);
-}
-
-static void emit_nan_check_msg(const char* text, const char* fun, int line)
+static cc_forceinline
+void emit_nan_check_msg(const char* text, const char* fun, int line)
{
eval_once(
qDebug() << "nan check failed"
@@ -254,30 +234,33 @@ template<typename... xs>
static cc_noinline
bool maybe_nan(const char* text, const char* fun, int line, const xs&... vals)
{
- if (nan_check_(vals...))
- {
- emit_nan_check_msg(text, fun, line);
- return true;
- }
+ for (const auto& x : { vals... })
+ if (is_nan(x))
+ {
+ emit_nan_check_msg(text, fun, line);
+ return true;
+ }
return false;
}
-// for MSVC `else' is like `unlikely' for GNU
-
#define nan_check(...) \
do \
{ \
if (likely(!maybe_nan(#__VA_ARGS__, cc_function_name, __LINE__, __VA_ARGS__))) \
+ { \
(void)0; \
+ } \
else \
+ { \
goto error; \
- } while (false)
+ } \
+ } \
+ while (false)
#else
# define nan_check(...) (void)(__VA_ARGS__)
#endif
-
bool pipeline::maybe_enable_center_on_tracking_started()
{
if (!tracking_started)
@@ -689,7 +672,3 @@ bits::bits() : b(0u)
}
} // ns pipeline_impl
-
-#if defined __llvm__
-# pragma clang diagnostic pop
-#endif
diff --git a/logic/pipeline.hpp b/logic/pipeline.hpp
index 91dfc668..142a3844 100644
--- a/logic/pipeline.hpp
+++ b/logic/pipeline.hpp
@@ -51,7 +51,7 @@ class reltrans
Timer interp_phase_timer;
unsigned RC_stage = 0;
- bool cur = false;
+ bool moving_to_reltans = false;
bool in_zone = false;
public: