diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/fs/fs.cpp | 15 | ||||
| -rw-r--r-- | src/common/logging/filter.cpp | 2 | ||||
| -rw-r--r-- | src/common/logging/types.h | 2 | ||||
| -rw-r--r-- | src/common/polyfill_thread.h | 20 | ||||
| -rw-r--r-- | src/common/settings.h | 2 | ||||
| -rw-r--r-- | src/common/settings_common.h | 10 | ||||
| -rw-r--r-- | src/common/settings_setting.h | 33 |
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, | |||
| 528 | // Generic Filesystem Operations | 528 | // Generic Filesystem Operations |
| 529 | 529 | ||
| 530 | bool Exists(const fs::path& path) { | 530 | bool Exists(const fs::path& path) { |
| 531 | std::error_code ec; | ||
| 531 | #ifdef ANDROID | 532 | #ifdef ANDROID |
| 532 | if (Android::IsContentUri(path)) { | 533 | if (Android::IsContentUri(path)) { |
| 533 | return Android::Exists(path); | 534 | return Android::Exists(path); |
| 534 | } else { | 535 | } else { |
| 535 | return fs::exists(path); | 536 | return fs::exists(path, ec); |
| 536 | } | 537 | } |
| 537 | #else | 538 | #else |
| 538 | return fs::exists(path); | 539 | return fs::exists(path, ec); |
| 539 | #endif | 540 | #endif |
| 540 | } | 541 | } |
| 541 | 542 | ||
| 542 | bool IsFile(const fs::path& path) { | 543 | bool IsFile(const fs::path& path) { |
| 544 | std::error_code ec; | ||
| 543 | #ifdef ANDROID | 545 | #ifdef ANDROID |
| 544 | if (Android::IsContentUri(path)) { | 546 | if (Android::IsContentUri(path)) { |
| 545 | return !Android::IsDirectory(path); | 547 | return !Android::IsDirectory(path); |
| 546 | } else { | 548 | } else { |
| 547 | return fs::is_regular_file(path); | 549 | return fs::is_regular_file(path, ec); |
| 548 | } | 550 | } |
| 549 | #else | 551 | #else |
| 550 | return fs::is_regular_file(path); | 552 | return fs::is_regular_file(path, ec); |
| 551 | #endif | 553 | #endif |
| 552 | } | 554 | } |
| 553 | 555 | ||
| 554 | bool IsDir(const fs::path& path) { | 556 | bool IsDir(const fs::path& path) { |
| 557 | std::error_code ec; | ||
| 555 | #ifdef ANDROID | 558 | #ifdef ANDROID |
| 556 | if (Android::IsContentUri(path)) { | 559 | if (Android::IsContentUri(path)) { |
| 557 | return Android::IsDirectory(path); | 560 | return Android::IsDirectory(path); |
| 558 | } else { | 561 | } else { |
| 559 | return fs::is_directory(path); | 562 | return fs::is_directory(path, ec); |
| 560 | } | 563 | } |
| 561 | #else | 564 | #else |
| 562 | return fs::is_directory(path); | 565 | return fs::is_directory(path, ec); |
| 563 | #endif | 566 | #endif |
| 564 | } | 567 | } |
| 565 | 568 | ||
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) { | |||
| 112 | SUB(Service, NCM) \ | 112 | SUB(Service, NCM) \ |
| 113 | SUB(Service, NFC) \ | 113 | SUB(Service, NFC) \ |
| 114 | SUB(Service, NFP) \ | 114 | SUB(Service, NFP) \ |
| 115 | SUB(Service, NGCT) \ | 115 | SUB(Service, NGC) \ |
| 116 | SUB(Service, NIFM) \ | 116 | SUB(Service, NIFM) \ |
| 117 | SUB(Service, NIM) \ | 117 | SUB(Service, NIM) \ |
| 118 | SUB(Service, NOTIF) \ | 118 | 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 { | |||
| 80 | Service_NCM, ///< The NCM service | 80 | Service_NCM, ///< The NCM service |
| 81 | Service_NFC, ///< The NFC (Near-field communication) service | 81 | Service_NFC, ///< The NFC (Near-field communication) service |
| 82 | Service_NFP, ///< The NFP service | 82 | Service_NFP, ///< The NFP service |
| 83 | Service_NGCT, ///< The NGCT (No Good Content for Terra) service | 83 | Service_NGC, ///< The NGC (No Good Content) service |
| 84 | Service_NIFM, ///< The NIFM (Network interface) service | 84 | Service_NIFM, ///< The NIFM (Network interface) service |
| 85 | Service_NIM, ///< The NIM service | 85 | Service_NIM, ///< The NIM service |
| 86 | Service_NOTIF, ///< The NOTIF (Notification) service | 86 | 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 @@ | |||
| 19 | namespace Common { | 19 | namespace Common { |
| 20 | 20 | ||
| 21 | template <typename Condvar, typename Lock, typename Pred> | 21 | template <typename Condvar, typename Lock, typename Pred> |
| 22 | void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred&& pred) { | 22 | void CondvarWait(Condvar& cv, std::unique_lock<Lock>& lk, std::stop_token token, Pred&& pred) { |
| 23 | cv.wait(lock, token, std::move(pred)); | 23 | cv.wait(lk, token, std::move(pred)); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | template <typename Rep, typename Period> | 26 | template <typename Rep, typename Period> |
| @@ -332,13 +332,17 @@ private: | |||
| 332 | namespace Common { | 332 | namespace Common { |
| 333 | 333 | ||
| 334 | template <typename Condvar, typename Lock, typename Pred> | 334 | template <typename Condvar, typename Lock, typename Pred> |
| 335 | void CondvarWait(Condvar& cv, Lock& lock, std::stop_token token, Pred pred) { | 335 | void CondvarWait(Condvar& cv, std::unique_lock<Lock>& lk, std::stop_token token, Pred pred) { |
| 336 | if (token.stop_requested()) { | 336 | if (token.stop_requested()) { |
| 337 | return; | 337 | return; |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | std::stop_callback callback(token, [&] { cv.notify_all(); }); | 340 | std::stop_callback callback(token, [&] { |
| 341 | cv.wait(lock, [&] { return pred() || token.stop_requested(); }); | 341 | { std::scoped_lock lk2{*lk.mutex()}; } |
| 342 | cv.notify_all(); | ||
| 343 | }); | ||
| 344 | |||
| 345 | cv.wait(lk, [&] { return pred() || token.stop_requested(); }); | ||
| 342 | } | 346 | } |
| 343 | 347 | ||
| 344 | template <typename Rep, typename Period> | 348 | template <typename Rep, typename Period> |
| @@ -353,8 +357,10 @@ bool StoppableTimedWait(std::stop_token token, const std::chrono::duration<Rep, | |||
| 353 | 357 | ||
| 354 | std::stop_callback cb(token, [&] { | 358 | std::stop_callback cb(token, [&] { |
| 355 | // Wake up the waiting thread. | 359 | // Wake up the waiting thread. |
| 356 | std::unique_lock lk{m}; | 360 | { |
| 357 | stop_requested = true; | 361 | std::scoped_lock lk{m}; |
| 362 | stop_requested = true; | ||
| 363 | } | ||
| 358 | cv.notify_one(); | 364 | cv.notify_one(); |
| 359 | }); | 365 | }); |
| 360 | 366 | ||
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 { | |||
| 348 | Category::RendererDebug}; | 348 | Category::RendererDebug}; |
| 349 | Setting<bool> disable_shader_loop_safety_checks{ | 349 | Setting<bool> disable_shader_loop_safety_checks{ |
| 350 | linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug}; | 350 | linkage, false, "disable_shader_loop_safety_checks", Category::RendererDebug}; |
| 351 | Setting<bool> enable_renderdoc_hotkey{linkage, false, "renderdoc_hotkey", | ||
| 352 | Category::RendererDebug}; | ||
| 351 | 353 | ||
| 352 | // System | 354 | // System |
| 353 | SwitchableSetting<Language, true> language_index{linkage, | 355 | 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: | |||
| 225 | */ | 225 | */ |
| 226 | [[nodiscard]] virtual constexpr u32 EnumIndex() const = 0; | 226 | [[nodiscard]] virtual constexpr u32 EnumIndex() const = 0; |
| 227 | 227 | ||
| 228 | /** | ||
| 229 | * @returns True if the underlying type is a floating point storage | ||
| 230 | */ | ||
| 231 | [[nodiscard]] virtual constexpr bool IsFloatingPoint() const = 0; | ||
| 232 | |||
| 233 | /** | ||
| 234 | * @returns True if the underlying type is an integer storage | ||
| 235 | */ | ||
| 236 | [[nodiscard]] virtual constexpr bool IsIntegral() const = 0; | ||
| 237 | |||
| 228 | /* | 238 | /* |
| 229 | * Switchable settings | 239 | * Switchable settings |
| 230 | */ | 240 | */ |
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 @@ | |||
| 10 | #include <string> | 10 | #include <string> |
| 11 | #include <typeindex> | 11 | #include <typeindex> |
| 12 | #include <typeinfo> | 12 | #include <typeinfo> |
| 13 | #include <fmt/core.h> | ||
| 13 | #include "common/common_types.h" | 14 | #include "common/common_types.h" |
| 14 | #include "common/settings_common.h" | 15 | #include "common/settings_common.h" |
| 15 | #include "common/settings_enums.h" | 16 | #include "common/settings_enums.h" |
| @@ -115,8 +116,12 @@ protected: | |||
| 115 | } else if constexpr (std::is_same_v<Type, AudioEngine>) { | 116 | } else if constexpr (std::is_same_v<Type, AudioEngine>) { |
| 116 | // Compatibility with old AudioEngine setting being a string | 117 | // Compatibility with old AudioEngine setting being a string |
| 117 | return CanonicalizeEnum(value_); | 118 | return CanonicalizeEnum(value_); |
| 119 | } else if constexpr (std::is_floating_point_v<Type>) { | ||
| 120 | return fmt::format("{:f}", value_); | ||
| 121 | } else if constexpr (std::is_enum_v<Type>) { | ||
| 122 | return std::to_string(static_cast<u32>(value_)); | ||
| 118 | } else { | 123 | } else { |
| 119 | return std::to_string(static_cast<u64>(value_)); | 124 | return std::to_string(value_); |
| 120 | } | 125 | } |
| 121 | } | 126 | } |
| 122 | 127 | ||
| @@ -180,13 +185,15 @@ public: | |||
| 180 | this->SetValue(static_cast<u32>(std::stoul(input))); | 185 | this->SetValue(static_cast<u32>(std::stoul(input))); |
| 181 | } else if constexpr (std::is_same_v<Type, bool>) { | 186 | } else if constexpr (std::is_same_v<Type, bool>) { |
| 182 | this->SetValue(input == "true"); | 187 | this->SetValue(input == "true"); |
| 183 | } else if constexpr (std::is_same_v<Type, AudioEngine>) { | 188 | } else if constexpr (std::is_same_v<Type, float>) { |
| 184 | this->SetValue(ToEnum<Type>(input)); | 189 | this->SetValue(std::stof(input)); |
| 185 | } else { | 190 | } else { |
| 186 | this->SetValue(static_cast<Type>(std::stoll(input))); | 191 | this->SetValue(static_cast<Type>(std::stoll(input))); |
| 187 | } | 192 | } |
| 188 | } catch (std::invalid_argument&) { | 193 | } catch (std::invalid_argument&) { |
| 189 | this->SetValue(this->GetDefault()); | 194 | this->SetValue(this->GetDefault()); |
| 195 | } catch (std::out_of_range&) { | ||
| 196 | this->SetValue(this->GetDefault()); | ||
| 190 | } | 197 | } |
| 191 | } | 198 | } |
| 192 | 199 | ||
| @@ -215,11 +222,27 @@ public: | |||
| 215 | } | 222 | } |
| 216 | } | 223 | } |
| 217 | 224 | ||
| 225 | [[nodiscard]] constexpr bool IsFloatingPoint() const final { | ||
| 226 | return std::is_floating_point_v<Type>; | ||
| 227 | } | ||
| 228 | |||
| 229 | [[nodiscard]] constexpr bool IsIntegral() const final { | ||
| 230 | return std::is_integral_v<Type>; | ||
| 231 | } | ||
| 232 | |||
| 218 | [[nodiscard]] std::string MinVal() const override final { | 233 | [[nodiscard]] std::string MinVal() const override final { |
| 219 | return this->ToString(minimum); | 234 | if constexpr (std::is_arithmetic_v<Type> && !ranged) { |
| 235 | return this->ToString(std::numeric_limits<Type>::min()); | ||
| 236 | } else { | ||
| 237 | return this->ToString(minimum); | ||
| 238 | } | ||
| 220 | } | 239 | } |
| 221 | [[nodiscard]] std::string MaxVal() const override final { | 240 | [[nodiscard]] std::string MaxVal() const override final { |
| 222 | return this->ToString(maximum); | 241 | if constexpr (std::is_arithmetic_v<Type> && !ranged) { |
| 242 | return this->ToString(std::numeric_limits<Type>::max()); | ||
| 243 | } else { | ||
| 244 | return this->ToString(maximum); | ||
| 245 | } | ||
| 223 | } | 246 | } |
| 224 | 247 | ||
| 225 | [[nodiscard]] constexpr bool Ranged() const override { | 248 | [[nodiscard]] constexpr bool Ranged() const override { |