Sign in to follow this  
watermelonChris

How can I get input from a joypad? XNA or DirectX

Recommended Posts

I'm wanting to get input form a generic joypad (ps2 like)..

It seems you can't do it via XNA alone and you need DirectX.
How ever I'm using C#. NET and I've download the latest DirectX SDK but I can't seem to add it as a reference.

I have googled and googled but can't find anything, except some framework DirectX 'wrapper' for C#.

So any suggestions?

Share this post


Link to post
Share on other sites
[quote name='Watermelon Chris' timestamp='1312725507' post='4845783']
How ever I'm using C#. NET and I've download the latest DirectX SDK but I can't seem to add it as a reference.
[/quote]

You probably downloaded the C++ SDK, I would think.

What you want is [url="http://slimdx.org/"]SlimDX[/url], so you can use the DirectInput API.

Share this post


Link to post
Share on other sites
Hmmmmm could I write a class/module in C++ . NET, because it would compile to CLI right?

Could I then add that to my C# project?

I'm not to keen on that SlimDX, I guess it's worth a try though.

Share this post


Link to post
Share on other sites
In my opinion, as a developer, you should do yourself a favor by avoiding the headache of having to support the myriad of controller types out there with all their button and stick combinations, and instead just support the xbox 360 controller (xinput). The user can still easily use whatever game pad he has and do the mapping he wants by using a utility that emulates a 360 controller using the game pad that the user has. I have a cheap generic dual analog stick game pad and I use it to play all sorts of games supporting the 360 controller. Check this out:[url="http://www.jayceooi.com/2009/01/19/download-xbox-360-controller-emulator-for-pc-games/"]http://www.jayceooi.com/2009/01/19/download-xbox-360-controller-emulator-for-pc-games/[/url]

Share this post


Link to post
Share on other sites
[quote name='Amr0' timestamp='1312800618' post='4846124']
In my opinion, as a developer, you should do yourself a favor by avoiding the headache of having to support the myriad of controller types out there with all their button and stick combinations, and instead just support the xbox 360 controller (xinput). The user can still easily use whatever game pad he has and do the mapping he wants by using a utility that emulates a 360 controller using the game pad that the user has. I have a cheap generic dual analog stick game pad and I use it to play all sorts of games supporting the 360 controller. Check this out:[url="http://www.jayceooi.com/2009/01/19/download-xbox-360-controller-emulator-for-pc-games/"]http://www.jayceooi....r-for-pc-games/[/url]
[/quote]
That is sick dude :D might do that. Yeah the only reason I wanted to support 'controllers' is cause you cant push many buttons simultaneously on a keyboard before they start to conflict (thinking multiplayer).

Kinda sad that a game like GTA IV only supports a xbox 360 controller though :( saddening..

Share this post


Link to post
Share on other sites
Woot woot! It works!

Downloaded it here: http://virusdev.ovh.org/files/xinputemu/x360ce%20vibmod%203.1.4.1.zip

I copied xbox360ce.ini and xinput1_3.dll to my debug folder and it works! (Using the Platformer example)!

Thanks people your awesome haha!

Share this post


Link to post
Share on other sites
As an alternative there's also the ancient [url=http://msdn.microsoft.com/en-us/library/dd757121.aspx]Windows Multimedia Joystick API[/url]. It's quite a bit simpler to use than DirectInput if you're just querying joystick position and button input and is easily P/Invoked.

I agree that limiting yourself to XInput and replying on the user to install an Xbox 360 controller emulator is probably the easiest way out, though (and makes it more practical for the user, else you'll need to provide a way for the user to edit joystick button and axis mappings within your game).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this