Skip to main content
GameDev.net gamedev.net
🔒 Locked

WINAPI Mouse movement diff via WinAPI

Started by ongamex92 Nov 17, 2017 at 11:48 PM 6 replies 2.3k views
Original Post
ongamex92
ongamex92

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?

ongamex92
ongamex92

Yeah, sadly there isn't an alternative :(

NLScotty
NLScotty

Raw input does this

Shaarigan
Shaarigan

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

xycsoscyx
xycsoscyx

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

CrazyCdn
CrazyCdn

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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.