summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/fs/fs.cpp15
-rw-r--r--src/common/logging/filter.cpp2
-rw-r--r--src/common/logging/types.h2
-rw-r--r--src/common/polyfill_thread.h20
-rw-r--r--src/common/settings.h2
-rw-r--r--src/common/settings_common.h10
-rw-r--r--src/common/settings_setting.h33
7 files changed, 64 insertions, 20 deletions
diff --git a/src/common/fs/fs.cpp b/src/common/fs/fs.cpp
index 36e67c145..174aed49b 100644
--- a/src/common/fs/fs.cpp
+++ b/src/common/fs/fs.cpp
@@ -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
}
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index c95909561..4e3a614a4 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -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) \
diff --git a/src/common/logging/types.h b/src/common/logging/types.h
index 8356e3183..08af50ee0 100644
--- a/src/common/logging/types.h
+++ b/src/common/logging/types.h
@@ -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
diff --git a/src/common/polyfill_thread.h b/src/common/polyfill_thread.h
index b5ef055db..41cbb9ed5 100644
--- a/src/common/polyfill_thread.h
+++ b/src/common/polyfill_thread.h
@@ -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();
});
diff --git a/src/common/settings.h b/src/common/settings.h
index b15213bd7..82ec9077e 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -348,6 +348,8 @@ struct Values {
Category::RendererDebug};
Setting<bool> disable_shader_loop_safety_checks{
linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug};
+ Setting<bool> enable_renderdoc_hotkey{linkage, false, "renderdoc_hotkey",
+ Category::RendererDebug};
// System
SwitchableSetting<Language, true> language_index{linkage,
diff --git a/src/common/settings_common.h b/src/common/settings_common.h
index 5b170dfd5..1800ab10d 100644
--- a/src/common/settings_common.h
+++ b/src/common/settings_common.h
@@ -225,6 +225,16 @@ 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
*/
diff --git a/src/common/settings_setting.h b/src/common/settings_setting.h
index e10843c73..7be6f26f7 100644
--- a/src/common/settings_setting.h
+++ b/src/common/settings_setting.h
@@ -10,6 +10,7 @@
#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"
@@ -115,8 +116,12 @@ 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(static_cast<u64>(value_));
+ return std::to_string(value_);
}
}
@@ -180,13 +185,15 @@ 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, AudioEngine>) {
- this->SetValue(ToEnum<Type>(input));
+ } else if constexpr (std::is_same_v<Type, float>) {
+ this->SetValue(std::stof(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());
}
}
@@ -215,11 +222,27 @@ 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 {
- return this->ToString(minimum);
+ if constexpr (std::is_arithmetic_v<Type> && !ranged) {
+ return this->ToString(std::numeric_limits<Type>::min());
+ } else {
+ return this->ToString(minimum);
+ }
}
[[nodiscard]] std::string MaxVal() const override final {
- return this->ToString(maximum);
+ if constexpr (std::is_arithmetic_v<Type> && !ranged) {
+ return this->ToString(std::numeric_limits<Type>::max());
+ } else {
+ return this->ToString(maximum);
+ }
}
[[nodiscard]] constexpr bool Ranged() const override {