summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/CMakeLists.txt4
-rw-r--r--src/common/assert.cpp7
-rw-r--r--src/common/logging/backend.cpp39
-rw-r--r--src/common/logging/backend.h8
-rw-r--r--src/common/logging/filter.cpp4
-rw-r--r--src/common/logging/filter.h4
-rw-r--r--src/common/logging/log.h34
-rw-r--r--src/common/logging/text_formatter.cpp4
-rw-r--r--src/common/logging/text_formatter.h4
-rw-r--r--src/common/settings.cpp (renamed from src/core/settings.cpp)15
-rw-r--r--src/common/settings.h (renamed from src/core/settings.h)15
-rw-r--r--src/common/settings_input.cpp (renamed from src/input_common/settings.cpp)2
-rw-r--r--src/common/settings_input.h (renamed from src/input_common/settings.h)1
13 files changed, 73 insertions, 68 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 9f8dafa3b..88644eeb6 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -152,6 +152,10 @@ add_library(common STATIC
scm_rev.cpp
scm_rev.h
scope_exit.h
+ settings.cpp
+ settings.h
+ settings_input.cpp
+ settings_input.h
spin_lock.cpp
spin_lock.h
stream.cpp
diff --git a/src/common/assert.cpp b/src/common/assert.cpp
index d7d91b96b..72f1121aa 100644
--- a/src/common/assert.cpp
+++ b/src/common/assert.cpp
@@ -3,9 +3,12 @@
// Refer to the license.txt file included.
#include "common/assert.h"
-
#include "common/common_funcs.h"
+#include "common/settings.h"
+
void assert_handle_failure() {
- Crash();
+ if (Settings::values.use_debug_asserts) {
+ Crash();
+ }
}
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 4575df24d..96efa977d 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -21,11 +21,11 @@
#include "common/logging/backend.h"
#include "common/logging/log.h"
#include "common/logging/text_formatter.h"
+#include "common/settings.h"
#include "common/string_util.h"
#include "common/threadsafe_queue.h"
-#include "core/settings.h"
-namespace Log {
+namespace Common::Log {
/**
* Static state as a singleton.
@@ -37,8 +37,11 @@ public:
return backend;
}
- Impl(Impl const&) = delete;
- const Impl& operator=(Impl const&) = delete;
+ Impl(const Impl&) = delete;
+ Impl& operator=(const Impl&) = delete;
+
+ Impl(Impl&&) = delete;
+ Impl& operator=(Impl&&) = delete;
void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num,
const char* function, std::string message) {
@@ -53,10 +56,10 @@ public:
void RemoveBackend(std::string_view backend_name) {
std::lock_guard lock{writing_mutex};
- const auto it =
- std::remove_if(backends.begin(), backends.end(),
- [&backend_name](const auto& i) { return backend_name == i->GetName(); });
- backends.erase(it, backends.end());
+
+ std::erase_if(backends, [&backend_name](const auto& backend) {
+ return backend_name == backend->GetName();
+ });
}
const Filter& GetGlobalFilter() const {
@@ -132,7 +135,7 @@ private:
std::mutex writing_mutex;
std::thread backend_thread;
std::vector<std::unique_ptr<Backend>> backends;
- Common::MPSCQueue<Log::Entry> message_queue;
+ MPSCQueue<Entry> message_queue;
Filter filter;
std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
};
@@ -145,17 +148,19 @@ void ColorConsoleBackend::Write(const Entry& entry) {
PrintColoredMessage(entry);
}
-FileBackend::FileBackend(const std::string& filename) : bytes_written(0) {
- if (Common::FS::Exists(filename + ".old.txt")) {
- Common::FS::Delete(filename + ".old.txt");
+FileBackend::FileBackend(const std::string& filename) {
+ const auto old_filename = filename + ".old.txt";
+
+ if (FS::Exists(old_filename)) {
+ FS::Delete(old_filename);
}
- if (Common::FS::Exists(filename)) {
- Common::FS::Rename(filename, filename + ".old.txt");
+ if (FS::Exists(filename)) {
+ FS::Rename(filename, old_filename);
}
// _SH_DENYWR allows read only access to the file for other programs.
// It is #defined to 0 on other platforms
- file = Common::FS::IOFile(filename, "w", _SH_DENYWR);
+ file = FS::IOFile(filename, "w", _SH_DENYWR);
}
void FileBackend::Write(const Entry& entry) {
@@ -182,7 +187,7 @@ void FileBackend::Write(const Entry& entry) {
void DebuggerBackend::Write(const Entry& entry) {
#ifdef _WIN32
- ::OutputDebugStringW(Common::UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str());
+ ::OutputDebugStringW(UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str());
#endif
}
@@ -342,4 +347,4 @@ void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
instance.PushEntry(log_class, log_level, filename, line_num, function,
fmt::vformat(format, args));
}
-} // namespace Log
+} // namespace Common::Log
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h
index da1c2f185..9dd2589c3 100644
--- a/src/common/logging/backend.h
+++ b/src/common/logging/backend.h
@@ -11,7 +11,7 @@
#include "common/logging/filter.h"
#include "common/logging/log.h"
-namespace Log {
+namespace Common::Log {
class Filter;
@@ -94,8 +94,8 @@ public:
void Write(const Entry& entry) override;
private:
- Common::FS::IOFile file;
- std::size_t bytes_written;
+ FS::IOFile file;
+ std::size_t bytes_written = 0;
};
/**
@@ -135,4 +135,4 @@ const char* GetLevelName(Level log_level);
* never get the message
*/
void SetGlobalFilter(const Filter& filter);
-} // namespace Log \ No newline at end of file
+} // namespace Common::Log \ No newline at end of file
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp
index 2eccbcd8d..20a2dd106 100644
--- a/src/common/logging/filter.cpp
+++ b/src/common/logging/filter.cpp
@@ -7,7 +7,7 @@
#include "common/logging/filter.h"
#include "common/string_util.h"
-namespace Log {
+namespace Common::Log {
namespace {
template <typename It>
Level GetLevelByName(const It begin, const It end) {
@@ -103,4 +103,4 @@ bool Filter::IsDebug() const {
});
}
-} // namespace Log
+} // namespace Common::Log
diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h
index 773df6f2c..f5673a9f6 100644
--- a/src/common/logging/filter.h
+++ b/src/common/logging/filter.h
@@ -9,7 +9,7 @@
#include <string_view>
#include "common/logging/log.h"
-namespace Log {
+namespace Common::Log {
/**
* Implements a log message filter which allows different log classes to have different minimum
@@ -51,4 +51,4 @@ public:
private:
std::array<Level, static_cast<std::size_t>(Class::Count)> class_levels;
};
-} // namespace Log
+} // namespace Common::Log
diff --git a/src/common/logging/log.h b/src/common/logging/log.h
index 3d7b7dab7..1f0f8db52 100644
--- a/src/common/logging/log.h
+++ b/src/common/logging/log.h
@@ -7,7 +7,7 @@
#include <fmt/format.h>
#include "common/common_types.h"
-namespace Log {
+namespace Common::Log {
// trims up to and including the last of ../, ..\, src/, src\ in a string
constexpr const char* TrimSourcePath(std::string_view source) {
@@ -148,28 +148,34 @@ void FmtLogMessage(Class log_class, Level log_level, const char* filename, unsig
fmt::make_format_args(args...));
}
-} // namespace Log
+} // namespace Common::Log
#ifdef _DEBUG
#define LOG_TRACE(log_class, ...) \
- ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Trace, \
- ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
+ Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Trace, \
+ Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
+ __VA_ARGS__)
#else
#define LOG_TRACE(log_class, fmt, ...) (void(0))
#endif
#define LOG_DEBUG(log_class, ...) \
- ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Debug, \
- ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
+ Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Debug, \
+ Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
+ __VA_ARGS__)
#define LOG_INFO(log_class, ...) \
- ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Info, \
- ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
+ Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Info, \
+ Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
+ __VA_ARGS__)
#define LOG_WARNING(log_class, ...) \
- ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Warning, \
- ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
+ Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Warning, \
+ Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
+ __VA_ARGS__)
#define LOG_ERROR(log_class, ...) \
- ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Error, \
- ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
+ Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Error, \
+ Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
+ __VA_ARGS__)
#define LOG_CRITICAL(log_class, ...) \
- ::Log::FmtLogMessage(::Log::Class::log_class, ::Log::Level::Critical, \
- ::Log::TrimSourcePath(__FILE__), __LINE__, __func__, __VA_ARGS__)
+ Common::Log::FmtLogMessage(Common::Log::Class::log_class, Common::Log::Level::Critical, \
+ Common::Log::TrimSourcePath(__FILE__), __LINE__, __func__, \
+ __VA_ARGS__)
diff --git a/src/common/logging/text_formatter.cpp b/src/common/logging/text_formatter.cpp
index 6a0605c63..80ee2cca1 100644
--- a/src/common/logging/text_formatter.cpp
+++ b/src/common/logging/text_formatter.cpp
@@ -16,7 +16,7 @@
#include "common/logging/text_formatter.h"
#include "common/string_util.h"
-namespace Log {
+namespace Common::Log {
std::string FormatLogMessage(const Entry& entry) {
unsigned int time_seconds = static_cast<unsigned int>(entry.timestamp.count() / 1000000);
@@ -108,4 +108,4 @@ void PrintColoredMessage(const Entry& entry) {
#undef ESC
#endif
}
-} // namespace Log
+} // namespace Common::Log
diff --git a/src/common/logging/text_formatter.h b/src/common/logging/text_formatter.h
index b6d9e57c8..171e74cfe 100644
--- a/src/common/logging/text_formatter.h
+++ b/src/common/logging/text_formatter.h
@@ -7,7 +7,7 @@
#include <cstddef>
#include <string>
-namespace Log {
+namespace Common::Log {
struct Entry;
@@ -17,4 +17,4 @@ std::string FormatLogMessage(const Entry& entry);
void PrintMessage(const Entry& entry);
/// Prints the same message as `PrintMessage`, but colored according to the severity level.
void PrintColoredMessage(const Entry& entry);
-} // namespace Log
+} // namespace Common::Log
diff --git a/src/core/settings.cpp b/src/common/settings.cpp
index 2ae5196e0..702b6598d 100644
--- a/src/core/settings.cpp
+++ b/src/common/settings.cpp
@@ -1,4 +1,4 @@
-// Copyright 2014 Citra Emulator Project
+// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@@ -7,10 +7,7 @@
#include "common/assert.h"
#include "common/file_util.h"
#include "common/logging/log.h"
-#include "core/core.h"
-#include "core/hle/service/hid/hid.h"
-#include "core/settings.h"
-#include "video_core/renderer_base.h"
+#include "common/settings.h"
namespace Settings {
@@ -32,14 +29,6 @@ std::string GetTimeZoneString() {
return timezones[time_zone_index];
}
-void Apply(Core::System& system) {
- if (system.IsPoweredOn()) {
- system.Renderer().RefreshBaseSettings();
- }
-
- Service::HID::ReloadInputDevices();
-}
-
void LogSettings() {
const auto log_setting = [](std::string_view name, const auto& value) {
LOG_INFO(Config, "{}: {}", name, value);
diff --git a/src/core/settings.h b/src/common/settings.h
index 6c03a6ea9..d39b4aa45 100644
--- a/src/core/settings.h
+++ b/src/common/settings.h
@@ -1,4 +1,4 @@
-// Copyright 2014 Citra Emulator Project
+// Copyright 2021 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
@@ -11,16 +11,13 @@
#include <optional>
#include <string>
#include <vector>
-#include "common/common_types.h"
-#include "input_common/settings.h"
-namespace Core {
-class System;
-}
+#include "common/common_types.h"
+#include "common/settings_input.h"
namespace Settings {
-enum class RendererBackend {
+enum class RendererBackend : u32 {
OpenGL = 0,
Vulkan = 1,
};
@@ -31,7 +28,7 @@ enum class GPUAccuracy : u32 {
Extreme = 2,
};
-enum class CPUAccuracy {
+enum class CPUAccuracy : u32 {
Accurate = 0,
Unsafe = 1,
DebugMode = 2,
@@ -223,6 +220,7 @@ struct Values {
bool quest_flag;
bool disable_macro_jit;
bool extended_logging;
+ bool use_debug_asserts;
bool use_auto_stub;
// Miscellaneous
@@ -255,7 +253,6 @@ float Volume();
std::string GetTimeZoneString();
-void Apply(Core::System& system);
void LogSettings();
// Restore the global state of all applicable settings in the Values struct
diff --git a/src/input_common/settings.cpp b/src/common/settings_input.cpp
index 557e7a9a0..bea2b837b 100644
--- a/src/input_common/settings.cpp
+++ b/src/common/settings_input.cpp
@@ -2,7 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
-#include "input_common/settings.h"
+#include "common/settings_input.h"
namespace Settings {
namespace NativeButton {
diff --git a/src/input_common/settings.h b/src/common/settings_input.h
index a59f5d461..609600582 100644
--- a/src/input_common/settings.h
+++ b/src/common/settings_input.h
@@ -6,6 +6,7 @@
#include <array>
#include <string>
+
#include "common/common_types.h"
namespace Settings {