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

Quick DirectInput Problem/Question

Started by kooooo Sep 16, 2006 at 4:32 PM 3 replies 750+ views
Original Post
kooooo
kooooo
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
kooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
circlesoft
circlesoft
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.
kooooo
kooooo
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]
kooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
TheAdmiral
TheAdmiral
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
Ring3 Circus - Diary of a programmer, journal of a hacker.
kooooo
kooooo
Understood. I'll start to use the Win32 stuff I guess. Thanks Admiral
kooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo

Topic Locked

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

Sign in to reply to this topic.