Running into an odd issue. I'm using RawInput to calculate absolute mouse screen coordinates but for some reason it always reaches max dimensions (1920x1080) before the mouse actually reaches the screen.
See this - http://imgur.com/a/0qLC7 - for reference, the red rectangle is where I reach the max screen resolution (1920x1080) which is not yet at the end of the screen.
Relevant parts of the code:
WindowManager::WindowManager(const WindowSettings& settings, Logger& logger) :
{
assert(SetProcessDPIAware());
...
// get initial mouse position
POINT p;
ZeroMemory(&p, sizeof(p));
assert(GetCursorPos(&p));
mMouseData.mAbsolutePos = { p.x, p.y };
...
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INPUT:
{
RAWINPUT rawInput;
UINT rawInputSize = sizeof(rawInput);
GetRawInputData((HRAWINPUT)(lParam), RID_INPUT, &rawInput, &rawInputSize, sizeof(RAWINPUTHEADER));
if (rawInput.header.dwType == RIM_TYPEKEYBOARD)
ProcessKeyboardInput(rawInput.data.keyboard);
else if (rawInput.header.dwType == RIM_TYPEMOUSE)
ProcessMouseInput(rawInput.data.mouse);
break;
}
void WindowManager::ProcessMouseInput(const tagRAWMOUSE& mouseInput)
{
if (!mMouseButtonCallback && !mMousePositionCallback)
return;
mMouseData.mRelativePos.x += mouseInput.lLastX;
mMouseData.mRelativePos.y += mouseInput.lLastY;
mMouseData.mAbsolutePos.x += mouseInput.lLastX;
mMouseData.mAbsolutePos.y += mouseInput.lLastY;
VerifyAbsoluteMousePosition();
}
void WindowManager::VerifyAbsoluteMousePosition()
{
static int32_t right = static_cast<int32_t>(GetSystemMetrics(SM_CXSCREEN));
static int32_t bottom = static_cast<int32_t>(GetSystemMetrics(SM_CYSCREEN));
static int32_t top = 0;
static int32_t left = 0;
// Ensure mouse coords are within the screens boundaries
if (mMouseData.mAbsolutePos.x < left) mMouseData.mAbsolutePos.x = left;
if (mMouseData.mAbsolutePos.x > right) mMouseData.mAbsolutePos.x = right;
if (mMouseData.mAbsolutePos.y < top) mMouseData.mAbsolutePos.y = top;
if (mMouseData.mAbsolutePos.y > bottom) mMouseData.mAbsolutePos.y = bottom;
_RPT1(0, "%dx%d\n", mMouseData.mAbsolutePos.x, mMouseData.mAbsolutePos.y);
}
Funny thing is if I replace the incrementing of absolute mouse coordinates with simply GetCursorPos() it works as expected.
Any idea what is causing this?