diff --git a/cocos/base/CCController-linux-win32.cpp b/cocos/base/CCController-linux-win32.cpp index c6eba3655a..bec6d8bfeb 100644 --- a/cocos/base/CCController-linux-win32.cpp +++ b/cocos/base/CCController-linux-win32.cpp @@ -42,6 +42,15 @@ class CC_DLL ControllerImpl ControllerImpl() { + //FIXME: Once GLFW 3.3 is bundled with cocos2d-x and no extra + //controllers have been added here, remove all the code here. If + //extra controllers were added, make sure to add them to the SDL + //Controller Database at + //https://github.com/gabomdq/SDL_GameControllerDB which GLFW uses + //for providing the new gamepad API. We are going to map the GLFW + //game pad events to Controller::Key key codes. + + // Note: the controllers input profile were taken from the // RetroArch joypad autoconfig project at: // https://github.com/libretro/retroarch-joypad-autoconfig/tree/master/udev @@ -4854,6 +4863,11 @@ class CC_DLL ControllerImpl } private: + //FIXME: Once GLFW 3.3 is bundled with cocos2d-x, remove these + //controller profiles and all the related code. We will only need to + //provide a mapping from the GLFW gamepad key codes to the + //Controller::Key keycodes. So far an std::unordered_map + //should suffice. static std::map, std::unordered_map > > s_controllerProfiles; }; diff --git a/cocos/base/CCController.h b/cocos/base/CCController.h index e1068b0af3..282732468f 100644 --- a/cocos/base/CCController.h +++ b/cocos/base/CCController.h @@ -220,10 +220,14 @@ private: EventController *_axisEvent; #if ( CC_TARGET_PLATFORM == CC_PLATFORM_LINUX || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 ) + //FIXME: Once GLFW 3.3 is bundled with cocos2d-x, remove these unordered + //maps. They won't be needed. We will only need to provide a mapping from + //the GLFW gamepad key codes to the Controller::Key. + // Attach the controller profiles from CCController-linux-win32.cpp to each // of the Controller variables in order to minimize profile lookup time. - // Note: this increases memory usage unecessarily since the same maps are + // Note: this increases memory usage unnecessarily since the same maps are // already stored on ControllerImpl within the static member variable // "s_controllerProfiles", but on these platforms the increase in memory // usage is negligible. Peformance over memory optimization was