diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2021-10-17 18:55:14 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2021-10-17 18:55:14 +0200 |
commit | fd767cbad1afa92ed54fc283d63f858d5e096b0c (patch) | |
tree | 6e3b5992fa5c3d0c1c08cd4c64d92f575839eb20 | |
parent | 53f16e314c38700439b5cf58b285b1ea27c4ed53 (diff) |
tracker/wii: allow repeated start()/stop() callswii-robust-start-stop
-rw-r--r-- | tracker-wii/wii_camera.cpp | 16 | ||||
-rw-r--r-- | tracker-wii/wii_camera.h | 1 |
2 files changed, 5 insertions, 12 deletions
diff --git a/tracker-wii/wii_camera.cpp b/tracker-wii/wii_camera.cpp index 98d180bf..009dc345 100644 --- a/tracker-wii/wii_camera.cpp +++ b/tracker-wii/wii_camera.cpp @@ -56,9 +56,7 @@ void WIICamera::show_camera_settings() WIICamera::result WIICamera::get_info() const { - if (cam_info.res_x == 0 || cam_info.res_y == 0) - return result(false, pt_camera_info()); - return result(true, cam_info); + return {true, cam_info}; } WIICamera::result WIICamera::get_frame(pt_frame& frame_) @@ -88,22 +86,18 @@ WIICamera::result WIICamera::get_frame(pt_frame& frame_) bool WIICamera::start(const pt_settings&) { + if (m_pDev) + return true; m_pDev = std::make_unique<wiimote>(); m_pDev->ChangedCallback = on_state_change; m_pDev->CallbackTriggerFlags = (state_change_flags)(CONNECTED | EXTENSION_CHANGED | MOTIONPLUS_CHANGED); - return true; + return true; } void WIICamera::stop() { - desired_name = QString(); - active_name = QString(); - cam_info = pt_camera_info(); - cam_desired = pt_camera_info(); - onExit = true; - if (m_pDev) { m_pDev->ChangedCallback = nullptr; @@ -111,7 +105,7 @@ void WIICamera::stop() m_pDev = nullptr; } - Beep(1000, 200); + //Beep(1000, 200); } #ifdef __MINGW32__ diff --git a/tracker-wii/wii_camera.h b/tracker-wii/wii_camera.h index 038e25e7..68e5970d 100644 --- a/tracker-wii/wii_camera.h +++ b/tracker-wii/wii_camera.h @@ -48,7 +48,6 @@ private: static void on_state_change(wiimote &remote, state_change_flags changed, const wiimote_state &new_state); - bool onExit = false; wii_camera_status pair(); wii_camera_status get_frame(cv::Mat& Frame); |