Compare commits
29 Commits
__refs_pul
...
__refs_pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cfb51e5e7 | ||
|
|
2c357c929c | ||
|
|
482e203d5c | ||
|
|
a2f23746c2 | ||
|
|
215b13f2a2 | ||
|
|
35ed9425d7 | ||
|
|
74cc8721c7 | ||
|
|
8ef1db78b0 | ||
|
|
18c8f10ff2 | ||
|
|
96d881f087 | ||
|
|
0e950baf41 | ||
|
|
8113f55f4b | ||
|
|
ddbefc71cb | ||
|
|
85143e8376 | ||
|
|
504abbd6e0 | ||
|
|
4cccbe7989 | ||
|
|
5eb5c96750 | ||
|
|
5da55cbac9 | ||
|
|
81cc4df1f9 | ||
|
|
25f3d358b1 | ||
|
|
a3c8bb251d | ||
|
|
327533be1f | ||
|
|
61ea2115c7 | ||
|
|
fb3ef957bb | ||
|
|
78f72b3bf5 | ||
|
|
818721d12d | ||
|
|
442aad9b27 | ||
|
|
8e0f97ac96 | ||
|
|
345d691328 |
1
dist/languages/.tx/config
vendored
1
dist/languages/.tx/config
vendored
@@ -11,3 +11,4 @@ type = QT
|
||||
file_filter = ../../src/android/app/src/main/res/values-<lang>/strings.xml
|
||||
source_file = ../../src/android/app/src/main/res/values/strings.xml
|
||||
type = ANDROID
|
||||
lang_map = ja_JP:ja, ko_KR:ko, pt_BR:pt-rBR, pt_PT:pt-rPT, ru_RU:ru, vi_VN:vi, zh_CN:zh-rCN, zh_TW:zh-rTW
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fmt/format.h>
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace Common {
|
||||
@@ -29,6 +30,8 @@ namespace Common {
|
||||
|
||||
template <std::size_t Size, bool le = false>
|
||||
[[nodiscard]] constexpr std::array<u8, Size> HexStringToArray(std::string_view str) {
|
||||
ASSERT_MSG(Size * 2 <= str.size(), "Invalid string size");
|
||||
|
||||
std::array<u8, Size> out{};
|
||||
if constexpr (le) {
|
||||
for (std::size_t i = 2 * Size - 2; i <= 2 * Size; i -= 2) {
|
||||
|
||||
@@ -186,68 +186,68 @@ static_assert(std::is_trivially_destructible_v<PhysicalAddress>);
|
||||
static_assert(std::is_trivially_destructible_v<VirtualAddress>);
|
||||
static_assert(std::is_trivially_destructible_v<ProcessAddress>);
|
||||
|
||||
static_assert(Null<uint64_t> == 0);
|
||||
static_assert(Null<uint64_t> == 0U);
|
||||
static_assert(Null<PhysicalAddress> == Null<uint64_t>);
|
||||
static_assert(Null<VirtualAddress> == Null<uint64_t>);
|
||||
static_assert(Null<ProcessAddress> == Null<uint64_t>);
|
||||
|
||||
// Constructor/assignment validations.
|
||||
static_assert([] {
|
||||
const PhysicalAddress a(5);
|
||||
const PhysicalAddress a(5U);
|
||||
PhysicalAddress b(a);
|
||||
return b;
|
||||
}() == PhysicalAddress(5));
|
||||
}() == PhysicalAddress(5U));
|
||||
static_assert([] {
|
||||
const PhysicalAddress a(5);
|
||||
PhysicalAddress b(10);
|
||||
const PhysicalAddress a(5U);
|
||||
PhysicalAddress b(10U);
|
||||
b = a;
|
||||
return b;
|
||||
}() == PhysicalAddress(5));
|
||||
}() == PhysicalAddress(5U));
|
||||
|
||||
// Arithmetic validations.
|
||||
static_assert(PhysicalAddress(10) + 5 == PhysicalAddress(15));
|
||||
static_assert(PhysicalAddress(10) - 5 == PhysicalAddress(5));
|
||||
static_assert(PhysicalAddress(10U) + 5U == PhysicalAddress(15U));
|
||||
static_assert(PhysicalAddress(10U) - 5U == PhysicalAddress(5U));
|
||||
static_assert([] {
|
||||
PhysicalAddress v(10);
|
||||
v += 5;
|
||||
PhysicalAddress v(10U);
|
||||
v += 5U;
|
||||
return v;
|
||||
}() == PhysicalAddress(15));
|
||||
}() == PhysicalAddress(15U));
|
||||
static_assert([] {
|
||||
PhysicalAddress v(10);
|
||||
v -= 5;
|
||||
PhysicalAddress v(10U);
|
||||
v -= 5U;
|
||||
return v;
|
||||
}() == PhysicalAddress(5));
|
||||
static_assert(PhysicalAddress(10)++ == PhysicalAddress(10));
|
||||
static_assert(++PhysicalAddress(10) == PhysicalAddress(11));
|
||||
static_assert(PhysicalAddress(10)-- == PhysicalAddress(10));
|
||||
static_assert(--PhysicalAddress(10) == PhysicalAddress(9));
|
||||
}() == PhysicalAddress(5U));
|
||||
static_assert(PhysicalAddress(10U)++ == PhysicalAddress(10U));
|
||||
static_assert(++PhysicalAddress(10U) == PhysicalAddress(11U));
|
||||
static_assert(PhysicalAddress(10U)-- == PhysicalAddress(10U));
|
||||
static_assert(--PhysicalAddress(10U) == PhysicalAddress(9U));
|
||||
|
||||
// Logical validations.
|
||||
static_assert((PhysicalAddress(0b11111111) >> 1) == 0b01111111);
|
||||
static_assert((PhysicalAddress(0b10101010) >> 1) == 0b01010101);
|
||||
static_assert((PhysicalAddress(0b11111111) << 1) == 0b111111110);
|
||||
static_assert((PhysicalAddress(0b01010101) << 1) == 0b10101010);
|
||||
static_assert((PhysicalAddress(0b11111111) & 0b01010101) == 0b01010101);
|
||||
static_assert((PhysicalAddress(0b11111111) & 0b10101010) == 0b10101010);
|
||||
static_assert((PhysicalAddress(0b01010101) & 0b10101010) == 0b00000000);
|
||||
static_assert((PhysicalAddress(0b00000000) | 0b01010101) == 0b01010101);
|
||||
static_assert((PhysicalAddress(0b11111111) | 0b01010101) == 0b11111111);
|
||||
static_assert((PhysicalAddress(0b10101010) | 0b01010101) == 0b11111111);
|
||||
static_assert((PhysicalAddress(0b11111111U) >> 1) == 0b01111111U);
|
||||
static_assert((PhysicalAddress(0b10101010U) >> 1) == 0b01010101U);
|
||||
static_assert((PhysicalAddress(0b11111111U) << 1) == 0b111111110U);
|
||||
static_assert((PhysicalAddress(0b01010101U) << 1) == 0b10101010U);
|
||||
static_assert((PhysicalAddress(0b11111111U) & 0b01010101U) == 0b01010101U);
|
||||
static_assert((PhysicalAddress(0b11111111U) & 0b10101010U) == 0b10101010U);
|
||||
static_assert((PhysicalAddress(0b01010101U) & 0b10101010U) == 0b00000000U);
|
||||
static_assert((PhysicalAddress(0b00000000U) | 0b01010101U) == 0b01010101U);
|
||||
static_assert((PhysicalAddress(0b11111111U) | 0b01010101U) == 0b11111111U);
|
||||
static_assert((PhysicalAddress(0b10101010U) | 0b01010101U) == 0b11111111U);
|
||||
|
||||
// Comparisons.
|
||||
static_assert(PhysicalAddress(0) == PhysicalAddress(0));
|
||||
static_assert(PhysicalAddress(0) != PhysicalAddress(1));
|
||||
static_assert(PhysicalAddress(0) < PhysicalAddress(1));
|
||||
static_assert(PhysicalAddress(0) <= PhysicalAddress(1));
|
||||
static_assert(PhysicalAddress(1) > PhysicalAddress(0));
|
||||
static_assert(PhysicalAddress(1) >= PhysicalAddress(0));
|
||||
static_assert(PhysicalAddress(0U) == PhysicalAddress(0U));
|
||||
static_assert(PhysicalAddress(0U) != PhysicalAddress(1U));
|
||||
static_assert(PhysicalAddress(0U) < PhysicalAddress(1U));
|
||||
static_assert(PhysicalAddress(0U) <= PhysicalAddress(1U));
|
||||
static_assert(PhysicalAddress(1U) > PhysicalAddress(0U));
|
||||
static_assert(PhysicalAddress(1U) >= PhysicalAddress(0U));
|
||||
|
||||
static_assert(!(PhysicalAddress(0) == PhysicalAddress(1)));
|
||||
static_assert(!(PhysicalAddress(0) != PhysicalAddress(0)));
|
||||
static_assert(!(PhysicalAddress(1) < PhysicalAddress(0)));
|
||||
static_assert(!(PhysicalAddress(1) <= PhysicalAddress(0)));
|
||||
static_assert(!(PhysicalAddress(0) > PhysicalAddress(1)));
|
||||
static_assert(!(PhysicalAddress(0) >= PhysicalAddress(1)));
|
||||
static_assert(!(PhysicalAddress(0U) == PhysicalAddress(1U)));
|
||||
static_assert(!(PhysicalAddress(0U) != PhysicalAddress(0U)));
|
||||
static_assert(!(PhysicalAddress(1U) < PhysicalAddress(0U)));
|
||||
static_assert(!(PhysicalAddress(1U) <= PhysicalAddress(0U)));
|
||||
static_assert(!(PhysicalAddress(0U) > PhysicalAddress(1U)));
|
||||
static_assert(!(PhysicalAddress(0U) >= PhysicalAddress(1U)));
|
||||
|
||||
} // namespace Common
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ std::string GDBStubA32::RegRead(const Kernel::KThread* thread, size_t id) const
|
||||
} else if (id == CPSR_REGISTER) {
|
||||
return ValueToHex(context.pstate);
|
||||
} else if (id >= D0_REGISTER && id < Q0_REGISTER) {
|
||||
return ValueToHex(fprs[id - D0_REGISTER][0]);
|
||||
return ValueToHex(fprs[(id - D0_REGISTER) / 2][(id - D0_REGISTER) % 2]);
|
||||
} else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) {
|
||||
return ValueToHex(fprs[id - Q0_REGISTER]);
|
||||
} else if (id == FPSCR_REGISTER) {
|
||||
@@ -406,7 +406,7 @@ void GDBStubA32::RegWrite(Kernel::KThread* thread, size_t id, std::string_view v
|
||||
} else if (id == CPSR_REGISTER) {
|
||||
context.pstate = HexToValue<u32>(value);
|
||||
} else if (id >= D0_REGISTER && id < Q0_REGISTER) {
|
||||
fprs[id - D0_REGISTER] = {HexToValue<u64>(value), 0};
|
||||
fprs[(id - D0_REGISTER) / 2][(id - D0_REGISTER) % 2] = HexToValue<u64>(value);
|
||||
} else if (id >= Q0_REGISTER && id < FPSCR_REGISTER) {
|
||||
fprs[id - Q0_REGISTER] = HexToValue<u128>(value);
|
||||
} else if (id == FPSCR_REGISTER) {
|
||||
|
||||
@@ -115,6 +115,11 @@ struct ArgumentTraits {
|
||||
static constexpr ArgumentType Type = ArgumentType::InData;
|
||||
};
|
||||
|
||||
template <typename... Ts>
|
||||
consteval bool ConstIfReference() {
|
||||
return ((!std::is_reference_v<Ts> || std::is_const_v<std::remove_reference_t<Ts>>) && ... && true);
|
||||
}
|
||||
|
||||
struct RequestLayout {
|
||||
u32 copy_handle_count;
|
||||
u32 move_handle_count;
|
||||
@@ -435,6 +440,7 @@ void CmifReplyWrapImpl(HLERequestContext& ctx, T& t, Result (T::*f)(A...)) {
|
||||
}
|
||||
const bool is_domain = Domain ? ctx.GetManager()->IsDomain() : false;
|
||||
|
||||
static_assert(ConstIfReference<A...>(), "Arguments taken by reference must be const");
|
||||
using MethodArguments = std::tuple<std::remove_cvref_t<A>...>;
|
||||
|
||||
OutTemporaryBuffers buffers{};
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <span>
|
||||
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "core/hle/service/hle_ipc.h"
|
||||
|
||||
namespace Service {
|
||||
|
||||
@@ -22,8 +21,10 @@ class Out {
|
||||
public:
|
||||
using Type = T;
|
||||
|
||||
/* implicit */ Out(const Out& t) : raw(t.raw) {}
|
||||
/* implicit */ Out(AutoOut<Type>& t) : raw(&t.raw) {}
|
||||
/* implicit */ Out(Type* t) : raw(t) {}
|
||||
Out& operator=(const Out&) = delete;
|
||||
|
||||
Type* Get() const {
|
||||
return raw;
|
||||
@@ -37,6 +38,10 @@ public:
|
||||
return raw;
|
||||
}
|
||||
|
||||
operator Type*() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
private:
|
||||
Type* raw;
|
||||
};
|
||||
@@ -113,8 +118,10 @@ class OutCopyHandle {
|
||||
public:
|
||||
using Type = T*;
|
||||
|
||||
/* implicit */ OutCopyHandle(const OutCopyHandle& t) : raw(t.raw) {}
|
||||
/* implicit */ OutCopyHandle(AutoOut<Type>& t) : raw(&t.raw) {}
|
||||
/* implicit */ OutCopyHandle(Type* t) : raw(t) {}
|
||||
OutCopyHandle& operator=(const OutCopyHandle&) = delete;
|
||||
|
||||
Type* Get() const {
|
||||
return raw;
|
||||
@@ -128,6 +135,10 @@ public:
|
||||
return raw;
|
||||
}
|
||||
|
||||
operator Type*() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
private:
|
||||
Type* raw;
|
||||
};
|
||||
@@ -137,8 +148,10 @@ class OutMoveHandle {
|
||||
public:
|
||||
using Type = T*;
|
||||
|
||||
/* implicit */ OutMoveHandle(const OutMoveHandle& t) : raw(t.raw) {}
|
||||
/* implicit */ OutMoveHandle(AutoOut<Type>& t) : raw(&t.raw) {}
|
||||
/* implicit */ OutMoveHandle(Type* t) : raw(t) {}
|
||||
OutMoveHandle& operator=(const OutMoveHandle&) = delete;
|
||||
|
||||
Type* Get() const {
|
||||
return raw;
|
||||
@@ -152,6 +165,10 @@ public:
|
||||
return raw;
|
||||
}
|
||||
|
||||
operator Type*() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
private:
|
||||
Type* raw;
|
||||
};
|
||||
@@ -248,8 +265,10 @@ public:
|
||||
static constexpr BufferAttr Attr = static_cast<BufferAttr>(A | BufferAttr_In | BufferAttr_FixedSize);
|
||||
using Type = T;
|
||||
|
||||
/* implicit */ OutLargeData(const OutLargeData& t) : raw(t.raw) {}
|
||||
/* implicit */ OutLargeData(Type* t) : raw(t) {}
|
||||
/* implicit */ OutLargeData(AutoOut<T>& t) : raw(&t.raw) {}
|
||||
OutLargeData& operator=(const OutLargeData&) = delete;
|
||||
|
||||
Type* Get() const {
|
||||
return raw;
|
||||
@@ -263,6 +282,10 @@ public:
|
||||
return raw;
|
||||
}
|
||||
|
||||
operator Type*() const {
|
||||
return raw;
|
||||
}
|
||||
|
||||
private:
|
||||
Type* raw;
|
||||
};
|
||||
|
||||
@@ -115,6 +115,11 @@ private:
|
||||
if (type->GetName() == "save") {
|
||||
for (const auto& save_id : type->GetSubdirectories()) {
|
||||
for (const auto& user_id : save_id->GetSubdirectories()) {
|
||||
// Skip non user id subdirectories
|
||||
if (user_id->GetName().size() != 0x20) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const auto save_id_numeric = stoull_be(save_id->GetName());
|
||||
auto user_id_numeric = Common::HexStringToArray<0x10>(user_id->GetName());
|
||||
std::reverse(user_id_numeric.begin(), user_id_numeric.end());
|
||||
@@ -160,6 +165,10 @@ private:
|
||||
} else if (space == FileSys::SaveDataSpaceId::TemporaryStorage) {
|
||||
// Temporary Storage
|
||||
for (const auto& user_id : type->GetSubdirectories()) {
|
||||
// Skip non user id subdirectories
|
||||
if (user_id->GetName().size() != 0x20) {
|
||||
continue;
|
||||
}
|
||||
for (const auto& title_id : user_id->GetSubdirectories()) {
|
||||
if (!title_id->GetFiles().empty() ||
|
||||
!title_id->GetSubdirectories().empty()) {
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "core/hle/service/nvdrv/devices/nvdisp_disp0.h"
|
||||
#include "core/hle/service/nvnflinger/buffer_item.h"
|
||||
#include "core/hle/service/nvnflinger/buffer_item_consumer.h"
|
||||
#include "core/hle/service/nvnflinger/buffer_queue_producer.h"
|
||||
#include "core/hle/service/nvnflinger/hardware_composer.h"
|
||||
#include "core/hle/service/nvnflinger/hwc_layer.h"
|
||||
#include "core/hle/service/nvnflinger/ui/graphic_buffer.h"
|
||||
@@ -46,31 +45,9 @@ HardwareComposer::HardwareComposer() = default;
|
||||
HardwareComposer::~HardwareComposer() = default;
|
||||
|
||||
u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, VI::Display& display,
|
||||
Nvidia::Devices::nvdisp_disp0& nvdisp, u32 frame_advance) {
|
||||
Nvidia::Devices::nvdisp_disp0& nvdisp) {
|
||||
boost::container::small_vector<HwcLayer, 2> composition_stack;
|
||||
|
||||
m_frame_number += frame_advance;
|
||||
|
||||
// Release any necessary framebuffers.
|
||||
for (auto& [layer_id, framebuffer] : m_framebuffers) {
|
||||
if (framebuffer.release_frame_number > m_frame_number) {
|
||||
// Not yet ready to release this framebuffer.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!framebuffer.is_acquired) {
|
||||
// Already released.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (auto* layer = display.FindLayer(layer_id); layer != nullptr) {
|
||||
// TODO: support release fence
|
||||
// This is needed to prevent screen tearing
|
||||
layer->GetConsumer().ReleaseBuffer(framebuffer.item, android::Fence::NoFence());
|
||||
framebuffer.is_acquired = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Set default speed limit to 100%.
|
||||
*out_speed_scale = 1.0f;
|
||||
|
||||
@@ -142,7 +119,30 @@ u32 HardwareComposer::ComposeLocked(f32* out_speed_scale, VI::Display& display,
|
||||
MicroProfileFlip();
|
||||
|
||||
// Advance by at least one frame.
|
||||
return swap_interval.value_or(1);
|
||||
const u32 frame_advance = swap_interval.value_or(1);
|
||||
m_frame_number += frame_advance;
|
||||
|
||||
// Release any necessary framebuffers.
|
||||
for (auto& [layer_id, framebuffer] : m_framebuffers) {
|
||||
if (framebuffer.release_frame_number > m_frame_number) {
|
||||
// Not yet ready to release this framebuffer.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!framebuffer.is_acquired) {
|
||||
// Already released.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (auto* layer = display.FindLayer(layer_id); layer != nullptr) {
|
||||
// TODO: support release fence
|
||||
// This is needed to prevent screen tearing
|
||||
layer->GetConsumer().ReleaseBuffer(framebuffer.item, android::Fence::NoFence());
|
||||
framebuffer.is_acquired = false;
|
||||
}
|
||||
}
|
||||
|
||||
return frame_advance;
|
||||
}
|
||||
|
||||
void HardwareComposer::RemoveLayerLocked(VI::Display& display, LayerId layer_id) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
~HardwareComposer();
|
||||
|
||||
u32 ComposeLocked(f32* out_speed_scale, VI::Display& display,
|
||||
Nvidia::Devices::nvdisp_disp0& nvdisp, u32 frame_advance);
|
||||
Nvidia::Devices::nvdisp_disp0& nvdisp);
|
||||
void RemoveLayerLocked(VI::Display& display, LayerId layer_id);
|
||||
|
||||
private:
|
||||
|
||||
@@ -291,8 +291,7 @@ void Nvnflinger::Compose() {
|
||||
auto nvdisp = nvdrv->GetDevice<Nvidia::Devices::nvdisp_disp0>(disp_fd);
|
||||
ASSERT(nvdisp);
|
||||
|
||||
swap_interval = display.GetComposer().ComposeLocked(&compose_speed_scale, display, *nvdisp,
|
||||
swap_interval);
|
||||
swap_interval = display.GetComposer().ComposeLocked(&compose_speed_scale, display, *nvdisp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "core/core_timing.h"
|
||||
#include "core/hle/kernel/k_page_table.h"
|
||||
#include "core/hle/kernel/k_process.h"
|
||||
#include "core/hle/kernel/k_process_page_table.h"
|
||||
#include "core/hle/service/hid/hid_server.h"
|
||||
#include "core/hle/service/sm/sm.h"
|
||||
#include "core/memory.h"
|
||||
@@ -46,12 +47,23 @@ StandardVmCallbacks::StandardVmCallbacks(System& system_, const CheatProcessMeta
|
||||
|
||||
StandardVmCallbacks::~StandardVmCallbacks() = default;
|
||||
|
||||
void StandardVmCallbacks::MemoryRead(VAddr address, void* data, u64 size) {
|
||||
system.ApplicationMemory().ReadBlock(SanitizeAddress(address), data, size);
|
||||
void StandardVmCallbacks::MemoryReadUnsafe(VAddr address, void* data, u64 size) {
|
||||
// Return zero on invalid address
|
||||
if (!IsAddressInRange(address) || !system.ApplicationMemory().IsValidVirtualAddress(address)) {
|
||||
std::memset(data, 0, size);
|
||||
return;
|
||||
}
|
||||
|
||||
system.ApplicationMemory().ReadBlock(address, data, size);
|
||||
}
|
||||
|
||||
void StandardVmCallbacks::MemoryWrite(VAddr address, const void* data, u64 size) {
|
||||
system.ApplicationMemory().WriteBlock(SanitizeAddress(address), data, size);
|
||||
void StandardVmCallbacks::MemoryWriteUnsafe(VAddr address, const void* data, u64 size) {
|
||||
// Skip invalid memory write address
|
||||
if (!IsAddressInRange(address) || !system.ApplicationMemory().IsValidVirtualAddress(address)) {
|
||||
return;
|
||||
}
|
||||
|
||||
system.ApplicationMemory().WriteBlock(address, data, size);
|
||||
}
|
||||
|
||||
u64 StandardVmCallbacks::HidKeysDown() {
|
||||
@@ -81,21 +93,25 @@ void StandardVmCallbacks::CommandLog(std::string_view data) {
|
||||
data.back() == '\n' ? data.substr(0, data.size() - 1) : data);
|
||||
}
|
||||
|
||||
VAddr StandardVmCallbacks::SanitizeAddress(VAddr in) const {
|
||||
bool StandardVmCallbacks::IsAddressInRange(VAddr in) const {
|
||||
if ((in < metadata.main_nso_extents.base ||
|
||||
in >= metadata.main_nso_extents.base + metadata.main_nso_extents.size) &&
|
||||
(in < metadata.heap_extents.base ||
|
||||
in >= metadata.heap_extents.base + metadata.heap_extents.size)) {
|
||||
LOG_ERROR(CheatEngine,
|
||||
in >= metadata.heap_extents.base + metadata.heap_extents.size) &&
|
||||
(in < metadata.alias_extents.base ||
|
||||
in >= metadata.heap_extents.base + metadata.alias_extents.size) &&
|
||||
(in < metadata.aslr_extents.base ||
|
||||
in >= metadata.heap_extents.base + metadata.aslr_extents.size)) {
|
||||
LOG_DEBUG(CheatEngine,
|
||||
"Cheat attempting to access memory at invalid address={:016X}, if this "
|
||||
"persists, "
|
||||
"the cheat may be incorrect. However, this may be normal early in execution if "
|
||||
"the game has not properly set up yet.",
|
||||
in);
|
||||
return 0; ///< Invalid addresses will hard crash
|
||||
return false; ///< Invalid addresses will hard crash
|
||||
}
|
||||
|
||||
return in;
|
||||
return true;
|
||||
}
|
||||
|
||||
CheatParser::~CheatParser() = default;
|
||||
@@ -211,16 +227,14 @@ void CheatEngine::Initialize() {
|
||||
.base = GetInteger(page_table.GetHeapRegionStart()),
|
||||
.size = page_table.GetHeapRegionSize(),
|
||||
};
|
||||
|
||||
metadata.address_space_extents = {
|
||||
.base = GetInteger(page_table.GetAddressSpaceStart()),
|
||||
.size = page_table.GetAddressSpaceSize(),
|
||||
};
|
||||
|
||||
metadata.alias_extents = {
|
||||
metadata.aslr_extents = {
|
||||
.base = GetInteger(page_table.GetAliasCodeRegionStart()),
|
||||
.size = page_table.GetAliasCodeRegionSize(),
|
||||
};
|
||||
metadata.alias_extents = {
|
||||
.base = GetInteger(page_table.GetAliasRegionStart()),
|
||||
.size = page_table.GetAliasRegionSize(),
|
||||
};
|
||||
|
||||
is_pending_reload.exchange(true);
|
||||
}
|
||||
|
||||
@@ -27,17 +27,17 @@ public:
|
||||
StandardVmCallbacks(System& system_, const CheatProcessMetadata& metadata_);
|
||||
~StandardVmCallbacks() override;
|
||||
|
||||
void MemoryRead(VAddr address, void* data, u64 size) override;
|
||||
void MemoryWrite(VAddr address, const void* data, u64 size) override;
|
||||
void MemoryReadUnsafe(VAddr address, void* data, u64 size) override;
|
||||
void MemoryWriteUnsafe(VAddr address, const void* data, u64 size) override;
|
||||
u64 HidKeysDown() override;
|
||||
void DebugLog(u8 id, u64 value) override;
|
||||
void CommandLog(std::string_view data) override;
|
||||
|
||||
private:
|
||||
VAddr SanitizeAddress(VAddr address) const;
|
||||
bool IsAddressInRange(VAddr address) const;
|
||||
|
||||
const CheatProcessMetadata& metadata;
|
||||
System& system;
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
// Intermediary class that parses a text file or other disk format for storing cheats into a
|
||||
|
||||
@@ -18,7 +18,7 @@ struct CheatProcessMetadata {
|
||||
MemoryRegionExtents main_nso_extents{};
|
||||
MemoryRegionExtents heap_extents{};
|
||||
MemoryRegionExtents alias_extents{};
|
||||
MemoryRegionExtents address_space_extents{};
|
||||
MemoryRegionExtents aslr_extents{};
|
||||
std::array<u8, 0x20> main_nso_build_id{};
|
||||
};
|
||||
|
||||
|
||||
@@ -322,8 +322,9 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode& out) {
|
||||
} break;
|
||||
case CheatVmOpcodeType::EndConditionalBlock: {
|
||||
// 20000000
|
||||
// There's actually nothing left to process here!
|
||||
opcode.opcode = EndConditionalOpcode{};
|
||||
opcode.opcode = EndConditionalOpcode{
|
||||
.is_else = ((first_dword >> 24) & 0xf) == 1,
|
||||
};
|
||||
} break;
|
||||
case CheatVmOpcodeType::ControlLoop: {
|
||||
// 300R0000 VVVVVVVV
|
||||
@@ -555,6 +556,18 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode& out) {
|
||||
.idx = first_dword & 0xF,
|
||||
};
|
||||
} break;
|
||||
case CheatVmOpcodeType::PauseProcess: {
|
||||
/* FF0????? */
|
||||
/* FF0 = opcode 0xFF0 */
|
||||
/* Pauses the current process. */
|
||||
opcode.opcode = PauseProcessOpcode{};
|
||||
} break;
|
||||
case CheatVmOpcodeType::ResumeProcess: {
|
||||
/* FF0????? */
|
||||
/* FF0 = opcode 0xFF0 */
|
||||
/* Pauses the current process. */
|
||||
opcode.opcode = ResumeProcessOpcode{};
|
||||
} break;
|
||||
case CheatVmOpcodeType::DebugLog: {
|
||||
// FFFTIX##
|
||||
// FFFTI0Ma aaaaaaaa
|
||||
@@ -621,7 +634,7 @@ bool DmntCheatVm::DecodeNextOpcode(CheatVmOpcode& out) {
|
||||
return valid;
|
||||
}
|
||||
|
||||
void DmntCheatVm::SkipConditionalBlock() {
|
||||
void DmntCheatVm::SkipConditionalBlock(bool is_if) {
|
||||
if (condition_depth > 0) {
|
||||
// We want to continue until we're out of the current block.
|
||||
const std::size_t desired_depth = condition_depth - 1;
|
||||
@@ -637,8 +650,12 @@ void DmntCheatVm::SkipConditionalBlock() {
|
||||
// We also support nesting of conditional blocks, and Gateway does not.
|
||||
if (skip_opcode.begin_conditional_block) {
|
||||
condition_depth++;
|
||||
} else if (std::holds_alternative<EndConditionalOpcode>(skip_opcode.opcode)) {
|
||||
condition_depth--;
|
||||
} else if (auto end_cond = std::get_if<EndConditionalOpcode>(&skip_opcode.opcode)) {
|
||||
if (!end_cond->is_else) {
|
||||
condition_depth--;
|
||||
} else if (is_if && condition_depth - 1 == desired_depth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -675,6 +692,10 @@ u64 DmntCheatVm::GetCheatProcessAddress(const CheatProcessMetadata& metadata,
|
||||
return metadata.main_nso_extents.base + rel_address;
|
||||
case MemoryAccessType::Heap:
|
||||
return metadata.heap_extents.base + rel_address;
|
||||
case MemoryAccessType::Alias:
|
||||
return metadata.alias_extents.base + rel_address;
|
||||
case MemoryAccessType::Aslr:
|
||||
return metadata.aslr_extents.base + rel_address;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -682,7 +703,6 @@ void DmntCheatVm::ResetState() {
|
||||
registers.fill(0);
|
||||
saved_values.fill(0);
|
||||
loop_tops.fill(0);
|
||||
static_registers.fill(0);
|
||||
instruction_ptr = 0;
|
||||
condition_depth = 0;
|
||||
decode_success = true;
|
||||
@@ -753,7 +773,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
callbacks->MemoryWrite(dst_address, &dst_value, store_static->bit_width);
|
||||
callbacks->MemoryWriteUnsafe(dst_address, &dst_value, store_static->bit_width);
|
||||
break;
|
||||
}
|
||||
} else if (auto begin_cond = std::get_if<BeginConditionalOpcode>(&cur_opcode.opcode)) {
|
||||
@@ -766,7 +786,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
callbacks->MemoryRead(src_address, &src_value, begin_cond->bit_width);
|
||||
callbacks->MemoryReadUnsafe(src_address, &src_value, begin_cond->bit_width);
|
||||
break;
|
||||
}
|
||||
// Check against condition.
|
||||
@@ -794,13 +814,18 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
|
||||
}
|
||||
// Skip conditional block if condition not met.
|
||||
if (!cond_met) {
|
||||
SkipConditionalBlock();
|
||||
SkipConditionalBlock(true);
|
||||
}
|
||||
} else if (std::holds_alternative<EndConditionalOpcode>(cur_opcode.opcode)) {
|
||||
// Decrement the condition depth.
|
||||
// We will assume, graciously, that mismatched conditional block ends are a nop.
|
||||
if (condition_depth > 0) {
|
||||
condition_depth--;
|
||||
} else if (auto end_cond = std::get_if<EndConditionalOpcode>(&cur_opcode.opcode)) {
|
||||
if (end_cond->is_else) {
|
||||
/* Skip to the end of the conditional block. */
|
||||
this->SkipConditionalBlock(false);
|
||||
} else {
|
||||
/* Decrement the condition depth. */
|
||||
/* We will assume, graciously, that mismatched conditional block ends are a nop. */
|
||||
if (condition_depth > 0) {
|
||||
condition_depth--;
|
||||
}
|
||||
}
|
||||
} else if (auto ctrl_loop = std::get_if<ControlLoopOpcode>(&cur_opcode.opcode)) {
|
||||
if (ctrl_loop->start_loop) {
|
||||
@@ -832,8 +857,8 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
callbacks->MemoryRead(src_address, ®isters[ldr_memory->reg_index],
|
||||
ldr_memory->bit_width);
|
||||
callbacks->MemoryReadUnsafe(src_address, ®isters[ldr_memory->reg_index],
|
||||
ldr_memory->bit_width);
|
||||
break;
|
||||
}
|
||||
} else if (auto str_static = std::get_if<StoreStaticToAddressOpcode>(&cur_opcode.opcode)) {
|
||||
@@ -849,7 +874,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
callbacks->MemoryWrite(dst_address, &dst_value, str_static->bit_width);
|
||||
callbacks->MemoryWriteUnsafe(dst_address, &dst_value, str_static->bit_width);
|
||||
break;
|
||||
}
|
||||
// Increment register if relevant.
|
||||
@@ -908,7 +933,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
|
||||
// Check for keypress.
|
||||
if ((begin_keypress_cond->key_mask & kDown) != begin_keypress_cond->key_mask) {
|
||||
// Keys not pressed. Skip conditional block.
|
||||
SkipConditionalBlock();
|
||||
SkipConditionalBlock(true);
|
||||
}
|
||||
} else if (auto perform_math_reg =
|
||||
std::get_if<PerformArithmeticRegisterOpcode>(&cur_opcode.opcode)) {
|
||||
@@ -1007,7 +1032,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
callbacks->MemoryWrite(dst_address, &dst_value, str_register->bit_width);
|
||||
callbacks->MemoryWriteUnsafe(dst_address, &dst_value, str_register->bit_width);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1086,7 +1111,8 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
callbacks->MemoryRead(cond_address, &cond_value, begin_reg_cond->bit_width);
|
||||
callbacks->MemoryReadUnsafe(cond_address, &cond_value,
|
||||
begin_reg_cond->bit_width);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1116,7 +1142,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
|
||||
|
||||
// Skip conditional block if condition not met.
|
||||
if (!cond_met) {
|
||||
SkipConditionalBlock();
|
||||
SkipConditionalBlock(true);
|
||||
}
|
||||
} else if (auto save_restore_reg =
|
||||
std::get_if<SaveRestoreRegisterOpcode>(&cur_opcode.opcode)) {
|
||||
@@ -1178,6 +1204,10 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
|
||||
// Store a register to a static register.
|
||||
static_registers[rw_static_reg->static_idx] = registers[rw_static_reg->idx];
|
||||
}
|
||||
} else if (std::holds_alternative<PauseProcessOpcode>(cur_opcode.opcode)) {
|
||||
// TODO: Pause cheat process
|
||||
} else if (std::holds_alternative<ResumeProcessOpcode>(cur_opcode.opcode)) {
|
||||
// TODO: Resume cheat process
|
||||
} else if (auto debug_log = std::get_if<DebugLogOpcode>(&cur_opcode.opcode)) {
|
||||
// Read value from memory.
|
||||
u64 log_value = 0;
|
||||
@@ -1224,7 +1254,7 @@ void DmntCheatVm::Execute(const CheatProcessMetadata& metadata) {
|
||||
case 2:
|
||||
case 4:
|
||||
case 8:
|
||||
callbacks->MemoryRead(val_address, &log_value, debug_log->bit_width);
|
||||
callbacks->MemoryReadUnsafe(val_address, &log_value, debug_log->bit_width);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,12 +42,16 @@ enum class CheatVmOpcodeType : u32 {
|
||||
DoubleExtendedWidth = 0xF0,
|
||||
|
||||
// Double-extended width opcodes.
|
||||
PauseProcess = 0xFF0,
|
||||
ResumeProcess = 0xFF1,
|
||||
DebugLog = 0xFFF,
|
||||
};
|
||||
|
||||
enum class MemoryAccessType : u32 {
|
||||
MainNso = 0,
|
||||
Heap = 1,
|
||||
Alias = 2,
|
||||
Aslr = 3,
|
||||
};
|
||||
|
||||
enum class ConditionalComparisonType : u32 {
|
||||
@@ -131,7 +135,9 @@ struct BeginConditionalOpcode {
|
||||
VmInt value{};
|
||||
};
|
||||
|
||||
struct EndConditionalOpcode {};
|
||||
struct EndConditionalOpcode {
|
||||
bool is_else;
|
||||
};
|
||||
|
||||
struct ControlLoopOpcode {
|
||||
bool start_loop{};
|
||||
@@ -222,6 +228,10 @@ struct ReadWriteStaticRegisterOpcode {
|
||||
u32 idx{};
|
||||
};
|
||||
|
||||
struct PauseProcessOpcode {};
|
||||
|
||||
struct ResumeProcessOpcode {};
|
||||
|
||||
struct DebugLogOpcode {
|
||||
u32 bit_width{};
|
||||
u32 log_id{};
|
||||
@@ -244,8 +254,8 @@ struct CheatVmOpcode {
|
||||
PerformArithmeticStaticOpcode, BeginKeypressConditionalOpcode,
|
||||
PerformArithmeticRegisterOpcode, StoreRegisterToAddressOpcode,
|
||||
BeginRegisterConditionalOpcode, SaveRestoreRegisterOpcode,
|
||||
SaveRestoreRegisterMaskOpcode, ReadWriteStaticRegisterOpcode, DebugLogOpcode,
|
||||
UnrecognizedInstruction>
|
||||
SaveRestoreRegisterMaskOpcode, ReadWriteStaticRegisterOpcode, PauseProcessOpcode,
|
||||
ResumeProcessOpcode, DebugLogOpcode, UnrecognizedInstruction>
|
||||
opcode{};
|
||||
};
|
||||
|
||||
@@ -256,8 +266,8 @@ public:
|
||||
public:
|
||||
virtual ~Callbacks();
|
||||
|
||||
virtual void MemoryRead(VAddr address, void* data, u64 size) = 0;
|
||||
virtual void MemoryWrite(VAddr address, const void* data, u64 size) = 0;
|
||||
virtual void MemoryReadUnsafe(VAddr address, void* data, u64 size) = 0;
|
||||
virtual void MemoryWriteUnsafe(VAddr address, const void* data, u64 size) = 0;
|
||||
|
||||
virtual u64 HidKeysDown() = 0;
|
||||
|
||||
@@ -296,7 +306,7 @@ private:
|
||||
std::array<std::size_t, NumRegisters> loop_tops{};
|
||||
|
||||
bool DecodeNextOpcode(CheatVmOpcode& out);
|
||||
void SkipConditionalBlock();
|
||||
void SkipConditionalBlock(bool is_if);
|
||||
void ResetState();
|
||||
|
||||
// For implementing the DebugLog opcode.
|
||||
|
||||
@@ -52,9 +52,42 @@ ResourceManager::ResourceManager(Core::System& system_,
|
||||
std::shared_ptr<HidFirmwareSettings> settings)
|
||||
: firmware_settings{settings}, system{system_}, service_context{system_, "hid"} {
|
||||
applet_resource = std::make_shared<AppletResource>(system);
|
||||
|
||||
// Register update callbacks
|
||||
npad_update_event = Core::Timing::CreateEvent("HID::UpdatePadCallback",
|
||||
[this](s64 time, std::chrono::nanoseconds ns_late)
|
||||
-> std::optional<std::chrono::nanoseconds> {
|
||||
UpdateNpad(ns_late);
|
||||
return std::nullopt;
|
||||
});
|
||||
default_update_event = Core::Timing::CreateEvent(
|
||||
"HID::UpdateDefaultCallback",
|
||||
[this](s64 time,
|
||||
std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> {
|
||||
UpdateControllers(ns_late);
|
||||
return std::nullopt;
|
||||
});
|
||||
mouse_keyboard_update_event = Core::Timing::CreateEvent(
|
||||
"HID::UpdateMouseKeyboardCallback",
|
||||
[this](s64 time,
|
||||
std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> {
|
||||
UpdateMouseKeyboard(ns_late);
|
||||
return std::nullopt;
|
||||
});
|
||||
motion_update_event = Core::Timing::CreateEvent(
|
||||
"HID::UpdateMotionCallback",
|
||||
[this](s64 time,
|
||||
std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> {
|
||||
UpdateMotion(ns_late);
|
||||
return std::nullopt;
|
||||
});
|
||||
}
|
||||
|
||||
ResourceManager::~ResourceManager() {
|
||||
system.CoreTiming().UnscheduleEvent(npad_update_event);
|
||||
system.CoreTiming().UnscheduleEvent(default_update_event);
|
||||
system.CoreTiming().UnscheduleEvent(mouse_keyboard_update_event);
|
||||
system.CoreTiming().UnscheduleEvent(motion_update_event);
|
||||
system.CoreTiming().UnscheduleEvent(touch_update_event);
|
||||
input_event->Finalize();
|
||||
};
|
||||
@@ -201,6 +234,7 @@ void ResourceManager::InitializeHidCommonSampler() {
|
||||
|
||||
debug_pad->SetAppletResource(applet_resource, &shared_mutex);
|
||||
digitizer->SetAppletResource(applet_resource, &shared_mutex);
|
||||
unique_pad->SetAppletResource(applet_resource, &shared_mutex);
|
||||
keyboard->SetAppletResource(applet_resource, &shared_mutex);
|
||||
|
||||
const auto settings =
|
||||
@@ -214,6 +248,14 @@ void ResourceManager::InitializeHidCommonSampler() {
|
||||
home_button->SetAppletResource(applet_resource, &shared_mutex);
|
||||
sleep_button->SetAppletResource(applet_resource, &shared_mutex);
|
||||
capture_button->SetAppletResource(applet_resource, &shared_mutex);
|
||||
|
||||
system.CoreTiming().ScheduleLoopingEvent(npad_update_ns, npad_update_ns, npad_update_event);
|
||||
system.CoreTiming().ScheduleLoopingEvent(default_update_ns, default_update_ns,
|
||||
default_update_event);
|
||||
system.CoreTiming().ScheduleLoopingEvent(mouse_keyboard_update_ns, mouse_keyboard_update_ns,
|
||||
mouse_keyboard_update_event);
|
||||
system.CoreTiming().ScheduleLoopingEvent(motion_update_ns, motion_update_ns,
|
||||
motion_update_event);
|
||||
}
|
||||
|
||||
void ResourceManager::InitializeTouchScreenSampler() {
|
||||
@@ -465,55 +507,9 @@ IAppletResource::IAppletResource(Core::System& system_, std::shared_ptr<Resource
|
||||
{0, &IAppletResource::GetSharedMemoryHandle, "GetSharedMemoryHandle"},
|
||||
};
|
||||
RegisterHandlers(functions);
|
||||
|
||||
// Register update callbacks
|
||||
npad_update_event = Core::Timing::CreateEvent(
|
||||
"HID::UpdatePadCallback",
|
||||
[this, resource](
|
||||
s64 time, std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> {
|
||||
const auto guard = LockService();
|
||||
resource->UpdateNpad(ns_late);
|
||||
return std::nullopt;
|
||||
});
|
||||
default_update_event = Core::Timing::CreateEvent(
|
||||
"HID::UpdateDefaultCallback",
|
||||
[this, resource](
|
||||
s64 time, std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> {
|
||||
const auto guard = LockService();
|
||||
resource->UpdateControllers(ns_late);
|
||||
return std::nullopt;
|
||||
});
|
||||
mouse_keyboard_update_event = Core::Timing::CreateEvent(
|
||||
"HID::UpdateMouseKeyboardCallback",
|
||||
[this, resource](
|
||||
s64 time, std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> {
|
||||
const auto guard = LockService();
|
||||
resource->UpdateMouseKeyboard(ns_late);
|
||||
return std::nullopt;
|
||||
});
|
||||
motion_update_event = Core::Timing::CreateEvent(
|
||||
"HID::UpdateMotionCallback",
|
||||
[this, resource](
|
||||
s64 time, std::chrono::nanoseconds ns_late) -> std::optional<std::chrono::nanoseconds> {
|
||||
const auto guard = LockService();
|
||||
resource->UpdateMotion(ns_late);
|
||||
return std::nullopt;
|
||||
});
|
||||
|
||||
system.CoreTiming().ScheduleLoopingEvent(npad_update_ns, npad_update_ns, npad_update_event);
|
||||
system.CoreTiming().ScheduleLoopingEvent(default_update_ns, default_update_ns,
|
||||
default_update_event);
|
||||
system.CoreTiming().ScheduleLoopingEvent(mouse_keyboard_update_ns, mouse_keyboard_update_ns,
|
||||
mouse_keyboard_update_event);
|
||||
system.CoreTiming().ScheduleLoopingEvent(motion_update_ns, motion_update_ns,
|
||||
motion_update_event);
|
||||
}
|
||||
|
||||
IAppletResource::~IAppletResource() {
|
||||
system.CoreTiming().UnscheduleEvent(npad_update_event);
|
||||
system.CoreTiming().UnscheduleEvent(default_update_event);
|
||||
system.CoreTiming().UnscheduleEvent(mouse_keyboard_update_event);
|
||||
system.CoreTiming().UnscheduleEvent(motion_update_event);
|
||||
resource_manager->FreeAppletResourceId(aruid);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,6 +147,10 @@ private:
|
||||
std::shared_ptr<SixAxis> six_axis{nullptr};
|
||||
std::shared_ptr<SleepButton> sleep_button{nullptr};
|
||||
std::shared_ptr<UniquePad> unique_pad{nullptr};
|
||||
std::shared_ptr<Core::Timing::EventType> npad_update_event;
|
||||
std::shared_ptr<Core::Timing::EventType> default_update_event;
|
||||
std::shared_ptr<Core::Timing::EventType> mouse_keyboard_update_event;
|
||||
std::shared_ptr<Core::Timing::EventType> motion_update_event;
|
||||
|
||||
// TODO: Create these resources
|
||||
// std::shared_ptr<AudioControl> audio_control{nullptr};
|
||||
@@ -179,11 +183,6 @@ public:
|
||||
private:
|
||||
void GetSharedMemoryHandle(HLERequestContext& ctx);
|
||||
|
||||
std::shared_ptr<Core::Timing::EventType> npad_update_event{nullptr};
|
||||
std::shared_ptr<Core::Timing::EventType> default_update_event{nullptr};
|
||||
std::shared_ptr<Core::Timing::EventType> mouse_keyboard_update_event{nullptr};
|
||||
std::shared_ptr<Core::Timing::EventType> motion_update_event{nullptr};
|
||||
|
||||
u64 aruid{};
|
||||
std::shared_ptr<ResourceManager> resource_manager;
|
||||
};
|
||||
|
||||
@@ -17,10 +17,6 @@ void Digitizer::OnInit() {}
|
||||
void Digitizer::OnRelease() {}
|
||||
|
||||
void Digitizer::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!smart_update) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::scoped_lock shared_lock{*shared_mutex};
|
||||
const u64 aruid = applet_resource->GetActiveAruid();
|
||||
auto* data = applet_resource->GetAruidData(aruid);
|
||||
|
||||
@@ -20,8 +20,5 @@ public:
|
||||
|
||||
// When the controller is requesting an update for the shared memory
|
||||
void OnUpdate(const Core::Timing::CoreTiming& core_timing) override;
|
||||
|
||||
private:
|
||||
bool smart_update{};
|
||||
};
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -102,6 +102,8 @@ Result NPad::Activate(u64 aruid) {
|
||||
for (std::size_t i = 0; i < 19; ++i) {
|
||||
WriteEmptyEntry(npad);
|
||||
}
|
||||
|
||||
controller.is_active = true;
|
||||
}
|
||||
|
||||
return ResultSuccess;
|
||||
@@ -467,6 +469,13 @@ void NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool is_set{};
|
||||
npad_resource.IsSupportedNpadStyleSet(is_set, aruid);
|
||||
// Wait until style is defined
|
||||
if (!is_set) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (std::size_t i = 0; i < controller_data[aruid_index].size(); ++i) {
|
||||
auto& controller = controller_data[aruid_index][i];
|
||||
controller.shared_memory =
|
||||
@@ -484,6 +493,10 @@ void NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!controller.is_active) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RequestPadStateUpdate(aruid, controller.device->GetNpadIdType());
|
||||
auto& pad_state = controller.npad_pad_state;
|
||||
auto& libnx_state = controller.npad_libnx_state;
|
||||
@@ -592,7 +605,9 @@ void NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
libnx_state.npad_buttons.raw = pad_state.npad_buttons.raw;
|
||||
libnx_state.l_stick = pad_state.l_stick;
|
||||
libnx_state.r_stick = pad_state.r_stick;
|
||||
npad->system_ext_lifo.WriteNextEntry(pad_state);
|
||||
libnx_state.sampling_number =
|
||||
npad->system_ext_lifo.ReadCurrentEntry().state.sampling_number + 1;
|
||||
npad->system_ext_lifo.WriteNextEntry(libnx_state);
|
||||
|
||||
press_state |= static_cast<u64>(pad_state.npad_buttons.raw);
|
||||
}
|
||||
@@ -1060,6 +1075,7 @@ void NPad::UnregisterAppletResourceUserId(u64 aruid) {
|
||||
// TODO: Remove this once abstract pad is emulated properly
|
||||
const auto aruid_index = npad_resource.GetIndexFromAruid(aruid);
|
||||
for (auto& controller : controller_data[aruid_index]) {
|
||||
controller.is_active = false;
|
||||
controller.is_connected = false;
|
||||
controller.shared_memory = nullptr;
|
||||
}
|
||||
|
||||
@@ -164,6 +164,7 @@ private:
|
||||
NpadInternalState* shared_memory = nullptr;
|
||||
Core::HID::EmulatedController* device = nullptr;
|
||||
|
||||
bool is_active{};
|
||||
bool is_connected{};
|
||||
|
||||
// Dual joycons can have only one side connected
|
||||
|
||||
@@ -17,10 +17,6 @@ void UniquePad::OnInit() {}
|
||||
void UniquePad::OnRelease() {}
|
||||
|
||||
void UniquePad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
|
||||
if (!smart_update) {
|
||||
return;
|
||||
}
|
||||
|
||||
const u64 aruid = applet_resource->GetActiveAruid();
|
||||
auto* data = applet_resource->GetAruidData(aruid);
|
||||
|
||||
|
||||
@@ -20,8 +20,5 @@ public:
|
||||
|
||||
// When the controller is requesting an update for the shared memory
|
||||
void OnUpdate(const Core::Timing::CoreTiming& core_timing) override;
|
||||
|
||||
private:
|
||||
bool smart_update{};
|
||||
};
|
||||
} // namespace Service::HID
|
||||
|
||||
@@ -73,8 +73,11 @@ ConfigurePerGame::ConfigurePerGame(QWidget* parent, u64 title_id_, const std::st
|
||||
ui->tabWidget->addTab(graphics_advanced_tab.get(), tr("Adv. Graphics"));
|
||||
ui->tabWidget->addTab(audio_tab.get(), tr("Audio"));
|
||||
ui->tabWidget->addTab(input_tab.get(), tr("Input Profiles"));
|
||||
|
||||
// Only show Linux tab on Unix
|
||||
linux_tab->setVisible(false);
|
||||
#ifdef __unix__
|
||||
linux_tab->setVisible(true);
|
||||
ui->tabWidget->addTab(linux_tab.get(), tr("Linux"));
|
||||
#endif
|
||||
|
||||
|
||||
@@ -37,13 +37,28 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
||||
QStringLiteral());
|
||||
|
||||
// Core
|
||||
INSERT(Settings, use_multi_core, tr("Multicore CPU Emulation"), QStringLiteral());
|
||||
INSERT(Settings, memory_layout_mode, tr("Memory Layout"), QStringLiteral());
|
||||
INSERT(
|
||||
Settings, use_multi_core, tr("Multicore CPU Emulation"),
|
||||
tr("This option increases CPU emulation thread use from 1 to the Switch’s maximum of 4.\n"
|
||||
"This is mainly a debug option and shouldn’t be disabled."));
|
||||
INSERT(
|
||||
Settings, memory_layout_mode, tr("Memory Layout"),
|
||||
tr("Increases the amount of emulated RAM from the stock 4GB of the retail Switch to the "
|
||||
"developer kit's 8/6GB.\nIt’s doesn’t improve stability or performance and is intended "
|
||||
"to let big texture mods fit in emulated RAM.\nEnabling it will increase memory "
|
||||
"use. It is not recommended to enable unless a specific game with a texture mod needs "
|
||||
"it."));
|
||||
INSERT(Settings, use_speed_limit, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, speed_limit, tr("Limit Speed Percent"), QStringLiteral());
|
||||
INSERT(Settings, speed_limit, tr("Limit Speed Percent"),
|
||||
tr("Controls the game's maximum rendering speed, but it’s up to each game if it runs "
|
||||
"faster or not.\n200% for a 30 FPS game is 60 FPS, and for a "
|
||||
"60 FPS game it will be 120 FPS.\nDisabling it means unlocking the framerate to the "
|
||||
"maximum your PC can reach."));
|
||||
|
||||
// Cpu
|
||||
INSERT(Settings, cpu_accuracy, tr("Accuracy:"), QStringLiteral());
|
||||
INSERT(Settings, cpu_accuracy, tr("Accuracy:"),
|
||||
tr("This setting controls the accuracy of the emulated CPU.\nDon't change this unless "
|
||||
"you know what you are doing."));
|
||||
INSERT(Settings, cpu_backend, tr("Backend:"), QStringLiteral());
|
||||
|
||||
// Cpu Debug
|
||||
@@ -63,34 +78,75 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
||||
tr("This option improves the speed of 32 bits ASIMD floating-point functions by running "
|
||||
"with incorrect rounding modes."));
|
||||
INSERT(Settings, cpuopt_unsafe_inaccurate_nan, tr("Inaccurate NaN handling"),
|
||||
tr("This option improves speed by removing NaN checking. Please note this also reduces "
|
||||
tr("This option improves speed by removing NaN checking.\nPlease note this also reduces "
|
||||
"accuracy of certain floating-point instructions."));
|
||||
INSERT(Settings, cpuopt_unsafe_fastmem_check, tr("Disable address space checks"),
|
||||
tr("This option improves speed by eliminating a safety check before every memory "
|
||||
"read/write "
|
||||
"in guest. Disabling it may allow a game to read/write the emulator's memory."));
|
||||
"read/write in guest.\nDisabling it may allow a game to read/write the emulator's "
|
||||
"memory."));
|
||||
INSERT(
|
||||
Settings, cpuopt_unsafe_ignore_global_monitor, tr("Ignore global monitor"),
|
||||
tr("This option improves speed by relying only on the semantics of cmpxchg to ensure "
|
||||
"safety of exclusive access instructions. Please note this may result in deadlocks and "
|
||||
"safety of exclusive access instructions.\nPlease note this may result in deadlocks and "
|
||||
"other race conditions."));
|
||||
|
||||
// Renderer
|
||||
INSERT(Settings, renderer_backend, tr("API:"), QStringLiteral());
|
||||
INSERT(Settings, vulkan_device, tr("Device:"), QStringLiteral());
|
||||
INSERT(Settings, shader_backend, tr("Shader Backend:"), QStringLiteral());
|
||||
INSERT(Settings, resolution_setup, tr("Resolution:"), QStringLiteral());
|
||||
INSERT(
|
||||
Settings, renderer_backend, tr("API:"),
|
||||
tr("Switches between the available graphics APIs.\nVulkan is recommended in most cases."));
|
||||
INSERT(Settings, vulkan_device, tr("Device:"),
|
||||
tr("This setting selects the GPU to use with the Vulkan backend."));
|
||||
INSERT(Settings, shader_backend, tr("Shader Backend:"),
|
||||
tr("The shader backend to use for the OpenGL renderer.\nGLSL is the fastest in "
|
||||
"performance and the best in rendering accuracy.\n"
|
||||
"GLASM is a deprecated NVIDIA-only backend that offers much better shader building "
|
||||
"performance at the cost of FPS and rendering accuracy.\n"
|
||||
"SPIR-V compiles the fastest, but yields poor results on most GPU drivers."));
|
||||
INSERT(Settings, resolution_setup, tr("Resolution:"),
|
||||
tr("Forces the game to render at a different resolution.\nHigher resolutions require "
|
||||
"much more VRAM and bandwidth.\n"
|
||||
"Options lower than 1X can cause rendering issues."));
|
||||
INSERT(Settings, scaling_filter, tr("Window Adapting Filter:"), QStringLiteral());
|
||||
INSERT(Settings, fsr_sharpening_slider, tr("FSR Sharpness:"), QStringLiteral());
|
||||
INSERT(Settings, anti_aliasing, tr("Anti-Aliasing Method:"), QStringLiteral());
|
||||
INSERT(Settings, fullscreen_mode, tr("Fullscreen Mode:"), QStringLiteral());
|
||||
INSERT(Settings, aspect_ratio, tr("Aspect Ratio:"), QStringLiteral());
|
||||
INSERT(Settings, use_disk_shader_cache, tr("Use disk pipeline cache"), QStringLiteral());
|
||||
INSERT(Settings, use_asynchronous_gpu_emulation, tr("Use asynchronous GPU emulation"),
|
||||
QStringLiteral());
|
||||
INSERT(Settings, nvdec_emulation, tr("NVDEC emulation:"), QStringLiteral());
|
||||
INSERT(Settings, accelerate_astc, tr("ASTC Decoding Method:"), QStringLiteral());
|
||||
INSERT(Settings, astc_recompression, tr("ASTC Recompression Method:"), QStringLiteral());
|
||||
INSERT(Settings, fsr_sharpening_slider, tr("FSR Sharpness:"),
|
||||
tr("Determines how sharpened the image will look while using FSR’s dynamic contrast."));
|
||||
INSERT(Settings, anti_aliasing, tr("Anti-Aliasing Method:"),
|
||||
tr("The anti-aliasing method to use.\nSMAA offers the best quality.\nFXAA has a "
|
||||
"lower performance impact and can produce a better and more stable picture under "
|
||||
"very low resolutions."));
|
||||
INSERT(Settings, fullscreen_mode, tr("Fullscreen Mode:"),
|
||||
tr("The method used to render the window in fullscreen.\nBorderless offers the best "
|
||||
"compatibility with the on-screen keyboard that some games request for "
|
||||
"input.\nExclusive "
|
||||
"fullscreen may offer better performance and better Freesync/Gsync support."));
|
||||
INSERT(Settings, aspect_ratio, tr("Aspect Ratio:"),
|
||||
tr("Stretches the game to fit the specified aspect ratio.\nSwitch games only support "
|
||||
"16:9, so custom game mods are required to get other ratios.\nAlso controls the "
|
||||
"aspect ratio of captured screenshots."));
|
||||
INSERT(Settings, use_disk_shader_cache, tr("Use disk pipeline cache"),
|
||||
tr("Allows saving shaders to storage for faster loading on following game "
|
||||
"boots.\nDisabling "
|
||||
"it is only intended for debugging."));
|
||||
INSERT(
|
||||
Settings, use_asynchronous_gpu_emulation, tr("Use asynchronous GPU emulation"),
|
||||
tr("Uses an extra CPU thread for rendering.\nThis option should always remain enabled."));
|
||||
INSERT(Settings, nvdec_emulation, tr("NVDEC emulation:"),
|
||||
tr("Specifies how videos should be decoded.\nIt can either use the CPU or the GPU for "
|
||||
"decoding, or perform no decoding at all (black screen on videos).\n"
|
||||
"In most cases, GPU decoding provides the best performance."));
|
||||
INSERT(Settings, accelerate_astc, tr("ASTC Decoding Method:"),
|
||||
tr("This option controls how ASTC textures should be decoded.\n"
|
||||
"CPU: Use the CPU for decoding, slowest but safest method.\n"
|
||||
"GPU: Use the GPU's compute shaders to decode ASTC textures, recommended for most "
|
||||
"games and users.\n"
|
||||
"CPU Asynchronously: Use the CPU to decode ASTC textures as they arrive. Completely "
|
||||
"eliminates ASTC decoding\nstuttering at the cost of rendering issues while the "
|
||||
"texture is being decoded."));
|
||||
INSERT(
|
||||
Settings, astc_recompression, tr("ASTC Recompression Method:"),
|
||||
tr("Almost all desktop and laptop dedicated GPUs lack support for ASTC textures, forcing "
|
||||
"the emulator to decompress to an intermediate format any card supports, RGBA8.\n"
|
||||
"This option recompresses RGBA8 to either the BC1 or BC3 format, saving VRAM but "
|
||||
"negatively affecting image quality."));
|
||||
INSERT(
|
||||
Settings, vsync_mode, tr("VSync Mode:"),
|
||||
tr("FIFO (VSync) does not drop frames or exhibit tearing but is limited by the screen "
|
||||
@@ -104,22 +160,29 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
||||
|
||||
// Renderer (Advanced Graphics)
|
||||
INSERT(Settings, async_presentation, tr("Enable asynchronous presentation (Vulkan only)"),
|
||||
QStringLiteral());
|
||||
tr("Slightly improves performance by moving presentation to a separate CPU thread."));
|
||||
INSERT(
|
||||
Settings, renderer_force_max_clock, tr("Force maximum clocks (Vulkan only)"),
|
||||
tr("Runs work in the background while waiting for graphics commands to keep the GPU from "
|
||||
"lowering its clock speed."));
|
||||
INSERT(Settings, max_anisotropy, tr("Anisotropic Filtering:"), QStringLiteral());
|
||||
INSERT(Settings, gpu_accuracy, tr("Accuracy Level:"), QStringLiteral());
|
||||
INSERT(
|
||||
Settings, use_asynchronous_shaders, tr("Use asynchronous shader building (Hack)"),
|
||||
tr("Enables asynchronous shader compilation, which may reduce shader stutter. This feature "
|
||||
"is experimental."));
|
||||
INSERT(Settings, max_anisotropy, tr("Anisotropic Filtering:"),
|
||||
tr("Controls the quality of texture rendering at oblique angles.\nIt’s a light setting "
|
||||
"and safe to set at 16x on most GPUs."));
|
||||
INSERT(Settings, gpu_accuracy, tr("Accuracy Level:"),
|
||||
tr("GPU emulation accuracy.\nMost games render fine with Normal, but High is still "
|
||||
"required for some.\nParticles tend to only render correctly with High "
|
||||
"accuracy.\nExtreme should only be used for debugging.\nThis option can "
|
||||
"be changed while playing.\nSome games may require booting on high to render "
|
||||
"properly."));
|
||||
INSERT(Settings, use_asynchronous_shaders, tr("Use asynchronous shader building (Hack)"),
|
||||
tr("Enables asynchronous shader compilation, which may reduce shader stutter.\nThis "
|
||||
"feature "
|
||||
"is experimental."));
|
||||
INSERT(Settings, use_fast_gpu_time, tr("Use Fast GPU Time (Hack)"),
|
||||
tr("Enables Fast GPU Time. This option will force most games to run at their highest "
|
||||
"native resolution."));
|
||||
INSERT(Settings, use_vulkan_driver_pipeline_cache, tr("Use Vulkan pipeline cache"),
|
||||
tr("Enables GPU vendor-specific pipeline cache. This option can improve shader loading "
|
||||
tr("Enables GPU vendor-specific pipeline cache.\nThis option can improve shader loading "
|
||||
"time significantly in cases where the Vulkan driver does not store pipeline cache "
|
||||
"files internally."));
|
||||
INSERT(
|
||||
@@ -140,19 +203,27 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
||||
// Renderer (Debug)
|
||||
|
||||
// System
|
||||
INSERT(Settings, rng_seed, tr("RNG Seed"), QStringLiteral());
|
||||
INSERT(Settings, rng_seed, tr("RNG Seed"),
|
||||
tr("Controls the seed of the random number generator.\nMainly used for speedrunning "
|
||||
"purposes."));
|
||||
INSERT(Settings, rng_seed_enabled, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, device_name, tr("Device Name"), QStringLiteral());
|
||||
INSERT(Settings, custom_rtc, tr("Custom RTC Date:"), QStringLiteral());
|
||||
INSERT(Settings, device_name, tr("Device Name"), tr("The name of the emulated Switch."));
|
||||
INSERT(Settings, custom_rtc, tr("Custom RTC Date:"),
|
||||
tr("This option allows to change the emulated clock of the Switch.\n"
|
||||
"Can be used to manipulate time in games."));
|
||||
INSERT(Settings, custom_rtc_enabled, QStringLiteral(), QStringLiteral());
|
||||
INSERT(Settings, custom_rtc_offset, QStringLiteral(" "),
|
||||
QStringLiteral("The number of seconds from the current unix time"));
|
||||
INSERT(Settings, language_index, tr("Language:"),
|
||||
tr("Note: this can be overridden when region setting is auto-select"));
|
||||
INSERT(Settings, region_index, tr("Region:"), QStringLiteral());
|
||||
INSERT(Settings, time_zone_index, tr("Time Zone:"), QStringLiteral());
|
||||
INSERT(Settings, region_index, tr("Region:"), tr("The region of the emulated Switch."));
|
||||
INSERT(Settings, time_zone_index, tr("Time Zone:"),
|
||||
tr("The time zone of the emulated Switch."));
|
||||
INSERT(Settings, sound_index, tr("Sound Output Mode:"), QStringLiteral());
|
||||
INSERT(Settings, use_docked_mode, tr("Console Mode:"), QStringLiteral());
|
||||
INSERT(Settings, use_docked_mode, tr("Console Mode:"),
|
||||
tr("Selects if the console is emulated in Docked or Handheld mode.\nGames will change "
|
||||
"their resolution, details and supported controllers and depending on this setting.\n"
|
||||
"Setting to Handheld can help improve performance for low end systems."));
|
||||
INSERT(Settings, current_user, QStringLiteral(), QStringLiteral());
|
||||
|
||||
// Controls
|
||||
@@ -170,14 +241,19 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) {
|
||||
// Ui
|
||||
|
||||
// Ui General
|
||||
INSERT(UISettings, select_user_on_boot, tr("Prompt for user on game boot"), QStringLiteral());
|
||||
INSERT(UISettings, select_user_on_boot, tr("Prompt for user on game boot"),
|
||||
tr("Ask to select a user profile on each boot, useful if multiple people use yuzu on "
|
||||
"the same PC."));
|
||||
INSERT(UISettings, pause_when_in_background, tr("Pause emulation when in background"),
|
||||
QStringLiteral());
|
||||
tr("This setting pauses yuzu when focusing other windows."));
|
||||
INSERT(UISettings, confirm_before_stopping, tr("Confirm before stopping emulation"),
|
||||
QStringLiteral());
|
||||
INSERT(UISettings, hide_mouse, tr("Hide mouse on inactivity"), QStringLiteral());
|
||||
tr("This setting overrides game prompts asking to confirm stopping the game.\nEnabling "
|
||||
"it bypasses such prompts and directly exits the emulation."));
|
||||
INSERT(UISettings, hide_mouse, tr("Hide mouse on inactivity"),
|
||||
tr("This setting hides the mouse after 2.5s of inactivity."));
|
||||
INSERT(UISettings, controller_applet_disabled, tr("Disable controller applet"),
|
||||
QStringLiteral());
|
||||
tr("Forcibly disables the use of the controller applet by guests.\nWhen a guest "
|
||||
"attempts to open the controller applet, it is immediately closed."));
|
||||
|
||||
// Linux
|
||||
INSERT(Settings, enable_gamemode, tr("Enable Gamemode"), QStringLiteral());
|
||||
|
||||
@@ -1353,6 +1353,13 @@ void GMainWindow::InitializeHotkeys() {
|
||||
LinkActionShortcut(ui->action_TAS_Start, QStringLiteral("TAS Start/Stop"), true);
|
||||
LinkActionShortcut(ui->action_TAS_Record, QStringLiteral("TAS Record"), true);
|
||||
LinkActionShortcut(ui->action_TAS_Reset, QStringLiteral("TAS Reset"), true);
|
||||
LinkActionShortcut(ui->action_View_Lobby,
|
||||
QStringLiteral("Multiplayer Browse Public Game Lobby"));
|
||||
LinkActionShortcut(ui->action_Start_Room, QStringLiteral("Multiplayer Create Room"));
|
||||
LinkActionShortcut(ui->action_Connect_To_Room,
|
||||
QStringLiteral("Multiplayer Direct Connect to Room"));
|
||||
LinkActionShortcut(ui->action_Show_Room, QStringLiteral("Multiplayer Show Current Room"));
|
||||
LinkActionShortcut(ui->action_Leave_Room, QStringLiteral("Multiplayer Leave Room"));
|
||||
|
||||
static const QString main_window = QStringLiteral("Main Window");
|
||||
const auto connect_shortcut = [&]<typename Fn>(const QString& action_name, const Fn& function) {
|
||||
|
||||
@@ -77,16 +77,23 @@ Lobby::Lobby(QWidget* parent, QStandardItemModel* list,
|
||||
|
||||
// UI Buttons
|
||||
connect(ui->refresh_list, &QPushButton::clicked, this, &Lobby::RefreshLobby);
|
||||
connect(ui->search, &QLineEdit::textChanged, proxy, &LobbyFilterProxyModel::SetFilterSearch);
|
||||
connect(ui->games_owned, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterOwned);
|
||||
connect(ui->hide_empty, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterEmpty);
|
||||
connect(ui->hide_full, &QCheckBox::toggled, proxy, &LobbyFilterProxyModel::SetFilterFull);
|
||||
connect(ui->search, &QLineEdit::textChanged, proxy, &LobbyFilterProxyModel::SetFilterSearch);
|
||||
connect(ui->room_list, &QTreeView::doubleClicked, this, &Lobby::OnJoinRoom);
|
||||
connect(ui->room_list, &QTreeView::clicked, this, &Lobby::OnExpandRoom);
|
||||
|
||||
// Actions
|
||||
connect(&room_list_watcher, &QFutureWatcher<AnnounceMultiplayerRoom::RoomList>::finished, this,
|
||||
&Lobby::OnRefreshLobby);
|
||||
|
||||
// Load persistent filters after events are connected to make sure they apply
|
||||
ui->search->setText(
|
||||
QString::fromStdString(UISettings::values.multiplayer_filter_text.GetValue()));
|
||||
ui->games_owned->setChecked(UISettings::values.multiplayer_filter_games_owned.GetValue());
|
||||
ui->hide_empty->setChecked(UISettings::values.multiplayer_filter_hide_empty.GetValue());
|
||||
ui->hide_full->setChecked(UISettings::values.multiplayer_filter_hide_full.GetValue());
|
||||
}
|
||||
|
||||
Lobby::~Lobby() = default;
|
||||
@@ -204,6 +211,10 @@ void Lobby::OnJoinRoom(const QModelIndex& source) {
|
||||
|
||||
// Save settings
|
||||
UISettings::values.multiplayer_nickname = ui->nickname->text().toStdString();
|
||||
UISettings::values.multiplayer_filter_text = ui->search->text().toStdString();
|
||||
UISettings::values.multiplayer_filter_games_owned = ui->games_owned->isChecked();
|
||||
UISettings::values.multiplayer_filter_hide_empty = ui->hide_empty->isChecked();
|
||||
UISettings::values.multiplayer_filter_hide_full = ui->hide_full->isChecked();
|
||||
UISettings::values.multiplayer_ip =
|
||||
proxy->data(connection_index, LobbyItemHost::HostIPRole).value<QString>().toStdString();
|
||||
UISettings::values.multiplayer_port =
|
||||
|
||||
@@ -193,12 +193,29 @@ public:
|
||||
}
|
||||
|
||||
QVariant data(int role) const override {
|
||||
if (role != Qt::DisplayRole) {
|
||||
switch (role) {
|
||||
case Qt::DisplayRole: {
|
||||
auto members = data(MemberListRole).toList();
|
||||
return QStringLiteral("%1 / %2 ")
|
||||
.arg(QString::number(members.size()), data(MaxPlayerRole).toString());
|
||||
}
|
||||
case Qt::ForegroundRole: {
|
||||
auto members = data(MemberListRole).toList();
|
||||
auto max_players = data(MaxPlayerRole).toInt();
|
||||
if (members.size() >= max_players) {
|
||||
return QBrush(QColor(255, 48, 32));
|
||||
} else if (members.size() == (max_players - 1)) {
|
||||
return QBrush(QColor(255, 140, 32));
|
||||
} else if (members.size() == 0) {
|
||||
return QBrush(QColor(128, 128, 128));
|
||||
}
|
||||
// FIXME: How to return a value that tells Qt not to modify the
|
||||
// text color from the default (as if Qt::ForegroundRole wasn't overridden)?
|
||||
return QBrush(nullptr);
|
||||
}
|
||||
default:
|
||||
return LobbyItem::data(role);
|
||||
}
|
||||
auto members = data(MemberListRole).toList();
|
||||
return QStringLiteral("%1 / %2 ")
|
||||
.arg(QString::number(members.size()), data(MaxPlayerRole).toString());
|
||||
}
|
||||
|
||||
bool operator<(const QStandardItem& other) const override {
|
||||
|
||||
@@ -169,6 +169,13 @@ struct Values {
|
||||
|
||||
// multiplayer settings
|
||||
Setting<std::string> multiplayer_nickname{linkage, {}, "nickname", Category::Multiplayer};
|
||||
Setting<std::string> multiplayer_filter_text{linkage, {}, "filter_text", Category::Multiplayer};
|
||||
Setting<bool> multiplayer_filter_games_owned{linkage, false, "filter_games_owned",
|
||||
Category::Multiplayer};
|
||||
Setting<bool> multiplayer_filter_hide_empty{linkage, false, "filter_games_hide_empty",
|
||||
Category::Multiplayer};
|
||||
Setting<bool> multiplayer_filter_hide_full{linkage, false, "filter_games_hide_full",
|
||||
Category::Multiplayer};
|
||||
Setting<std::string> multiplayer_ip{linkage, {}, "ip", Category::Multiplayer};
|
||||
Setting<u16, true> multiplayer_port{linkage, 24872, 0,
|
||||
UINT16_MAX, "port", Category::Multiplayer};
|
||||
@@ -222,7 +229,7 @@ void RestoreWindowState(std::unique_ptr<QtConfig>& qtConfig);
|
||||
// This must be in alphabetical order according to action name as it must have the same order as
|
||||
// UISetting::values.shortcuts, which is alphabetically ordered.
|
||||
// clang-format off
|
||||
const std::array<Shortcut, 23> default_hotkeys{{
|
||||
const std::array<Shortcut, 28> default_hotkeys{{
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Mute/Unmute")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+M"), std::string("Home+Dpad_Right"), Qt::WindowShortcut, false}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Down")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("-"), std::string("Home+Dpad_Down"), Qt::ApplicationShortcut, true}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Audio Volume Up")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("="), std::string("Home+Dpad_Up"), Qt::ApplicationShortcut, true}},
|
||||
@@ -236,6 +243,11 @@ const std::array<Shortcut, 23> default_hotkeys{{
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Fullscreen")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F11"), std::string("Home+B"), Qt::WindowShortcut, false}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load File")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+O"), std::string(""), Qt::WidgetWithChildrenShortcut, false}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Load/Remove Amiibo")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F2"), std::string("Home+A"), Qt::WidgetWithChildrenShortcut, false}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Multiplayer Browse Public Game Lobby")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+B"), std::string(""), Qt::ApplicationShortcut, false}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Multiplayer Create Room")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+N"), std::string(""), Qt::ApplicationShortcut, false}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Multiplayer Direct Connect to Room")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+C"), std::string(""), Qt::ApplicationShortcut, false}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Multiplayer Leave Room")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+L"), std::string(""), Qt::ApplicationShortcut, false}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Multiplayer Show Current Room")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+R"), std::string(""), Qt::ApplicationShortcut, false}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Restart Emulation")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F6"), std::string("R+Plus+Minus"), Qt::WindowShortcut, false}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Stop Emulation")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("F5"), std::string("L+Plus+Minus"), Qt::WindowShortcut, false}},
|
||||
{QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "TAS Record")).toStdString(), QStringLiteral(QT_TRANSLATE_NOOP("Hotkeys", "Main Window")).toStdString(), {std::string("Ctrl+F7"), std::string(""), Qt::ApplicationShortcut, false}},
|
||||
|
||||
Reference in New Issue
Block a user