summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-12-24 18:54:34 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-12-24 19:32:10 +0100
commita88e34b21b07f70123926fcb5c505d6afdf99807 (patch)
tree905059194dcc64c7c163b8912947d8173fd4cc91
parent5bf85412e4eacf92acc936b6e74bce0e2b1055d9 (diff)
style/quality only
No functional changes. - add `override' everywhere where missing - almost pass clang's `-Wweak-vtables' - avoid some float/double conversions - remove unused private members - make signedness conversions explicit - put stuff in right namespaces to aid analysis
-rw-r--r--api/plugin-api.cpp47
-rw-r--r--api/plugin-api.hpp11
-rw-r--r--cmake/opentrack-boilerplate.cmake8
-rw-r--r--cmake/opentrack-policy.cmake2
-rw-r--r--compat/correlation-calibrator.cpp6
-rw-r--r--csv/csv.cpp3
-rw-r--r--dinput/dinput.cpp18
-rw-r--r--dinput/keybinding-worker.hpp1
-rw-r--r--dinput/win32-joystick.hpp1
-rw-r--r--logic/pipeline.cpp4
-rw-r--r--logic/tracklogger.cpp2
-rw-r--r--logic/tracklogger.hpp2
-rw-r--r--logic/win32-shortcuts.cpp4
-rw-r--r--migration/migration.cpp13
-rw-r--r--migration/migration.hpp10
-rw-r--r--options/globals.cpp3
-rw-r--r--options/value-traits.hpp21
-rw-r--r--pose-widget/pose-widget.cpp8
-rw-r--r--pose-widget/pose-widget.hpp7
-rw-r--r--proto-flightgear/ftnoir_protocol_fg.h12
-rw-r--r--proto-ft/ftnoir_protocol_ft.cpp10
-rw-r--r--proto-udp/ftnoir_protocol_ftn.h15
-rw-r--r--spline/spline-widget.cpp10
-rw-r--r--spline/spline.cpp22
-rw-r--r--spline/spline.hpp12
-rw-r--r--tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp6
-rw-r--r--tracker-hatire/ftnoir_tracker_hat.cpp2
-rw-r--r--tracker-hatire/thread.cpp2
-rw-r--r--tracker-pt/module/camera.cpp10
-rw-r--r--tracker-pt/module/frame.cpp4
-rw-r--r--tracker-pt/module/frame.hpp12
-rw-r--r--tracker-pt/module/module.cpp16
-rw-r--r--tracker-pt/module/module.hpp4
-rw-r--r--tracker-pt/module/point_extractor.cpp9
-rw-r--r--tracker-pt/pt-api.hpp9
-rw-r--r--tracker-pt/pt-settings.hpp11
-rw-r--r--tracker-wii/wii_camera.cpp8
-rw-r--r--tracker-wii/wii_frame.hpp9
-rw-r--r--tracker-wii/wii_module.cpp17
-rw-r--r--tracker-wii/wii_point_extractor.cpp8
-rw-r--r--tracker-wii/wiiyourself/warns-begin.hpp7
-rw-r--r--tracker-wii/wiiyourself/wiimote.cpp27
-rw-r--r--tracker-wii/wiiyourself/wiimote.h2
-rw-r--r--variant/default/main-window.cpp12
44 files changed, 239 insertions, 188 deletions
diff --git a/api/plugin-api.cpp b/api/plugin-api.cpp
index 404ed434..3630beae 100644
--- a/api/plugin-api.cpp
+++ b/api/plugin-api.cpp
@@ -27,35 +27,27 @@ void BaseDialog::done(int)
// these exist so that vtable is emitted in a single compilation unit, not all of them.
+Metadata_::Metadata_() = default;
Metadata_::~Metadata_() = default;
-IFilter::~IFilter() = default;
-IProtocol::~IProtocol() = default;
-ITracker::~ITracker() = default;
-IExtension::~IExtension() = default;
-
-void ITrackerDialog::register_tracker(ITracker*) {}
-void ITrackerDialog::unregister_tracker() {}
-
-bool ITracker::center() { return false; }
-
-module_status ITracker::status_ok()
-{
- return module_status();
-}
-
-module_status ITracker::error(const QString& error)
-{
- return module_status(error);
-}
+Metadata::Metadata() = default;
+Metadata::~Metadata() = default;
-Metadata_::Metadata_() = default;
IFilter::IFilter() = default;
+IFilter::~IFilter() = default;
IFilterDialog::IFilterDialog() = default;
+IFilterDialog::~IFilterDialog() = default;
IProtocol::IProtocol() = default;
+IProtocol::~IProtocol() = default;
IProtocolDialog::IProtocolDialog() = default;
+IProtocolDialog::~IProtocolDialog() = default;
ITracker::ITracker() = default;
+ITracker::~ITracker() = default;
+bool ITracker::center() { return false; }
ITrackerDialog::ITrackerDialog() = default;
-
+ITrackerDialog::~ITrackerDialog() = default;
+void ITrackerDialog::register_tracker(ITracker*) {}
+void ITrackerDialog::unregister_tracker() {}
+IExtension::~IExtension() = default;
IExtensionDialog::~IExtensionDialog() = default;
bool module_status::is_ok() const
@@ -63,8 +55,8 @@ bool module_status::is_ok() const
return error.isNull();
}
+module_status_mixin::~module_status_mixin() = default;
module_status::module_status(QString error) : error(std::move(error)) {}
-
module_status module_status_mixin::status_ok() { return {}; }
module_status module_status_mixin::error(const QString& error)
@@ -72,7 +64,12 @@ module_status module_status_mixin::error(const QString& error)
return module_status(error.isEmpty() ? "Unknown error" : error);
}
-Metadata::Metadata() = default;
-Metadata::~Metadata() = default;
-
+module_status ITracker::status_ok()
+{
+ return module_status();
+}
+module_status ITracker::error(const QString& error)
+{
+ return module_status(error);
+}
diff --git a/api/plugin-api.hpp b/api/plugin-api.hpp
index 52776986..3950ade0 100644
--- a/api/plugin-api.hpp
+++ b/api/plugin-api.hpp
@@ -84,7 +84,7 @@ class OTR_API_EXPORT Metadata : public TR, public Metadata_
public:
Metadata();
- ~Metadata();
+ ~Metadata() override;
};
struct OTR_API_EXPORT module_status final
@@ -104,6 +104,7 @@ struct OTR_API_EXPORT module_status_mixin
static module_status error(const QString& error); // return error message on init failure
virtual module_status initialize() = 0; // where to return from
+ virtual ~module_status_mixin();
};
// implement this in filters
@@ -125,6 +126,7 @@ struct OTR_API_EXPORT IFilter : module_status_mixin
struct OTR_API_EXPORT IFilterDialog : public plugin_api::detail::BaseDialog
{
IFilterDialog();
+ ~IFilterDialog() override;
// optional destructor
//~IFilterDialog() override;
@@ -142,12 +144,11 @@ struct OTR_API_EXPORT IFilterDialog : public plugin_api::detail::BaseDialog
struct OTR_API_EXPORT IProtocol : module_status_mixin
{
IProtocol();
+ ~IProtocol() override;
IProtocol(const IProtocol&) = delete;
IProtocol& operator=(const IProtocol&) = delete;
- // optional destructor
- virtual ~IProtocol();
// called 250 times a second with XYZ yaw pitch roll pose
// try not to perform intense computation here. use a thread.
virtual void pose(const double* headpose) = 0;
@@ -165,6 +166,7 @@ struct OTR_API_EXPORT IProtocolDialog : public plugin_api::detail::BaseDialog
virtual void unregister_protocol() = 0;
IProtocolDialog();
+ ~IProtocolDialog() override;
};
// call once with your chosen class names in the plugin
@@ -203,6 +205,7 @@ struct OTR_API_EXPORT ITrackerDialog : public plugin_api::detail::BaseDialog
virtual void unregister_tracker();
ITrackerDialog();
+ ~ITrackerDialog() override;
};
// call once with your chosen class names in the plugin
@@ -231,7 +234,7 @@ struct OTR_API_EXPORT IExtension : module_status_mixin
};
IExtension() = default;
- virtual ~IExtension();
+ ~IExtension() override;
virtual event_mask hook_types() = 0;
diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake
index c56c43ee..9d72c1af 100644
--- a/cmake/opentrack-boilerplate.cmake
+++ b/cmake/opentrack-boilerplate.cmake
@@ -133,8 +133,6 @@ function(otr_module n_)
endif()
set(n "opentrack-${n_}")
- # XXX TODO update callers to use instead of long name -sh 20180527
- set(self "${n}" PARENT_SCOPE)
if(NOT arg_SUBDIRS)
otr_glob_sources(${n} .)
@@ -175,6 +173,8 @@ function(otr_module n_)
set_property(TARGET "${n}" PROPERTY PREFIX "")
endif()
+ set(self "${n}" PARENT_SCOPE)
+
if(NOT arg_RELINK)
set_property(TARGET ${n} PROPERTY LINK_DEPENDS_NO_SHARED TRUE)
else()
@@ -205,6 +205,10 @@ function(otr_module n_)
otr_compat(${n})
+ if(CMAKE_COMPILER_IS_CLANG AND (arg_EXECUTABLE OR (NOT arg_BIN AND NOT arg_STATIC)))
+ set_property(TARGET "${n}" APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-weak-vtables ")
+ endif()
+
if(NOT arg_NO-INSTALL)
if(arg_BIN AND WIN32)
install(TARGETS "${n}" RUNTIME DESTINATION . PERMISSIONS ${opentrack-perms-exec})
diff --git a/cmake/opentrack-policy.cmake b/cmake/opentrack-policy.cmake
index e86cd284..e14bcbf7 100644
--- a/cmake/opentrack-policy.cmake
+++ b/cmake/opentrack-policy.cmake
@@ -1,5 +1,5 @@
include_guard(GLOBAL)
-foreach(k CMP0020 CMP0022 CMP0058 CMP0028 CMP0042 CMP0063 CMP0053 CMP0011 CMP0054 CMP0012)
+foreach(k CMP0020 CMP0022 CMP0058 CMP0028 CMP0042 CMP0063 CMP0053 CMP0011 CMP0054 CMP0012 CMP0069)
if(POLICY ${k})
cmake_policy(SET ${k} NEW)
endif()
diff --git a/compat/correlation-calibrator.cpp b/compat/correlation-calibrator.cpp
index a58d31cd..7edbd22d 100644
--- a/compat/correlation-calibrator.cpp
+++ b/compat/correlation-calibrator.cpp
@@ -16,7 +16,7 @@
using std::fflush;
#endif
-using namespace correlation_calibrator_impl;
+namespace correlation_calibrator_impl {
static constexpr unsigned nbuckets[6] =
{
@@ -53,7 +53,7 @@ bool correlation_calibrator::check_buckets(const vec6& data)
for (unsigned k = 0; k < 6; k++)
{
const double val = clamp(data[k], min[k], max[k]);
- pos[k] = (val-min[k])/spacing[k];
+ pos[k] = unsigned((val-min[k])/spacing[k]);
if (pos[k] >= nbuckets[k])
{
@@ -158,3 +158,5 @@ unsigned correlation_calibrator::sample_count() const
{
return data.size();
}
+
+} // ns correlation_calibrator_impl
diff --git a/csv/csv.cpp b/csv/csv.cpp
index aa518673..a1f62dc0 100644
--- a/csv/csv.cpp
+++ b/csv/csv.cpp
@@ -111,13 +111,12 @@ bool CSV::getGameData(int id, unsigned char* table, QString& gamename)
CSV csv(&file);
- int lineno = 0;
unsigned tmp[8];
unsigned fuzz[3];
QStringList gameLine;
- while (lineno++, csv.parseLine(gameLine))
+ for (int lineno = 0; csv.parseLine(gameLine); lineno++)
{
//qDebug() << "Column 0: " << gameLine.at(0); // No.
//qDebug() << "Column 1: " << gameLine.at(1); // Game Name
diff --git a/dinput/dinput.cpp b/dinput/dinput.cpp
index 8a3d0f4a..3931255b 100644
--- a/dinput/dinput.cpp
+++ b/dinput/dinput.cpp
@@ -10,12 +10,12 @@ diptr di_t::init_di_()
CoInitialize(nullptr);
diptr di = nullptr;
- if (HRESULT hr = DirectInput8Create(GetModuleHandle(nullptr),
- DIRECTINPUT_VERSION,
- IID_IDirectInput8,
- (void**)&di,
- nullptr);
- !SUCCEEDED(hr))
+ HRESULT hr = DirectInput8Create(GetModuleHandle(nullptr),
+ DIRECTINPUT_VERSION,
+ IID_IDirectInput8,
+ (void**)&di,
+ nullptr);
+ if (!SUCCEEDED(hr))
{
qDebug() << "can't make dinput:" << (void*)(LONG_PTR)hr;
qDebug() << "crashing!";
@@ -32,7 +32,8 @@ di_t::di_t()
void di_t::ref_di()
{
- while (init_lock.test_and_set()) { /* busy loop */ }
+ while (init_lock.test_and_set())
+ (void)0;
if (!handle)
handle = init_di_();
@@ -48,7 +49,8 @@ void di_t::unref_di()
if (refcnt_ == 0)
{
- while (init_lock.test_and_set()) { /* busy loop */ }
+ while (init_lock.test_and_set())
+ (void)0;
qDebug() << "exit: di handle";
handle->Release();
diff --git a/dinput/keybinding-worker.hpp b/dinput/keybinding-worker.hpp
index fdcf94c9..43a4aee1 100644
--- a/dinput/keybinding-worker.hpp
+++ b/dinput/keybinding-worker.hpp
@@ -53,7 +53,6 @@ private:
di_t din;
bool keystate[256] {};
- bool old_keystate[256] {};
void run() override;
bool run_keyboard_nolock();
diff --git a/dinput/win32-joystick.hpp b/dinput/win32-joystick.hpp
index 8d5524ff..59ec0c49 100644
--- a/dinput/win32-joystick.hpp
+++ b/dinput/win32-joystick.hpp
@@ -51,7 +51,6 @@ struct OTR_DINPUT_EXPORT win32_joy_ctx final
LPDIRECTINPUTDEVICE8 joy_handle;
QString guid, name;
bool last_state[max_buttons_and_pov_hats] {};
- Timer first_timer;
static DIDEVICEOBJECTDATA keystate_buffers[num_buffers];
diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp
index 1bde1bb1..4700bcc7 100644
--- a/logic/pipeline.cpp
+++ b/logic/pipeline.cpp
@@ -119,8 +119,8 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value,
{
const double dt = interp_timer.elapsed_seconds();
- static constexpr float RC_stages[] = { 2, 1, .5, .1, .05 };
- static constexpr float RC_time_deltas[] = { 1, .25, .25, 2 };
+ static constexpr double RC_stages[] = { 2, 1, .5, .1, .05 };
+ static constexpr double RC_time_deltas[] = { 1, .25, .25, 2 };
interp_timer.start();
diff --git a/logic/tracklogger.cpp b/logic/tracklogger.cpp
index a287b633..758c2478 100644
--- a/logic/tracklogger.cpp
+++ b/logic/tracklogger.cpp
@@ -3,6 +3,8 @@
#include <QMessageBox>
+TrackLogger::~TrackLogger() = default;
+
void TrackLogger::write_pose(const double* p)
{
write(p, 6);
diff --git a/logic/tracklogger.hpp b/logic/tracklogger.hpp
index d6c34157..134a27fd 100644
--- a/logic/tracklogger.hpp
+++ b/logic/tracklogger.hpp
@@ -13,7 +13,7 @@ class OTR_LOGIC_EXPORT TrackLogger
public:
TrackLogger() = default;
- virtual ~TrackLogger() = default;
+ virtual ~TrackLogger();
virtual void write(const char *) {}
virtual void write(const double *, int) {}
diff --git a/logic/win32-shortcuts.cpp b/logic/win32-shortcuts.cpp
index 1e2f1b77..324b1b04 100644
--- a/logic/win32-shortcuts.cpp
+++ b/logic/win32-shortcuts.cpp
@@ -15,6 +15,7 @@
#include <QVariant>
#include <QDebug>
+#if 0
win_key const windows_key_mods[] {
{DIK_LCONTROL, Qt::Key_Control},
{DIK_RCONTROL, Qt::Key_Control},
@@ -25,6 +26,7 @@ win_key const windows_key_mods[] {
{DIK_LWIN, Qt::Key_Super_L},
{DIK_RWIN, Qt::Key_Super_R},
};
+#endif
static const win_key windows_key_sequences[] {
{ DIK_F1, Qt::Key_F1 },
@@ -164,7 +166,7 @@ bool win_key::from_qt(const QKeySequence& qt_, int& dik, Qt::KeyboardModifiers&
#if 0
const unsigned qt = QVariant(qt_).toInt(); // verbose
#endif
- const unsigned qt = int(qt_); // deprecated
+ const unsigned qt = (unsigned)int(qt_); // deprecated
const unsigned our_mods = qt & Qt::KeyboardModifierMask;
if (qt == 0)
diff --git a/migration/migration.cpp b/migration/migration.cpp
index 45965bee..59ceee1a 100644
--- a/migration/migration.cpp
+++ b/migration/migration.cpp
@@ -24,9 +24,7 @@ using namespace options::globals;
// individual migrations are run in the UI thread. they can be interactive if necessary.
-namespace migrations {
-
-namespace detail {
+namespace migrations::detail {
static std::vector<mptr> migration_list;
static std::vector<mfun> migration_thunks;
@@ -180,9 +178,14 @@ std::vector<QString> migrator::run()
return done;
}
-}
+} // ns migrations::detail
+
+namespace migrations {
+
+migration::migration() = default;
+migration::~migration() = default;
-} // ns
+} // ns migrations
std::vector<QString> run_migrations()
{
diff --git a/migration/migration.hpp b/migration/migration.hpp
index 42c8bead..4eaa959f 100644
--- a/migration/migration.hpp
+++ b/migration/migration.hpp
@@ -71,25 +71,19 @@ namespace detail {
#define OPENTRACK_MIGRATION(type) \
MIGRATE_EXPANDED1(type, MIGRATE_EXPAND1(__COUNTER__))
-#ifdef Q_CREATOR_RUN
-# pragma clang diagnostic ignored "-Wweak-vtables"
-#endif
-
struct migration
{
- migration() = default;
+ migration();
migration(const migration&) = delete;
migration& operator=(const migration&) = delete;
- inline virtual ~migration();
+ virtual ~migration();
virtual QString unique_date() const = 0;
virtual QString name() const = 0;
virtual bool should_run() const = 0;
virtual void run() = 0;
};
-inline migration::~migration() {}
-
} // ns migrations
OTR_MIGRATION_EXPORT std::vector<QString> run_migrations();
diff --git a/options/globals.cpp b/options/globals.cpp
index 33327090..3bd185af 100644
--- a/options/globals.cpp
+++ b/options/globals.cpp
@@ -17,8 +17,9 @@ bool is_portable_installation()
// must keep consistent between invocations
static const bool ret = QFile::exists(OPENTRACK_BASE_PATH + "/portable.txt");
return ret;
-#endif
+#else
return false;
+#endif
}
saver_::~saver_()
diff --git a/options/value-traits.hpp b/options/value-traits.hpp
index f5b74f73..765740f6 100644
--- a/options/value-traits.hpp
+++ b/options/value-traits.hpp
@@ -79,26 +79,13 @@ struct value_traits : default_value_traits<t> {};
template<>
struct value_traits<double> : default_value_traits<double>
{
- static bool is_equal(value_type x, value_type y)
- {
- if (x == y)
- return true;
- else
- {
- using I = std::int64_t;
- constexpr int K = 1000;
-
- value_type x_, y_;
-
- return I(std::modf(x, &x_) * K) == I(std::modf(y, &y_) * K) &&
- I(x_) == I(y_);
- }
- }
+ static bool is_equal(value_type x, value_type y) { return std::fabs(x - y) < 1e-6; }
};
-template<> struct value_traits<float> : value_traits<float, double>
+template<>
+struct value_traits<float> : default_value_traits<float>
{
- static constexpr inline value_type pass_value(const value_type& x) { return x; }
+ static bool is_equal(value_type x, value_type y) { return std::fabs(x - y) < 1e-6f; }
};
template<>
diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp
index b10578d9..d9b563e9 100644
--- a/pose-widget/pose-widget.cpp
+++ b/pose-widget/pose-widget.cpp
@@ -182,7 +182,7 @@ bool Triangle::barycentric_coords(const vec2& px, vec2& uv, int& i) const
std::pair<vec2i, vec2i> pose_transform::get_bounds(const vec2& size)
{
- const int x = size.x(), y = size.y();
+ const num x = size.x(), y = size.y();
const vec3 corners[] = {
{ -x, -y, 0 },
@@ -350,8 +350,8 @@ void pose_transform::project_quad_texture()
const unsigned px_ = fx + 1;
const unsigned py_ = fy + 1;
#endif
- const unsigned px = fx;
- const unsigned py = fy;
+ const unsigned px = (unsigned)fx;
+ const unsigned py = (unsigned)fy;
const unsigned orig_pos = py * orig_pitch + px * const_depth;
#if defined BILINEAR_FILTER
@@ -380,7 +380,7 @@ void pose_transform::project_quad_texture()
dest[pos + k] = orig[orig_pos + k];
else
for (int k = 0; k < 3; k++)
- dest[pos + k] = bgcolor(k);
+ dest[pos + k] = (unsigned char)bgcolor(k);
}
}
}
diff --git a/pose-widget/pose-widget.hpp b/pose-widget/pose-widget.hpp
index fa956b47..4a97b789 100644
--- a/pose-widget/pose-widget.hpp
+++ b/pose-widget/pose-widget.hpp
@@ -48,7 +48,7 @@ public:
struct pose_transform final : QThread
{
pose_transform(QWidget* dst);
- ~pose_transform();
+ ~pose_transform() override;
void rotate_async(double xAngle, double yAngle, double zAngle, double x, double y, double z);
void rotate_sync(double xAngle, double yAngle, double zAngle, double x, double y, double z);
@@ -76,14 +76,13 @@ struct pose_transform final : QThread
QImage front, back;
QImage image, image2;
- struct uv_
+ struct uv_ // NOLINT(cppcoreguidelines-pro-type-member-init)
{
vec2 coords;
int i;
};
std::vector<uv_> uv_vec;
-
std::atomic<bool> fresh;
static constexpr inline int w = 320, h = 240;
@@ -93,7 +92,7 @@ class OTR_POSE_WIDGET_EXPORT pose_widget final : public QWidget
{
public:
pose_widget(QWidget *parent = nullptr);
- ~pose_widget();
+ ~pose_widget() override;
void rotate_async(double xAngle, double yAngle, double zAngle, double x, double y, double z);
void rotate_sync(double xAngle, double yAngle, double zAngle, double x, double y, double z);
diff --git a/proto-flightgear/ftnoir_protocol_fg.h b/proto-flightgear/ftnoir_protocol_fg.h
index 45cd0cad..4b4efa29 100644
--- a/proto-flightgear/ftnoir_protocol_fg.h
+++ b/proto-flightgear/ftnoir_protocol_fg.h
@@ -44,8 +44,8 @@ class flightgear : TR, public IProtocol
Q_OBJECT
public:
- void pose(const double *headpose);
- QString game_name() { return tr("FlightGear"); }
+ void pose(const double *headpose) override;
+ QString game_name() override { return tr("FlightGear"); }
module_status initialize() override;
private:
settings s;
@@ -59,8 +59,8 @@ class FGControls: public IProtocolDialog
Q_OBJECT
public:
FGControls();
- void register_protocol(IProtocol *) {}
- void unregister_protocol() {}
+ void register_protocol(IProtocol *) override {}
+ void unregister_protocol() override {}
private:
Ui::UICFGControls ui;
settings s;
@@ -73,6 +73,6 @@ class flightgearDll : public Metadata
{
Q_OBJECT
- QString name() { return tr("FlightGear"); }
- QIcon icon() { return QIcon(":/images/flightgear.png"); }
+ QString name() override { return tr("FlightGear"); }
+ QIcon icon() override { return QIcon(":/images/flightgear.png"); }
};
diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp
index 314bb451..874f83da 100644
--- a/proto-ft/ftnoir_protocol_ft.cpp
+++ b/proto-ft/ftnoir_protocol_ft.cpp
@@ -23,8 +23,6 @@ freetrack::~freetrack()
static_assert(sizeof(LONG) == sizeof(std::int32_t));
static_assert(sizeof(LONG) == 4u);
-static constexpr inline float d2r = float(M_PI/180);
-
cc_noinline void store(float volatile& place, const float value)
{
union
@@ -55,15 +53,17 @@ static std::int32_t load(std::int32_t volatile& place)
void freetrack::pose(const double* headpose)
{
- const float yaw = -headpose[Yaw] * d2r;
- const float roll = headpose[Roll] * d2r;
+ constexpr double d2r = M_PI/180;
+
+ const float yaw = float(-headpose[Yaw] * d2r);
+ const float roll = float(headpose[Roll] * d2r);
const float tx = float(headpose[TX] * 10);
const float ty = float(headpose[TY] * 10);
const float tz = float(headpose[TZ] * 10);
// HACK: Falcon BMS makes a "bump" if pitch is over the value -sh 20170615
const bool is_crossing_90 = std::fabs(headpose[Pitch] - 90) < .15;
- const float pitch = -d2r * (is_crossing_90 ? 89.86 : headpose[Pitch]);
+ const float pitch = float(-d2r * (is_crossing_90 ? 89.86 : headpose[Pitch]));
FTHeap* const ft = pMemData;
FTData* const data = &ft->data;
diff --git a/proto-udp/ftnoir_protocol_ftn.h b/proto-udp/ftnoir_protocol_ftn.h
index dc6e3a6f..8bc581bf 100644
--- a/proto-udp/ftnoir_protocol_ftn.h
+++ b/proto-udp/ftnoir_protocol_ftn.h
@@ -35,11 +35,8 @@ class udp : public QObject, public IProtocol
public:
udp();
module_status initialize() override;
- void pose(const double *headpose);
- QString game_name()
- {
- return tr("UDP over network");
- }
+ void pose(const double *headpose) override;
+ QString game_name() override { return tr("UDP over network"); }
private:
QUdpSocket outSocket;
settings s;
@@ -58,8 +55,8 @@ class FTNControls: public IProtocolDialog
public:
FTNControls();
- void register_protocol(IProtocol *) {}
- void unregister_protocol() {}
+ void register_protocol(IProtocol *) override {}
+ void unregister_protocol() override {}
private:
Ui::UICFTNControls ui;
settings s;
@@ -72,6 +69,6 @@ class udp_sender_dll : public Metadata
{
Q_OBJECT
- QString name() { return tr("UDP over network"); }
- QIcon icon() { return QIcon(":/images/opentrack.png"); }
+ QString name() override { return tr("UDP over network"); }
+ QIcon icon() override { return QIcon(":/images/opentrack.png"); }
};
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index 4a591870..36d3e2bf 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -107,7 +107,7 @@ void spline_widget::drawBackground()
const QPen pen(color__, 1, Qt::SolidLine, Qt::FlatCap);
- const int ystep = y_step_, xstep = x_step_;
+ const int ystep = std::ceil(y_step_), xstep = std::ceil(x_step_);
const double maxx = config->max_input();
const double maxy = config->max_output();
@@ -505,7 +505,7 @@ void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_)
double x = value.x(), y = value.y();
if (preview_only)
- y = config->get_value_no_save(x);
+ y = (double)config->get_value_no_save((float)x);
const int x_ = iround(x), y_ = iround(y);
@@ -515,7 +515,7 @@ void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_)
y = y_;
// the style on OSX has different offsets
- static const bool is_fusion =
+ constexpr bool is_fusion =
#if defined __APPLE__
true;
#else
@@ -535,8 +535,8 @@ void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_)
bool spline_widget::is_in_bounds(const QPointF& pos) const
{
- const int grace = point_size_in_pixels * 3;
- const int bottom_grace = int(point_size_in_pixels * 1.5);
+ const int grace = (int)std::ceil(point_size_in_pixels * 3);
+ const int bottom_grace = (int)std::ceil(point_size_in_pixels * 1.5);
return (pos.x() + grace > pixel_bounds.left() &&
pos.x() - grace < pixel_bounds.right() &&
pos.y() + grace > pixel_bounds.top() &&
diff --git a/spline/spline.cpp b/spline/spline.cpp
index 0c619c50..ea5b8c95 100644
--- a/spline/spline.cpp
+++ b/spline/spline.cpp
@@ -25,7 +25,12 @@
#include <QDebug>
-using namespace spline_detail;
+namespace spline_detail {
+
+base_spline_::~base_spline_() = default;
+base_spline::~base_spline() = default;
+spline_modify_mixin::~spline_modify_mixin() = default;
+spline_settings_mixin::~spline_settings_mixin() = default;
spline::spline(const QString& name, const QString& axis_name, Axis axis)
{
@@ -220,7 +225,7 @@ void spline::update_interp_data() const
{
if (data[i] == magic_fill_value)
data[i] = last;
- data[i] = (float)clamp(data[i], 0, maxy);
+ data[i] = clamp(data[i], 0, (float)maxy);
last = data[i];
}
}
@@ -361,7 +366,7 @@ void spline::ensure_valid(points_t& list) const
const int sz = list.size();
QList<QPointF> all_points, tmp;
- all_points.reserve(sz), tmp.reserve(sz);
+ all_points.reserve(sz); tmp.reserve(sz);
const double maxx = max_input();
@@ -445,14 +450,12 @@ void spline::disconnect_signals()
{
if (conn_changed)
{
- QObject::disconnect(conn_changed), conn_changed = {};
- QObject::disconnect(conn_maxx), conn_maxx = {};
- QObject::disconnect(conn_maxy), conn_maxy = {};
+ QObject::disconnect(conn_changed); conn_changed = {};
+ QObject::disconnect(conn_maxx); conn_maxx = {};
+ QObject::disconnect(conn_maxy); conn_maxy = {};
}
}
-namespace spline_detail {
-
settings::settings(bundle const& b, const QString& axis_name, Axis idx):
b(b ? b : make_bundle("")),
opts(axis_name, idx)
@@ -460,5 +463,4 @@ settings::settings(bundle const& b, const QString& axis_name, Axis idx):
settings::~settings() = default;
-}
-
+} // ns spline_detail
diff --git a/spline/spline.hpp b/spline/spline.hpp
index 270c4670..87489076 100644
--- a/spline/spline.hpp
+++ b/spline/spline.hpp
@@ -48,7 +48,8 @@ public:
struct OTR_SPLINE_EXPORT base_spline_
{
- virtual inline ~base_spline_();
+ virtual ~base_spline_();
+ base_spline_& operator=(const base_spline_&) = default;
virtual float get_value(double x) = 0;
virtual float get_value_no_save(double x) const = 0;
@@ -72,7 +73,7 @@ struct OTR_SPLINE_EXPORT spline_settings_mixin
virtual std::shared_ptr<spline_detail::base_settings> get_settings() = 0;
virtual std::shared_ptr<const spline_detail::base_settings> get_settings() const = 0;
- virtual inline ~spline_settings_mixin();
+ virtual ~spline_settings_mixin();
};
struct OTR_SPLINE_EXPORT spline_modify_mixin
@@ -83,11 +84,12 @@ struct OTR_SPLINE_EXPORT spline_modify_mixin
virtual void remove_point(int i) = 0;
virtual void clear() = 0;
- virtual inline ~spline_modify_mixin();
+ virtual ~spline_modify_mixin();
};
struct OTR_SPLINE_EXPORT base_spline : base_spline_, spline_modify_mixin, spline_settings_mixin
{
+ ~base_spline() override;
};
class OTR_SPLINE_EXPORT spline : public base_spline
@@ -158,10 +160,6 @@ public:
using settings = spline_detail::settings;
};
-inline base_spline_::~base_spline_() = default;
-inline spline_modify_mixin::~spline_modify_mixin() = default;
-inline spline_settings_mixin::~spline_settings_mixin() = default;
-
} // ns spline_detail
using spline = spline_detail::spline;
diff --git a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
index 269f8266..6622a3b7 100644
--- a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
+++ b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp
@@ -61,12 +61,13 @@ void tracker_freepie::run() {
continue;
case flag_Raw | flag_Orient:
for (int i = 0; i < 3; i++)
- orient[i] = tmp.fl[i+9];
+ orient[i] = (double)tmp.fl[i+9];
break;
case flag_Orient:
for (int i = 0; i < 3; i++)
- orient[i] = tmp.fl[i];
+ orient[i] = (double)tmp.fl[i];
break;
+ default: goto fail;
}
filled = true;
@@ -100,6 +101,7 @@ void tracker_freepie::run() {
pose[Yaw + i] = r2d * orient[axis] + add;
}
}
+fail:
usleep(4000);
}
}
diff --git a/tracker-hatire/ftnoir_tracker_hat.cpp b/tracker-hatire/ftnoir_tracker_hat.cpp
index d9f0a33b..08027f48 100644
--- a/tracker-hatire/ftnoir_tracker_hat.cpp
+++ b/tracker-hatire/ftnoir_tracker_hat.cpp
@@ -141,7 +141,7 @@ void hatire::data(double *data)
};
for (auto& k : spec)
- k.place = (k.sign ? -1 : 1) * (k.enable ? k.input : 0);
+ k.place = (k.sign ? -1 : 1) * (k.enable ? (double)k.input : 0);
}
#include "ftnoir_tracker_hat_dialog.h"
diff --git a/tracker-hatire/thread.cpp b/tracker-hatire/thread.cpp
index 3eb2579f..4c9574b9 100644
--- a/tracker-hatire/thread.cpp
+++ b/tracker-hatire/thread.cpp
@@ -304,7 +304,7 @@ void hatire_thread::serial_info_impl()
void hatire_thread::on_serial_read()
{
- const int sz = com_port.read(buf, sizeof(buf));
+ const int sz = (int)com_port.read(buf, sizeof(buf));
if (sz > 0)
{
diff --git a/tracker-pt/module/camera.cpp b/tracker-pt/module/camera.cpp
index 85439431..1b948932 100644
--- a/tracker-pt/module/camera.cpp
+++ b/tracker-pt/module/camera.cpp
@@ -19,6 +19,7 @@
#include <cstdlib>
using namespace pt_module;
+namespace pt_module {
Camera::Camera(const QString& module_name) : s { module_name }
{
@@ -141,10 +142,10 @@ bool Camera::start(int idx, int fps, int res_x, int res_y)
void Camera::stop()
{
cap = nullptr;
- desired_name = QString();
- active_name = QString();
- cam_info = pt_camera_info();
- cam_desired = pt_camera_info();
+ desired_name = QString{};
+ active_name = QString{};
+ cam_info = {};
+ cam_desired = {};
}
bool Camera::get_frame_(cv::Mat& frame)
@@ -171,3 +172,4 @@ void Camera::camera_deleter::operator()(cv::VideoCapture* cap)
}
}
+} // ns pt_module
diff --git a/tracker-pt/module/frame.cpp b/tracker-pt/module/frame.cpp
index 6734edf6..7dd8c92f 100644
--- a/tracker-pt/module/frame.cpp
+++ b/tracker-pt/module/frame.cpp
@@ -4,7 +4,7 @@
#include <opencv2/imgproc.hpp>
-using namespace pt_module;
+namespace pt_module {
Preview& Preview::operator=(const pt_frame& frame_)
{
@@ -76,3 +76,5 @@ void Preview::ensure_size(cv::Mat& frame, int w, int h, int type)
if (frame.cols != w || frame.rows != h)
frame = cv::Mat(h, w, type);
}
+
+} // ns pt_module
diff --git a/tracker-pt/module/frame.hpp b/tracker-pt/module/frame.hpp
index 49dde49e..d440bd67 100644
--- a/tracker-pt/module/frame.hpp
+++ b/tracker-pt/module/frame.hpp
@@ -5,6 +5,11 @@
#include <opencv2/core.hpp>
#include <QImage>
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wweak-vtables"
+#endif
+
namespace pt_module {
struct Frame final : pt_frame
@@ -29,8 +34,11 @@ struct Preview final : pt_preview
private:
static void ensure_size(cv::Mat& frame, int w, int h, int type);
- bool fresh = true;
- cv::Mat frame_copy, frame_color, frame_out, frame_out2;
+ cv::Mat frame_copy, frame_out;
};
} // ns pt_module
+
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
diff --git a/tracker-pt/module/module.cpp b/tracker-pt/module/module.cpp
index 4731175a..f665face 100644
--- a/tracker-pt/module/module.cpp
+++ b/tracker-pt/module/module.cpp
@@ -12,7 +12,11 @@
static const QString module_name = "tracker-pt";
-using namespace pt_module;
+#ifdef __clang__
+# pragma clang diagnostic ignored "-Wweak-vtables"
+#endif
+
+namespace pt_module {
struct pt_module_traits final : pt_runtime_traits
{
@@ -54,13 +58,15 @@ struct dialog_pt : TrackerDialog_PT
dialog_pt();
};
-// ns pt_module
-
-using namespace pt_module;
-
dialog_pt::dialog_pt() : TrackerDialog_PT(module_name) {}
QString metadata_pt::name() { return tr("PointTracker 1.1"); }
QIcon metadata_pt::icon() { return QIcon(":/Resources/Logo_IR.png"); }
+}
+
+// ns pt_module
+
+using namespace pt_module;
+
OPENTRACK_DECLARE_TRACKER(tracker_pt, dialog_pt, metadata_pt)
diff --git a/tracker-pt/module/module.hpp b/tracker-pt/module/module.hpp
index 3afe8bc9..0b3f12cf 100644
--- a/tracker-pt/module/module.hpp
+++ b/tracker-pt/module/module.hpp
@@ -13,8 +13,8 @@ class OTR_GENERIC_EXPORT metadata_pt : public Metadata
{
Q_OBJECT
- QString name();
- QIcon icon();
+ QString name() override;
+ QIcon icon() override;
};
} // ns pt_module
diff --git a/tracker-pt/module/point_extractor.cpp b/tracker-pt/module/point_extractor.cpp
index f8c37351..c0756a40 100644
--- a/tracker-pt/module/point_extractor.cpp
+++ b/tracker-pt/module/point_extractor.cpp
@@ -30,7 +30,6 @@
#include <QDebug>
using namespace types;
-using namespace pt_module;
// meanshift code written by Michael Welter
@@ -84,6 +83,8 @@ static cv::Vec2d MeanShiftIteration(const cv::Mat &frame_gray, const vec2 &curre
return current_center;
}
+namespace pt_module {
+
PointExtractor::PointExtractor(const QString& module_name) : s(module_name)
{
blobs.reserve(max_blobs);
@@ -352,7 +353,9 @@ end:
const f overlay_size = dpi > 1.5 ? 2 : 1;
- cv::circle(preview_frame, p, iround((b.radius + 3.3) * c_ * c_fract), circle_color, overlay_size, cv::LINE_AA, fract_bits);
+ cv::circle(preview_frame, p, iround((b.radius + 3.3) * c_ * c_fract),
+ circle_color, (int)overlay_size,
+ cv::LINE_AA, fract_bits);
char buf[16];
buf[sizeof(buf)-1] = '\0';
@@ -387,3 +390,5 @@ blob::blob(f radius, const vec2& pos, f brightness, const cv::Rect& rect) :
{
//qDebug() << "radius" << radius << "pos" << pos[0] << pos[1];
}
+
+} // ns pt_module
diff --git a/tracker-pt/pt-api.hpp b/tracker-pt/pt-api.hpp
index 6c36ebaf..300e4558 100644
--- a/tracker-pt/pt-api.hpp
+++ b/tracker-pt/pt-api.hpp
@@ -13,6 +13,11 @@
#include <QImage>
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wweak-vtables"
+#endif
+
struct pt_camera_info final
{
using f = types::f;
@@ -107,3 +112,7 @@ struct pt_runtime_traits
template<typename t>
using pt_pointer = typename pt_runtime_traits::pointer<t>;
+
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
diff --git a/tracker-pt/pt-settings.hpp b/tracker-pt/pt-settings.hpp
index 088dfe5a..2027302b 100644
--- a/tracker-pt/pt-settings.hpp
+++ b/tracker-pt/pt-settings.hpp
@@ -19,6 +19,11 @@ namespace pt_settings_detail {
using namespace options;
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wweak-vtables"
+#endif
+
struct pt_settings final : options::opts
{
using slider_value = options::slider_value;
@@ -57,9 +62,13 @@ struct pt_settings final : options::opts
value<slider_value> threshold_slider { b, "threshold-slider", { 128, 0, 255 } };
explicit pt_settings(const QString& name) : opts(name) {}
- ~pt_settings() = default;
+ ~pt_settings() override = default;
};
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
+
} // ns pt_settings_detail
using pt_settings = pt_settings_detail::pt_settings;
diff --git a/tracker-wii/wii_camera.cpp b/tracker-wii/wii_camera.cpp
index 83c6a0ce..ab216215 100644
--- a/tracker-wii/wii_camera.cpp
+++ b/tracker-wii/wii_camera.cpp
@@ -28,10 +28,10 @@ namespace pt_module {
WIICamera::WIICamera(const QString& module_name) : s { module_name }
{
- cam_info.fps = 70;
- cam_info.res_x = 1024;
- cam_info.res_y = 768;
- cam_info.fov = 42.0f;
+ cam_info.fps = 70;
+ cam_info.res_x = 1024;
+ cam_info.res_y = 768;
+ cam_info.fov = 42;
cam_info.idx = 0;
}
diff --git a/tracker-wii/wii_frame.hpp b/tracker-wii/wii_frame.hpp
index 10c1b122..5b55bec8 100644
--- a/tracker-wii/wii_frame.hpp
+++ b/tracker-wii/wii_frame.hpp
@@ -12,7 +12,10 @@
#include <opencv2/core.hpp>
#include <QImage>
-
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wweak-vtables"
+#endif
namespace pt_module {
@@ -62,3 +65,7 @@ private:
};
} // ns pt_module
+
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
diff --git a/tracker-wii/wii_module.cpp b/tracker-wii/wii_module.cpp
index 9f2a4b04..c4884f22 100644
--- a/tracker-wii/wii_module.cpp
+++ b/tracker-wii/wii_module.cpp
@@ -20,7 +20,12 @@
static const QString module_name = "tracker-wii-pt";
-using namespace pt_module;
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wweak-vtables"
+#endif
+
+namespace pt_module {
struct wii_pt_module_traits final : pt_runtime_traits
{
@@ -63,6 +68,12 @@ struct wii_dialog_pt : TrackerDialog_PT
wii_dialog_pt();
};
+} // ns pt_module
+
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
+
QString wii_metadata_pt::name()
{
return tr("WiiPointTracker 1.1");
@@ -73,13 +84,11 @@ QIcon wii_metadata_pt::icon()
return QIcon(":/Resources/wii.png");
}
-// ns pt_module
-
using namespace pt_module;
wii_dialog_pt::wii_dialog_pt() : TrackerDialog_PT(module_name)
{
- ui.tabWidget->removeTab(0);
+ ui.tabWidget->removeTab(0);
}
OPENTRACK_DECLARE_TRACKER(wii_tracker_pt, wii_dialog_pt, wii_metadata_pt)
diff --git a/tracker-wii/wii_point_extractor.cpp b/tracker-wii/wii_point_extractor.cpp
index 2da91d01..c5c20c6a 100644
--- a/tracker-wii/wii_point_extractor.cpp
+++ b/tracker-wii/wii_point_extractor.cpp
@@ -72,8 +72,8 @@ bool WIIPointExtractor::draw_points(cv::Mat& preview_frame, const struct wii_inf
if (dot.bvis) {
//qDebug() << "wii:" << dot.RawX << "+" << dot.RawY;
//anti-clockwise rotate the 2D point
- const float RX = W - dot.ux;
- const float RY = H - dot.uy;
+ const double RX = W - dot.ux;
+ const double RY = H - dot.uy;
//vec2 dt((dot.RawX - W / 2.0f) / W, -(dot.RawY - H / 2.0f) / W);
//vec2 dt((RX - W / 2.0f) / W, -(RY - H / 2.0f) / W);
//vec2 dt((2.0f*RX - W) / W, -(2.0f*RY - H ) / W);
@@ -99,8 +99,8 @@ void WIIPointExtractor::draw_bg(cv::Mat& preview_frame, const struct wii_info& w
2);
//draw horizon
- int pdelta = iround((preview_frame.rows / 4) * tan((wii.Pitch)* M_PI / 180.0f));
- int rdelta = iround((preview_frame.cols / 4) * tan((wii.Roll)* M_PI / 180.0f));
+ int pdelta = iround((preview_frame.rows / 4.) * tan(((double)wii.Pitch)* M_PI / 180.));
+ int rdelta = iround((preview_frame.cols / 4.) * tan(((double)wii.Roll)* M_PI / 180.));
cv::line(preview_frame,
cv::Point(0, preview_frame.rows / 2 + rdelta - pdelta),
diff --git a/tracker-wii/wiiyourself/warns-begin.hpp b/tracker-wii/wiiyourself/warns-begin.hpp
index ca2b6b93..e4b148ef 100644
--- a/tracker-wii/wiiyourself/warns-begin.hpp
+++ b/tracker-wii/wiiyourself/warns-begin.hpp
@@ -3,7 +3,10 @@
# pragma GCC diagnostic ignored "-Wswitch"
# pragma GCC diagnostic ignored "-Wreorder"
# pragma GCC diagnostic ignored "-Wunused-variable"
-# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
# pragma GCC diagnostic ignored "-Wunused-parameter"
-# pragma GCC diagnostic ignored "-Wcast-function-type"
+# pragma GCC diagnostic ignored "-Wcast-align"
+# ifndef __clang__
+# pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+# pragma GCC diagnostic ignored "-Wcast-function-type"
+# endif
#endif
diff --git a/tracker-wii/wiiyourself/wiimote.cpp b/tracker-wii/wiiyourself/wiimote.cpp
index 0da0113b..f6946fad 100644
--- a/tracker-wii/wiiyourself/wiimote.cpp
+++ b/tracker-wii/wiiyourself/wiimote.cpp
@@ -10,16 +10,10 @@
#include "warns-begin.hpp"
-// VC-specifics:
-#ifdef _MSC_VER
- // disable warning "C++ exception handler used, but unwind semantics are not enabled."
- // in <xstring> (I don't use it - or just enable C++ exceptions)
-# pragma warning(disable: 4530)
-// auto-link with the necessary libs
-//# pragma comment(lib, "setupapi.lib")
-//# pragma comment(lib, "hid.lib") // for HID API (from DDK)
-//# pragma comment(lib, "winmm.lib") // for timeGetTime()
-#endif // _MSC_VER
+#include <cmath>
+#include <new>
+#include <cstring>
+#include <cstdio>
#include "wiimote.h"
#include <setupapi.h>
@@ -29,8 +23,6 @@ extern "C" {
#include <sys/types.h> // for _stat
#include <sys/stat.h> // "
-#include <cstring>
-#include <cstdio>
#include <process.h> // for _beginthreadex()
#include <math.h> // for orientation
#include <mmreg.h> // for WAVEFORMATEXTENSIBLE
@@ -251,8 +243,9 @@ bool wiimote::Connect(unsigned wiimote_index, bool force_hidwrites)
// (bizarre way of doing it) create a buffer large enough to hold the
// fixed-size detail struct components, and the variable string size
- SP_DEVICE_INTERFACE_DETAIL_DATA *didetail =
- (SP_DEVICE_INTERFACE_DETAIL_DATA*) new BYTE[req_size];
+ using spdidd = SP_DEVICE_INTERFACE_DETAIL_DATA;
+ constexpr std::align_val_t align { alignof(spdidd) };
+ spdidd *didetail = (spdidd*)operator new(req_size, align);
_ASSERT(didetail);
didetail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA);
@@ -1203,7 +1196,7 @@ bool wiimote::EstimateOrientationFrom(wiimote_state::acceleration &accel)
// wiimote seems to be stationary: normalize the current acceleration
// (ie. the assumed gravity vector)
- float inv_len = 1.f / sqrt(length_sq);
+ float inv_len = 1.f / std::sqrt(length_sq);
float x = accel.X * inv_len;
float y = accel.Y * inv_len;
float z = accel.Z * inv_len;
@@ -1215,9 +1208,9 @@ bool wiimote::EstimateOrientationFrom(wiimote_state::acceleration &accel)
// and extract pitch & roll from them:
// (may not be optimal)
- float pitch = -asin(y) * 57.2957795f;
+ float pitch = -std::asin(y) * 57.2957795f;
// float roll = asin(x) * 57.2957795f;
- float roll = atan2(x, z) * 57.2957795f;
+ float roll = std::atan2(x, z) * 57.2957795f;
if (z < 0) {
pitch = (y < 0) ? 180 - pitch : -180 - pitch;
roll = (x < 0) ? -180 - roll : 180 - roll;
diff --git a/tracker-wii/wiiyourself/wiimote.h b/tracker-wii/wiiyourself/wiimote.h
index b4738026..9b6d3ba3 100644
--- a/tracker-wii/wiiyourself/wiimote.h
+++ b/tracker-wii/wiiyourself/wiimote.h
@@ -472,7 +472,7 @@ volatile int MotionPlusDetectCount; // waiting for the result
volatile DWORD AsyncRumbleTimeout;
// orientation estimation
unsigned WiimoteNearGUpdates;
- unsigned NunchukNearGUpdates;
+ //unsigned NunchukNearGUpdates;
// audio
HANDLE SampleThread;
const wiimote_sample* volatile CurrentSample; // otherwise playing square wave
diff --git a/variant/default/main-window.cpp b/variant/default/main-window.cpp
index 7b2456e8..11d3eb97 100644
--- a/variant/default/main-window.cpp
+++ b/variant/default/main-window.cpp
@@ -339,9 +339,15 @@ main_window::~main_window()
if (work)
{
stop_tracker_();
- QEventLoop ev;
- ev.processEvents();
- portable::sleep(2000);
+
+ constexpr int inc = 100, max = 2000;
+
+ for (int k = 0; k < max; k += inc)
+ {
+ QEventLoop ev;
+ ev.processEvents();
+ portable::sleep(inc);
+ }
}
exit();