Make controller button names translatable and deduplicate code

This commit is contained in:
Fs00 2022-09-10 15:10:52 +02:00
parent 4c6f22ba39
commit 13aa0a4fd0
13 changed files with 162 additions and 217 deletions

View File

@ -29,16 +29,7 @@ ClassicControllerInputPanel::ClassicControllerInputPanel(wxWindow* parent)
for (const auto& id : g_kFirstColumnItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(ClassicController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData(reinterpret_cast<void*>(id));
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
//////////////////////////////////////////////////////////////////
@ -55,16 +46,7 @@ ClassicControllerInputPanel::ClassicControllerInputPanel(wxWindow* parent)
for (const auto& id : g_kSecondColumnItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(ClassicController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData(reinterpret_cast<void*>(id));
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
row++;
@ -87,16 +69,7 @@ ClassicControllerInputPanel::ClassicControllerInputPanel(wxWindow* parent)
for (const auto& id : g_kThirdColumnItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(ClassicController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData(reinterpret_cast<void*>(id));
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
row++;
@ -119,21 +92,27 @@ ClassicControllerInputPanel::ClassicControllerInputPanel(wxWindow* parent)
for (auto id : g_kFourthRowItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(ClassicController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData(reinterpret_cast<void*>(id));
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
//////////////////////////////////////////////////////////////////
SetSizer(main_sizer);
Layout();
}
void ClassicControllerInputPanel::add_button_row(wxGridBagSizer *sizer, sint32 row, sint32 column, const ClassicController::ButtonId &button_id) {
sizer->Add(
new wxStaticText(this, wxID_ANY, wxGetTranslation(to_wxString(ClassicController::get_button_name(button_id)))),
wxGBPosition(row, column),
wxDefaultSpan,
wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData(reinterpret_cast<void*>(button_id));
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
}

View File

@ -1,5 +1,7 @@
#pragma once
#include <wx/gbsizer.h>
#include "input/emulated/ClassicController.h"
#include "gui/input/panels/InputPanel.h"
class wxInputDraw;
@ -11,5 +13,7 @@ public:
private:
wxInputDraw* m_left_draw, * m_right_draw;
void add_button_row(wxGridBagSizer *sizer, sint32 row, sint32 column, const ClassicController::ButtonId &button_id);
};

View File

@ -4,9 +4,7 @@
#include <wx/stattext.h>
#include <wx/statline.h>
#include <wx/textctrl.h>
#include <wx/slider.h>
#include "gui/helpers/wxControlObject.h"
#include "input/emulated/ProController.h"
#include "gui/helpers/wxHelpers.h"
#include "gui/components/wxInputDraw.h"
@ -30,16 +28,7 @@ ProControllerInputPanel::ProControllerInputPanel(wxWindow* parent)
for (auto id : g_kFirstColumnItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(ProController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
//////////////////////////////////////////////////////////////////
@ -56,16 +45,7 @@ ProControllerInputPanel::ProControllerInputPanel(wxWindow* parent)
for (auto id : g_kSecondColumnItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(ProController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
row++;
@ -88,16 +68,7 @@ ProControllerInputPanel::ProControllerInputPanel(wxWindow* parent)
for (auto id : g_kThirdColumnItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(ProController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
row++;
@ -120,16 +91,7 @@ ProControllerInputPanel::ProControllerInputPanel(wxWindow* parent)
for (auto id : g_kFourthRowItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(ProController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
//////////////////////////////////////////////////////////////////
@ -140,6 +102,22 @@ ProControllerInputPanel::ProControllerInputPanel(wxWindow* parent)
//wxWindow::Show(show);
}
void ProControllerInputPanel::add_button_row(wxGridBagSizer *sizer, sint32 row, sint32 column, const ProController::ButtonId &button_id) {
sizer->Add(
new wxStaticText(this, wxID_ANY, wxGetTranslation(to_wxString(ProController::get_button_name(button_id)))),
wxGBPosition(row, column),
wxDefaultSpan,
wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)button_id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
}
void ProControllerInputPanel::on_timer(const EmulatedControllerPtr& emulated_controller,
const ControllerPtr& controller_base)
{

View File

@ -1,5 +1,7 @@
#pragma once
#include <wx/gbsizer.h>
#include "input/emulated/ProController.h"
#include "gui/input/panels/InputPanel.h"
#include "gui/components/wxInputDraw.h"
@ -12,4 +14,6 @@ public:
private:
wxInputDraw* m_left_draw, * m_right_draw;
void add_button_row(wxGridBagSizer *sizer, sint32 row, sint32 column, const ProController::ButtonId &button_id);
};

View File

@ -48,16 +48,7 @@ VPADInputPanel::VPADInputPanel(wxWindow* parent)
for (const auto& id : g_kFirstColumnItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(VPADController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
//////////////////////////////////////////////////////////////////
@ -74,16 +65,7 @@ VPADInputPanel::VPADInputPanel(wxWindow* parent)
for (const auto& id : g_kSecondColumnItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(VPADController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
row++;
@ -106,16 +88,7 @@ VPADInputPanel::VPADInputPanel(wxWindow* parent)
for (const auto& id : g_kThirdColumnItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(VPADController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
row++;
@ -154,40 +127,15 @@ VPADInputPanel::VPADInputPanel(wxWindow* parent)
for (const auto& id : g_kFourthRowItems)
{
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(VPADController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, id);
}
// Blow Mic
row = 9;
main_sizer->Add(new wxStaticText(this, wxID_ANY, _("blow mic")), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)VPADController::kButtonId_Mic);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, VPADController::kButtonId_Mic, _("blow mic"));
row++;
main_sizer->Add(new wxStaticText(this, wxID_ANY, _("show screen")), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)VPADController::kButtonId_Screen);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
main_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(main_sizer, row, column, VPADController::kButtonId_Screen, _("show screen"));
//////////////////////////////////////////////////////////////////
@ -200,6 +148,27 @@ VPADInputPanel::VPADInputPanel(wxWindow* parent)
//wxWindow::Show(show);
}
void VPADInputPanel::add_button_row(wxGridBagSizer *sizer, sint32 row, sint32 column, const VPADController::ButtonId &button_id) {
add_button_row(sizer, row, column, button_id, wxGetTranslation(to_wxString(VPADController::get_button_name(button_id))));
}
void VPADInputPanel::add_button_row(wxGridBagSizer *sizer, sint32 row, sint32 column,
const VPADController::ButtonId &button_id, const wxString &label) {
sizer->Add(
new wxStaticText(this, wxID_ANY, label),
wxGBPosition(row, column),
wxDefaultSpan,
wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)button_id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
}
void VPADInputPanel::on_timer(const EmulatedControllerPtr& emulated_controller, const ControllerPtr& controller_base)
{
InputPanel::on_timer(emulated_controller, controller_base);

View File

@ -1,5 +1,6 @@
#pragma once
#include <wx/gbsizer.h>
#include "gui/input/panels/InputPanel.h"
class wxInputDraw;
@ -15,4 +16,7 @@ private:
void OnVolumeChange(wxCommandEvent& event);
wxInputDraw* m_left_draw, * m_right_draw;
void add_button_row(wxGridBagSizer *sizer, sint32 row, sint32 column, const VPADController::ButtonId &button_id);
void add_button_row(wxGridBagSizer *sizer, sint32 row, sint32 column, const VPADController::ButtonId &button_id, const wxString &label);
};

View File

@ -64,16 +64,7 @@ WiimoteInputPanel::WiimoteInputPanel(wxWindow* parent)
for (const auto& id : g_kFirstColumnItems)
{
row++;
m_item_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(WiimoteController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
m_item_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(row, column, id);
}
m_item_sizer->Add(new wxStaticLine(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVERTICAL), wxGBPosition(0, column + 2), wxGBSpan(11, 1), wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND, 5);
@ -90,16 +81,7 @@ WiimoteInputPanel::WiimoteInputPanel(wxWindow* parent)
for (const auto& id : g_kSecondColumnItems)
{
row++;
m_item_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(WiimoteController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
m_item_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
add_button_row(row, column, id);
}
row = 8;
@ -135,7 +117,11 @@ WiimoteInputPanel::WiimoteInputPanel(wxWindow* parent)
if (id == WiimoteController::kButtonId_None)
continue;
m_item_sizer->Add(new wxStaticText(this, wxID_ANY, to_wxString(WiimoteController::get_button_name(id))), wxGBPosition(row, column), wxDefaultSpan, wxALL | wxALIGN_CENTER_VERTICAL, 5);
m_item_sizer->Add(
new wxStaticText(this, wxID_ANY, wxGetTranslation(to_wxString(WiimoteController::get_button_name(id)))),
wxGBPosition(row, column),
wxDefaultSpan,
wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)id);
@ -166,6 +152,22 @@ WiimoteInputPanel::WiimoteInputPanel(wxWindow* parent)
Layout();
}
void WiimoteInputPanel::add_button_row(sint32 row, sint32 column, const WiimoteController::ButtonId &button_id) {
m_item_sizer->Add(
new wxStaticText(this, wxID_ANY, wxGetTranslation(to_wxString(WiimoteController::get_button_name(button_id)))),
wxGBPosition(row, column),
wxDefaultSpan,
wxALL | wxALIGN_CENTER_VERTICAL, 5);
auto* text_ctrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL | wxTE_PROCESS_ENTER | wxTE_PROCESS_TAB);
text_ctrl->SetClientData((void*)button_id);
text_ctrl->SetMinSize(wxSize(150, -1));
text_ctrl->SetEditable(false);
text_ctrl->SetBackgroundColour(kKeyColourNormalMode);
bind_hotkey_events(text_ctrl);
m_item_sizer->Add(text_ctrl, wxGBPosition(row, column + 1), wxDefaultSpan, wxALL | wxEXPAND, 5);
}
void WiimoteInputPanel::set_active_device_type(WPADDeviceType type)
{
m_device_type = type;

View File

@ -1,6 +1,7 @@
#pragma once
#include "gui/input/panels/InputPanel.h"
#include "input/emulated/WiimoteController.h"
#include <wx/slider.h>
class wxCheckBox;
@ -33,7 +34,8 @@ private:
wxSlider* m_volume;
std::vector<wxWindow*> m_nunchuck_items;
bool m_extensions_changed;
void add_button_row(sint32 row, sint32 column, const WiimoteController::ButtonId &button_id);
};

View File

@ -3,6 +3,7 @@
#include "input/api/Controller.h"
#include "input/api/SDL/SDLController.h"
#include <wx/intl.h>
ClassicController::ClassicController(size_t player_index)
: WPADController(player_index, kDataFormat_CLASSIC)
@ -69,22 +70,22 @@ std::string_view ClassicController::get_button_name(ButtonId id)
case kButtonId_Plus: return "+";
case kButtonId_Minus: return "-";
case kButtonId_Home: return "home";
case kButtonId_Home: return wxTRANSLATE("home");
case kButtonId_Up: return "up";
case kButtonId_Down: return "down";
case kButtonId_Left: return "left";
case kButtonId_Right: return "right";
case kButtonId_Up: return wxTRANSLATE("up");
case kButtonId_Down: return wxTRANSLATE("down");
case kButtonId_Left: return wxTRANSLATE("left");
case kButtonId_Right: return wxTRANSLATE("right");
case kButtonId_StickL_Up: return "up";
case kButtonId_StickL_Down: return "down";
case kButtonId_StickL_Left: return "left";
case kButtonId_StickL_Right: return "right";
case kButtonId_StickL_Up: return wxTRANSLATE("up");
case kButtonId_StickL_Down: return wxTRANSLATE("down");
case kButtonId_StickL_Left: return wxTRANSLATE("left");
case kButtonId_StickL_Right: return wxTRANSLATE("right");
case kButtonId_StickR_Up: return "up";
case kButtonId_StickR_Down: return "down";
case kButtonId_StickR_Left: return "left";
case kButtonId_StickR_Right: return "right";
case kButtonId_StickR_Up: return wxTRANSLATE("up");
case kButtonId_StickR_Down: return wxTRANSLATE("down");
case kButtonId_StickR_Left: return wxTRANSLATE("left");
case kButtonId_StickR_Right: return wxTRANSLATE("right");
default:
return "";

View File

@ -3,6 +3,8 @@
#include "input/api/Controller.h"
#include "input/api/SDL/SDLController.h"
#include <wx/intl.h>
ProController::ProController(size_t player_index)
: WPADController(player_index, kDataFormat_URCC)
{
@ -73,21 +75,21 @@ std::string_view ProController::get_button_name(ButtonId id)
case kButtonId_ZR: return "ZR";
case kButtonId_Plus: return "+";
case kButtonId_Minus: return "-";
case kButtonId_Up: return "up";
case kButtonId_Down: return "down";
case kButtonId_Left: return "left";
case kButtonId_Right: return "right";
case kButtonId_StickL: return "click";
case kButtonId_StickR: return "click";
case kButtonId_StickL_Up: return "up";
case kButtonId_StickL_Down: return "down";
case kButtonId_StickL_Left: return "left";
case kButtonId_StickL_Right: return "right";
case kButtonId_StickR_Up: return "up";
case kButtonId_StickR_Down: return "down";
case kButtonId_StickR_Left: return "left";
case kButtonId_StickR_Right: return "right";
case kButtonId_Home: return "home";
case kButtonId_Up: return wxTRANSLATE("up");
case kButtonId_Down: return wxTRANSLATE("down");
case kButtonId_Left: return wxTRANSLATE("left");
case kButtonId_Right: return wxTRANSLATE("right");
case kButtonId_StickL: return wxTRANSLATE("click");
case kButtonId_StickR: return wxTRANSLATE("click");
case kButtonId_StickL_Up: return wxTRANSLATE("up");
case kButtonId_StickL_Down: return wxTRANSLATE("down");
case kButtonId_StickL_Left: return wxTRANSLATE("left");
case kButtonId_StickL_Right: return wxTRANSLATE("right");
case kButtonId_StickR_Up: return wxTRANSLATE("up");
case kButtonId_StickR_Down: return wxTRANSLATE("down");
case kButtonId_StickR_Left: return wxTRANSLATE("left");
case kButtonId_StickR_Right: return wxTRANSLATE("right");
case kButtonId_Home: return wxTRANSLATE("home");
default:
cemu_assert_debug(false);
return "";

View File

@ -5,6 +5,7 @@
#include "input/InputManager.h"
#include "Cafe/HW/Latte/Core/Latte.h"
#include "Cafe/CafeSystem.h"
#include <wx/intl.h>
enum ControllerVPADMapping2 : uint32
{
@ -366,21 +367,21 @@ std::string_view VPADController::get_button_name(ButtonId id)
case kButtonId_ZR: return "ZR";
case kButtonId_Plus: return "+";
case kButtonId_Minus: return "-";
case kButtonId_Up: return "up";
case kButtonId_Down: return "down";
case kButtonId_Left: return "left";
case kButtonId_Right: return "right";
case kButtonId_StickL: return "click";
case kButtonId_StickR: return "click";
case kButtonId_StickL_Up: return "up";
case kButtonId_StickL_Down: return "down";
case kButtonId_StickL_Left: return "left";
case kButtonId_StickL_Right: return "right";
case kButtonId_StickR_Up: return "up";
case kButtonId_StickR_Down: return "down";
case kButtonId_StickR_Left: return "left";
case kButtonId_StickR_Right: return "right";
case kButtonId_Home: return "home";
case kButtonId_Up: return wxTRANSLATE("up");
case kButtonId_Down: return wxTRANSLATE("down");
case kButtonId_Left: return wxTRANSLATE("left");
case kButtonId_Right: return wxTRANSLATE("right");
case kButtonId_StickL: return wxTRANSLATE("click");
case kButtonId_StickR: return wxTRANSLATE("click");
case kButtonId_StickL_Up: return wxTRANSLATE("up");
case kButtonId_StickL_Down: return wxTRANSLATE("down");
case kButtonId_StickL_Left: return wxTRANSLATE("left");
case kButtonId_StickL_Right: return wxTRANSLATE("right");
case kButtonId_StickR_Up: return wxTRANSLATE("up");
case kButtonId_StickR_Down: return wxTRANSLATE("down");
case kButtonId_StickR_Left: return wxTRANSLATE("left");
case kButtonId_StickR_Right: return wxTRANSLATE("right");
case kButtonId_Home: return wxTRANSLATE("home");
default:
cemu_assert_debug(false);
return "";

View File

@ -2,7 +2,7 @@
#include "input/api/Controller.h"
#include "input/api/Wiimote/NativeWiimoteController.h"
#include <wx/intl.h>
WiimoteController::WiimoteController(size_t player_index)
: WPADController(player_index, kDataFormat_CORE_ACC_DPD)
@ -159,22 +159,22 @@ std::string_view WiimoteController::get_button_name(ButtonId id)
case kButtonId_1: return "1";
case kButtonId_2: return "2";
case kButtonId_Home: return "home";
case kButtonId_Home: return wxTRANSLATE("home");
case kButtonId_Plus: return "+";
case kButtonId_Minus: return "-";
case kButtonId_Up: return "up";
case kButtonId_Down: return "down";
case kButtonId_Left: return "left";
case kButtonId_Right: return "right";
case kButtonId_Up: return wxTRANSLATE("up");
case kButtonId_Down: return wxTRANSLATE("down");
case kButtonId_Left: return wxTRANSLATE("left");
case kButtonId_Right: return wxTRANSLATE("right");
case kButtonId_Nunchuck_Z: return "Z";
case kButtonId_Nunchuck_C: return "C";
case kButtonId_Nunchuck_Up: return "up";
case kButtonId_Nunchuck_Down: return "down";
case kButtonId_Nunchuck_Left: return "left";
case kButtonId_Nunchuck_Right: return "right";
case kButtonId_Nunchuck_Up: return wxTRANSLATE("up");
case kButtonId_Nunchuck_Down: return wxTRANSLATE("down");
case kButtonId_Nunchuck_Left: return wxTRANSLATE("left");
case kButtonId_Nunchuck_Right: return wxTRANSLATE("right");
default:
return "";

View File

@ -1,7 +1,6 @@
#pragma once
#include "input/emulated/WPADController.h"
#include "gui/input/panels/WiimoteInputPanel.h"
class WiimoteController : public WPADController
{