Archived

This topic is now archived and is closed to further replies.

IceGod

Direct Input problem - Buffered mouse input

Recommended Posts

Hi, Im trying to get buffered mouse input working, and basically all I did was copy the code from the DX8 mouse tutorial (in the sdk help files). Anyways, everything seems to be working fine, but when I go to look at the data returned by dinput with regards to mouse movement, it gives values like this: dwOfs = 0 (x-axis movement) dwData = 4294967295 - how do I interpret this? dwTimeStamp = 59666463 dwSequence = 3729940745 None of those values make any sense for me, or for my app, to use. In the DX8 sample mouse app, it doesn''t seem to do anything special with the data it gets, it just prints it into a formatted string. The string it displays at the bottom is like x:8 y:2 etc, in other words pixel movement, how is it doing this? Thanks, Tom

Share this post


Link to post
Share on other sites
I was debugging the SDK mouse sample program, and if I move the mouse around really fast in buffered input mode, the data in dwData is also a really large number. If I move it slowly it returns appropriate numbers, like -8 etc. Is this some sort of buffer overflow? If so, how do I handle it?

P.S. Sorry about the multiple posts dunno how that happened.

Tom

Share this post


Link to post
Share on other sites
More info on the input problem.
I found out that when I move right or down, so that Dinput returns positive values for the mouse offsets when you poll it, everything is ok. When I move left or up though, it messes up.

I noticed that the DIDEVICEOBJECTDATA structure, the one you are supposed to pass to GetDeviceData(), has a member called dwData which is supposed to store the offset. Well, its a double word (unsigned long), so how can it store a negative number? Is this where the error is coming from? It seems like it must be.

Now my question is how is the microsoft program working? What the heck is goin on? Some sorta conversion I''m not doin? I don''t see them doing anything different though.

Tom

Share this post


Link to post
Share on other sites
Hi,
You are right that it is a negative number. I appreciate it is confusing to exctract a signed integer from a DWORD but that''s what you need to do. A simple cast will do the trick, which is what happens in the DX Scrawl sample.

After calling GetDeviceData the program looks to see what has happened (ie. X Changed, Y changed, button down, etc.)
If X or Y have changed it calls a function called UpdateCursorPosition(int dx, int dy) which takes two parameters which correspond to the change in the X direction and the change to the Y. Note, these are both integers.

So, that''s how Microsoft do it.

Cheers,
John

Share this post


Link to post
Share on other sites