Jump to content
  • Advertisement
Sign in to follow this  
Liort

XInput sample from DIRECTX SDK question

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

Hello All! First let me state that i know almost nothing (YET) about DirectX syntax or structure, and my method for learning is disecting the DirectX SDK sample code for now. What i didn't understand from this particular sample (called XinputGame): 1. I currently have no XBOX controller connected - i get a blue screen with a message saying "No controller is connected" - who throws this message? i couldn't find the function that checks the connection to the controller.. 2. As a result of 1, i tried putting breakpoints on all the state checking functions (XInputGetState) to see when it returns a failure, however VS2005 just froze every time and it was impossible to debug like this, what could be the cause of this ? p.s: i realize that nothing will replace reading a very thick directx book.. but i think many things can be learnt by reverse-engineering someone else's program. Thanks Lior tal

Share this post


Link to post
Share on other sites
Advertisement
Quote:
1. I currently have no XBOX controller connected - i get a blue screen with a message saying "No controller is connected" - who throws this message? i couldn't find the function that checks the connection to the controller..


XInputGame.cpp line #777 :) I just used the "Find in Files" function :)

What MSDN says about XInputGetState: "If the controller is not connected, the return value is ERROR_DEVICE_NOT_CONNECTED."

http://msdn.microsoft.com/en-us/library/bb174829(VS.85).aspx

I can't answer your second question.. sorry.

Share this post


Link to post
Share on other sites
Funny thing, i've searched it myself, i must've written the entire string, and in the source file it is seperated to 3 lines.

About the 2nd question - i guess it doesn't matter for now....

btw - whenever there are multiple controllers involved, do i read all of them in sequence (read controller 0<i<4) ? will this seem concurrent enough?

Share this post


Link to post
Share on other sites
Does this mean that controller[1..3] will suffer some latency?

Is this noticeable?

Share this post


Link to post
Share on other sites
Well maybe a microsecond? I don't know how long it takes to execute a function call :D

Don't worry, it's not noticeable, that's for sure. Here's an example taken from MSDN:

DWORD dwResult;    
for (DWORD i=0; i< MAX_CONTROLLERS; i++ )
{
XINPUT_STATE state;
ZeroMemory( &state, sizeof(XINPUT_STATE) );

// Simply get the state of the controller from XInput.
dwResult = XInputGetState( i, &state );

if( dwResult == ERROR_SUCCESS )
{
// Controller is connected
}
else
{
// Controller is not connected
}
}

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!