title: How to get absolute mouse position with WM_INPUT set up?
body: <p>I'm working on Direct3D Game engine, I got my mouse and keyboard setup from my previous project, but recently ran into problem:</p>
  
  <p>The thing is, my engine is for a shooter/slasher game, so it requires a direct input, which was set in previous project using RAWMOUSE and WM_INPUT message parsing. </p>
  
  <pre><code>    case WM_INPUT:
          if (wParam == RIM_INPUT)
          {
              dword dwSize = 48;
              RAWINPUT raw;
  
              if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, &amp;raw, &amp;dwSize,
                  sizeof(RAWINPUTHEADER)) != dwSize)
                  OutputDebugString(TEXT("GetRawInputData does not return correct size !\n"));
  
              if (raw.header.dwType == RIM_TYPEMOUSE)
              {
                  this-&gt;mouse.TranslateMouseInput(raw.data.mouse);
              }
              break;
          }
  </code></pre>
  
  <p>Problem is, that code returns only relative movement of mouse, it's useful in setting up a camera lookup, but when it comes to menu or basic GUI, which are controlled by mouse (buttons etc...) things go bad: GUI and other controls require cursor position to be calculated relative to client rectangle.</p>
  
  <p>Closest thing I found to answer in WinAPI is <code>GetCursorPos()</code> combined with <code>GetWindowRect()</code>, but if window has a title bar relative offset of it does not count and (0,0) coordinate is set at the top of the title bar, but not on the client region.</p>
  
  <p>How do I solve the issue without losing a relative mouse movement?</p>
  
  <p>-Should I try parsing WM_MOUSEMOVE messages with WM_INPUT?</p>
  
  <p>I've looked for a popular input solution for game engines, but didn't find any particular one. </p>
  
  <p><strong>Additional Info</strong>:</p>
  
  <ul>
  <li><a href="https://github.com/Agrael1/VeritasD3D/blob/master/WinD3D/Mouse.cpp" rel="nofollow noreferrer">Mouse.cpp file</a></li>
  <li><a href="https://github.com/Agrael1/VeritasD3D/blob/master/WinD3D/Mouse.h" rel="nofollow noreferrer">Mouse.h</a></li>
  </ul>