summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-10-05 15:59:58 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-10-05 14:35:44 +0000
commit9cca4ffd9987352e43119d9c4dea0ce84c2c448f (patch)
tree250e8092af1738ce51c268e2866dd75d67e879df
parentf0216a3c53d43918295f1bd81975b391f4e5ed3b (diff)
silly busywork
-rw-r--r--compat/camera-names.cpp33
-rw-r--r--compat/macros.hpp2
-rw-r--r--compat/math.hpp6
-rw-r--r--compat/qhash.hpp3
-rw-r--r--dinput/dinput.hpp2
-rw-r--r--logic/pipeline.cpp52
-rw-r--r--logic/pipeline.hpp36
-rw-r--r--proto-ft/ftnoir_protocol_ft.h1
-rw-r--r--proto-vjoystick/vjoystick_dialog.cpp2
-rw-r--r--qxt-mini/qxtglobalshortcut.h4
-rw-r--r--sdk-paths-sthalik@MSVC-windows.cmake4
-rw-r--r--spline/spline-widget.cpp27
-rw-r--r--spline/spline-widget.hpp4
-rw-r--r--tracker-pt/point_tracker.h3
-rw-r--r--variant/default/main-window.cpp6
15 files changed, 73 insertions, 112 deletions
diff --git a/compat/camera-names.cpp b/compat/camera-names.cpp
index 23649d38..246d76ee 100644
--- a/compat/camera-names.cpp
+++ b/compat/camera-names.cpp
@@ -1,9 +1,9 @@
#include "camera-names.hpp"
#ifdef _WIN32
+# include <cwchar>
# define NO_DSHOW_STRSAFE
# include <dshow.h>
-# include <cwchar>
#elif defined(__unix) || defined(__linux) || defined(__APPLE__)
# include <unistd.h>
#endif
@@ -13,6 +13,7 @@
# include <sys/ioctl.h>
# include <linux/videodev2.h>
# include <cerrno>
+# include <cstring>
#endif
#include <QDebug>
@@ -29,7 +30,7 @@ int camera_name_to_index(const QString &name)
QList<QString> get_camera_names()
{
QList<QString> ret;
-#if defined(_WIN32)
+#ifdef _WIN32
// Create the System Device Enumerator.
HRESULT hr;
CoInitialize(nullptr);
@@ -54,23 +55,16 @@ QList<QString> get_camera_names()
hr = pMoniker->BindToStorage(nullptr, nullptr, IID_IPropertyBag, (void **)&pPropBag);
if (SUCCEEDED(hr)) {
// To retrieve the filter's friendly name, do the following:
- VARIANT varName;
- VariantInit(&varName);
- hr = pPropBag->Read(L"FriendlyName", &varName, nullptr);
+ VARIANT var;
+ VariantInit(&var);
+ hr = pPropBag->Read(L"FriendlyName", &var, nullptr);
if (SUCCEEDED(hr))
{
// Display the name in your UI somehow.
- QString str((QChar*)varName.bstrVal, int(std::wcslen(varName.bstrVal)));
+ QString str((QChar*)var.bstrVal, int(std::wcslen(var.bstrVal)));
ret.append(str);
}
- VariantClear(&varName);
-
- ////// To create an instance of the filter, do the following:
- ////IBaseFilter *pFilter;
- ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter,
- //// (void**)&pFilter);
- // Now add the filter to the graph.
- //Remember to release pFilter later.
+ VariantClear(&var);
pPropBag->Release();
}
pMoniker->Release();
@@ -82,14 +76,11 @@ QList<QString> get_camera_names()
pSysDevEnum->Release();
#endif
+
#ifdef __linux
for (int i = 0; i < 16; i++) {
- char buf[128];
- sprintf(buf, "/dev/video%d", i);
- if (access(buf, F_OK) == 0)
- ret.append(buf);
- else
- continue;
+ char buf[32];
+ snprintf(buf, sizeof(buf), "/dev/video%d", i);
if (access(buf, R_OK | W_OK) == 0) {
int fd = open(buf, O_RDONLY);
@@ -102,7 +93,7 @@ QList<QString> get_camera_names()
close(fd);
continue;
}
- ret[ret.size()-1] = reinterpret_cast<const char*>(video_cap.card);
+ ret.append(QString{(const char*)video_cap.card});
close(fd);
}
}
diff --git a/compat/macros.hpp b/compat/macros.hpp
index 3c93ee13..42d5d649 100644
--- a/compat/macros.hpp
+++ b/compat/macros.hpp
@@ -85,7 +85,7 @@ using to_const_lvalue_reference_t = remove_cvref_t<t> const&;
template<typename t>
using cv_qualified = std::conditional_t<std::is_fundamental_v<std::decay_t<t>>,
std::decay_t<t>,
- std::add_lvalue_reference_t<std::add_const_t<std::remove_reference_t<t>>>>;
+ std::add_lvalue_reference_t<std::add_const_t<remove_cvref_t<t>>>>;
template<bool>
[[deprecated]] constexpr cc_forceinline void static_warn() {}
diff --git a/compat/math.hpp b/compat/math.hpp
index eae1435e..04a6e08d 100644
--- a/compat/math.hpp
+++ b/compat/math.hpp
@@ -53,10 +53,10 @@ inline auto clamp(const t& val, const u& min, const w& max)
return ::util_detail::clamp<std::decay_t<tp>, tp>::clamp_(val, min, max);
}
-template<typename t>
-inline auto iround(t val) -> std::enable_if_t<!std::is_integral_v<std::decay_t<t>>, t>
+template<typename t, typename integral_type = int>
+inline auto iround(t val) -> std::enable_if_t<!std::is_integral_v<std::decay_t<t>>, integral_type>
{
- return (int) std::round(val);
+ return static_cast<integral_type>(std::round(val));
}
template<typename t>
diff --git a/compat/qhash.hpp b/compat/qhash.hpp
index a9685007..ba569285 100644
--- a/compat/qhash.hpp
+++ b/compat/qhash.hpp
@@ -1,13 +1,12 @@
#pragma once
-#include <functional>
#include <QString>
#include <QHashFunctions>
namespace std {
template<> struct hash<QString>
{
- inline unsigned operator()(const QString& value) const
+ constexpr unsigned operator()(const QString& value) const
{
return qHash(value);
}
diff --git a/dinput/dinput.hpp b/dinput/dinput.hpp
index e3eb2758..a9241504 100644
--- a/dinput/dinput.hpp
+++ b/dinput/dinput.hpp
@@ -36,7 +36,7 @@ public:
di_t& operator=(const di_t&) = default;
diptr operator->() const { return handle; }
- operator bool() { return handle; }
+ operator bool() { return handle != nullptr; }
// for debugging bad usages. must use a dependent name.
template<typename t = void>
diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp
index bd7f8300..73f51509 100644
--- a/logic/pipeline.cpp
+++ b/logic/pipeline.cpp
@@ -28,9 +28,7 @@
# include <windows.h>
#endif
-using namespace euler;
-using namespace time_units;
-using namespace pipeline_impl;
+namespace pipeline_impl {
static constexpr inline double r2d = 180. / M_PI;
static constexpr inline double d2r = M_PI / 180.;
@@ -158,9 +156,7 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value,
}
}
else
- {
interp_pos = rel;
- }
}
else
{
@@ -295,7 +291,7 @@ bool pipeline::maybe_enable_center_on_tracking_started()
if (tracking_started && s.center_at_startup)
{
- set(f_center, true);
+ b.set(f_center, true);
return true;
}
}
@@ -305,28 +301,18 @@ bool pipeline::maybe_enable_center_on_tracking_started()
void pipeline::maybe_set_center_pose(const Pose& value, bool own_center_logic)
{
- if (get(f_center | f_held_center))
+ if (b.get(f_center | f_held_center))
{
if (libs.pFilter)
libs.pFilter->center();
if (own_center_logic)
{
-#if 0
- state.inv_rot_center = rmat::eye();
- state.t_center = {};
-#endif
-
scaled_state.inv_rot_center = rmat::eye();
scaled_state.t_center = {};
}
else
{
-#if 0
- state.inv_rot_center = state.inv_rot_center;
- state.t_center = (const double*)(value);
-#endif
-
scaled_state.inv_rot_center = scaled_state.rotation.t();
scaled_state.t_center = (const double*)(value);
}
@@ -335,10 +321,6 @@ void pipeline::maybe_set_center_pose(const Pose& value, bool own_center_logic)
void pipeline::store_tracker_pose(const Pose& value)
{
-#if 0
- euler_t tmp(d2r * euler_t(&value[Yaw]));
- state.rotation = euler_to_rmat(tmp);
-#endif
// alas, this is poor man's gimbal lock "prevention"
// this is some kind of "canonical" representation,
// if we can even talk of one
@@ -464,9 +446,9 @@ void pipeline::logic()
logger.reset_dt();
// we must center prior to getting data from the tracker
- const bool center_ordered = get(f_center | f_held_center) && tracking_started;
+ const bool center_ordered = b.get(f_center | f_held_center) && tracking_started;
const bool own_center_logic = center_ordered && libs.pTracker->center();
- const bool hold_ordered = get(f_enabled_p) ^ get(f_enabled_h);
+ const bool hold_ordered = b.get(f_enabled_p) ^ b.get(f_enabled_h);
{
Pose tmp;
@@ -535,9 +517,9 @@ error:
ok:
- set(f_center, false);
+ b.set(f_center, false);
- if (get(f_zero))
+ if (b.get(f_zero))
for (int i = 0; i < 6; i++)
value(i) = 0;
@@ -650,20 +632,20 @@ void pipeline::raw_and_mapped_pose(double* mapped, double* raw) const
}
}
-void pipeline::set_center() { set(f_center, true); }
+void pipeline::set_center() { b.set(f_center, true); }
void pipeline::set_held_center(bool value)
{
- set(f_held_center, value);
+ b.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); }
+void pipeline::set_enabled(bool value) { b.set(f_enabled_h, value); }
+void pipeline::set_zero(bool value) { b.set(f_zero, value); }
-void pipeline::toggle_zero() { negate(f_zero); }
-void pipeline::toggle_enabled() { negate(f_enabled_p); }
+void pipeline::toggle_zero() { b.negate(f_zero); }
+void pipeline::toggle_enabled() { b.negate(f_enabled_p); }
-void bits::set(flags flag, bool val)
+void bits::set(bit_flags flag, bool val)
{
const unsigned flag_ = unsigned(flag);
const unsigned val_ = unsigned(val);
@@ -674,7 +656,7 @@ void bits::set(flags flag, bool val)
break;
}
-void bits::negate(flags flag)
+void bits::negate(bit_flags flag)
{
const unsigned flag_= flag;
unsigned b_ = 0;
@@ -684,7 +666,7 @@ void bits::negate(flags flag)
break;
}
-bool bits::get(flags flag)
+bool bits::get(bit_flags flag)
{
return !!(b & flag);
}
@@ -697,3 +679,5 @@ bits::bits() : b(0u)
set(f_enabled_h, true);
set(f_zero, false);
}
+
+} // ns pipeline_impl
diff --git a/logic/pipeline.hpp b/logic/pipeline.hpp
index 0cdeebfb..3be4f45e 100644
--- a/logic/pipeline.hpp
+++ b/logic/pipeline.hpp
@@ -25,8 +25,8 @@
namespace pipeline_impl {
-using rmat = euler::rmat;
-using euler_t = euler::euler_t;
+using namespace euler;
+using namespace time_units;
using vec6_bool = Mat<bool, 6, 1>;
using vec3_bool = Mat<bool, 6, 1>;
@@ -49,7 +49,7 @@ class reltrans
// this implements smooth transition into reltrans mode
// once not aiming anymore. see `apply_pipeline()'.
Timer interp_phase_timer;
- unsigned RC_phase = 0;
+ unsigned RC_stage = 0;
bool cur = false;
bool in_zone = false;
@@ -72,27 +72,27 @@ public:
using namespace time_units;
-struct OTR_LOGIC_EXPORT bits
-{
- enum flags : unsigned {
- f_center = 1 << 0,
- f_held_center = 1 << 1,
- f_enabled_h = 1 << 2,
- f_enabled_p = 1 << 3,
- f_zero = 1 << 4,
- };
+enum bit_flags : unsigned {
+ f_center = 1 << 0,
+ f_held_center = 1 << 1,
+ f_enabled_h = 1 << 2,
+ f_enabled_p = 1 << 3,
+ f_zero = 1 << 4,
+};
+struct OTR_LOGIC_EXPORT bits
+{
std::atomic<unsigned> b;
- void set(flags flag, bool val);
- void negate(flags flag);
- bool get(flags flag);
+ void set(bit_flags flag, bool val);
+ void negate(bit_flags flag);
+ bool get(bit_flags flag);
bits();
};
-DEFINE_ENUM_OPERATORS(bits::flags);
+DEFINE_ENUM_OPERATORS(bit_flags);
-class OTR_LOGIC_EXPORT pipeline : private QThread, private bits
+class OTR_LOGIC_EXPORT pipeline : private QThread
{
Q_OBJECT
@@ -133,6 +133,8 @@ class OTR_LOGIC_EXPORT pipeline : private QThread, private bits
Pose apply_reltrans(Pose value, vec6_bool disabled, bool centerp);
Pose apply_zero_pos(Pose value) const;
+ bits b;
+
public:
pipeline(Mappings& m, runtime_libraries& libs, event_handler& ev, TrackLogger& logger);
~pipeline() override;
diff --git a/proto-ft/ftnoir_protocol_ft.h b/proto-ft/ftnoir_protocol_ft.h
index 4ddda8de..0056721c 100644
--- a/proto-ft/ftnoir_protocol_ft.h
+++ b/proto-ft/ftnoir_protocol_ft.h
@@ -56,7 +56,6 @@ private:
QMutex game_name_mutex;
void start_dummy();
- static float degrees_to_rads(double degrees);
public:
static void set_protocols(bool ft, bool npclient);
diff --git a/proto-vjoystick/vjoystick_dialog.cpp b/proto-vjoystick/vjoystick_dialog.cpp
index 461230a6..0a1fa9b0 100644
--- a/proto-vjoystick/vjoystick_dialog.cpp
+++ b/proto-vjoystick/vjoystick_dialog.cpp
@@ -1,6 +1,8 @@
#include "vjoystick.h"
#include "api/plugin-api.hpp"
+#include <QDialogButtonBox>
+
vjoystick_dialog::vjoystick_dialog()
{
ui.setupUi(this);
diff --git a/qxt-mini/qxtglobalshortcut.h b/qxt-mini/qxtglobalshortcut.h
index be62a984..98bee92d 100644
--- a/qxt-mini/qxtglobalshortcut.h
+++ b/qxt-mini/qxtglobalshortcut.h
@@ -1,4 +1,4 @@
-#ifndef QXTGLOBALSHORTCUT_H
+#pragma once
/****************************************************************************
** Copyright (c) 2006 - 2011, the LibQxt project.
** See the Qxt AUTHORS file for a list of authors and copyright holders.
@@ -62,5 +62,3 @@ public Q_SLOTS:
Q_SIGNALS:
void activated(bool keydown = true);
};
-
-#endif // QXTGLOBALSHORTCUT_H
diff --git a/sdk-paths-sthalik@MSVC-windows.cmake b/sdk-paths-sthalik@MSVC-windows.cmake
index dacdd1bb..252431a6 100644
--- a/sdk-paths-sthalik@MSVC-windows.cmake
+++ b/sdk-paths-sthalik@MSVC-windows.cmake
@@ -29,13 +29,9 @@ setq(EIGEN3_INCLUDE_DIR "eigen")
setq(SDK_FSUIPC "fsuipc")
setq(SDK_HYDRA "SixenseSDK")
-setq(SDK_RIFT_025 "LibOVR-025/build")
-setq(SDK_RIFT_042 "LibOVR-042/build")
-setq(SDK_RIFT_080 "LibOVR-080/build")
setq(SDK_RIFT_140 "LibOVR-140/build")
setq(SDK_VALVE_STEAMVR "steamvr")
-setq(SDK_TOBII_EYEX "Tobii-EyeX")
setq(SDK_VJOYSTICK "vjoystick")
setq(SDK_REALSENSE "RSSDK-R2")
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index 8849d45d..a4b9534f 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -15,13 +15,10 @@
#include <QPixmap>
#include <QString>
#include <QToolTip>
-#include <QApplication>
#include <QtEvents>
#include <QDebug>
-#include "compat/timer.hpp"
-
using namespace spline_detail;
spline_widget::spline_widget(QWidget *parent) : QWidget(parent)
@@ -187,15 +184,6 @@ void spline_widget::drawFunction()
painter.setPen(QPen(color_, 1.75, Qt::SolidLine, Qt::FlatCap));
-//#define DEBUG_TIMINGS
-#ifdef DEBUG_TIMINGS
- static Timer t;
- static unsigned cnt = 0;
- static time_units::ms total { 0 };
- cnt++;
- t.start();
-#endif
-
const double dpr = devicePixelRatioF();
const double line_length_pixels = std::fmax(1, 2 * dpr);
const double step = std::fmax(.1, line_length_pixels / c.x());
@@ -245,11 +233,6 @@ void spline_widget::drawFunction()
}
#endif
-#ifdef DEBUG_TIMINGS
- total += t.elapsed<time_units::ms>();
- qDebug() << "avg" << total.count() / cnt;
-#endif
-
const QRect r1(pixel_bounds.left(), 0, width() - pixel_bounds.left(), pixel_bounds.top()),
r2(pixel_bounds.right(), 0, width() - pixel_bounds.right(), pixel_bounds.bottom());
@@ -531,8 +514,14 @@ void spline_widget::show_tooltip(const QPoint& pos, const QPointF& value_)
if (std::fabs(y_ - y) < 1e-3)
y = y_;
- static const bool is_fusion = QStringLiteral("fusion") == QApplication::style()->objectName();
- // no fusion means OSX
+ // the style on OSX has different offsets
+ static const bool is_fusion =
+#if defined __APPLE__
+ true;
+#else
+ false;
+#endif
+
const int off_x = (is_fusion ? 25 : 0), off_y = (is_fusion ? 15 : 0);
const QPoint pix(pos.x() + off_x, pos.y() + off_y);
diff --git a/spline/spline-widget.hpp b/spline/spline-widget.hpp
index 70071c28..737b29f1 100644
--- a/spline/spline-widget.hpp
+++ b/spline/spline-widget.hpp
@@ -36,8 +36,8 @@ class OTR_SPLINE_EXPORT spline_widget final : public QWidget
using points_t = spline::points_t;
public:
- spline_widget(QWidget *parent = 0);
- ~spline_widget();
+ explicit spline_widget(QWidget *parent = nullptr);
+ ~spline_widget() override;
void setConfig(base_spline* spl);
diff --git a/tracker-pt/point_tracker.h b/tracker-pt/point_tracker.h
index 00325ee4..095b79d2 100644
--- a/tracker-pt/point_tracker.h
+++ b/tracker-pt/point_tracker.h
@@ -74,7 +74,8 @@ private:
PointOrder find_correspondences(const vec2* projected_points, const PointModel &model);
PointOrder find_correspondences_previous(const vec2* points, const PointModel &model, const pt_camera_info& info);
- int POSIT(const PointModel& point_model, const PointOrder& order, f focal_length); // The POSIT algorithm, returns the number of iterations
+ // The POSIT algorithm, returns the number of iterations
+ int POSIT(const PointModel& point_model, const PointOrder& order, f focal_length);
Affine X_CM; // transform from model to camera
PointOrder prev_order, prev_scaled_order;
diff --git a/variant/default/main-window.cpp b/variant/default/main-window.cpp
index 76a6d404..d6df6b8f 100644
--- a/variant/default/main-window.cpp
+++ b/variant/default/main-window.cpp
@@ -167,17 +167,17 @@ main_window::main_window() : State(OPENTRACK_BASE_PATH + OPENTRACK_LIBRARY_PATH)
connect(ui.iconcomboTrackerSource,
&QComboBox::currentTextChanged,
this,
- [&](const QString&) { if (pTrackerDialog) pTrackerDialog = nullptr; });
+ [&](const QString&) { pTrackerDialog = nullptr; });
connect(ui.iconcomboTrackerSource,
&QComboBox::currentTextChanged,
this,
- [&](const QString&) { if (pProtocolDialog) pProtocolDialog = nullptr; });
+ [&](const QString&) { pProtocolDialog = nullptr; });
connect(ui.iconcomboTrackerSource,
&QComboBox::currentTextChanged,
this,
- [&](const QString&) { if (pFilterDialog) pFilterDialog = nullptr; });
+ [&](const QString&) { pFilterDialog = nullptr; });
connect(&m.tracker_dll, value_::value_changed<QString>(),
this, &main_window::save_modules,