Jump to content
  • Advertisement
Sign in to follow this  
rewolF werdnA

DirectInput key always pressed

This topic is 3918 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 couldn't see any code tags, so i apologise for the ew look) Hi I've been making an input engine for my game using DirectInput8 - got most of the code from a book. Problem is that I seem to be getting the same mouse information regardless of whether a button is pressed or not. Here is my initialization: int res = DirectInput8Create(::GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_di, NULL); if (FAILED(res)){ g_pLogger->error("Could not create Input Device"); return; } res = m_di->CreateDevice(GUID_SysMouse, &m_mouse, NULL); if (FAILED(res)){ g_pLogger->error("Could not create mouse interface"); return; } if (FAILED(m_mouse->SetDataFormat(&c_dfDIMouse))){ g_pLogger->error("Could not set data format for mouse"); return; } if (FAILED(m_mouse->SetCooperativeLevel(m_hWnd, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE))){ g_pLogger->error("Could not set coop level for mouse"); return; } if (FAILED(m_mouse->Acquire())){ g_pLogger->error("Could not acquire mouse"); return; } Here is the updating: while (true){ m_mouse->Poll(); if (SUCCEEDED(res = m_mouse->GetDeviceState(sizeof(DIMOUSESTATE), &m_mouseState))) break; if (res != DIERR_INPUTLOST && res != DIERR_NOTACQUIRED){ g_pLogger->error("Could not get mouse state???"); return; } if (FAILED(m_mouse->Acquire())){ g_pLogger->error("Could not reacquire mouse!!!!"); return; } } Now if i check each of the four .rgbButtons values I get rgbButtons = {205,205,410,615} these values don't change if I click any of the buttons... this is odd - I came about it by finding that my button was always pressed (Coz 205 & 0x80 is not 0) any help would be much appreciated !!

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!