GamePad Support!

Topics: Controllers and Device Hardware
May 16, 2014 at 1:36 PM
Hi There,

I seem to have a problem with the GamePad which is not recognized. I don't get any events and also the GamePad class seems to not recognize any gamepad device. Is there any known issue about this? I enable GamePad through CCDirector and Layer class.


May 16, 2014 at 4:35 PM
There are so many platforms where you could connect a gamepad, so many possibilities. Maybe you could share with us which platform you are using?

Next, the framework is a high level framework. If there is a gamepad available, it will connect automatically. That is determined by the underlying graphics engine, e.g. XNA from Microsoft or MonoGame...
May 16, 2014 at 5:10 PM
Thanks a lot for the quick reply and sorry that I forgot to provide enough information. I tested both Windows DX and GL versions using MonoGame on VS 2012 and both seem to not get any gamepad events. I installed the templates from Visual Studio gallery and the versions of the dlls are as follows :

cocos2xna :
SharpDX :
MonoGame :
May 16, 2014 at 6:19 PM
GamePad support depends on your gamepad device and drivers. Did you install the drivers for this gamepad correctly? Have you verified that it works with other gamepad enabled games on your system?

The GamePad support comes out of SharpDX. There are some gamepad DLLs from SharpDX that need to be included in your game project. I am not sure that they are installed by default when you use the nuget packages.
May 17, 2014 at 2:32 PM
Yes, I can confirm that the gamepad works correctly in other games. All my research so far points to SharpDX.XInput.dll for gamepad support which is referenced on my project. Do you (or anybody) have a tested/working gamepad example on Windows DirectX?

Thanks a lot once more for all the help...
May 17, 2014 at 6:41 PM
Nope, unfortunately, I do not have any Windows DX + MonoGame examples. We only wrote the gamepad support against Microsoft XNA on Xbox 360.
May 21, 2014 at 11:06 AM
OK, I found the cause and the solution :). It seems my PC controller was not supporting XInput Interface thus not seen by MonoGame (XNA as well). I bought a wireless controller receiver for my XBOX 360 controller and it's recognized as a controller in MonoGame and Cocos2d-Xna. On a side note, I could reach my other controller but only via DirectInput which was a bit hassle to code.

Many thanks for your time and keep up the good work!
May 21, 2014 at 4:47 PM
Well, if you have the DirectInput code to make your controller work, please post it. I am sure someone at MonoGame would like to see it. The more compatible it becomes with gamepads the more useful it is for desktop games....

May 24, 2014 at 11:55 AM
It's a small piece of code I found from internet regarding DirectInput controller query and polling just to be able to connect the controller I've. Since I'm prototyping things for now I won't be able to make a full fledged class of it but will hopefully do in the near future where I can share with you.

Many thanks so far for taking time and answering all my questions.