From ce5885889dad52e2df6a41618dbb59b63eb03bca Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Tue, 30 Jul 2019 15:44:26 -0400 Subject: [PATCH] Process Start/Stop zoom within camera manager. --- src/Camera/QGCCameraManager.cc | 42 +++++++++++++++++++++++++++------- src/Camera/QGCCameraManager.h | 2 ++ 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/Camera/QGCCameraManager.cc b/src/Camera/QGCCameraManager.cc index 4a55f591b..e85a45587 100644 --- a/src/Camera/QGCCameraManager.cc +++ b/src/Camera/QGCCameraManager.cc @@ -379,6 +379,8 @@ QGCCameraManager::_activeJoystickChanged(Joystick* joystick) qCDebug(CameraManagerLog) << "Joystick changed"; if(_activeJoystick) { disconnect(_activeJoystick, &Joystick::stepZoom, this, &QGCCameraManager::_stepZoom); + disconnect(_activeJoystick, &Joystick::startContinuousZoom, this, &QGCCameraManager::_startZoom); + disconnect(_activeJoystick, &Joystick::stopContinuousZoom, this, &QGCCameraManager::_stopZoom); disconnect(_activeJoystick, &Joystick::stepCamera, this, &QGCCameraManager::_stepCamera); disconnect(_activeJoystick, &Joystick::stepStream, this, &QGCCameraManager::_stepStream); disconnect(_activeJoystick, &Joystick::triggerCamera, this, &QGCCameraManager::_triggerCamera); @@ -388,13 +390,15 @@ QGCCameraManager::_activeJoystickChanged(Joystick* joystick) } _activeJoystick = joystick; if(_activeJoystick) { - connect(_activeJoystick, &Joystick::stepZoom, this, &QGCCameraManager::_stepZoom); - connect(_activeJoystick, &Joystick::stepCamera, this, &QGCCameraManager::_stepCamera); - connect(_activeJoystick, &Joystick::stepStream, this, &QGCCameraManager::_stepStream); - connect(_activeJoystick, &Joystick::triggerCamera, this, &QGCCameraManager::_triggerCamera); - connect(_activeJoystick, &Joystick::startVideoRecord, this, &QGCCameraManager::_startVideoRecording); - connect(_activeJoystick, &Joystick::stopVideoRecord, this, &QGCCameraManager::_stopVideoRecording); - connect(_activeJoystick, &Joystick::toggleVideoRecord, this, &QGCCameraManager::_toggleVideoRecording); + connect(_activeJoystick, &Joystick::stepZoom, this, &QGCCameraManager::_stepZoom); + connect(_activeJoystick, &Joystick::startContinuousZoom, this, &QGCCameraManager::_startZoom); + connect(_activeJoystick, &Joystick::stopContinuousZoom, this, &QGCCameraManager::_stopZoom); + connect(_activeJoystick, &Joystick::stepCamera, this, &QGCCameraManager::_stepCamera); + connect(_activeJoystick, &Joystick::stepStream, this, &QGCCameraManager::_stepStream); + connect(_activeJoystick, &Joystick::triggerCamera, this, &QGCCameraManager::_triggerCamera); + connect(_activeJoystick, &Joystick::startVideoRecord, this, &QGCCameraManager::_startVideoRecording); + connect(_activeJoystick, &Joystick::stopVideoRecord, this, &QGCCameraManager::_stopVideoRecording); + connect(_activeJoystick, &Joystick::toggleVideoRecord, this, &QGCCameraManager::_toggleVideoRecording); } } @@ -442,7 +446,7 @@ QGCCameraManager::_toggleVideoRecording() void QGCCameraManager::_stepZoom(int direction) { - if(_lastZoomChange.elapsed() > 250) { + if(_lastZoomChange.elapsed() > 40) { _lastZoomChange.start(); qCDebug(CameraManagerLog) << "Step Camera Zoom" << direction; QGCCameraControl* pCamera = currentCameraInstance(); @@ -452,6 +456,28 @@ QGCCameraManager::_stepZoom(int direction) } } +//----------------------------------------------------------------------------- +void +QGCCameraManager::_startZoom(int direction) +{ + qCDebug(CameraManagerLog) << "Start Camera Zoom" << direction; + QGCCameraControl* pCamera = currentCameraInstance(); + if(pCamera) { + pCamera->startZoom(direction); + } +} + +//----------------------------------------------------------------------------- +void +QGCCameraManager::_stopZoom() +{ + qCDebug(CameraManagerLog) << "Stop Camera Zoom"; + QGCCameraControl* pCamera = currentCameraInstance(); + if(pCamera) { + pCamera->stopZoom(); + } +} + //----------------------------------------------------------------------------- void QGCCameraManager::_stepCamera(int direction) diff --git a/src/Camera/QGCCameraManager.h b/src/Camera/QGCCameraManager.h index 2c6964f40..e13cf9ab2 100644 --- a/src/Camera/QGCCameraManager.h +++ b/src/Camera/QGCCameraManager.h @@ -57,6 +57,8 @@ protected slots: virtual void _mavlinkMessageReceived (const mavlink_message_t& message); virtual void _activeJoystickChanged (Joystick* joystick); virtual void _stepZoom (int direction); + virtual void _startZoom (int direction); + virtual void _stopZoom (); virtual void _stepCamera (int direction); virtual void _stepStream (int direction); virtual void _cameraTimeout (); -- 2.22.0