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

Started by
6 comments, last by watermelonChris 12 years, 8 months ago
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?
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.
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.
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/


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..
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!
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).

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Woot woot! Searching 'get input from joypad in XNA' in google this topic comes in 3rd!

This topic is closed to new replies.

Advertisement