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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: