summaryrefslogtreecommitdiffhomepage
path: root/tracker-pt/tracker-wii/wii_camera.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tracker-pt/tracker-wii/wii_camera.cpp')
-rw-r--r--tracker-pt/tracker-wii/wii_camera.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/tracker-pt/tracker-wii/wii_camera.cpp b/tracker-pt/tracker-wii/wii_camera.cpp
index 21ff998d..514c71ae 100644
--- a/tracker-pt/tracker-wii/wii_camera.cpp
+++ b/tracker-pt/tracker-wii/wii_camera.cpp
@@ -1,11 +1,10 @@
-/* Copyright (c) 2012 Patrick Ruoff
- * Copyright (c) 2015-2016 Stanislaw Halik <sthalik@misaki.pl>
- * Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
+/*
+* Copyright (c) 2017-2018 Wei Shuai <cpuwolf@gmail.com>
+*
+* Permission to use, copy, modify, and/or distribute this software for any
+* purpose with or without fee is hereby granted, provided that the above
+* copyright notice and this permission notice appear in all copies.
+*/
#include "wii_camera.h"
@@ -77,8 +76,8 @@ WIICamera::result WIICamera::get_frame(pt_frame& frame_)
pt_camera_open_status WIICamera::start(int idx, int fps, int res_x, int res_y)
{
- m_pDev = new wiimote;
- if (m_pDev == NULL)
+ m_pDev = std::make_unique<wiimote>();
+ if (!m_pDev)
{
stop();
return cam_open_error;
@@ -97,7 +96,7 @@ void WIICamera::stop()
m_pDev->Disconnect();
Beep(1000, 200);
if (m_pDev) {
- delete m_pDev;
+ m_pDev=nullptr;
m_pDev = NULL;
}
@@ -140,6 +139,7 @@ bool WIICamera::_get_points(struct wii_info& wii)
{
bool dot_sizes = (m_pDev->IR.Mode == wiimote_state::ir::EXTENDED);
bool ret = false;
+ int point_count = 0;
for (unsigned index = 0; index < 4; index++)
{
@@ -153,6 +153,7 @@ bool WIICamera::_get_points(struct wii_info& wii)
wii.Points[index].isize = 1;
}
wii.Points[index].bvis = dot.bVisible;
+ point_count++;
ret = true;
} else {
wii.Points[index].ux = 0;
@@ -161,6 +162,7 @@ bool WIICamera::_get_points(struct wii_info& wii)
wii.Points[index].bvis = dot.bVisible;
}
}
+ m_pDev->SetLEDs(3 - point_count);
return ret;
}