Projects > cpp > Issues > Feature #4689

We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.

Create Issue on Github

Game controller support

Feature #4689 [Closed]
zhangxm 2014-04-05 02:25 . Updated over 2 years ago

cocos2d-x-3_1alpha1-GLFW-Joystick-patch_1alpha1-GLFW-Joystick-patch (8.5 kB) Sheado, 2014-05-22 21:14

cocos2d-x-3_1_1-GLFW-Joystick.patch - v3.1.1 GLFW joystick patch (10.9 kB) Sheado, 2014-06-04 00:32

zhangxm 2014-04-05 02:48
  • Assignee changed from WenHai to dumganhar
zhangxm 2014-04-24 07:27
  • Target version changed from v3.1 to v3.2
Sheado 2014-05-22 21:14


Here a patch for adding GLFW joystick support on the desktop. I don't have a pull request because couldn't run latest cocos2d-x from git.


HiramGeeks 2014-05-23 10:20

Hey guys, it's really exciting to hear that Joystick Support is officially on the way. I give you my total support and availability to help testing it. That's definitely one of the most wanted feature for Desktop Games.

Thanks for your commitment on this.

zhangxm 2014-05-29 08:01
  • Assignee changed from dumganhar to WenHai
Sheado 2014-06-04 00:32

Hey guys,

Just a quick update. I updated my patch file to work with v3.1.1
I'm testing with a PS3 controller on an iMac and it's working fine.
Attached is the latest patch file.

HiramGeeks 2014-06-04 00:35

Great Job! I'm looking forward for this feature..

HiramGeeks 2014-06-14 09:43

Hey @sheado any updates in your patch?

Sheado 2014-06-16 18:52

Hey @HiramGeeks

I'm not an official cocos2d-x developer - so I'm not really sure when or if the team will integrate my patch.
I've been using the PS3 controller on the iMac with my game for weeks now and it's working fine. The only thing is that I have yet to develop key mappings because that can be complicated due to large amounts of gamepads out there. I was hoping to look into Steam's SDL mappings database to see if that's something we can apply to GLFW.

Anyway.. If you want to use the patch, try the following:
1. Make a copy of cocos2d-x v3.1.1 (in case something goes wrong)
2. cd to_the_v3.1.1_directory
3. patch < cocos2d-x-3_1_1-GLFW-Joystick.patch

You may need to modify the patch parameters to adjust for path changes. Here's more info on how to do that:

zhangxm 2014-07-18 05:49
  • Status changed from New to Closed
Sheado 2014-07-22 19:56

Hi All,

It looks like PC/Mac/Linux gamepad support was not added in 3.2.
Are there any plans on implementing this? The patch above implements GLFW gamepad support - only things that need to be done are:

  • adhering to the new game controller architecture
  • button id mappings


HiramGeeks 2014-07-22 20:04

Really? I'm happy you mentioned that because I was considering staying on C2DX instead migrating to Unity 3D, but after that waiting for the 3.2 version and no joystick support, it's clear that I'm moving to Unity.

Thanks for letting us know, didn't need to waste time to figure it out.

zhangxm 2014-07-23 10:48

Sorry about it.
We don't have time to add support for PC/Mac/Linux in v3.2.
We will support it in future.
May be v3.4.

Sheado 2014-07-23 19:21

No problem @zhangxm,
I understand. You guys are probably super busy.

Can we at least create an issue ticket for it so it doesn't get forgotten?

zhangxm 2014-07-24 02:09

Yep. I have created it in trello.
And we will create a new ticket here when it is to be done.

Atom PDF

Start date:2014-04-17
Due date:
% Done:


Category:android, ios
Target version:v3.2
Estimated time:120.00 points


Feature #4890: API design of Game controllerClosedWenHai

Feature #4892: Implement logical codes of game controllerClosedWenHai

Feature #4895: Get events from controller to engine and add test caseClosedWenHai

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.