summaryrefslogtreecommitdiffhomepage
path: root/tracker-wii/wii_camera.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-wii/wii_camera.cpp')
-rw-r--r--tracker-wii/wii_camera.cpp71
1 files changed, 38 insertions, 33 deletions
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