- Joined
- Jan 15, 2011
- Messages
- 150
- Reaction score
- 8
I've been working on a game lately using DirectX, and I want to add some mouse controls in it.
First, I tried to get the mouse data using GetCursorPos (I only need the position, not the buttons).
Here's the function:
This made a really weird bug in the game.
The mouse position was correct at the top left of the screen, but going down with the mouse creates a gap between the mouse and the given coordinates.
The more I move to the right and bottom, the bigger the gap gets.
For example, when my mouse is at 5,5 it displays 5,5.
When my mouse is at 200,200 it displays 205,210
When my mouse is at 500,500 it displays 510,520
(These is not the data as it displays, but it comes really close)
Note that the Y is growing faster than the X.
After this I tried using the WM_MOUSEMOVE method, but this gave the same result.
I'm only using 1 monitor and the size of the window is 1024x768 (window mode).
Can someone help me out?
First, I tried to get the mouse data using GetCursorPos (I only need the position, not the buttons).
Here's the function:
Code:
POINT GetMousePos(HWND hWnd)
{
POINT cursorPos;
GetCursorPos(&cursorPos);
ScreenToClient(hWnd, &cursorPos);
return cursorPos;
}
This made a really weird bug in the game.
The mouse position was correct at the top left of the screen, but going down with the mouse creates a gap between the mouse and the given coordinates.
The more I move to the right and bottom, the bigger the gap gets.
For example, when my mouse is at 5,5 it displays 5,5.
When my mouse is at 200,200 it displays 205,210
When my mouse is at 500,500 it displays 510,520
(These is not the data as it displays, but it comes really close)
Note that the Y is growing faster than the X.
After this I tried using the WM_MOUSEMOVE method, but this gave the same result.
I'm only using 1 monitor and the size of the window is 1024x768 (window mode).
Can someone help me out?

