Add flexibility to InputConfigDialog

Removed the unecessary forced tabbed layout, removed the layout part of the constructor and remade some method in preparation for tabbed styled input dialog such as the new hotkey configuration one.  It breaks every inputconfigDialog, but this will get fixed in the next commits.

Also moved to a folder since there will be many more files created in the next commits so it gives better separation.
This commit is contained in:
aldelaro5 2016-11-18 02:03:06 -05:00
parent 7e99d03b7f
commit 00f680b830
11 changed files with 172 additions and 215 deletions

View File

@ -40,6 +40,8 @@ set(GUI_SRCS
NetPlay/NetPlaySetupFrame.cpp NetPlay/NetPlaySetupFrame.cpp
NetPlay/NetWindow.cpp NetPlay/NetWindow.cpp
NetPlay/PadMapDialog.cpp NetPlay/PadMapDialog.cpp
Input/InputConfigDiag.cpp
Input/InputConfigDiagBitmaps.cpp
DolphinSlider.cpp DolphinSlider.cpp
FifoPlayerDlg.cpp FifoPlayerDlg.cpp
Frame.cpp Frame.cpp
@ -48,8 +50,6 @@ set(GUI_SRCS
GameListCtrl.cpp GameListCtrl.cpp
ISOFile.cpp ISOFile.cpp
ISOProperties.cpp ISOProperties.cpp
InputConfigDiag.cpp
InputConfigDiagBitmaps.cpp
LogConfigWindow.cpp LogConfigWindow.cpp
LogWindow.cpp LogWindow.cpp
Main.cpp Main.cpp

View File

@ -24,7 +24,7 @@
#include "Core/HotkeyManager.h" #include "Core/HotkeyManager.h"
#include "DolphinWX/Config/InterfaceConfigPane.h" #include "DolphinWX/Config/InterfaceConfigPane.h"
#include "DolphinWX/Frame.h" #include "DolphinWX/Frame.h"
#include "DolphinWX/InputConfigDiag.h" #include "DolphinWX/Input/InputConfigDiag.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
#if defined(HAVE_XRANDR) && HAVE_XRANDR #if defined(HAVE_XRANDR) && HAVE_XRANDR

View File

@ -33,7 +33,7 @@
#include "DolphinWX/Config/GCAdapterConfigDiag.h" #include "DolphinWX/Config/GCAdapterConfigDiag.h"
#include "DolphinWX/ControllerConfigDiag.h" #include "DolphinWX/ControllerConfigDiag.h"
#include "DolphinWX/DolphinSlider.h" #include "DolphinWX/DolphinSlider.h"
#include "DolphinWX/InputConfigDiag.h" #include "DolphinWX/Input/InputConfigDiag.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
#include "InputCommon/GCAdapter.h" #include "InputCommon/GCAdapter.h"
@ -447,20 +447,24 @@ void ControllerConfigDiag::OnGameCubeConfigButton(wxCommandEvent& event)
if (SConfig::GetInstance().m_SIDevice[port_num] == SIDEVICE_GC_KEYBOARD) if (SConfig::GetInstance().m_SIDevice[port_num] == SIDEVICE_GC_KEYBOARD)
{ {
InputConfigDialog config_diag(this, *key_plugin, _("GameCube Keyboard Configuration"), InputConfigDialog config_diag(
port_num); this, *key_plugin,
wxString::Format("GameCube Keyboard Configuration Port %i", port_num + 1), port_num);
config_diag.ShowModal(); config_diag.ShowModal();
} }
else if (SConfig::GetInstance().m_SIDevice[port_num] == SIDEVICE_WIIU_ADAPTER) else if (SConfig::GetInstance().m_SIDevice[port_num] == SIDEVICE_WIIU_ADAPTER)
{ {
GCAdapterConfigDiag config_diag(this, _("Wii U GameCube Controller Adapter Configuration"), GCAdapterConfigDiag config_diag(
port_num); this,
wxString::Format("Wii U GameCube Controller Adapter Configuration Port %i", port_num + 1),
port_num);
config_diag.ShowModal(); config_diag.ShowModal();
} }
else else
{ {
InputConfigDialog config_diag(this, *pad_plugin, _("GameCube Controller Configuration"), InputConfigDialog config_diag(
port_num); this, *pad_plugin,
wxString::Format("GameCube Controller Configuration Port %i", port_num + 1), port_num);
config_diag.ShowModal(); config_diag.ShowModal();
} }
@ -494,9 +498,12 @@ void ControllerConfigDiag::OnWiimoteConfigButton(wxCommandEvent& ev)
HotkeyManagerEmu::Enable(false); HotkeyManagerEmu::Enable(false);
InputConfigDialog m_ConfigFrame(this, *wiimote_plugin, int port_num = m_wiimote_index_from_config_id[ev.GetId()];
_("Dolphin Emulated Wii Remote Configuration"),
m_wiimote_index_from_config_id[ev.GetId()]); InputConfigDialog m_ConfigFrame(
this, *wiimote_plugin,
wxString::Format("Dolphin Emulated Wii Remote Configuration Port %i", port_num + 1),
port_num);
m_ConfigFrame.ShowModal(); m_ConfigFrame.ShowModal();
HotkeyManagerEmu::Enable(true); HotkeyManagerEmu::Enable(true);

View File

@ -100,8 +100,8 @@
<ClCompile Include="FrameAui.cpp" /> <ClCompile Include="FrameAui.cpp" />
<ClCompile Include="FrameTools.cpp" /> <ClCompile Include="FrameTools.cpp" />
<ClCompile Include="GameListCtrl.cpp" /> <ClCompile Include="GameListCtrl.cpp" />
<ClCompile Include="InputConfigDiag.cpp" /> <ClCompile Include="Input\InputConfigDiag.cpp" />
<ClCompile Include="InputConfigDiagBitmaps.cpp" /> <ClCompile Include="Input\InputConfigDiagBitmaps.cpp" />
<ClCompile Include="ISOFile.cpp" /> <ClCompile Include="ISOFile.cpp" />
<ClCompile Include="ISOProperties.cpp" /> <ClCompile Include="ISOProperties.cpp" />
<ClCompile Include="LogConfigWindow.cpp" /> <ClCompile Include="LogConfigWindow.cpp" />
@ -170,7 +170,7 @@
<ClInclude Include="Frame.h" /> <ClInclude Include="Frame.h" />
<ClInclude Include="GameListCtrl.h" /> <ClInclude Include="GameListCtrl.h" />
<ClInclude Include="Globals.h" /> <ClInclude Include="Globals.h" />
<ClInclude Include="InputConfigDiag.h" /> <ClInclude Include="Input\InputConfigDiag.h" />
<ClInclude Include="ISOFile.h" /> <ClInclude Include="ISOFile.h" />
<ClInclude Include="ISOProperties.h" /> <ClInclude Include="ISOProperties.h" />
<ClInclude Include="LogConfigWindow.h" /> <ClInclude Include="LogConfigWindow.h" />

View File

@ -104,10 +104,10 @@
<ClCompile Include="NetPlay\NetWindow.cpp"> <ClCompile Include="NetPlay\NetWindow.cpp">
<Filter>GUI\NetPlay</Filter> <Filter>GUI\NetPlay</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="InputConfigDiag.cpp"> <ClCompile Include="Input\InputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter> <Filter>GUI\InputConfig</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="InputConfigDiagBitmaps.cpp"> <ClCompile Include="Input\InputConfigDiagBitmaps.cpp">
<Filter>GUI\InputConfig</Filter> <Filter>GUI\InputConfig</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Debugger\DebuggerPanel.cpp"> <ClCompile Include="Debugger\DebuggerPanel.cpp">
@ -290,7 +290,7 @@
<ClInclude Include="NetPlay\NetWindow.h"> <ClInclude Include="NetPlay\NetWindow.h">
<Filter>GUI\NetPlay</Filter> <Filter>GUI\NetPlay</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="InputConfigDiag.h"> <ClInclude Include="Input\InputConfigDiag.h">
<Filter>GUI\InputConfig</Filter> <Filter>GUI\InputConfig</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Debugger\DebuggerPanel.h"> <ClInclude Include="Debugger\DebuggerPanel.h">

View File

@ -65,7 +65,7 @@
#include "DolphinWX/GameListCtrl.h" #include "DolphinWX/GameListCtrl.h"
#include "DolphinWX/Globals.h" #include "DolphinWX/Globals.h"
#include "DolphinWX/ISOFile.h" #include "DolphinWX/ISOFile.h"
#include "DolphinWX/InputConfigDiag.h" #include "DolphinWX/Input/InputConfigDiag.h"
#include "DolphinWX/LogWindow.h" #include "DolphinWX/LogWindow.h"
#include "DolphinWX/MainMenuBar.h" #include "DolphinWX/MainMenuBar.h"
#include "DolphinWX/MainToolBar.h" #include "DolphinWX/MainToolBar.h"

View File

@ -44,7 +44,7 @@
#include "Core/HW/Wiimote.h" #include "Core/HW/Wiimote.h"
#include "Core/HotkeyManager.h" #include "Core/HotkeyManager.h"
#include "DolphinWX/DolphinSlider.h" #include "DolphinWX/DolphinSlider.h"
#include "DolphinWX/InputConfigDiag.h" #include "DolphinWX/Input/InputConfigDiag.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
#include "InputCommon/ControllerEmu.h" #include "InputCommon/ControllerEmu.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h" #include "InputCommon/ControllerInterface/ControllerInterface.h"
@ -54,7 +54,7 @@
using namespace ciface::ExpressionParser; using namespace ciface::ExpressionParser;
void GamepadPage::ConfigExtension(wxCommandEvent& event) void InputConfigDialog::ConfigExtension(wxCommandEvent& event)
{ {
ControllerEmu::Extension* const ex = ((ExtensionButton*)event.GetEventObject())->extension; ControllerEmu::Extension* const ex = ((ExtensionButton*)event.GetEventObject())->extension;
@ -67,8 +67,8 @@ void GamepadPage::ConfigExtension(wxCommandEvent& event)
wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL); wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
const std::size_t orig_size = control_groups.size(); const std::size_t orig_size = control_groups.size();
ControlGroupsSizer* const szr = new ControlGroupsSizer( ControlGroupsSizer* const szr =
ex->attachments[ex->switch_extension].get(), &dlg, this, &control_groups); new ControlGroupsSizer(ex->attachments[ex->switch_extension].get(), this, &control_groups);
const int space5 = FromDIP(5); const int space5 = FromDIP(5);
main_szr->Add(szr, 0, wxLEFT, space5); main_szr->Add(szr, 0, wxLEFT, space5);
main_szr->Add(dlg.CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT, space5); main_szr->Add(dlg.CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
@ -150,13 +150,13 @@ void PadSettingSpin::UpdateValue()
setting->SetValue(ControlState(((wxSpinCtrl*)wxcontrol)->GetValue()) / 100); setting->SetValue(ControlState(((wxSpinCtrl*)wxcontrol)->GetValue()) / 100);
} }
ControlDialog::ControlDialog(GamepadPage* const parent, InputConfig& config, ControlDialog::ControlDialog(InputConfigDialog* const parent, InputConfig& config,
ControllerInterface::ControlReference* const ref) ControllerInterface::ControlReference* const ref)
: wxDialog(parent, wxID_ANY, _("Configure Control"), wxDefaultPosition, wxDefaultSize, : wxDialog(parent, wxID_ANY, _("Configure Control"), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
control_reference(ref), m_config(config), m_parent(parent) control_reference(ref), m_config(config), m_parent(parent)
{ {
m_devq = m_parent->controller->default_device; m_devq = m_parent->GetController()->default_device;
const int space5 = FromDIP(5); const int space5 = FromDIP(5);
// GetStrings() sounds slow :/ // GetStrings() sounds slow :/
@ -229,19 +229,13 @@ void InputConfigDialog::UpdateProfileComboBox()
strs.push_back(StrToWxStr(base)); strs.push_back(StrToWxStr(base));
} }
for (GamepadPage* page : m_padpages) profile_cbox->Clear();
{ profile_cbox->Append(strs);
page->profile_cbox->Clear();
page->profile_cbox->Append(strs);
}
} }
void InputConfigDialog::UpdateControlReferences() void InputConfigDialog::UpdateControlReferences()
{ {
for (GamepadPage* page : m_padpages) controller->UpdateReferences(g_controller_interface);
{
page->controller->UpdateReferences(g_controller_interface);
}
} }
void InputConfigDialog::OnClose(wxCloseEvent& event) void InputConfigDialog::OnClose(wxCloseEvent& event)
@ -315,9 +309,10 @@ void ControlDialog::UpdateGUI()
} }
}; };
void GamepadPage::UpdateGUI() void InputConfigDialog::UpdateGUI()
{ {
device_cbox->SetValue(StrToWxStr(controller->default_device.ToString())); if (device_cbox != nullptr)
device_cbox->SetValue(StrToWxStr(controller->default_device.ToString()));
for (ControlGroupBox* cgBox : control_groups) for (ControlGroupBox* cgBox : control_groups)
{ {
@ -333,7 +328,7 @@ void GamepadPage::UpdateGUI()
} }
} }
void GamepadPage::ClearAll(wxCommandEvent&) void InputConfigDialog::ClearAll(wxCommandEvent&)
{ {
// just load an empty ini section to clear everything :P // just load an empty ini section to clear everything :P
IniFile::Section section; IniFile::Section section;
@ -347,7 +342,7 @@ void GamepadPage::ClearAll(wxCommandEvent&)
UpdateGUI(); UpdateGUI();
} }
void GamepadPage::LoadDefaults(wxCommandEvent&) void InputConfigDialog::LoadDefaults(wxCommandEvent&)
{ {
controller->LoadDefaults(g_controller_interface); controller->LoadDefaults(g_controller_interface);
@ -361,7 +356,8 @@ bool ControlDialog::Validate()
control_reference->expression = WxStrToStr(textctrl->GetValue()); control_reference->expression = WxStrToStr(textctrl->GetValue());
auto lock = ControllerEmu::GetStateLock(); auto lock = ControllerEmu::GetStateLock();
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); g_controller_interface.UpdateReference(control_reference,
m_parent->GetController()->default_device);
UpdateGUI(); UpdateGUI();
@ -369,7 +365,7 @@ bool ControlDialog::Validate()
control_reference->parse_error == EXPRESSION_PARSE_NO_DEVICE); control_reference->parse_error == EXPRESSION_PARSE_NO_DEVICE);
} }
void GamepadPage::SetDevice(wxCommandEvent&) void InputConfigDialog::SetDevice(wxCommandEvent&)
{ {
controller->default_device.FromString(WxStrToStr(device_cbox->GetValue())); controller->default_device.FromString(WxStrToStr(device_cbox->GetValue()));
@ -399,7 +395,8 @@ void ControlDialog::ClearControl(wxCommandEvent&)
control_reference->expression.clear(); control_reference->expression.clear();
auto lock = ControllerEmu::GetStateLock(); auto lock = ControllerEmu::GetStateLock();
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); g_controller_interface.UpdateReference(control_reference,
m_parent->GetController()->default_device);
UpdateGUI(); UpdateGUI();
} }
@ -441,7 +438,7 @@ bool ControlDialog::GetExpressionForSelectedControl(wxString& expr)
return false; return false;
wxString control_name = control_lbox->GetString(num); wxString control_name = control_lbox->GetString(num);
GetExpressionForControl(expr, control_name, &m_devq, &m_parent->controller->default_device); GetExpressionForControl(expr, control_name, &m_devq, &m_parent->GetController()->default_device);
return true; return true;
} }
@ -457,7 +454,8 @@ void ControlDialog::SetSelectedControl(wxCommandEvent&)
control_reference->expression = textctrl->GetValue(); control_reference->expression = textctrl->GetValue();
auto lock = ControllerEmu::GetStateLock(); auto lock = ControllerEmu::GetStateLock();
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); g_controller_interface.UpdateReference(control_reference,
m_parent->GetController()->default_device);
UpdateGUI(); UpdateGUI();
} }
@ -492,13 +490,14 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
control_reference->expression = textctrl->GetValue(); control_reference->expression = textctrl->GetValue();
auto lock = ControllerEmu::GetStateLock(); auto lock = ControllerEmu::GetStateLock();
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device); g_controller_interface.UpdateReference(control_reference,
m_parent->GetController()->default_device);
UpdateGUI(); UpdateGUI();
} }
void GamepadPage::EnablePadSetting(const std::string& group_name, const std::string& name, void InputConfigDialog::EnablePadSetting(const std::string& group_name, const std::string& name,
const bool enabled) const bool enabled)
{ {
const auto box_iterator = const auto box_iterator =
std::find_if(control_groups.begin(), control_groups.end(), [&group_name](const auto& box) { std::find_if(control_groups.begin(), control_groups.end(), [&group_name](const auto& box) {
@ -517,8 +516,8 @@ void GamepadPage::EnablePadSetting(const std::string& group_name, const std::str
(*it)->wxcontrol->Enable(enabled); (*it)->wxcontrol->Enable(enabled);
} }
void GamepadPage::EnableControlButton(const std::string& group_name, const std::string& name, void InputConfigDialog::EnableControlButton(const std::string& group_name, const std::string& name,
const bool enabled) const bool enabled)
{ {
const auto box_iterator = const auto box_iterator =
std::find_if(control_groups.begin(), control_groups.end(), [&group_name](const auto& box) { std::find_if(control_groups.begin(), control_groups.end(), [&group_name](const auto& box) {
@ -553,14 +552,14 @@ void ControlDialog::OnRangeThumbtrack(wxScrollEvent& event)
m_range_spinner->SetValue(event.GetPosition()); m_range_spinner->SetValue(event.GetPosition());
} }
void GamepadPage::AdjustSetting(wxCommandEvent& event) void InputConfigDialog::AdjustSetting(wxCommandEvent& event)
{ {
const auto* const control = static_cast<wxControl*>(event.GetEventObject()); const auto* const control = static_cast<wxControl*>(event.GetEventObject());
auto* const pad_setting = static_cast<PadSetting*>(control->GetClientData()); auto* const pad_setting = static_cast<PadSetting*>(control->GetClientData());
pad_setting->UpdateValue(); pad_setting->UpdateValue();
} }
void GamepadPage::AdjustBooleanSetting(wxCommandEvent& event) void InputConfigDialog::AdjustBooleanSetting(wxCommandEvent& event)
{ {
const auto* const control = static_cast<wxControl*>(event.GetEventObject()); const auto* const control = static_cast<wxControl*>(event.GetEventObject());
auto* const pad_setting = static_cast<PadSettingCheckBox*>(control->GetClientData()); auto* const pad_setting = static_cast<PadSettingCheckBox*>(control->GetClientData());
@ -578,7 +577,7 @@ void GamepadPage::AdjustBooleanSetting(wxCommandEvent& event)
} }
} }
void GamepadPage::ConfigControl(wxEvent& event) void InputConfigDialog::ConfigControl(wxEvent& event)
{ {
m_control_dialog = new ControlDialog(this, m_config, m_control_dialog = new ControlDialog(this, m_config,
((ControlButton*)event.GetEventObject())->control_reference); ((ControlButton*)event.GetEventObject())->control_reference);
@ -589,7 +588,7 @@ void GamepadPage::ConfigControl(wxEvent& event)
UpdateGUI(); UpdateGUI();
} }
void GamepadPage::ClearControl(wxEvent& event) void InputConfigDialog::ClearControl(wxEvent& event)
{ {
ControlButton* const btn = (ControlButton*)event.GetEventObject(); ControlButton* const btn = (ControlButton*)event.GetEventObject();
btn->control_reference->expression.clear(); btn->control_reference->expression.clear();
@ -630,7 +629,7 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
} }
} }
void GamepadPage::DetectControl(wxCommandEvent& event) void InputConfigDialog::DetectControl(wxCommandEvent& event)
{ {
auto* btn = static_cast<ControlButton*>(event.GetEventObject()); auto* btn = static_cast<ControlButton*>(event.GetEventObject());
if (DetectButton(btn) && m_iterate) if (DetectButton(btn) && m_iterate)
@ -649,7 +648,7 @@ void GamepadPage::DetectControl(wxCommandEvent& event)
} }
} }
bool GamepadPage::DetectButton(ControlButton* button) bool InputConfigDialog::DetectButton(ControlButton* button)
{ {
bool success = false; bool success = false;
// find device :/ // find device :/
@ -687,7 +686,7 @@ bool GamepadPage::DetectButton(ControlButton* button)
return success; return success;
} }
wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent) wxStaticBoxSizer* ControlDialog::CreateControlChooser(InputConfigDialog* const parent)
{ {
wxStaticBoxSizer* const main_szr = new wxStaticBoxSizer( wxStaticBoxSizer* const main_szr = new wxStaticBoxSizer(
wxVERTICAL, this, control_reference->is_input ? _("Input") : _("Output")); wxVERTICAL, this, control_reference->is_input ? _("Input") : _("Output"));
@ -785,7 +784,7 @@ wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent)
return main_szr; return main_szr;
} }
void GamepadPage::GetProfilePath(std::string& path) void InputConfigDialog::GetProfilePath(std::string& path)
{ {
const wxString& name = profile_cbox->GetValue(); const wxString& name = profile_cbox->GetValue();
if (!name.empty()) if (!name.empty())
@ -801,10 +800,15 @@ void GamepadPage::GetProfilePath(std::string& path)
} }
} }
void GamepadPage::LoadProfile(wxCommandEvent&) ControllerEmu* InputConfigDialog::GetController() const
{
return controller;
}
void InputConfigDialog::LoadProfile(wxCommandEvent&)
{ {
std::string fname; std::string fname;
GamepadPage::GetProfilePath(fname); InputConfigDialog::GetProfilePath(fname);
if (!File::Exists(fname)) if (!File::Exists(fname))
return; return;
@ -818,10 +822,10 @@ void GamepadPage::LoadProfile(wxCommandEvent&)
UpdateGUI(); UpdateGUI();
} }
void GamepadPage::SaveProfile(wxCommandEvent&) void InputConfigDialog::SaveProfile(wxCommandEvent&)
{ {
std::string fname; std::string fname;
GamepadPage::GetProfilePath(fname); InputConfigDialog::GetProfilePath(fname);
File::CreateFullPath(fname); File::CreateFullPath(fname);
if (!fname.empty()) if (!fname.empty())
@ -830,7 +834,7 @@ void GamepadPage::SaveProfile(wxCommandEvent&)
controller->SaveConfig(inifile.GetOrCreateSection("Profile")); controller->SaveConfig(inifile.GetOrCreateSection("Profile"));
inifile.Save(fname); inifile.Save(fname);
m_config_dialog->UpdateProfileComboBox(); UpdateProfileComboBox();
} }
else else
{ {
@ -838,10 +842,10 @@ void GamepadPage::SaveProfile(wxCommandEvent&)
} }
} }
void GamepadPage::DeleteProfile(wxCommandEvent&) void InputConfigDialog::DeleteProfile(wxCommandEvent&)
{ {
std::string fname; std::string fname;
GamepadPage::GetProfilePath(fname); InputConfigDialog::GetProfilePath(fname);
const char* const fnamecstr = fname.c_str(); const char* const fnamecstr = fname.c_str();
@ -850,24 +854,21 @@ void GamepadPage::DeleteProfile(wxCommandEvent&)
{ {
File::Delete(fnamecstr); File::Delete(fnamecstr);
m_config_dialog->UpdateProfileComboBox(); UpdateProfileComboBox();
} }
} }
void InputConfigDialog::UpdateDeviceComboBox() void InputConfigDialog::UpdateDeviceComboBox()
{ {
for (GamepadPage* page : m_padpages) device_cbox->Clear();
{
page->device_cbox->Clear();
for (const std::string& device_string : g_controller_interface.GetAllDeviceStrings()) for (const std::string& device_string : g_controller_interface.GetAllDeviceStrings())
page->device_cbox->Append(StrToWxStr(device_string)); device_cbox->Append(StrToWxStr(device_string));
page->device_cbox->SetValue(StrToWxStr(page->controller->default_device.ToString())); device_cbox->SetValue(StrToWxStr(controller->default_device.ToString()));
}
} }
void GamepadPage::RefreshDevices(wxCommandEvent&) void InputConfigDialog::RefreshDevices(wxCommandEvent&)
{ {
bool was_unpaused = Core::PauseAndLock(true); bool was_unpaused = Core::PauseAndLock(true);
@ -875,10 +876,10 @@ void GamepadPage::RefreshDevices(wxCommandEvent&)
g_controller_interface.Reinitialize(); g_controller_interface.Reinitialize();
// update all control references // update all control references
m_config_dialog->UpdateControlReferences(); UpdateControlReferences();
// update device cbox // update device cbox
m_config_dialog->UpdateDeviceComboBox(); UpdateDeviceComboBox();
Wiimote::LoadConfig(); Wiimote::LoadConfig();
Keyboard::LoadConfig(); Keyboard::LoadConfig();
@ -897,8 +898,9 @@ ControlGroupBox::~ControlGroupBox()
} }
ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent,
GamepadPage* const eventsink) InputConfigDialog* eventsink)
: wxBoxSizer(wxVERTICAL), control_group(group), static_bitmap(nullptr), m_scale(1) : wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->ui_name))),
control_group(group), static_bitmap(nullptr), m_scale(1)
{ {
static constexpr std::array<const char* const, 2> exclude_buttons{{"Mic", "Modifier"}}; static constexpr std::array<const char* const, 2> exclude_buttons{{"Mic", "Modifier"}};
static constexpr std::array<const char* const, 7> exclude_groups{ static constexpr std::array<const char* const, 7> exclude_groups{
@ -929,16 +931,16 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
{ {
control_button->SetToolTip( control_button->SetToolTip(
_("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options.")); _("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
control_button->Bind(wxEVT_BUTTON, &GamepadPage::DetectControl, eventsink); control_button->Bind(wxEVT_BUTTON, &InputConfigDialog::DetectControl, eventsink);
} }
else else
{ {
control_button->SetToolTip(_("Left/Right-click for more options.\nMiddle-click to clear.")); control_button->SetToolTip(_("Left/Right-click for more options.\nMiddle-click to clear."));
control_button->Bind(wxEVT_BUTTON, &GamepadPage::ConfigControl, eventsink); control_button->Bind(wxEVT_BUTTON, &InputConfigDialog::ConfigControl, eventsink);
} }
control_button->Bind(wxEVT_MIDDLE_DOWN, &GamepadPage::ClearControl, eventsink); control_button->Bind(wxEVT_MIDDLE_DOWN, &InputConfigDialog::ClearControl, eventsink);
control_button->Bind(wxEVT_RIGHT_UP, &GamepadPage::ConfigControl, eventsink); control_button->Bind(wxEVT_RIGHT_UP, &InputConfigDialog::ConfigControl, eventsink);
control_grid->Add(label, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT); control_grid->Add(label, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
control_grid->Add(control_button, 0, wxALIGN_CENTER_VERTICAL); control_grid->Add(control_button, 0, wxALIGN_CENTER_VERTICAL);
@ -968,7 +970,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (auto& groupSetting : group->numeric_settings) for (auto& groupSetting : group->numeric_settings)
{ {
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get()); PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink); setting->wxcontrol->Bind(wxEVT_SPINCTRL, &InputConfigDialog::AdjustSetting, eventsink);
options.push_back(setting); options.push_back(setting);
szr->Add( szr->Add(
new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(groupSetting->m_name)))); new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(groupSetting->m_name))));
@ -977,7 +979,8 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (auto& groupSetting : group->boolean_settings) for (auto& groupSetting : group->boolean_settings)
{ {
auto* checkbox = new PadSettingCheckBox(parent, groupSetting.get()); auto* checkbox = new PadSettingCheckBox(parent, groupSetting.get());
checkbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustBooleanSetting, eventsink); checkbox->wxcontrol->Bind(wxEVT_CHECKBOX, &InputConfigDialog::AdjustBooleanSetting,
eventsink);
options.push_back(checkbox); options.push_back(checkbox);
Add(checkbox->wxcontrol, 0, wxALL | wxLEFT, space3); Add(checkbox->wxcontrol, 0, wxALL | wxLEFT, space3);
} }
@ -1010,7 +1013,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
wxBITMAP_TYPE_BMP); wxBITMAP_TYPE_BMP);
auto* const threshold_cbox = new PadSettingSpin(parent, group->numeric_settings[0].get()); auto* const threshold_cbox = new PadSettingSpin(parent, group->numeric_settings[0].get());
threshold_cbox->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink); threshold_cbox->wxcontrol->Bind(wxEVT_SPINCTRL, &InputConfigDialog::AdjustSetting, eventsink);
threshold_cbox->wxcontrol->SetToolTip( threshold_cbox->wxcontrol->SetToolTip(
_("Adjust the analog control pressure required to activate buttons.")); _("Adjust the analog control pressure required to activate buttons."));
@ -1057,7 +1060,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (auto& groupSetting : group->numeric_settings) for (auto& groupSetting : group->numeric_settings)
{ {
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get()); PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink); setting->wxcontrol->Bind(wxEVT_SPINCTRL, &InputConfigDialog::AdjustSetting, eventsink);
options.push_back(setting); options.push_back(setting);
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
szr->Add( szr->Add(
@ -1081,8 +1084,8 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
options.push_back(attachments); options.push_back(attachments);
attachments->wxcontrol->Bind(wxEVT_CHOICE, &GamepadPage::AdjustSetting, eventsink); attachments->wxcontrol->Bind(wxEVT_CHOICE, &InputConfigDialog::AdjustSetting, eventsink);
configure_btn->Bind(wxEVT_BUTTON, &GamepadPage::ConfigExtension, eventsink); configure_btn->Bind(wxEVT_BUTTON, &InputConfigDialog::ConfigExtension, eventsink);
AddSpacer(space3); AddSpacer(space3);
Add(attachments->wxcontrol, 0, wxEXPAND | wxLEFT | wxRIGHT, space3); Add(attachments->wxcontrol, 0, wxEXPAND | wxLEFT | wxRIGHT, space3);
@ -1096,7 +1099,8 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (auto& groupSetting : group->boolean_settings) for (auto& groupSetting : group->boolean_settings)
{ {
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, groupSetting.get()); PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, groupSetting.get());
setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustBooleanSetting, eventsink); setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &InputConfigDialog::AdjustBooleanSetting,
eventsink);
if (groupSetting->m_name == "Iterative Input") if (groupSetting->m_name == "Iterative Input")
groupSetting->SetValue(false); groupSetting->SetValue(false);
options.push_back(setting_cbox); options.push_back(setting_cbox);
@ -1106,7 +1110,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (auto& groupSetting : group->numeric_settings) for (auto& groupSetting : group->numeric_settings)
{ {
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get()); PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink); setting->wxcontrol->Bind(wxEVT_SPINCTRL, &InputConfigDialog::AdjustSetting, eventsink);
options.push_back(setting); options.push_back(setting);
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
szr->Add( szr->Add(
@ -1114,16 +1118,17 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
wxALIGN_CENTER_VERTICAL, space3); wxALIGN_CENTER_VERTICAL, space3);
szr->Add(setting->wxcontrol, 0, wxLEFT, space3); szr->Add(setting->wxcontrol, 0, wxLEFT, space3);
AddSpacer(space3); AddSpacer(space3);
Add(szr, 0, wxLEFT | wxRIGHT, space3); Add(szr, 0, wxLEFT | wxRIGHT | wxALIGN_RIGHT, space3);
} }
break; break;
} }
} }
AddSpacer(space3); AddSpacer(space3);
eventsink->control_groups.push_back(this);
} }
ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow* const parent, ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller,
GamepadPage* const eventsink, InputConfigDialog* const parent,
std::vector<ControlGroupBox*>* groups) std::vector<ControlGroupBox*>* groups)
: wxBoxSizer(wxHORIZONTAL) : wxBoxSizer(wxHORIZONTAL)
{ {
@ -1133,11 +1138,7 @@ ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow
wxBoxSizer* stacked_groups = nullptr; wxBoxSizer* stacked_groups = nullptr;
for (auto& group : controller->groups) for (auto& group : controller->groups)
{ {
wxStaticBoxSizer* control_group = ControlGroupBox* control_group_box = new ControlGroupBox(group.get(), parent, parent);
new wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->ui_name)));
ControlGroupBox* control_group_box =
new ControlGroupBox(group.get(), control_group->GetStaticBox(), eventsink);
control_group->Add(control_group_box, 0, wxEXPAND);
const size_t grp_size = const size_t grp_size =
group->controls.size() + group->numeric_settings.size() + group->boolean_settings.size(); group->controls.size() + group->numeric_settings.size() + group->boolean_settings.size();
@ -1151,13 +1152,13 @@ ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow
} }
stacked_groups = new wxBoxSizer(wxVERTICAL); stacked_groups = new wxBoxSizer(wxVERTICAL);
stacked_groups->Add(control_group, 0, wxEXPAND); stacked_groups->Add(control_group_box, 0, wxEXPAND);
col_size = grp_size; col_size = grp_size;
} }
else else
{ {
stacked_groups->Add(control_group, 0, wxEXPAND); stacked_groups->Add(control_group_box, 0, wxEXPAND);
} }
if (groups) if (groups)
@ -1168,16 +1169,9 @@ ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow
Add(stacked_groups, 0, wxBOTTOM, space5); Add(stacked_groups, 0, wxBOTTOM, space5);
} }
GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const int pad_num, wxBoxSizer* InputConfigDialog::CreateDeviceChooserGroupBox()
InputConfigDialog* const config_dialog)
: wxPanel(parent, wxID_ANY), controller(config.GetController(pad_num)),
m_config_dialog(config_dialog), m_config(config)
{ {
wxBoxSizer* control_group_sizer = new ControlGroupsSizer(controller, this, this, &control_groups);
const int space3 = FromDIP(3); const int space3 = FromDIP(3);
const int space5 = FromDIP(5);
// device chooser
wxStaticBoxSizer* const device_sbox = new wxStaticBoxSizer(wxVERTICAL, this, _("Device")); wxStaticBoxSizer* const device_sbox = new wxStaticBoxSizer(wxVERTICAL, this, _("Device"));
device_cbox = new wxComboBox(device_sbox->GetStaticBox(), wxID_ANY, ""); device_cbox = new wxComboBox(device_sbox->GetStaticBox(), wxID_ANY, "");
@ -1186,9 +1180,9 @@ GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const int pad_nu
wxButton* refresh_button = new wxButton(device_sbox->GetStaticBox(), wxID_ANY, _("Refresh"), wxButton* refresh_button = new wxButton(device_sbox->GetStaticBox(), wxID_ANY, _("Refresh"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
device_cbox->Bind(wxEVT_COMBOBOX, &GamepadPage::SetDevice, this); device_cbox->Bind(wxEVT_COMBOBOX, &InputConfigDialog::SetDevice, this);
device_cbox->Bind(wxEVT_TEXT_ENTER, &GamepadPage::SetDevice, this); device_cbox->Bind(wxEVT_TEXT_ENTER, &InputConfigDialog::SetDevice, this);
refresh_button->Bind(wxEVT_BUTTON, &GamepadPage::RefreshDevices, this); refresh_button->Bind(wxEVT_BUTTON, &InputConfigDialog::RefreshDevices, this);
wxBoxSizer* const device_sbox_in = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* const device_sbox_in = new wxBoxSizer(wxHORIZONTAL);
device_sbox_in->Add(WxUtils::GiveMinSizeDIP(device_cbox, wxSize(64, -1)), 1, device_sbox_in->Add(WxUtils::GiveMinSizeDIP(device_cbox, wxSize(64, -1)), 1,
@ -1196,25 +1190,32 @@ GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const int pad_nu
device_sbox_in->Add(refresh_button, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space3); device_sbox_in->Add(refresh_button, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space3);
device_sbox->Add(device_sbox_in, 1, wxEXPAND | wxLEFT | wxRIGHT, space3); device_sbox->Add(device_sbox_in, 1, wxEXPAND | wxLEFT | wxRIGHT, space3);
device_sbox->AddSpacer(space3); device_sbox->AddSpacer(space3);
return device_sbox;
}
// Clear / Reset buttons wxBoxSizer* InputConfigDialog::CreaterResetGroupBox(wxOrientation orientation)
wxStaticBoxSizer* const clear_sbox = new wxStaticBoxSizer(wxVERTICAL, this, _("Reset")); {
const int space3 = FromDIP(3);
wxStaticBoxSizer* const clear_sbox = new wxStaticBoxSizer(orientation, this, _("Reset"));
wxButton* const default_button = new wxButton(clear_sbox->GetStaticBox(), wxID_ANY, _("Default"), wxButton* const default_button = new wxButton(clear_sbox->GetStaticBox(), wxID_ANY, _("Default"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
wxButton* const clearall_button = new wxButton(clear_sbox->GetStaticBox(), wxID_ANY, _("Clear"), wxButton* const clearall_button = new wxButton(clear_sbox->GetStaticBox(), wxID_ANY, _("Clear"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
wxBoxSizer* clear_sbox_in = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* clear_sbox_in = new wxBoxSizer(orientation);
clear_sbox_in->Add(default_button, 1, wxALIGN_CENTER_VERTICAL); clear_sbox_in->Add(default_button, 1, wxEXPAND);
clear_sbox_in->Add(clearall_button, 1, wxALIGN_CENTER_VERTICAL); clear_sbox_in->Add(clearall_button, 1, wxEXPAND);
clear_sbox->Add(clear_sbox_in, 1, wxEXPAND | wxLEFT | wxRIGHT, space3); clear_sbox->Add(clear_sbox_in, 1, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, space3);
clear_sbox->AddSpacer(space3);
clearall_button->Bind(wxEVT_BUTTON, &GamepadPage::ClearAll, this); clearall_button->Bind(wxEVT_BUTTON, &InputConfigDialog::ClearAll, this);
default_button->Bind(wxEVT_BUTTON, &GamepadPage::LoadDefaults, this); default_button->Bind(wxEVT_BUTTON, &InputConfigDialog::LoadDefaults, this);
return clear_sbox;
}
// Profile selector wxBoxSizer* InputConfigDialog::CreateProfileChooserGroupBox()
{
const int space3 = FromDIP(3);
wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer(wxVERTICAL, this, _("Profile")); wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer(wxVERTICAL, this, _("Profile"));
profile_cbox = new wxComboBox(profile_sbox->GetStaticBox(), wxID_ANY, ""); profile_cbox = new wxComboBox(profile_sbox->GetStaticBox(), wxID_ANY, "");
@ -1225,9 +1226,9 @@ GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const int pad_nu
wxButton* const pdelete_btn = new wxButton(profile_sbox->GetStaticBox(), wxID_ANY, _("Delete"), wxButton* const pdelete_btn = new wxButton(profile_sbox->GetStaticBox(), wxID_ANY, _("Delete"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT); wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
pload_btn->Bind(wxEVT_BUTTON, &GamepadPage::LoadProfile, this); pload_btn->Bind(wxEVT_BUTTON, &InputConfigDialog::LoadProfile, this);
psave_btn->Bind(wxEVT_BUTTON, &GamepadPage::SaveProfile, this); psave_btn->Bind(wxEVT_BUTTON, &InputConfigDialog::SaveProfile, this);
pdelete_btn->Bind(wxEVT_BUTTON, &GamepadPage::DeleteProfile, this); pdelete_btn->Bind(wxEVT_BUTTON, &InputConfigDialog::DeleteProfile, this);
wxBoxSizer* profile_sbox_in = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* profile_sbox_in = new wxBoxSizer(wxHORIZONTAL);
profile_sbox_in->Add(WxUtils::GiveMinSizeDIP(profile_cbox, wxSize(64, -1)), 1, profile_sbox_in->Add(WxUtils::GiveMinSizeDIP(profile_cbox, wxSize(64, -1)), 1,
@ -1238,55 +1239,19 @@ GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const int pad_nu
profile_sbox_in->Add(pdelete_btn, 0, wxALIGN_CENTER_VERTICAL); profile_sbox_in->Add(pdelete_btn, 0, wxALIGN_CENTER_VERTICAL);
profile_sbox->Add(profile_sbox_in, 1, wxEXPAND | wxLEFT | wxRIGHT, space3); profile_sbox->Add(profile_sbox_in, 1, wxEXPAND | wxLEFT | wxRIGHT, space3);
profile_sbox->AddSpacer(space3); profile_sbox->AddSpacer(space3);
return profile_sbox;
wxBoxSizer* const dio = new wxBoxSizer(wxHORIZONTAL); }
dio->Add(device_sbox, 1, wxEXPAND);
dio->Add(clear_sbox, 0, wxEXPAND | wxLEFT, space5);
dio->Add(profile_sbox, 1, wxEXPAND | wxLEFT, space5);
wxBoxSizer* const mapping = new wxBoxSizer(wxVERTICAL);
mapping->AddSpacer(space5);
mapping->Add(dio, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
mapping->AddSpacer(space5);
mapping->Add(control_group_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
UpdateGUI();
SetSizerAndFit(mapping); // needed
Layout();
};
InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputConfig& config, InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputConfig& config,
const wxString& name, const int tab_num) const wxString& name, const int port_num)
: wxDialog(parent, wxID_ANY, name), m_config(config) : wxDialog(parent, wxID_ANY, name), controller(config.GetController(port_num)),
m_config(config), m_port_num(port_num)
{ {
m_pad_notebook = new wxNotebook(this, wxID_ANY);
GamepadPage* gp = new GamepadPage(m_pad_notebook, m_config, tab_num, this);
m_padpages.push_back(gp);
m_pad_notebook->AddPage(gp, wxString::Format("%s [%u]",
wxGetTranslation(StrToWxStr(m_config.GetGUIName())),
1 + tab_num));
m_pad_notebook->SetSelection(0);
UpdateDeviceComboBox();
UpdateProfileComboBox();
Bind(wxEVT_CLOSE_WINDOW, &InputConfigDialog::OnClose, this); Bind(wxEVT_CLOSE_WINDOW, &InputConfigDialog::OnClose, this);
Bind(wxEVT_BUTTON, &InputConfigDialog::OnCloseButton, this, wxID_CLOSE); Bind(wxEVT_BUTTON, &InputConfigDialog::OnCloseButton, this, wxID_CLOSE);
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
const int space5 = FromDIP(5);
szr->AddSpacer(space5);
szr->Add(m_pad_notebook, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr->AddSpacer(space5);
szr->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr->AddSpacer(space5);
SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED); SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED);
SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER); SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER);
SetSizerAndFit(szr);
Center();
// live preview update timer // live preview update timer
m_update_timer.SetOwner(this); m_update_timer.SetOwner(this);

View File

@ -31,7 +31,6 @@ class DolphinSlider;
class InputConfig; class InputConfig;
class wxComboBox; class wxComboBox;
class wxListBox; class wxListBox;
class wxNotebook;
class wxStaticBitmap; class wxStaticBitmap;
class wxStaticText; class wxStaticText;
class wxTextCtrl; class wxTextCtrl;
@ -100,12 +99,12 @@ private:
bool m_block = false; bool m_block = false;
}; };
class GamepadPage; class InputConfigDialog;
class ControlDialog : public wxDialog class ControlDialog : public wxDialog
{ {
public: public:
ControlDialog(GamepadPage* const parent, InputConfig& config, ControlDialog(InputConfigDialog* const parent, InputConfig& config,
ControllerInterface::ControlReference* const ref); ControllerInterface::ControlReference* const ref);
bool Validate() override; bool Validate() override;
@ -116,7 +115,7 @@ public:
InputConfig& m_config; InputConfig& m_config;
private: private:
wxStaticBoxSizer* CreateControlChooser(GamepadPage* const parent); wxStaticBoxSizer* CreateControlChooser(InputConfigDialog* parent);
void UpdateGUI(); void UpdateGUI();
void UpdateListContents(); void UpdateListContents();
@ -134,7 +133,7 @@ private:
bool GetExpressionForSelectedControl(wxString& expr); bool GetExpressionForSelectedControl(wxString& expr);
GamepadPage* const m_parent; InputConfigDialog* m_parent;
wxComboBox* device_cbox; wxComboBox* device_cbox;
wxTextCtrl* textctrl; wxTextCtrl* textctrl;
wxListBox* control_lbox; wxListBox* control_lbox;
@ -172,11 +171,11 @@ protected:
int m_configured_width = wxDefaultCoord; int m_configured_width = wxDefaultCoord;
}; };
class ControlGroupBox : public wxBoxSizer class ControlGroupBox : public wxStaticBoxSizer
{ {
public: public:
ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent, ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent,
GamepadPage* const eventsink); InputConfigDialog* eventsink);
~ControlGroupBox(); ~ControlGroupBox();
bool HasBitmapHeading() const bool HasBitmapHeading() const
@ -196,21 +195,25 @@ public:
class ControlGroupsSizer : public wxBoxSizer class ControlGroupsSizer : public wxBoxSizer
{ {
public: public:
ControlGroupsSizer(ControllerEmu* const controller, wxWindow* const parent, ControlGroupsSizer(ControllerEmu* const controller, InputConfigDialog* const parent,
GamepadPage* const eventsink,
std::vector<ControlGroupBox*>* const groups = nullptr); std::vector<ControlGroupBox*>* const groups = nullptr);
}; };
class InputConfigDialog; class InputConfigDialog : public wxDialog
class GamepadPage : public wxPanel
{ {
friend class InputConfigDialog;
friend class ControlDialog;
public: public:
GamepadPage(wxWindow* parent, InputConfig& config, const int pad_num, InputConfigDialog(wxWindow* const parent, InputConfig& config, const wxString& name,
InputConfigDialog* const config_dialog); const int port_num = 0);
virtual ~InputConfigDialog() = default;
void OnClose(wxCloseEvent& event);
void OnCloseButton(wxCommandEvent& event);
void UpdateDeviceComboBox();
void UpdateProfileComboBox();
void UpdateControlReferences();
void UpdateBitmaps(wxTimerEvent&);
void UpdateGUI(); void UpdateGUI();
@ -238,44 +241,29 @@ public:
void AdjustBooleanSetting(wxCommandEvent& event); void AdjustBooleanSetting(wxCommandEvent& event);
void GetProfilePath(std::string& path); void GetProfilePath(std::string& path);
ControllerEmu* GetController() const;
wxComboBox* profile_cbox; wxComboBox* profile_cbox = nullptr;
wxComboBox* device_cbox; wxComboBox* device_cbox = nullptr;
std::vector<ControlGroupBox*> control_groups; std::vector<ControlGroupBox*> control_groups;
std::vector<ControlButton*> control_buttons; std::vector<ControlButton*> control_buttons;
protected: protected:
wxBoxSizer* CreateDeviceChooserGroupBox();
wxBoxSizer* CreaterResetGroupBox(wxOrientation orientation);
wxBoxSizer* CreateProfileChooserGroupBox();
ControllerEmu* const controller; ControllerEmu* const controller;
wxTimer m_update_timer;
private: private:
ControlDialog* m_control_dialog;
InputConfigDialog* const m_config_dialog;
InputConfig& m_config; InputConfig& m_config;
int m_port_num;
ControlDialog* m_control_dialog;
InputEventFilter m_event_filter; InputEventFilter m_event_filter;
bool DetectButton(ControlButton* button); bool DetectButton(ControlButton* button);
bool m_iterate = false; bool m_iterate = false;
}; };
class InputConfigDialog : public wxDialog
{
public:
InputConfigDialog(wxWindow* const parent, InputConfig& config, const wxString& name,
const int tab_num = 0);
void OnClose(wxCloseEvent& event);
void OnCloseButton(wxCommandEvent& event);
void UpdateDeviceComboBox();
void UpdateProfileComboBox();
void UpdateControlReferences();
void UpdateBitmaps(wxTimerEvent&);
private:
wxNotebook* m_pad_notebook;
std::vector<GamepadPage*> m_padpages;
InputConfig& m_config;
wxTimer m_update_timer;
};

View File

@ -19,7 +19,7 @@
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/statbmp.h> #include <wx/statbmp.h>
#include "DolphinWX/InputConfigDiag.h" #include "DolphinWX/Input/InputConfigDiag.h"
#include "DolphinWX/WxUtils.h" #include "DolphinWX/WxUtils.h"
#include "InputCommon/ControllerEmu.h" #include "InputCommon/ControllerEmu.h"
@ -487,12 +487,9 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
g_controller_interface.UpdateInput(); g_controller_interface.UpdateInput();
GamepadPage* const current_page =
static_cast<GamepadPage*>(m_pad_notebook->GetPage(m_pad_notebook->GetSelection()));
wxMemoryDC dc; wxMemoryDC dc;
auto lock = ControllerEmu::GetStateLock(); auto lock = ControllerEmu::GetStateLock();
for (ControlGroupBox* g : current_page->control_groups) for (ControlGroupBox* g : control_groups)
{ {
// Only if this control group has a bitmap // Only if this control group has a bitmap
if (!g->static_bitmap) if (!g->static_bitmap)

View File

@ -193,8 +193,8 @@ ControllerEmu::Buttons::Buttons(const std::string& _name)
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5)); numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
} }
ControllerEmu::Buttons::Buttons(const std::string& _name, const std::string& _ui_name) ControllerEmu::Buttons::Buttons(const std::string& ini_name, const std::string& group_name)
: ControlGroup(_name, _ui_name, GROUP_TYPE_BUTTONS) : ControlGroup(ini_name, group_name, GROUP_TYPE_BUTTONS)
{ {
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5)); numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
} }

View File

@ -204,7 +204,7 @@ public:
{ {
public: public:
Buttons(const std::string& _name); Buttons(const std::string& _name);
Buttons(const std::string& _name, const std::string& _ui_name); Buttons(const std::string& ini_name, const std::string& group_name);
template <typename C> template <typename C>
void GetState(C* const buttons, const C* bitmasks) void GetState(C* const buttons, const C* bitmasks)