diff options
55 files changed, 180 insertions, 193 deletions
diff --git a/api/plugin-api.cpp b/api/plugin-api.cpp index 004938f1..0ce321c7 100644 --- a/api/plugin-api.cpp +++ b/api/plugin-api.cpp @@ -1,5 +1,6 @@ #include "plugin-api.hpp" -#include "compat/macros.hpp" + +#include <utility> using namespace plugin_api::detail; @@ -63,7 +64,7 @@ bool module_status::is_ok() const return error.isNull(); } -module_status::module_status(const QString& error) : error(error) {} +module_status::module_status(QString error) : error(std::move(error)) {} module_status module_status_mixin::status_ok() { return module_status(); } diff --git a/api/plugin-api.hpp b/api/plugin-api.hpp index 75555e93..b23a5010 100644 --- a/api/plugin-api.hpp +++ b/api/plugin-api.hpp @@ -95,7 +95,7 @@ struct OTR_API_EXPORT module_status final QString error; bool is_ok() const; - module_status(const QString& error = QString()); + module_status(QString error = {}); }; /* diff --git a/compat/camera-names.cpp b/compat/camera-names.cpp index 22dcdd8f..c88bae75 100644 --- a/compat/camera-names.cpp +++ b/compat/camera-names.cpp @@ -33,30 +33,30 @@ OTR_COMPAT_EXPORT QList<QString> get_camera_names() // Create the System Device Enumerator. HRESULT hr; CoInitialize(nullptr); - ICreateDevEnum *pSysDevEnum = NULL; - hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); + ICreateDevEnum *pSysDevEnum = nullptr; + hr = CoCreateInstance(CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); if (FAILED(hr)) { qDebug() << "failed CLSID_SystemDeviceEnum" << hr; return ret; } // Obtain a class enumerator for the video compressor category. - IEnumMoniker *pEnumCat = NULL; + IEnumMoniker *pEnumCat = nullptr; hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); if (hr == S_OK) { // Enumerate the monikers. - IMoniker *pMoniker = NULL; + IMoniker *pMoniker = nullptr; ULONG cFetched; while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { IPropertyBag *pPropBag; - hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); + 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, 0); + hr = pPropBag->Read(L"FriendlyName", &varName, nullptr); if (SUCCEEDED(hr)) { // Display the name in your UI somehow. diff --git a/compat/correlation-calibrator.cpp b/compat/correlation-calibrator.cpp index 949f10ae..70455818 100644 --- a/compat/correlation-calibrator.cpp +++ b/compat/correlation-calibrator.cpp @@ -49,7 +49,7 @@ static constexpr wchar_t const* const names[6] { L"yaw", L"pitch", L"roll", }; -bool correlation_calibrator::check_buckets(const vec6 &data) +bool correlation_calibrator::check_buckets(const vec6& data) { bool ret = false; unsigned pos[6]; @@ -63,7 +63,7 @@ bool correlation_calibrator::check_buckets(const vec6 &data) { once_only(qDebug() << "idx" << k << "bucket" << (int)pos[k] - << "outside bounds" << nbuckets[k]);; + << "outside bounds" << nbuckets[k]); return false; } @@ -135,8 +135,8 @@ mat66 correlation_calibrator::get_coefficients() const #if defined DEBUG_PRINT fwprintf(stderr, L"v:change-of h:due-to\n"); fwprintf(stderr, L"%10s ", L""); - for (unsigned k = 0; k < 6; k++) - fwprintf(stderr, L"%10s", names[k]); + for (wchar_t const* k : names) + fwprintf(stderr, L"%10s", k); fwprintf(stderr, L"\n"); for (unsigned i = 0; i < 6; i++) diff --git a/compat/macros.hpp b/compat/macros.hpp index 761da0b1..61c49975 100644 --- a/compat/macros.hpp +++ b/compat/macros.hpp @@ -2,21 +2,17 @@ #if defined _MSC_VER # define cc_noinline __declspec(noinline) -#elif defined __GNUG__ -# define cc_noinline __attribute__((noinline)) #else -# define cc_noinline +# define cc_noinline __attribute__((noinline)) #endif #if defined _MSC_VER # define cc_forceinline __forceinline #else -# define cc_forceinline __attribute__((always_inline, gnu_inline)) inline +# define cc_forceinline __attribute__((always_inline)) #endif -#ifdef Q_CREATOR_RUN -# define cc_warn_unused_result -#elif defined _MSC_VER +#if defined _MSC_VER # define cc_warn_unused_result _Check_return_ #else # define cc_warn_unused_result __attribute__((warn_unused_result)) @@ -40,15 +36,17 @@ #if !defined PP_CAT # define PP_CAT(x,y) PP_CAT1(x,y) -# define PP_CAT1(x,y) x##y +# define PP_CAT1(x,y) PP_CAT2(x,y) +# define PP_CAT2(x,y) x ## y #endif -#define once_only(...) do { static bool once__ = false; if (!once__) { once__ = true; __VA_ARGS__; } } while(false) - #if defined __cplusplus // from now only C++ +//#define once_only(...) do { static bool once__ = false; if (!once__) { once__ = true; __VA_ARGS__; } } while(false) +#define once_only(expr) ([&] { static decltype(auto) ret___1132 = (expr); return ret___1132; }()) + #include <type_traits> template<typename t> @@ -66,7 +64,7 @@ constexpr cc_forceinline void static_warn<true>() {} static_warn<(cond)>(); \ #define progn(...) (([&] { __VA_ARGS__ })()) -#define prog1(x, ...) (([&] { auto _ret1324 = (x); do { __VA_ARGS__; } while (0); return _ret1324; })()) +#define prog1(x, ...) (([&] { decltype(auto) ret1324 = (x); __VA_ARGS__; return ret1324; })()) // end c++-only macros #endif diff --git a/compat/shm.cpp b/compat/shm.cpp index 0f44d8bc..791cb303 100644 --- a/compat/shm.cpp +++ b/compat/shm.cpp @@ -10,7 +10,7 @@ #if defined _WIN32 #include <cstring> -#include <stdio.h> +#include <cstdio> #include <accctrl.h> #include <aclapi.h> @@ -131,7 +131,7 @@ bool shm_wrapper::success() #ifndef _WIN32 return mem != (void*) -1; #else - return mem != NULL; + return mem != nullptr; #endif } diff --git a/compat/timer.cpp b/compat/timer.cpp index 0e7fb362..dc9808b1 100644 --- a/compat/timer.cpp +++ b/compat/timer.cpp @@ -82,7 +82,7 @@ static void otr_clock_gettime(timespec* ts) (void) QueryPerformanceCounter(&d); using ll = long long; - const ll part = ll(std::roundl((d.QuadPart * 1000000000.L) / ll(freq.QuadPart))); + const auto part = ll(std::roundl((d.QuadPart * 1000000000.L) / ll(freq.QuadPart))); using t_s = decltype(ts->tv_sec); using t_ns = decltype(ts->tv_nsec); diff --git a/compat/timer.hpp b/compat/timer.hpp index fb14145d..26e612b0 100644 --- a/compat/timer.hpp +++ b/compat/timer.hpp @@ -33,7 +33,7 @@ struct OTR_COMPAT_EXPORT Timer final double elapsed_ms() const; double elapsed_seconds() const; private: - struct timespec state; + struct timespec state {}; static void gettime(struct timespec* state); time_type conv_nsecs(const struct timespec& cur) const; using ns = time_units::ns; diff --git a/csv/csv.cpp b/csv/csv.cpp index 31f361a8..73c56aed 100644 --- a/csv/csv.cpp +++ b/csv/csv.cpp @@ -132,12 +132,12 @@ bool CSV::getGameData(int id, unsigned char* table, QString& gamename) { if (gameLine.at(6).compare(id_str, Qt::CaseInsensitive) == 0) { - const QString& proto = gameLine.at(3); - const QString& name = gameLine.at(1); + const QString& proto = gameLine[3]; + QString& name = gameLine[1]; - const QByteArray id_cstr = gameLine.at(7).toLatin1(); + const QByteArray id_cstr = gameLine[7].toLatin1(); - if (proto == QString("V160")) + if (proto == QStringLiteral("V160")) { /* nothing */ } diff --git a/cv/affine.cpp b/cv/affine.cpp index 1b37305c..4ec63e57 100644 --- a/cv/affine.cpp +++ b/cv/affine.cpp @@ -15,17 +15,17 @@ Affine::Affine(const mat33& R, const vec3& t) : R(R),t(t) {} Affine operator*(const Affine& X, const Affine& Y) { - return Affine(X.R*Y.R, X.R*Y.t + X.t); + return { X.R*Y.R, X.R*Y.t + X.t }; } Affine operator*(const mat33& X, const Affine& Y) { - return Affine(X*Y.R, X*Y.t); + return { X*Y.R, X*Y.t }; } Affine operator*(const Affine& X, const mat33& Y) { - return Affine(X.R*Y, X.t); + return { X.R*Y, X.t }; } vec3 operator*(const Affine& X, const vec3& v) diff --git a/cv/translation-calibrator.hpp b/cv/translation-calibrator.hpp index c1f6d2ec..774bc7cb 100644 --- a/cv/translation-calibrator.hpp +++ b/cv/translation-calibrator.hpp @@ -47,5 +47,5 @@ private: static constexpr inline double pitch_spacing_in_degrees = 1.5; static constexpr inline double roll_spacing_in_degrees = 3.5; - unsigned yaw_rdof, pitch_rdof, roll_rdof, nsamples; + unsigned yaw_rdof, pitch_rdof, roll_rdof, nsamples = 0; }; diff --git a/cv/video-property-page.cpp b/cv/video-property-page.cpp index 7d94bbc2..e76f8bc3 100644 --- a/cv/video-property-page.cpp +++ b/cv/video-property-page.cpp @@ -37,7 +37,7 @@ bool video_property_page::show_from_capture(cv::VideoCapture& cap, int /*index * struct prop_settings_worker final : QThread { - prop_settings_worker(int idx); + explicit prop_settings_worker(int idx); ~prop_settings_worker() override; void _open_prop_page(); void run() override; diff --git a/cv/video-widget.cpp b/cv/video-widget.cpp index fd4fe350..d93429cb 100644 --- a/cv/video-widget.cpp +++ b/cv/video-widget.cpp @@ -8,6 +8,7 @@ #include "video-widget.hpp" #include "compat/check-visible.hpp" +#include "compat/math.hpp" #include <cstring> @@ -88,8 +89,8 @@ void cv_video_widget::paintEvent(QPaintEvent*) double dpr = devicePixelRatioF(); - int W = int(QWidget::width() * dpr); - int H = int(QWidget::height() * dpr); + int W = iround(QWidget::width() * dpr); + int H = iround(QWidget::height() * dpr); painter.drawImage(rect(), texture); diff --git a/dinput/keybinding-worker.cpp b/dinput/keybinding-worker.cpp index 40754b4f..0bdc18cd 100644 --- a/dinput/keybinding-worker.cpp +++ b/dinput/keybinding-worker.cpp @@ -47,7 +47,7 @@ bool KeybindingWorker::init() return false; } - if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL) != DI_OK) { + if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, nullptr) != DI_OK) { qDebug() << "setup CreateDevice function failed!" << GetLastError(); return false; } @@ -55,13 +55,13 @@ bool KeybindingWorker::init() if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) { qDebug() << "setup SetDataFormat function failed!" << GetLastError(); dinkeyboard->Release(); - dinkeyboard = 0; + dinkeyboard = nullptr; return false; } if (dinkeyboard->SetCooperativeLevel((HWND) fake_main_window.winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { dinkeyboard->Release(); - dinkeyboard = 0; + dinkeyboard = nullptr; qDebug() << "setup SetCooperativeLevel function failed!" << GetLastError(); return false; } @@ -77,7 +77,7 @@ bool KeybindingWorker::init() { qDebug() << "setup keyboard buffer mode failed!"; dinkeyboard->Release(); - dinkeyboard = 0; + dinkeyboard = nullptr; return false; } } @@ -85,7 +85,7 @@ bool KeybindingWorker::init() if (dinkeyboard->Acquire() != DI_OK) { dinkeyboard->Release(); - dinkeyboard = 0; + dinkeyboard = nullptr; qDebug() << "setup dinkeyboard Acquire failed!" << GetLastError(); return false; } @@ -112,7 +112,7 @@ void KeybindingWorker::run() { QMutexLocker l(&mtx); - if (receivers.size()) + if (!receivers.empty()) { /* There are some problems reported on various forums * with regard to key-up events. But that's what I dug up: diff --git a/dinput/keybinding-worker.hpp b/dinput/keybinding-worker.hpp index 2596bda0..7481bcea 100644 --- a/dinput/keybinding-worker.hpp +++ b/dinput/keybinding-worker.hpp @@ -42,7 +42,7 @@ struct OTR_DINPUT_EXPORT KeybindingWorker : private QThread using fun = std::function<void(const Key&)>; private: - LPDIRECTINPUTDEVICE8 dinkeyboard; + LPDIRECTINPUTDEVICE8 dinkeyboard { nullptr }; win32_joy_ctx joy_ctx; std::vector<std::unique_ptr<fun>> receivers; QMutex mtx; @@ -62,7 +62,7 @@ private: ~KeybindingWorker(); static constexpr int num_keyboard_states = 16; - DIDEVICEOBJECTDATA keyboard_states[num_keyboard_states]; + DIDEVICEOBJECTDATA keyboard_states[num_keyboard_states] {}; KeybindingWorker(const KeybindingWorker&) = delete; KeybindingWorker& operator=(KeybindingWorker&) = delete; diff --git a/dinput/win32-joystick.cpp b/dinput/win32-joystick.cpp index e9a6c4ed..ed5bd214 100644 --- a/dinput/win32-joystick.cpp +++ b/dinput/win32-joystick.cpp @@ -17,11 +17,11 @@ DIDEVICEOBJECTDATA win32_joy_ctx::joy::keystate_buffers[win32_joy_ctx::joy::num_ QMutex win32_joy_ctx::enum_state::mtx; win32_joy_ctx::enum_state win32_joy_ctx::enumerator; -void win32_joy_ctx::poll(fn f) +void win32_joy_ctx::poll(fn const& f) { //refresh(false); - QMutexLocker l(&enumerator.mtx); + QMutexLocker l(&enum_state::mtx); auto& joys = enumerator.get_joys(); @@ -33,7 +33,7 @@ void win32_joy_ctx::poll(fn f) bool win32_joy_ctx::poll_axis(const QString &guid, int* axes) { - QMutexLocker l(&enumerator.mtx); + QMutexLocker l(&enum_state::mtx); for (int k = 0; k < 10; k++) { @@ -102,7 +102,7 @@ bool win32_joy_ctx::poll_axis(const QString &guid, int* axes) std::vector<win32_joy_ctx::joy_info> win32_joy_ctx::get_joy_info() { std::vector<joy_info> ret; - QMutexLocker l(&enumerator.mtx); + QMutexLocker l(&enum_state::mtx); auto& joys = enumerator.get_joys(); ret.reserve(joys.size()); @@ -121,7 +121,7 @@ win32_joy_ctx::win32_joy_ctx() void win32_joy_ctx::refresh() { - QMutexLocker l(&enumerator.mtx); + QMutexLocker l(&enum_state::mtx); enumerator.refresh(); } @@ -131,7 +131,7 @@ QString win32_joy_ctx::guid_to_string(const GUID& guid) wchar_t szGuidW[40] = {0}; StringFromGUID2(guid, szGuidW, 40); - WideCharToMultiByte(0, 0, szGuidW, -1, buf, 40, NULL, NULL); + WideCharToMultiByte(0, 0, szGuidW, -1, buf, 40, nullptr, nullptr); return QString(buf); } @@ -148,7 +148,7 @@ void win32_joy_ctx::joy::release() } } -bool win32_joy_ctx::joy::poll(fn f) +bool win32_joy_ctx::joy::poll(fn const& f) { HRESULT hr; @@ -380,7 +380,7 @@ BOOL CALLBACK win32_joy_ctx::enum_state::EnumObjectsCallback(const DIDEVICEOBJEC return DIENUM_CONTINUE; } -win32_joy_ctx::joy::joy(LPDIRECTINPUTDEVICE8 handle, const QString &guid, const QString &name) +win32_joy_ctx::joy::joy(LPDIRECTINPUTDEVICE8 handle, const QString& guid, const QString &name) : joy_handle(handle), guid(guid), name(name) { //qDebug() << "make joy" << guid << name << joy_handle; diff --git a/dinput/win32-joystick.hpp b/dinput/win32-joystick.hpp index 8b71b8b7..f42bd450 100644 --- a/dinput/win32-joystick.hpp +++ b/dinput/win32-joystick.hpp @@ -54,7 +54,7 @@ struct OTR_DINPUT_EXPORT win32_joy_ctx final ~joy(); void release(); - bool poll(fn f); + bool poll(fn const& f); }; using joys_t = std::unordered_map<QString, std::shared_ptr<joy>>; @@ -66,7 +66,7 @@ struct OTR_DINPUT_EXPORT win32_joy_ctx final QString name, guid; }; - void poll(fn f); + void poll(fn const& f); bool poll_axis(const QString& guid, int* axes); std::vector<joy_info> get_joy_info(); diff --git a/filter-accela/ftnoir_filter_accela.cpp b/filter-accela/ftnoir_filter_accela.cpp index 7bddec1c..15e2edfb 100644 --- a/filter-accela/ftnoir_filter_accela.cpp +++ b/filter-accela/ftnoir_filter_accela.cpp @@ -15,7 +15,7 @@ #include "compat/math-imports.hpp" #include "compat/time.hpp" -accela::accela() : first_run(true) +accela::accela() { s.make_splines(spline_rot, spline_pos); } diff --git a/filter-accela/ftnoir_filter_accela.h b/filter-accela/ftnoir_filter_accela.h index 40ba82ba..a3f93756 100644 --- a/filter-accela/ftnoir_filter_accela.h +++ b/filter-accela/ftnoir_filter_accela.h @@ -27,14 +27,14 @@ public: module_status initialize() override { return status_ok(); } private: settings_accela s; - double last_output[6], deltas[6]; + double last_output[6] {}, deltas[6] {}; Timer t; #if defined DEBUG_ACCELA Timer debug_timer; double debug_max; variance var; #endif - bool first_run; + bool first_run = true; }; class dialog_accela : public IFilterDialog diff --git a/filter-ewma2/ftnoir_filter_ewma2.cpp b/filter-ewma2/ftnoir_filter_ewma2.cpp index c79596ef..b29746a0 100644 --- a/filter-ewma2/ftnoir_filter_ewma2.cpp +++ b/filter-ewma2/ftnoir_filter_ewma2.cpp @@ -22,7 +22,7 @@ // to minSmooth at a rate controlled by the powCurve setting. -ewma::ewma() : first_run(true) +ewma::ewma() { } @@ -48,10 +48,10 @@ void ewma::filter(const double *input, double *output) double noise_alpha = dt/(dt + noise_RC); // scale curve .01->1 where 1.0 is sqrt(norm_noise). - const double smoothing_scale_curve = static_cast<slider_value>(s.kSmoothingScaleCurve); + const double smoothing_scale_curve = *s.kSmoothingScaleCurve; // min/max smoothing .01->1 - const double min_smoothing = static_cast<slider_value>(s.kMinSmoothing); - const double max_smoothing = std::fmax(min_smoothing, static_cast<slider_value>(s.kMaxSmoothing)); + const double min_smoothing = *s.kMinSmoothing; + const double max_smoothing = std::fmax(min_smoothing, *s.kMaxSmoothing); // Calculate the new camera position. for (int i=0;i<6;i++) diff --git a/filter-ewma2/ftnoir_filter_ewma2.h b/filter-ewma2/ftnoir_filter_ewma2.h index fd7047e1..1cd30a6b 100644 --- a/filter-ewma2/ftnoir_filter_ewma2.h +++ b/filter-ewma2/ftnoir_filter_ewma2.h @@ -36,7 +36,7 @@ private: double last_output[6]; Timer timer; settings s; - bool first_run; + bool first_run = true; }; class dialog_ewma: public IFilterDialog diff --git a/filter-kalman/kalman.cpp b/filter-kalman/kalman.cpp index 3a0da608..c70093bb 100644 --- a/filter-kalman/kalman.cpp +++ b/filter-kalman/kalman.cpp @@ -112,8 +112,8 @@ void kalman::fill_process_noise_cov_matrix(StateMatrix &target, double dt) const // brownian motion. Unlike standard models for tracking of objects // with a very well predictable trajectory (e.g. // https://en.wikipedia.org/wiki/Kalman_filter#Example_application.2C_technical) - double sigma_pos = s.process_sigma_pos; - double sigma_angle = s.process_sigma_rot; + double sigma_pos = settings::process_sigma_pos; + double sigma_angle = settings::process_sigma_rot; double a_pos = sigma_pos * sigma_pos * dt; double a_ang = sigma_angle * sigma_angle * dt; constexpr double b = 20; @@ -238,7 +238,7 @@ void kalman::filter(const double* input_, double *output_) // We can use this to calculate the size of the deadzone, so that in the stationary state the // deadzone size is small. Thus the tracking error due to the dz-filter becomes also small. PoseVector variance = kf.state_cov.diagonal().head(6); - dz_filter.dz_size = variance.cwiseSqrt() * s.deadzone_scale; + dz_filter.dz_size = variance.cwiseSqrt() * settings::deadzone_scale; } output = dz_filter.filter(output); diff --git a/gui/init.cpp b/gui/init.cpp index cddea9ae..75f6b1eb 100644 --- a/gui/init.cpp +++ b/gui/init.cpp @@ -169,7 +169,7 @@ void attach_parent_console() #endif -int run_window(QApplication& app, std::unique_ptr<QWidget> main_window) +static int run_window(std::unique_ptr<QWidget> main_window) { if (!main_window->isEnabled()) { @@ -177,8 +177,8 @@ int run_window(QApplication& app, std::unique_ptr<QWidget> main_window) return 2; } - app.setQuitOnLastWindowClosed(true); - int status = app.exec(); + QApplication::setQuitOnLastWindowClosed(true); + int status = QApplication::exec(); return status; } @@ -224,7 +224,7 @@ OTR_GUI_EXPORT int otr_main(int argc, char** argv, std::function<QWidget*()> con } } - int ret = run_window(app, std::unique_ptr<QWidget>(make_main_window())); + int ret = run_window(std::unique_ptr<QWidget>(make_main_window())); #if 0 // msvc crashes in Qt plugin system's dtor diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp index 4987d9c0..b9964ecb 100644 --- a/gui/keyboard.cpp +++ b/gui/keyboard.cpp @@ -12,14 +12,14 @@ keyboard_listener::keyboard_listener(QWidget* parent) : if (k.alt) mods |= Qt::AltModifier; if (k.shift) mods |= Qt::ShiftModifier; if (k.ctrl) mods |= Qt::ControlModifier; - joystick_button_pressed(k.guid, k.keycode | mods, k.held); + emit joystick_button_pressed(k.guid, k.keycode | mods, k.held); } else { Qt::KeyboardModifiers m; QKeySequence k_; if (win_key::to_qt(k, k_, m)) - key_pressed(static_cast<QVariant>(k_).toInt() | m); + emit key_pressed(static_cast<QVariant>(k_).toInt() | m); } }) // token initializer ends, real ctor body begins diff --git a/gui/mapping-dialog.cpp b/gui/mapping-dialog.cpp index 43130a92..c6e49cee 100644 --- a/gui/mapping-dialog.cpp +++ b/gui/mapping-dialog.cpp @@ -12,6 +12,8 @@ #include <QtEvents> +using namespace options; + mapping_dialog::mapping_dialog(Mappings& m) : m(m), widgets{} { ui.setupUi(this); diff --git a/gui/process_detector.cpp b/gui/process_detector.cpp index 7563d521..969b1856 100644 --- a/gui/process_detector.cpp +++ b/gui/process_detector.cpp @@ -58,7 +58,7 @@ QHash<QString, QString> proc_detector_settings::split_process_names() QHash<QString, QString> ret; QString str = get_game_list(); QStringList pairs = str.split(RECORD_SEPARATOR, QString::SkipEmptyParts); - for (auto pair : pairs) + for (auto const& pair : pairs) { QList<QString> tmp = pair.split(UNIT_SEPARATOR); if (tmp.count() != 2) @@ -67,7 +67,7 @@ QHash<QString, QString> proc_detector_settings::split_process_names() continue; if (tmp[1].contains(UNIT_SEPARATOR) || tmp[1].contains(RECORD_SEPARATOR)) continue; - if (tmp[0] == QLatin1String("") || tmp[1] == QLatin1String("")) + if (tmp[0].isEmpty() || tmp[1].isEmpty()) continue; ret[tmp[0]] = tmp[1]; } @@ -76,21 +76,19 @@ QHash<QString, QString> proc_detector_settings::split_process_names() void BrowseButton::browse() { - QFileDialog dialog(this); - dialog.setFileMode(QFileDialog::ExistingFile); QString dir_path = QFileInfo(group::ini_pathname()).absolutePath(); - QString filename = dialog.getOpenFileName( - this, - tr("Set executable name"), - dir_path, - tr("Executable (*.exe);;All Files (*)")); + QString filename = QFileDialog::getOpenFileName( + this, + tr("Set executable name"), + dir_path, + tr("Executable (*.exe);;All Files (*)")); QDir::setCurrent(OPENTRACK_BASE_PATH); filename = QFileInfo(filename).fileName(); if (!filename.isNull()) twi->setText(filename); } -int process_detector::add_row(QString exe_name, QString profile) +int process_detector::add_row(QString const& exe_name, QString const& profile) { int i = ui.tableWidget->rowCount(); ui.tableWidget->insertRow(i); @@ -122,7 +120,7 @@ void process_detector::add_items() ui.tableWidget->clearContents(); auto keys = names.keys(); std::sort(keys.begin(), keys.end()); - for (auto n : keys) + for (auto const& n : keys) add_row(n, names[n]); } diff --git a/gui/process_detector.h b/gui/process_detector.h index c3ff078a..7439b19b 100644 --- a/gui/process_detector.h +++ b/gui/process_detector.h @@ -34,7 +34,7 @@ class OTR_GUI_EXPORT process_detector final : public QWidget Ui_process_detector ui; proc_detector_settings s; - int add_row(QString exe_name = "...", QString profile = ""); + int add_row(const QString& exe_name = "...", const QString& profile = ""); void add_items(); public: process_detector(QWidget* parent = nullptr); diff --git a/gui/settings.cpp b/gui/settings.cpp index ee0e9959..d280a9b7 100644 --- a/gui/settings.cpp +++ b/gui/settings.cpp @@ -9,6 +9,9 @@ #include "settings.hpp" #include "keyboard.h" #include "compat/library-path.hpp" + +#include <utility> + #include <QPushButton> #include <QLayout> #include <QDialog> @@ -41,8 +44,8 @@ void options_dialog::set_disable_translation_state(bool value) }); } -options_dialog::options_dialog(std::function<void(bool)> pause_keybindings) : - pause_keybindings(pause_keybindings) +options_dialog::options_dialog(std::function<void(bool)>&& pause_keybindings) : + pause_keybindings(std::move(pause_keybindings)) { ui.setupUi(this); diff --git a/gui/settings.hpp b/gui/settings.hpp index 63e109a4..ebcaa66c 100644 --- a/gui/settings.hpp +++ b/gui/settings.hpp @@ -4,10 +4,12 @@ #include "gui/ui_settings-dialog.h" #include "logic/shortcuts.h" + +#include <functional> + #include <QObject> #include <QDialog> #include <QWidget> -#include <functional> class OTR_GUI_EXPORT options_dialog : public QDialog { @@ -15,12 +17,12 @@ class OTR_GUI_EXPORT options_dialog : public QDialog signals: void closing(); public: - options_dialog(std::function<void(bool)> pause_keybindings); + options_dialog(std::function<void(bool)>&& pause_keybindings); private: main_settings main; std::function<void(bool)> pause_keybindings; Ui::options_dialog ui; - void closeEvent(QCloseEvent *) override; + void closeEvent(QCloseEvent*) override; static QString kopts_to_string(const key_opts& opts); private slots: void doOK(); diff --git a/logic/pipeline.cpp b/logic/pipeline.cpp index 7b4444c3..bf264315 100644 --- a/logic/pipeline.cpp +++ b/logic/pipeline.cpp @@ -130,7 +130,7 @@ Pose reltrans::apply_pipeline(reltrans_state state, const Pose& value, interp_timer.start(); - if (RC_phase + 1 != std::size(RC_phases) && + if (RC_phase + 1 < std::size(RC_phases) && interp_phase_timer.elapsed_seconds() > RC_time_deltas[RC_phase]) { RC_phase++; @@ -252,7 +252,7 @@ void emit_nan_check_msg(const char* text, const char* fun, int line) qDebug() << "nan check failed" << "for:" << text << "function:" << fun - << "line:" << line; + << "line:" << line ); } @@ -577,7 +577,7 @@ void pipeline::run() { qDebug() << "tracker: backlog interval overflow" << time_cast<ms>(backlog_time).count() << "ms"; - backlog_time = backlog_time.zero(); + backlog_time = ns::zero(); } backlog_time += ns(elapsed_nsecs - const_sleep_ms); diff --git a/logic/pipeline.hpp b/logic/pipeline.hpp index 4a676862..0b48d741 100644 --- a/logic/pipeline.hpp +++ b/logic/pipeline.hpp @@ -39,7 +39,7 @@ class reltrans // this implements smooth transition into reltrans mode // once not aiming anymore. see `apply_pipeline()'. Timer interp_phase_timer; - unsigned RC_phase; + unsigned RC_phase = 0; bool cur = false; bool in_zone = false; diff --git a/logic/shortcuts.cpp b/logic/shortcuts.cpp index 5ddefc1f..478036a2 100644 --- a/logic/shortcuts.cpp +++ b/logic/shortcuts.cpp @@ -130,14 +130,14 @@ void Shortcuts::reload(const t_keys& keys_) const auto& kk = keys_[i]; const key_opts& opts = std::get<0>(kk); const bool held = std::get<2>(kk); - auto fun = std::get<1>(kk); + auto const& fun = std::get<1>(kk); #ifdef _WIN32 K k; #else K k(nullptr); #endif bind_shortcut(k, opts, held); - keys.push_back(tt(k, [=](bool flag) { fun(flag); }, held)); + keys.emplace_back(k, [=](bool flag) { fun(flag); }, held); #ifndef _WIN32 const int idx = keys.size() - 1; diff --git a/logic/win32-shortcuts.cpp b/logic/win32-shortcuts.cpp index 2099ce09..170d16fe 100644 --- a/logic/win32-shortcuts.cpp +++ b/logic/win32-shortcuts.cpp @@ -119,7 +119,7 @@ static const win_key windows_key_sequences[] { { DIK_PAUSE, Qt::Key_Pause}, { DIK_NUMLOCK, Qt::Key_NumLock}, { DIK_CAPSLOCK, Qt::Key_CapsLock}, -#define mod(x, y) static_cast<Qt::Key>(x | y) +#define mod(x, y) static_cast<Qt::Key>((x) | (y)) { DIK_NUMPAD0, mod(Qt::Key_0, Qt::KeypadModifier)}, { DIK_NUMPAD0, mod(Qt::Key_0, Qt::KeypadModifier)}, { DIK_NUMPAD1, mod(Qt::Key_1, Qt::KeypadModifier)}, diff --git a/migration/20160906_00-mappings.cpp b/migration/20160906_00-mappings.cpp index 567fbdcb..0019d0ef 100644 --- a/migration/20160906_00-mappings.cpp +++ b/migration/20160906_00-mappings.cpp @@ -18,6 +18,7 @@ #include <QDebug> +using namespace options; using namespace migrations; static const char* const old_names[] = @@ -46,19 +47,19 @@ static QList<QList<QPointF>> get_old_splines() return group::with_settings_object([&](QSettings& settings) { for (const char* name : old_names) { + const int max = settings.value("point-count", 0).toInt(); + + if (max < 0 || max > 1 << 16) + return ret; + QList<QPointF> points; + points.reserve(max); settings.beginGroup(QString("Curves-%1").arg(name)); - const int max = settings.value("point-count", 0).toInt(); - for (int i = 0; i < max; i++) - { - QPointF new_point(settings.value(QString("point-%1-x").arg(i), 0).toDouble(), - settings.value(QString("point-%1-y").arg(i), 0).toDouble()); - - points.append(new_point); - } + points.append({ settings.value(QString("point-%1-x").arg(i), 0).toDouble(), + settings.value(QString("point-%1-y").arg(i), 0).toDouble() }); settings.endGroup(); @@ -85,7 +86,7 @@ struct mappings_from_2_3_0_rc11 : migration // run only if old splines exist for (const QList<QPointF>& points : get_old_splines()) - if (points.size()) + if (!points.empty()) return true; } diff --git a/options/connector.cpp b/options/connector.cpp index 6031d9ed..2d039ccf 100644 --- a/options/connector.cpp +++ b/options/connector.cpp @@ -27,7 +27,7 @@ bool connector::is_equal(const QString& name, const QVariant& val1, const QVaria auto it = connected_values.find(name); - if (it != connected_values.cend() && std::get<0>((*it).second).size() != 0) + if (it != connected_values.cend() && !std::get<0>((*it).second).empty()) return std::get<1>((*it).second)(val1, val2); else return generic_is_equal(val1, val2); @@ -37,29 +37,23 @@ bool connector::on_value_destructed_impl(const QString& name, value_type val) { QMutexLocker l(get_mtx()); - const bool ok = progn( - auto it = connected_values.find(name); + auto it = connected_values.find(name); - if (it != connected_values.end()) + if (it != connected_values.end()) + { + std::vector<value_type>& values = std::get<0>((*it).second); + for (auto it = values.begin(); it != values.end(); it++) { - std::vector<value_type>& values = std::get<0>((*it).second); - for (auto it = values.begin(); it != values.end(); it++) + if (*it == val) { - if (*it == val) - { - values.erase(it); - return true; - } + values.erase(it); + return true; } } - return false; - ); - - return ok; + } + return false; } - - void connector::on_value_destructed(const QString& name, value_type val) { if (!name.size()) diff --git a/options/group.cpp b/options/group.cpp index 77773744..788dd5de 100644 --- a/options/group.cpp +++ b/options/group.cpp @@ -69,8 +69,7 @@ bool group::contains(const QString &s) const bool group::is_portable_installation() { #if defined _WIN32 - if (QFile::exists(OPENTRACK_BASE_PATH + "/portable.txt")) - return true; + return QFile::exists(OPENTRACK_BASE_PATH + "/portable.txt"); #endif return false; } diff --git a/options/group.hpp b/options/group.hpp index c3fce892..0717e2c9 100644 --- a/options/group.hpp +++ b/options/group.hpp @@ -1,5 +1,6 @@ #pragma once +#include "compat/macros.hpp" #include "export.hpp" // included here to propagate into callers of options::group diff --git a/pose-widget/pose-widget.cpp b/pose-widget/pose-widget.cpp index 9b9a1478..08e3a469 100644 --- a/pose-widget/pose-widget.cpp +++ b/pose-widget/pose-widget.cpp @@ -407,7 +407,7 @@ vec2 pose_transform::project(const vec3 &point) num y = h_ * translation.y() / 2 / -80; if (fabs(y) > h_/2) y = y > 0 ? h_/2 : h_/-2; - return vec2(z * (ret.x() + x), z * (ret.y() + y)); + return { z * (ret.x() + x), z * (ret.y() + y) }; } vec3 pose_transform::project2(const vec3 &point) diff --git a/proto-fsuipc/ftnoir_protocol_fsuipc.cpp b/proto-fsuipc/ftnoir_protocol_fsuipc.cpp index 4db85ac5..7ba466a8 100644 --- a/proto-fsuipc/ftnoir_protocol_fsuipc.cpp +++ b/proto-fsuipc/ftnoir_protocol_fsuipc.cpp @@ -149,7 +149,7 @@ module_status fsuipc::initialize() FSUIPCLib.setFileName( s.LocationOfDLL ); FSUIPCLib.setLoadHints(QLibrary::PreventUnloadHint); - if (FSUIPCLib.load() != true) + if (!FSUIPCLib.load()) return error(tr("Can't load fsuipc at '%1'").arg(s.LocationOfDLL)); else return status_ok(); diff --git a/proto-ft/ftnoir_protocol_ft.cpp b/proto-ft/ftnoir_protocol_ft.cpp index 389e12b2..bf99a94f 100644 --- a/proto-ft/ftnoir_protocol_ft.cpp +++ b/proto-ft/ftnoir_protocol_ft.cpp @@ -31,7 +31,7 @@ cc_noinline void store(float volatile& place, const float value) { float f32; LONG i32; - } value_; + } value_ {}; value_.f32 = value; @@ -84,7 +84,7 @@ void freetrack::pose(const double* headpose) union { unsigned char table[8]; std::int32_t ints[2]; - } t; + } t {}; t.ints[0] = 0; t.ints[1] = 0; diff --git a/proto-simconnect/ftnoir_protocol_sc.cpp b/proto-simconnect/ftnoir_protocol_sc.cpp index 05cc3d0b..ab4a85dd 100644 --- a/proto-simconnect/ftnoir_protocol_sc.cpp +++ b/proto-simconnect/ftnoir_protocol_sc.cpp @@ -14,10 +14,6 @@ #include "compat/timer.hpp" #include "compat/library-path.hpp" -simconnect::simconnect() : hSimConnect(nullptr), should_reconnect(false) -{ -} - simconnect::~simconnect() { requestInterruption(); @@ -112,11 +108,8 @@ void simconnect::pose( const double *headpose ) class ActivationContext { public: - ActivationContext(const int resid) : - ok(false) + explicit ActivationContext(int resid) { - hactctx = INVALID_HANDLE_VALUE; - actctx_cookie = 0; ACTCTXA actx = {}; actx.cbSize = sizeof(actx); actx.lpResourceName = MAKEINTRESOURCEA(resid); @@ -126,7 +119,6 @@ public: QByteArray name = QFile::encodeName(path); actx.lpSource = name.constData(); hactctx = CreateActCtxA(&actx); - actctx_cookie = 0; if (hactctx != INVALID_HANDLE_VALUE) { if (!ActivateActCtx(hactctx, &actctx_cookie)) @@ -151,9 +143,9 @@ public: bool is_ok() const { return ok; } private: - ULONG_PTR actctx_cookie; - HANDLE hactctx; - bool ok; + ULONG_PTR actctx_cookie = 0; + HANDLE hactctx = INVALID_HANDLE_VALUE; + bool ok = false; }; module_status simconnect::initialize() @@ -174,27 +166,22 @@ module_status simconnect::initialize() } simconnect_open = (importSimConnect_Open) SCClientLib.resolve("SimConnect_Open"); - if (simconnect_open == NULL) { + if (!simconnect_open) return error("Open function not found in DLL!"); - } simconnect_set6DOF = (importSimConnect_CameraSetRelative6DOF) SCClientLib.resolve("SimConnect_CameraSetRelative6DOF"); - if (simconnect_set6DOF == NULL) { + if (!simconnect_set6DOF) return error("CameraSetRelative6DOF function not found in DLL!"); - } simconnect_close = (importSimConnect_Close) SCClientLib.resolve("SimConnect_Close"); - if (simconnect_close == NULL) { + if (!simconnect_close) return error("Close function not found in DLL!"); - } simconnect_calldispatch = (importSimConnect_CallDispatch) SCClientLib.resolve("SimConnect_CallDispatch"); - if (simconnect_calldispatch == NULL) { + if (!simconnect_calldispatch) return error("CallDispatch function not found in DLL!"); - } simconnect_subscribetosystemevent = (importSimConnect_SubscribeToSystemEvent) SCClientLib.resolve("SimConnect_SubscribeToSystemEvent"); - if (simconnect_subscribetosystemevent == NULL) { + if (!simconnect_subscribetosystemevent) return error("SubscribeToSystemEvent function not found in DLL!"); - } start(); diff --git a/proto-simconnect/ftnoir_protocol_sc.h b/proto-simconnect/ftnoir_protocol_sc.h index 6932bfc8..749f7906 100644 --- a/proto-simconnect/ftnoir_protocol_sc.h +++ b/proto-simconnect/ftnoir_protocol_sc.h @@ -38,7 +38,7 @@ class simconnect : private QThread, public IProtocol { Q_OBJECT public: - simconnect(); + simconnect() = default; ~simconnect() override; module_status initialize() override; void pose(const double* headpose); @@ -74,12 +74,12 @@ private: void run() override; - std::atomic<float> virtSCPosX; - std::atomic<float> virtSCPosY; - std::atomic<float> virtSCPosZ; - std::atomic<float> virtSCRotX; - std::atomic<float> virtSCRotY; - std::atomic<float> virtSCRotZ; + std::atomic<float> virtSCPosX {0}; + std::atomic<float> virtSCPosY {0}; + std::atomic<float> virtSCPosZ {0}; + std::atomic<float> virtSCRotX {0}; + std::atomic<float> virtSCRotY {0}; + std::atomic<float> virtSCRotZ {0}; importSimConnect_Open simconnect_open; importSimConnect_Close simconnect_close; @@ -87,8 +87,8 @@ private: importSimConnect_CallDispatch simconnect_calldispatch; importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent; - HANDLE hSimConnect; - std::atomic<bool> should_reconnect; + HANDLE hSimConnect = nullptr; + std::atomic<bool> should_reconnect = false; static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); settings s; QLibrary SCClientLib; diff --git a/proto-vjoystick/vjoystick.h b/proto-vjoystick/vjoystick.h index d859d8a9..81f70a7f 100644 --- a/proto-vjoystick/vjoystick.h +++ b/proto-vjoystick/vjoystick.h @@ -27,8 +27,8 @@ public: private: state joy_state; - LONG axis_min[6]; - LONG axis_max[6]; + LONG axis_min[6] {}; + LONG axis_max[6] {}; void init(); public: diff --git a/spline/spline.cpp b/spline/spline.cpp index dcd8f5ab..64a9142d 100644 --- a/spline/spline.cpp +++ b/spline/spline.cpp @@ -134,7 +134,7 @@ QPointF spline::ensure_in_bounds(const QList<QPointF>& points, int i) const int sz = points.size(); if (i < 0 || sz == 0) - return QPointF(0, 0); + return {}; if (i < sz) return points[i]; @@ -168,7 +168,7 @@ void spline::update_interp_data() const double maxx = max_input(); if (sz == 0) - list.prepend(QPointF(maxx, max_output())); + list.prepend({ maxx, max_output() }); std::stable_sort(list.begin(), list.begin() + sz, sort_fn); @@ -377,7 +377,7 @@ double spline::max_input() const { using m = axis_opts::max_clamp; const value<m>& clamp = s->opts.clamp_x_; - if (clamp == m::x1000 && points.size()) + if (clamp == m::x1000 && !points.empty()) return points[points.size() - 1].x(); return s ? std::fabs(clamp.to<double>()) : 0; } @@ -391,7 +391,7 @@ double spline::max_output() const { using m = axis_opts::max_clamp; const value<m>& clamp = s->opts.clamp_y_; - if (clamp == m::x1000 && points.size()) + if (clamp == m::x1000 && !points.empty()) return points[points.size() - 1].y(); return s ? std::fabs(clamp.to<double>()) : 0; } diff --git a/tracker-aruco/ftnoir_tracker_aruco.cpp b/tracker-aruco/ftnoir_tracker_aruco.cpp index a3d58c88..a63edb8b 100644 --- a/tracker-aruco/ftnoir_tracker_aruco.cpp +++ b/tracker-aruco/ftnoir_tracker_aruco.cpp @@ -193,9 +193,9 @@ void aruco_tracker::set_intrinsics() const double focal_length_h = .5 * h / tan(.5 * fov_h); intrinsics(0, 0) = focal_length_w; - intrinsics(0, 2) = grayscale.cols/2; + intrinsics(0, 2) = grayscale.cols/2.; intrinsics(1, 1) = focal_length_h; - intrinsics(1, 2) = grayscale.rows/2; + intrinsics(1, 2) = grayscale.rows/2.; } void aruco_tracker::update_fps() @@ -257,7 +257,7 @@ void aruco_tracker::draw_centroid() cv::projectPoints(centroid, rvec, tvec, intrinsics, cv::noArray(), repr2); - cv::circle(frame, repr2[0], 4, cv::Scalar(255, 0, 255), -1); + cv::circle(frame, repr2[0], 4, {255, 0, 255}, -1); } void aruco_tracker::set_last_roi() @@ -542,6 +542,7 @@ void aruco_dialog::camera_settings() void aruco_dialog::update_camera_settings_state(const QString& name) { + (void)name; ui.camera_settings->setEnabled(true); } diff --git a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp index a93a22cb..269f8266 100644 --- a/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp +++ b/tracker-freepie-udp/ftnoir_tracker_freepie-udp.cpp @@ -22,7 +22,7 @@ void tracker_freepie::run() { uint8_t pad1; uint8_t flags; float fl[12]; - } data; + } data {}; #pragma pack(pop) enum F @@ -49,7 +49,7 @@ void tracker_freepie::run() { while (sock.hasPendingDatagrams()) { using t = decltype(data); - t tmp {0,0, {0,0,0, 0,0,0, 0,0,0, 0,0,0}}; + t tmp {}; (void) sock.readDatagram(reinterpret_cast<char*>(&tmp), sizeof(data)); int flags = tmp.flags & F::Mask; diff --git a/tracker-hatire/ftnoir_tracker_hat.h b/tracker-hatire/ftnoir_tracker_hat.h index b1faacd3..e7d9c0e4 100644 --- a/tracker-hatire/ftnoir_tracker_hat.h +++ b/tracker-hatire/ftnoir_tracker_hat.h @@ -39,9 +39,9 @@ private: TrackerSettings s; - int frame_cnt; + int frame_cnt = 0; - std::atomic<int> CptError; + std::atomic<int> CptError { 0 }; static inline QByteArray to_latin1(const QString& str) { return str.toLatin1(); } }; diff --git a/tracker-joystick/ftnoir_tracker_joystick.cpp b/tracker-joystick/ftnoir_tracker_joystick.cpp index 27a5408d..6257ee24 100644 --- a/tracker-joystick/ftnoir_tracker_joystick.cpp +++ b/tracker-joystick/ftnoir_tracker_joystick.cpp @@ -14,7 +14,7 @@ joystick::joystick() if (static_cast<QString>(s.guid) == "") { std::vector<win32_joy_ctx::joy_info> info = joy_ctx.get_joy_info(); - if (info.size()) + if (!info.empty()) { s.guid = info[0].guid; s.b->save(); diff --git a/tracker-pt/ftnoir_tracker_pt_dialog.cpp b/tracker-pt/ftnoir_tracker_pt_dialog.cpp index ce1b9eb0..01ae83c9 100644 --- a/tracker-pt/ftnoir_tracker_pt_dialog.cpp +++ b/tracker-pt/ftnoir_tracker_pt_dialog.cpp @@ -265,7 +265,7 @@ void TrackerDialog_PT::register_tracker(ITracker *t) void TrackerDialog_PT::unregister_tracker() { - tracker = NULL; + tracker = nullptr; ui.tcalib_button->setEnabled(false); poll_tracker_info(); timer.stop(); diff --git a/tracker-pt/module/camera.cpp b/tracker-pt/module/camera.cpp index 9c62e8a3..816a2484 100644 --- a/tracker-pt/module/camera.cpp +++ b/tracker-pt/module/camera.cpp @@ -16,6 +16,8 @@ #include "cv/video-property-page.hpp" +#include <cstdlib> + using namespace pt_module; Camera::Camera(const QString& module_name) : s { module_name } @@ -75,10 +77,10 @@ Camera::result Camera::get_frame(pt_frame& frame_) cam_info.res_y = frame.rows; cam_info.fov = fov; - return result(true, cam_info); + return { true, cam_info }; } else - return result(false, pt_camera_info()); + return { false, {} }; } bool Camera::start(int idx, int fps, int res_x, int res_y) diff --git a/tracker-pt/module/camera.h b/tracker-pt/module/camera.h index 05ca93dd..f3f88cc5 100644 --- a/tracker-pt/module/camera.h +++ b/tracker-pt/module/camera.h @@ -8,12 +8,9 @@ #pragma once #include "pt-api.hpp" - #include "compat/timer.hpp" -#include <functional> #include <memory> -#include <tuple> #include <opencv2/core.hpp> #include <opencv2/videoio.hpp> diff --git a/tracker-pt/pt-api.hpp b/tracker-pt/pt-api.hpp index 0ddfb4e1..a0d9a806 100644 --- a/tracker-pt/pt-api.hpp +++ b/tracker-pt/pt-api.hpp @@ -15,7 +15,7 @@ struct pt_camera_info final { - typedef typename types::f f; + using f = typename types::f; pt_camera_info(); static double get_focal_length(f fov, int res_x, int res_y); diff --git a/tracker-steamvr/steamvr.cpp b/tracker-steamvr/steamvr.cpp index 52a1c44d..e4ac8835 100644 --- a/tracker-steamvr/steamvr.cpp +++ b/tracker-steamvr/steamvr.cpp @@ -138,14 +138,14 @@ device_list::maybe_pose device_list::get_pose(int k) const pose_t& pose = poses[k]; if (pose.bPoseIsValid && pose.bDeviceIsConnected) - return maybe_pose(true, poses[k]); + return maybe_pose{ true, poses[k] }; else once_only(qDebug() << "steamvr:" << "no valid pose from device" << k << "valid" << pose.bPoseIsValid << "connected" << pose.bDeviceIsConnected); - return maybe_pose(false, pose_t{}); + return maybe_pose{ false, {} }; }); } @@ -165,7 +165,7 @@ tt device_list::vr_init_() else qDebug() << "steamvr: init failure" << error << device_list::error_string(error); - return tt(v, error); + return { v, error }; } QString device_list::error_string(vr_error_t err) diff --git a/tracker-wii/wii_camera.cpp b/tracker-wii/wii_camera.cpp index 7ec21666..b8b370ab 100644 --- a/tracker-wii/wii_camera.cpp +++ b/tracker-wii/wii_camera.cpp @@ -57,8 +57,8 @@ void WIICamera::show_camera_settings() WIICamera::result WIICamera::get_info() const { if (cam_info.res_x == 0 || cam_info.res_y == 0) - return result(false, pt_camera_info()); - return result(true, cam_info); + return { false, {} }; + return { true, cam_info }; } WIICamera::result WIICamera::get_frame(pt_frame& frame_) @@ -78,10 +78,10 @@ WIICamera::result WIICamera::get_frame(pt_frame& frame_) _get_points(wii); break; case wii_cam_data_no_change: - return result(false, cam_info); + return { false, cam_info }; } - return result(true, cam_info); + return { true, cam_info }; } bool WIICamera::start(int idx, int fps, int res_x, int res_y) @@ -97,12 +97,12 @@ bool WIICamera::start(int idx, int fps, int res_x, int res_y) void WIICamera::stop() { onExit = true; - m_pDev->ChangedCallback = NULL; + m_pDev->ChangedCallback = nullptr; m_pDev->Disconnect(); Beep(1000, 200); if (m_pDev) { m_pDev=nullptr; - m_pDev = NULL; + m_pDev = nullptr; } desired_name = QString(); @@ -181,7 +181,7 @@ wii_camera_status WIICamera::_pair() pwd[4] = btinfo.address.rgBytes[4]; pwd[5] = btinfo.address.rgBytes[5]; - if (ERROR_SUCCESS != BluetoothAuthenticateDevice(NULL, hbtlist[i], &btdevinfo, pwd, 6)) { error = true; continue; } + if (ERROR_SUCCESS != BluetoothAuthenticateDevice(nullptr, hbtlist[i], &btdevinfo, pwd, 6)) { error = true; continue; } DWORD servicecount = 32; GUID guids[32]; if (ERROR_SUCCESS != BluetoothEnumerateInstalledServices(hbtlist[i], &btdevinfo, &servicecount, guids)) { error = true; continue; } diff --git a/variant/default/main-window.cpp b/variant/default/main-window.cpp index 5fd52830..efc0882e 100644 --- a/variant/default/main-window.cpp +++ b/variant/default/main-window.cpp @@ -475,7 +475,7 @@ bool main_window::refresh_config_list() QStringList ini_list = group::ini_list(); // check for sameness - const bool exact_same = ini_list.size() > 0 && progn( + const bool exact_same = !ini_list.empty() && progn( if (ini_list.size() == ui.iconcomboProfile->count()) { const int sz = ini_list.size(); |