I set up Rawinput to process mouse events like this
m_rawSize = 0;
m_pRaw = 0;
RAWINPUTDEVICE pMouseRid[1];
pMouseRid->usUsagePage = 0x01;
pMouseRid->usUsage = 0x02;
pMouseRid->dwFlags = 0;//RIDEV_NOLEGACY;
pMouseRid->hwndTarget = m_hwnd;
if(!RegisterRawInputDevices(pMouseRid, 1, sizeof(RAWINPUTDEVICE)))
{
IG_ERROR("RegisterRawInputDevices() failed!");
return false;
}
else
{
return true;
}
And I listen to them like this
UINT dwSize = 0;
UINT result = GetRawInputData((HRAWINPUT)p_lParam, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
if(result != 0)
{
IG_WARNING("GetRawInputData() failed (Result " << result << ", lParam " << p_lParam << ").");
return;
}
if(m_rawSize < dwSize)
{
SAFE_DELETE_ARRAY(m_pRaw);
m_pRaw = (RAWINPUT*)(IG_NEW unsigned char[dwSize]);
m_rawSize = dwSize;
if(!m_pRaw)
{
IG_WARNING("Failed to allocate space.");
return;
}
}
if(m_pRaw)
{
result = GetRawInputData((HRAWINPUT)p_lParam, RID_INPUT, m_pRaw, &dwSize, sizeof(RAWINPUTHEADER));
if(result == (UINT)-1)
{
IG_WARNING("GetRawInputData() failed.");
return;
}
if(result != dwSize)
{
IG_WARNING("GetRawInputData does not return correct size! Expected " << dwSize << ", got " << result);
return;
}
else if(m_pRaw->header.dwType == RIM_TYPEMOUSE)
{
WmInput input;
input.m_message = WM_INPUT;
input.m_deltaX = m_pRaw->data.mouse.lLastX;
input.m_deltaY = m_pRaw->data.mouse.lLastY;
input.m_flags = m_pRaw->data.mouse.usButtonFlags;
input.m_data = m_pRaw->data.mouse.usButtonData;
IG_INFO("WM_INPUT " << m_pRaw->data.mouse.lLastX << ", " << m_pRaw->data.mouse.lLastY << ".");
m_inputs.push(input);
}
}
But with this code the WM_INPUT events only come in as the cursor moves one pixel and the lLastX/Y vars do represent that on pixel. So it doesn't have the promised advantage of being more precise than the WM_MOUSEMOVE messages. Am I wrong? What is the proper way to get high resolution input from my mouse?
I have a Logitech G500 + Logitech Gaming Software 8.45.88 installed. The DPI is set to 1500.