From 6de45b5596bbcd829d9d17e4b5b179e156fd981f Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Wed, 5 May 2021 10:10:21 +0200 Subject: [PATCH] early-access version 1655 --- README.md | 4 +- src/common/bit_util.h | 2 - src/core/arm/dynarmic/arm_dynarmic_32.cpp | 12 +- src/core/arm/dynarmic/arm_dynarmic_32.h | 4 +- src/core/arm/dynarmic/arm_dynarmic_64.cpp | 12 +- src/core/arm/dynarmic/arm_dynarmic_64.h | 4 +- src/core/arm/dynarmic/arm_dynarmic_cp15.cpp | 11 +- src/core/core_timing.cpp | 4 +- src/core/core_timing.h | 2 +- src/core/cpu_manager.h | 8 +- src/core/hle/kernel/init/init_slab_setup.cpp | 54 ++-- src/core/hle/kernel/init/init_slab_setup.h | 9 +- src/core/hle/kernel/k_class_token.h | 2 +- src/core/hle/kernel/kernel.cpp | 12 +- src/core/hle/kernel/kernel.h | 10 + src/core/hle/service/acc/acc_aa.cpp | 8 +- src/core/hle/service/acc/acc_aa.h | 4 +- src/core/hle/service/acc/acc_su.cpp | 6 +- src/core/hle/service/acc/acc_su.h | 4 +- src/core/hle/service/acc/acc_u0.cpp | 6 +- src/core/hle/service/acc/acc_u0.h | 4 +- src/core/hle/service/acc/acc_u1.cpp | 6 +- src/core/hle/service/acc/acc_u1.h | 4 +- src/core/hle/service/am/am.cpp | 2 - .../service/am/applets/software_keyboard.cpp | 6 +- .../service/am/applets/software_keyboard.h | 2 +- src/core/hle/service/audio/audren_u.cpp | 5 +- src/core/hle/service/bcat/bcat.cpp | 6 +- src/core/hle/service/bcat/bcat.h | 4 +- src/core/hle/service/grc/grc.cpp | 2 +- .../hid/controllers/console_sixaxis.cpp | 4 +- .../service/hid/controllers/console_sixaxis.h | 2 +- .../hle/service/hid/controllers/debug_pad.cpp | 2 +- .../hle/service/hid/controllers/debug_pad.h | 2 +- .../hle/service/hid/controllers/gesture.cpp | 244 ++++++++++-------- .../hle/service/hid/controllers/gesture.h | 35 ++- .../hle/service/hid/controllers/keyboard.cpp | 2 +- .../hle/service/hid/controllers/keyboard.h | 2 +- .../hle/service/hid/controllers/mouse.cpp | 2 +- src/core/hle/service/hid/controllers/mouse.h | 2 +- src/core/hle/service/hid/controllers/npad.cpp | 2 +- src/core/hle/service/hid/controllers/npad.h | 2 +- .../hle/service/hid/controllers/stubbed.cpp | 2 +- .../hle/service/hid/controllers/stubbed.h | 2 +- .../service/hid/controllers/touchscreen.cpp | 2 +- .../hle/service/hid/controllers/touchscreen.h | 2 +- src/core/hle/service/hid/controllers/xpad.cpp | 2 +- src/core/hle/service/hid/controllers/xpad.h | 2 +- src/core/hle/service/nifm/nifm.cpp | 2 - src/core/hle/service/ns/pl_u.cpp | 4 +- .../service/nvdrv/devices/nvdisp_disp0.cpp | 4 +- .../hle/service/nvdrv/devices/nvdisp_disp0.h | 2 +- .../service/nvdrv/devices/nvhost_as_gpu.cpp | 4 +- .../hle/service/nvdrv/devices/nvhost_as_gpu.h | 2 +- .../hle/service/nvdrv/devices/nvhost_ctrl.cpp | 7 +- .../hle/service/nvdrv/devices/nvhost_ctrl.h | 4 +- .../service/nvdrv/devices/nvhost_ctrl_gpu.cpp | 2 +- .../service/nvdrv/devices/nvhost_ctrl_gpu.h | 2 +- .../hle/service/nvdrv/devices/nvhost_gpu.cpp | 10 +- .../hle/service/nvdrv/devices/nvhost_gpu.h | 4 +- .../service/nvdrv/devices/nvhost_nvdec.cpp | 6 +- .../hle/service/nvdrv/devices/nvhost_nvdec.h | 4 +- .../nvdrv/devices/nvhost_nvdec_common.cpp | 6 +- .../nvdrv/devices/nvhost_nvdec_common.h | 4 +- .../service/nvdrv/devices/nvhost_nvjpg.cpp | 2 +- .../hle/service/nvdrv/devices/nvhost_nvjpg.h | 2 +- .../hle/service/nvdrv/devices/nvhost_vic.cpp | 6 +- .../hle/service/nvdrv/devices/nvhost_vic.h | 4 +- src/core/hle/service/nvdrv/devices/nvmap.cpp | 2 +- src/core/hle/service/nvdrv/devices/nvmap.h | 2 +- src/core/hle/service/nvdrv/interface.cpp | 17 +- src/core/hle/service/pctl/module.cpp | 10 +- src/core/hle/service/pctl/module.h | 4 +- src/core/hle/service/time/interface.cpp | 4 +- src/core/hle/service/time/interface.h | 2 +- .../loader/deconstructed_rom_directory.cpp | 4 +- src/core/loader/deconstructed_rom_directory.h | 11 +- src/core/memory/cheat_engine.cpp | 4 +- src/core/memory/cheat_engine.h | 2 +- src/core/tools/freezer.cpp | 4 +- src/core/tools/freezer.h | 2 +- 81 files changed, 378 insertions(+), 303 deletions(-) diff --git a/README.md b/README.md index b2759aafe..009e6d621 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ yuzu emulator early access ============= -This is the source code for early-access 1653. +This is the source code for early-access 1655. ## Legal Notice -yuzu is an GPLv2 program, which allows fully free redistribution of its source code. \ No newline at end of file +yuzu is a GPLv2 program, which allows fully free redistribution of its source code. \ No newline at end of file diff --git a/src/common/bit_util.h b/src/common/bit_util.h index 683f09158..64520ca4e 100755 --- a/src/common/bit_util.h +++ b/src/common/bit_util.h @@ -44,6 +44,4 @@ template return static_cast(log2_f + static_cast((value ^ (1ULL << log2_f)) != 0ULL)); } -#define BIT(n) (1U << (n)) - } // namespace Common diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index 7aeb2a658..42a37e84f 100755 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp @@ -198,13 +198,13 @@ void ARM_Dynarmic_32::Step() { jit->Step(); } -ARM_Dynarmic_32::ARM_Dynarmic_32(System& system, CPUInterrupts& interrupt_handlers, - bool uses_wall_clock, ExclusiveMonitor& exclusive_monitor, - std::size_t core_index) - : ARM_Interface{system, interrupt_handlers, uses_wall_clock}, +ARM_Dynarmic_32::ARM_Dynarmic_32(System& system_, CPUInterrupts& interrupt_handlers_, + bool uses_wall_clock_, ExclusiveMonitor& exclusive_monitor_, + std::size_t core_index_) + : ARM_Interface{system_, interrupt_handlers_, uses_wall_clock_}, cb(std::make_unique(*this)), - cp15(std::make_shared(*this)), core_index{core_index}, - exclusive_monitor{dynamic_cast(exclusive_monitor)}, + cp15(std::make_shared(*this)), core_index{core_index_}, + exclusive_monitor{dynamic_cast(exclusive_monitor_)}, jit(MakeJit(nullptr)) {} ARM_Dynarmic_32::~ARM_Dynarmic_32() = default; diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.h b/src/core/arm/dynarmic/arm_dynarmic_32.h index d40aef7a9..42778c02c 100755 --- a/src/core/arm/dynarmic/arm_dynarmic_32.h +++ b/src/core/arm/dynarmic/arm_dynarmic_32.h @@ -29,8 +29,8 @@ class System; class ARM_Dynarmic_32 final : public ARM_Interface { public: - ARM_Dynarmic_32(System& system, CPUInterrupts& interrupt_handlers, bool uses_wall_clock, - ExclusiveMonitor& exclusive_monitor, std::size_t core_index); + ARM_Dynarmic_32(System& system_, CPUInterrupts& interrupt_handlers_, bool uses_wall_clock_, + ExclusiveMonitor& exclusive_monitor_, std::size_t core_index_); ~ARM_Dynarmic_32() override; void SetPC(u64 pc) override; diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index 97140c9c2..653bb7a77 100755 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp @@ -238,12 +238,12 @@ void ARM_Dynarmic_64::Step() { cb->InterpreterFallback(jit->GetPC(), 1); } -ARM_Dynarmic_64::ARM_Dynarmic_64(System& system, CPUInterrupts& interrupt_handlers, - bool uses_wall_clock, ExclusiveMonitor& exclusive_monitor, - std::size_t core_index) - : ARM_Interface{system, interrupt_handlers, uses_wall_clock}, - cb(std::make_unique(*this)), core_index{core_index}, - exclusive_monitor{dynamic_cast(exclusive_monitor)}, +ARM_Dynarmic_64::ARM_Dynarmic_64(System& system_, CPUInterrupts& interrupt_handlers_, + bool uses_wall_clock_, ExclusiveMonitor& exclusive_monitor_, + std::size_t core_index_) + : ARM_Interface{system_, interrupt_handlers_, uses_wall_clock_}, + cb(std::make_unique(*this)), core_index{core_index_}, + exclusive_monitor{dynamic_cast(exclusive_monitor_)}, jit(MakeJit(nullptr, 48)) {} ARM_Dynarmic_64::~ARM_Dynarmic_64() = default; diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.h b/src/core/arm/dynarmic/arm_dynarmic_64.h index edef04376..b81fbcc66 100755 --- a/src/core/arm/dynarmic/arm_dynarmic_64.h +++ b/src/core/arm/dynarmic/arm_dynarmic_64.h @@ -26,8 +26,8 @@ class System; class ARM_Dynarmic_64 final : public ARM_Interface { public: - ARM_Dynarmic_64(System& system, CPUInterrupts& interrupt_handlers, bool uses_wall_clock, - ExclusiveMonitor& exclusive_monitor, std::size_t core_index); + ARM_Dynarmic_64(System& system_, CPUInterrupts& interrupt_handlers_, bool uses_wall_clock_, + ExclusiveMonitor& exclusive_monitor_, std::size_t core_index_); ~ARM_Dynarmic_64() override; void SetPC(u64 pc) override; diff --git a/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp b/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp index caefc09f4..ebd506121 100755 --- a/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_cp15.cpp @@ -94,12 +94,11 @@ CallbackOrAccessOneWord DynarmicCP15::CompileGetOneWord(bool two, unsigned opc1, CallbackOrAccessTwoWords DynarmicCP15::CompileGetTwoWords(bool two, unsigned opc, CoprocReg CRm) { if (!two && opc == 0 && CRm == CoprocReg::C14) { // CNTPCT - const auto callback = static_cast( - [](Dynarmic::A32::Jit*, void* arg, u32, u32) -> u64 { - ARM_Dynarmic_32& parent = *(ARM_Dynarmic_32*)arg; - return parent.system.CoreTiming().GetClockTicks(); - }); - return Dynarmic::A32::Coprocessor::Callback{callback, (void*)&parent}; + const auto callback = [](Dynarmic::A32::Jit*, void* arg, u32, u32) -> u64 { + const auto& parent_arg = *static_cast(arg); + return parent_arg.system.CoreTiming().GetClockTicks(); + }; + return Callback{callback, &parent}; } LOG_CRITICAL(Core_ARM, "CP15: mrrc{} p15, {}, , , {}", two ? "2" : "", opc, CRm); diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 874b5673a..c2f0f609f 100755 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -133,8 +133,8 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr& event_type, } } -void CoreTiming::AddTicks(u64 ticks) { - this->ticks += ticks; +void CoreTiming::AddTicks(u64 ticks_to_add) { + ticks += ticks_to_add; downcount -= static_cast(ticks); } diff --git a/src/core/core_timing.h b/src/core/core_timing.h index 77ff4c6fe..b64caacda 100755 --- a/src/core/core_timing.h +++ b/src/core/core_timing.h @@ -102,7 +102,7 @@ public: /// We only permit one event of each type in the queue at a time. void RemoveEvent(const std::shared_ptr& event_type); - void AddTicks(u64 ticks); + void AddTicks(u64 ticks_to_add); void ResetTicks(); diff --git a/src/core/cpu_manager.h b/src/core/cpu_manager.h index 17420c941..9817017c0 100755 --- a/src/core/cpu_manager.h +++ b/src/core/cpu_manager.h @@ -35,13 +35,13 @@ public: CpuManager& operator=(CpuManager&&) = delete; /// Sets if emulation is multicore or single core, must be set before Initialize - void SetMulticore(bool is_multicore) { - this->is_multicore = is_multicore; + void SetMulticore(bool is_multi) { + is_multicore = is_multi; } /// Sets if emulation is using an asynchronous GPU. - void SetAsyncGpu(bool is_async_gpu) { - this->is_async_gpu = is_async_gpu; + void SetAsyncGpu(bool is_async) { + is_async_gpu = is_async; } void Initialize(); diff --git a/src/core/hle/kernel/init/init_slab_setup.cpp b/src/core/hle/kernel/init/init_slab_setup.cpp index 2dd792e71..69ae405e6 100755 --- a/src/core/hle/kernel/init/init_slab_setup.cpp +++ b/src/core/hle/kernel/init/init_slab_setup.cpp @@ -25,7 +25,7 @@ namespace Kernel::Init { -#define SLAB_COUNT(CLASS) g_slab_resource_counts.num_##CLASS +#define SLAB_COUNT(CLASS) kernel.SlabResourceCounts().num_##CLASS #define FOREACH_SLAB_TYPE(HANDLER, ...) \ HANDLER(KProcess, (SLAB_COUNT(KProcess)), ##__VA_ARGS__) \ @@ -67,26 +67,6 @@ constexpr size_t SlabCountKBeta = 6; constexpr size_t SlabCountExtraKThread = 160; -// Global to hold our resource counts. -KSlabResourceCounts g_slab_resource_counts = { - .num_KProcess = SlabCountKProcess, - .num_KThread = SlabCountKThread, - .num_KEvent = SlabCountKEvent, - .num_KInterruptEvent = SlabCountKInterruptEvent, - .num_KPort = SlabCountKPort, - .num_KSharedMemory = SlabCountKSharedMemory, - .num_KTransferMemory = SlabCountKTransferMemory, - .num_KCodeMemory = SlabCountKCodeMemory, - .num_KDeviceAddressSpace = SlabCountKDeviceAddressSpace, - .num_KSession = SlabCountKSession, - .num_KLightSession = SlabCountKLightSession, - .num_KObjectName = SlabCountKObjectName, - .num_KResourceLimit = SlabCountKResourceLimit, - .num_KDebug = SlabCountKDebug, - .num_KAlpha = SlabCountKAlpha, - .num_KBeta = SlabCountKBeta, -}; - template VAddr InitializeSlabHeap(Core::System& system, KMemoryLayout& memory_layout, VAddr address, size_t num_objects) { @@ -105,19 +85,35 @@ VAddr InitializeSlabHeap(Core::System& system, KMemoryLayout& memory_layout, VAd } // namespace -const KSlabResourceCounts& GetSlabResourceCounts() { - return g_slab_resource_counts; +KSlabResourceCounts KSlabResourceCounts::CreateDefault() { + return { + .num_KProcess = SlabCountKProcess, + .num_KThread = SlabCountKThread, + .num_KEvent = SlabCountKEvent, + .num_KInterruptEvent = SlabCountKInterruptEvent, + .num_KPort = SlabCountKPort, + .num_KSharedMemory = SlabCountKSharedMemory, + .num_KTransferMemory = SlabCountKTransferMemory, + .num_KCodeMemory = SlabCountKCodeMemory, + .num_KDeviceAddressSpace = SlabCountKDeviceAddressSpace, + .num_KSession = SlabCountKSession, + .num_KLightSession = SlabCountKLightSession, + .num_KObjectName = SlabCountKObjectName, + .num_KResourceLimit = SlabCountKResourceLimit, + .num_KDebug = SlabCountKDebug, + .num_KAlpha = SlabCountKAlpha, + .num_KBeta = SlabCountKBeta, + }; } -void InitializeSlabResourceCounts() { - // Note: Nintendo initializes all fields here, but we initialize all constants at compile-time. - +void InitializeSlabResourceCounts(KernelCore& kernel) { + kernel.SlabResourceCounts() = KSlabResourceCounts::CreateDefault(); if (KSystemControl::Init::ShouldIncreaseThreadResourceLimit()) { - g_slab_resource_counts.num_KThread += SlabCountExtraKThread; + kernel.SlabResourceCounts().num_KThread += SlabCountExtraKThread; } } -size_t CalculateTotalSlabHeapSize() { +size_t CalculateTotalSlabHeapSize(const KernelCore& kernel) { size_t size = 0; #define ADD_SLAB_SIZE(NAME, COUNT, ...) \ @@ -138,6 +134,8 @@ size_t CalculateTotalSlabHeapSize() { } void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout) { + auto& kernel = system.Kernel(); + // Get the start of the slab region, since that's where we'll be working. VAddr address = memory_layout.GetSlabRegionAddress(); diff --git a/src/core/hle/kernel/init/init_slab_setup.h b/src/core/hle/kernel/init/init_slab_setup.h index 6418b97ac..a8f7e0918 100755 --- a/src/core/hle/kernel/init/init_slab_setup.h +++ b/src/core/hle/kernel/init/init_slab_setup.h @@ -9,12 +9,15 @@ class System; } // namespace Core namespace Kernel { +class KernelCore; class KMemoryLayout; } // namespace Kernel namespace Kernel::Init { struct KSlabResourceCounts { + static KSlabResourceCounts CreateDefault(); + size_t num_KProcess; size_t num_KThread; size_t num_KEvent; @@ -33,10 +36,8 @@ struct KSlabResourceCounts { size_t num_KBeta; }; -void InitializeSlabResourceCounts(); -const KSlabResourceCounts& GetSlabResourceCounts(); - -size_t CalculateTotalSlabHeapSize(); +void InitializeSlabResourceCounts(KernelCore& kernel); +size_t CalculateTotalSlabHeapSize(const KernelCore& kernel); void InitializeSlabHeaps(Core::System& system, KMemoryLayout& memory_layout); } // namespace Kernel::Init diff --git a/src/core/hle/kernel/k_class_token.h b/src/core/hle/kernel/k_class_token.h index fb4307cd0..c28db49ec 100755 --- a/src/core/hle/kernel/k_class_token.h +++ b/src/core/hle/kernel/k_class_token.h @@ -38,7 +38,7 @@ public: private: template - static constexpr inline TokenBaseType BaseClassToken = BIT(Index); + static constexpr inline TokenBaseType BaseClassToken = 1U << Index; template static constexpr inline TokenBaseType FinalClassToken = [] { diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 5ebd47e49..32bbf2d9b 100755 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -69,6 +69,7 @@ struct KernelCore::Impl { InitializePhysicalCores(); // Derive the initial memory layout from the emulated board + Init::InitializeSlabResourceCounts(kernel); KMemoryLayout memory_layout; DeriveInitialMemoryLayout(memory_layout); Init::InitializeSlabHeaps(system, memory_layout); @@ -395,7 +396,7 @@ struct KernelCore::Impl { // Determine the size of the slab region. const size_t slab_region_size = - Common::AlignUp(Init::CalculateTotalSlabHeapSize(), PageSize); + Common::AlignUp(Init::CalculateTotalSlabHeapSize(system.Kernel()), PageSize); ASSERT(slab_region_size <= resource_region_size); // Setup the slab region. @@ -642,6 +643,7 @@ struct KernelCore::Impl { std::unique_ptr global_scheduler_context; Kernel::TimeManager time_manager; + Init::KSlabResourceCounts slab_resource_counts{}; KResourceLimit* system_resource_limit{}; std::shared_ptr preemption_event; @@ -995,6 +997,14 @@ void KernelCore::ReleaseServiceThread(std::weak_ptr servi }); } +Init::KSlabResourceCounts& KernelCore::SlabResourceCounts() { + return impl->slab_resource_counts; +} + +const Init::KSlabResourceCounts& KernelCore::SlabResourceCounts() const { + return impl->slab_resource_counts; +} + bool KernelCore::IsPhantomModeForSingleCore() const { return impl->IsPhantomModeForSingleCore(); } diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 7c46aa997..51aaccbc7 100755 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -51,6 +51,10 @@ class ServiceThread; class Synchronization; class TimeManager; +namespace Init { +struct KSlabResourceCounts; +} + template class KSlabHeap; @@ -292,6 +296,12 @@ public: } } + /// Gets the current slab resource counts. + Init::KSlabResourceCounts& SlabResourceCounts(); + + /// Gets the current slab resource counts. + const Init::KSlabResourceCounts& SlabResourceCounts() const; + private: friend class KProcess; friend class KThread; diff --git a/src/core/hle/service/acc/acc_aa.cpp b/src/core/hle/service/acc/acc_aa.cpp index 51f119b12..e498fb64d 100755 --- a/src/core/hle/service/acc/acc_aa.cpp +++ b/src/core/hle/service/acc/acc_aa.cpp @@ -6,9 +6,10 @@ namespace Service::Account { -ACC_AA::ACC_AA(std::shared_ptr module, std::shared_ptr profile_manager, - Core::System& system) - : Module::Interface(std::move(module), std::move(profile_manager), system, "acc:aa") { +ACC_AA::ACC_AA(std::shared_ptr module_, std::shared_ptr profile_manager_, + Core::System& system_) + : Interface(std::move(module_), std::move(profile_manager_), system_, "acc:aa") { + // clang-format off static const FunctionInfo functions[] = { {0, nullptr, "EnsureCacheAsync"}, {1, nullptr, "LoadCache"}, @@ -16,6 +17,7 @@ ACC_AA::ACC_AA(std::shared_ptr module, std::shared_ptr p {50, nullptr, "RegisterNotificationTokenAsync"}, // 1.0.0 - 6.2.0 {51, nullptr, "UnregisterNotificationTokenAsync"}, // 1.0.0 - 6.2.0 }; + // clang-format on RegisterHandlers(functions); } diff --git a/src/core/hle/service/acc/acc_aa.h b/src/core/hle/service/acc/acc_aa.h index 932c04890..d1be20ff3 100755 --- a/src/core/hle/service/acc/acc_aa.h +++ b/src/core/hle/service/acc/acc_aa.h @@ -10,8 +10,8 @@ namespace Service::Account { class ACC_AA final : public Module::Interface { public: - explicit ACC_AA(std::shared_ptr module, std::shared_ptr profile_manager, - Core::System& system); + explicit ACC_AA(std::shared_ptr module_, + std::shared_ptr profile_manager_, Core::System& system_); ~ACC_AA() override; }; diff --git a/src/core/hle/service/acc/acc_su.cpp b/src/core/hle/service/acc/acc_su.cpp index bb6118abf..94a1b8814 100755 --- a/src/core/hle/service/acc/acc_su.cpp +++ b/src/core/hle/service/acc/acc_su.cpp @@ -6,9 +6,9 @@ namespace Service::Account { -ACC_SU::ACC_SU(std::shared_ptr module, std::shared_ptr profile_manager, - Core::System& system) - : Module::Interface(std::move(module), std::move(profile_manager), system, "acc:su") { +ACC_SU::ACC_SU(std::shared_ptr module_, std::shared_ptr profile_manager_, + Core::System& system_) + : Interface(std::move(module_), std::move(profile_manager_), system_, "acc:su") { // clang-format off static const FunctionInfo functions[] = { {0, &ACC_SU::GetUserCount, "GetUserCount"}, diff --git a/src/core/hle/service/acc/acc_su.h b/src/core/hle/service/acc/acc_su.h index 0a700d9bf..132a126b4 100755 --- a/src/core/hle/service/acc/acc_su.h +++ b/src/core/hle/service/acc/acc_su.h @@ -10,8 +10,8 @@ namespace Service::Account { class ACC_SU final : public Module::Interface { public: - explicit ACC_SU(std::shared_ptr module, std::shared_ptr profile_manager, - Core::System& system); + explicit ACC_SU(std::shared_ptr module_, + std::shared_ptr profile_manager_, Core::System& system_); ~ACC_SU() override; }; diff --git a/src/core/hle/service/acc/acc_u0.cpp b/src/core/hle/service/acc/acc_u0.cpp index 8d66d180d..ed241647c 100755 --- a/src/core/hle/service/acc/acc_u0.cpp +++ b/src/core/hle/service/acc/acc_u0.cpp @@ -6,9 +6,9 @@ namespace Service::Account { -ACC_U0::ACC_U0(std::shared_ptr module, std::shared_ptr profile_manager, - Core::System& system) - : Module::Interface(std::move(module), std::move(profile_manager), system, "acc:u0") { +ACC_U0::ACC_U0(std::shared_ptr module_, std::shared_ptr profile_manager_, + Core::System& system_) + : Interface(std::move(module_), std::move(profile_manager_), system_, "acc:u0") { // clang-format off static const FunctionInfo functions[] = { {0, &ACC_U0::GetUserCount, "GetUserCount"}, diff --git a/src/core/hle/service/acc/acc_u0.h b/src/core/hle/service/acc/acc_u0.h index 3bd9c3164..4c2600b67 100755 --- a/src/core/hle/service/acc/acc_u0.h +++ b/src/core/hle/service/acc/acc_u0.h @@ -10,8 +10,8 @@ namespace Service::Account { class ACC_U0 final : public Module::Interface { public: - explicit ACC_U0(std::shared_ptr module, std::shared_ptr profile_manager, - Core::System& system); + explicit ACC_U0(std::shared_ptr module_, + std::shared_ptr profile_manager_, Core::System& system_); ~ACC_U0() override; }; diff --git a/src/core/hle/service/acc/acc_u1.cpp b/src/core/hle/service/acc/acc_u1.cpp index 71982ad5a..6ce7fe8e6 100755 --- a/src/core/hle/service/acc/acc_u1.cpp +++ b/src/core/hle/service/acc/acc_u1.cpp @@ -6,9 +6,9 @@ namespace Service::Account { -ACC_U1::ACC_U1(std::shared_ptr module, std::shared_ptr profile_manager, - Core::System& system) - : Module::Interface(std::move(module), std::move(profile_manager), system, "acc:u1") { +ACC_U1::ACC_U1(std::shared_ptr module_, std::shared_ptr profile_manager_, + Core::System& system_) + : Interface(std::move(module_), std::move(profile_manager_), system_, "acc:u1") { // clang-format off static const FunctionInfo functions[] = { {0, &ACC_U1::GetUserCount, "GetUserCount"}, diff --git a/src/core/hle/service/acc/acc_u1.h b/src/core/hle/service/acc/acc_u1.h index 829f8a744..2d478324a 100755 --- a/src/core/hle/service/acc/acc_u1.h +++ b/src/core/hle/service/acc/acc_u1.h @@ -10,8 +10,8 @@ namespace Service::Account { class ACC_U1 final : public Module::Interface { public: - explicit ACC_U1(std::shared_ptr module, std::shared_ptr profile_manager, - Core::System& system); + explicit ACC_U1(std::shared_ptr module_, + std::shared_ptr profile_manager_, Core::System& system_); ~ACC_U1() override; }; diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index e8b82db00..408e441dc 100755 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1338,8 +1338,6 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_) RegisterHandlers(functions); - auto& kernel = system.Kernel(); - Kernel::KAutoObject::Create(std::addressof(gpu_error_detected_event)); Kernel::KAutoObject::Create(std::addressof(friend_invitation_storage_channel_event)); Kernel::KAutoObject::Create(std::addressof(health_warning_disappeared_system_event)); diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp index 73a06def1..b05a5da04 100755 --- a/src/core/hle/service/am/applets/software_keyboard.cpp +++ b/src/core/hle/service/am/applets/software_keyboard.cpp @@ -241,7 +241,7 @@ void SoftwareKeyboard::InitializeForeground() { InitializeFrontendKeyboard(); } -void SoftwareKeyboard::InitializeBackground(LibraryAppletMode applet_mode) { +void SoftwareKeyboard::InitializeBackground(LibraryAppletMode library_applet_mode) { LOG_INFO(Service_AM, "Initializing Inline Software Keyboard Applet."); is_background = true; @@ -256,9 +256,9 @@ void SoftwareKeyboard::InitializeBackground(LibraryAppletMode applet_mode) { swkbd_inline_initialize_arg.size()); if (swkbd_initialize_arg.library_applet_mode_flag) { - ASSERT(applet_mode == LibraryAppletMode::Background); + ASSERT(library_applet_mode == LibraryAppletMode::Background); } else { - ASSERT(applet_mode == LibraryAppletMode::BackgroundIndirectDisplay); + ASSERT(library_applet_mode == LibraryAppletMode::BackgroundIndirectDisplay); } } diff --git a/src/core/hle/service/am/applets/software_keyboard.h b/src/core/hle/service/am/applets/software_keyboard.h index 7c67b7574..7bdef78a7 100755 --- a/src/core/hle/service/am/applets/software_keyboard.h +++ b/src/core/hle/service/am/applets/software_keyboard.h @@ -57,7 +57,7 @@ private: void InitializeForeground(); /// Initializes the inline software keyboard. - void InitializeBackground(LibraryAppletMode applet_mode); + void InitializeBackground(LibraryAppletMode library_applet_mode); /// Processes the text check sent by the application. void ProcessTextCheck(); diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 95e4f373e..513bd3730 100755 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -27,9 +27,10 @@ namespace Service::Audio { class IAudioRenderer final : public ServiceFramework { public: - explicit IAudioRenderer(Core::System& system, AudioCommon::AudioRendererParameter audren_params, + explicit IAudioRenderer(Core::System& system_, + const AudioCommon::AudioRendererParameter& audren_params, const std::size_t instance_number) - : ServiceFramework{system, "IAudioRenderer"}, system_event{system.Kernel()} { + : ServiceFramework{system_, "IAudioRenderer"}, system_event{system.Kernel()} { // clang-format off static const FunctionInfo functions[] = { {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"}, diff --git a/src/core/hle/service/bcat/bcat.cpp b/src/core/hle/service/bcat/bcat.cpp index b31766212..5a95707de 100755 --- a/src/core/hle/service/bcat/bcat.cpp +++ b/src/core/hle/service/bcat/bcat.cpp @@ -6,9 +6,9 @@ namespace Service::BCAT { -BCAT::BCAT(Core::System& system, std::shared_ptr module, - FileSystem::FileSystemController& fsc, const char* name) - : Interface(system, std::move(module), fsc, name) { +BCAT::BCAT(Core::System& system_, std::shared_ptr module_, + FileSystem::FileSystemController& fsc_, const char* name_) + : Interface(system_, std::move(module_), fsc_, name_) { // clang-format off static const FunctionInfo functions[] = { {0, &BCAT::CreateBcatService, "CreateBcatService"}, diff --git a/src/core/hle/service/bcat/bcat.h b/src/core/hle/service/bcat/bcat.h index 6354465fc..d72798980 100755 --- a/src/core/hle/service/bcat/bcat.h +++ b/src/core/hle/service/bcat/bcat.h @@ -14,8 +14,8 @@ namespace Service::BCAT { class BCAT final : public Module::Interface { public: - explicit BCAT(Core::System& system, std::shared_ptr module, - FileSystem::FileSystemController& fsc, const char* name); + explicit BCAT(Core::System& system_, std::shared_ptr module_, + FileSystem::FileSystemController& fsc_, const char* name_); ~BCAT() override; }; diff --git a/src/core/hle/service/grc/grc.cpp b/src/core/hle/service/grc/grc.cpp index a502ab47f..f918bdf03 100755 --- a/src/core/hle/service/grc/grc.cpp +++ b/src/core/hle/service/grc/grc.cpp @@ -12,7 +12,7 @@ namespace Service::GRC { class GRC final : public ServiceFramework { public: - explicit GRC(Core::System& system) : ServiceFramework{system, "grc:c"} { + explicit GRC(Core::System& system_) : ServiceFramework{system_, "grc:c"} { // clang-format off static const FunctionInfo functions[] = { {1, nullptr, "OpenContinuousRecorder"}, diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.cpp b/src/core/hle/service/hid/controllers/console_sixaxis.cpp index 913768fab..bda6e2557 100755 --- a/src/core/hle/service/hid/controllers/console_sixaxis.cpp +++ b/src/core/hle/service/hid/controllers/console_sixaxis.cpp @@ -9,8 +9,8 @@ namespace Service::HID { constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C200; -Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::System& system) - : ControllerBase(system) {} +Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::System& system_) + : ControllerBase{system_} {} Controller_ConsoleSixAxis::~Controller_ConsoleSixAxis() = default; void Controller_ConsoleSixAxis::OnInit() {} diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.h b/src/core/hle/service/hid/controllers/console_sixaxis.h index 1fae98e94..fd8a427af 100755 --- a/src/core/hle/service/hid/controllers/console_sixaxis.h +++ b/src/core/hle/service/hid/controllers/console_sixaxis.h @@ -14,7 +14,7 @@ namespace Service::HID { class Controller_ConsoleSixAxis final : public ControllerBase { public: - explicit Controller_ConsoleSixAxis(Core::System& system); + explicit Controller_ConsoleSixAxis(Core::System& system_); ~Controller_ConsoleSixAxis() override; // Called when the controller is initialized diff --git a/src/core/hle/service/hid/controllers/debug_pad.cpp b/src/core/hle/service/hid/controllers/debug_pad.cpp index a460f2f79..d439b8fb0 100755 --- a/src/core/hle/service/hid/controllers/debug_pad.cpp +++ b/src/core/hle/service/hid/controllers/debug_pad.cpp @@ -14,7 +14,7 @@ constexpr s32 HID_JOYSTICK_MAX = 0x7fff; [[maybe_unused]] constexpr s32 HID_JOYSTICK_MIN = -0x7fff; enum class JoystickId : std::size_t { Joystick_Left, Joystick_Right }; -Controller_DebugPad::Controller_DebugPad(Core::System& system) : ControllerBase(system) {} +Controller_DebugPad::Controller_DebugPad(Core::System& system_) : ControllerBase{system_} {} Controller_DebugPad::~Controller_DebugPad() = default; void Controller_DebugPad::OnInit() {} diff --git a/src/core/hle/service/hid/controllers/debug_pad.h b/src/core/hle/service/hid/controllers/debug_pad.h index 0593d7d39..1b1645184 100755 --- a/src/core/hle/service/hid/controllers/debug_pad.h +++ b/src/core/hle/service/hid/controllers/debug_pad.h @@ -16,7 +16,7 @@ namespace Service::HID { class Controller_DebugPad final : public ControllerBase { public: - explicit Controller_DebugPad(Core::System& system); + explicit Controller_DebugPad(Core::System& system_); ~Controller_DebugPad() override; // Called when the controller is initialized diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp index 353ee20ac..03a291111 100755 --- a/src/core/hle/service/hid/controllers/gesture.cpp +++ b/src/core/hle/service/hid/controllers/gesture.cpp @@ -1,26 +1,31 @@ -// Copyright 2018 yuzu emulator team +// Copyright 2021 yuzu Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include -#include "common/common_types.h" #include "common/logging/log.h" +#include "common/math_util.h" #include "common/settings.h" #include "core/core_timing.h" #include "core/frontend/emu_window.h" #include "core/hle/service/hid/controllers/gesture.h" +namespace { +constexpr inline f32 Square(s32 num) { + return static_cast(num * num); +} +} // Anonymous namespace + namespace Service::HID { constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3BA00; -constexpr f32 angle_threshold = 0.02f; -constexpr f32 pinch_threshold = 100.0f; // HW is around 700, value is set to 400 to make it easier to trigger with mouse -constexpr float swipe_threshold = 400.0f; -constexpr float press_delay = 0.500f; // Time in seconds -constexpr float double_tap_delay = 0.350f; // Time in seconds +constexpr f32 swipe_threshold = 400.0f; // Threshold in pixels/s +constexpr f32 angle_threshold = 0.015f; // Threshold in radians +constexpr f32 pinch_threshold = 0.5f; // Threshold in pixels +constexpr f32 press_delay = 0.5f; // Time in seconds +constexpr f32 double_tap_delay = 0.35f; // Time in seconds -Controller_Gesture::Controller_Gesture(Core::System& system) : ControllerBase(system) {} +Controller_Gesture::Controller_Gesture(Core::System& system_) : ControllerBase{system_} {} Controller_Gesture::~Controller_Gesture() = default; void Controller_Gesture::OnInit() { @@ -49,9 +54,8 @@ void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u ReadTouchInput(); GestureProperties gesture = GetGestureProperties(); - float time_difference = - static_cast(shared_memory.header.timestamp - last_update_timestamp) / - (1000 * 1000 * 1000); + f32 time_difference = static_cast(shared_memory.header.timestamp - last_update_timestamp) / + (1000 * 1000 * 1000); // Only update if necesary if (!ShouldUpdateGesture(gesture, time_difference)) { @@ -80,7 +84,7 @@ void Controller_Gesture::ReadTouchInput() { } bool Controller_Gesture::ShouldUpdateGesture(const GestureProperties& gesture, - float time_difference) { + f32 time_difference) { const auto& last_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; if (force_update) { force_update = false; @@ -98,7 +102,7 @@ bool Controller_Gesture::ShouldUpdateGesture(const GestureProperties& gesture, // Update on press and hold event after 0.5 seconds if (last_entry.type == TouchType::Touch && last_entry.point_count == 1 && time_difference > press_delay) { - return true; + return enable_press_and_tap; } return false; @@ -106,7 +110,7 @@ bool Controller_Gesture::ShouldUpdateGesture(const GestureProperties& gesture, void Controller_Gesture::UpdateGestureSharedMemory(u8* data, std::size_t size, GestureProperties& gesture, - float time_difference) { + f32 time_difference) { TouchType type = TouchType::Idle; Attribute attributes{}; @@ -117,6 +121,7 @@ void Controller_Gesture::UpdateGestureSharedMemory(u8* data, std::size_t size, if (shared_memory.header.entry_count < 16) { shared_memory.header.entry_count++; } + cur_entry.sampling_number = last_entry.sampling_number + 1; cur_entry.sampling_number2 = cur_entry.sampling_number; @@ -131,71 +136,15 @@ void Controller_Gesture::UpdateGestureSharedMemory(u8* data, std::size_t size, if (gesture.active_points > 0) { if (last_gesture.active_points == 0) { - // New touch - gesture.detection_count++; - type = TouchType::Touch; - if (last_entry.type != TouchType::Cancel) { - attributes.is_new_touch.Assign(1); - } + NewGesture(gesture, type, attributes); } else { - // Promote to pan type if touch moved - for (size_t id = 0; id < MAX_POINTS; id++) { - if (gesture.points[id].x != last_gesture.points[id].x || - gesture.points[id].y != last_gesture.points[id].y) { - type = TouchType::Pan; - break; - } - } - // Number of fingers changed cancel the last event - if (gesture.active_points != last_gesture.active_points) { - type = TouchType::Cancel; - gesture.active_points = 0; - gesture.mid_point = {}; - for (size_t id = 0; id < MAX_POINTS; id++) { - gesture.points[id].x = 0; - gesture.points[id].y = 0; - } - } + UpdateExistingGesture(gesture, type, time_difference); } - - // Calculate extra parameters of panning - if (type == TouchType::Pan) { - UpdatePanEvent(gesture, last_gesture, type, time_difference); - } - - // Promote to press type - if (type == TouchType::Idle && last_entry.type == TouchType::Touch) { - type = TouchType::Press; - } - } else { - // Touch end - if (last_gesture.active_points != 0) { - switch (last_entry.type) { - case TouchType::Touch: - SetTapEvent(gesture, last_gesture, type, attributes); - break; - case TouchType::Press: - case TouchType::Tap: - case TouchType::Swipe: - case TouchType::Pinch: - case TouchType::Rotate: - type = TouchType::Complete; - force_update = true; - break; - case TouchType::Pan: - EndPanEvent(gesture, last_gesture, type, time_difference); - break; - default: - break; - } - } else { - if (last_entry.type == TouchType::Complete || last_entry.type == TouchType::Cancel) { - gesture.detection_count++; - } - } + EndGesture(gesture, last_gesture, type, attributes, time_difference); } + // Apply attributes cur_entry.detection_count = gesture.detection_count; cur_entry.type = type; cur_entry.attributes = attributes; @@ -211,13 +160,101 @@ void Controller_Gesture::UpdateGestureSharedMemory(u8* data, std::size_t size, std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(SharedMemory)); } +void Controller_Gesture::NewGesture(GestureProperties& gesture, TouchType& type, + Attribute& attributes) { + const auto& last_entry = + shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; + gesture.detection_count++; + type = TouchType::Touch; + + // New touch after cancel is not considered new + if (last_entry.type != TouchType::Cancel) { + attributes.is_new_touch.Assign(1); + enable_press_and_tap = true; + } +} + +void Controller_Gesture::UpdateExistingGesture(GestureProperties& gesture, TouchType& type, + f32 time_difference) { + const auto& last_entry = + shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; + + // Promote to pan type if touch moved + for (size_t id = 0; id < MAX_POINTS; id++) { + if (gesture.points[id].x != last_gesture.points[id].x || + gesture.points[id].y != last_gesture.points[id].y) { + type = TouchType::Pan; + break; + } + } + + // Number of fingers changed cancel the last event and clear data + if (gesture.active_points != last_gesture.active_points) { + type = TouchType::Cancel; + enable_press_and_tap = false; + gesture.active_points = 0; + gesture.mid_point = {}; + for (size_t id = 0; id < MAX_POINTS; id++) { + gesture.points[id].x = 0; + gesture.points[id].y = 0; + } + return; + } + + // Calculate extra parameters of panning + if (type == TouchType::Pan) { + UpdatePanEvent(gesture, last_gesture, type, time_difference); + return; + } + + // Promote to press type + if (last_entry.type == TouchType::Touch) { + type = TouchType::Press; + } +} + +void Controller_Gesture::EndGesture(GestureProperties& gesture, GestureProperties& last_gesture, + TouchType& type, Attribute& attributes, f32 time_difference) { + const auto& last_entry = + shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; + if (last_gesture.active_points != 0) { + switch (last_entry.type) { + case TouchType::Touch: + if (enable_press_and_tap) { + SetTapEvent(gesture, last_gesture, type, attributes); + return; + } + type = TouchType::Cancel; + force_update = true; + break; + case TouchType::Press: + case TouchType::Tap: + case TouchType::Swipe: + case TouchType::Pinch: + case TouchType::Rotate: + type = TouchType::Complete; + force_update = true; + break; + case TouchType::Pan: + EndPanEvent(gesture, last_gesture, type, time_difference); + break; + default: + break; + } + return; + } + if (last_entry.type == TouchType::Complete || last_entry.type == TouchType::Cancel) { + gesture.detection_count++; + } +} + void Controller_Gesture::SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type, Attribute& attributes) { type = TouchType::Tap; gesture = last_gesture; force_update = true; - float tap_time_difference = - static_cast(last_update_timestamp - last_tap_timestamp) / (1000 * 1000 * 1000); + f32 tap_time_difference = + static_cast(last_update_timestamp - last_tap_timestamp) / (1000 * 1000 * 1000); last_tap_timestamp = last_update_timestamp; if (tap_time_difference < double_tap_delay) { attributes.is_double_tap.Assign(1); @@ -225,40 +262,43 @@ void Controller_Gesture::SetTapEvent(GestureProperties& gesture, GestureProperti } void Controller_Gesture::UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type, float time_difference) { + TouchType& type, f32 time_difference) { auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; - auto& last_entry = + const auto& last_entry = shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; cur_entry.delta_x = gesture.mid_point.x - last_entry.x; cur_entry.delta_y = gesture.mid_point.y - last_entry.y; - cur_entry.vel_x = static_cast(cur_entry.delta_x) / time_difference; - cur_entry.vel_y = static_cast(cur_entry.delta_y) / time_difference; + cur_entry.vel_x = static_cast(cur_entry.delta_x) / time_difference; + cur_entry.vel_y = static_cast(cur_entry.delta_y) / time_difference; last_pan_time_difference = time_difference; // Promote to pinch type if (std::abs(gesture.average_distance - last_gesture.average_distance) > pinch_threshold) { type = TouchType::Pinch; - cur_entry.scale = 1; + cur_entry.scale = gesture.average_distance / last_gesture.average_distance; } + const f32 angle_between_two_lines = std::atan((gesture.angle - last_gesture.angle) / + (1 + (gesture.angle * last_gesture.angle))); // Promote to rotate type - if (std::abs(gesture.angle - last_gesture.angle) > angle_threshold) { + if (std::abs(angle_between_two_lines) > angle_threshold) { type = TouchType::Rotate; - cur_entry.rotation_angle = 1; + cur_entry.scale = 0; + cur_entry.rotation_angle = angle_between_two_lines * 180.0f / Common::PI; } } void Controller_Gesture::EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type, float time_difference) { + TouchType& type, f32 time_difference) { auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; - auto& last_entry = + const auto& last_entry = shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; cur_entry.vel_x = - static_cast(last_entry.delta_x) / (last_pan_time_difference + time_difference); + static_cast(last_entry.delta_x) / (last_pan_time_difference + time_difference); cur_entry.vel_y = - static_cast(last_entry.delta_y) / (last_pan_time_difference + time_difference); - const float curr_vel = + static_cast(last_entry.delta_y) / (last_pan_time_difference + time_difference); + const f32 curr_vel = std::sqrt((cur_entry.vel_x * cur_entry.vel_x) + (cur_entry.vel_y * cur_entry.vel_y)); // Set swipe event with parameters @@ -277,7 +317,7 @@ void Controller_Gesture::EndPanEvent(GestureProperties& gesture, GestureProperti void Controller_Gesture::SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type) { auto& cur_entry = shared_memory.gesture_states[shared_memory.header.last_entry_index]; - auto& last_entry = + const auto& last_entry = shared_memory.gesture_states[(shared_memory.header.last_entry_index + 16) % 17]; type = TouchType::Swipe; gesture = last_gesture; @@ -360,32 +400,30 @@ Controller_Gesture::GestureProperties Controller_Gesture::GetGestureProperties() for (size_t id = 0; id < gesture.active_points; ++id) { gesture.points[id].x = - static_cast(active_fingers[id].x * Layout::ScreenUndocked::Width); + static_cast(active_fingers[id].x * Layout::ScreenUndocked::Width); gesture.points[id].y = - static_cast(active_fingers[id].y * Layout::ScreenUndocked::Height); + static_cast(active_fingers[id].y * Layout::ScreenUndocked::Height); // Hack: There is no touch in docked but games still allow it if (Settings::values.use_docked_mode.GetValue()) { gesture.points[id].x = - static_cast(active_fingers[id].x * Layout::ScreenDocked::Width); + static_cast(active_fingers[id].x * Layout::ScreenDocked::Width); gesture.points[id].y = - static_cast(active_fingers[id].y * Layout::ScreenDocked::Height); + static_cast(active_fingers[id].y * Layout::ScreenDocked::Height); } - gesture.mid_point.x += static_cast(gesture.points[id].x / gesture.active_points); - gesture.mid_point.y += static_cast(gesture.points[id].y / gesture.active_points); + gesture.mid_point.x += static_cast(gesture.points[id].x / gesture.active_points); + gesture.mid_point.y += static_cast(gesture.points[id].y / gesture.active_points); } for (size_t id = 0; id < gesture.active_points; ++id) { - const double distance = - std::pow(static_cast(gesture.mid_point.x - gesture.points[id].x), 2) + - std::pow(static_cast(gesture.mid_point.y - gesture.points[id].y), 2); - gesture.average_distance += - static_cast(distance) / static_cast(gesture.active_points); + const f32 distance = std::sqrt(Square(gesture.mid_point.x - gesture.points[id].x) + + Square(gesture.mid_point.y - gesture.points[id].y)); + gesture.average_distance += distance / static_cast(gesture.active_points); } - gesture.angle = std::atan2(static_cast(gesture.mid_point.y - gesture.points[0].y), - static_cast(gesture.mid_point.x - gesture.points[0].x)); + gesture.angle = std::atan2(static_cast(gesture.mid_point.y - gesture.points[0].y), + static_cast(gesture.mid_point.x - gesture.points[0].x)); gesture.detection_count = last_gesture.detection_count; diff --git a/src/core/hle/service/hid/controllers/gesture.h b/src/core/hle/service/hid/controllers/gesture.h index d3550c3f3..18110a6ad 100755 --- a/src/core/hle/service/hid/controllers/gesture.h +++ b/src/core/hle/service/hid/controllers/gesture.h @@ -1,4 +1,4 @@ -// Copyright 2018 yuzu emulator team +// Copyright 2021 yuzu Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. @@ -7,14 +7,13 @@ #include #include "common/bit_field.h" #include "common/common_types.h" -#include "common/swap.h" #include "core/frontend/input.h" #include "core/hle/service/hid/controllers/controller_base.h" namespace Service::HID { class Controller_Gesture final : public ControllerBase { public: - explicit Controller_Gesture(Core::System& system); + explicit Controller_Gesture(Core::System& system_); ~Controller_Gesture() override; // Called when the controller is initialized @@ -73,7 +72,6 @@ private: struct GestureState { s64_le sampling_number; s64_le sampling_number2; - s64_le detection_count; TouchType type; Direction direction; @@ -84,8 +82,8 @@ private: f32 vel_x; f32 vel_y; Attribute attributes; - u32 scale; - u32 rotation_angle; + f32 scale; + f32 rotation_angle; s32_le point_count; std::array points; }; @@ -109,19 +107,29 @@ private: Points mid_point{}; s64_le detection_count{}; u64_le delta_time{}; - float average_distance{}; - float angle{}; + f32 average_distance{}; + f32 angle{}; }; // Reads input from all available input engines void ReadTouchInput(); // Returns true if gesture state needs to be updated - bool ShouldUpdateGesture(const GestureProperties& gesture, float time_difference); + bool ShouldUpdateGesture(const GestureProperties& gesture, f32 time_difference); // Updates the shared memory to the next state void UpdateGestureSharedMemory(u8* data, std::size_t size, GestureProperties& gesture, - float time_difference); + f32 time_difference); + + // Initializes new gesture + void NewGesture(GestureProperties& gesture, TouchType& type, Attribute& attributes); + + // Updates existing gesture state + void UpdateExistingGesture(GestureProperties& gesture, TouchType& type, f32 time_difference); + + // Terminates exiting gesture + void EndGesture(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type, + Attribute& attributes, f32 time_difference); // Set current event to a tap event void SetTapEvent(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type, @@ -129,11 +137,11 @@ private: // Calculates and set the extra parameters related to a pan event void UpdatePanEvent(GestureProperties& gesture, GestureProperties& last_gesture, - TouchType& type, float time_difference); + TouchType& type, f32 time_difference); // Terminates the pan event void EndPanEvent(GestureProperties& gesture, GestureProperties& last_gesture, TouchType& type, - float time_difference); + f32 time_difference); // Set current event to a swipe event void SetSwipeEvent(GestureProperties& gesture, GestureProperties& last_gesture, @@ -163,7 +171,8 @@ private: GestureProperties last_gesture{}; s64_le last_update_timestamp{}; s64_le last_tap_timestamp{}; - float last_pan_time_difference{}; + f32 last_pan_time_difference{}; bool force_update{false}; + bool enable_press_and_tap{false}; }; } // namespace Service::HID diff --git a/src/core/hle/service/hid/controllers/keyboard.cpp b/src/core/hle/service/hid/controllers/keyboard.cpp index 18b76038f..c6c620008 100755 --- a/src/core/hle/service/hid/controllers/keyboard.cpp +++ b/src/core/hle/service/hid/controllers/keyboard.cpp @@ -12,7 +12,7 @@ namespace Service::HID { constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3800; constexpr u8 KEYS_PER_BYTE = 8; -Controller_Keyboard::Controller_Keyboard(Core::System& system) : ControllerBase(system) {} +Controller_Keyboard::Controller_Keyboard(Core::System& system_) : ControllerBase{system_} {} Controller_Keyboard::~Controller_Keyboard() = default; void Controller_Keyboard::OnInit() {} diff --git a/src/core/hle/service/hid/controllers/keyboard.h b/src/core/hle/service/hid/controllers/keyboard.h index e72948591..172a80e9c 100755 --- a/src/core/hle/service/hid/controllers/keyboard.h +++ b/src/core/hle/service/hid/controllers/keyboard.h @@ -16,7 +16,7 @@ namespace Service::HID { class Controller_Keyboard final : public ControllerBase { public: - explicit Controller_Keyboard(Core::System& system); + explicit Controller_Keyboard(Core::System& system_); ~Controller_Keyboard() override; // Called when the controller is initialized diff --git a/src/core/hle/service/hid/controllers/mouse.cpp b/src/core/hle/service/hid/controllers/mouse.cpp index 2e7457604..544a71948 100755 --- a/src/core/hle/service/hid/controllers/mouse.cpp +++ b/src/core/hle/service/hid/controllers/mouse.cpp @@ -11,7 +11,7 @@ namespace Service::HID { constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3400; -Controller_Mouse::Controller_Mouse(Core::System& system) : ControllerBase(system) {} +Controller_Mouse::Controller_Mouse(Core::System& system_) : ControllerBase{system_} {} Controller_Mouse::~Controller_Mouse() = default; void Controller_Mouse::OnInit() {} diff --git a/src/core/hle/service/hid/controllers/mouse.h b/src/core/hle/service/hid/controllers/mouse.h index 0ec0c2b94..3d391a798 100755 --- a/src/core/hle/service/hid/controllers/mouse.h +++ b/src/core/hle/service/hid/controllers/mouse.h @@ -15,7 +15,7 @@ namespace Service::HID { class Controller_Mouse final : public ControllerBase { public: - explicit Controller_Mouse(Core::System& system); + explicit Controller_Mouse(Core::System& system_); ~Controller_Mouse() override; // Called when the controller is initialized diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 70bd08a44..7acad3798 100755 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -147,7 +147,7 @@ bool Controller_NPad::IsDeviceHandleValid(const DeviceHandle& device_handle) { device_handle.device_index < DeviceIndex::MaxDeviceIndex; } -Controller_NPad::Controller_NPad(Core::System& system) : ControllerBase(system) { +Controller_NPad::Controller_NPad(Core::System& system_) : ControllerBase{system_} { latest_vibration_values.fill({DEFAULT_VIBRATION_VALUE, DEFAULT_VIBRATION_VALUE}); } diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 932d833d1..c050c9a44 100755 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -25,7 +25,7 @@ constexpr u32 NPAD_UNKNOWN = 16; // TODO(ogniK): What is this? class Controller_NPad final : public ControllerBase { public: - explicit Controller_NPad(Core::System& system); + explicit Controller_NPad(Core::System& system_); ~Controller_NPad() override; // Called when the controller is initialized diff --git a/src/core/hle/service/hid/controllers/stubbed.cpp b/src/core/hle/service/hid/controllers/stubbed.cpp index e7483bfa2..772c20453 100755 --- a/src/core/hle/service/hid/controllers/stubbed.cpp +++ b/src/core/hle/service/hid/controllers/stubbed.cpp @@ -9,7 +9,7 @@ namespace Service::HID { -Controller_Stubbed::Controller_Stubbed(Core::System& system) : ControllerBase(system) {} +Controller_Stubbed::Controller_Stubbed(Core::System& system_) : ControllerBase{system_} {} Controller_Stubbed::~Controller_Stubbed() = default; void Controller_Stubbed::OnInit() {} diff --git a/src/core/hle/service/hid/controllers/stubbed.h b/src/core/hle/service/hid/controllers/stubbed.h index 4fa83ac85..21092af0d 100755 --- a/src/core/hle/service/hid/controllers/stubbed.h +++ b/src/core/hle/service/hid/controllers/stubbed.h @@ -10,7 +10,7 @@ namespace Service::HID { class Controller_Stubbed final : public ControllerBase { public: - explicit Controller_Stubbed(Core::System& system); + explicit Controller_Stubbed(Core::System& system_); ~Controller_Stubbed() override; // Called when the controller is initialized diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index 55e3cc014..ac9112c40 100755 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -15,7 +15,7 @@ namespace Service::HID { constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400; -Controller_Touchscreen::Controller_Touchscreen(Core::System& system) : ControllerBase(system) {} +Controller_Touchscreen::Controller_Touchscreen(Core::System& system_) : ControllerBase{system_} {} Controller_Touchscreen::~Controller_Touchscreen() = default; void Controller_Touchscreen::OnInit() { diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index 784124e25..2869d0cfd 100755 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h @@ -14,7 +14,7 @@ namespace Service::HID { class Controller_Touchscreen final : public ControllerBase { public: - explicit Controller_Touchscreen(Core::System& system); + explicit Controller_Touchscreen(Core::System& system_); ~Controller_Touchscreen() override; // Called when the controller is initialized diff --git a/src/core/hle/service/hid/controllers/xpad.cpp b/src/core/hle/service/hid/controllers/xpad.cpp index 2503ef241..41dc22cf9 100755 --- a/src/core/hle/service/hid/controllers/xpad.cpp +++ b/src/core/hle/service/hid/controllers/xpad.cpp @@ -10,7 +10,7 @@ namespace Service::HID { constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C00; -Controller_XPad::Controller_XPad(Core::System& system) : ControllerBase(system) {} +Controller_XPad::Controller_XPad(Core::System& system_) : ControllerBase{system_} {} Controller_XPad::~Controller_XPad() = default; void Controller_XPad::OnInit() {} diff --git a/src/core/hle/service/hid/controllers/xpad.h b/src/core/hle/service/hid/controllers/xpad.h index 5b59961bd..f9ab5facf 100755 --- a/src/core/hle/service/hid/controllers/xpad.h +++ b/src/core/hle/service/hid/controllers/xpad.h @@ -13,7 +13,7 @@ namespace Service::HID { class Controller_XPad final : public ControllerBase { public: - explicit Controller_XPad(Core::System& system); + explicit Controller_XPad(Core::System& system_); ~Controller_XPad() override; // Called when the controller is initialized diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index c91427b8b..94ef3983a 100755 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp @@ -158,8 +158,6 @@ public: }; RegisterHandlers(functions); - auto& kernel = system.Kernel(); - Kernel::KAutoObject::Create(std::addressof(event1)); Kernel::KAutoObject::Create(std::addressof(event2)); diff --git a/src/core/hle/service/ns/pl_u.cpp b/src/core/hle/service/ns/pl_u.cpp index 82d847130..e14acce58 100755 --- a/src/core/hle/service/ns/pl_u.cpp +++ b/src/core/hle/service/ns/pl_u.cpp @@ -258,12 +258,12 @@ void PL_U::GetSharedMemoryNativeHandle(Kernel::HLERequestContext& ctx) { // Create shared font memory object auto& kernel = system.Kernel(); - std::memcpy(system.Kernel().GetFontSharedMem().GetPointer(), impl->shared_font->data(), + std::memcpy(kernel.GetFontSharedMem().GetPointer(), impl->shared_font->data(), impl->shared_font->size()); IPC::ResponseBuilder rb{ctx, 2, 1}; rb.Push(RESULT_SUCCESS); - rb.PushCopyObjects(&system.Kernel().GetFontSharedMem()); + rb.PushCopyObjects(&kernel.GetFontSharedMem()); } void PL_U::GetSharedFontInOrderOfPriority(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp index 5ab7e39b0..bbef04a29 100755 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp @@ -14,8 +14,8 @@ namespace Service::Nvidia::Devices { -nvdisp_disp0::nvdisp_disp0(Core::System& system, std::shared_ptr nvmap_dev) - : nvdevice(system), nvmap_dev(std::move(nvmap_dev)) {} +nvdisp_disp0::nvdisp_disp0(Core::System& system_, std::shared_ptr nvmap_dev_) + : nvdevice{system_}, nvmap_dev{std::move(nvmap_dev_)} {} nvdisp_disp0 ::~nvdisp_disp0() = default; NvResult nvdisp_disp0::Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h index 59c9b6101..de01e1d5f 100755 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h @@ -17,7 +17,7 @@ class nvmap; class nvdisp_disp0 final : public nvdevice { public: - explicit nvdisp_disp0(Core::System& system, std::shared_ptr nvmap_dev); + explicit nvdisp_disp0(Core::System& system_, std::shared_ptr nvmap_dev_); ~nvdisp_disp0() override; NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp index f7b3dc317..7dc41d875 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.cpp @@ -17,8 +17,8 @@ namespace Service::Nvidia::Devices { -nvhost_as_gpu::nvhost_as_gpu(Core::System& system, std::shared_ptr nvmap_dev) - : nvdevice(system), nvmap_dev(std::move(nvmap_dev)) {} +nvhost_as_gpu::nvhost_as_gpu(Core::System& system_, std::shared_ptr nvmap_dev_) + : nvdevice{system_}, nvmap_dev{std::move(nvmap_dev_)} {} nvhost_as_gpu::~nvhost_as_gpu() = default; NvResult nvhost_as_gpu::Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h index d86a9cab6..229bf6350 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_as_gpu.h @@ -30,7 +30,7 @@ DECLARE_ENUM_FLAG_OPERATORS(AddressSpaceFlags); class nvhost_as_gpu final : public nvdevice { public: - explicit nvhost_as_gpu(Core::System& system, std::shared_ptr nvmap_dev); + explicit nvhost_as_gpu(Core::System& system_, std::shared_ptr nvmap_dev_); ~nvhost_as_gpu() override; NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp index f50acbd79..775e76330 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.cpp @@ -15,9 +15,10 @@ namespace Service::Nvidia::Devices { -nvhost_ctrl::nvhost_ctrl(Core::System& system, EventInterface& events_interface, - SyncpointManager& syncpoint_manager) - : nvdevice(system), events_interface{events_interface}, syncpoint_manager{syncpoint_manager} {} +nvhost_ctrl::nvhost_ctrl(Core::System& system_, EventInterface& events_interface_, + SyncpointManager& syncpoint_manager_) + : nvdevice{system_}, events_interface{events_interface_}, syncpoint_manager{ + syncpoint_manager_} {} nvhost_ctrl::~nvhost_ctrl() = default; NvResult nvhost_ctrl::Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h index 9178789c3..cdf03887d 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl.h @@ -14,8 +14,8 @@ namespace Service::Nvidia::Devices { class nvhost_ctrl final : public nvdevice { public: - explicit nvhost_ctrl(Core::System& system, EventInterface& events_interface, - SyncpointManager& syncpoint_manager); + explicit nvhost_ctrl(Core::System& system_, EventInterface& events_interface_, + SyncpointManager& syncpoint_manager_); ~nvhost_ctrl() override; NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp index 2edd803f3..d8b684f4f 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.cpp @@ -12,7 +12,7 @@ namespace Service::Nvidia::Devices { -nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system) : nvdevice(system) {} +nvhost_ctrl_gpu::nvhost_ctrl_gpu(Core::System& system_) : nvdevice{system_} {} nvhost_ctrl_gpu::~nvhost_ctrl_gpu() = default; NvResult nvhost_ctrl_gpu::Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h index f98aa841a..898d00a17 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h @@ -13,7 +13,7 @@ namespace Service::Nvidia::Devices { class nvhost_ctrl_gpu final : public nvdevice { public: - explicit nvhost_ctrl_gpu(Core::System& system); + explicit nvhost_ctrl_gpu(Core::System& system_); ~nvhost_ctrl_gpu() override; NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index e83aaa798..c0a380088 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp @@ -14,11 +14,11 @@ namespace Service::Nvidia::Devices { -nvhost_gpu::nvhost_gpu(Core::System& system, std::shared_ptr nvmap_dev, - SyncpointManager& syncpoint_manager) - : nvdevice(system), nvmap_dev(std::move(nvmap_dev)), syncpoint_manager{syncpoint_manager} { - channel_fence.id = syncpoint_manager.AllocateSyncpoint(); - channel_fence.value = system.GPU().GetSyncpointValue(channel_fence.id); +nvhost_gpu::nvhost_gpu(Core::System& system_, std::shared_ptr nvmap_dev_, + SyncpointManager& syncpoint_manager_) + : nvdevice{system_}, nvmap_dev{std::move(nvmap_dev_)}, syncpoint_manager{syncpoint_manager_} { + channel_fence.id = syncpoint_manager_.AllocateSyncpoint(); + channel_fence.value = system_.GPU().GetSyncpointValue(channel_fence.id); } nvhost_gpu::~nvhost_gpu() = default; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h index 12a1a1133..f27a82bff 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.h @@ -22,8 +22,8 @@ namespace Service::Nvidia::Devices { class nvmap; class nvhost_gpu final : public nvdevice { public: - explicit nvhost_gpu(Core::System& system, std::shared_ptr nvmap_dev, - SyncpointManager& syncpoint_manager); + explicit nvhost_gpu(Core::System& system_, std::shared_ptr nvmap_dev_, + SyncpointManager& syncpoint_manager_); ~nvhost_gpu() override; NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index aa51d44c5..4f42fffcb 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp @@ -11,9 +11,9 @@ namespace Service::Nvidia::Devices { -nvhost_nvdec::nvhost_nvdec(Core::System& system, std::shared_ptr nvmap_dev, - SyncpointManager& syncpoint_manager) - : nvhost_nvdec_common(system, std::move(nvmap_dev), syncpoint_manager) {} +nvhost_nvdec::nvhost_nvdec(Core::System& system_, std::shared_ptr nvmap_dev_, + SyncpointManager& syncpoint_manager_) + : nvhost_nvdec_common{system_, std::move(nvmap_dev_), syncpoint_manager_} {} nvhost_nvdec::~nvhost_nvdec() = default; NvResult nvhost_nvdec::Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h index 6c38a8c24..523d96e3a 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.h @@ -11,8 +11,8 @@ namespace Service::Nvidia::Devices { class nvhost_nvdec final : public nvhost_nvdec_common { public: - explicit nvhost_nvdec(Core::System& system, std::shared_ptr nvmap_dev, - SyncpointManager& syncpoint_manager); + explicit nvhost_nvdec(Core::System& system_, std::shared_ptr nvmap_dev_, + SyncpointManager& syncpoint_manager_); ~nvhost_nvdec() override; NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp index 6654aa66d..1375689e7 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.cpp @@ -42,9 +42,9 @@ std::size_t WriteVectors(std::vector& dst, const std::vector& src, std::s } } // Anonymous namespace -nvhost_nvdec_common::nvhost_nvdec_common(Core::System& system, std::shared_ptr nvmap_dev, - SyncpointManager& syncpoint_manager) - : nvdevice(system), nvmap_dev(std::move(nvmap_dev)), syncpoint_manager(syncpoint_manager) {} +nvhost_nvdec_common::nvhost_nvdec_common(Core::System& system_, std::shared_ptr nvmap_dev_, + SyncpointManager& syncpoint_manager_) + : nvdevice{system_}, nvmap_dev{std::move(nvmap_dev_)}, syncpoint_manager{syncpoint_manager_} {} nvhost_nvdec_common::~nvhost_nvdec_common() = default; NvResult nvhost_nvdec_common::SetNVMAPfd(const std::vector& input) { diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h index 2e0aece2f..35c11a7ba 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec_common.h @@ -18,8 +18,8 @@ class nvmap; class nvhost_nvdec_common : public nvdevice { public: - explicit nvhost_nvdec_common(Core::System& system, std::shared_ptr nvmap_dev, - SyncpointManager& syncpoint_manager); + explicit nvhost_nvdec_common(Core::System& system_, std::shared_ptr nvmap_dev_, + SyncpointManager& syncpoint_manager_); ~nvhost_nvdec_common() override; protected: diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp index 0a9c35c01..c2be3cea7 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.cpp @@ -10,7 +10,7 @@ namespace Service::Nvidia::Devices { -nvhost_nvjpg::nvhost_nvjpg(Core::System& system) : nvdevice(system) {} +nvhost_nvjpg::nvhost_nvjpg(Core::System& system_) : nvdevice{system_} {} nvhost_nvjpg::~nvhost_nvjpg() = default; NvResult nvhost_nvjpg::Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h index 1f97b642f..6045e5cbd 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvjpg.h @@ -13,7 +13,7 @@ namespace Service::Nvidia::Devices { class nvhost_nvjpg final : public nvdevice { public: - explicit nvhost_nvjpg(Core::System& system); + explicit nvhost_nvjpg(Core::System& system_); ~nvhost_nvjpg() override; NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp index 8e712c451..64aa7b06f 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.cpp @@ -10,9 +10,9 @@ #include "video_core/renderer_base.h" namespace Service::Nvidia::Devices { -nvhost_vic::nvhost_vic(Core::System& system, std::shared_ptr nvmap_dev, - SyncpointManager& syncpoint_manager) - : nvhost_nvdec_common(system, std::move(nvmap_dev), syncpoint_manager) { +nvhost_vic::nvhost_vic(Core::System& system_, std::shared_ptr nvmap_dev_, + SyncpointManager& syncpoint_manager_) + : nvhost_nvdec_common(system_, std::move(nvmap_dev_), syncpoint_manager_) { vic_device = true; } nvhost_vic::~nvhost_vic() = default; diff --git a/src/core/hle/service/nvdrv/devices/nvhost_vic.h b/src/core/hle/service/nvdrv/devices/nvhost_vic.h index cebefad71..6d7fda9d1 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_vic.h +++ b/src/core/hle/service/nvdrv/devices/nvhost_vic.h @@ -10,8 +10,8 @@ namespace Service::Nvidia::Devices { class nvhost_vic final : public nvhost_nvdec_common { public: - explicit nvhost_vic(Core::System& system, std::shared_ptr nvmap_dev, - SyncpointManager& syncpoint_manager); + explicit nvhost_vic(Core::System& system_, std::shared_ptr nvmap_dev_, + SyncpointManager& syncpoint_manager_); ~nvhost_vic(); NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/devices/nvmap.cpp b/src/core/hle/service/nvdrv/devices/nvmap.cpp index dd1355522..dc59b4494 100755 --- a/src/core/hle/service/nvdrv/devices/nvmap.cpp +++ b/src/core/hle/service/nvdrv/devices/nvmap.cpp @@ -11,7 +11,7 @@ namespace Service::Nvidia::Devices { -nvmap::nvmap(Core::System& system) : nvdevice(system) { +nvmap::nvmap(Core::System& system_) : nvdevice{system_} { // Handle 0 appears to be used when remapping, so we create a placeholder empty nvmap object to // represent this. CreateObject(0); diff --git a/src/core/hle/service/nvdrv/devices/nvmap.h b/src/core/hle/service/nvdrv/devices/nvmap.h index 208875845..d90b69e5a 100755 --- a/src/core/hle/service/nvdrv/devices/nvmap.h +++ b/src/core/hle/service/nvdrv/devices/nvmap.h @@ -16,7 +16,7 @@ namespace Service::Nvidia::Devices { class nvmap final : public nvdevice { public: - explicit nvmap(Core::System& system); + explicit nvmap(Core::System& system_); ~nvmap() override; NvResult Ioctl1(DeviceFD fd, Ioctl command, const std::vector& input, diff --git a/src/core/hle/service/nvdrv/interface.cpp b/src/core/hle/service/nvdrv/interface.cpp index 4c4cc182e..613d2f149 100755 --- a/src/core/hle/service/nvdrv/interface.cpp +++ b/src/core/hle/service/nvdrv/interface.cpp @@ -22,19 +22,30 @@ void NVDRV::SignalGPUInterruptSyncpt(const u32 syncpoint_id, const u32 value) { void NVDRV::Open(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_NVDRV, "called"); + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(RESULT_SUCCESS); if (!is_initialized) { - ServiceError(ctx, NvResult::NotInitialized); + rb.Push(0); + rb.PushEnum(NvResult::NotInitialized); + LOG_ERROR(Service_NVDRV, "NvServices is not initalized!"); return; } const auto& buffer = ctx.ReadBuffer(); const std::string device_name(buffer.begin(), buffer.end()); + + if (device_name == "/dev/nvhost-prof-gpu") { + rb.Push(0); + rb.PushEnum(NvResult::NotSupported); + + LOG_WARNING(Service_NVDRV, "/dev/nvhost-prof-gpu cannot be openned on production"); + return; + } + DeviceFD fd = nvdrv->Open(device_name); - IPC::ResponseBuilder rb{ctx, 4}; - rb.Push(RESULT_SUCCESS); rb.Push(fd); rb.PushEnum(fd != INVALID_NVDRV_FD ? NvResult::Success : NvResult::FileOperationFailed); } diff --git a/src/core/hle/service/pctl/module.cpp b/src/core/hle/service/pctl/module.cpp index 092bba4f5..55898f3dc 100755 --- a/src/core/hle/service/pctl/module.cpp +++ b/src/core/hle/service/pctl/module.cpp @@ -24,9 +24,8 @@ constexpr ResultCode ResultNoRestrictionEnabled{ErrorModule::PCTL, 181}; class IParentalControlService final : public ServiceFramework { public: - explicit IParentalControlService(Core::System& system_, Capability capability) - : ServiceFramework{system_, "IParentalControlService"}, system(system_), - capability(capability) { + explicit IParentalControlService(Core::System& system_, Capability capability_) + : ServiceFramework{system_, "IParentalControlService"}, capability{capability_} { // clang-format off static const FunctionInfo functions[] = { {1, &IParentalControlService::Initialize, "Initialize"}, @@ -363,7 +362,6 @@ private: ParentalControlSettings settings{}; std::array pin_code{}; bool can_use_stereo_vision = true; - Core::System& system; Capability capability{}; }; @@ -386,8 +384,8 @@ void Module::Interface::CreateServiceWithoutInitialize(Kernel::HLERequestContext } Module::Interface::Interface(Core::System& system_, std::shared_ptr module_, - const char* name, Capability capability) - : ServiceFramework{system_, name}, module{std::move(module_)}, capability(capability) {} + const char* name_, Capability capability_) + : ServiceFramework{system_, name_}, module{std::move(module_)}, capability{capability_} {} Module::Interface::~Interface() = default; diff --git a/src/core/hle/service/pctl/module.h b/src/core/hle/service/pctl/module.h index 032481b00..f25c5c557 100755 --- a/src/core/hle/service/pctl/module.h +++ b/src/core/hle/service/pctl/module.h @@ -28,8 +28,8 @@ class Module final { public: class Interface : public ServiceFramework { public: - explicit Interface(Core::System& system_, std::shared_ptr module_, const char* name, - Capability capability); + explicit Interface(Core::System& system_, std::shared_ptr module_, + const char* name_, Capability capability_); ~Interface() override; void CreateService(Kernel::HLERequestContext& ctx); diff --git a/src/core/hle/service/time/interface.cpp b/src/core/hle/service/time/interface.cpp index a01d9e0ff..53a204796 100755 --- a/src/core/hle/service/time/interface.cpp +++ b/src/core/hle/service/time/interface.cpp @@ -6,8 +6,8 @@ namespace Service::Time { -Time::Time(std::shared_ptr module, Core::System& system, const char* name) - : Interface(std::move(module), system, name) { +Time::Time(std::shared_ptr module_, Core::System& system_, const char* name_) + : Interface{std::move(module_), system_, name_} { // clang-format off static const FunctionInfo functions[] = { {0, &Time::GetStandardUserSystemClock, "GetStandardUserSystemClock"}, diff --git a/src/core/hle/service/time/interface.h b/src/core/hle/service/time/interface.h index 4f49e1f07..c41766f1a 100755 --- a/src/core/hle/service/time/interface.h +++ b/src/core/hle/service/time/interface.h @@ -14,7 +14,7 @@ namespace Service::Time { class Time final : public Module::Interface { public: - explicit Time(std::shared_ptr time, Core::System& system, const char* name); + explicit Time(std::shared_ptr time, Core::System& system_, const char* name_); ~Time() override; }; diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index a0ed7a98f..42f023258 100755 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp @@ -79,8 +79,8 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory( : AppLoader(directory->GetFile("main")), dir(std::move(directory)), override_update(override_update) {} -FileType AppLoader_DeconstructedRomDirectory::IdentifyType(const FileSys::VirtualFile& file) { - if (FileSys::IsDirectoryExeFS(file->GetContainingDirectory())) { +FileType AppLoader_DeconstructedRomDirectory::IdentifyType(const FileSys::VirtualFile& dir_file) { + if (FileSys::IsDirectoryExeFS(dir_file->GetContainingDirectory())) { return FileType::DeconstructedRomDirectory; } diff --git a/src/core/loader/deconstructed_rom_directory.h b/src/core/loader/deconstructed_rom_directory.h index 12e646f39..a49a8b001 100755 --- a/src/core/loader/deconstructed_rom_directory.h +++ b/src/core/loader/deconstructed_rom_directory.h @@ -31,11 +31,14 @@ public: bool override_update = false); /** - * Returns the type of the file - * @param file open file - * @return FileType found, or FileType::Error if this loader doesn't know it + * Identifies whether or not the given file is a deconstructed ROM directory. + * + * @param dir_file The file to verify. + * + * @return FileType::DeconstructedRomDirectory, or FileType::Error + * if the file is not a deconstructed ROM directory. */ - static FileType IdentifyType(const FileSys::VirtualFile& file); + static FileType IdentifyType(const FileSys::VirtualFile& dir_file); FileType GetFileType() const override { return IdentifyType(file); diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp index b14817f02..0f5ef7954 100755 --- a/src/core/memory/cheat_engine.cpp +++ b/src/core/memory/cheat_engine.cpp @@ -222,8 +222,8 @@ void CheatEngine::SetMainMemoryParameters(VAddr main_region_begin, u64 main_regi }; } -void CheatEngine::Reload(std::vector cheats) { - this->cheats = std::move(cheats); +void CheatEngine::Reload(std::vector reload_cheats) { + cheats = std::move(reload_cheats); is_pending_reload.exchange(true); } diff --git a/src/core/memory/cheat_engine.h b/src/core/memory/cheat_engine.h index a31002346..5e6f901ec 100755 --- a/src/core/memory/cheat_engine.h +++ b/src/core/memory/cheat_engine.h @@ -68,7 +68,7 @@ public: void Initialize(); void SetMainMemoryParameters(VAddr main_region_begin, u64 main_region_size); - void Reload(std::vector cheats); + void Reload(std::vector reload_cheats); private: void FrameCallback(std::uintptr_t user_data, std::chrono::nanoseconds ns_late); diff --git a/src/core/tools/freezer.cpp b/src/core/tools/freezer.cpp index 5c674a099..2e09faa6d 100755 --- a/src/core/tools/freezer.cpp +++ b/src/core/tools/freezer.cpp @@ -67,8 +67,8 @@ Freezer::~Freezer() { core_timing.UnscheduleEvent(event, 0); } -void Freezer::SetActive(bool active) { - if (!this->active.exchange(active)) { +void Freezer::SetActive(bool is_active) { + if (!active.exchange(is_active)) { FillEntryReads(); core_timing.ScheduleEvent(memory_freezer_ns, event); LOG_DEBUG(Common_Memory, "Memory freezer activated!"); diff --git a/src/core/tools/freezer.h b/src/core/tools/freezer.h index 0fdb701a7..067134e93 100755 --- a/src/core/tools/freezer.h +++ b/src/core/tools/freezer.h @@ -43,7 +43,7 @@ public: ~Freezer(); // Enables or disables the entire memory freezer. - void SetActive(bool active); + void SetActive(bool is_active); // Returns whether or not the freezer is active. bool IsActive() const;