Started adding option to disable gamepads, this will allow shutting up gamepads that have soemthing constantly pressed

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@6430 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2010-11-08 01:26:31 +00:00
parent 55c9659b79
commit 92e7be10d3
5 changed files with 28 additions and 6 deletions

BIN
data/gui/gamepad_off.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

View File

@@ -140,6 +140,8 @@ bool DeviceConfig::doGetAction(Input::InputType type,
const PlayerAction lastActionToCheck,
PlayerAction* action /* out */ )
{
if (!m_enabled) return false;
bool success = false;
int n;
@@ -310,7 +312,8 @@ KeyboardConfig::KeyboardConfig() : DeviceConfig(DEVICE_CONFIG_TYPE_KEYBOARD)
void GamepadConfig::serialize (std::ofstream& stream)
{
stream << "<gamepad name =\"" << m_name.c_str() << "\">\n\n";
stream << "<gamepad name =\"" << m_name.c_str() << "\" enabled=\""
<< (m_enabled ? "true" : "false") << "\">\n\n";
DeviceConfig::serialize(stream);
stream << "</gamepad>\n\n\n";
}
@@ -363,6 +366,17 @@ GamepadConfig::GamepadConfig(irr::io::IrrXMLReader* xml) : DeviceConfig( DEVICE_
{
m_name = name_string;
}
const char* enabled_string = xml->getAttributeValue("enabled");
if (enabled_string != NULL)
{
m_enabled = (strcmp(enabled_string, "true") == 0);
}
else
{
m_enabled = true;
}
setPlugged(false);
setDefaultBinds();
}

View File

@@ -44,6 +44,8 @@ private:
protected:
bool m_enabled; //!< If set to false, this device will be ignored. Currently for gamepads only
std::string m_name;
DeviceConfigType m_type;
@@ -51,6 +53,7 @@ protected:
DeviceConfig(DeviceConfigType type)
{
m_type = type;
m_enabled = true;
}
/**
@@ -112,6 +115,8 @@ public:
bool hasBindingFor(const int buttonID) const;
/** At this time only relevant for gamepads, keyboards are always enabled */
bool isEnabled() const { return m_enabled; }
};
//==== K E Y B O A R D C O N F I G =============================================
@@ -157,8 +162,7 @@ public:
GamepadConfig (const std::string name,
const int axis_count,
const int btnCount);
// ~GamepadConfig();
// ~GamepadConfig();
};
#endif

View File

@@ -446,8 +446,8 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID, int btnID,
// reset timer when released
if (abs(value) == 0 && (/*type == Input::IT_KEYBOARD ||*/ type == Input::IT_STICKBUTTON))
{
if(type == Input::IT_STICKBUTTON) std::cout << "resetting because type == Input::IT_STICKBUTTON\n";
else std::cout << "resetting for another reason\n";
//if(type == Input::IT_STICKBUTTON) std::cout << "resetting because type == Input::IT_STICKBUTTON\n";
//else std::cout << "resetting for another reason\n";
m_timer_in_use = false;
m_timer = 0;

View File

@@ -56,10 +56,12 @@ void OptionsScreenInput::loadedFromFile()
{
video::ITexture* icon1 = irr_driver->getTexture( file_manager->getGUIDir() + "/keyboard.png" );
video::ITexture* icon2 = irr_driver->getTexture( file_manager->getGUIDir() + "/gamepad.png" );
video::ITexture* icon3 = irr_driver->getTexture( file_manager->getGUIDir() + "/gamepad_off.png" );
m_icon_bank = new irr::gui::STKModifiedSpriteBank( GUIEngine::getGUIEnv() );
m_icon_bank->addTextureAsSprite(icon1);
m_icon_bank->addTextureAsSprite(icon2);
m_icon_bank->addTextureAsSprite(icon3);
// scale icons depending on screen resolution. the numbers below are a bit arbitrary
const int screen_width = irr_driver->getFrameSize().Width;
@@ -109,7 +111,9 @@ void OptionsScreenInput::buildDeviceList()
gpname << "gamepad" << i;
const std::string internal_name = gpname.str();
devices->addItem(internal_name, name, 1 /* icon */);
const int icon = (config->isEnabled() ? 1 : 2);
devices->addItem(internal_name, name, icon);
} // if config->isPlugged
} // for i<gpad_config_count
} // buildDeviceList