mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-24 19:14:40 +00:00
Network config (#3292)
* Config entry isConnectedToNetwork * Respect Config::isConnectedToNetwork when returning connection state * Return connection status in NetCtlGetInfo * Print connection data in log
This commit is contained in:
parent
4d3578edbe
commit
ea37ea11fc
@ -47,6 +47,7 @@ static bool isShowSplash = false;
|
||||
static std::string isSideTrophy = "right";
|
||||
static bool compatibilityData = false;
|
||||
static bool checkCompatibilityOnStartup = false;
|
||||
static bool isConnectedToNetwork = false;
|
||||
|
||||
// Input
|
||||
static int cursorState = HideCursorState::Idle;
|
||||
@ -358,6 +359,10 @@ bool getCheckCompatibilityOnStartup() {
|
||||
return checkCompatibilityOnStartup;
|
||||
}
|
||||
|
||||
bool getIsConnectedToNetwork() {
|
||||
return isConnectedToNetwork;
|
||||
}
|
||||
|
||||
void setGpuId(s32 selectedGpuId) {
|
||||
gpuId = selectedGpuId;
|
||||
}
|
||||
@ -643,6 +648,9 @@ void load(const std::filesystem::path& path) {
|
||||
compatibilityData = toml::find_or<bool>(general, "compatibilityEnabled", compatibilityData);
|
||||
checkCompatibilityOnStartup = toml::find_or<bool>(general, "checkCompatibilityOnStartup",
|
||||
checkCompatibilityOnStartup);
|
||||
|
||||
isConnectedToNetwork =
|
||||
toml::find_or<bool>(general, "isConnectedToNetwork", isConnectedToNetwork);
|
||||
chooseHomeTab = toml::find_or<std::string>(general, "chooseHomeTab", chooseHomeTab);
|
||||
}
|
||||
|
||||
@ -824,6 +832,7 @@ void save(const std::filesystem::path& path) {
|
||||
data["General"]["sideTrophy"] = isSideTrophy;
|
||||
data["General"]["compatibilityEnabled"] = compatibilityData;
|
||||
data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup;
|
||||
data["General"]["isConnectedToNetwork"] = isConnectedToNetwork;
|
||||
data["Input"]["cursorState"] = cursorState;
|
||||
data["Input"]["cursorHideTimeout"] = cursorHideTimeout;
|
||||
data["Input"]["useSpecialPad"] = useSpecialPad;
|
||||
@ -922,6 +931,7 @@ void setDefaultValues() {
|
||||
isSideTrophy = "right";
|
||||
compatibilityData = false;
|
||||
checkCompatibilityOnStartup = false;
|
||||
isConnectedToNetwork = false;
|
||||
|
||||
// Input
|
||||
cursorState = HideCursorState::Idle;
|
||||
|
@ -113,6 +113,7 @@ std::filesystem::path GetSaveDataPath();
|
||||
void setLoadGameSizeEnabled(bool enable);
|
||||
bool getCompatibilityEnabled();
|
||||
bool getCheckCompatibilityOnStartup();
|
||||
bool getIsConnectedToNetwork();
|
||||
std::string getUserName();
|
||||
std::string getChooseHomeTab();
|
||||
bool GetUseUnifiedInputConfig();
|
||||
|
@ -2,6 +2,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
#include "common/config.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/libraries/network/net_ctl_codes.h"
|
||||
#include "core/libraries/network/net_ctl_obj.h"
|
||||
#include "core/tls.h"
|
||||
@ -44,18 +46,22 @@ s32 NetCtlInternal::RegisterNpToolkitCallback(OrbisNetCtlCallbackForNpToolkit fu
|
||||
|
||||
void NetCtlInternal::CheckCallback() {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
const auto event = Config::getIsConnectedToNetwork() ? ORBIS_NET_CTL_EVENT_TYPE_IPOBTAINED
|
||||
: ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED;
|
||||
for (const auto [func, arg] : callbacks) {
|
||||
if (func != nullptr) {
|
||||
Core::ExecuteGuest(func, ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED, arg);
|
||||
Core::ExecuteGuest(func, event, arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NetCtlInternal::CheckNpToolkitCallback() {
|
||||
std::scoped_lock lock{m_mutex};
|
||||
const auto event = Config::getIsConnectedToNetwork() ? ORBIS_NET_CTL_EVENT_TYPE_IPOBTAINED
|
||||
: ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED;
|
||||
for (const auto [func, arg] : nptool_callbacks) {
|
||||
if (func != nullptr) {
|
||||
Core::ExecuteGuest(func, ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED, arg);
|
||||
Core::ExecuteGuest(func, event, arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#endif
|
||||
|
||||
#include <common/singleton.h>
|
||||
#include "common/config.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/libraries/error_codes.h"
|
||||
#include "core/libraries/libs.h"
|
||||
@ -160,6 +161,8 @@ int PS4_SYSV_ABI sceNetCtlGetIfStat() {
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) {
|
||||
LOG_DEBUG(Lib_NetCtl, "code = {}", code);
|
||||
|
||||
switch (code) {
|
||||
case ORBIS_NET_CTL_INFO_DEVICE:
|
||||
info->device = ORBIS_NET_CTL_DEVICE_WIRED;
|
||||
@ -173,7 +176,8 @@ int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) {
|
||||
info->mtu = 1500; // default value
|
||||
break;
|
||||
case ORBIS_NET_CTL_INFO_LINK:
|
||||
info->link = ORBIS_NET_CTL_LINK_DISCONNECTED;
|
||||
info->link = Config::getIsConnectedToNetwork() ? ORBIS_NET_CTL_LINK_CONNECTED
|
||||
: ORBIS_NET_CTL_LINK_DISCONNECTED;
|
||||
break;
|
||||
case ORBIS_NET_CTL_INFO_IP_ADDRESS: {
|
||||
strcpy(info->ip_address,
|
||||
@ -271,7 +275,11 @@ int PS4_SYSV_ABI sceNetCtlGetScanInfoForSsidScanIpcInt() {
|
||||
}
|
||||
|
||||
int PS4_SYSV_ABI sceNetCtlGetState(int* state) {
|
||||
*state = ORBIS_NET_CTL_STATE_DISCONNECTED;
|
||||
const auto connected = Config::getIsConnectedToNetwork();
|
||||
LOG_DEBUG(Lib_NetCtl, "connected = {}", connected);
|
||||
const auto current_state =
|
||||
connected ? ORBIS_NET_CTL_STATE_IPOBTAINED : ORBIS_NET_CTL_STATE_DISCONNECTED;
|
||||
*state = current_state;
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
||||
|
@ -134,6 +134,8 @@ void Emulator::Run(std::filesystem::path file, const std::vector<std::string> ar
|
||||
|
||||
LOG_INFO(Config, "General LogType: {}", Config::getLogType());
|
||||
LOG_INFO(Config, "General isNeo: {}", Config::isNeoModeConsole());
|
||||
LOG_INFO(Config, "General isConnectedToNetwork: {}", Config::getIsConnectedToNetwork());
|
||||
LOG_INFO(Config, "General isPsnSignedIn: {}", Config::getPSNSignedIn());
|
||||
LOG_INFO(Config, "GPU isNullGpu: {}", Config::nullGpu());
|
||||
LOG_INFO(Config, "GPU readbacks: {}", Config::readbacks());
|
||||
LOG_INFO(Config, "GPU readbackLinearImages: {}", Config::readbackLinearImages());
|
||||
|
Loading…
Reference in New Issue
Block a user