Absolute mouse cords

Started by
4 comments, last by Goober King 22 years, 5 months ago
I''m having issues with getting the mouse to return is position in any real usable form with DI. I set up the struct with the absolute flag in the dwData member. Called whatever function the Set is(My code is on another system so sorry for my lack of exactness). This should be done after setting the device type but before aquiring the device right? I apear to still be getting relative data not absolute. I realize without the code handy this might be pointless. What I''m realy curious about is even if I got it to work the DOCs say that its only absolute from the where the device was first initalized. This presents one of the two main problems with the relitive mode. If the mouse starting point could be anywhere how can I ever realy know where it is? In relative the even at the edge of the screen it will still send new values so couting them does no good. I can''t test for the edge of the screen to toss the extra values without first knowing where the mouse is makeing that a usless idea. Nothing I have seams to take you past geting the device aquired.
------------------------------------------------------------- neglected projects Lore and The KeepersRandom artwork
Advertisement
AFAIK, you can only get relative data from the mouse with DirectInput... DI doesn''t store the coordinates, it just reports motion in the mouse.
you can just store two variables somewhere, mX and mY, and use these as your absolute mouse coordinates. when you get a mousemove callback event (or whatever the hell it is called in DI and c++) add the relative data to your (mX,mY) variables. you can check these against the screen edges, et cetera...
if you want your mouse to start in the center of the screen, initialize the mX,mY variables to the coordinates of the center of the screen. if you want it to start in the upper left corner, set them both to 0.

--- krez (krezisback@aol.com)
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
So I should be able to just make my own cursor and move it around instead of using the regular cursor. I was tring to know
where it was. Using my own would be easy. It just raises the
"?" as to how I get the pointer to disapear.
------------------------------------------------------------- neglected projects Lore and The KeepersRandom artwork
Add up the relative data and then create a function to restrict that data to the screen coordinates.

So, if you want your mouse to start at (0,0) then when your mouse moves left you substract that value from the last x position (0). Since your mouse shouldn't move into negative areas you would make sure that if x < 0 that you make x = 0. If x > screen size then x = screen size.

DI also allows you to explicitly state that the device will return absolute data based on some random point, but this way you at least are using a known point.

Invader X
Invader's Realm

Edited by - Invader X on November 1, 2001 8:14:18 PM
It should have been common sence. Took all of 2 min to write the
stuff. I still not to sure how to turn of the standard mouse pointer. thanx
------------------------------------------------------------- neglected projects Lore and The KeepersRandom artwork
To turn off the standard mouse pointer use ShowCursor(0).

This topic is closed to new replies.

Advertisement