mirror of
https://github.com/minetest/minetest.git
synced 2025-01-08 14:27:31 +01:00
Controls: extract init_joysticks (#15597)
This commit is contained in:
parent
35bc217ba8
commit
cca65fde08
@ -301,24 +301,29 @@ void ClientLauncher::init_input()
|
|||||||
else
|
else
|
||||||
input = new RealInputHandler(receiver);
|
input = new RealInputHandler(receiver);
|
||||||
|
|
||||||
if (g_settings->getBool("enable_joysticks")) {
|
if (g_settings->getBool("enable_joysticks"))
|
||||||
irr::core::array<irr::SJoystickInfo> infos;
|
init_joysticks();
|
||||||
std::vector<irr::SJoystickInfo> joystick_infos;
|
}
|
||||||
|
|
||||||
// Make sure this is called maximum once per
|
void ClientLauncher::init_joysticks()
|
||||||
// irrlicht device, otherwise it will give you
|
{
|
||||||
// multiple events for the same joystick.
|
irr::core::array<irr::SJoystickInfo> infos;
|
||||||
if (m_rendering_engine->get_raw_device()->activateJoysticks(infos)) {
|
std::vector<irr::SJoystickInfo> joystick_infos;
|
||||||
infostream << "Joystick support enabled" << std::endl;
|
|
||||||
joystick_infos.reserve(infos.size());
|
// Make sure this is called maximum once per
|
||||||
for (u32 i = 0; i < infos.size(); i++) {
|
// irrlicht device, otherwise it will give you
|
||||||
joystick_infos.push_back(infos[i]);
|
// multiple events for the same joystick.
|
||||||
}
|
if (!m_rendering_engine->get_raw_device()->activateJoysticks(infos)) {
|
||||||
input->joystick.onJoystickConnect(joystick_infos);
|
errorstream << "Could not activate joystick support." << std::endl;
|
||||||
} else {
|
return;
|
||||||
errorstream << "Could not activate joystick support." << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
input->joystick.onJoystickConnect(joystick_infos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientLauncher::setting_changed_callback(const std::string &name, void *data)
|
void ClientLauncher::setting_changed_callback(const std::string &name, void *data)
|
||||||
|
@ -26,6 +26,7 @@ private:
|
|||||||
void init_args(GameStartData &start_data, const Settings &cmd_args);
|
void init_args(GameStartData &start_data, const Settings &cmd_args);
|
||||||
bool init_engine();
|
bool init_engine();
|
||||||
void init_input();
|
void init_input();
|
||||||
|
void init_joysticks();
|
||||||
|
|
||||||
static void setting_changed_callback(const std::string &name, void *data);
|
static void setting_changed_callback(const std::string &name, void *data);
|
||||||
void config_guienv();
|
void config_guienv();
|
||||||
|
Loading…
Reference in New Issue
Block a user