Made m_plugged and m_name in DeviceConfig private.
This commit is contained in:
@@ -63,8 +63,9 @@ DeviceConfig* DeviceConfig::create(const XMLNode *config)
|
||||
} // create
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
DeviceConfig::DeviceConfig(DeviceConfigType type)
|
||||
DeviceConfig::DeviceConfig( DeviceConfigType type)
|
||||
{
|
||||
m_name = "";
|
||||
m_type = type;
|
||||
m_enabled = true;
|
||||
m_plugged = 0;
|
||||
@@ -305,6 +306,7 @@ void DeviceConfig::save (std::ofstream& stream)
|
||||
*/
|
||||
bool DeviceConfig::load(const XMLNode *config)
|
||||
{
|
||||
config->get("name", &m_name);
|
||||
config->get("enabled", &m_enabled);
|
||||
bool error = false;
|
||||
for(unsigned int i=0; i<config->getNumNodes(); i++)
|
||||
|
||||
@@ -51,16 +51,16 @@ private:
|
||||
* Currently for gamepads only. */
|
||||
bool m_enabled;
|
||||
|
||||
protected:
|
||||
|
||||
Binding m_bindings[PA_COUNT];
|
||||
|
||||
/** How many devices connected to the system which uses this config? */
|
||||
int m_plugged;
|
||||
|
||||
/** Name of this configuratiom. */
|
||||
std::string m_name;
|
||||
|
||||
protected:
|
||||
|
||||
Binding m_bindings[PA_COUNT];
|
||||
|
||||
/** Configuration type. */
|
||||
DeviceConfigType m_type;
|
||||
|
||||
@@ -105,6 +105,9 @@ public:
|
||||
virtual void save(std::ofstream& stream);
|
||||
virtual bool load(const XMLNode *config);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the name of this device. */
|
||||
void setName(const std::string &name) { m_name = name; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the name for this device configuration. */
|
||||
const std::string& getName() const { return m_name; };
|
||||
|
||||
|
||||
@@ -29,26 +29,23 @@
|
||||
using namespace irr;
|
||||
|
||||
|
||||
GamepadConfig::GamepadConfig ( const std::string &name,
|
||||
const int axis_count,
|
||||
const int button_count )
|
||||
: DeviceConfig( DEVICE_CONFIG_TYPE_GAMEPAD )
|
||||
GamepadConfig::GamepadConfig( const std::string &name,
|
||||
const int axis_count,
|
||||
const int button_count )
|
||||
: DeviceConfig(DEVICE_CONFIG_TYPE_GAMEPAD )
|
||||
{
|
||||
m_name = name;
|
||||
setName(name);
|
||||
m_axis_count = axis_count;
|
||||
m_button_count = button_count;
|
||||
m_deadzone = 2000;
|
||||
m_plugged = 0;
|
||||
setDefaultBinds();
|
||||
} // GamepadConfig
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
GamepadConfig::GamepadConfig() : DeviceConfig( DEVICE_CONFIG_TYPE_GAMEPAD )
|
||||
GamepadConfig::GamepadConfig() : DeviceConfig(DEVICE_CONFIG_TYPE_GAMEPAD )
|
||||
{
|
||||
m_plugged = 0;
|
||||
m_deadzone = 2000;
|
||||
m_name = "";
|
||||
setDefaultBinds();
|
||||
} // GamepadConfig
|
||||
|
||||
@@ -59,14 +56,16 @@ GamepadConfig::GamepadConfig() : DeviceConfig( DEVICE_CONFIG_TYPE_GAMEPAD )
|
||||
*/
|
||||
bool GamepadConfig::load(const XMLNode *config)
|
||||
{
|
||||
if(!config->get("name", &m_name))
|
||||
config->get("deadzone", &m_deadzone);
|
||||
bool ok = DeviceConfig::load(config);
|
||||
|
||||
if(getName()=="")
|
||||
{
|
||||
Log::error("DeviceConfig", "Unnamed joystick in config file.");
|
||||
return false;
|
||||
}
|
||||
m_deadzone = 2000;
|
||||
config->get("deadzone", &m_deadzone);
|
||||
return DeviceConfig::load(config);
|
||||
|
||||
return ok;
|
||||
} // load
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -77,7 +76,7 @@ bool GamepadConfig::load(const XMLNode *config)
|
||||
*/
|
||||
void GamepadConfig::save (std::ofstream& stream)
|
||||
{
|
||||
stream << "<gamepad name =\"" << m_name.c_str()
|
||||
stream << "<gamepad name =\"" << getName()
|
||||
<<"\" deadzone=\""<<m_deadzone << "\"\n";
|
||||
stream << " ";
|
||||
DeviceConfig::save(stream);
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
using namespace irr;
|
||||
|
||||
|
||||
KeyboardConfig::KeyboardConfig() : DeviceConfig(DEVICE_CONFIG_TYPE_KEYBOARD)
|
||||
KeyboardConfig::KeyboardConfig()
|
||||
: DeviceConfig(DEVICE_CONFIG_TYPE_KEYBOARD)
|
||||
{
|
||||
m_name = "Keyboard";
|
||||
m_plugged = 1;
|
||||
setDefaultBinds();
|
||||
setPlugged();
|
||||
} // KeyboardConfig
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user