Jump to content
  • Advertisement
Sign in to follow this  
horsfield2001

Heeeelp!! DirectInput8 mouse in absolute coordinance

This topic is 4071 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok ive written a DirectX program that uses DirectInput to get the current state of the mouse in an attempt to get the current location of the mouse. void GameEngine::DetectMouseMove(void) { static DIMOUSESTATE mousestate; // create a static storage for the mouse-states dinmouse->Acquire(); // get access if we don't have it already // fill the mousestate with values dinmouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate); absolute.lX += mousestate.lX; absolute.lY += mousestate.lY; if(mousestate.rgbButtons[0] & 0x80) MouseButtonDown(absolute.lX, absolute.lY, true); if(mousestate.rgbButtons[1] & 0x80) MouseButtonDown(absolute.lX, absolute.lY, false); if(mousestate.lX != 0 || mousestate.lY != 0) MouseMove(absolute.lX, absolute.lY); return; } now i realize that DirectInput gives the mouse's postion relitive to its loast location when the GetDeviceState function was last called. i have created a global variable called absolute. during the initialization of DirectInput and the mouose i get the current location of the mouse in client coordiance and assign those values to the global variable. then as you can see i add the relitive postion given by DirectInput to the global variable. this should give me the current locaiton of the mouse... but it dosnt for some reason. when i run a program that puts a 2D sprite on the location the mouse is pointing to then move the mouse the sprite gets more and more lost. the sprite moves in approxametly the right direction but at a seeminly random amount of offset. whats going on here???

Share this post


Link to post
Share on other sites
Advertisement
If you ever need absolute mouse coordinates, that's a sure sign that you shouldn't be using DirectInput for your mouse input. DirectInput is not designed for that, and Microsoft even recommends against using DirectInput for mouse and keyboard input. There's a reason it's not being developed any more.

Share this post


Link to post
Share on other sites
Steve's made an important point, but just to extend it a little - relative coordinates like you're receiving are mostly useful where mouse movement/navigation is required but the actual position of the cursor isn't. Think about every first-person-shooter you've played, the cursor is always in the middle of the screen and relative movements of the mouse are used to change the viewing direction...

Follow mflayer's suggestion or use regular Windows Messaging.

hth
Jack

Share this post


Link to post
Share on other sites
Well i guess you guys are right. kind of anoying but i cant really argue. i can still use directinput for the keyboard that works just fine in my engine. but if anyone else has any idea as to how i could get absolut coordinance with directx dont hesitate to let me know.

Share this post


Link to post
Share on other sites
Check your mouse properties in control panel....do you have 'Enhance Pointer Precision' enabled or some sort of acceleration?

Share this post


Link to post
Share on other sites
Quote:
Original post by Benden
Check your mouse properties in control panel....do you have 'Enhance Pointer Precision' enabled or some sort of acceleration?
All mouse settings in the control pannel have no effect on DirectInput. Yet another reason not to use it.

Share this post


Link to post
Share on other sites
Quote:
Original post by Evil Steve
Quote:
Original post by Benden
Check your mouse properties in control panel....do you have 'Enhance Pointer Precision' enabled or some sort of acceleration?
All mouse settings in the control pannel have no effect on DirectInput. Yet another reason not to use it.


Exactly my point...it sounds as though the OP was seeing his sprite move at a different rate to the normal cursor, the cursor being under the influence of extra mouse settings while the sprite isnt.

Share this post


Link to post
Share on other sites
Benben was right. i did have "Enhance Pointer Precision" checked. i unchecked it and the problem went away. now the question is ... how do i detect that programicaly? and how do i fix it?

Share this post


Link to post
Share on other sites
Look into intercepting WM_MOUSEMOVE in the wndproc instead of using Direct Input...particularly for mouse cursors situations anyway as it takes into account the mouse settings. You wouldnt want to use this for things like an FPS camera though as the precision is limited. Search for "High-Definition Mouse Movement" in the DX SDK for more info.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!