Compare commits
11 Commits
__refs_pul
...
__refs_pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21ecf01a17 | ||
|
|
04352a9aef | ||
|
|
48dec7e0c9 | ||
|
|
b5f99164f1 | ||
|
|
eb4ddb2868 | ||
|
|
9d7eebde7b | ||
|
|
8fb9f78e83 | ||
|
|
baad1238c3 | ||
|
|
7bec8d1c5b | ||
|
|
bdd09d6844 | ||
|
|
531572b411 |
@@ -282,7 +282,7 @@ void Config::ReadValues() {
|
||||
std::stringstream ss(title_list);
|
||||
std::string line;
|
||||
while (std::getline(ss, line, '|')) {
|
||||
const auto title_id = std::strtoul(line.c_str(), nullptr, 16);
|
||||
const auto title_id = std::stoul(line, nullptr, 16);
|
||||
const auto disabled_list = config->Get("AddOns", "disabled_" + line, "");
|
||||
|
||||
std::stringstream inner_ss(disabled_list);
|
||||
|
||||
@@ -528,38 +528,41 @@ void IterateDirEntriesRecursively(const std::filesystem::path& path,
|
||||
// Generic Filesystem Operations
|
||||
|
||||
bool Exists(const fs::path& path) {
|
||||
std::error_code ec;
|
||||
#ifdef ANDROID
|
||||
if (Android::IsContentUri(path)) {
|
||||
return Android::Exists(path);
|
||||
} else {
|
||||
return fs::exists(path);
|
||||
return fs::exists(path, ec);
|
||||
}
|
||||
#else
|
||||
return fs::exists(path);
|
||||
return fs::exists(path, ec);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsFile(const fs::path& path) {
|
||||
std::error_code ec;
|
||||
#ifdef ANDROID
|
||||
if (Android::IsContentUri(path)) {
|
||||
return !Android::IsDirectory(path);
|
||||
} else {
|
||||
return fs::is_regular_file(path);
|
||||
return fs::is_regular_file(path, ec);
|
||||
}
|
||||
#else
|
||||
return fs::is_regular_file(path);
|
||||
return fs::is_regular_file(path, ec);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool IsDir(const fs::path& path) {
|
||||
std::error_code ec;
|
||||
#ifdef ANDROID
|
||||
if (Android::IsContentUri(path)) {
|
||||
return Android::IsDirectory(path);
|
||||
} else {
|
||||
return fs::is_directory(path);
|
||||
return fs::is_directory(path, ec);
|
||||
}
|
||||
#else
|
||||
return fs::is_directory(path);
|
||||
return fs::is_directory(path, ec);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
|
||||
SUB(Service, NCM) \
|
||||
SUB(Service, NFC) \
|
||||
SUB(Service, NFP) \
|
||||
SUB(Service, NGCT) \
|
||||
SUB(Service, NGC) \
|
||||
SUB(Service, NIFM) \
|
||||
SUB(Service, NIM) \
|
||||
SUB(Service, NOTIF) \
|
||||
|
||||
@@ -80,7 +80,7 @@ enum class Class : u8 {
|
||||
Service_NCM, ///< The NCM service
|
||||
Service_NFC, ///< The NFC (Near-field communication) service
|
||||
Service_NFP, ///< The NFP service
|
||||
Service_NGCT, ///< The NGCT (No Good Content for Terra) service
|
||||
Service_NGC, ///< The NGC (No Good Content) service
|
||||
Service_NIFM, ///< The NIFM (Network interface) service
|
||||
Service_NIM, ///< The NIM service
|
||||
Service_NOTIF, ///< The NOTIF (Notification) service
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
namespace Common {
|
||||
|
||||
template <typename Condvar, typename Lock, typename Pred>
|
||||
void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred&& pred) {
|
||||
cv.wait(lock, token, std::move(pred));
|
||||
void CondvarWait(Condvar& cv, std::unique_lock<Lock>& lk, std::stop_token token, Pred&& pred) {
|
||||
cv.wait(lk, token, std::move(pred));
|
||||
}
|
||||
|
||||
template <typename Rep, typename Period>
|
||||
@@ -332,13 +332,17 @@ private:
|
||||
namespace Common {
|
||||
|
||||
template <typename Condvar, typename Lock, typename Pred>
|
||||
void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred pred) {
|
||||
void CondvarWait(Condvar& cv, std::unique_lock<Lock>& lk, std::stop_token token, Pred pred) {
|
||||
if (token.stop_requested()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::stop_callback callback(token, [&] { cv.notify_all(); });
|
||||
cv.wait(lock, [&] { return pred() || token.stop_requested(); });
|
||||
std::stop_callback callback(token, [&] {
|
||||
{ std::scoped_lock lk2{*lk.mutex()}; }
|
||||
cv.notify_all();
|
||||
});
|
||||
|
||||
cv.wait(lk, [&] { return pred() || token.stop_requested(); });
|
||||
}
|
||||
|
||||
template <typename Rep, typename Period>
|
||||
@@ -353,8 +357,10 @@ bool StoppableTimedWait(std::stop_token token, const std::chrono::duration<Rep,
|
||||
|
||||
std::stop_callback cb(token, [&] {
|
||||
// Wake up the waiting thread.
|
||||
std::unique_lock lk{m};
|
||||
stop_requested = true;
|
||||
{
|
||||
std::scoped_lock lk{m};
|
||||
stop_requested = true;
|
||||
}
|
||||
cv.notify_one();
|
||||
});
|
||||
|
||||
|
||||
@@ -225,16 +225,6 @@ public:
|
||||
*/
|
||||
[[nodiscard]] virtual constexpr u32 EnumIndex() const = 0;
|
||||
|
||||
/**
|
||||
* @returns True if the underlying type is a floating point storage
|
||||
*/
|
||||
[[nodiscard]] virtual constexpr bool IsFloatingPoint() const = 0;
|
||||
|
||||
/**
|
||||
* @returns True if the underlying type is an integer storage
|
||||
*/
|
||||
[[nodiscard]] virtual constexpr bool IsIntegral() const = 0;
|
||||
|
||||
/*
|
||||
* Switchable settings
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <string>
|
||||
#include <typeindex>
|
||||
#include <typeinfo>
|
||||
#include <fmt/core.h>
|
||||
#include "common/common_types.h"
|
||||
#include "common/settings_common.h"
|
||||
#include "common/settings_enums.h"
|
||||
@@ -116,12 +115,8 @@ protected:
|
||||
} else if constexpr (std::is_same_v<Type, AudioEngine>) {
|
||||
// Compatibility with old AudioEngine setting being a string
|
||||
return CanonicalizeEnum(value_);
|
||||
} else if constexpr (std::is_floating_point_v<Type>) {
|
||||
return fmt::format("{:f}", value_);
|
||||
} else if constexpr (std::is_enum_v<Type>) {
|
||||
return std::to_string(static_cast<u32>(value_));
|
||||
} else {
|
||||
return std::to_string(value_);
|
||||
return std::to_string(static_cast<u64>(value_));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,15 +180,13 @@ public:
|
||||
this->SetValue(static_cast<u32>(std::stoul(input)));
|
||||
} else if constexpr (std::is_same_v<Type, bool>) {
|
||||
this->SetValue(input == "true");
|
||||
} else if constexpr (std::is_same_v<Type, float>) {
|
||||
this->SetValue(std::stof(input));
|
||||
} else if constexpr (std::is_same_v<Type, AudioEngine>) {
|
||||
this->SetValue(ToEnum<Type>(input));
|
||||
} else {
|
||||
this->SetValue(static_cast<Type>(std::stoll(input)));
|
||||
}
|
||||
} catch (std::invalid_argument&) {
|
||||
this->SetValue(this->GetDefault());
|
||||
} catch (std::out_of_range&) {
|
||||
this->SetValue(this->GetDefault());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,27 +215,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool IsFloatingPoint() const final {
|
||||
return std::is_floating_point_v<Type>;
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool IsIntegral() const final {
|
||||
return std::is_integral_v<Type>;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string MinVal() const override final {
|
||||
if constexpr (std::is_arithmetic_v<Type> && !ranged) {
|
||||
return this->ToString(std::numeric_limits<Type>::min());
|
||||
} else {
|
||||
return this->ToString(minimum);
|
||||
}
|
||||
return this->ToString(minimum);
|
||||
}
|
||||
[[nodiscard]] std::string MaxVal() const override final {
|
||||
if constexpr (std::is_arithmetic_v<Type> && !ranged) {
|
||||
return this->ToString(std::numeric_limits<Type>::max());
|
||||
} else {
|
||||
return this->ToString(maximum);
|
||||
}
|
||||
return this->ToString(maximum);
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr bool Ranged() const override {
|
||||
|
||||
@@ -627,8 +627,8 @@ add_library(core STATIC
|
||||
hle/service/nfp/nfp_interface.h
|
||||
hle/service/nfp/nfp_result.h
|
||||
hle/service/nfp/nfp_types.h
|
||||
hle/service/ngct/ngct.cpp
|
||||
hle/service/ngct/ngct.h
|
||||
hle/service/ngc/ngc.cpp
|
||||
hle/service/ngc/ngc.h
|
||||
hle/service/nifm/nifm.cpp
|
||||
hle/service/nifm/nifm.h
|
||||
hle/service/nim/nim.cpp
|
||||
|
||||
@@ -406,6 +406,7 @@ struct System::Impl {
|
||||
gpu_core->NotifyShutdown();
|
||||
}
|
||||
|
||||
Network::CancelPendingSocketOperations();
|
||||
kernel.SuspendApplication(true);
|
||||
if (services) {
|
||||
services->KillNVNFlinger();
|
||||
@@ -427,6 +428,7 @@ struct System::Impl {
|
||||
debugger.reset();
|
||||
kernel.Shutdown();
|
||||
memory.Reset();
|
||||
Network::RestartSocketOperations();
|
||||
|
||||
if (auto room_member = room_network.GetRoomMember().lock()) {
|
||||
Network::GameInfo game_info{};
|
||||
|
||||
@@ -724,14 +724,14 @@ void KeyManager::LoadFromFile(const std::filesystem::path& file_path, bool is_ti
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto index = std::strtoul(out[0].substr(8, 2).c_str(), nullptr, 16);
|
||||
const auto index = std::stoul(out[0].substr(8, 2), nullptr, 16);
|
||||
keyblobs[index] = Common::HexStringToArray<0x90>(out[1]);
|
||||
} else if (out[0].compare(0, 18, "encrypted_keyblob_") == 0) {
|
||||
if (!ValidCryptoRevisionString(out[0], 18, 2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto index = std::strtoul(out[0].substr(18, 2).c_str(), nullptr, 16);
|
||||
const auto index = std::stoul(out[0].substr(18, 2), nullptr, 16);
|
||||
encrypted_keyblobs[index] = Common::HexStringToArray<0xB0>(out[1]);
|
||||
} else if (out[0].compare(0, 20, "eticket_extended_kek") == 0) {
|
||||
eticket_extended_kek = Common::HexStringToArray<576>(out[1]);
|
||||
@@ -750,7 +750,7 @@ void KeyManager::LoadFromFile(const std::filesystem::path& file_path, bool is_ti
|
||||
}
|
||||
if (out[0].compare(0, kv.second.size(), kv.second) == 0) {
|
||||
const auto index =
|
||||
std::strtoul(out[0].substr(kv.second.size(), 2).c_str(), nullptr, 16);
|
||||
std::stoul(out[0].substr(kv.second.size(), 2), nullptr, 16);
|
||||
const auto sub = kv.first.second;
|
||||
if (sub == 0) {
|
||||
s128_keys[{kv.first.first, index, 0}] =
|
||||
@@ -770,7 +770,7 @@ void KeyManager::LoadFromFile(const std::filesystem::path& file_path, bool is_ti
|
||||
const auto& match = kak_names[j];
|
||||
if (out[0].compare(0, std::strlen(match), match) == 0) {
|
||||
const auto index =
|
||||
std::strtoul(out[0].substr(std::strlen(match), 2).c_str(), nullptr, 16);
|
||||
std::stoul(out[0].substr(std::strlen(match), 2), nullptr, 16);
|
||||
s128_keys[{S128KeyType::KeyArea, index, j}] =
|
||||
Common::HexStringToArray<16>(out[1]);
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ static std::string EscapeStringSequences(std::string in) {
|
||||
void IPSwitchCompiler::ParseFlag(const std::string& line) {
|
||||
if (StartsWith(line, "@flag offset_shift ")) {
|
||||
// Offset Shift Flag
|
||||
offset_shift = std::strtoll(line.substr(19).c_str(), nullptr, 0);
|
||||
offset_shift = std::stoll(line.substr(19), nullptr, 0);
|
||||
} else if (StartsWith(line, "@little-endian")) {
|
||||
// Set values to read as little endian
|
||||
is_little_endian = true;
|
||||
@@ -263,7 +263,7 @@ void IPSwitchCompiler::Parse() {
|
||||
// 11 - 8 hex digit offset + space + minimum two digit overwrite val
|
||||
if (patch_line.length() < 11)
|
||||
break;
|
||||
auto offset = std::strtoul(patch_line.substr(0, 8).c_str(), nullptr, 16);
|
||||
auto offset = std::stoul(patch_line.substr(0, 8), nullptr, 16);
|
||||
offset += static_cast<unsigned long>(offset_shift);
|
||||
|
||||
std::vector<u8> replace;
|
||||
|
||||
150
src/core/hle/service/ngc/ngc.cpp
Normal file
150
src/core/hle/service/ngc/ngc.cpp
Normal file
@@ -0,0 +1,150 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/ngc/ngc.h"
|
||||
#include "core/hle/service/server_manager.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Service::NGC {
|
||||
|
||||
class NgctServiceImpl final : public ServiceFramework<NgctServiceImpl> {
|
||||
public:
|
||||
explicit NgctServiceImpl(Core::System& system_) : ServiceFramework{system_, "ngct:u"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &NgctServiceImpl::Match, "Match"},
|
||||
{1, &NgctServiceImpl::Filter, "Filter"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
void Match(HLERequestContext& ctx) {
|
||||
const auto buffer = ctx.ReadBuffer();
|
||||
const auto text = Common::StringFromFixedZeroTerminatedBuffer(
|
||||
reinterpret_cast<const char*>(buffer.data()), buffer.size());
|
||||
|
||||
LOG_WARNING(Service_NGC, "(STUBBED) called, text={}", text);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
// Return false since we don't censor anything
|
||||
rb.Push(false);
|
||||
}
|
||||
|
||||
void Filter(HLERequestContext& ctx) {
|
||||
const auto buffer = ctx.ReadBuffer();
|
||||
const auto text = Common::StringFromFixedZeroTerminatedBuffer(
|
||||
reinterpret_cast<const char*>(buffer.data()), buffer.size());
|
||||
|
||||
LOG_WARNING(Service_NGC, "(STUBBED) called, text={}", text);
|
||||
|
||||
// Return the same string since we don't censor anything
|
||||
ctx.WriteBuffer(buffer);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
};
|
||||
|
||||
class NgcServiceImpl final : public ServiceFramework<NgcServiceImpl> {
|
||||
public:
|
||||
explicit NgcServiceImpl(Core::System& system_) : ServiceFramework(system_, "ngc:u") {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &NgcServiceImpl::GetContentVersion, "GetContentVersion"},
|
||||
{1, &NgcServiceImpl::Check, "Check"},
|
||||
{2, &NgcServiceImpl::Mask, "Mask"},
|
||||
{3, &NgcServiceImpl::Reload, "Reload"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr u32 NgcContentVersion = 1;
|
||||
|
||||
// This is nn::ngc::detail::ProfanityFilterOption
|
||||
struct ProfanityFilterOption {
|
||||
INSERT_PADDING_BYTES_NOINIT(0x20);
|
||||
};
|
||||
static_assert(sizeof(ProfanityFilterOption) == 0x20,
|
||||
"ProfanityFilterOption has incorrect size");
|
||||
|
||||
void GetContentVersion(HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_NGC, "(STUBBED) called");
|
||||
|
||||
// This calls nn::ngc::ProfanityFilter::GetContentVersion
|
||||
const u32 version = NgcContentVersion;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(version);
|
||||
}
|
||||
|
||||
void Check(HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_NGC, "(STUBBED) called");
|
||||
|
||||
struct InputParameters {
|
||||
u32 flags;
|
||||
ProfanityFilterOption option;
|
||||
};
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
[[maybe_unused]] const auto params = rp.PopRaw<InputParameters>();
|
||||
[[maybe_unused]] const auto input = ctx.ReadBuffer(0);
|
||||
|
||||
// This calls nn::ngc::ProfanityFilter::CheckProfanityWords
|
||||
const u32 out_flags = 0;
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(out_flags);
|
||||
}
|
||||
|
||||
void Mask(HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_NGC, "(STUBBED) called");
|
||||
|
||||
struct InputParameters {
|
||||
u32 flags;
|
||||
ProfanityFilterOption option;
|
||||
};
|
||||
|
||||
IPC::RequestParser rp{ctx};
|
||||
[[maybe_unused]] const auto params = rp.PopRaw<InputParameters>();
|
||||
const auto input = ctx.ReadBuffer(0);
|
||||
|
||||
// This calls nn::ngc::ProfanityFilter::MaskProfanityWordsInText
|
||||
const u32 out_flags = 0;
|
||||
ctx.WriteBuffer(input);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
rb.Push(out_flags);
|
||||
}
|
||||
|
||||
void Reload(HLERequestContext& ctx) {
|
||||
LOG_INFO(Service_NGC, "(STUBBED) called");
|
||||
|
||||
// This reloads the database.
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
};
|
||||
|
||||
void LoopProcess(Core::System& system) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
|
||||
server_manager->RegisterNamedService("ngct:u", std::make_shared<NgctServiceImpl>(system));
|
||||
server_manager->RegisterNamedService("ngc:u", std::make_shared<NgcServiceImpl>(system));
|
||||
ServerManager::RunServer(std::move(server_manager));
|
||||
}
|
||||
|
||||
} // namespace Service::NGC
|
||||
@@ -7,8 +7,8 @@ namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::NGCT {
|
||||
namespace Service::NGC {
|
||||
|
||||
void LoopProcess(Core::System& system);
|
||||
|
||||
} // namespace Service::NGCT
|
||||
} // namespace Service::NGC
|
||||
@@ -1,62 +0,0 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/hle/service/ipc_helpers.h"
|
||||
#include "core/hle/service/ngct/ngct.h"
|
||||
#include "core/hle/service/server_manager.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Service::NGCT {
|
||||
|
||||
class IService final : public ServiceFramework<IService> {
|
||||
public:
|
||||
explicit IService(Core::System& system_) : ServiceFramework{system_, "ngct:u"} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IService::Match, "Match"},
|
||||
{1, &IService::Filter, "Filter"},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
RegisterHandlers(functions);
|
||||
}
|
||||
|
||||
private:
|
||||
void Match(HLERequestContext& ctx) {
|
||||
const auto buffer = ctx.ReadBuffer();
|
||||
const auto text = Common::StringFromFixedZeroTerminatedBuffer(
|
||||
reinterpret_cast<const char*>(buffer.data()), buffer.size());
|
||||
|
||||
LOG_WARNING(Service_NGCT, "(STUBBED) called, text={}", text);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 3};
|
||||
rb.Push(ResultSuccess);
|
||||
// Return false since we don't censor anything
|
||||
rb.Push(false);
|
||||
}
|
||||
|
||||
void Filter(HLERequestContext& ctx) {
|
||||
const auto buffer = ctx.ReadBuffer();
|
||||
const auto text = Common::StringFromFixedZeroTerminatedBuffer(
|
||||
reinterpret_cast<const char*>(buffer.data()), buffer.size());
|
||||
|
||||
LOG_WARNING(Service_NGCT, "(STUBBED) called, text={}", text);
|
||||
|
||||
// Return the same string since we don't censor anything
|
||||
ctx.WriteBuffer(buffer);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
rb.Push(ResultSuccess);
|
||||
}
|
||||
};
|
||||
|
||||
void LoopProcess(Core::System& system) {
|
||||
auto server_manager = std::make_unique<ServerManager>(system);
|
||||
|
||||
server_manager->RegisterNamedService("ngct:u", std::make_shared<IService>(system));
|
||||
ServerManager::RunServer(std::move(server_manager));
|
||||
}
|
||||
|
||||
} // namespace Service::NGCT
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "core/hle/service/ncm/ncm.h"
|
||||
#include "core/hle/service/nfc/nfc.h"
|
||||
#include "core/hle/service/nfp/nfp.h"
|
||||
#include "core/hle/service/ngct/ngct.h"
|
||||
#include "core/hle/service/ngc/ngc.h"
|
||||
#include "core/hle/service/nifm/nifm.h"
|
||||
#include "core/hle/service/nim/nim.h"
|
||||
#include "core/hle/service/npns/npns.h"
|
||||
@@ -257,7 +257,7 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system
|
||||
kernel.RunOnGuestCoreProcess("NCM", [&] { NCM::LoopProcess(system); });
|
||||
kernel.RunOnGuestCoreProcess("nfc", [&] { NFC::LoopProcess(system); });
|
||||
kernel.RunOnGuestCoreProcess("nfp", [&] { NFP::LoopProcess(system); });
|
||||
kernel.RunOnGuestCoreProcess("ngct", [&] { NGCT::LoopProcess(system); });
|
||||
kernel.RunOnGuestCoreProcess("ngc", [&] { NGC::LoopProcess(system); });
|
||||
kernel.RunOnGuestCoreProcess("nifm", [&] { NIFM::LoopProcess(system); });
|
||||
kernel.RunOnGuestCoreProcess("nim", [&] { NIM::LoopProcess(system); });
|
||||
kernel.RunOnGuestCoreProcess("npns", [&] { NPNS::LoopProcess(system); });
|
||||
|
||||
@@ -48,15 +48,32 @@ enum class CallType {
|
||||
|
||||
using socklen_t = int;
|
||||
|
||||
SOCKET interrupt_socket = static_cast<SOCKET>(-1);
|
||||
|
||||
void InterruptSocketOperations() {
|
||||
closesocket(interrupt_socket);
|
||||
}
|
||||
|
||||
void AcknowledgeInterrupt() {
|
||||
interrupt_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
}
|
||||
|
||||
void Initialize() {
|
||||
WSADATA wsa_data;
|
||||
(void)WSAStartup(MAKEWORD(2, 2), &wsa_data);
|
||||
|
||||
AcknowledgeInterrupt();
|
||||
}
|
||||
|
||||
void Finalize() {
|
||||
InterruptSocketOperations();
|
||||
WSACleanup();
|
||||
}
|
||||
|
||||
SOCKET GetInterruptSocket() {
|
||||
return interrupt_socket;
|
||||
}
|
||||
|
||||
sockaddr TranslateFromSockAddrIn(SockAddrIn input) {
|
||||
sockaddr_in result;
|
||||
|
||||
@@ -157,9 +174,42 @@ constexpr int SD_RECEIVE = SHUT_RD;
|
||||
constexpr int SD_SEND = SHUT_WR;
|
||||
constexpr int SD_BOTH = SHUT_RDWR;
|
||||
|
||||
void Initialize() {}
|
||||
int interrupt_pipe_fd[2] = {-1, -1};
|
||||
|
||||
void Finalize() {}
|
||||
void Initialize() {
|
||||
if (pipe(interrupt_pipe_fd) != 0) {
|
||||
LOG_ERROR(Network, "Failed to create interrupt pipe!");
|
||||
}
|
||||
int flags = fcntl(interrupt_pipe_fd[0], F_GETFL);
|
||||
ASSERT_MSG(fcntl(interrupt_pipe_fd[0], F_SETFL, flags | O_NONBLOCK) == 0,
|
||||
"Failed to set nonblocking state for interrupt pipe");
|
||||
}
|
||||
|
||||
void Finalize() {
|
||||
if (interrupt_pipe_fd[0] >= 0) {
|
||||
close(interrupt_pipe_fd[0]);
|
||||
}
|
||||
if (interrupt_pipe_fd[1] >= 0) {
|
||||
close(interrupt_pipe_fd[1]);
|
||||
}
|
||||
}
|
||||
|
||||
void InterruptSocketOperations() {
|
||||
u8 value = 0;
|
||||
ASSERT(write(interrupt_pipe_fd[1], &value, sizeof(value)) == 1);
|
||||
}
|
||||
|
||||
void AcknowledgeInterrupt() {
|
||||
u8 value = 0;
|
||||
ssize_t ret = read(interrupt_pipe_fd[0], &value, sizeof(value));
|
||||
if (ret != 1 && errno != EAGAIN && errno != EWOULDBLOCK) {
|
||||
LOG_ERROR(Network, "Failed to acknowledge interrupt on shutdown");
|
||||
}
|
||||
}
|
||||
|
||||
SOCKET GetInterruptSocket() {
|
||||
return interrupt_pipe_fd[0];
|
||||
}
|
||||
|
||||
sockaddr TranslateFromSockAddrIn(SockAddrIn input) {
|
||||
sockaddr_in result;
|
||||
@@ -490,6 +540,14 @@ NetworkInstance::~NetworkInstance() {
|
||||
Finalize();
|
||||
}
|
||||
|
||||
void CancelPendingSocketOperations() {
|
||||
InterruptSocketOperations();
|
||||
}
|
||||
|
||||
void RestartSocketOperations() {
|
||||
AcknowledgeInterrupt();
|
||||
}
|
||||
|
||||
std::optional<IPv4Address> GetHostIPv4Address() {
|
||||
const auto network_interface = Network::GetSelectedNetworkInterface();
|
||||
if (!network_interface.has_value()) {
|
||||
@@ -560,7 +618,14 @@ std::pair<s32, Errno> Poll(std::vector<PollFD>& pollfds, s32 timeout) {
|
||||
return result;
|
||||
});
|
||||
|
||||
const int result = WSAPoll(host_pollfds.data(), static_cast<ULONG>(num), timeout);
|
||||
host_pollfds.push_back(WSAPOLLFD{
|
||||
.fd = GetInterruptSocket(),
|
||||
.events = POLLIN,
|
||||
.revents = 0,
|
||||
});
|
||||
|
||||
const int result =
|
||||
WSAPoll(host_pollfds.data(), static_cast<ULONG>(host_pollfds.size()), timeout);
|
||||
if (result == 0) {
|
||||
ASSERT(std::all_of(host_pollfds.begin(), host_pollfds.end(),
|
||||
[](WSAPOLLFD fd) { return fd.revents == 0; }));
|
||||
@@ -627,6 +692,24 @@ Errno Socket::Initialize(Domain domain, Type type, Protocol protocol) {
|
||||
std::pair<SocketBase::AcceptResult, Errno> Socket::Accept() {
|
||||
sockaddr_in addr;
|
||||
socklen_t addrlen = sizeof(addr);
|
||||
|
||||
std::vector<WSAPOLLFD> host_pollfds{
|
||||
WSAPOLLFD{fd, POLLIN, 0},
|
||||
WSAPOLLFD{GetInterruptSocket(), POLLIN, 0},
|
||||
};
|
||||
|
||||
while (true) {
|
||||
const int pollres =
|
||||
WSAPoll(host_pollfds.data(), static_cast<ULONG>(host_pollfds.size()), -1);
|
||||
if (host_pollfds[1].revents != 0) {
|
||||
// Interrupt signaled before a client could be accepted, break
|
||||
return {AcceptResult{}, Errno::AGAIN};
|
||||
}
|
||||
if (pollres > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const SOCKET new_socket = accept(fd, reinterpret_cast<sockaddr*>(&addr), &addrlen);
|
||||
|
||||
if (new_socket == INVALID_SOCKET) {
|
||||
|
||||
@@ -96,6 +96,9 @@ public:
|
||||
~NetworkInstance();
|
||||
};
|
||||
|
||||
void CancelPendingSocketOperations();
|
||||
void RestartSocketOperations();
|
||||
|
||||
#ifdef _WIN32
|
||||
constexpr IPv4Address TranslateIPv4(in_addr addr) {
|
||||
auto& bytes = addr.S_un.S_un_b;
|
||||
|
||||
@@ -154,7 +154,7 @@ std::vector<CheatEntry> TextCheatParser::Parse(std::string_view data) const {
|
||||
return {};
|
||||
}
|
||||
|
||||
const auto value = static_cast<u32>(std::strtoul(hex.c_str(), nullptr, 0x10));
|
||||
const auto value = static_cast<u32>(std::stoul(hex, nullptr, 0x10));
|
||||
out[*current_entry].definition.opcodes[out[*current_entry].definition.num_opcodes++] =
|
||||
value;
|
||||
|
||||
|
||||
@@ -204,9 +204,7 @@ Id TextureImage(EmitContext& ctx, IR::TextureInstInfo info, const IR::Value& ind
|
||||
if (def.count > 1) {
|
||||
throw NotImplementedException("Indirect texture sample");
|
||||
}
|
||||
const Id sampler_id{def.id};
|
||||
const Id id{ctx.OpLoad(ctx.sampled_texture_buffer_type, sampler_id)};
|
||||
return ctx.OpImage(ctx.image_buffer_type, id);
|
||||
return ctx.OpLoad(ctx.image_buffer_type, def.id);
|
||||
} else {
|
||||
const TextureDefinition& def{ctx.textures.at(info.descriptor_index)};
|
||||
if (def.count > 1) {
|
||||
|
||||
@@ -1247,9 +1247,8 @@ void EmitContext::DefineTextureBuffers(const Info& info, u32& binding) {
|
||||
}
|
||||
const spv::ImageFormat format{spv::ImageFormat::Unknown};
|
||||
image_buffer_type = TypeImage(F32[1], spv::Dim::Buffer, 0U, false, false, 1, format);
|
||||
sampled_texture_buffer_type = TypeSampledImage(image_buffer_type);
|
||||
|
||||
const Id type{TypePointer(spv::StorageClass::UniformConstant, sampled_texture_buffer_type)};
|
||||
const Id type{TypePointer(spv::StorageClass::UniformConstant, image_buffer_type)};
|
||||
texture_buffers.reserve(info.texture_buffer_descriptors.size());
|
||||
for (const TextureBufferDescriptor& desc : info.texture_buffer_descriptors) {
|
||||
if (desc.count != 1) {
|
||||
|
||||
@@ -206,7 +206,6 @@ public:
|
||||
Id output_u32{};
|
||||
|
||||
Id image_buffer_type{};
|
||||
Id sampled_texture_buffer_type{};
|
||||
Id image_u32{};
|
||||
|
||||
std::array<UniformDefinitions, Info::MAX_CBUFS> cbufs{};
|
||||
|
||||
@@ -719,6 +719,7 @@ typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView(VAddr cpu_ad
|
||||
return nullptr;
|
||||
}
|
||||
const auto& image_map_ids = it->second;
|
||||
boost::container::small_vector<const ImageBase*, 4> valid_images;
|
||||
for (const ImageMapId map_id : image_map_ids) {
|
||||
const ImageMapView& map = slot_map_views[map_id];
|
||||
const ImageBase& image = slot_images[map.image_id];
|
||||
@@ -728,8 +729,20 @@ typename P::ImageView* TextureCache<P>::TryFindFramebufferImageView(VAddr cpu_ad
|
||||
if (image.image_view_ids.empty()) {
|
||||
continue;
|
||||
}
|
||||
return &slot_image_views[image.image_view_ids.at(0)];
|
||||
valid_images.push_back(&image);
|
||||
}
|
||||
|
||||
if (valid_images.size() == 1) [[likely]] {
|
||||
return &slot_image_views[valid_images[0]->image_view_ids.at(0)];
|
||||
}
|
||||
|
||||
if (valid_images.size() > 0) [[unlikely]] {
|
||||
std::ranges::sort(valid_images, [](const auto* a, const auto* b) {
|
||||
return a->modification_tick > b->modification_tick;
|
||||
});
|
||||
return &slot_image_views[valid_images[0]->image_view_ids.at(0)];
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "yuzu/configuration/configure_ui.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstdlib>
|
||||
#include <set>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
@@ -95,7 +94,11 @@ static void PopulateResolutionComboBox(QComboBox* screenshot_height, QWidget* pa
|
||||
}
|
||||
|
||||
static u32 ScreenshotDimensionToInt(const QString& height) {
|
||||
return std::strtoul(height.toUtf8(), nullptr, 0);
|
||||
try {
|
||||
return std::stoi(height.toStdString());
|
||||
} catch (std::invalid_argument&) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
ConfigureUi::ConfigureUi(Core::System& system_, QWidget* parent)
|
||||
|
||||
@@ -63,7 +63,7 @@ static QString DefaultSuffix(QWidget* parent, Settings::BasicSetting& setting) {
|
||||
return tr("%", context.c_str());
|
||||
}
|
||||
|
||||
return default_suffix;
|
||||
return QStringLiteral("");
|
||||
}
|
||||
|
||||
QPushButton* Widget::CreateRestoreGlobalButton(bool using_global, QWidget* parent) {
|
||||
@@ -71,7 +71,7 @@ QPushButton* Widget::CreateRestoreGlobalButton(bool using_global, QWidget* paren
|
||||
|
||||
QStyle* style = parent->style();
|
||||
QIcon* icon = new QIcon(style->standardIcon(QStyle::SP_LineEditClearButton));
|
||||
QPushButton* restore_button = new QPushButton(*icon, QStringLiteral(), parent);
|
||||
QPushButton* restore_button = new QPushButton(*icon, QStringLiteral(""), parent);
|
||||
restore_button->setObjectName(QStringLiteral("RestoreButton%1").arg(restore_button_count));
|
||||
restore_button->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
|
||||
@@ -151,7 +151,7 @@ QWidget* Widget::CreateCombobox(std::function<std::string()>& serializer,
|
||||
return -1;
|
||||
};
|
||||
|
||||
const u32 setting_value = std::strtoul(setting.ToString().c_str(), nullptr, 0);
|
||||
const u32 setting_value = std::stoi(setting.ToString());
|
||||
combobox->setCurrentIndex(find_index(setting_value));
|
||||
|
||||
serializer = [this, enumeration]() {
|
||||
@@ -160,7 +160,7 @@ QWidget* Widget::CreateCombobox(std::function<std::string()>& serializer,
|
||||
};
|
||||
|
||||
restore_func = [this, find_index]() {
|
||||
const u32 global_value = std::strtoul(RelevantDefault(setting).c_str(), nullptr, 0);
|
||||
const u32 global_value = std::stoi(RelevantDefault(setting));
|
||||
combobox->setCurrentIndex(find_index(global_value));
|
||||
};
|
||||
|
||||
@@ -209,7 +209,7 @@ QWidget* Widget::CreateRadioGroup(std::function<std::string()>& serializer,
|
||||
}
|
||||
};
|
||||
|
||||
const u32 setting_value = std::strtoul(setting.ToString().c_str(), nullptr, 0);
|
||||
const u32 setting_value = std::stoi(setting.ToString());
|
||||
set_index(setting_value);
|
||||
|
||||
serializer = [get_selected]() {
|
||||
@@ -218,7 +218,7 @@ QWidget* Widget::CreateRadioGroup(std::function<std::string()>& serializer,
|
||||
};
|
||||
|
||||
restore_func = [this, set_index]() {
|
||||
const u32 global_value = std::strtoul(RelevantDefault(setting).c_str(), nullptr, 0);
|
||||
const u32 global_value = std::stoi(RelevantDefault(setting));
|
||||
set_index(global_value);
|
||||
};
|
||||
|
||||
@@ -255,59 +255,6 @@ QWidget* Widget::CreateLineEdit(std::function<std::string()>& serializer,
|
||||
return line_edit;
|
||||
}
|
||||
|
||||
static void CreateIntSlider(Settings::BasicSetting& setting, bool reversed, float multiplier,
|
||||
QLabel* feedback, const QString& use_format, QSlider* slider,
|
||||
std::function<std::string()>& serializer,
|
||||
std::function<void()>& restore_func) {
|
||||
const int max_val = std::strtol(setting.MaxVal().c_str(), nullptr, 0);
|
||||
|
||||
const auto update_feedback = [=](int value) {
|
||||
int present = (reversed ? max_val - value : value) * multiplier + 0.5f;
|
||||
feedback->setText(use_format.arg(QVariant::fromValue(present).value<QString>()));
|
||||
};
|
||||
|
||||
QObject::connect(slider, &QAbstractSlider::valueChanged, update_feedback);
|
||||
update_feedback(std::strtol(setting.ToString().c_str(), nullptr, 0));
|
||||
|
||||
slider->setMinimum(std::strtol(setting.MinVal().c_str(), nullptr, 0));
|
||||
slider->setMaximum(max_val);
|
||||
slider->setValue(std::strtol(setting.ToString().c_str(), nullptr, 0));
|
||||
|
||||
serializer = [slider]() { return std::to_string(slider->value()); };
|
||||
restore_func = [slider, &setting]() {
|
||||
slider->setValue(std::strtol(RelevantDefault(setting).c_str(), nullptr, 0));
|
||||
};
|
||||
}
|
||||
|
||||
static void CreateFloatSlider(Settings::BasicSetting& setting, bool reversed, float multiplier,
|
||||
QLabel* feedback, const QString& use_format, QSlider* slider,
|
||||
std::function<std::string()>& serializer,
|
||||
std::function<void()>& restore_func) {
|
||||
const float max_val = std::strtof(setting.MaxVal().c_str(), nullptr);
|
||||
const float min_val = std::strtof(setting.MinVal().c_str(), nullptr);
|
||||
const float use_multiplier =
|
||||
multiplier == default_multiplier ? default_float_multiplier : multiplier;
|
||||
|
||||
const auto update_feedback = [=](float value) {
|
||||
int present = (reversed ? max_val - value : value) + 0.5f;
|
||||
feedback->setText(use_format.arg(QVariant::fromValue(present).value<QString>()));
|
||||
};
|
||||
|
||||
QObject::connect(slider, &QAbstractSlider::valueChanged, update_feedback);
|
||||
update_feedback(std::strtof(setting.ToString().c_str(), nullptr));
|
||||
|
||||
slider->setMinimum(min_val * use_multiplier);
|
||||
slider->setMaximum(max_val * use_multiplier);
|
||||
slider->setValue(std::strtof(setting.ToString().c_str(), nullptr) * use_multiplier);
|
||||
|
||||
serializer = [slider, use_multiplier]() {
|
||||
return std::to_string(slider->value() / use_multiplier);
|
||||
};
|
||||
restore_func = [slider, &setting, use_multiplier]() {
|
||||
slider->setValue(std::strtof(RelevantDefault(setting).c_str(), nullptr) * use_multiplier);
|
||||
};
|
||||
}
|
||||
|
||||
QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& given_suffix,
|
||||
std::function<std::string()>& serializer,
|
||||
std::function<void()>& restore_func,
|
||||
@@ -331,19 +278,27 @@ QWidget* Widget::CreateSlider(bool reversed, float multiplier, const QString& gi
|
||||
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
QString suffix = given_suffix == default_suffix ? DefaultSuffix(this, setting) : given_suffix;
|
||||
int max_val = std::stoi(setting.MaxVal());
|
||||
|
||||
QString suffix =
|
||||
given_suffix == QStringLiteral("") ? DefaultSuffix(this, setting) : given_suffix;
|
||||
|
||||
const QString use_format = QStringLiteral("%1").append(suffix);
|
||||
|
||||
if (setting.IsIntegral()) {
|
||||
CreateIntSlider(setting, reversed, multiplier, feedback, use_format, slider, serializer,
|
||||
restore_func);
|
||||
} else {
|
||||
CreateFloatSlider(setting, reversed, multiplier, feedback, use_format, slider, serializer,
|
||||
restore_func);
|
||||
}
|
||||
QObject::connect(slider, &QAbstractSlider::valueChanged, [=](int value) {
|
||||
int present = (reversed ? max_val - value : value) * multiplier + 0.5f;
|
||||
feedback->setText(use_format.arg(QVariant::fromValue(present).value<QString>()));
|
||||
});
|
||||
|
||||
slider->setMinimum(std::stoi(setting.MinVal()));
|
||||
slider->setMaximum(max_val);
|
||||
slider->setValue(std::stoi(setting.ToString()));
|
||||
|
||||
slider->setInvertedAppearance(reversed);
|
||||
slider->setInvertedControls(reversed);
|
||||
|
||||
serializer = [this]() { return std::to_string(slider->value()); };
|
||||
restore_func = [this]() { slider->setValue(std::stoi(RelevantDefault(setting))); };
|
||||
|
||||
if (!Settings::IsConfiguringGlobal()) {
|
||||
QObject::connect(slider, &QAbstractSlider::actionTriggered, [touch]() { touch(); });
|
||||
@@ -356,11 +311,14 @@ QWidget* Widget::CreateSpinBox(const QString& given_suffix,
|
||||
std::function<std::string()>& serializer,
|
||||
std::function<void()>& restore_func,
|
||||
const std::function<void()>& touch) {
|
||||
const auto min_val = std::strtol(setting.MinVal().c_str(), nullptr, 0);
|
||||
const auto max_val = std::strtol(setting.MaxVal().c_str(), nullptr, 0);
|
||||
const auto default_val = std::strtol(setting.ToString().c_str(), nullptr, 0);
|
||||
const int min_val =
|
||||
setting.Ranged() ? std::stoi(setting.MinVal()) : std::numeric_limits<int>::min();
|
||||
const int max_val =
|
||||
setting.Ranged() ? std::stoi(setting.MaxVal()) : std::numeric_limits<int>::max();
|
||||
const int default_val = std::stoi(setting.ToString());
|
||||
|
||||
QString suffix = given_suffix == default_suffix ? DefaultSuffix(this, setting) : given_suffix;
|
||||
QString suffix =
|
||||
given_suffix == QStringLiteral("") ? DefaultSuffix(this, setting) : given_suffix;
|
||||
|
||||
spinbox = new QSpinBox(this);
|
||||
spinbox->setRange(min_val, max_val);
|
||||
@@ -371,13 +329,13 @@ QWidget* Widget::CreateSpinBox(const QString& given_suffix,
|
||||
serializer = [this]() { return std::to_string(spinbox->value()); };
|
||||
|
||||
restore_func = [this]() {
|
||||
auto value{std::strtol(RelevantDefault(setting).c_str(), nullptr, 0)};
|
||||
auto value{std::stol(RelevantDefault(setting))};
|
||||
spinbox->setValue(value);
|
||||
};
|
||||
|
||||
if (!Settings::IsConfiguringGlobal()) {
|
||||
QObject::connect(spinbox, QOverload<int>::of(&QSpinBox::valueChanged), [this, touch]() {
|
||||
if (spinbox->value() != std::strtol(setting.ToStringGlobal().c_str(), nullptr, 0)) {
|
||||
if (spinbox->value() != std::stoi(setting.ToStringGlobal())) {
|
||||
touch();
|
||||
}
|
||||
});
|
||||
@@ -386,42 +344,6 @@ QWidget* Widget::CreateSpinBox(const QString& given_suffix,
|
||||
return spinbox;
|
||||
}
|
||||
|
||||
QWidget* Widget::CreateDoubleSpinBox(const QString& given_suffix,
|
||||
std::function<std::string()>& serializer,
|
||||
std::function<void()>& restore_func,
|
||||
const std::function<void()>& touch) {
|
||||
const auto min_val = std::strtod(setting.MinVal().c_str(), nullptr);
|
||||
const auto max_val = std::strtod(setting.MaxVal().c_str(), nullptr);
|
||||
const auto default_val = std::strtod(setting.ToString().c_str(), nullptr);
|
||||
|
||||
QString suffix = given_suffix == default_suffix ? DefaultSuffix(this, setting) : given_suffix;
|
||||
|
||||
double_spinbox = new QDoubleSpinBox(this);
|
||||
double_spinbox->setRange(min_val, max_val);
|
||||
double_spinbox->setValue(default_val);
|
||||
double_spinbox->setSuffix(suffix);
|
||||
double_spinbox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
|
||||
serializer = [this]() { return fmt::format("{:f}", double_spinbox->value()); };
|
||||
|
||||
restore_func = [this]() {
|
||||
auto value{std::strtod(RelevantDefault(setting).c_str(), nullptr)};
|
||||
double_spinbox->setValue(value);
|
||||
};
|
||||
|
||||
if (!Settings::IsConfiguringGlobal()) {
|
||||
QObject::connect(double_spinbox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
|
||||
[this, touch]() {
|
||||
if (double_spinbox->value() !=
|
||||
std::strtod(setting.ToStringGlobal().c_str(), nullptr)) {
|
||||
touch();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return double_spinbox;
|
||||
}
|
||||
|
||||
QWidget* Widget::CreateHexEdit(std::function<std::string()>& serializer,
|
||||
std::function<void()>& restore_func,
|
||||
const std::function<void()>& touch) {
|
||||
@@ -431,8 +353,7 @@ QWidget* Widget::CreateHexEdit(std::function<std::string()>& serializer,
|
||||
}
|
||||
|
||||
auto to_hex = [=](const std::string& input) {
|
||||
return QString::fromStdString(
|
||||
fmt::format("{:08x}", std::strtoul(input.c_str(), nullptr, 0)));
|
||||
return QString::fromStdString(fmt::format("{:08x}", std::stoul(input)));
|
||||
};
|
||||
|
||||
QRegularExpressionValidator* regex = new QRegularExpressionValidator(
|
||||
@@ -445,7 +366,7 @@ QWidget* Widget::CreateHexEdit(std::function<std::string()>& serializer,
|
||||
line_edit->setValidator(regex);
|
||||
|
||||
auto hex_to_dec = [this]() -> std::string {
|
||||
return std::to_string(std::strtoul(line_edit->text().toStdString().c_str(), nullptr, 16));
|
||||
return std::to_string(std::stoul(line_edit->text().toStdString(), nullptr, 16));
|
||||
};
|
||||
|
||||
serializer = [hex_to_dec]() { return hex_to_dec(); };
|
||||
@@ -465,8 +386,7 @@ QWidget* Widget::CreateDateTimeEdit(bool disabled, bool restrict,
|
||||
std::function<void()>& restore_func,
|
||||
const std::function<void()>& touch) {
|
||||
const long long current_time = QDateTime::currentSecsSinceEpoch();
|
||||
const s64 the_time =
|
||||
disabled ? current_time : std::strtoll(setting.ToString().c_str(), nullptr, 0);
|
||||
const s64 the_time = disabled ? current_time : std::stoll(setting.ToString());
|
||||
const auto default_val = QDateTime::fromSecsSinceEpoch(the_time);
|
||||
|
||||
date_time_edit = new QDateTimeEdit(this);
|
||||
@@ -479,7 +399,7 @@ QWidget* Widget::CreateDateTimeEdit(bool disabled, bool restrict,
|
||||
auto get_clear_val = [this, restrict, current_time]() {
|
||||
return QDateTime::fromSecsSinceEpoch([this, restrict, current_time]() {
|
||||
if (restrict && checkbox->checkState() == Qt::Checked) {
|
||||
return std::strtoll(RelevantDefault(setting).c_str(), nullptr, 0);
|
||||
return std::stoll(RelevantDefault(setting));
|
||||
}
|
||||
return current_time;
|
||||
}());
|
||||
@@ -586,7 +506,8 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu
|
||||
} else {
|
||||
data_component = CreateCombobox(serializer, restore_func, touch);
|
||||
}
|
||||
} else if (setting.IsIntegral()) {
|
||||
} else if (type == typeid(u32) || type == typeid(int) || type == typeid(u16) ||
|
||||
type == typeid(s64) || type == typeid(u8)) {
|
||||
switch (request) {
|
||||
case RequestType::Slider:
|
||||
case RequestType::ReverseSlider:
|
||||
@@ -613,20 +534,6 @@ void Widget::SetupComponent(const QString& label, std::function<void()>& load_fu
|
||||
default:
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
} else if (setting.IsFloatingPoint()) {
|
||||
switch (request) {
|
||||
case RequestType::Default:
|
||||
case RequestType::SpinBox:
|
||||
data_component = CreateDoubleSpinBox(suffix, serializer, restore_func, touch);
|
||||
break;
|
||||
case RequestType::Slider:
|
||||
case RequestType::ReverseSlider:
|
||||
data_component = CreateSlider(request == RequestType::ReverseSlider, multiplier, suffix,
|
||||
serializer, restore_func, touch);
|
||||
break;
|
||||
default:
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
} else if (type == typeid(std::string)) {
|
||||
switch (request) {
|
||||
case RequestType::Default:
|
||||
@@ -731,10 +638,10 @@ Widget::Widget(Settings::BasicSetting* setting_, const TranslationMap& translati
|
||||
return std::pair{translations.at(id).first, translations.at(id).second};
|
||||
}
|
||||
LOG_WARNING(Frontend, "Translation table lacks entry for \"{}\"", setting_label);
|
||||
return std::pair{QString::fromStdString(setting_label), QStringLiteral()};
|
||||
return std::pair{QString::fromStdString(setting_label), QStringLiteral("")};
|
||||
}();
|
||||
|
||||
if (label == QStringLiteral()) {
|
||||
if (label == QStringLiteral("")) {
|
||||
LOG_DEBUG(Frontend, "Translation table has empty entry for \"{}\", skipping...",
|
||||
setting.GetLabel());
|
||||
return;
|
||||
|
||||
@@ -22,7 +22,6 @@ class QObject;
|
||||
class QPushButton;
|
||||
class QSlider;
|
||||
class QSpinBox;
|
||||
class QDoubleSpinBox;
|
||||
class QRadioButton;
|
||||
|
||||
namespace Settings {
|
||||
@@ -44,10 +43,6 @@ enum class RequestType {
|
||||
MaxEnum,
|
||||
};
|
||||
|
||||
constexpr float default_multiplier{1.f};
|
||||
constexpr float default_float_multiplier{100.f};
|
||||
static const QString default_suffix = QStringLiteral();
|
||||
|
||||
class Widget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -71,9 +66,8 @@ public:
|
||||
const ComboboxTranslationMap& combobox_translations, QWidget* parent,
|
||||
bool runtime_lock, std::vector<std::function<void(bool)>>& apply_funcs_,
|
||||
RequestType request = RequestType::Default, bool managed = true,
|
||||
float multiplier = default_multiplier,
|
||||
Settings::BasicSetting* other_setting = nullptr,
|
||||
const QString& suffix = default_suffix);
|
||||
float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr,
|
||||
const QString& suffix = QStringLiteral(""));
|
||||
virtual ~Widget();
|
||||
|
||||
/**
|
||||
@@ -95,7 +89,6 @@ public:
|
||||
QPushButton* restore_button{}; ///< Restore button for custom configurations
|
||||
QLineEdit* line_edit{}; ///< QLineEdit, used for LineEdit and HexEdit
|
||||
QSpinBox* spinbox{};
|
||||
QDoubleSpinBox* double_spinbox{};
|
||||
QCheckBox* checkbox{};
|
||||
QSlider* slider{};
|
||||
QComboBox* combobox{};
|
||||
@@ -133,9 +126,6 @@ private:
|
||||
const std::function<void()>& touch);
|
||||
QWidget* CreateSpinBox(const QString& suffix, std::function<std::string()>& serializer,
|
||||
std::function<void()>& restore_func, const std::function<void()>& touch);
|
||||
QWidget* CreateDoubleSpinBox(const QString& suffix, std::function<std::string()>& serializer,
|
||||
std::function<void()>& restore_func,
|
||||
const std::function<void()>& touch);
|
||||
|
||||
QWidget* parent;
|
||||
const TranslationMap& translations;
|
||||
@@ -155,15 +145,14 @@ public:
|
||||
Widget* BuildWidget(Settings::BasicSetting* setting,
|
||||
std::vector<std::function<void(bool)>>& apply_funcs,
|
||||
RequestType request = RequestType::Default, bool managed = true,
|
||||
float multiplier = default_multiplier,
|
||||
Settings::BasicSetting* other_setting = nullptr,
|
||||
const QString& suffix = default_suffix) const;
|
||||
float multiplier = 1.0f, Settings::BasicSetting* other_setting = nullptr,
|
||||
const QString& suffix = QStringLiteral("")) const;
|
||||
|
||||
Widget* BuildWidget(Settings::BasicSetting* setting,
|
||||
std::vector<std::function<void(bool)>>& apply_funcs,
|
||||
Settings::BasicSetting* other_setting,
|
||||
RequestType request = RequestType::Default,
|
||||
const QString& suffix = default_suffix) const;
|
||||
const QString& suffix = QStringLiteral("")) const;
|
||||
|
||||
const ComboboxTranslationMap& ComboboxTranslations() const;
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ void Config::ReadValues() {
|
||||
std::stringstream ss(title_list);
|
||||
std::string line;
|
||||
while (std::getline(ss, line, '|')) {
|
||||
const auto title_id = std::strtoul(line.c_str(), nullptr, 16);
|
||||
const auto title_id = std::stoul(line, nullptr, 16);
|
||||
const auto disabled_list = sdl2_config->Get("AddOns", "disabled_" + line, "");
|
||||
|
||||
std::stringstream inner_ss(disabled_list);
|
||||
|
||||
@@ -264,9 +264,8 @@ int main(int argc, char** argv) {
|
||||
nickname = match[1];
|
||||
password = match[2];
|
||||
address = match[3];
|
||||
if (!match[4].str().empty()) {
|
||||
port = static_cast<u16>(std::strtoul(match[4].str().c_str(), nullptr, 0));
|
||||
}
|
||||
if (!match[4].str().empty())
|
||||
port = static_cast<u16>(std::stoi(match[4]));
|
||||
std::regex nickname_re("^[a-zA-Z0-9._\\- ]+$");
|
||||
if (!std::regex_match(nickname, nickname_re)) {
|
||||
std::cout
|
||||
|
||||
Reference in New Issue
Block a user