Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


DirectInput Error

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

Hi all. Why do I get an error on this line? nEvents = Mouse.GetDeviceData(DevData, DIGDD_DEFAULT) The DevData buffer is set to 10, and it''s not helping to increse the buffer. I use Directinput for both Mouse and Keyboard. My cooperativelevels is set as following: Keyboard: DISCL_FOREGROUND Or DISCL_NONEXCLUSIVE Or DISCL_NOWINKEY Mouse: DISCL_FOREGROUND Or DISCL_EXCLUSIVE I''ve tried other cooperativelevels without success. The error occurs when the app is loaded or when I move the mouse. I use a temporary solution with an ''On Error Resume Next'' line and that solves the prob. and give me the desierd mouse-move most of the time. I cant however figure out how to eliminate this error. If you know, please help!

Share this post

Link to post
Share on other sites
The GetDeviceData() function is a buffered instruction. If you only wish to retrieve the state of the mouse at that moment in time, use GetDeviceState(). You can find this in the MSDN help for DirectInput. The parameters that you are passing to the function indicate that you only want the snapshot state.

GetDeviceData returns a buffer that is setup with the following code. Execute this code before you acquire the mouse.

//Setup the buffer on the device
m_BufferDesc.diph.dwSize = sizeof(DIPROPDWORD);
m_BufferDesc.diph.dwHeaderSize = sizeof(DIPROPHEADER);
m_BufferDesc.diph.dwObj = 0;
m_BufferDesc.diph.dwHow = DIPH_DEVICE;
m_BufferDesc.dwData = MAX_UIBUFFERSIZE;

if (FAILED(m_Mouse->SetProperty(DIPROP_BUFFERSIZE, &m_BufferDesc.diph)))
return false;

To read the data you will need to call GetDeviceData() and pass it parameters. See the following code.

DWORD m_MouseBufferElements;

if (FAILED(m_Mouse->GetDeviceData(sizeof(DIDEVICEOBJECTDATA),
m_MouseBuffer, &dwItems, 0)))
m_MouseBufferElements = 0;
m_MouseBufferElements = dwItems;

To process the data returned you will need to create a for loop and cycle through the buffer based on the number of elements the GetDeviceData() function returns. I have other code checking to see if the mouse is acquired and am assuming you have that under control.

Hope this helps.
ps All of this is in the MSDN help on Direct Input and can be found online as well. I searched for Direct Input in google and was also able to find a bit more information on running Direct Input.

[edited by - kressilac on November 11, 2002 1:27:09 AM]

Share this post

Link to post
Share on other sites

  • 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!