Jump to content
  • Advertisement
Sign in to follow this  
watermelonChris

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

This topic is 2539 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'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
Advertisement

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.


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

What you want is SlimDX, 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:http://www.jayceooi.com/2009/01/19/download-xbox-360-controller-emulator-for-pc-games/

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:http://www.jayceooi....r-for-pc-games/

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 Windows Multimedia Joystick API. 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
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!