This is a helper for simplified mouse tracking modeled after the XNA C# Mouse class.
For exception safety, it is recommended you make use of the C++ RAII pattern and use a std::unique_ptr.
For universal Windows apps or Windows Store apps:
Header
#include <Mouse.h>
Initialization
Mouse is a singleton.
std::unique_ptr<Mouse> keyboard( new Mouse );
Integration
For Windows desktop applications, the application needs to make the appropriate calls during the main WndProc message processing:LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_MOUSEWHEEL: case WM_XBUTTONDOWN: case WM_XBUTTONUP: Mouse::ProcessMessage(message, wParam, lParam); break; } return DefWindowProc(hWnd, message, wParam, lParam); }
For universal Windows apps or Windows Store apps:
void App::SetWindow(CoreWindow^ window)
{
mouse->SetWindow(window);
}