|
|
|
|
@@ -24,11 +24,13 @@
|
|
|
|
|
#include "config/player.hpp"
|
|
|
|
|
#include "config/user_config.hpp"
|
|
|
|
|
#include "graphics/irr_driver.hpp"
|
|
|
|
|
#include "input/wiimote_manager.hpp"
|
|
|
|
|
#include "io/file_manager.hpp"
|
|
|
|
|
#include "states_screens/kart_selection.hpp"
|
|
|
|
|
#include "states_screens/state_manager.hpp"
|
|
|
|
|
#include "utils/log.hpp"
|
|
|
|
|
#include "utils/translation.hpp"
|
|
|
|
|
#include "input/wiimote_manager.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define INPUT_MODE_DEBUG 0
|
|
|
|
|
|
|
|
|
|
@@ -56,18 +58,18 @@ bool DeviceManager::initialize()
|
|
|
|
|
|
|
|
|
|
if(UserConfigParams::logMisc())
|
|
|
|
|
{
|
|
|
|
|
printf("Initializing Device Manager\n");
|
|
|
|
|
printf("---------------------------\n");
|
|
|
|
|
Log::info("Device manager","Initializing Device Manager");
|
|
|
|
|
Log::info("-","---------------------------");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deserialize();
|
|
|
|
|
|
|
|
|
|
// Assign a configuration to the keyboard, or create one if we haven't yet
|
|
|
|
|
if(UserConfigParams::logMisc()) printf("Initializing keyboard support.\n");
|
|
|
|
|
if(UserConfigParams::logMisc()) Log::info("Device manager","Initializing keyboard support.");
|
|
|
|
|
if (m_keyboard_configs.size() == 0)
|
|
|
|
|
{
|
|
|
|
|
if(UserConfigParams::logMisc())
|
|
|
|
|
printf("No keyboard configuration exists, creating one.\n");
|
|
|
|
|
Log::info("Device manager","No keyboard configuration exists, creating one.");
|
|
|
|
|
m_keyboard_configs.push_back(new KeyboardConfig());
|
|
|
|
|
created = true;
|
|
|
|
|
}
|
|
|
|
|
@@ -79,13 +81,13 @@ bool DeviceManager::initialize()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(UserConfigParams::logMisc())
|
|
|
|
|
printf("Initializing gamepad support.\n");
|
|
|
|
|
Log::info("Device manager","Initializing gamepad support.");
|
|
|
|
|
|
|
|
|
|
irr_driver->getDevice()->activateJoysticks(m_irrlicht_gamepads);
|
|
|
|
|
int num_gamepads = m_irrlicht_gamepads.size();
|
|
|
|
|
if(UserConfigParams::logMisc())
|
|
|
|
|
{
|
|
|
|
|
printf("Irrlicht reports %d gamepads are attached to the system.\n",
|
|
|
|
|
Log::info("Device manager","Irrlicht reports %d gamepads are attached to the system.",
|
|
|
|
|
num_gamepads);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -109,19 +111,19 @@ bool DeviceManager::initialize()
|
|
|
|
|
|
|
|
|
|
if (UserConfigParams::logMisc())
|
|
|
|
|
{
|
|
|
|
|
printf("#%d: %s detected...", id, name.c_str());
|
|
|
|
|
Log::info("Device manager","#%d: %s detected...", id, name.c_str());
|
|
|
|
|
}
|
|
|
|
|
// Returns true if new configuration was created
|
|
|
|
|
if (getConfigForGamepad(id, name, &gamepadConfig) == true)
|
|
|
|
|
{
|
|
|
|
|
if(UserConfigParams::logMisc())
|
|
|
|
|
printf("creating new configuration.\n");
|
|
|
|
|
Log::info("Device manager","creating new configuration.");
|
|
|
|
|
created = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(UserConfigParams::logMisc())
|
|
|
|
|
printf("using existing configuration.\n");
|
|
|
|
|
Log::info("Device manager","using existing configuration.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gamepadConfig->setPlugged();
|
|
|
|
|
@@ -440,12 +442,12 @@ bool DeviceManager::deserialize()
|
|
|
|
|
static std::string filepath = file_manager->getUserConfigFile(INPUT_FILE_NAME);
|
|
|
|
|
|
|
|
|
|
if(UserConfigParams::logMisc())
|
|
|
|
|
printf("Deserializing input.xml...\n");
|
|
|
|
|
Log::info("Device manager","Deserializing input.xml...");
|
|
|
|
|
|
|
|
|
|
if(!file_manager->fileExists(filepath))
|
|
|
|
|
{
|
|
|
|
|
if(UserConfigParams::logMisc())
|
|
|
|
|
printf("Warning: no configuration file exists.\n");
|
|
|
|
|
Log::warn("Device manager","No configuration file exists.");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@@ -499,15 +501,15 @@ bool DeviceManager::deserialize()
|
|
|
|
|
{
|
|
|
|
|
if(keyboard_config != NULL)
|
|
|
|
|
if(!keyboard_config->deserializeAction(xml))
|
|
|
|
|
std::cerr << "Ignoring an ill-formed keyboard action in input config.\n";
|
|
|
|
|
Log::error("Device manager","Ignoring an ill-formed keyboard action in input config.");
|
|
|
|
|
}
|
|
|
|
|
else if(reading_now == GAMEPAD)
|
|
|
|
|
{
|
|
|
|
|
if(gamepad_config != NULL)
|
|
|
|
|
if(!gamepad_config->deserializeAction(xml))
|
|
|
|
|
std::cerr << "Ignoring an ill-formed gamepad action in input config.\n";
|
|
|
|
|
Log::error("Device manager","Ignoring an ill-formed gamepad action in input config.");
|
|
|
|
|
}
|
|
|
|
|
else std::cerr << "Warning: An action is placed in an unexpected area in the input config file.\n";
|
|
|
|
|
else Log::warn("Device manager","An action is placed in an unexpected area in the input config file.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
@@ -534,7 +536,7 @@ bool DeviceManager::deserialize()
|
|
|
|
|
|
|
|
|
|
if(UserConfigParams::logMisc())
|
|
|
|
|
{
|
|
|
|
|
printf("Found %d keyboard and %d gamepad configurations.\n",
|
|
|
|
|
Log::info("Device manager","Found %d keyboard and %d gamepad configurations.",
|
|
|
|
|
m_keyboard_configs.size(), m_gamepad_configs.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -557,7 +559,7 @@ bool DeviceManager::deserialize()
|
|
|
|
|
void DeviceManager::serialize()
|
|
|
|
|
{
|
|
|
|
|
static std::string filepath = file_manager->getUserConfigFile(INPUT_FILE_NAME);
|
|
|
|
|
if(UserConfigParams::logMisc()) printf("Serializing input.xml...\n");
|
|
|
|
|
if(UserConfigParams::logMisc()) Log::info("Device manager","Serializing input.xml...");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::ofstream configfile;
|
|
|
|
|
@@ -565,8 +567,7 @@ void DeviceManager::serialize()
|
|
|
|
|
|
|
|
|
|
if(!configfile.is_open())
|
|
|
|
|
{
|
|
|
|
|
std::cerr << "Failed to open " << filepath.c_str()
|
|
|
|
|
<< " for writing, controls won't be saved\n";
|
|
|
|
|
Log::error("Device manager","Failed to open %s for writing, controls won't be saved",filepath.c_str());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -584,7 +585,7 @@ void DeviceManager::serialize()
|
|
|
|
|
|
|
|
|
|
configfile << "</input>\n";
|
|
|
|
|
configfile.close();
|
|
|
|
|
if(UserConfigParams::logMisc()) printf("Serialization complete.\n\n");
|
|
|
|
|
if(UserConfigParams::logMisc()) Log::info("Device manager","Serialization complete.");
|
|
|
|
|
} // serialize
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|