summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-04-14 05:43:05 +0200
committerStanislaw Halik <sthalik@misaki.pl>2019-04-14 06:30:05 +0200
commit30378f88294c81bfc00b23cadfd7e292f29d8fe6 (patch)
tree0ef6946ee1b00b46c8f83d0702682b67eda02642
parentfd8df2acc588fabc6022664f292b6353b2b7bf07 (diff)
tracker/wii: appease clang-tidy
-rw-r--r--tracker-wii/wii_camera.cpp25
-rw-r--r--tracker-wii/wii_point_extractor.cpp26
2 files changed, 29 insertions, 22 deletions
diff --git a/tracker-wii/wii_camera.cpp b/tracker-wii/wii_camera.cpp
index 06a607c0..f6f8726f 100644
--- a/tracker-wii/wii_camera.cpp
+++ b/tracker-wii/wii_camera.cpp
@@ -35,6 +35,7 @@ WIICamera::WIICamera(const QString& module_name) : s { module_name }
WIICamera::~WIICamera()
{
+ // XXX why is this commented out? -sh 20190414
//stop();
}
@@ -78,12 +79,14 @@ WIICamera::result WIICamera::get_frame(pt_frame& frame_)
break;
case wii_cam_data_no_change:
return result(false, cam_info);
+ default:
+ break;
}
return result(true, cam_info);
}
-bool WIICamera::start(const QString& name, int fps, int res_x, int res_y)
+bool WIICamera::start(const QString&, int, int, int)
{
m_pDev = std::make_unique<wiimote>();
m_pDev->ChangedCallback = on_state_change;
@@ -96,12 +99,12 @@ bool WIICamera::start(const QString& name, 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();
@@ -160,7 +163,8 @@ wii_camera_status WIICamera::pair()
}
do
{
- if (wcscmp(btdevinfo.szName, L"Nintendo RVL-CNT-01-TR") && wcscmp(btdevinfo.szName, L"Nintendo RVL-CNT-01"))
+ if (!!wcscmp(btdevinfo.szName, L"Nintendo RVL-CNT-01-TR") &&
+ !!wcscmp(btdevinfo.szName, L"Nintendo RVL-CNT-01"))
{
continue;
}
@@ -181,7 +185,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; }
@@ -199,19 +203,22 @@ wii_camera_status WIICamera::pair()
return ret;
}
-wii_camera_status WIICamera::get_frame(cv::Mat& frame)
+wii_camera_status WIICamera::get_frame(cv::Mat&)
{
wii_camera_status ret = wii_cam_wait_for_connect;
if (!m_pDev->IsConnected()) {
qDebug() << "wii wait";
ret = pair();
- switch(ret){
+ switch(ret)
+ {
case wii_cam_wait_for_sync:
m_pDev->Disconnect();
goto goodbye;
case wii_cam_wait_for_connect:
break;
+ default:
+ break;
}
if (!m_pDev->Connect(wiimote::FIRST_AVAILABLE)) {
Beep(500, 30); Sleep(1000);
@@ -276,8 +283,8 @@ void WIICamera::get_status(struct wii_info& wii)
//draw horizon
if (m_pDev->Nunchuk.Acceleration.Orientation.UpdateAge < 10)
{
- pitch_ = m_pDev->Acceleration.Orientation.Pitch;
- roll_ = m_pDev->Acceleration.Orientation.Roll;
+ pitch_ = (int)m_pDev->Acceleration.Orientation.Pitch;
+ roll_ = (int)m_pDev->Acceleration.Orientation.Roll;
}
wii.Pitch = pitch_;
diff --git a/tracker-wii/wii_point_extractor.cpp b/tracker-wii/wii_point_extractor.cpp
index 553abdab..393dc1c9 100644
--- a/tracker-wii/wii_point_extractor.cpp
+++ b/tracker-wii/wii_point_extractor.cpp
@@ -35,8 +35,8 @@ void WIIPointExtractor::draw_point(cv::Mat& preview_frame, const vec2& p, const
{
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 / 2.f),
+ iround(-p[1] * preview_frame.cols + preview_frame.rows / 2.f));
cv::line(preview_frame,
cv::Point(p2.x - len, p2.y),
@@ -52,12 +52,12 @@ void WIIPointExtractor::draw_point(cv::Mat& preview_frame, const vec2& p, const
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) {
@@ -80,18 +80,18 @@ bool WIIPointExtractor::draw_points(cv::Mat& preview_frame, const struct wii_inf
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,
- cv::Point(0, 0),
- cv::Point(preview_frame.cols*wii.BatteryPercent / 100, 0),
- (wii.bBatteryDrained ? cv::Scalar(255, 0, 0) : cv::Scalar(0, 140, 0)),
- 2);
+ cv::line(preview_frame,
+ cv::Point(0, 0),
+ cv::Point(preview_frame.cols*wii.BatteryPercent / 100, 0),
+ (wii.bBatteryDrained ? cv::Scalar(255, 0, 0) : cv::Scalar(0, 140, 0)),
+ 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.f * tan(wii.Pitch * pi / 180.f));
+ int rdelta = iround(preview_frame.cols / 4.f * tan(wii.Roll* pi / 180.f));
cv::line(preview_frame,
cv::Point(0, preview_frame.rows / 2 + rdelta - pdelta),