diff options
Diffstat (limited to 'tracker-wii')
-rw-r--r-- | tracker-wii/CMakeLists.txt | 5 | ||||
-rw-r--r-- | tracker-wii/export.hpp | 11 | ||||
-rw-r--r-- | tracker-wii/wii_camera.cpp | 71 | ||||
-rw-r--r-- | tracker-wii/wii_camera.h | 33 | ||||
-rw-r--r-- | tracker-wii/wii_frame.cpp | 6 | ||||
-rw-r--r-- | tracker-wii/wii_frame.hpp | 16 | ||||
-rw-r--r-- | tracker-wii/wii_module.cpp | 17 | ||||
-rw-r--r-- | tracker-wii/wii_module.hpp | 9 | ||||
-rw-r--r-- | tracker-wii/wii_point_extractor.cpp | 50 | ||||
-rw-r--r-- | tracker-wii/wii_point_extractor.h | 14 | ||||
-rw-r--r-- | tracker-wii/wiiyourself/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tracker-wii/wiiyourself/warns-begin.hpp | 19 | ||||
-rw-r--r-- | tracker-wii/wiiyourself/warns-end.hpp | 4 | ||||
-rw-r--r-- | tracker-wii/wiiyourself/wiimote.cpp | 37 | ||||
-rw-r--r-- | tracker-wii/wiiyourself/wiimote.h | 5 |
15 files changed, 156 insertions, 144 deletions
diff --git a/tracker-wii/CMakeLists.txt b/tracker-wii/CMakeLists.txt index e40692ba..f43dca55 100644 --- a/tracker-wii/CMakeLists.txt +++ b/tracker-wii/CMakeLists.txt @@ -3,7 +3,8 @@ if(WIN32) if(OpenCV_FOUND) add_subdirectory(wiiyourself) otr_module(tracker-wii) - target_link_libraries(opentrack-tracker-wii opentrack-tracker-pt-base opentrack-wiiyourself bthprops) - target_include_directories(opentrack-tracker-wii PRIVATE "${CMAKE_SOURCE_DIR}/tracker-pt") + target_link_libraries(${self} opentrack-tracker-pt-base opentrack-wiiyourself bthprops) + target_include_directories(${self} PRIVATE SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/wiiyourself") + target_include_directories(${self} PRIVATE "${CMAKE_SOURCE_DIR}/tracker-pt") endif() endif() diff --git a/tracker-wii/export.hpp b/tracker-wii/export.hpp deleted file mode 100644 index e186b1aa..00000000 --- a/tracker-wii/export.hpp +++ /dev/null @@ -1,11 +0,0 @@ -// generates export.hpp for each module from compat/linkage.hpp - -#pragma once - -#include "compat/linkage-macros.hpp" - -#ifdef BUILD_TRACKER_WII -# define OTR_WII_EXPORT OTR_GENERIC_EXPORT -#else -# define OTR_WII_EXPORT OTR_GENERIC_IMPORT -#endif diff --git a/tracker-wii/wii_camera.cpp b/tracker-wii/wii_camera.cpp index 38cbf26a..a393b843 100644 --- a/tracker-wii/wii_camera.cpp +++ b/tracker-wii/wii_camera.cpp @@ -7,8 +7,19 @@ */ // silence #pragma deprecated in bluetoothapis.h + +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wreserved-id-macro" +#endif + #undef _WIN32_WINNT #define _WIN32_WINNT _WIN32_WINNT_VISTA + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif + #undef NTDDI_VERSION #define NTDDI_VERSION NTDDI_VISTASP1 @@ -24,14 +35,14 @@ #include <bthsdpdef.h> #include <bluetoothapis.h> -using namespace pt_module; +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; } @@ -42,12 +53,12 @@ WIICamera::~WIICamera() QString WIICamera::get_desired_name() const { - return desired_name; + return {}; } QString WIICamera::get_active_name() const { - return active_name; + return {}; } void WIICamera::show_camera_settings() @@ -67,7 +78,7 @@ WIICamera::result WIICamera::get_frame(pt_frame& frame_) cv::Mat& frame = frame_.as<WIIFrame>()->mat; struct wii_info& wii = frame_.as<WIIFrame>()->wii; - const wii_camera_status new_frame = _get_frame(frame); + const wii_camera_status new_frame = get_frame_(frame); //create a fake blank frame frame = cv::Mat(cam_info.res_x, cam_info.res_y, CV_8UC3, cv::Scalar(0, 0, 0)); wii.status = new_frame; @@ -75,8 +86,8 @@ WIICamera::result WIICamera::get_frame(pt_frame& frame_) switch (new_frame) { case wii_cam_data_change: - _get_status(wii); - _get_points(wii); + get_status(wii); + get_points(wii); break; case wii_cam_data_no_change: return { false, cam_info }; @@ -97,22 +108,16 @@ bool WIICamera::start(int, int, int, int) void WIICamera::stop() { - onExit = true; - m_pDev->ChangedCallback = nullptr; - m_pDev->Disconnect(); - Beep(1000, 200); - if (m_pDev) { - m_pDev=nullptr; - m_pDev = nullptr; - } + m_pDev->ChangedCallback = nullptr; + m_pDev->Disconnect(); + Beep(1000, 200); + m_pDev = nullptr; - desired_name = QString(); - active_name = QString(); - cam_info = pt_camera_info(); - cam_desired = pt_camera_info(); + cam_info = {}; + cam_desired = {}; } -wii_camera_status WIICamera::_pair() +wii_camera_status WIICamera::pair() { #if defined __MINGW32__ // missing prototypes and implib entries @@ -204,14 +209,14 @@ wii_camera_status WIICamera::_pair() #endif } -wii_camera_status WIICamera::_get_frame(cv::Mat& frame) +wii_camera_status WIICamera::get_frame_(cv::Mat& frame) { (void)frame; wii_camera_status ret = wii_cam_wait_for_connect; if (!m_pDev->IsConnected()) { qDebug() << "wii wait"; - ret = _pair(); + ret = pair(); switch (ret) { case wii_cam_wait_for_sync: m_pDev->Disconnect(); @@ -244,7 +249,7 @@ goodbye: return ret; } -bool WIICamera::_get_points(struct wii_info& wii) +bool WIICamera::get_points(struct wii_info& wii) { bool dot_sizes = (m_pDev->IR.Mode == wiimote_state::ir::EXTENDED); bool ret = false; @@ -275,23 +280,21 @@ bool WIICamera::_get_points(struct wii_info& wii) return ret; } -void WIICamera::_get_status(struct wii_info& wii) +void WIICamera::get_status(struct wii_info& wii) { //draw battery status wii.BatteryPercent = m_pDev->BatteryPercent; wii.bBatteryDrained = m_pDev->bBatteryDrained; //draw horizon - static int p = 0; - static int r = 0; if (m_pDev->Nunchuk.Acceleration.Orientation.UpdateAge < 10) { - p = m_pDev->Acceleration.Orientation.Pitch; - r = m_pDev->Acceleration.Orientation.Roll; + horizon.p = m_pDev->Acceleration.Orientation.Pitch; + horizon.r = m_pDev->Acceleration.Orientation.Roll; } - wii.Pitch = p; - wii.Roll = r; + wii.Pitch = horizon.p; + wii.Roll = horizon.r; } void WIICamera::on_state_change(wiimote &remote, @@ -336,3 +339,5 @@ void WIICamera::on_state_change(wiimote &remote, remote.SetReportType(wiimote::IN_BUTTONS_ACCEL_IR); } } + +} // ns pt_module diff --git a/tracker-wii/wii_camera.h b/tracker-wii/wii_camera.h index f4ee5c00..e7d93b83 100644 --- a/tracker-wii/wii_camera.h +++ b/tracker-wii/wii_camera.h @@ -21,7 +21,7 @@ #include <QString> -#include <wiiyourself/wiimote.h> +#include <wiimote.h> #include "wii_frame.hpp" namespace pt_module { @@ -41,33 +41,26 @@ struct WIICamera final : pt_camera QString get_desired_name() const override; QString get_active_name() const override; - void set_fov(double value) override { (void)value; } + void set_fov(f value) override { (void)value; } void show_camera_settings() override; private: - std::unique_ptr<wiimote> m_pDev; - static void on_state_change(wiimote &remote, - state_change_flags changed, - const wiimote_state &new_state); - bool onExit = false; - pt_frame internalframe; - - wii_camera_status _pair(); - wii_camera_status _get_frame(cv::Mat& Frame); - bool _get_points(struct wii_info&); - void _get_status(struct wii_info&); - - double dt_mean = 0; - - Timer t; + static void on_state_change(wiimote &remote, + state_change_flags changed, + const wiimote_state &new_state); + wii_camera_status pair(); + wii_camera_status get_frame_(cv::Mat& Frame); + bool get_points(struct wii_info& wii); + void get_status(struct wii_info& wii); + + std::unique_ptr<wiimote> m_pDev; pt_camera_info cam_info; pt_camera_info cam_desired; - QString desired_name, active_name; - pt_settings s; + struct { float p = 0, r = 0; } horizon; - static constexpr inline double dt_eps = 1./384; + pt_settings s; }; } // ns pt_module diff --git a/tracker-wii/wii_frame.cpp b/tracker-wii/wii_frame.cpp index 432b1f18..4520fde4 100644 --- a/tracker-wii/wii_frame.cpp +++ b/tracker-wii/wii_frame.cpp @@ -15,7 +15,7 @@ #include <opencv2/imgproc.hpp> -using namespace pt_module; +namespace pt_module { WIIPreview& WIIPreview::operator=(const pt_frame& frame_) { @@ -78,7 +78,7 @@ QImage WIIPreview::get_bitmap() QImage::Format_ARGB32); } -void WIIPreview::draw_head_center(double x, double y) +void WIIPreview::draw_head_center(f x, f y) { auto [px_, py_] = to_pixel_pos(x, y, frame_copy.cols, frame_copy.rows); @@ -102,3 +102,5 @@ void WIIPreview::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-wii/wii_frame.hpp b/tracker-wii/wii_frame.hpp index 2107646b..8c4508b2 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 { @@ -49,7 +52,7 @@ struct WIIPreview final : pt_preview WIIPreview& operator=(const pt_frame& frame) override; QImage get_bitmap() override; - void draw_head_center(double x, double y) override; + void draw_head_center(f x, f y) override; operator cv::Mat&() { return frame_copy; } operator cv::Mat const&() const { return frame_copy; } @@ -57,9 +60,12 @@ struct WIIPreview 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_resize, frame_out; - wii_camera_status status = wii_cam_wait_for_dongle; + cv::Mat frame_copy, frame_out; + wii_camera_status status = wii_cam_wait_for_dongle; }; } // 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_module.hpp b/tracker-wii/wii_module.hpp index 34a8561d..b167e150 100644 --- a/tracker-wii/wii_module.hpp +++ b/tracker-wii/wii_module.hpp @@ -2,13 +2,10 @@ #include "api/plugin-api.hpp" -#include <QIcon> -#include <QtGlobal> - -class Q_DECL_EXPORT wii_metadata_pt : public Metadata +class wii_metadata_pt : public Metadata { Q_OBJECT - QString name(); - QIcon icon(); + QString name() override; + QIcon icon() override; }; diff --git a/tracker-wii/wii_point_extractor.cpp b/tracker-wii/wii_point_extractor.cpp index 1be6049b..a16cf233 100644 --- a/tracker-wii/wii_point_extractor.cpp +++ b/tracker-wii/wii_point_extractor.cpp @@ -30,9 +30,9 @@ #include <QDebug> -using namespace types; -using namespace pt_module; +using namespace numeric_types; +namespace pt_module { WIIPointExtractor::WIIPointExtractor(const QString& module_name) : s(module_name) { @@ -40,40 +40,40 @@ WIIPointExtractor::WIIPointExtractor(const QString& module_name) : s(module_name } //define a temp draw function -void WIIPointExtractor::_draw_point(cv::Mat& preview_frame, const vec2& p, const cv::Scalar& color, int thinkness) +void WIIPointExtractor::draw_point(cv::Mat& preview_frame, const vec2& p, const cv::Scalar& color, int thickness) { static constexpr int len = 9; - cv::Point p2(iround(p[0] * preview_frame.cols + preview_frame.cols / 2), - iround(-p[1] * preview_frame.cols + preview_frame.rows / 2)); + cv::Point p2(iround(p[0] * preview_frame.cols + preview_frame.cols / f{2}), + iround(-p[1] * preview_frame.cols + preview_frame.rows / f{2})); cv::line(preview_frame, cv::Point(p2.x - len, p2.y), cv::Point(p2.x + len, p2.y), color, - thinkness); + thickness); cv::line(preview_frame, cv::Point(p2.x, p2.y - len), cv::Point(p2.x, p2.y + len), color, - thinkness); + thickness); } -bool WIIPointExtractor::_draw_points(cv::Mat& preview_frame, const struct wii_info &wii, std::vector<vec2>& points) +bool WIIPointExtractor::draw_points(cv::Mat& preview_frame, const struct wii_info& wii, std::vector<vec2>& points) { - const float W = 1024.0f; - const float H = 768.0f; + constexpr int W = 1024; + constexpr int H = 768; points.reserve(4); points.clear(); - for (unsigned index = 0; index < 4; index++) + for (unsigned index = 0; index < 4; index++) // NOLINT(modernize-loop-convert) { const struct wii_info_points &dot = wii.Points[index]; 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 f RX = W - dot.ux; + const f 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); @@ -81,7 +81,7 @@ bool WIIPointExtractor::_draw_points(cv::Mat& preview_frame, const struct wii_in std::tie(dt[0], dt[1]) = to_screen_pos(RX, RY, W, H); points.push_back(dt); - _draw_point(preview_frame, dt, cv::Scalar(0, 255, 0), dot.isize); + draw_point(preview_frame, dt, cv::Scalar(0, 255, 0), dot.isize); } } const bool success = points.size() >= PointModel::N_POINTS; @@ -89,7 +89,7 @@ bool WIIPointExtractor::_draw_points(cv::Mat& preview_frame, const struct wii_in return success; } -void WIIPointExtractor::_draw_bg(cv::Mat& preview_frame, const struct wii_info &wii) +void WIIPointExtractor::draw_bg(cv::Mat& preview_frame, const struct wii_info& wii) { //draw battery status cv::line(preview_frame, @@ -99,8 +99,8 @@ void WIIPointExtractor::_draw_bg(cv::Mat& preview_frame, const struct wii_info & 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 / f{4}) * tan(((double)wii.Pitch)* pi / f(180))); + int rdelta = iround((preview_frame.cols / f{4}) * tan(((double)wii.Roll)* pi / f(180))); cv::line(preview_frame, cv::Point(0, preview_frame.rows / 2 + rdelta - pdelta), @@ -114,11 +114,15 @@ void WIIPointExtractor::extract_points(const pt_frame& frame_, pt_preview& previ const struct wii_info& wii = frame_.as_const<WIIFrame>()->wii; cv::Mat& preview_frame = *preview_frame_.as<WIIPreview>(); - switch (wii.status) { - case wii_cam_data_change: - _draw_bg(preview_frame, wii); - _draw_points(preview_frame, wii, points); - break; - } + switch (wii.status) + { + case wii_cam_data_change: + draw_bg(preview_frame, wii); + draw_points(preview_frame, wii, points); + break; + default: + break; + } } +} // ns pt_module diff --git a/tracker-wii/wii_point_extractor.h b/tracker-wii/wii_point_extractor.h index be0e5f45..661ce35f 100644 --- a/tracker-wii/wii_point_extractor.h +++ b/tracker-wii/wii_point_extractor.h @@ -16,23 +16,19 @@ namespace pt_module { -using namespace types; +using namespace numeric_types; class WIIPointExtractor final : public pt_point_extractor { public: - // extracts points from frame and draws some processing info into frame, if draw_output is set - // dt: time since last call in seconds void extract_points(const pt_frame& frame, pt_preview& preview_frame, std::vector<vec2>& points) override; WIIPointExtractor(const QString& module_name); -private: - static constexpr int max_blobs = 16; +private: pt_settings s; - void _draw_point(cv::Mat& preview_frame, const vec2& p, const cv::Scalar& color, int thinkness = 1); - bool _draw_points(cv::Mat& preview_frame, const struct wii_info &wii, std::vector<vec2>& points); - void _draw_bg(cv::Mat& preview_frame, const struct wii_info &wii); + void draw_point(cv::Mat& preview_frame, const vec2& p, const cv::Scalar& color, int thickness = 1); + bool draw_points(cv::Mat& preview_frame, const struct wii_info& wii, std::vector<vec2>& points); + void draw_bg(cv::Mat& preview_frame, const struct wii_info& wii); }; } // ns impl - diff --git a/tracker-wii/wiiyourself/CMakeLists.txt b/tracker-wii/wiiyourself/CMakeLists.txt index fe6d62e8..91fa245a 100644 --- a/tracker-wii/wiiyourself/CMakeLists.txt +++ b/tracker-wii/wiiyourself/CMakeLists.txt @@ -1,4 +1,7 @@ if(WIN32) otr_module(wiiyourself STATIC NO-COMPAT NO-QT) target_link_libraries(${self} setupapi hid winmm) + if(CMAKE_COMPILER_IS_CLANGXX OR CMAKE_COMPILER_IS_GNUCXX) + target_compile_options(${self} PRIVATE -Wno-error) + endif() endif() diff --git a/tracker-wii/wiiyourself/warns-begin.hpp b/tracker-wii/wiiyourself/warns-begin.hpp index ca2b6b93..0d0365a9 100644 --- a/tracker-wii/wiiyourself/warns-begin.hpp +++ b/tracker-wii/wiiyourself/warns-begin.hpp @@ -3,7 +3,22 @@ # 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 + +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" +# pragma clang diagnostic ignored "-Wextra-semi" +# pragma clang diagnostic ignored "-Wshadow-field" +# pragma clang diagnostic ignored "-Wreserved-id-macro" +# pragma clang diagnostic ignored "-Wconversion" +# pragma clang diagnostic ignored "-Wfloat-equal" +# pragma clang diagnostic ignored "-Wunused-macros" +# pragma clang diagnostic ignored "-Wcast-qual" #endif diff --git a/tracker-wii/wiiyourself/warns-end.hpp b/tracker-wii/wiiyourself/warns-end.hpp index beaf245d..3de03ca5 100644 --- a/tracker-wii/wiiyourself/warns-end.hpp +++ b/tracker-wii/wiiyourself/warns-end.hpp @@ -1,3 +1,7 @@ #ifdef __GNUG__ # pragma GCC diagnostic pop #endif + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif diff --git a/tracker-wii/wiiyourself/wiimote.cpp b/tracker-wii/wiiyourself/wiimote.cpp index 0da0113b..503a0783 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; @@ -1439,7 +1432,7 @@ int wiimote::ParseExtension(BYTE *buff, unsigned offset) float raw_x = buff[offset + 0]; float raw_y = buff[offset + 1]; - if ((raw_x != joy.RawX) || (raw_y != joy.RawY)) + if (std::fabs(raw_x - joy.RawX) < 1e-6f || std::fabs(raw_y - joy.RawY) < 1e-6f) changed |= NUNCHUK_JOYSTICK_CHANGED; joy.RawX = raw_x; @@ -2376,11 +2369,7 @@ bool wiimote::Load16bitMonoSampleWAV(const TCHAR* filepath, wiimote_sample &out) TRACE(_T("Loading '%s'"), filepath); FILE *file; -#if (_MSC_VER >= 1400) // VC 2005+ _tfopen_s(&file, filepath, _T("rb")); -#else - file = _tfopen(filepath, _T("rb")); -#endif _ASSERT(file); if (!file) { WARN(_T("Couldn't open '%s"), filepath); @@ -2569,11 +2558,7 @@ bool wiimote::Load16BitMonoSampleRAW(const TCHAR* filepath, // load them FILE *file; bool res; -#if (_MSC_VER >= 1400) // VC 2005+ _tfopen_s(&file, filepath, _T("rb")); -#else - file = _tfopen(filepath, _T("rb")); -#endif _ASSERT(file); if (!file) { TRACE(_T("Couldn't open '%s"), filepath); diff --git a/tracker-wii/wiiyourself/wiimote.h b/tracker-wii/wiiyourself/wiimote.h index dac949c7..73212e05 100644 --- a/tracker-wii/wiiyourself/wiimote.h +++ b/tracker-wii/wiiyourself/wiimote.h @@ -10,8 +10,11 @@ #pragma once +#undef NDEBUG + #include "warns-begin.hpp" +#undef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <tchar.h> // auto Unicode/Ansi support @@ -471,7 +474,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 |