summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/common/alignment.h21
-rw-r--r--src/common/div_ceil.h8
-rw-r--r--src/common/fs/fs_paths.h1
-rw-r--r--src/common/fs/path_util.cpp1
-rw-r--r--src/common/fs/path_util.h1
-rw-r--r--src/common/intrusive_red_black_tree.h17
-rw-r--r--src/common/settings.cpp5
-rw-r--r--src/common/settings.h12
-rw-r--r--src/common/threadsafe_queue.h27
-rw-r--r--src/common/uuid.h7
-rw-r--r--src/common/vector_math.h4
11 files changed, 71 insertions, 33 deletions
diff --git a/src/common/alignment.h b/src/common/alignment.h
index 32d796ffa..1b56569d1 100644
--- a/src/common/alignment.h
+++ b/src/common/alignment.h
@@ -9,41 +9,48 @@
namespace Common {
template <typename T>
-requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignUp(T value, size_t size) {
+requires std::is_unsigned_v<T>
+[[nodiscard]] constexpr T AlignUp(T value, size_t size) {
auto mod{static_cast<T>(value % size)};
value -= mod;
return static_cast<T>(mod == T{0} ? value : value + size);
}
template <typename T>
-requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) {
+requires std::is_unsigned_v<T>
+[[nodiscard]] constexpr T AlignUpLog2(T value, size_t align_log2) {
return static_cast<T>((value + ((1ULL << align_log2) - 1)) >> align_log2 << align_log2);
}
template <typename T>
-requires std::is_unsigned_v<T>[[nodiscard]] constexpr T AlignDown(T value, size_t size) {
+requires std::is_unsigned_v<T>
+[[nodiscard]] constexpr T AlignDown(T value, size_t size) {
return static_cast<T>(value - value % size);
}
template <typename T>
-requires std::is_unsigned_v<T>[[nodiscard]] constexpr bool Is4KBAligned(T value) {
+requires std::is_unsigned_v<T>
+[[nodiscard]] constexpr bool Is4KBAligned(T value) {
return (value & 0xFFF) == 0;
}
template <typename T>
-requires std::is_unsigned_v<T>[[nodiscard]] constexpr bool IsWordAligned(T value) {
+requires std::is_unsigned_v<T>
+[[nodiscard]] constexpr bool IsWordAligned(T value) {
return (value & 0b11) == 0;
}
template <typename T>
-requires std::is_integral_v<T>[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) {
+requires std::is_integral_v<T>
+[[nodiscard]] constexpr bool IsAligned(T value, size_t alignment) {
using U = typename std::make_unsigned_t<T>;
const U mask = static_cast<U>(alignment - 1);
return (value & mask) == 0;
}
template <typename T, typename U>
-requires std::is_integral_v<T>[[nodiscard]] constexpr T DivideUp(T x, U y) {
+requires std::is_integral_v<T>
+[[nodiscard]] constexpr T DivideUp(T x, U y) {
return (x + (y - 1)) / y;
}
diff --git a/src/common/div_ceil.h b/src/common/div_ceil.h
index 95e1489a9..e1db35464 100644
--- a/src/common/div_ceil.h
+++ b/src/common/div_ceil.h
@@ -11,15 +11,15 @@ namespace Common {
/// Ceiled integer division.
template <typename N, typename D>
-requires std::is_integral_v<N>&& std::is_unsigned_v<D>[[nodiscard]] constexpr N DivCeil(N number,
- D divisor) {
+requires std::is_integral_v<N> && std::is_unsigned_v<D>
+[[nodiscard]] constexpr N DivCeil(N number, D divisor) {
return static_cast<N>((static_cast<D>(number) + divisor - 1) / divisor);
}
/// Ceiled integer division with logarithmic divisor in base 2
template <typename N, typename D>
-requires std::is_integral_v<N>&& std::is_unsigned_v<D>[[nodiscard]] constexpr N DivCeilLog2(
- N value, D alignment_log2) {
+requires std::is_integral_v<N> && std::is_unsigned_v<D>
+[[nodiscard]] constexpr N DivCeilLog2(N value, D alignment_log2) {
return static_cast<N>((static_cast<D>(value) + (D(1) << alignment_log2) - 1) >> alignment_log2);
}
diff --git a/src/common/fs/fs_paths.h b/src/common/fs/fs_paths.h
index b32614797..5d447f108 100644
--- a/src/common/fs/fs_paths.h
+++ b/src/common/fs/fs_paths.h
@@ -21,6 +21,7 @@
#define SCREENSHOTS_DIR "screenshots"
#define SDMC_DIR "sdmc"
#define SHADER_DIR "shader"
+#define TAS_DIR "tas"
// yuzu-specific files
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp
index 6cdd14f13..43b79bd6d 100644
--- a/src/common/fs/path_util.cpp
+++ b/src/common/fs/path_util.cpp
@@ -116,6 +116,7 @@ private:
GenerateYuzuPath(YuzuPath::ScreenshotsDir, yuzu_path / SCREENSHOTS_DIR);
GenerateYuzuPath(YuzuPath::SDMCDir, yuzu_path / SDMC_DIR);
GenerateYuzuPath(YuzuPath::ShaderDir, yuzu_path / SHADER_DIR);
+ GenerateYuzuPath(YuzuPath::TASDir, yuzu_path / TAS_DIR);
}
~PathManagerImpl() = default;
diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h
index f956ac9a2..0a9e3a145 100644
--- a/src/common/fs/path_util.h
+++ b/src/common/fs/path_util.h
@@ -23,6 +23,7 @@ enum class YuzuPath {
ScreenshotsDir, // Where yuzu screenshots are stored.
SDMCDir, // Where the emulated SDMC is stored.
ShaderDir, // Where shaders are stored.
+ TASDir, // Where TAS scripts are stored.
};
/**
diff --git a/src/common/intrusive_red_black_tree.h b/src/common/intrusive_red_black_tree.h
index 1f696fe80..3173cc449 100644
--- a/src/common/intrusive_red_black_tree.h
+++ b/src/common/intrusive_red_black_tree.h
@@ -235,20 +235,19 @@ public:
template <typename T>
concept HasLightCompareType = requires {
- { std::is_same<typename T::LightCompareType, void>::value }
- ->std::convertible_to<bool>;
+ { std::is_same<typename T::LightCompareType, void>::value } -> std::convertible_to<bool>;
};
namespace impl {
-template <typename T, typename Default>
-consteval auto* GetLightCompareType() {
- if constexpr (HasLightCompareType<T>) {
- return static_cast<typename T::LightCompareType*>(nullptr);
- } else {
- return static_cast<Default*>(nullptr);
+ template <typename T, typename Default>
+ consteval auto* GetLightCompareType() {
+ if constexpr (HasLightCompareType<T>) {
+ return static_cast<typename T::LightCompareType*>(nullptr);
+ } else {
+ return static_cast<Default*>(nullptr);
+ }
}
-}
} // namespace impl
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 0d2df80a8..69f0bd8c0 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -61,7 +61,6 @@ void LogSettings() {
log_setting("Renderer_UseAsynchronousShaders", values.use_asynchronous_shaders.GetValue());
log_setting("Renderer_AnisotropicFilteringLevel", values.max_anisotropy.GetValue());
log_setting("Audio_OutputEngine", values.sink_id.GetValue());
- log_setting("Audio_EnableAudioStretching", values.enable_audio_stretching.GetValue());
log_setting("Audio_OutputDevice", values.audio_device_id.GetValue());
log_setting("DataStorage_UseVirtualSd", values.use_virtual_sd.GetValue());
log_path("DataStorage_CacheDir", Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir));
@@ -72,6 +71,9 @@ void LogSettings() {
log_setting("Debugging_ProgramArgs", values.program_args.GetValue());
log_setting("Services_BCATBackend", values.bcat_backend.GetValue());
log_setting("Services_BCATBoxcatLocal", values.bcat_boxcat_local.GetValue());
+ log_setting("Input_EnableMotion", values.motion_enabled.GetValue());
+ log_setting("Input_EnableVibration", values.vibration_enabled.GetValue());
+ log_setting("Input_EnableRawInput", values.enable_raw_input.GetValue());
}
bool IsConfiguringGlobal() {
@@ -112,7 +114,6 @@ void RestoreGlobalState(bool is_powered_on) {
}
// Audio
- values.enable_audio_stretching.SetGlobal(true);
values.volume.SetGlobal(true);
// Core
diff --git a/src/common/settings.h b/src/common/settings.h
index b7195670b..c53d5acc3 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -16,7 +16,6 @@
#include "common/common_types.h"
#include "common/settings_input.h"
-#include "input_common/udp/client.h"
namespace Settings {
@@ -415,7 +414,6 @@ struct Values {
BasicSetting<std::string> audio_device_id{"auto", "output_device"};
BasicSetting<std::string> sink_id{"auto", "output_engine"};
BasicSetting<bool> audio_muted{false, "audio_muted"};
- Setting<bool> enable_audio_stretching{true, "enable_audio_stretching"};
RangedSetting<u8> volume{100, 0, 100, "volume"};
// Core
@@ -504,14 +502,20 @@ struct Values {
Setting<bool> use_docked_mode{true, "use_docked_mode"};
+ BasicSetting<bool> enable_raw_input{false, "enable_raw_input"};
+
Setting<bool> vibration_enabled{true, "vibration_enabled"};
Setting<bool> enable_accurate_vibrations{false, "enable_accurate_vibrations"};
Setting<bool> motion_enabled{true, "motion_enabled"};
BasicSetting<std::string> motion_device{"engine:motion_emu,update_period:100,sensitivity:0.01",
"motion_device"};
- BasicSetting<std::string> udp_input_servers{InputCommon::CemuhookUDP::DEFAULT_SRV,
- "udp_input_servers"};
+ BasicSetting<std::string> udp_input_servers{"127.0.0.1:26760", "udp_input_servers"};
+
+ BasicSetting<bool> pause_tas_on_load{true, "pause_tas_on_load"};
+ BasicSetting<bool> tas_enable{false, "tas_enable"};
+ BasicSetting<bool> tas_loop{false, "tas_loop"};
+ BasicSetting<bool> tas_swap_controllers{true, "tas_swap_controllers"};
BasicSetting<bool> mouse_panning{false, "mouse_panning"};
BasicRangedSetting<u8> mouse_panning_sensitivity{10, 1, 100, "mouse_panning_sensitivity"};
diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h
index 8430b9778..2c8c2b90e 100644
--- a/src/common/threadsafe_queue.h
+++ b/src/common/threadsafe_queue.h
@@ -14,7 +14,7 @@
#include <utility>
namespace Common {
-template <typename T>
+template <typename T, bool with_stop_token = false>
class SPSCQueue {
public:
SPSCQueue() {
@@ -84,7 +84,7 @@ public:
void Wait() {
if (Empty()) {
std::unique_lock lock{cv_mutex};
- cv.wait(lock, [this]() { return !Empty(); });
+ cv.wait(lock, [this] { return !Empty(); });
}
}
@@ -95,6 +95,19 @@ public:
return t;
}
+ T PopWait(std::stop_token stop_token) {
+ if (Empty()) {
+ std::unique_lock lock{cv_mutex};
+ cv.wait(lock, stop_token, [this] { return !Empty(); });
+ }
+ if (stop_token.stop_requested()) {
+ return T{};
+ }
+ T t;
+ Pop(t);
+ return t;
+ }
+
// not thread-safe
void Clear() {
size.store(0);
@@ -123,13 +136,13 @@ private:
ElementPtr* read_ptr;
std::atomic_size_t size{0};
std::mutex cv_mutex;
- std::condition_variable cv;
+ std::conditional_t<with_stop_token, std::condition_variable_any, std::condition_variable> cv;
};
// a simple thread-safe,
// single reader, multiple writer queue
-template <typename T>
+template <typename T, bool with_stop_token = false>
class MPSCQueue {
public:
[[nodiscard]] std::size_t Size() const {
@@ -166,13 +179,17 @@ public:
return spsc_queue.PopWait();
}
+ T PopWait(std::stop_token stop_token) {
+ return spsc_queue.PopWait(stop_token);
+ }
+
// not thread-safe
void Clear() {
spsc_queue.Clear();
}
private:
- SPSCQueue<T> spsc_queue;
+ SPSCQueue<T, with_stop_token> spsc_queue;
std::mutex write_lock;
};
} // namespace Common
diff --git a/src/common/uuid.h b/src/common/uuid.h
index 2353179d8..8ea01f8da 100644
--- a/src/common/uuid.h
+++ b/src/common/uuid.h
@@ -58,6 +58,13 @@ struct UUID {
uuid = INVALID_UUID;
}
+ [[nodiscard]] constexpr bool IsInvalid() const {
+ return uuid == INVALID_UUID;
+ }
+ [[nodiscard]] constexpr bool IsValid() const {
+ return !IsInvalid();
+ }
+
// TODO(ogniK): Properly generate a Nintendo ID
[[nodiscard]] constexpr u64 GetNintendoID() const {
return uuid[0];
diff --git a/src/common/vector_math.h b/src/common/vector_math.h
index 22dba3c2d..ba7c363c1 100644
--- a/src/common/vector_math.h
+++ b/src/common/vector_math.h
@@ -667,8 +667,8 @@ template <typename T>
// linear interpolation via float: 0.0=begin, 1.0=end
template <typename X>
-[[nodiscard]] constexpr decltype(X{} * float{} + X{} * float{}) Lerp(const X& begin, const X& end,
- const float t) {
+[[nodiscard]] constexpr decltype(X{} * float{} + X{} * float{})
+ Lerp(const X& begin, const X& end, const float t) {
return begin * (1.f - t) + end * t;
}