Jump to content
  • Advertisement
Sign in to follow this  

DirectInput Havoc - Look at it

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

Dear Sir, Am working on DirectInput 3.0, and am able to set the Mouse and also Get Data from it, but the problem is that am not getting it into pixels, my screen co-ordinates are 800*600, for this first am getting the Relative positions but those are also varring.. then i try to get the absolute postitions by first creating two variables of float and then add those to relative position.. but that is also not working. the output am getting is very wrird... m_AbsMouseX = 400; m_AbsMouseY = 300; if (m_lpdiMouse->GetDeviceState(sizeof(m_MouseState), &m_MouseState) == DI_OK) { //left click if (m_MouseState.rgbButtons[0] /*& 0x80*/) { if (!m_ClickHandled) { m_ClickHandled = TRUE; } } else { m_ClickHandled = FALSE; } // newest rel position data m_RelMouseX = m_MouseState.lX; m_RelMouseY = m_MouseState.lY; // now calc abs position from new relative data m_AbsMouseX += m_RelMouseX; m_AbsMouseY += m_RelMouseY; } etc.. but from the above code i think am gettnig the MICKEYS rather than the original positions.. so for that i write other method.. void CDirectInput::MickeysToPixel(long mickeyX, long mickeyY, long& outX, long& outY) { const int MOUSE_MICKEYS = 65535; int screenX = 800; // this should be set to the screen width int screenY = 600; // this should be set to the screen height outX = mickeyX / (MOUSE_MICKEYS / screenX); outY = mickeyY / (MOUSE_MICKEYS / screenY); } but this is also not working.. its giving me wrong values everytime.. i am keeping a log of it. everytime i restart the demo.. the values change on clicks.. and those dont make sense... eg. instead of getting 0,0 position i get something like 124, 0 and other time the same spot i get 10, 124 that is something weird.. am also not able to get 4 parameters to the m_lpdiMouse->GetDeviceState(sizeof(m_MouseState), &m_MouseState) after all this i also tried to change the properties with SetPorperties.. void CDirectInput::MakeAxesAbsolute(BOOL Absolute) { HRESULT hres; DIPROPDWORD dipdw; dipdw.diph.dwSize = sizeof(DIPROPDWORD); dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); dipdw.diph.dwObj = 0; dipdw.diph.dwHow = DIPH_DEVICE; dipdw.dwData = Absolute ? DIPROPAXISMODE_ABS : DIPROPAXISMODE_REL; hres = m_lpdiMouse->SetProperty(DIPROP_AXISMODE, &dipdw.diph); if (hres != DI_OK) Error("Failed to set mouse axis mode.\n"); } i cannot use win32 apis or WM_CLICK or GetCursorPos stuff.. please try to give me real solution..can you please help me.. am stuck on this for more than a week now. and there seem to be no possible solution i found while doing google too... Waiting for your reply with some code, lot of hopes.. Regards, Tejas.

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!