From 3f13dbe0878523b65d158efddc3eff37d59ca3a2 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 30 Mar 2018 21:42:26 +0200 Subject: [PATCH 1/2] Translate certain button names but not all Some button names should be translated, for instance Up, Left and such. At the same time, some other button names shouldn't be translated, for reasons that might be less obvious. In 0146456af, I removed the _trans markers for button names that never need to be translated (such as A and B), but that isn't actually enough to ensure that DolphinWX won't try to translate them anyway. This commit adds a bool that explicitly tells the GUI whether a button name should be translated. Otherwise we'll have problems like the GUI treating the button name "B" (which isn't supposed to be translated) as matching the translatable string "B" (being an abbreviation of "bytes"), meaning that the button "B" will be labeled "o" when running Dolphin in French (after translations get pulled from Transifex the next time). By the way, while it turned out that DolphinWX translated all button names, it also turned out that DolphinQt2 translated *no* button names. Go figure. This commit makes them consistent with each other. --- Source/Core/Core/HW/GCKeyboardEmu.cpp | 12 ++++++------ Source/Core/Core/HW/GCPadEmu.cpp | 16 ++++++++-------- .../Core/HW/WiimoteEmu/Attachment/Classic.cpp | 6 +++--- .../Core/Core/HW/WiimoteEmu/Attachment/Drums.cpp | 6 +++--- .../Core/HW/WiimoteEmu/Attachment/Guitar.cpp | 12 ++++++------ .../Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp | 10 +++++----- .../Core/HW/WiimoteEmu/Attachment/Turntable.cpp | 14 ++++++++------ Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp | 12 ++++++------ Source/Core/Core/HotkeyManager.cpp | 2 +- .../DolphinQt2/Config/Mapping/MappingBool.cpp | 2 +- .../DolphinQt2/Config/Mapping/MappingWidget.cpp | 6 ++++-- Source/Core/DolphinWX/Input/InputConfigDiag.cpp | 6 ++++-- .../ControllerEmu/Control/Control.cpp | 8 ++++---- .../InputCommon/ControllerEmu/Control/Control.h | 5 +++-- .../InputCommon/ControllerEmu/Control/Input.cpp | 7 ++++--- .../InputCommon/ControllerEmu/Control/Input.h | 4 ++-- .../InputCommon/ControllerEmu/Control/Output.cpp | 3 ++- .../InputCommon/ControllerEmu/Control/Output.h | 2 +- .../ControllerEmu/ControlGroup/AnalogStick.cpp | 4 ++-- .../ControllerEmu/ControlGroup/Cursor.cpp | 10 +++++----- .../ControllerEmu/ControlGroup/Force.cpp | 12 ++++++------ .../ControlGroup/ModifySettingsButton.cpp | 2 +- .../ControllerEmu/ControlGroup/Slider.cpp | 4 ++-- .../ControllerEmu/ControlGroup/Tilt.cpp | 10 +++++----- .../InputCommon/ControllerEmu/ControllerEmu.h | 4 +++- 25 files changed, 95 insertions(+), 84 deletions(-) diff --git a/Source/Core/Core/HW/GCKeyboardEmu.cpp b/Source/Core/Core/HW/GCKeyboardEmu.cpp index 6072d4322b..cca4bc8a7a 100644 --- a/Source/Core/Core/HW/GCKeyboardEmu.cpp +++ b/Source/Core/Core/HW/GCKeyboardEmu.cpp @@ -56,27 +56,27 @@ GCKeyboard::GCKeyboard(const unsigned int index) : m_index(index) // buttons groups.emplace_back(m_keys0x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys0) - m_keys0x->controls.emplace_back(new ControllerEmu::Input(key)); + m_keys0x->controls.emplace_back(new ControllerEmu::Input(false, key)); groups.emplace_back(m_keys1x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys1) - m_keys1x->controls.emplace_back(new ControllerEmu::Input(key)); + m_keys1x->controls.emplace_back(new ControllerEmu::Input(false, key)); groups.emplace_back(m_keys2x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys2) - m_keys2x->controls.emplace_back(new ControllerEmu::Input(key)); + m_keys2x->controls.emplace_back(new ControllerEmu::Input(false, key)); groups.emplace_back(m_keys3x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys3) - m_keys3x->controls.emplace_back(new ControllerEmu::Input(key)); + m_keys3x->controls.emplace_back(new ControllerEmu::Input(false, key)); groups.emplace_back(m_keys4x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys4) - m_keys4x->controls.emplace_back(new ControllerEmu::Input(key)); + m_keys4x->controls.emplace_back(new ControllerEmu::Input(false, key)); groups.emplace_back(m_keys5x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys5) - m_keys5x->controls.emplace_back(new ControllerEmu::Input(key)); + m_keys5x->controls.emplace_back(new ControllerEmu::Input(false, key)); // options groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options"))); diff --git a/Source/Core/Core/HW/GCPadEmu.cpp b/Source/Core/Core/HW/GCPadEmu.cpp index 5a2ee3a018..412dfc8225 100644 --- a/Source/Core/Core/HW/GCPadEmu.cpp +++ b/Source/Core/Core/HW/GCPadEmu.cpp @@ -52,10 +52,10 @@ GCPad::GCPad(const unsigned int index) : m_index(index) groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); for (const char* named_button : named_buttons) { - const std::string& ui_name = - // i18n: The START/PAUSE button on GameCube controllers - (named_button == std::string("Start")) ? _trans("START") : named_button; - m_buttons->controls.emplace_back(new ControllerEmu::Input(named_button, ui_name)); + const bool is_start = named_button == std::string("Start"); + // i18n: The START/PAUSE button on GameCube controllers + const std::string& ui_name = is_start ? _trans("START") : named_button; + m_buttons->controls.emplace_back(new ControllerEmu::Input(is_start, named_button, ui_name)); } // sticks @@ -67,20 +67,20 @@ GCPad::GCPad(const unsigned int index) : m_index(index) // triggers groups.emplace_back(m_triggers = new ControllerEmu::MixedTriggers(_trans("Triggers"))); for (const char* named_trigger : named_triggers) - m_triggers->controls.emplace_back(new ControllerEmu::Input(named_trigger)); + m_triggers->controls.emplace_back(new ControllerEmu::Input(true, named_trigger)); // rumble groups.emplace_back(m_rumble = new ControllerEmu::ControlGroup(_trans("Rumble"))); - m_rumble->controls.emplace_back(new ControllerEmu::Output(_trans("Motor"))); + m_rumble->controls.emplace_back(new ControllerEmu::Output(true, _trans("Motor"))); // Microphone groups.emplace_back(m_mic = new ControllerEmu::Buttons(_trans("Microphone"))); - m_mic->controls.emplace_back(new ControllerEmu::Input(_trans("Button"))); + m_mic->controls.emplace_back(new ControllerEmu::Input(true, _trans("Button"))); // dpad groups.emplace_back(m_dpad = new ControllerEmu::Buttons(_trans("D-Pad"))); for (const char* named_direction : named_directions) - m_dpad->controls.emplace_back(new ControllerEmu::Input(named_direction)); + m_dpad->controls.emplace_back(new ControllerEmu::Input(true, named_direction)); // options groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options"))); diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.cpp index 840d9192fc..c473116029 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.cpp @@ -98,7 +98,7 @@ Classic::Classic(ExtensionReg& reg) : Attachment(_trans("Classic"), reg) for (const char* button_name : classic_button_names) { const std::string& ui_name = (button_name == std::string("Home")) ? "HOME" : button_name; - m_buttons->controls.emplace_back(new ControllerEmu::Input(button_name, ui_name)); + m_buttons->controls.emplace_back(new ControllerEmu::Input(false, button_name, ui_name)); } // sticks @@ -110,12 +110,12 @@ Classic::Classic(ExtensionReg& reg) : Attachment(_trans("Classic"), reg) // triggers groups.emplace_back(m_triggers = new ControllerEmu::MixedTriggers(_trans("Triggers"))); for (const char* trigger_name : classic_trigger_names) - m_triggers->controls.emplace_back(new ControllerEmu::Input(trigger_name)); + m_triggers->controls.emplace_back(new ControllerEmu::Input(true, trigger_name)); // dpad groups.emplace_back(m_dpad = new ControllerEmu::Buttons(_trans("D-Pad"))); for (const char* named_direction : named_directions) - m_dpad->controls.emplace_back(new ControllerEmu::Input(named_direction)); + m_dpad->controls.emplace_back(new ControllerEmu::Input(true, named_direction)); // Set up register m_calibration = classic_calibration; diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Drums.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Drums.cpp index bae2e750cd..669fa803c5 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Drums.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Drums.cpp @@ -47,7 +47,7 @@ Drums::Drums(ExtensionReg& reg) : Attachment(_trans("Drums"), reg) // pads groups.emplace_back(m_pads = new ControllerEmu::Buttons(_trans("Pads"))); for (auto& drum_pad_name : drum_pad_names) - m_pads->controls.emplace_back(new ControllerEmu::Input(drum_pad_name)); + m_pads->controls.emplace_back(new ControllerEmu::Input(true, drum_pad_name)); // stick groups.emplace_back( @@ -55,8 +55,8 @@ Drums::Drums(ExtensionReg& reg) : Attachment(_trans("Drums"), reg) // buttons groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); - m_buttons->controls.emplace_back(new ControllerEmu::Input("-")); - m_buttons->controls.emplace_back(new ControllerEmu::Input("+")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "-")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "+")); // set up register m_id = drums_id; diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp index 125ae12038..271d4a7678 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp @@ -66,17 +66,17 @@ Guitar::Guitar(ExtensionReg& reg) : Attachment(_trans("Guitar"), reg) // frets groups.emplace_back(m_frets = new ControllerEmu::Buttons(_trans("Frets"))); for (auto& guitar_fret_name : guitar_fret_names) - m_frets->controls.emplace_back(new ControllerEmu::Input(guitar_fret_name)); + m_frets->controls.emplace_back(new ControllerEmu::Input(true, guitar_fret_name)); // strum groups.emplace_back(m_strum = new ControllerEmu::Buttons(_trans("Strum"))); - m_strum->controls.emplace_back(new ControllerEmu::Input(_trans("Up"))); - m_strum->controls.emplace_back(new ControllerEmu::Input(_trans("Down"))); + m_strum->controls.emplace_back(new ControllerEmu::Input(true, _trans("Up"))); + m_strum->controls.emplace_back(new ControllerEmu::Input(true, _trans("Down"))); // buttons groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); - m_buttons->controls.emplace_back(new ControllerEmu::Input("-")); - m_buttons->controls.emplace_back(new ControllerEmu::Input("+")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "-")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "+")); // stick groups.emplace_back( @@ -84,7 +84,7 @@ Guitar::Guitar(ExtensionReg& reg) : Attachment(_trans("Guitar"), reg) // whammy groups.emplace_back(m_whammy = new ControllerEmu::Triggers(_trans("Whammy"))); - m_whammy->controls.emplace_back(new ControllerEmu::Input(_trans("Bar"))); + m_whammy->controls.emplace_back(new ControllerEmu::Input(true, _trans("Bar"))); // slider bar groups.emplace_back(m_slider_bar = new ControllerEmu::Slider(_trans("Slider Bar"))); diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp index 0197c72708..1a2bbe59ec 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp @@ -32,8 +32,8 @@ Nunchuk::Nunchuk(ExtensionReg& reg) : Attachment(_trans("Nunchuk"), reg) { // buttons groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); - m_buttons->controls.emplace_back(new ControllerEmu::Input("C")); - m_buttons->controls.emplace_back(new ControllerEmu::Input("Z")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "C")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "Z")); // stick groups.emplace_back( @@ -48,11 +48,11 @@ Nunchuk::Nunchuk(ExtensionReg& reg) : Attachment(_trans("Nunchuk"), reg) // shake groups.emplace_back(m_shake = new ControllerEmu::Buttons(_trans("Shake"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(_trans("X"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("X"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(_trans("Y"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("Y"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(_trans("Z"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("Z"))); m_id = nunchuk_id; } diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Turntable.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Turntable.cpp index 2889c5a09a..e0155d69ec 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Turntable.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Turntable.cpp @@ -41,10 +41,6 @@ constexpr std::array turntable_button_names{{ _trans("Green Right"), _trans("Red Right"), _trans("Blue Right"), - "-", - "+", - // i18n: This button name refers to a gameplay element in DJ Hero - _trans("Euphoria"), }}; Turntable::Turntable(ExtensionReg& reg) : Attachment(_trans("Turntable"), reg) @@ -52,7 +48,13 @@ Turntable::Turntable(ExtensionReg& reg) : Attachment(_trans("Turntable"), reg) // buttons groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); for (auto& turntable_button_name : turntable_button_names) - m_buttons->controls.emplace_back(new ControllerEmu::Input(turntable_button_name)); + m_buttons->controls.emplace_back(new ControllerEmu::Input(true, turntable_button_name)); + + m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "-")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "+")); + + // i18n: This button name refers to a gameplay element in DJ Hero + m_buttons->controls.emplace_back(new ControllerEmu::Input(true, _trans("Euphoria"))); // turntables // i18n: "Table" refers to a turntable @@ -67,7 +69,7 @@ Turntable::Turntable(ExtensionReg& reg) : Attachment(_trans("Turntable"), reg) // effect dial groups.emplace_back(m_effect_dial = new ControllerEmu::Triggers(_trans("Effect"))); - m_effect_dial->controls.emplace_back(new ControllerEmu::Input(_trans("Dial"))); + m_effect_dial->controls.emplace_back(new ControllerEmu::Input(true, _trans("Dial"))); // crossfade groups.emplace_back(m_crossfade = new ControllerEmu::Slider(_trans("Crossfade"))); diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index ba74e007e2..59bce81c77 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -261,7 +261,7 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index), ir_sin(0), ir_cos(1 for (const char* named_button : named_buttons) { const std::string& ui_name = (named_button == std::string("Home")) ? "HOME" : named_button; - m_buttons->controls.emplace_back(new ControllerEmu::Input(named_button, ui_name)); + m_buttons->controls.emplace_back(new ControllerEmu::Input(false, named_button, ui_name)); } // ir @@ -277,11 +277,11 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index), ir_sin(0), ir_cos(1 // shake groups.emplace_back(m_shake = new ControllerEmu::Buttons(_trans("Shake"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(_trans("X"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("X"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(_trans("Y"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("Y"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(_trans("Z"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("Z"))); // extension groups.emplace_back(m_extension = new ControllerEmu::Extension(_trans("Extension"))); @@ -294,12 +294,12 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index), ir_sin(0), ir_cos(1 // rumble groups.emplace_back(m_rumble = new ControllerEmu::ControlGroup(_trans("Rumble"))); - m_rumble->controls.emplace_back(m_motor = new ControllerEmu::Output(_trans("Motor"))); + m_rumble->controls.emplace_back(m_motor = new ControllerEmu::Output(true, _trans("Motor"))); // dpad groups.emplace_back(m_dpad = new ControllerEmu::Buttons(_trans("D-Pad"))); for (const char* named_direction : named_directions) - m_dpad->controls.emplace_back(new ControllerEmu::Input(named_direction)); + m_dpad->controls.emplace_back(new ControllerEmu::Input(true, named_direction)); // options groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options"))); diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index ecaeb58369..78bb12beaa 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -270,7 +270,7 @@ HotkeyManager::HotkeyManager() groups.emplace_back(m_hotkey_groups[group]); for (int key = groups_info[group].first; key <= groups_info[group].last; key++) { - m_keys[group]->controls.emplace_back(new ControllerEmu::Input(hotkey_labels[key])); + m_keys[group]->controls.emplace_back(new ControllerEmu::Input(true, hotkey_labels[key])); } } } diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingBool.cpp b/Source/Core/DolphinQt2/Config/Mapping/MappingBool.cpp index 1c35a53910..31529a8887 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingBool.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingBool.cpp @@ -8,7 +8,7 @@ #include "InputCommon/ControllerEmu/Setting/BooleanSetting.h" MappingBool::MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting) - : QCheckBox(QString::fromStdString(setting->m_ui_name)), m_parent(widget), m_setting(setting) + : QCheckBox(tr(setting->m_ui_name.c_str())), m_parent(widget), m_setting(setting) { Update(); Connect(); diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingWidget.cpp b/Source/Core/DolphinQt2/Config/Mapping/MappingWidget.cpp index 01913ca8c7..ab8e2444e0 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingWidget.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingWidget.cpp @@ -82,7 +82,9 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con button->setMinimumWidth(100); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - form_layout->addRow(QString::fromStdString(control->name), button); + const QString translated_name = control->translate ? tr(control->ui_name.c_str()) : + QString::fromStdString(control->ui_name); + form_layout->addRow(translated_name, button); auto* control_ref = control->control_ref.get(); @@ -103,7 +105,7 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con for (auto& numeric : group->numeric_settings) { auto* spinbox = new MappingNumeric(this, numeric.get()); - form_layout->addRow(QString::fromStdString(numeric->m_name), spinbox); + form_layout->addRow(tr(numeric->m_name.c_str()), spinbox); m_numerics.push_back(spinbox); } diff --git a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp index 99307a650c..14c90709b3 100644 --- a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp @@ -964,8 +964,10 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin control_grid->AddGrowableCol(0); for (const auto& control : group->controls) { - wxStaticText* const label = - new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(control->ui_name))); + const wxString control_ui_name = StrToWxStr(control->ui_name); + + wxStaticText* const label = new wxStaticText( + parent, wxID_ANY, control->translate ? wxGetTranslation(control_ui_name) : control_ui_name); ControlButton* const control_button = new ControlButton(parent, control->control_ref.get(), control->ui_name, 80); diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp b/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp index 3f5d00d822..7ea3ec27d5 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp +++ b/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp @@ -9,14 +9,14 @@ namespace ControllerEmu { -Control::Control(std::unique_ptr ref, const std::string& name_, +Control::Control(std::unique_ptr ref, bool translate_, const std::string& name_, const std::string& ui_name_) - : control_ref(std::move(ref)), name(name_), ui_name(ui_name_) + : control_ref(std::move(ref)), translate(translate_), name(name_), ui_name(ui_name_) { } -Control::Control(std::unique_ptr ref, const std::string& name_) - : Control(std::move(ref), name_, name_) +Control::Control(std::unique_ptr ref, bool translate_, const std::string& name_) + : Control(std::move(ref), translate_, name_, name_) { } diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Control.h b/Source/Core/InputCommon/ControllerEmu/Control/Control.h index b34c843c5d..f5c2e394ea 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Control.h +++ b/Source/Core/InputCommon/ControllerEmu/Control/Control.h @@ -17,12 +17,13 @@ public: virtual ~Control(); std::unique_ptr const control_ref; + const bool translate; const std::string name; const std::string ui_name; protected: - Control(std::unique_ptr ref, const std::string& name, + Control(std::unique_ptr ref, bool translate, const std::string& name, const std::string& ui_name); - Control(std::unique_ptr ref, const std::string& name); + Control(std::unique_ptr ref, bool translate, const std::string& name); }; } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp b/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp index a213916a83..ca872b5cbd 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp +++ b/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp @@ -10,12 +10,13 @@ namespace ControllerEmu { -Input::Input(const std::string& name_, const std::string& ui_name_) - : Control(std::make_unique(), name_, ui_name_) +Input::Input(bool translate_, const std::string& name_, const std::string& ui_name_) + : Control(std::make_unique(), translate_, name_, ui_name_) { } -Input::Input(const std::string& name_) : Control(std::make_unique(), name_) +Input::Input(bool translate_, const std::string& name_) + : Control(std::make_unique(), translate_, name_) { } } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Input.h b/Source/Core/InputCommon/ControllerEmu/Control/Input.h index dad90ed12e..1782249026 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Input.h +++ b/Source/Core/InputCommon/ControllerEmu/Control/Input.h @@ -12,7 +12,7 @@ namespace ControllerEmu class Input : public Control { public: - Input(const std::string& name, const std::string& ui_name); - explicit Input(const std::string& name); + Input(bool translate, const std::string& name, const std::string& ui_name); + Input(bool translate, const std::string& name); }; } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp b/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp index a031893410..9089b15b7f 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp +++ b/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp @@ -10,7 +10,8 @@ namespace ControllerEmu { -Output::Output(const std::string& name_) : Control(std::make_unique(), name_) +Output::Output(bool translate, const std::string& name_) + : Control(std::make_unique(), translate, name_) { } } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Output.h b/Source/Core/InputCommon/ControllerEmu/Control/Output.h index 415c67f7d9..74aa85e165 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Output.h +++ b/Source/Core/InputCommon/ControllerEmu/Control/Output.h @@ -12,6 +12,6 @@ namespace ControllerEmu class Output : public Control { public: - explicit Output(const std::string& name); + Output(bool translate, const std::string& name); }; } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp index 2b7430dcbf..9ca3a70eb2 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp @@ -28,9 +28,9 @@ AnalogStick::AnalogStick(const char* const name_, const char* const ui_name_, : ControlGroup(name_, ui_name_, GroupType::Stick) { for (auto& named_direction : named_directions) - controls.emplace_back(std::make_unique(named_direction)); + controls.emplace_back(std::make_unique(true, named_direction)); - controls.emplace_back(std::make_unique(_trans("Modifier"))); + controls.emplace_back(std::make_unique(true, _trans("Modifier"))); numeric_settings.emplace_back( std::make_unique(_trans("Radius"), default_radius, 0, 100)); numeric_settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp index 3467205ccf..2ee8e146f4 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp @@ -24,12 +24,12 @@ namespace ControllerEmu Cursor::Cursor(const std::string& name_) : ControlGroup(name_, GroupType::Cursor) { for (auto& named_direction : named_directions) - controls.emplace_back(std::make_unique(named_direction)); + controls.emplace_back(std::make_unique(true, named_direction)); - controls.emplace_back(std::make_unique(_trans("Forward"))); - controls.emplace_back(std::make_unique(_trans("Backward"))); - controls.emplace_back(std::make_unique(_trans("Hide"))); - controls.emplace_back(std::make_unique(_trans("Recenter"))); + controls.emplace_back(std::make_unique(true, _trans("Forward"))); + controls.emplace_back(std::make_unique(true, _trans("Backward"))); + controls.emplace_back(std::make_unique(true, _trans("Hide"))); + controls.emplace_back(std::make_unique(true, _trans("Recenter"))); numeric_settings.emplace_back(std::make_unique(_trans("Center"), 0.5)); numeric_settings.emplace_back(std::make_unique(_trans("Width"), 0.5)); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp index a825ce51c9..c620bd787a 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp @@ -19,12 +19,12 @@ namespace ControllerEmu { Force::Force(const std::string& name_) : ControlGroup(name_, GroupType::Force) { - controls.emplace_back(std::make_unique(_trans("Up"))); - controls.emplace_back(std::make_unique(_trans("Down"))); - controls.emplace_back(std::make_unique(_trans("Left"))); - controls.emplace_back(std::make_unique(_trans("Right"))); - controls.emplace_back(std::make_unique(_trans("Forward"))); - controls.emplace_back(std::make_unique(_trans("Backward"))); + controls.emplace_back(std::make_unique(true, _trans("Up"))); + controls.emplace_back(std::make_unique(true, _trans("Down"))); + controls.emplace_back(std::make_unique(true, _trans("Left"))); + controls.emplace_back(std::make_unique(true, _trans("Right"))); + controls.emplace_back(std::make_unique(true, _trans("Forward"))); + controls.emplace_back(std::make_unique(true, _trans("Backward"))); numeric_settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); } diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp index a534b7904f..943a0bae85 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp @@ -27,7 +27,7 @@ ModifySettingsButton::ModifySettingsButton(std::string button_name) void ModifySettingsButton::AddInput(std::string button_name, bool toggle) { - controls.emplace_back(new Input(std::move(button_name))); + controls.emplace_back(std::make_unique(true, std::move(button_name))); threshold_exceeded.emplace_back(false); associated_settings.emplace_back(false); associated_settings_toggle.emplace_back(toggle); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp index b5e7ff5a1a..f04508e011 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp @@ -20,8 +20,8 @@ namespace ControllerEmu Slider::Slider(const std::string& name_, const std::string& ui_name_) : ControlGroup(name_, ui_name_, GroupType::Slider) { - controls.emplace_back(std::make_unique("Left")); - controls.emplace_back(std::make_unique("Right")); + controls.emplace_back(std::make_unique(true, _trans("Left"))); + controls.emplace_back(std::make_unique(true, _trans("Right"))); numeric_settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); } diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp index 72bc258976..94d3538685 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp @@ -19,12 +19,12 @@ namespace ControllerEmu { Tilt::Tilt(const std::string& name_) : ControlGroup(name_, GroupType::Tilt) { - controls.emplace_back(std::make_unique(_trans("Forward"))); - controls.emplace_back(std::make_unique(_trans("Backward"))); - controls.emplace_back(std::make_unique(_trans("Left"))); - controls.emplace_back(std::make_unique(_trans("Right"))); + controls.emplace_back(std::make_unique(true, _trans("Forward"))); + controls.emplace_back(std::make_unique(true, _trans("Backward"))); + controls.emplace_back(std::make_unique(true, _trans("Left"))); + controls.emplace_back(std::make_unique(true, _trans("Right"))); - controls.emplace_back(std::make_unique(_trans("Modifier"))); + controls.emplace_back(std::make_unique(true, _trans("Modifier"))); numeric_settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); numeric_settings.emplace_back(std::make_unique(_trans("Circle Stick"), 0)); diff --git a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h index 8b7925f7df..4f734e2824 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h +++ b/Source/Core/InputCommon/ControllerEmu/ControllerEmu.h @@ -9,6 +9,7 @@ #include #include +#include "Common/Common.h" #include "Common/IniFile.h" #include "InputCommon/ControllerInterface/Device.h" @@ -16,7 +17,8 @@ class ControllerInterface; #define sign(x) ((x) ? (x) < 0 ? -1 : 1 : 0) -const char* const named_directions[] = {"Up", "Down", "Left", "Right"}; +const char* const named_directions[] = {_trans("Up"), _trans("Down"), _trans("Left"), + _trans("Right")}; namespace ControllerEmu { From 7ed28297b237779f0e4b6d7045cd27e10a8cfb0e Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 10 Apr 2018 17:22:30 +0200 Subject: [PATCH 2/2] ControllerEmu: Use enum instead of bool for translatability --- Source/Core/Core/HW/GCKeyboardEmu.cpp | 12 +++++------ Source/Core/Core/HW/GCPadEmu.cpp | 20 ++++++++++++++----- .../Core/HW/WiimoteEmu/Attachment/Classic.cpp | 13 +++++++++--- .../Core/HW/WiimoteEmu/Attachment/Drums.cpp | 9 ++++++--- .../Core/HW/WiimoteEmu/Attachment/Guitar.cpp | 17 ++++++++++------ .../Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp | 10 +++++----- .../HW/WiimoteEmu/Attachment/Turntable.cpp | 15 +++++++++----- Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp | 17 ++++++++++------ Source/Core/Core/HotkeyManager.cpp | 3 ++- .../Config/Mapping/MappingWidget.cpp | 5 +++-- .../Core/DolphinWX/Input/InputConfigDiag.cpp | 3 ++- .../ControllerEmu/Control/Control.cpp | 7 ++++--- .../ControllerEmu/Control/Control.h | 13 +++++++++--- .../ControllerEmu/Control/Input.cpp | 4 ++-- .../InputCommon/ControllerEmu/Control/Input.h | 4 ++-- .../ControllerEmu/Control/Output.cpp | 4 ++-- .../ControllerEmu/Control/Output.h | 2 +- .../ControlGroup/AnalogStick.cpp | 4 ++-- .../ControllerEmu/ControlGroup/Cursor.cpp | 10 +++++----- .../ControllerEmu/ControlGroup/Force.cpp | 12 +++++------ .../ControlGroup/ModifySettingsButton.cpp | 2 +- .../ControllerEmu/ControlGroup/Slider.cpp | 4 ++-- .../ControllerEmu/ControlGroup/Tilt.cpp | 10 +++++----- 23 files changed, 123 insertions(+), 77 deletions(-) diff --git a/Source/Core/Core/HW/GCKeyboardEmu.cpp b/Source/Core/Core/HW/GCKeyboardEmu.cpp index cca4bc8a7a..952036ae5a 100644 --- a/Source/Core/Core/HW/GCKeyboardEmu.cpp +++ b/Source/Core/Core/HW/GCKeyboardEmu.cpp @@ -56,27 +56,27 @@ GCKeyboard::GCKeyboard(const unsigned int index) : m_index(index) // buttons groups.emplace_back(m_keys0x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys0) - m_keys0x->controls.emplace_back(new ControllerEmu::Input(false, key)); + m_keys0x->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, key)); groups.emplace_back(m_keys1x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys1) - m_keys1x->controls.emplace_back(new ControllerEmu::Input(false, key)); + m_keys1x->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, key)); groups.emplace_back(m_keys2x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys2) - m_keys2x->controls.emplace_back(new ControllerEmu::Input(false, key)); + m_keys2x->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, key)); groups.emplace_back(m_keys3x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys3) - m_keys3x->controls.emplace_back(new ControllerEmu::Input(false, key)); + m_keys3x->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, key)); groups.emplace_back(m_keys4x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys4) - m_keys4x->controls.emplace_back(new ControllerEmu::Input(false, key)); + m_keys4x->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, key)); groups.emplace_back(m_keys5x = new ControllerEmu::Buttons(_trans("Keys"))); for (const char* key : named_keys5) - m_keys5x->controls.emplace_back(new ControllerEmu::Input(false, key)); + m_keys5x->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, key)); // options groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options"))); diff --git a/Source/Core/Core/HW/GCPadEmu.cpp b/Source/Core/Core/HW/GCPadEmu.cpp index 412dfc8225..6a97931fc3 100644 --- a/Source/Core/Core/HW/GCPadEmu.cpp +++ b/Source/Core/Core/HW/GCPadEmu.cpp @@ -53,9 +53,11 @@ GCPad::GCPad(const unsigned int index) : m_index(index) for (const char* named_button : named_buttons) { const bool is_start = named_button == std::string("Start"); + const ControllerEmu::Translatability translate = + is_start ? ControllerEmu::Translate : ControllerEmu::DoNotTranslate; // i18n: The START/PAUSE button on GameCube controllers const std::string& ui_name = is_start ? _trans("START") : named_button; - m_buttons->controls.emplace_back(new ControllerEmu::Input(is_start, named_button, ui_name)); + m_buttons->controls.emplace_back(new ControllerEmu::Input(translate, named_button, ui_name)); } // sticks @@ -67,20 +69,28 @@ GCPad::GCPad(const unsigned int index) : m_index(index) // triggers groups.emplace_back(m_triggers = new ControllerEmu::MixedTriggers(_trans("Triggers"))); for (const char* named_trigger : named_triggers) - m_triggers->controls.emplace_back(new ControllerEmu::Input(true, named_trigger)); + { + m_triggers->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, named_trigger)); + } // rumble groups.emplace_back(m_rumble = new ControllerEmu::ControlGroup(_trans("Rumble"))); - m_rumble->controls.emplace_back(new ControllerEmu::Output(true, _trans("Motor"))); + m_rumble->controls.emplace_back( + new ControllerEmu::Output(ControllerEmu::Translate, _trans("Motor"))); // Microphone groups.emplace_back(m_mic = new ControllerEmu::Buttons(_trans("Microphone"))); - m_mic->controls.emplace_back(new ControllerEmu::Input(true, _trans("Button"))); + m_mic->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, _trans("Button"))); // dpad groups.emplace_back(m_dpad = new ControllerEmu::Buttons(_trans("D-Pad"))); for (const char* named_direction : named_directions) - m_dpad->controls.emplace_back(new ControllerEmu::Input(true, named_direction)); + { + m_dpad->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, named_direction)); + } // options groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options"))); diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.cpp index c473116029..1646048813 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Classic.cpp @@ -98,7 +98,8 @@ Classic::Classic(ExtensionReg& reg) : Attachment(_trans("Classic"), reg) for (const char* button_name : classic_button_names) { const std::string& ui_name = (button_name == std::string("Home")) ? "HOME" : button_name; - m_buttons->controls.emplace_back(new ControllerEmu::Input(false, button_name, ui_name)); + m_buttons->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::DoNotTranslate, button_name, ui_name)); } // sticks @@ -110,12 +111,18 @@ Classic::Classic(ExtensionReg& reg) : Attachment(_trans("Classic"), reg) // triggers groups.emplace_back(m_triggers = new ControllerEmu::MixedTriggers(_trans("Triggers"))); for (const char* trigger_name : classic_trigger_names) - m_triggers->controls.emplace_back(new ControllerEmu::Input(true, trigger_name)); + { + m_triggers->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, trigger_name)); + } // dpad groups.emplace_back(m_dpad = new ControllerEmu::Buttons(_trans("D-Pad"))); for (const char* named_direction : named_directions) - m_dpad->controls.emplace_back(new ControllerEmu::Input(true, named_direction)); + { + m_dpad->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, named_direction)); + } // Set up register m_calibration = classic_calibration; diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Drums.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Drums.cpp index 669fa803c5..83a9435d99 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Drums.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Drums.cpp @@ -47,7 +47,10 @@ Drums::Drums(ExtensionReg& reg) : Attachment(_trans("Drums"), reg) // pads groups.emplace_back(m_pads = new ControllerEmu::Buttons(_trans("Pads"))); for (auto& drum_pad_name : drum_pad_names) - m_pads->controls.emplace_back(new ControllerEmu::Input(true, drum_pad_name)); + { + m_pads->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, drum_pad_name)); + } // stick groups.emplace_back( @@ -55,8 +58,8 @@ Drums::Drums(ExtensionReg& reg) : Attachment(_trans("Drums"), reg) // buttons groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); - m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "-")); - m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "+")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "-")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "+")); // set up register m_id = drums_id; diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp index 271d4a7678..cbac1b74a6 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Guitar.cpp @@ -66,17 +66,21 @@ Guitar::Guitar(ExtensionReg& reg) : Attachment(_trans("Guitar"), reg) // frets groups.emplace_back(m_frets = new ControllerEmu::Buttons(_trans("Frets"))); for (auto& guitar_fret_name : guitar_fret_names) - m_frets->controls.emplace_back(new ControllerEmu::Input(true, guitar_fret_name)); + { + m_frets->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, guitar_fret_name)); + } // strum groups.emplace_back(m_strum = new ControllerEmu::Buttons(_trans("Strum"))); - m_strum->controls.emplace_back(new ControllerEmu::Input(true, _trans("Up"))); - m_strum->controls.emplace_back(new ControllerEmu::Input(true, _trans("Down"))); + m_strum->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("Up"))); + m_strum->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, _trans("Down"))); // buttons groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); - m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "-")); - m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "+")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "-")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "+")); // stick groups.emplace_back( @@ -84,7 +88,8 @@ Guitar::Guitar(ExtensionReg& reg) : Attachment(_trans("Guitar"), reg) // whammy groups.emplace_back(m_whammy = new ControllerEmu::Triggers(_trans("Whammy"))); - m_whammy->controls.emplace_back(new ControllerEmu::Input(true, _trans("Bar"))); + m_whammy->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, _trans("Bar"))); // slider bar groups.emplace_back(m_slider_bar = new ControllerEmu::Slider(_trans("Slider Bar"))); diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp index 1a2bbe59ec..7a2ac4ef7e 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Nunchuk.cpp @@ -32,8 +32,8 @@ Nunchuk::Nunchuk(ExtensionReg& reg) : Attachment(_trans("Nunchuk"), reg) { // buttons groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); - m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "C")); - m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "Z")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "C")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "Z")); // stick groups.emplace_back( @@ -48,11 +48,11 @@ Nunchuk::Nunchuk(ExtensionReg& reg) : Attachment(_trans("Nunchuk"), reg) // shake groups.emplace_back(m_shake = new ControllerEmu::Buttons(_trans("Shake"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("X"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("X"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("Y"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("Y"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("Z"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("Z"))); m_id = nunchuk_id; } diff --git a/Source/Core/Core/HW/WiimoteEmu/Attachment/Turntable.cpp b/Source/Core/Core/HW/WiimoteEmu/Attachment/Turntable.cpp index e0155d69ec..f1af564152 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Attachment/Turntable.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Attachment/Turntable.cpp @@ -48,13 +48,17 @@ Turntable::Turntable(ExtensionReg& reg) : Attachment(_trans("Turntable"), reg) // buttons groups.emplace_back(m_buttons = new ControllerEmu::Buttons(_trans("Buttons"))); for (auto& turntable_button_name : turntable_button_names) - m_buttons->controls.emplace_back(new ControllerEmu::Input(true, turntable_button_name)); + { + m_buttons->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, turntable_button_name)); + } - m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "-")); - m_buttons->controls.emplace_back(new ControllerEmu::Input(false, "+")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "-")); + m_buttons->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::DoNotTranslate, "+")); // i18n: This button name refers to a gameplay element in DJ Hero - m_buttons->controls.emplace_back(new ControllerEmu::Input(true, _trans("Euphoria"))); + m_buttons->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, _trans("Euphoria"))); // turntables // i18n: "Table" refers to a turntable @@ -69,7 +73,8 @@ Turntable::Turntable(ExtensionReg& reg) : Attachment(_trans("Turntable"), reg) // effect dial groups.emplace_back(m_effect_dial = new ControllerEmu::Triggers(_trans("Effect"))); - m_effect_dial->controls.emplace_back(new ControllerEmu::Input(true, _trans("Dial"))); + m_effect_dial->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, _trans("Dial"))); // crossfade groups.emplace_back(m_crossfade = new ControllerEmu::Slider(_trans("Crossfade"))); diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp index 59bce81c77..c4130ee15b 100644 --- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.cpp @@ -261,7 +261,8 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index), ir_sin(0), ir_cos(1 for (const char* named_button : named_buttons) { const std::string& ui_name = (named_button == std::string("Home")) ? "HOME" : named_button; - m_buttons->controls.emplace_back(new ControllerEmu::Input(false, named_button, ui_name)); + m_buttons->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::DoNotTranslate, named_button, ui_name)); } // ir @@ -277,11 +278,11 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index), ir_sin(0), ir_cos(1 // shake groups.emplace_back(m_shake = new ControllerEmu::Buttons(_trans("Shake"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("X"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("X"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("Y"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("Y"))); // i18n: Refers to a 3D axis (used when mapping motion controls) - m_shake->controls.emplace_back(new ControllerEmu::Input(true, _trans("Z"))); + m_shake->controls.emplace_back(new ControllerEmu::Input(ControllerEmu::Translate, _trans("Z"))); // extension groups.emplace_back(m_extension = new ControllerEmu::Extension(_trans("Extension"))); @@ -294,12 +295,16 @@ Wiimote::Wiimote(const unsigned int index) : m_index(index), ir_sin(0), ir_cos(1 // rumble groups.emplace_back(m_rumble = new ControllerEmu::ControlGroup(_trans("Rumble"))); - m_rumble->controls.emplace_back(m_motor = new ControllerEmu::Output(true, _trans("Motor"))); + m_rumble->controls.emplace_back( + m_motor = new ControllerEmu::Output(ControllerEmu::Translate, _trans("Motor"))); // dpad groups.emplace_back(m_dpad = new ControllerEmu::Buttons(_trans("D-Pad"))); for (const char* named_direction : named_directions) - m_dpad->controls.emplace_back(new ControllerEmu::Input(true, named_direction)); + { + m_dpad->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, named_direction)); + } // options groups.emplace_back(m_options = new ControllerEmu::ControlGroup(_trans("Options"))); diff --git a/Source/Core/Core/HotkeyManager.cpp b/Source/Core/Core/HotkeyManager.cpp index 78bb12beaa..67086b593c 100644 --- a/Source/Core/Core/HotkeyManager.cpp +++ b/Source/Core/Core/HotkeyManager.cpp @@ -270,7 +270,8 @@ HotkeyManager::HotkeyManager() groups.emplace_back(m_hotkey_groups[group]); for (int key = groups_info[group].first; key <= groups_info[group].last; key++) { - m_keys[group]->controls.emplace_back(new ControllerEmu::Input(true, hotkey_labels[key])); + m_keys[group]->controls.emplace_back( + new ControllerEmu::Input(ControllerEmu::Translate, hotkey_labels[key])); } } } diff --git a/Source/Core/DolphinQt2/Config/Mapping/MappingWidget.cpp b/Source/Core/DolphinQt2/Config/Mapping/MappingWidget.cpp index ab8e2444e0..7ec19c7a04 100644 --- a/Source/Core/DolphinQt2/Config/Mapping/MappingWidget.cpp +++ b/Source/Core/DolphinQt2/Config/Mapping/MappingWidget.cpp @@ -82,8 +82,9 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con button->setMinimumWidth(100); button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - const QString translated_name = control->translate ? tr(control->ui_name.c_str()) : - QString::fromStdString(control->ui_name); + const bool translate = control->translate == ControllerEmu::Translate; + const QString translated_name = + translate ? tr(control->ui_name.c_str()) : QString::fromStdString(control->ui_name); form_layout->addRow(translated_name, button); auto* control_ref = control->control_ref.get(); diff --git a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp index 14c90709b3..d31bcd6e7f 100644 --- a/Source/Core/DolphinWX/Input/InputConfigDiag.cpp +++ b/Source/Core/DolphinWX/Input/InputConfigDiag.cpp @@ -966,8 +966,9 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin { const wxString control_ui_name = StrToWxStr(control->ui_name); + const bool translate = control->translate == ControllerEmu::Translate; wxStaticText* const label = new wxStaticText( - parent, wxID_ANY, control->translate ? wxGetTranslation(control_ui_name) : control_ui_name); + parent, wxID_ANY, translate ? wxGetTranslation(control_ui_name) : control_ui_name); ControlButton* const control_button = new ControlButton(parent, control->control_ref.get(), control->ui_name, 80); diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp b/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp index 7ea3ec27d5..20ae3a3cda 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp +++ b/Source/Core/InputCommon/ControllerEmu/Control/Control.cpp @@ -9,13 +9,14 @@ namespace ControllerEmu { -Control::Control(std::unique_ptr ref, bool translate_, const std::string& name_, - const std::string& ui_name_) +Control::Control(std::unique_ptr ref, Translatability translate_, + const std::string& name_, const std::string& ui_name_) : control_ref(std::move(ref)), translate(translate_), name(name_), ui_name(ui_name_) { } -Control::Control(std::unique_ptr ref, bool translate_, const std::string& name_) +Control::Control(std::unique_ptr ref, Translatability translate_, + const std::string& name_) : Control(std::move(ref), translate_, name_, name_) { } diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Control.h b/Source/Core/InputCommon/ControllerEmu/Control/Control.h index f5c2e394ea..e005431873 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Control.h +++ b/Source/Core/InputCommon/ControllerEmu/Control/Control.h @@ -11,19 +11,26 @@ class ControlReference; namespace ControllerEmu { +enum Translatability +{ + DoNotTranslate, + Translate +}; + class Control { public: virtual ~Control(); std::unique_ptr const control_ref; - const bool translate; + const Translatability translate; const std::string name; const std::string ui_name; protected: - Control(std::unique_ptr ref, bool translate, const std::string& name, + Control(std::unique_ptr ref, Translatability translate, const std::string& name, const std::string& ui_name); - Control(std::unique_ptr ref, bool translate, const std::string& name); + Control(std::unique_ptr ref, Translatability translate, + const std::string& name); }; } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp b/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp index ca872b5cbd..69f817705e 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp +++ b/Source/Core/InputCommon/ControllerEmu/Control/Input.cpp @@ -10,12 +10,12 @@ namespace ControllerEmu { -Input::Input(bool translate_, const std::string& name_, const std::string& ui_name_) +Input::Input(Translatability translate_, const std::string& name_, const std::string& ui_name_) : Control(std::make_unique(), translate_, name_, ui_name_) { } -Input::Input(bool translate_, const std::string& name_) +Input::Input(Translatability translate_, const std::string& name_) : Control(std::make_unique(), translate_, name_) { } diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Input.h b/Source/Core/InputCommon/ControllerEmu/Control/Input.h index 1782249026..3fd301ae65 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Input.h +++ b/Source/Core/InputCommon/ControllerEmu/Control/Input.h @@ -12,7 +12,7 @@ namespace ControllerEmu class Input : public Control { public: - Input(bool translate, const std::string& name, const std::string& ui_name); - Input(bool translate, const std::string& name); + Input(Translatability translate, const std::string& name, const std::string& ui_name); + Input(Translatability translate, const std::string& name); }; } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp b/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp index 9089b15b7f..568035d106 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp +++ b/Source/Core/InputCommon/ControllerEmu/Control/Output.cpp @@ -10,8 +10,8 @@ namespace ControllerEmu { -Output::Output(bool translate, const std::string& name_) - : Control(std::make_unique(), translate, name_) +Output::Output(Translatability translate_, const std::string& name_) + : Control(std::make_unique(), translate_, name_) { } } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/Control/Output.h b/Source/Core/InputCommon/ControllerEmu/Control/Output.h index 74aa85e165..7970c26ad0 100644 --- a/Source/Core/InputCommon/ControllerEmu/Control/Output.h +++ b/Source/Core/InputCommon/ControllerEmu/Control/Output.h @@ -12,6 +12,6 @@ namespace ControllerEmu class Output : public Control { public: - Output(bool translate, const std::string& name); + Output(Translatability translate, const std::string& name); }; } // namespace ControllerEmu diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp index 9ca3a70eb2..3317da427c 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp @@ -28,9 +28,9 @@ AnalogStick::AnalogStick(const char* const name_, const char* const ui_name_, : ControlGroup(name_, ui_name_, GroupType::Stick) { for (auto& named_direction : named_directions) - controls.emplace_back(std::make_unique(true, named_direction)); + controls.emplace_back(std::make_unique(Translate, named_direction)); - controls.emplace_back(std::make_unique(true, _trans("Modifier"))); + controls.emplace_back(std::make_unique(Translate, _trans("Modifier"))); numeric_settings.emplace_back( std::make_unique(_trans("Radius"), default_radius, 0, 100)); numeric_settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp index 2ee8e146f4..a300a249f7 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Cursor.cpp @@ -24,12 +24,12 @@ namespace ControllerEmu Cursor::Cursor(const std::string& name_) : ControlGroup(name_, GroupType::Cursor) { for (auto& named_direction : named_directions) - controls.emplace_back(std::make_unique(true, named_direction)); + controls.emplace_back(std::make_unique(Translate, named_direction)); - controls.emplace_back(std::make_unique(true, _trans("Forward"))); - controls.emplace_back(std::make_unique(true, _trans("Backward"))); - controls.emplace_back(std::make_unique(true, _trans("Hide"))); - controls.emplace_back(std::make_unique(true, _trans("Recenter"))); + controls.emplace_back(std::make_unique(Translate, _trans("Forward"))); + controls.emplace_back(std::make_unique(Translate, _trans("Backward"))); + controls.emplace_back(std::make_unique(Translate, _trans("Hide"))); + controls.emplace_back(std::make_unique(Translate, _trans("Recenter"))); numeric_settings.emplace_back(std::make_unique(_trans("Center"), 0.5)); numeric_settings.emplace_back(std::make_unique(_trans("Width"), 0.5)); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp index c620bd787a..46dbd63c49 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp @@ -19,12 +19,12 @@ namespace ControllerEmu { Force::Force(const std::string& name_) : ControlGroup(name_, GroupType::Force) { - controls.emplace_back(std::make_unique(true, _trans("Up"))); - controls.emplace_back(std::make_unique(true, _trans("Down"))); - controls.emplace_back(std::make_unique(true, _trans("Left"))); - controls.emplace_back(std::make_unique(true, _trans("Right"))); - controls.emplace_back(std::make_unique(true, _trans("Forward"))); - controls.emplace_back(std::make_unique(true, _trans("Backward"))); + controls.emplace_back(std::make_unique(Translate, _trans("Up"))); + controls.emplace_back(std::make_unique(Translate, _trans("Down"))); + controls.emplace_back(std::make_unique(Translate, _trans("Left"))); + controls.emplace_back(std::make_unique(Translate, _trans("Right"))); + controls.emplace_back(std::make_unique(Translate, _trans("Forward"))); + controls.emplace_back(std::make_unique(Translate, _trans("Backward"))); numeric_settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); } diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp index 943a0bae85..268d239f0b 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ModifySettingsButton.cpp @@ -27,7 +27,7 @@ ModifySettingsButton::ModifySettingsButton(std::string button_name) void ModifySettingsButton::AddInput(std::string button_name, bool toggle) { - controls.emplace_back(std::make_unique(true, std::move(button_name))); + controls.emplace_back(std::make_unique(Translate, std::move(button_name))); threshold_exceeded.emplace_back(false); associated_settings.emplace_back(false); associated_settings_toggle.emplace_back(toggle); diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp index f04508e011..6784f6e24e 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Slider.cpp @@ -20,8 +20,8 @@ namespace ControllerEmu Slider::Slider(const std::string& name_, const std::string& ui_name_) : ControlGroup(name_, ui_name_, GroupType::Slider) { - controls.emplace_back(std::make_unique(true, _trans("Left"))); - controls.emplace_back(std::make_unique(true, _trans("Right"))); + controls.emplace_back(std::make_unique(Translate, _trans("Left"))); + controls.emplace_back(std::make_unique(Translate, _trans("Right"))); numeric_settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); } diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp index 94d3538685..2785f56ba5 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Tilt.cpp @@ -19,12 +19,12 @@ namespace ControllerEmu { Tilt::Tilt(const std::string& name_) : ControlGroup(name_, GroupType::Tilt) { - controls.emplace_back(std::make_unique(true, _trans("Forward"))); - controls.emplace_back(std::make_unique(true, _trans("Backward"))); - controls.emplace_back(std::make_unique(true, _trans("Left"))); - controls.emplace_back(std::make_unique(true, _trans("Right"))); + controls.emplace_back(std::make_unique(Translate, _trans("Forward"))); + controls.emplace_back(std::make_unique(Translate, _trans("Backward"))); + controls.emplace_back(std::make_unique(Translate, _trans("Left"))); + controls.emplace_back(std::make_unique(Translate, _trans("Right"))); - controls.emplace_back(std::make_unique(true, _trans("Modifier"))); + controls.emplace_back(std::make_unique(Translate, _trans("Modifier"))); numeric_settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); numeric_settings.emplace_back(std::make_unique(_trans("Circle Stick"), 0));