Gamepad / Controller Support - OSX / PC / Mobile

Gamepad / Controller Support - OSX / PC / Mobile
0.0 0


Hey All,

I’m wondering what the status is on adding gamepad support for Mac and PC?
I noticed this feature request for v3.2: - Is that going to be for Mac and PC or just mobile?


Cocos2d-x Linker issue with GameController

I will support mobile phones and TV that using Android system, such as Amazon TV.


I see, ok thanks.


Hi zhangxm,

I looked into this a bit more and was able to add desktop controller support using cocos2d-x v3’s use of GLFW.
I wasn’t able to get the latest cocos2d-x from git compiling in my environment, so I made my changes against 3.1alpha1 instead.

Attached is a patch file to apply to the cocos2d-x directory for adding Joystick support. Note that I added GLFW joystick support in a very basic way since I don’t yet have time to deal with key mappings.
GLFW docs:

Maybe somebody can use my patch file as a starting point to adding official joystick support for the desktop.


About the issue that you can not run latest cocos2d-x, i think you should read, you should run to download dependent libs.


Thanks. helped, but the main reason I couldn’t compile was because Matrix and Vector2 are gone.
My test environment requires those, so I’d like to wait until the next version of cocos2d-x is completed before I try to update my code.



Just an update - I updated my GLFW joystick patch to work with v3.1.1
Latest info is here:
Sorry, I still haven’t had a chance to make a proper pull request.


@zhangxm Hey Mingo - has this feature been added in the release version 3.4? :smiley:


Not yet.
It is in plan, but is low priority.


I’m working on this for v2.x if anyone needs it.


Hey @corytrese,

In case it helps, I got it working with PS3 and Xbox 360 controller for PC/Mac/Linux here:

It’s not completely polished yet, but it works - maybe it’ll be helpful to you in v2.x
To anybody wondering about v3.x, I’m getting a pull request together. In the meantime, you can get the latest at the branch linked above.


@Sheado So this works with verision 3.x? :open_mouth: Wow Nice!!! PLs pls pls. :smiley:

ALso looks like you are testing linux for 3.x. Will it work with OSX and Windows as of yet? Is there a sample project or tutorial to follow to see how to implement it? THX a ton.

Also do I need to download the following two steps to update the project? As the repo is around 80 mb only. So what additional steps need to be taken to build without errors. Sry git noob here :smiley:

I ran download deps. BUt update -init gave errors :expressionless:

After cloning the repo, please execute to download and install dependencies.

$ cd cocos2d-x
$ python
After running

$ cd cocos2d-x
$ git submodule update --init


HI. I would like to develop the game for MacOSX, WIndows and LInux so that I can release a port on Steam. I think this is an essential feature. I know Cocos2d-x main focus is mobile but with Steam really opening up new avenues for monetization why is this low priority. With all other framworks going free I think desktop centric featuters is required to stay competitive. You thoughts??!??


OK Got it to work!!! ;D. Tested on the Mac with 360 Controller!!!

I have one small nitpick. While playing if I disconnect the controller and connect it again the game doesnt recognize that the controller reconnected. Is there a workaround?

Also have you tested with XBoxOne and PS4 controller?!??


Yep, it may be great if cocos2d-x has as many features as possible, but we are limited with human resources. Adding a feature is easy, but maintain it for all versions is not easy. Take controller for example, cocos2d-x now even not support Xbox and PS4 now, don’t support steam now.

I think it is better to support it as a package. We are implementing package manager. It will manage all packages that implement extra features of cocos2d-x.


Welll yes that is true. Esp since the feature is not developed by you initially. I understand. Well xboxOne and PS4 support is not there but atleast you have for PC and Mac so that people can release it on steam.

Instead of working on version 4.0 of Cocos2d-x I think it is better if you work on improving 3.x you have spent all this time in developing this version and I think you need to spend more time and human effort in supporting and expanding this version.

This is my opinion anyway. :smiley:


We will continue to maintain v3, of course.
All bugs fixed will be included in v3 and v4.
v3 will continue to add 3d features too.


@zhangxm: That is great. I like the Cocos2d-x team for the that alone. You support backward compatibility. But I dont understand the need to go 3D now. I feel cocos2d-x should focus on 2D framework and make it better with cross platform support instead of branching out into 3D. I definitely am not complaining about the 3D :smiley: but feel that 2D is coco2d-x’s core strength and all effort needs to be put to make it a well rounded 2d framework. Once that is achieved we can always go 3D. It is just one more axis after all ;).


Thanks for your suggestion. We are moving to 3d is that, in Chinese market, 3d requirement is strong.


@zhangxm OK! Now I see the importance of 3D. Thanks for sharing the insight. I really appreciate you open mindedness.