WINAPI Mouse movement diff via WinAPI

Started by
6 comments, last by CrazyCdn 6 years, 4 months ago

Hi all,

I want to obtain the mouse movement win WINAPI. Basically if the cursor is on the left side of the screen and I move the mouse left, I want to sill get a -x value.
I know that this was possible with DirectInput, but I cannot find a WinAPI equivalent. Is there any?

Advertisement

DirectInput still works fine for the time being, as there is still no complete replacement.

Raw Input might fit your bill: https://msdn.microsoft.com/en-us/library/windows/desktop/ms645536(v=vs.85).aspx

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Yeah, sadly there isn't an alternative :(

Raw input does this

Yeah, Raw Input does but you still need to get the mouse initial position by WINAPI call GetCursorPos unless you now the direction but do not now the position of your cursor

GetRawInputData actually gives your the mouse motion in the X/Y directions, you can call it in response to a WM_INPUT event, after making sure to call RegisterRawInputDevice so that your window actually receives the events.

https://msdn.microsoft.com/query/dev15.query?appId=Dev15IDEF1&l=EN-US&k=k(WINUSER%2FGetRawInputData);k(GetRawInputData);k(SolutionItemsProject);k(DevLang-C%2B%2B);k(TargetOS-Windows)&rd=true

I second or third using RawInput.  Since eventually DirectInput will no longer be supported.  It's pretty easy to use too.

"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin

This topic is closed to new replies.

Advertisement