diff options
author | est31 <MTest31@outlook.com> | 2016-05-27 08:35:07 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2016-06-03 19:42:57 +0200 |
commit | 2060fd9cbe587d7e8ffe0cecdd67925f13a56c05 (patch) | |
tree | f9f74c0a6609b0063fec6ed6f3d43fe42e43d5f1 /src/client/clientlauncher.cpp | |
parent | 1e86c89f3614cf298916149a8f13d44ea671da64 (diff) | |
download | minetest-2060fd9cbe587d7e8ffe0cecdd67925f13a56c05.tar.xz |
Initial Gamepad support
Adds initial ingame gamepad support to minetest.
Full Formspec support is not implemented yet and
can be added by a later change.
Diffstat (limited to 'src/client/clientlauncher.cpp')
-rw-r--r-- | src/client/clientlauncher.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp index 404a16310..ee8662ed6 100644 --- a/src/client/clientlauncher.cpp +++ b/src/client/clientlauncher.cpp @@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "guiEngine.h" #include "player.h" #include "fontengine.h" +#include "joystick_controller.h" #include "clientlauncher.h" /* mainmenumanager.h @@ -499,7 +500,8 @@ void ClientLauncher::main_menu(MainMenuData *menudata) #endif /* show main menu */ - GUIEngine mymenu(device, guiroot, &g_menumgr, smgr, menudata, *kill); + GUIEngine mymenu(device, &input->joystick, guiroot, + &g_menumgr, smgr, menudata, *kill); smgr->clear(); /* leave scene manager in a clean state */ } @@ -558,6 +560,22 @@ bool ClientLauncher::create_engine_device() device = createDeviceEx(params); if (device) { + if (g_settings->getBool("enable_joysticks")) { + irr::core::array<irr::SJoystickInfo> infos; + std::vector<irr::SJoystickInfo> joystick_infos; + // Make sure this is called maximum once per + // irrlicht device, otherwise it will give you + // multiple events for the same joystick. + if (device->activateJoysticks(infos)) { + infostream << "Joystick support enabled" << std::endl; + joystick_infos.reserve(infos.size()); + for (u32 i = 0; i < infos.size(); i++) { + joystick_infos.push_back(infos[i]); + } + } else { + errorstream << "Could not activate joystick support." << std::endl; + } + } porting::initIrrlicht(device); } |