bool FlightCameraManipulatorHIDSync::updateFrame( float dt )
        {
          if (!m_hid)
          {
            return false;
          }

          setCursorPosition( m_hid->getValue<dp::math::Vec2i>( PID_Pos ) );
          setWheelTicks( m_hid->getValue<int>( PID_Wheel ) );

          bool forward = m_hid->getValue<bool>( PID_Forward );
          bool reverse = m_hid->getValue<bool>( PID_Reverse );
  
          // set speed based on wheel and buttons
          m_speed  += getWheelTicksDelta() * 0.1f;
          if( m_speed < 0.f )
          {
            m_speed = 0.f;
          }

          if( forward || reverse )
          {
            // set forward, reverse here
            FlightCameraManipulator::setSpeed( forward ? m_speed : -m_speed );
          }
          else
          {
            // stopped
            FlightCameraManipulator::setSpeed( 0.f );
          }

          return FlightCameraManipulator::updateFrame( dt );
        }
        bool TrackballTransformManipulator::dolly()
        {
          int dyScreen = getLastY() - getCurrentY();
          if( !dyScreen )
          {
            dyScreen = getWheelTicksDelta();
          }

          if ( dyScreen )
          {
            DP_ASSERT( getViewState()->getCamera().isPtrTo<FrustumCamera>() );
            TransformSharedPtr transform = m_transformPath->getTail().staticCast<Transform>();
            FrustumCameraSharedPtr const& camera = getViewState()->getCamera().staticCast<FrustumCamera>();
            if ( camera && transform )
            {
              unsigned int rtWidth = getRenderTarget()->getWidth();
              unsigned int rtHeight = getRenderTarget()->getHeight();
              Vec2f  camWinSize = camera->getWindowSize();
              if (    ( 0 < rtHeight ) && ( 0 < rtWidth )
                  &&  ( FLT_EPSILON < fabs( camWinSize[0] ) )
                  &&  ( FLT_EPSILON < fabs( camWinSize[1] ) ) )
              {
                //  get all the matrices needed here
                Mat44f m2w, w2m, w2v, v2w;
                m_transformPath->getModelToWorldMatrix(m2w, w2m);   // model->world and world->model
                w2v = camera->getWorldToViewMatrix();               // world->view
                v2w = camera->getViewToWorldMatrix();            // view->world

                // transfer mouse delta into view space
                float dyView = camWinSize[1]/rtHeight * dyScreen;

                // transfer the mouse delta vector into the model space
                Vec4f modelDelta = Vec4f( 0.0f, 0.0f, dyView, 0.0f ) * v2w * w2m;

                // minus the delta to the translation of the transform
                // minus, because we want mouse down to move the object into the direction of the user
                Trafo trafo = transform->getTrafo();
                trafo.setTranslation( trafo.getTranslation() - Vec3f( modelDelta ) );
                transform->setTrafo( trafo );

                return true;
              }
            }
          }
          return false;
        }
        bool WalkCameraManipulatorHIDSync::updateFrame( float dt )
        {
          if (!m_hid)
          {
            return false;
          }

          dp::math::Vec2i pos = m_hid->getValue<dp::math::Vec2i>( PID_Pos );
          if( getReverseMouse() && getRenderTarget() )
          {
            pos[1] = getRenderTarget()->getHeight() - pos[1] - 1;
          }

          setCursorPosition( pos );

          setWheelTicks( m_hid->getValue<int>( PID_Wheel ) );

          // set height above terrain
          if( m_hid->getValue<bool>( PID_KeyUp ) )
          {
            setCameraHeightAboveTerrain( getCameraHeightAboveTerrain() + m_sensitivity[1] );
          }
          else if( m_hid->getValue<bool>( PID_KeyDown ) )
          {
            float hat = getCameraHeightAboveTerrain() - m_sensitivity[1];
            if( hat < 0.f )
            {
              hat = 0.f;
            }

            setCameraHeightAboveTerrain( hat );
          }

          bool forward = m_hid->getValue<bool>( PID_ButtonForward ) ||
                         m_hid->getValue<bool>( PID_KeyForward );
          bool reverse = m_hid->getValue<bool>( PID_ButtonReverse ) ||
                         m_hid->getValue<bool>( PID_KeyReverse );

          bool strafeLeft  = m_hid->getValue<bool>( PID_KeyStrafeLeft );
          bool strafeRight = m_hid->getValue<bool>( PID_KeyStrafeRight );

          float run = m_hid->getValue<bool>( PID_KeyRun ) ? 2.0f : 1.0f;

          unsigned int mode = MODE_FREELOOK;
  
          // update speed based on wheel
          m_speed += getWheelTicksDelta() * 0.1f;
          if( m_speed < 0.f )
          {
            m_speed = 0.f;
          }

          if( forward || reverse )
          {
            // set forward, reverse here
            float speed = forward ? m_speed : -m_speed;
            WalkCameraManipulator::setSpeed( speed * run );

            mode |= MODE_WALK;
          }

          if( strafeLeft )
          {
            WalkCameraManipulator::setSpeed( m_speed * run );
            mode |= MODE_STRAFE_LEFT;
          }
          else if( strafeRight )
          {
            WalkCameraManipulator::setSpeed( m_speed * run );
            mode |= MODE_STRAFE_RIGHT;
          }

          // if not moving, set speed to 0
          if( mode == MODE_FREELOOK )
          {
            // stopped
            WalkCameraManipulator::setSpeed( 0.f );
          }

          setMode( mode );

          return WalkCameraManipulator::updateFrame( dt );
        }