diff options
author | muemart <muemart@users.noreply.github.com> | 2017-12-13 19:06:14 +0100 |
---|---|---|
committer | noah katz <n-katz@hotmail.com> | 2018-01-16 22:49:48 +0100 |
commit | aec3b28547c4f7bf1bd94340dd423b49df9e3db0 (patch) | |
tree | ee685fba2203bab0d41a3096ab104bbfdbd911ec /src | |
parent | Add translation support for button labels (diff) | |
download | yuzu-aec3b28547c4f7bf1bd94340dd423b49df9e3db0.tar yuzu-aec3b28547c4f7bf1bd94340dd423b49df9e3db0.tar.gz yuzu-aec3b28547c4f7bf1bd94340dd423b49df9e3db0.tar.bz2 yuzu-aec3b28547c4f7bf1bd94340dd423b49df9e3db0.tar.lz yuzu-aec3b28547c4f7bf1bd94340dd423b49df9e3db0.tar.xz yuzu-aec3b28547c4f7bf1bd94340dd423b49df9e3db0.tar.zst yuzu-aec3b28547c4f7bf1bd94340dd423b49df9e3db0.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/yuzu/configuration/configure_input.cpp | 95 |
1 files changed, 46 insertions, 49 deletions
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index bcb91b636..0a67c3180 100644 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -42,6 +42,52 @@ static void SetAnalogButton(const Common::ParamPackage& input_param, analog_param.Set(button_name, input_param.Serialize()); } +static QString ButtonToText(const Common::ParamPackage& param) { + if (!param.Has("engine")) { + return QObject::tr("[not set]"); + } else if (param.Get("engine", "") == "keyboard") { + return getKeyName(param.Get("code", 0)); + } else if (param.Get("engine", "") == "sdl") { + QString text = QString(QObject::tr("Joystick %1")).arg(param.Get("joystick", "").c_str()); + if (param.Has("hat")) { + text += QString(QObject::tr(" Hat %1 %2")) + .arg(param.Get("hat", "").c_str(), param.Get("direction", "").c_str()); + } + if (param.Has("axis")) { + text += QString(QObject::tr(" Axis %1%2")) + .arg(param.Get("axis", "").c_str(), param.Get("direction", "").c_str()); + } + if (param.Has("button")) { + text += QString(QObject::tr(" Button %1")).arg(param.Get("button", "").c_str()); + } + return text; + } else { + return QObject::tr("[unknown]"); + } +}; + +static QString AnalogToText(const Common::ParamPackage& param, const std::string& dir) { + if (!param.Has("engine")) { + return QObject::tr("[not set]"); + } else if (param.Get("engine", "") == "analog_from_button") { + return ButtonToText(Common::ParamPackage{param.Get(dir, "")}); + } else if (param.Get("engine", "") == "sdl") { + if (dir == "modifier") { + return QString(QObject::tr("[unused]")); + } + + QString text = QString(QObject::tr("Joystick %1")).arg(param.Get("joystick", "").c_str()); + if (dir == "left" || dir == "right") { + text += QString(QObject::tr(" Axis %1")).arg(param.Get("axis_x", "").c_str()); + } else if (dir == "up" || dir == "down") { + text += QString(QObject::tr(" Axis %1")).arg(param.Get("axis_y", "").c_str()); + } + return text; + } else { + return QObject::tr("[unknown]"); + } +}; + ConfigureInput::ConfigureInput(QWidget* parent) : QWidget(parent), ui(std::make_unique<Ui::ConfigureInput>()), timeout_timer(std::make_unique<QTimer>()), poll_timer(std::make_unique<QTimer>()) { @@ -166,55 +212,6 @@ void ConfigureInput::restoreDefaults() { } void ConfigureInput::updateButtonLabels() { - QString unknown_mapping(tr("[unknown]")); - QString mapping_not_set(tr("[not set]")); - - auto ButtonToText = [&unknown_mapping, &mapping_not_set](const Common::ParamPackage& param) { - if (!param.Has("engine")) { - return mapping_not_set; - } else if (param.Get("engine", "") == "keyboard") { - return getKeyName(param.Get("code", 0)); - } else if (param.Get("engine", "") == "sdl") { - QString text = QString(tr("Joystick %1")).arg(param.Get("joystick", "").c_str()); - if (param.Has("hat")) { - text += QString(tr(" Hat %1 %2")) - .arg(param.Get("hat", "").c_str(), param.Get("direction", "").c_str()); - } - if (param.Has("axis")) { - text += QString(tr(" Axis %1%2")) - .arg(param.Get("axis", "").c_str(), param.Get("direction", "").c_str()); - } - if (param.Has("button")) { - text += QString(tr(" Button %1")).arg(param.Get("button", "").c_str()); - } - return text; - } else { - return unknown_mapping; - } - }; - auto AnalogToText = [&unknown_mapping, &mapping_not_set, - &ButtonToText](const Common::ParamPackage& param, const std::string& dir) { - if (!param.Has("engine")) { - return mapping_not_set; - } else if (param.Get("engine", "") == "analog_from_button") { - return ButtonToText(Common::ParamPackage{param.Get(dir, "")}); - } else if (param.Get("engine", "") == "sdl") { - if (dir == "modifier") { - return QString(tr("[unused]")); - } - - QString text = QString(tr("Joystick %1")).arg(param.Get("joystick", "").c_str()); - if (dir == "left" || dir == "right") { - text += QString(tr(" Axis %1")).arg(param.Get("axis_x", "").c_str()); - } else if (dir == "up" || dir == "down") { - text += QString(tr(" Axis %1")).arg(param.Get("axis_y", "").c_str()); - } - return text; - } else { - return unknown_mapping; - } - }; - for (int button = 0; button < Settings::NativeButton::NumButtons; button++) { button_map[button]->setText(ButtonToText(buttons_param[button])); } |