   DirectInput MouseState (Solved)
  Whenever i use MouseState.X/Y/ZIt says they are zero.Any suggestion?I'm running this in a fullscreen Direct3d AppThx,AidaminaLoads Mouse:mouse = new Device(SystemGuid.Mouse);if(mouse == null)p_Mainclass.AddOutput("Input Device Error: "+"No mouse found.");mouse.SetCooperativeLevel(this.p_Mainclass.p_Window, CooperativeLevelFlags.Foreground | CooperativeLevelFlags.Exclusive);mouse.Acquire();Gets Mouse coordinats to string:public string GetMouseStatus(){if (mouse==null)return "ERROR NO MOUSE FOUND";MouseState mousestate= mouse.CurrentMouseState;string Output = "Mouse Postion (x/y): "+mousestate.X+"/"+mousestate.Y+"\n ScrollState: "+mousestate.Z+"\n";return Output;}[Edited by - Aidamina on December 31, 2005 7:41:22 AM]
  The Mouse in DirectInput uses Relative positioning. It's position is directly related to it's last position. So if you start it and the cursor is at say, 120x120, but you're not moving the mouse, you're going to see (0, 0) for the coords. If you move the mouse you might see somethign like (-5, -10).What you have to do is something similar to this:global_x += MouseState.x;global_y += MouseState.y;That'll help get an Absolute position system going. But it'll still be relative to where the cursor started. The DirectInput mouse system is annoying at times for 2D type stuff.   ;  isnt there an absolute way of getting x y z ?   ;  I don't know much about managed DirectX, but in C++ you would do something like the following to get "Absolute" coordinates. The problem is it's still related to where the mouse was first initialized.DIPROPDWORD  dipdw; HRESULT hr; dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = DIPROPAXISMODE_ABS; hr = lpdiDevice->SetProperty(DIPROP_AXISMODE, &dipdw.diph);Basicly, all the above does is instead of adding the relative positions yourself, DirectInput does it for you. It's still exactly the same thing.   ;  You can get the cursor position in screen coordinates with GetCursorPos() and then convert the screen cordinates to window coordinates with ScreenToClient() - also a WIN API function.   ;  Thank you for pointing to the right direction:Code that solved it:[DllImport("user32.dll")]static extern bool GetCursorPos(ref System.Drawing.Point lpPoint);AndSystem.Drawing.Point p = new System.Drawing.Point(); ;GetCursorPos(ref p);After that you can use p.X and p.Y to get the screen coordinats I'm using a fullscreen application, so im not sure if it will work on Windowed mode.   ;  Just be careful when using that if you plan on rendering your own cursor graphic. There will be a pause between the cursor moving on your screen and when you actually move it.I was trying to avoid going that route, but it's probably unavoidable at this point if you really need very exact coordinates.   