Adapt > Engage > Dominate

Instead of goofing around with DirectInput and mickeys, use Windows messaging instead.  This is especially useful in GUIs and hover events, should they be necessary for your game.

case WM_MOUSEMOVE:
{
mPos.setAbsX(GET_X_LPARAM(lParam));
mPos.setAbsY(GET_Y_LPARAM(lParam));
break;
}

case WM_LBUTTONUP:
{
mPos.setClick(true);
break;
}

in WndProc does the trick.  Additional messages such as double clicks, right clicks, and so on can be caught and used, depending on the program requirements.  Initialization with GetCursorPos and ScreenToClient sets up the correct beginning mouse position values.

Leave a comment