Remove unused gamepad android config
This commit is contained in:
parent
11a7cdfe9d
commit
1055dd8932
@ -20,7 +20,6 @@
|
||||
#include "input/device_config.hpp"
|
||||
|
||||
#include "input/gamepad_config.hpp"
|
||||
#include "input/gamepad_android_config.hpp"
|
||||
#include "input/keyboard_config.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "io/utf_writer.hpp"
|
||||
@ -49,10 +48,6 @@ DeviceConfig* DeviceConfig::create(const XMLNode *config)
|
||||
{
|
||||
device_config = new GamepadConfig();
|
||||
}
|
||||
else if(config->getName()=="gamepad_android")
|
||||
{
|
||||
device_config = new GamepadAndroidConfig();
|
||||
}
|
||||
else
|
||||
{
|
||||
Log::error("DeviceConfig", "Incorrect type: '%s'.",
|
||||
|
@ -98,7 +98,6 @@ public:
|
||||
irr::core::stringw getMappingIdString (const PlayerAction action) const;
|
||||
virtual irr::core::stringw getBindingAsString(const PlayerAction action) const;
|
||||
virtual bool isGamePad() const = 0;
|
||||
virtual bool isGamePadAndroid() const = 0;
|
||||
virtual bool isKeyboard() const = 0;
|
||||
|
||||
virtual void save(std::ofstream& stream);
|
||||
|
@ -1,146 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010-2015 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
|
||||
#include "input/gamepad_android_config.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <SKeyMap.h>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
GamepadAndroidConfig::GamepadAndroidConfig()
|
||||
{
|
||||
setDefaultBinds();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Saves the configuration to a file. It writes the name for a gamepad
|
||||
* config, saves the device specific parameters, and calls
|
||||
* DeviceConfig::save() to save the rest.
|
||||
* \param stream The stream to save to.
|
||||
*/
|
||||
void GamepadAndroidConfig::save(std::ofstream& stream)
|
||||
{
|
||||
stream << "<gamepad_android ";
|
||||
DeviceConfig::save(stream);
|
||||
stream << "</gamepad_android>\n\n";
|
||||
} // save
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
irr::core::stringw GamepadAndroidConfig::getBindingAsString(const PlayerAction action) const
|
||||
{
|
||||
const Binding &b = getBinding(action);
|
||||
int id = b.getId();
|
||||
|
||||
irr::core::stringw button_name;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case IRR_KEY_BUTTON_LEFT:
|
||||
button_name = _C("input_key", "Left");
|
||||
break;
|
||||
case IRR_KEY_BUTTON_RIGHT:
|
||||
button_name = _C("input_key", "Right");
|
||||
break;
|
||||
case IRR_KEY_BUTTON_UP:
|
||||
button_name = _C("input_key", "Up");
|
||||
break;
|
||||
case IRR_KEY_BUTTON_DOWN:
|
||||
button_name = _C("input_key", "Down");
|
||||
break;
|
||||
case IRR_KEY_BUTTON_A:
|
||||
button_name = "A";
|
||||
break;
|
||||
case IRR_KEY_BUTTON_B:
|
||||
button_name = "B";
|
||||
break;
|
||||
case IRR_KEY_BUTTON_C:
|
||||
button_name = "C";
|
||||
break;
|
||||
case IRR_KEY_BUTTON_X:
|
||||
button_name = "X";
|
||||
break;
|
||||
case IRR_KEY_BUTTON_Y:
|
||||
button_name = "Y";
|
||||
break;
|
||||
case IRR_KEY_BUTTON_Z:
|
||||
button_name = "Z";
|
||||
break;
|
||||
case IRR_KEY_BUTTON_L1:
|
||||
button_name = "L1";
|
||||
break;
|
||||
case IRR_KEY_BUTTON_R1:
|
||||
button_name = "R1";
|
||||
break;
|
||||
case IRR_KEY_BUTTON_L2:
|
||||
button_name = "L2";
|
||||
break;
|
||||
case IRR_KEY_BUTTON_R2:
|
||||
button_name = "R2";
|
||||
break;
|
||||
case IRR_KEY_BUTTON_THUMBL:
|
||||
button_name = _C("input_key", "Thumb Left");
|
||||
break;
|
||||
case IRR_KEY_BUTTON_THUMBR:
|
||||
button_name = _C("input_key", "Thumb Right");
|
||||
break;
|
||||
case IRR_KEY_BUTTON_START:
|
||||
button_name = _C("input_key", "Start");
|
||||
break;
|
||||
case IRR_KEY_BUTTON_SELECT:
|
||||
button_name = _C("input_key", "Select");
|
||||
break;
|
||||
case IRR_KEY_BUTTON_MODE:
|
||||
button_name = _C("input_key", "Mode");
|
||||
break;
|
||||
default:
|
||||
button_name = DeviceConfig::getBindingAsString(action);
|
||||
break;
|
||||
}
|
||||
|
||||
return button_name;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void GamepadAndroidConfig::setDefaultBinds()
|
||||
{
|
||||
setBinding(PA_NITRO, Input::IT_KEYBOARD, IRR_KEY_BUTTON_X);
|
||||
setBinding(PA_ACCEL, Input::IT_KEYBOARD, IRR_KEY_BUTTON_UP);
|
||||
setBinding(PA_BRAKE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_DOWN);
|
||||
setBinding(PA_STEER_LEFT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_LEFT);
|
||||
setBinding(PA_STEER_RIGHT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_RIGHT);
|
||||
setBinding(PA_DRIFT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_Y);
|
||||
setBinding(PA_RESCUE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_L1);
|
||||
setBinding(PA_FIRE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_A);
|
||||
setBinding(PA_LOOK_BACK, Input::IT_KEYBOARD, IRR_KEY_BUTTON_R1);
|
||||
setBinding(PA_PAUSE_RACE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_B);
|
||||
|
||||
setBinding(PA_MENU_UP, Input::IT_KEYBOARD, IRR_KEY_BUTTON_UP);
|
||||
setBinding(PA_MENU_DOWN, Input::IT_KEYBOARD, IRR_KEY_BUTTON_DOWN);
|
||||
setBinding(PA_MENU_LEFT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_LEFT);
|
||||
setBinding(PA_MENU_RIGHT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_RIGHT);
|
||||
setBinding(PA_MENU_SELECT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_A);
|
||||
setBinding(PA_MENU_CANCEL, Input::IT_KEYBOARD, IRR_KEY_BUTTON_B);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -1,55 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010-2015 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_GAMEPAD_ANDROID_CONFIG_HPP
|
||||
#define HEADER_GAMEPAD_ANDROID_CONFIG_HPP
|
||||
|
||||
#include "input/binding.hpp"
|
||||
#include "input/keyboard_config.hpp"
|
||||
#include "input/input.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
/**
|
||||
* \brief specialisation of DeviceConfig for android gamepad devices
|
||||
* \ingroup config
|
||||
*/
|
||||
class GamepadAndroidConfig : public KeyboardConfig
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
GamepadAndroidConfig();
|
||||
virtual ~GamepadAndroidConfig() {}
|
||||
|
||||
virtual void setDefaultBinds();
|
||||
virtual void save(std::ofstream& stream);
|
||||
virtual irr::core::stringw getBindingAsString(const PlayerAction action) const;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool isGamePad() const { return false; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool isGamePadAndroid() const { return true; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool isKeyboard() const { return true; }
|
||||
|
||||
}; // class GamepadAndroidConfig
|
||||
|
||||
#endif
|
@ -112,8 +112,6 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool isGamePad() const OVERRIDE { return true; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool isGamePadAndroid() const OVERRIDE { return false; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool isKeyboard() const OVERRIDE { return false; }
|
||||
// ------------------------------------------------------------------------
|
||||
void initSDLController(const std::string& mapping, int buttons, int axes,
|
||||
|
@ -45,8 +45,6 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool isGamePad() const { return false; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool isGamePadAndroid() const { return false; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual bool isKeyboard() const { return true; }
|
||||
|
||||
}; // class KeyboardConfig
|
||||
|
@ -88,53 +88,45 @@ void OptionsScreenDevice::init()
|
||||
ButtonWidget* delete_button = getWidget<ButtonWidget>("delete");
|
||||
ButtonWidget* disable_toggle = getWidget<ButtonWidget>("disable_toggle");
|
||||
|
||||
if (m_config->isGamePadAndroid())
|
||||
core::stringw label;
|
||||
|
||||
if (!m_config->isKeyboard())
|
||||
{
|
||||
// Only allow to enable or disable a gamepad,
|
||||
// as it is only in the list when connected
|
||||
delete_button->setActive(false);
|
||||
disable_toggle->setActive(false);
|
||||
|
||||
label = (m_config->isEnabled()
|
||||
? //I18N: button to disable a gamepad configuration
|
||||
_("Disable Device")
|
||||
: //I18N: button to enable a gamepad configuration
|
||||
_("Enable Device"));
|
||||
}
|
||||
else
|
||||
{
|
||||
core::stringw label;
|
||||
// Don't allow deleting or disabling the last enabled config
|
||||
bool enable = (input_manager->getDeviceManager()
|
||||
->getActiveKeyboardAmount() > 1 ||
|
||||
!m_config->isEnabled());
|
||||
delete_button->setActive(enable);
|
||||
disable_toggle->setActive(enable);
|
||||
|
||||
if (!m_config->isKeyboard())
|
||||
{
|
||||
// Only allow to enable or disable a gamepad,
|
||||
// as it is only in the list when connected
|
||||
delete_button->setActive(false);
|
||||
|
||||
label = (m_config->isEnabled()
|
||||
? //I18N: button to disable a gamepad configuration
|
||||
_("Disable Device")
|
||||
: //I18N: button to enable a gamepad configuration
|
||||
_("Enable Device"));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Don't allow deleting or disabling the last enabled config
|
||||
bool enable = (input_manager->getDeviceManager()
|
||||
->getActiveKeyboardAmount() > 1 ||
|
||||
!m_config->isEnabled());
|
||||
delete_button->setActive(enable);
|
||||
disable_toggle->setActive(enable);
|
||||
|
||||
label = (m_config->isEnabled()
|
||||
? //I18N: button to disable a keyboard configuration
|
||||
_("Disable Configuration")
|
||||
: //I18N: button to enable a keyboard configuration
|
||||
_("Enable Configuration"));
|
||||
}
|
||||
|
||||
// Make sure button is wide enough as the text is being changed away
|
||||
// from the original value
|
||||
core::dimension2d<u32> size =
|
||||
GUIEngine::getFont()->getDimension(label.c_str());
|
||||
const int needed = size.Width + disable_toggle->getWidthNeededAroundLabel();
|
||||
if (disable_toggle->m_w < needed) disable_toggle->m_w = needed;
|
||||
|
||||
disable_toggle->setLabel(label);
|
||||
label = (m_config->isEnabled()
|
||||
? //I18N: button to disable a keyboard configuration
|
||||
_("Disable Configuration")
|
||||
: //I18N: button to enable a keyboard configuration
|
||||
_("Enable Configuration"));
|
||||
}
|
||||
|
||||
// Make sure button is wide enough as the text is being changed away
|
||||
// from the original value
|
||||
core::dimension2d<u32> size =
|
||||
GUIEngine::getFont()->getDimension(label.c_str());
|
||||
const int needed = size.Width + disable_toggle->getWidthNeededAroundLabel();
|
||||
if (disable_toggle->m_w < needed) disable_toggle->m_w = needed;
|
||||
|
||||
disable_toggle->setLabel(label);
|
||||
|
||||
// Make the three buttons the same length, not strictly needed but will
|
||||
// look nicer...
|
||||
ButtonWidget* backBtn = getWidget<ButtonWidget>("back_to_device_list");
|
||||
@ -162,8 +154,8 @@ void OptionsScreenDevice::init()
|
||||
delete_button->moveIrrlichtElement();
|
||||
disable_toggle->moveIrrlichtElement();
|
||||
|
||||
LabelWidget* label = getWidget<LabelWidget>("title");
|
||||
label->setText( m_config->getName().c_str(), false );
|
||||
LabelWidget* label_widget = getWidget<LabelWidget>("title");
|
||||
label_widget->setText( m_config->getName().c_str(), false );
|
||||
|
||||
// ---- create list skeleton (right number of items, right internal names)
|
||||
// their actualy contents will be adapted as needed after
|
||||
|
@ -100,30 +100,20 @@ void OptionsScreenInput::buildDeviceList()
|
||||
kbname << "keyboard" << i;
|
||||
const std::string internal_name = kbname.str();
|
||||
|
||||
if (config->isGamePadAndroid())
|
||||
const int icon = (config->isEnabled() ? 0 : 1);
|
||||
|
||||
//Display the configName instead of default name if it exists
|
||||
if (!config->getConfigName().empty())
|
||||
{
|
||||
// since irrLicht's list widget has the nasty tendency to put the
|
||||
// icons very close to the text, I'm adding spaces to compensate.
|
||||
devices->addItem(internal_name, (core::stringw(" ") +
|
||||
_("Gamepad")).c_str(), 2 /* icon */);
|
||||
config->getConfigName()), icon);
|
||||
}
|
||||
else
|
||||
{
|
||||
const int icon = (config->isEnabled() ? 0 : 1);
|
||||
|
||||
//Display the configName instead of default name if it exists
|
||||
if (!config->getConfigName().empty())
|
||||
{
|
||||
// since irrLicht's list widget has the nasty tendency to put the
|
||||
// icons very close to the text, I'm adding spaces to compensate.
|
||||
devices->addItem(internal_name, (core::stringw(" ") +
|
||||
config->getConfigName()), icon);
|
||||
}
|
||||
else
|
||||
{
|
||||
devices->addItem(internal_name, (core::stringw(" ") +
|
||||
_("Keyboard %i", i)).c_str(), icon);
|
||||
}
|
||||
devices->addItem(internal_name, (core::stringw(" ") +
|
||||
_("Keyboard %i", i)).c_str(), icon);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user