From a2cc6a56808ad482294eafa3073d540973757df5 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Thu, 7 Apr 2022 04:37:48 +0200 Subject: [PATCH] early-access version 2652 --- README.md | 2 +- src/common/logging/filter.cpp | 1 + src/common/logging/types.h | 1 + src/common/settings.h | 3 - src/common/settings_input.h | 1 - src/core/CMakeLists.txt | 12 +--- src/core/hid/emulated_controller.cpp | 8 --- src/core/hid/emulated_controller.h | 3 - src/core/hid/emulated_devices.cpp | 45 ------------- src/core/hid/emulated_devices.h | 34 ---------- src/core/hid/hid_core.cpp | 13 ---- src/core/hid/hid_core.h | 3 - src/core/hle/kernel/hle_ipc.cpp | 5 +- src/core/hle/kernel/k_auto_object.h | 5 +- src/core/hle/kernel/k_server_port.cpp | 6 ++ src/core/hle/kernel/k_server_session.cpp | 3 + src/core/hle/kernel/kernel.cpp | 63 +++++++++---------- src/core/hle/kernel/kernel.h | 14 +++-- src/core/hle/service/am/am.cpp | 9 ++- src/core/hle/service/am/am.h | 1 + src/core/hle/service/hid/hid.cpp | 27 +++++++- src/core/hle/service/jit/jit.cpp | 53 ++++++++++++++++ src/core/hle/service/jit/jit.h | 20 ++++++ src/core/hle/service/service.cpp | 2 + src/core/hle/service/sm/sm.cpp | 8 +-- src/core/hle/service/sm/sm.h | 2 - src/yuzu/CMakeLists.txt | 3 - src/yuzu/configuration/config.cpp | 34 ---------- src/yuzu/configuration/config.h | 3 - src/yuzu/configuration/configure_input.cpp | 5 -- .../configure_input_advanced.cpp | 9 +-- .../configuration/configure_input_advanced.h | 1 - .../configuration/configure_input_advanced.ui | 14 ----- .../configuration/configure_input_player.cpp | 2 +- src/yuzu/main.cpp | 3 +- 35 files changed, 173 insertions(+), 245 deletions(-) create mode 100755 src/core/hle/service/jit/jit.cpp create mode 100755 src/core/hle/service/jit/jit.h diff --git a/README.md b/README.md index 645cd6b6a..b8a164819 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2651. +This is the source code for early-access 2652. ## Legal Notice diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 9120cc178..4acbff649 100755 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp @@ -101,6 +101,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { SUB(Service, GRC) \ SUB(Service, HID) \ SUB(Service, IRS) \ + SUB(Service, JIT) \ SUB(Service, LBL) \ SUB(Service, LDN) \ SUB(Service, LDR) \ diff --git a/src/common/logging/types.h b/src/common/logging/types.h index f803ab796..99c15fa96 100755 --- a/src/common/logging/types.h +++ b/src/common/logging/types.h @@ -69,6 +69,7 @@ enum class Class : u8 { Service_GRC, ///< The game recording service Service_HID, ///< The HID (Human interface device) service Service_IRS, ///< The IRS service + Service_JIT, ///< The JIT service Service_LBL, ///< The LBL (LCD backlight) service Service_LDN, ///< The LDN (Local domain network) service Service_LDR, ///< The loader service diff --git a/src/common/settings.h b/src/common/settings.h index 3b7be63b3..86e0fa140 100755 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -590,9 +590,6 @@ struct Values { BasicSetting touch_from_button_map_index{0, "touch_from_button_map"}; std::vector touch_from_button_maps; - BasicSetting enable_ring_controller{true, "enable_ring_controller"}; - RingconRaw ringcon_analogs; - // Data Storage BasicSetting use_virtual_sd{true, "use_virtual_sd"}; BasicSetting gamecard_inserted{false, "gamecard_inserted"}; diff --git a/src/common/settings_input.h b/src/common/settings_input.h index 6f42346bc..4ff37e186 100755 --- a/src/common/settings_input.h +++ b/src/common/settings_input.h @@ -357,7 +357,6 @@ constexpr int NUM_KEYBOARD_MODS_HID = NumKeyboardMods; using AnalogsRaw = std::array; using ButtonsRaw = std::array; using MotionsRaw = std::array; -using RingconRaw = std::string; constexpr u32 JOYCON_BODY_NEON_RED = 0xFF3C28; constexpr u32 JOYCON_BUTTONS_NEON_RED = 0x1E0A0A; diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 6fc10637c..81eaf0942 100755 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -432,8 +432,6 @@ add_library(core STATIC hle/service/grc/grc.h hle/service/hid/hid.cpp hle/service/hid/hid.h - hle/service/hid/hidbus.cpp - hle/service/hid/hidbus.h hle/service/hid/irs.cpp hle/service/hid/irs.h hle/service/hid/ring_lifo.h @@ -460,14 +458,8 @@ add_library(core STATIC hle/service/hid/controllers/touchscreen.h hle/service/hid/controllers/xpad.cpp hle/service/hid/controllers/xpad.h - hle/service/hid/hidbus/hidbus_base.cpp - hle/service/hid/hidbus/hidbus_base.h - hle/service/hid/hidbus/ringcon.cpp - hle/service/hid/hidbus/ringcon.h - hle/service/hid/hidbus/starlink.cpp - hle/service/hid/hidbus/starlink.h - hle/service/hid/hidbus/stubbed.cpp - hle/service/hid/hidbus/stubbed.h + hle/service/jit/jit.cpp + hle/service/jit/jit.h hle/service/lbl/lbl.cpp hle/service/lbl/lbl.h hle/service/ldn/errors.h diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 205648bd3..7e05666d6 100755 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp @@ -1207,12 +1207,4 @@ void EmulatedController::DeleteCallback(int key) { } callback_list.erase(iterator); } - -void EmulatedController::RemoveServiceCallbacks() { - std::lock_guard lock{mutex}; - const auto count = std::erase_if( - callback_list, [](const auto& callback) { return callback.second.is_npad_service; }); - LOG_DEBUG(Input, "Elements deleted {}", count); -} - } // namespace Core::HID diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h index 193be04f3..aa52f9572 100755 --- a/src/core/hid/emulated_controller.h +++ b/src/core/hid/emulated_controller.h @@ -335,9 +335,6 @@ public: */ void DeleteCallback(int key); - /// Removes all callbacks created from npad services - void RemoveServiceCallbacks(); - private: /// creates input devices from params void LoadDevices(); diff --git a/src/core/hid/emulated_devices.cpp b/src/core/hid/emulated_devices.cpp index 6de447361..708480f2d 100755 --- a/src/core/hid/emulated_devices.cpp +++ b/src/core/hid/emulated_devices.cpp @@ -15,7 +15,6 @@ EmulatedDevices::EmulatedDevices() = default; EmulatedDevices::~EmulatedDevices() = default; void EmulatedDevices::ReloadFromSettings() { - ring_params = Common::ParamPackage(Settings::values.ringcon_analogs); ReloadInput(); } @@ -67,8 +66,6 @@ void EmulatedDevices::ReloadInput() { key_index++; } - ring_analog_device = Common::Input::CreateDevice(ring_params); - for (std::size_t index = 0; index < mouse_button_devices.size(); ++index) { if (!mouse_button_devices[index]) { continue; @@ -123,13 +120,6 @@ void EmulatedDevices::ReloadInput() { }, }); } - - if (ring_analog_device) { - ring_analog_device->SetCallback({ - .on_change = - [this](const Common::Input::CallbackStatus& callback) { SetRingAnalog(callback); }, - }); - } } void EmulatedDevices::UnloadInput() { @@ -165,7 +155,6 @@ void EmulatedDevices::SaveCurrentConfig() { if (!is_configuring) { return; } - Settings::values.ringcon_analogs = ring_params.Serialize(); } void EmulatedDevices::RestoreConfig() { @@ -175,15 +164,6 @@ void EmulatedDevices::RestoreConfig() { ReloadFromSettings(); } -Common::ParamPackage EmulatedDevices::GetRingParam() const { - return ring_params; -} - -void EmulatedDevices::SetRingParam(Common::ParamPackage param) { - ring_params = std::move(param); - ReloadInput(); -} - void EmulatedDevices::SetKeyboardButton(const Common::Input::CallbackStatus& callback, std::size_t index) { if (index >= device_status.keyboard_values.size()) { @@ -420,23 +400,6 @@ void EmulatedDevices::SetMouseStick(const Common::Input::CallbackStatus& callbac TriggerOnChange(DeviceTriggerType::Mouse); } -void EmulatedDevices::SetRingAnalog(const Common::Input::CallbackStatus& callback) { - std::lock_guard lock{mutex}; - const auto force_value = TransformToStick(callback); - - device_status.ring_analog_value = force_value.x; - - if (is_configuring) { - device_status.ring_analog_value = {}; - TriggerOnChange(DeviceTriggerType::RingController); - return; - } - - device_status.ring_analog_state.force = force_value.x.value; - - TriggerOnChange(DeviceTriggerType::RingController); -} - KeyboardValues EmulatedDevices::GetKeyboardValues() const { return device_status.keyboard_values; } @@ -449,10 +412,6 @@ MouseButtonValues EmulatedDevices::GetMouseButtonsValues() const { return device_status.mouse_button_values; } -RingAnalogValue EmulatedDevices::GetRingSensorValues() const { - return device_status.ring_analog_value; -} - KeyboardKey EmulatedDevices::GetKeyboard() const { return device_status.keyboard_state; } @@ -473,10 +432,6 @@ AnalogStickState EmulatedDevices::GetMouseWheel() const { return device_status.mouse_wheel_state; } -RingSensorForce EmulatedDevices::GetRingSensorForce() const { - return device_status.ring_analog_state; -} - void EmulatedDevices::TriggerOnChange(DeviceTriggerType type) { for (const auto& poller_pair : callback_list) { const InterfaceUpdateCallback& poller = poller_pair.second; diff --git a/src/core/hid/emulated_devices.h b/src/core/hid/emulated_devices.h index 9f739028d..790d3b411 100755 --- a/src/core/hid/emulated_devices.h +++ b/src/core/hid/emulated_devices.h @@ -26,11 +26,9 @@ using MouseButtonDevices = std::array, Settings::NativeMouseWheel::NumMouseWheels>; using MouseStickDevice = std::unique_ptr; -using RingAnalogDevice = std::unique_ptr; using MouseButtonParams = std::array; -using RingAnalogParams = Common::ParamPackage; using KeyboardValues = std::array; @@ -41,17 +39,12 @@ using MouseButtonValues = using MouseAnalogValues = std::array; using MouseStickValue = Common::Input::TouchStatus; -using RingAnalogValue = Common::Input::AnalogStatus; struct MousePosition { f32 x; f32 y; }; -struct RingSensorForce { - f32 force; -}; - struct DeviceStatus { // Data from input_common KeyboardValues keyboard_values{}; @@ -59,7 +52,6 @@ struct DeviceStatus { MouseButtonValues mouse_button_values{}; MouseAnalogValues mouse_analog_values{}; MouseStickValue mouse_stick_value{}; - RingAnalogValue ring_analog_value{}; // Data for HID serices KeyboardKey keyboard_state{}; @@ -67,14 +59,12 @@ struct DeviceStatus { MouseButton mouse_button_state{}; MousePosition mouse_position_state{}; AnalogStickState mouse_wheel_state{}; - RingSensorForce ring_analog_state{}; }; enum class DeviceTriggerType { Keyboard, KeyboardModdifier, Mouse, - RingController, }; struct InterfaceUpdateCallback { @@ -120,15 +110,6 @@ public: /// Reverts any mapped changes made that weren't saved void RestoreConfig(); - // Returns the current mapped ring device - Common::ParamPackage GetRingParam() const; - - /** - * Updates the current mapped ring device - * @param param ParamPackage with ring sensor data to be mapped - */ - void SetRingParam(Common::ParamPackage param); - /// Returns the latest status of button input from the keyboard with parameters KeyboardValues GetKeyboardValues() const; @@ -138,9 +119,6 @@ public: /// Returns the latest status of button input from the mouse with parameters MouseButtonValues GetMouseButtonsValues() const; - /// Returns the latest status of analog input from the ring sensor with parameters - RingAnalogValue GetRingSensorValues() const; - /// Returns the latest status of button input from the keyboard KeyboardKey GetKeyboard() const; @@ -156,9 +134,6 @@ public: /// Returns the latest mouse wheel change AnalogStickState GetMouseWheel() const; - /// Returns the latest ringcon force sensor value - RingSensorForce GetRingSensorForce() const; - /** * Adds a callback to the list of events * @param update_callback InterfaceUpdateCallback that will be triggered @@ -210,12 +185,6 @@ private: */ void SetMouseStick(const Common::Input::CallbackStatus& callback); - /** - * Updates the ring analog sensor status of the ring controller - * @param callback A CallbackStatus containing the force status - */ - void SetRingAnalog(const Common::Input::CallbackStatus& callback); - /** * Triggers a callback that something has changed on the device status * @param type Input type of the event to trigger @@ -224,14 +193,11 @@ private: bool is_configuring{false}; - RingAnalogParams ring_params; - KeyboardDevices keyboard_devices; KeyboardModifierDevices keyboard_modifier_devices; MouseButtonDevices mouse_button_devices; MouseAnalogDevices mouse_analog_devices; MouseStickDevice mouse_stick_device; - RingAnalogDevice ring_analog_device; mutable std::mutex mutex; std::unordered_map callback_list; diff --git a/src/core/hid/hid_core.cpp b/src/core/hid/hid_core.cpp index fe9d7d3f4..a1c3bbb57 100755 --- a/src/core/hid/hid_core.cpp +++ b/src/core/hid/hid_core.cpp @@ -211,17 +211,4 @@ void HIDCore::UnloadInputDevices() { devices->UnloadInput(); } -void HIDCore::RemoveServiceCallbacks() { - player_1->RemoveServiceCallbacks(); - player_2->RemoveServiceCallbacks(); - player_3->RemoveServiceCallbacks(); - player_4->RemoveServiceCallbacks(); - player_5->RemoveServiceCallbacks(); - player_6->RemoveServiceCallbacks(); - player_7->RemoveServiceCallbacks(); - player_8->RemoveServiceCallbacks(); - other->RemoveServiceCallbacks(); - handheld->RemoveServiceCallbacks(); -} - } // namespace Core::HID diff --git a/src/core/hid/hid_core.h b/src/core/hid/hid_core.h index 02f423c2c..717f605e7 100755 --- a/src/core/hid/hid_core.h +++ b/src/core/hid/hid_core.h @@ -61,9 +61,6 @@ public: /// Removes all callbacks from input common void UnloadInputDevices(); - /// Removes all callbacks from npad services - void RemoveServiceCallbacks(); - /// Number of emulated controllers static constexpr std::size_t available_controllers{10}; diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index b547a3463..5828ac923 100755 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -51,7 +51,7 @@ bool SessionRequestManager::HasSessionRequestHandler(const HLERequestContext& co LOG_CRITICAL(IPC, "object_id {} is too big!", object_id); return false; } - return DomainHandler(object_id - 1).lock() != nullptr; + return !DomainHandler(object_id - 1).expired(); } else { return session_handler != nullptr; } @@ -59,6 +59,9 @@ bool SessionRequestManager::HasSessionRequestHandler(const HLERequestContext& co void SessionRequestHandler::ClientConnected(KServerSession* session) { session->ClientConnected(shared_from_this()); + + // Ensure our server session is tracked globally. + kernel.RegisterServerObject(session); } void SessionRequestHandler::ClientDisconnected(KServerSession* session) { diff --git a/src/core/hle/kernel/k_auto_object.h b/src/core/hle/kernel/k_auto_object.h index abdb8ae7c..423e8d8f5 100755 --- a/src/core/hle/kernel/k_auto_object.h +++ b/src/core/hle/kernel/k_auto_object.h @@ -89,9 +89,7 @@ public: explicit KAutoObject(KernelCore& kernel_) : kernel(kernel_) { RegisterWithKernel(); } - virtual ~KAutoObject() { - UnregisterWithKernel(); - } + virtual ~KAutoObject() = default; static KAutoObject* Create(KAutoObject* ptr); @@ -168,6 +166,7 @@ public: // If ref count hits zero, destroy the object. if (cur_ref_count - 1 == 0) { this->Destroy(); + this->UnregisterWithKernel(); } } diff --git a/src/core/hle/kernel/k_server_port.cpp b/src/core/hle/kernel/k_server_port.cpp index 433fc98e1..e66c0c992 100755 --- a/src/core/hle/kernel/k_server_port.cpp +++ b/src/core/hle/kernel/k_server_port.cpp @@ -62,6 +62,12 @@ void KServerPort::Destroy() { // Close our reference to our parent. parent->Close(); + + // Release host emulation members. + session_handler.reset(); + + // Ensure that the global list tracking server objects does not hold on to a reference. + kernel.UnregisterServerObject(this); } bool KServerPort::IsSignaled() const { diff --git a/src/core/hle/kernel/k_server_session.cpp b/src/core/hle/kernel/k_server_session.cpp index 30c56ff29..7ac2ef254 100755 --- a/src/core/hle/kernel/k_server_session.cpp +++ b/src/core/hle/kernel/k_server_session.cpp @@ -49,6 +49,9 @@ void KServerSession::Destroy() { // Release host emulation members. manager.reset(); + + // Ensure that the global list tracking server objects does not hold on to a reference. + kernel.UnregisterServerObject(this); } void KServerSession::OnClientClosed() { diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index a58cd71a6..fc4b65b6b 100755 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -96,15 +96,15 @@ struct KernelCore::Impl { process_list.clear(); - // Close all open server ports. - std::unordered_set server_ports_; + // Close all open server sessions and ports. + std::unordered_set server_objects_; { - std::lock_guard lk(server_ports_lock); - server_ports_ = server_ports; - server_ports.clear(); + std::lock_guard lk(server_objects_lock); + server_objects_ = server_objects; + server_objects.clear(); } - for (auto* server_port : server_ports_) { - server_port->Close(); + for (auto* server_object : server_objects_) { + server_object->Close(); } // Ensures all service threads gracefully shutdown. @@ -140,7 +140,6 @@ struct KernelCore::Impl { CleanupObject(font_shared_mem); CleanupObject(irs_shared_mem); CleanupObject(time_shared_mem); - CleanupObject(hidbus_shared_mem); CleanupObject(system_resource_limit); for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { @@ -181,8 +180,8 @@ struct KernelCore::Impl { { std::lock_guard lk(registered_objects_lock); if (registered_objects.size()) { - LOG_DEBUG(Kernel, "{} kernel objects were dangling on shutdown!", - registered_objects.size()); + LOG_CRITICAL(Kernel, "{} kernel objects were dangling on shutdown!", + registered_objects.size()); registered_objects.clear(); } } @@ -623,20 +622,16 @@ struct KernelCore::Impl { constexpr std::size_t font_size{0x1100000}; constexpr std::size_t irs_size{0x8000}; constexpr std::size_t time_size{0x1000}; - constexpr std::size_t hidbus_size{0x1000}; const PAddr hid_phys_addr{system_pool.GetAddress()}; const PAddr font_phys_addr{system_pool.GetAddress() + hid_size}; const PAddr irs_phys_addr{system_pool.GetAddress() + hid_size + font_size}; const PAddr time_phys_addr{system_pool.GetAddress() + hid_size + font_size + irs_size}; - const PAddr hidbus_phys_addr{system_pool.GetAddress() + hid_size + font_size + irs_size + - time_size}; hid_shared_mem = KSharedMemory::Create(system.Kernel()); font_shared_mem = KSharedMemory::Create(system.Kernel()); irs_shared_mem = KSharedMemory::Create(system.Kernel()); time_shared_mem = KSharedMemory::Create(system.Kernel()); - hidbus_shared_mem = KSharedMemory::Create(system.Kernel()); hid_shared_mem->Initialize(system.DeviceMemory(), nullptr, {hid_phys_addr, hid_size / PageSize}, @@ -654,10 +649,6 @@ struct KernelCore::Impl { {time_phys_addr, time_size / PageSize}, Svc::MemoryPermission::None, Svc::MemoryPermission::Read, time_phys_addr, time_size, "Time:SharedMemory"); - hidbus_shared_mem->Initialize(system.DeviceMemory(), nullptr, - {hidbus_phys_addr, hidbus_size / PageSize}, - Svc::MemoryPermission::None, Svc::MemoryPermission::Read, - hidbus_phys_addr, hidbus_size, "HidBus:SharedMemory"); } KClientPort* CreateNamedServicePort(std::string name) { @@ -668,13 +659,20 @@ struct KernelCore::Impl { } KClientPort* port = &search->second(system.ServiceManager(), system); - { - std::lock_guard lk(server_ports_lock); - server_ports.insert(&port->GetParent()->GetServerPort()); - } + RegisterServerObject(&port->GetParent()->GetServerPort()); return port; } + void RegisterServerObject(KAutoObject* server_object) { + std::lock_guard lk(server_objects_lock); + server_objects.insert(server_object); + } + + void UnregisterServerObject(KAutoObject* server_object) { + std::lock_guard lk(server_objects_lock); + server_objects.erase(server_object); + } + std::weak_ptr CreateServiceThread(KernelCore& kernel, const std::string& name) { auto service_thread = std::make_shared(kernel, 1, name); @@ -702,7 +700,7 @@ struct KernelCore::Impl { service_threads_manager.QueueWork([this]() { service_threads.clear(); }); } - std::mutex server_ports_lock; + std::mutex server_objects_lock; std::mutex registered_objects_lock; std::mutex registered_in_use_objects_lock; @@ -732,7 +730,7 @@ struct KernelCore::Impl { /// the ConnectToPort SVC. std::unordered_map service_interface_factory; NamedPortTable named_ports; - std::unordered_set server_ports; + std::unordered_set server_objects; std::unordered_set registered_objects; std::unordered_set registered_in_use_objects; @@ -750,7 +748,6 @@ struct KernelCore::Impl { Kernel::KSharedMemory* font_shared_mem{}; Kernel::KSharedMemory* irs_shared_mem{}; Kernel::KSharedMemory* time_shared_mem{}; - Kernel::KSharedMemory* hidbus_shared_mem{}; // Memory layout std::unique_ptr memory_layout; @@ -938,6 +935,14 @@ KClientPort* KernelCore::CreateNamedServicePort(std::string name) { return impl->CreateNamedServicePort(std::move(name)); } +void KernelCore::RegisterServerObject(KAutoObject* server_object) { + impl->RegisterServerObject(server_object); +} + +void KernelCore::UnregisterServerObject(KAutoObject* server_object) { + impl->UnregisterServerObject(server_object); +} + void KernelCore::RegisterKernelObject(KAutoObject* object) { std::lock_guard lk(impl->registered_objects_lock); impl->registered_objects.insert(object); @@ -1042,14 +1047,6 @@ const Kernel::KSharedMemory& KernelCore::GetTimeSharedMem() const { return *impl->time_shared_mem; } -Kernel::KSharedMemory& KernelCore::GetHidBusSharedMem() { - return *impl->hidbus_shared_mem; -} - -const Kernel::KSharedMemory& KernelCore::GetHidBusSharedMem() const { - return *impl->hidbus_shared_mem; -} - void KernelCore::Suspend(bool in_suspention) { const bool should_suspend = exception_exited || in_suspention; { diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index f4437a06f..d709c368b 100755 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -195,6 +195,14 @@ public: /// Opens a port to a service previously registered with RegisterNamedService. KClientPort* CreateNamedServicePort(std::string name); + /// Registers a server session or port with the gobal emulation state, to be freed on shutdown. + /// This is necessary because we do not emulate processes for HLE sessions and ports. + void RegisterServerObject(KAutoObject* server_object); + + /// Unregisters a server session or port previously registered with RegisterServerSession when + /// it was destroyed during the current emulation session. + void UnregisterServerObject(KAutoObject* server_object); + /// Registers all kernel objects with the global emulation state, this is purely for tracking /// leaks after emulation has been shutdown. void RegisterKernelObject(KAutoObject* object); @@ -256,12 +264,6 @@ public: /// Gets the shared memory object for Time services. const Kernel::KSharedMemory& GetTimeSharedMem() const; - /// Gets the shared memory object for HIDBus services. - Kernel::KSharedMemory& GetHidBusSharedMem(); - - /// Gets the shared memory object for HIDBus services. - const Kernel::KSharedMemory& GetHidBusSharedMem() const; - /// Suspend/unsuspend the OS. void Suspend(bool in_suspention); diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 420de3c54..4d7e5ecd3 100755 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1337,7 +1337,7 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_) {200, nullptr, "GetLastApplicationExitReason"}, {500, nullptr, "StartContinuousRecordingFlushForDebug"}, {1000, nullptr, "CreateMovieMaker"}, - {1001, nullptr, "PrepareForJit"}, + {1001, &IApplicationFunctions::PrepareForJit, "PrepareForJit"}, }; // clang-format on @@ -1787,6 +1787,13 @@ void IApplicationFunctions::GetHealthWarningDisappearedSystemEvent(Kernel::HLERe rb.PushCopyObjects(health_warning_disappeared_system_event->GetReadableEvent()); } +void IApplicationFunctions::PrepareForJit(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_AM, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, Core::System& system) { auto message_queue = std::make_shared(system); diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index fdd937b82..11a3c0459 100755 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -336,6 +336,7 @@ private: void TryPopFromFriendInvitationStorageChannel(Kernel::HLERequestContext& ctx); void GetNotificationStorageChannelEvent(Kernel::HLERequestContext& ctx); void GetHealthWarningDisappearedSystemEvent(Kernel::HLERequestContext& ctx); + void PrepareForJit(Kernel::HLERequestContext& ctx); KernelHelpers::ServiceContext service_context; diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 9d3e0a658..b2cec2253 100755 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -16,7 +16,6 @@ #include "core/hle/kernel/kernel.h" #include "core/hle/service/hid/errors.h" #include "core/hle/service/hid/hid.h" -#include "core/hle/service/hid/hidbus.h" #include "core/hle/service/hid/irs.h" #include "core/hle/service/hid/xcd.h" #include "core/memory.h" @@ -2129,6 +2128,32 @@ public: } }; +class HidBus final : public ServiceFramework { +public: + explicit HidBus(Core::System& system_) : ServiceFramework{system_, "hidbus"} { + // clang-format off + static const FunctionInfo functions[] = { + {1, nullptr, "GetBusHandle"}, + {2, nullptr, "IsExternalDeviceConnected"}, + {3, nullptr, "Initialize"}, + {4, nullptr, "Finalize"}, + {5, nullptr, "EnableExternalDevice"}, + {6, nullptr, "GetExternalDeviceId"}, + {7, nullptr, "SendCommandAsync"}, + {8, nullptr, "GetSendCommandAsynceResult"}, + {9, nullptr, "SetEventForSendCommandAsycResult"}, + {10, nullptr, "GetSharedMemoryHandle"}, + {11, nullptr, "EnableJoyPollingReceiveMode"}, + {12, nullptr, "DisableJoyPollingReceiveMode"}, + {13, nullptr, "GetPollingData"}, + {14, nullptr, "SetStatusManagerType"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { std::make_shared(system)->InstallAsService(service_manager); std::make_shared(system)->InstallAsService(service_manager); diff --git a/src/core/hle/service/jit/jit.cpp b/src/core/hle/service/jit/jit.cpp new file mode 100755 index 000000000..c8ebd2e3f --- /dev/null +++ b/src/core/hle/service/jit/jit.cpp @@ -0,0 +1,53 @@ +// Copyright 2022 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "core/hle/ipc_helpers.h" +#include "core/hle/result.h" +#include "core/hle/service/jit/jit.h" +#include "core/hle/service/service.h" + +namespace Service::JIT { + +class IJitEnvironment final : public ServiceFramework { +public: + explicit IJitEnvironment(Core::System& system_) : ServiceFramework{system_, "IJitEnvironment"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "GenerateCode"}, + {1, nullptr, "Control"}, + {1000, nullptr, "LoadPlugin"}, + {1001, nullptr, "GetCodeAddress"}, + }; + // clang-format on + + RegisterHandlers(functions); + } +}; + +class JITU final : public ServiceFramework { +public: + explicit JITU(Core::System& system_) : ServiceFramework{system_, "jit:u"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, &JITU::CreateJitEnvironment, "CreateJitEnvironment"}, + }; + // clang-format on + + RegisterHandlers(functions); + } + + void CreateJitEnvironment(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_JIT, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(ResultSuccess); + rb.PushIpcInterface(system); + } +}; + +void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { + std::make_shared(system)->InstallAsService(sm); +} + +} // namespace Service::JIT diff --git a/src/core/hle/service/jit/jit.h b/src/core/hle/service/jit/jit.h new file mode 100755 index 000000000..8fbf504a1 --- /dev/null +++ b/src/core/hle/service/jit/jit.h @@ -0,0 +1,20 @@ +// Copyright 2022 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +namespace Core { +class System; +} + +namespace Service::SM { +class ServiceManager; +} + +namespace Service::JIT { + +/// Registers all JIT services with the specified service manager. +void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); + +} // namespace Service::JIT diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 8d902beb9..0f59a03c5 100755 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -32,6 +32,7 @@ #include "core/hle/service/glue/glue.h" #include "core/hle/service/grc/grc.h" #include "core/hle/service/hid/hid.h" +#include "core/hle/service/jit/jit.h" #include "core/hle/service/lbl/lbl.h" #include "core/hle/service/ldn/ldn.h" #include "core/hle/service/ldr/ldr.h" @@ -262,6 +263,7 @@ Services::Services(std::shared_ptr& sm, Core::System& system Glue::InstallInterfaces(system); GRC::InstallInterfaces(*sm, system); HID::InstallInterfaces(*sm, system); + JIT::InstallInterfaces(*sm, system); LBL::InstallInterfaces(*sm, system); LDN::InstallInterfaces(*sm, system); LDR::InstallInterfaces(*sm, system); diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 97f895852..13f5e08ec 100755 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -153,7 +153,7 @@ ResultVal SM::GetServiceImpl(Kernel::HLERequestContext& auto& port = port_result.Unwrap(); SCOPE_EXIT({ port->GetClientPort().Close(); }); - server_ports.emplace_back(&port->GetServerPort()); + kernel.RegisterServerObject(&port->GetServerPort()); // Create a new session. Kernel::KClientSession* session{}; @@ -224,10 +224,6 @@ SM::SM(ServiceManager& service_manager_, Core::System& system_) }); } -SM::~SM() { - for (auto& server_port : server_ports) { - server_port->Close(); - } -} +SM::~SM() = default; } // namespace Service::SM diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 021eb51b4..f3ff7b27e 100755 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -22,7 +22,6 @@ class KClientPort; class KClientSession; class KernelCore; class KPort; -class KServerPort; class SessionRequestHandler; } // namespace Kernel @@ -48,7 +47,6 @@ private: ServiceManager& service_manager; bool is_initialized{}; Kernel::KernelCore& kernel; - std::vector server_ports; }; class ServiceManager { diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 2ee21f751..b1467d016 100755 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -99,9 +99,6 @@ add_executable(yuzu configuration/configure_profile_manager.cpp configuration/configure_profile_manager.h configuration/configure_profile_manager.ui - configuration/configure_ringcon.cpp - configuration/configure_ringcon.h - configuration/configure_ringcon.ui configuration/configure_network.cpp configuration/configure_network.h configuration/configure_network.ui diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index ac26b885b..d2e735f48 100755 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp @@ -60,11 +60,6 @@ const std::array Config::default_stick_mod = { 0, }; -const std::array Config::default_ringcon_analogs{{ - Qt::Key_A, - Qt::Key_D, -}}; - // This shouldn't have anything except static initializers (no functions). So // QKeySequence(...).toString() is NOT ALLOWED HERE. // This must be in alphabetical order according to action name as it must have the same order as @@ -351,23 +346,6 @@ void Config::ReadTouchscreenValues() { ReadSetting(QStringLiteral("touchscreen_diameter_y"), 15).toUInt(); } -void Config::ReadHidbusValues() { - Settings::values.enable_ring_controller = - ReadSetting(QStringLiteral("enable_ring_controller"), true).toBool(); - - const std::string default_param = InputCommon::GenerateAnalogParamFromKeys( - 0, 0, default_ringcon_analogs[0], default_ringcon_analogs[1], 0, 0.05f); - auto& ringcon_analogs = Settings::values.ringcon_analogs; - - ringcon_analogs = - qt_config->value(QStringLiteral("ring_controller"), QString::fromStdString(default_param)) - .toString() - .toStdString(); - if (ringcon_analogs.empty()) { - ringcon_analogs = default_param; - } -} - void Config::ReadAudioValues() { qt_config->beginGroup(QStringLiteral("Audio")); @@ -391,7 +369,6 @@ void Config::ReadControlValues() { ReadMouseValues(); ReadTouchscreenValues(); ReadMotionTouchValues(); - ReadHidbusValues(); #ifdef _WIN32 ReadBasicSetting(Settings::values.enable_raw_input); @@ -985,16 +962,6 @@ void Config::SaveMotionTouchValues() { qt_config->endArray(); } -void Config::SaveHidbusValues() { - WriteBasicSetting(Settings::values.enable_ring_controller); - - const std::string default_param = InputCommon::GenerateAnalogParamFromKeys( - 0, 0, default_ringcon_analogs[0], default_ringcon_analogs[1], 0, 0.05f); - WriteSetting(QStringLiteral("ring_controller"), - QString::fromStdString(Settings::values.ringcon_analogs), - QString::fromStdString(default_param)); -} - void Config::SaveValues() { if (global) { SaveControlValues(); @@ -1035,7 +1002,6 @@ void Config::SaveControlValues() { SaveMouseValues(); SaveTouchscreenValues(); SaveMotionTouchValues(); - SaveHidbusValues(); WriteGlobalSetting(Settings::values.use_docked_mode); WriteGlobalSetting(Settings::values.vibration_enabled); diff --git a/src/yuzu/configuration/config.h b/src/yuzu/configuration/config.h index f0ab6bdaa..ae3e36a11 100755 --- a/src/yuzu/configuration/config.h +++ b/src/yuzu/configuration/config.h @@ -42,7 +42,6 @@ public: static const std::array default_motions; static const std::array, Settings::NativeAnalog::NumAnalogs> default_analogs; static const std::array default_stick_mod; - static const std::array default_ringcon_analogs; static const std::array default_mouse_buttons; static const std::array default_keyboard_keys; @@ -67,7 +66,6 @@ private: void ReadMouseValues(); void ReadTouchscreenValues(); void ReadMotionTouchValues(); - void ReadHidbusValues(); // Read functions bases off the respective config section names. void ReadAudioValues(); @@ -95,7 +93,6 @@ private: void SaveMouseValues(); void SaveTouchscreenValues(); void SaveMotionTouchValues(); - void SaveHidbusValues(); // Save functions based off the respective config section names. void SaveAudioValues(); diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp index 73d7ba24b..4ca74a5f7 100755 --- a/src/yuzu/configuration/configure_input.cpp +++ b/src/yuzu/configuration/configure_input.cpp @@ -20,7 +20,6 @@ #include "yuzu/configuration/configure_input_advanced.h" #include "yuzu/configuration/configure_input_player.h" #include "yuzu/configuration/configure_motion_touch.h" -#include "yuzu/configuration/configure_ringcon.h" #include "yuzu/configuration/configure_touchscreen_advanced.h" #include "yuzu/configuration/configure_vibration.h" #include "yuzu/configuration/input_profiles.h" @@ -159,10 +158,6 @@ void ConfigureInput::Initialize(InputCommon::InputSubsystem* input_subsystem, [this, input_subsystem] { CallConfigureDialog(*this, input_subsystem); }); - connect(advanced, &ConfigureInputAdvanced::CallRingControllerDialog, - [this, input_subsystem, &hid_core] { - CallConfigureDialog(*this, input_subsystem, hid_core); - }); connect(ui->vibrationButton, &QPushButton::clicked, [this, &hid_core] { CallConfigureDialog(*this, hid_core); }); diff --git a/src/yuzu/configuration/configure_input_advanced.cpp b/src/yuzu/configuration/configure_input_advanced.cpp index 8fd1f4a38..20fc2599d 100755 --- a/src/yuzu/configuration/configure_input_advanced.cpp +++ b/src/yuzu/configuration/configure_input_advanced.cpp @@ -79,17 +79,13 @@ ConfigureInputAdvanced::ConfigureInputAdvanced(QWidget* parent) &ConfigureInputAdvanced::UpdateUIEnabled); connect(ui->touchscreen_enabled, &QCheckBox::stateChanged, this, &ConfigureInputAdvanced::UpdateUIEnabled); - connect(ui->enable_ring_controller, &QCheckBox::stateChanged, this, - &ConfigureInputAdvanced::UpdateUIEnabled); connect(ui->debug_configure, &QPushButton::clicked, this, [this] { CallDebugControllerDialog(); }); connect(ui->touchscreen_advanced, &QPushButton::clicked, this, [this] { CallTouchscreenConfigDialog(); }); connect(ui->buttonMotionTouch, &QPushButton::clicked, this, - [this] { CallMotionTouchConfigDialog(); }); - connect(ui->ring_controller_configure, &QPushButton::clicked, this, - [this] { CallRingControllerDialog(); }); + &ConfigureInputAdvanced::CallMotionTouchConfigDialog); #ifndef _WIN32 ui->enable_raw_input->setVisible(false); @@ -136,7 +132,6 @@ void ConfigureInputAdvanced::ApplyConfiguration() { Settings::values.enable_raw_input = ui->enable_raw_input->isChecked(); Settings::values.enable_udp_controller = ui->enable_udp_controller->isChecked(); Settings::values.controller_navigation = ui->controller_navigation->isChecked(); - Settings::values.enable_ring_controller = ui->enable_ring_controller->isChecked(); } void ConfigureInputAdvanced::LoadConfiguration() { @@ -169,7 +164,6 @@ void ConfigureInputAdvanced::LoadConfiguration() { ui->enable_raw_input->setChecked(Settings::values.enable_raw_input.GetValue()); ui->enable_udp_controller->setChecked(Settings::values.enable_udp_controller.GetValue()); ui->controller_navigation->setChecked(Settings::values.controller_navigation.GetValue()); - ui->enable_ring_controller->setChecked(Settings::values.enable_ring_controller.GetValue()); UpdateUIEnabled(); } @@ -191,5 +185,4 @@ void ConfigureInputAdvanced::UpdateUIEnabled() { ui->touchscreen_advanced->setEnabled(ui->touchscreen_enabled->isChecked()); ui->mouse_panning->setEnabled(!ui->mouse_enabled->isChecked()); ui->mouse_panning_sensitivity->setEnabled(!ui->mouse_enabled->isChecked()); - ui->ring_controller_configure->setEnabled(ui->enable_ring_controller->isChecked()); } diff --git a/src/yuzu/configuration/configure_input_advanced.h b/src/yuzu/configuration/configure_input_advanced.h index 4472cb846..3083d55c1 100755 --- a/src/yuzu/configuration/configure_input_advanced.h +++ b/src/yuzu/configuration/configure_input_advanced.h @@ -29,7 +29,6 @@ signals: void CallMouseConfigDialog(); void CallTouchscreenConfigDialog(); void CallMotionTouchConfigDialog(); - void CallRingControllerDialog(); private: void changeEvent(QEvent* event) override; diff --git a/src/yuzu/configuration/configure_input_advanced.ui b/src/yuzu/configuration/configure_input_advanced.ui index 14403cb10..66f2075f2 100755 --- a/src/yuzu/configuration/configure_input_advanced.ui +++ b/src/yuzu/configuration/configure_input_advanced.ui @@ -2603,20 +2603,6 @@ - - - - Ring Controller - - - - - - - Configure - - - diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index 291e37acf..8ef3596dd 100755 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -1407,10 +1407,10 @@ void ConfigureInputPlayer::mousePressEvent(QMouseEvent* event) { } void ConfigureInputPlayer::keyPressEvent(QKeyEvent* event) { + event->ignore(); if (!input_setter || !event) { return; } - event->ignore(); if (event->key() != Qt::Key_Escape) { input_subsystem->GetKeyboard()->PressKey(event->key()); } diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index d675e4a90..62d15f8cd 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -1540,9 +1540,8 @@ void GMainWindow::ShutdownGame() { input_subsystem->GetTas()->Stop(); OnTasStateChanged(); - // Enable all controllers types and remove all service callbacks + // Enable all controllers system->HIDCore().SetSupportedStyleTag({Core::HID::NpadStyleSet::All}); - system->HIDCore().RemoveServiceCallbacks(); render_window->removeEventFilter(render_window); render_window->setAttribute(Qt::WA_Hover, false);