Jump to content
  • Advertisement
Sign in to follow this  
kooooo

Quick DirectInput Problem/Question

This topic is 4389 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

I was wondering why DirectInput tells me that my mouse is at some insanely extreme coordinates... take a look at the pic below. This is during runtime and the coordinates change as I move my mouse around, always some rediculously extreme value that is useless to me to check. thanks, -pat picture of my problem

Share this post


Link to post
Share on other sites
Advertisement
First, check to see which mode your mouse device is in. By default, it will give you axis offset values (ie the device moved n-units on the x-axis, where the units are pretty arbitrary). However, you can set it manually to get absolute coordinates.

Secondly, I have found that Win32 messages are much easier to get screen coordinates from than DInput - check out WM_MOUSEMOVE. Generally, I used both though - for events that are impulse based, I use DirectInput. For events that require actual coordinates (like GUI, screen picking), I use the Win32 stuff.

Share this post


Link to post
Share on other sites
Ahhhh I forgot all about the mouse modes... lol! I'm going to try and apply your advice pretty quick.

Thanks for all your help in this and my other posts circlesoft - rating++ for you :)

EDIT: hmmm I'm having trouble setting the data format for the mouse. I think my trouble is with the ObjectDataFormat[] field - I'm not sure what to put there. Here is what I have for changing the format so far:

DataFormat df = new DataFormat();
df.Flags = DataFormatFlags.AbsoluteAxis;
mouse.SetDataFormat(df);

where mouse is my mouse device. In the meantime I'm going to play with it and try to figure something out.

EDIT 2: ok I tried

mouse.Properties.AxisModeAbsolute = true

just like in a sample in the documentation, but it doesn't work... I get the same numbers appearing...

[Edited by - kooooo on September 16, 2006 6:36:38 PM]

Share this post


Link to post
Share on other sites
DirectInput doesn't support screen coordinates directly. The coordinates it is returning are the driver's high-resolution coordinates, and aren't guaranteed to scale in a preditable way to screen coordnates on differing hardware.

Microsoft recommend that if you need absolute screen coordinates, you should use Win32, as it is faster and goes via the Windows mouse handling layer and will accelerate in the way the user is used to. Moreover, they say DirectInput is only really useful for high-resolution and relative mouse handling.

Regards
Admiral

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!