Completely removed device type, instead use isGamePad() and

isKeyboard().
This commit is contained in:
hiker 2014-10-30 17:43:50 +11:00
parent 25bbc06109
commit e9980fcb2f
7 changed files with 28 additions and 45 deletions

View File

@ -63,10 +63,9 @@ DeviceConfig* DeviceConfig::create(const XMLNode *config)
} // create
// ------------------------------------------------------------------------
DeviceConfig::DeviceConfig( DeviceConfigType type)
DeviceConfig::DeviceConfig()
{
m_name = "";
m_type = type;
m_enabled = true;
m_plugged = 0;
} // DeviceConfig

View File

@ -39,12 +39,6 @@
*/
class DeviceConfig : public NoCopy
{
public:
enum DeviceConfigType
{
DEVICE_CONFIG_TYPE_GAMEPAD,
DEVICE_CONFIG_TYPE_KEYBOARD
};
private:
/** If set to false, this device will be ignored.
@ -57,14 +51,11 @@ private:
/** Name of this configuratiom. */
std::string m_name;
/** Configuration type. */
DeviceConfigType m_type;
protected:
Binding m_bindings[PA_COUNT];
DeviceConfig(DeviceConfigType type);
DeviceConfig();
bool doGetAction(Input::InputType type,
const int id,
@ -100,8 +91,8 @@ public:
PlayerAction* action /* out */);
irr::core::stringw getMappingIdString (const PlayerAction action) const;
irr::core::stringw getBindingAsString(const PlayerAction action) const;
virtual DeviceConfigType getType() const = 0;
virtual bool isGamePad() const = 0;
virtual bool isKeyboard() const = 0;
virtual void save(std::ofstream& stream);
virtual bool load(const XMLNode *config);
// ------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ using namespace irr;
GamepadConfig::GamepadConfig( const std::string &name,
const int axis_count,
const int button_count )
: DeviceConfig(DEVICE_CONFIG_TYPE_GAMEPAD )
: DeviceConfig()
{
setName(name);
m_axis_count = axis_count;
@ -43,7 +43,7 @@ GamepadConfig::GamepadConfig( const std::string &name,
//------------------------------------------------------------------------------
GamepadConfig::GamepadConfig() : DeviceConfig(DEVICE_CONFIG_TYPE_GAMEPAD )
GamepadConfig::GamepadConfig() : DeviceConfig()
{
m_deadzone = 2000;
setDefaultBinds();

View File

@ -29,12 +29,10 @@
#include <irrString.h>
#include <string>
//==== G A M E P A D C O N F I G ===============================================
/**
* \brief specialisation of DeviceConfig for gamepad type devices
* \ingroup config
*/
/** \brief specialisation of DeviceConfig for gamepad type devices
* \ingroup config
*/
class GamepadConfig : public DeviceConfig
{
@ -72,11 +70,10 @@ public:
/** Return deadzone of this configuration. */
int getDeadzone() const { return m_deadzone; }
// ------------------------------------------------------------------------
/** Returns the type of this configuration. */
virtual DeviceConfig::DeviceConfigType getType() const
{
return DeviceConfig::DEVICE_CONFIG_TYPE_GAMEPAD;
} // getType
};
virtual bool isGamePad() const { return true; }
// ------------------------------------------------------------------------
virtual bool isKeyboard() const { return false; }
}; // class GamepadConfig
#endif

View File

@ -30,7 +30,7 @@ using namespace irr;
KeyboardConfig::KeyboardConfig()
: DeviceConfig(DEVICE_CONFIG_TYPE_KEYBOARD)
: DeviceConfig()
{
setDefaultBinds();
setPlugged();

View File

@ -23,11 +23,9 @@
#include "input/device_config.hpp"
#include "input/input.hpp"
#include "utils/no_copy.hpp"
#include "utils/cpp2011.hpp"
#include <iosfwd>
#include <irrString.h>
#include <string>
/**
* \brief specialisation of DeviceConfig for keyboard type devices
@ -43,12 +41,10 @@ public:
KeyboardConfig ();
// ------------------------------------------------------------------------
/** Returns the type of this configuration. */
virtual DeviceConfigType getType() const
{
return DEVICE_CONFIG_TYPE_KEYBOARD;
} // getType
};
virtual bool isGamePad() const { return false; }
// ------------------------------------------------------------------------
virtual bool isKeyboard() const { return true; }
}; // class KeyboardConfig
#endif

View File

@ -89,7 +89,7 @@ void OptionsScreenInput2::init()
ButtonWidget* delete_button = getWidget<ButtonWidget>("delete");
if (m_config->getType() != DeviceConfig::DEVICE_CONFIG_TYPE_KEYBOARD)
if (m_config->isKeyboard())
{
core::stringw label = (m_config->isEnabled()
? //I18N: button to disable a gamepad configuration
@ -291,7 +291,7 @@ void OptionsScreenInput2::updateInputButtons()
if (currently_used_keys.find(item) == currently_used_keys.end())
{
currently_used_keys.insert( item );
if (m_config->getType() == DeviceConfig::DEVICE_CONFIG_TYPE_KEYBOARD
if (m_config->isKeyboard()
&& conflictsBetweenKbdConfig(action, PA_FIRST_GAME_ACTION,
PA_LAST_GAME_ACTION))
{
@ -333,7 +333,7 @@ void OptionsScreenInput2::updateInputButtons()
if (currently_used_keys.find(item) == currently_used_keys.end())
{
currently_used_keys.insert( item );
if (m_config->getType() == DeviceConfig::DEVICE_CONFIG_TYPE_KEYBOARD
if (m_config->isKeyboard()
&& conflictsBetweenKbdConfig(action, PA_FIRST_MENU_ACTION,
PA_LAST_MENU_ACTION))
{
@ -386,11 +386,11 @@ static std::string binding_to_set_button;
void OptionsScreenInput2::gotSensedInput(const Input& sensed_input)
{
const bool keyboard = (m_config->getType() == DeviceConfig::DEVICE_CONFIG_TYPE_KEYBOARD&&
const bool keyboard = (m_config->isKeyboard() &&
sensed_input.m_type == Input::IT_KEYBOARD);
const bool gamepad = (sensed_input.m_type == Input::IT_STICKMOTION ||
sensed_input.m_type == Input::IT_STICKBUTTON) &&
m_config->getType() == DeviceConfig::DEVICE_CONFIG_TYPE_GAMEPAD;
m_config->isGamePad();
if (keyboard)
{
@ -549,11 +549,11 @@ void OptionsScreenInput2::eventCallback(Widget* widget,
new PressAKeyDialog(0.4f, 0.4f);
if (m_config->getType() == DeviceConfig::DEVICE_CONFIG_TYPE_KEYBOARD)
if (m_config->isKeyboard())
{
input_manager->setMode(InputManager::INPUT_SENSE_KEYBOARD);
}
else if (m_config->getType() == DeviceConfig::DEVICE_CONFIG_TYPE_GAMEPAD)
else if (m_config->isGamePad())
{
input_manager->setMode(InputManager::INPUT_SENSE_GAMEPAD);
}
@ -568,7 +568,7 @@ void OptionsScreenInput2::eventCallback(Widget* widget,
}
else if (name == "delete")
{
if (m_config->getType() == DeviceConfig::DEVICE_CONFIG_TYPE_KEYBOARD)
if (m_config->isKeyboard())
{
// keyboard configs may be deleted
//I18N: shown before deleting an input configuration