diff options
| author | iwubcode <iwubcode@users.noreply.github.com> | 2020-07-13 00:26:43 -0500 |
|---|---|---|
| committer | iwubcode <iwubcode@users.noreply.github.com> | 2020-07-17 14:53:39 -0500 |
| commit | 97c9cf3e21460a2292c108e676703cdeb826a22f (patch) | |
| tree | 0fafee82afb9876edd225573e8479a02b03c740d /Source/Core/InputCommon/ControllerInterface | |
| parent | 58aa0150e1d3d391d5fd4e04ab402afb10a60fcc (diff) | |
DolphinQt / InputCommon - add DSU string validator to avoid crashes, limited backwards compatibility support
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp | 18 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.h | 4 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp index 837be2c3df..371db4219c 100644 --- a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.cpp @@ -30,6 +30,9 @@ namespace ciface::DualShockUDPClient { namespace Settings { +const Config::Info<std::string> SERVER_ADDRESS{ + {Config::System::DualShockUDPClient, "Server", "IPAddress"}, ""}; +const Config::Info<int> SERVER_PORT{{Config::System::DualShockUDPClient, "Server", "Port"}, 0}; const Config::Info<std::string> SERVERS{{Config::System::DualShockUDPClient, "Server", "Entries"}, ""}; const Config::Info<bool> SERVERS_ENABLED{{Config::System::DualShockUDPClient, "Server", "Enabled"}, @@ -361,6 +364,21 @@ static void ConfigChanged() void Init() { + // The following is added for backwards compatibility + const auto server_address_setting = Config::Get(Settings::SERVER_ADDRESS); + const auto server_port_setting = Config::Get(Settings::SERVER_PORT); + + if (!server_address_setting.empty() && server_port_setting != 0) + { + const auto& servers_setting = Config::Get(ciface::DualShockUDPClient::Settings::SERVERS); + Config::SetBaseOrCurrent(ciface::DualShockUDPClient::Settings::SERVERS, + servers_setting + fmt::format("{}:{}:{};", "DS4", + server_address_setting, + server_port_setting)); + Config::SetBase(Settings::SERVER_ADDRESS, ""); + Config::SetBase(Settings::SERVER_PORT, 0); + } + Config::AddConfigChangedCallback(ConfigChanged); } diff --git a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.h b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.h index e7a9057569..2442634783 100644 --- a/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.h +++ b/Source/Core/InputCommon/ControllerInterface/DualShockUDPClient/DualShockUDPClient.h @@ -13,6 +13,10 @@ constexpr u16 DEFAULT_SERVER_PORT = 26760; namespace Settings { +// These two kept for backwards compatibility +extern const Config::Info<std::string> SERVER_ADDRESS; +extern const Config::Info<int> SERVER_PORT; + extern const Config::Info<std::string> SERVERS; extern const Config::Info<bool> SERVERS_ENABLED; } // namespace Settings |
