title: DirectX11 Mouse Control
body: <p>I have a 3d program in DirectX and I want to give the mouse control to the camera. The problem is the mouse moves right off the screen ( In windowed mode ) then the camera doesn't turn anymore. I tried to use SetCusorPos to just lock it in place after the mouse is moved. That way I could get a dx and then set the mouse back to the center of the screen. I ended up getting a endless white screen. Here is my camera/mouse movement code so far. If you need any more information just ask.</p>
  
  <pre><code>void PhysicsApp::OnMouseMove(WPARAM btnState, int x, int y)
  {
      // Make each pixel correspond to a quarter of a degree.
      float dx = XMConvertToRadians(0.25f*static_cast&lt;float&gt;(x - mLastMousePos.x));
      float dy = XMConvertToRadians(0.25f*static_cast&lt;float&gt;(y - mLastMousePos.y));
  
      // Update angles based on input to orbit camera around box.
      mTheta += -dx;
      mPhi   += -dy;
      // Update players direction to always face forward
      playerRotation.y = -mTheta;
  
      // Restrict the angle mPhi.
      mPhi = MathHelper::Clamp(mPhi, 0.1f, MathHelper::Pi-0.1f);
  
      if( (btnState &amp; MK_RBUTTON) != 0 )
      {
          // Make each pixel correspond to 0.2 unit in the scene.
          float dx = 0.05f*static_cast&lt;float&gt;(x - mLastMousePos.x);
          float dy = 0.05f*static_cast&lt;float&gt;(y - mLastMousePos.y);
  
          // Update the camera radius based on input.
          mRadius += dx - dy;
  
          // Restrict the radius.
          mRadius = MathHelper::Clamp(mRadius, 5.0f, 50.0f);
      }
      mLastMousePos.x = x;
      mLastMousePos.y = y;
  }
  </code></pre>