I'm working on Direct3D Game engine, I got my mouse and keyboard setup from my previous project, but recently ran into problem:
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.
case WM_INPUT:
if (wParam == RIM_INPUT)
{
dword dwSize = 48;
RAWINPUT raw;
if (GetRawInputData((HRAWINPUT)lParam, RID_INPUT, &raw, &dwSize,
sizeof(RAWINPUTHEADER)) != dwSize)
OutputDebugString(TEXT("GetRawInputData does not return correct size !\n"));
if (raw.header.dwType == RIM_TYPEMOUSE)
{
this->mouse.TranslateMouseInput(raw.data.mouse);
}
break;
}
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.
Closest thing I found to answer in WinAPI is GetCursorPos()
combined with GetWindowRect()
, 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.
How do I solve the issue without losing a relative mouse movement?
-Should I try parsing WM_MOUSEMOVE messages with WM_INPUT?
I've looked for a popular input solution for game engines, but didn't find any particular one.
Additional Info: