diff options
Diffstat (limited to 'tracker-wii/wiiyourself')
-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 |
5 files changed, 39 insertions, 29 deletions
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 |