diff options
-rw-r--r-- | src/core/hle/kernel/k_affinity_mask.h | 2 | ||||
-rw-r--r-- | src/core/hle/kernel/k_process.cpp | 26 | ||||
-rw-r--r-- | src/core/hle/kernel/k_process.h | 8 | ||||
-rw-r--r-- | src/core/hle/kernel/k_thread.cpp | 11 | ||||
-rw-r--r-- | src/input_common/drivers/udp_client.cpp | 8 | ||||
-rw-r--r-- | src/input_common/drivers/udp_client.h | 4 | ||||
-rw-r--r-- | src/yuzu/configuration/configure_input_player.cpp | 59 |
7 files changed, 61 insertions, 57 deletions
diff --git a/src/core/hle/kernel/k_affinity_mask.h b/src/core/hle/kernel/k_affinity_mask.h index b906895fc..cf704ce87 100644 --- a/src/core/hle/kernel/k_affinity_mask.h +++ b/src/core/hle/kernel/k_affinity_mask.h @@ -31,8 +31,6 @@ public: } constexpr void SetAffinity(s32 core, bool set) { - ASSERT(0 <= core && core < static_cast<s32>(Core::Hardware::NUM_CPU_CORES)); - if (set) { this->mask |= GetCoreBit(core); } else { diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index 265ac6fa1..85c506979 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp @@ -146,6 +146,13 @@ ResultCode KProcess::Initialize(KProcess* process, Core::System& system, std::st // Open a reference to the resource limit. process->resource_limit->Open(); + // Clear remaining fields. + process->num_running_threads = 0; + process->is_signaled = false; + process->exception_thread = nullptr; + process->is_suspended = false; + process->schedule_count = 0; + return ResultSuccess; } @@ -157,20 +164,17 @@ KResourceLimit* KProcess::GetResourceLimit() const { return resource_limit; } -void KProcess::IncrementThreadCount() { - ASSERT(num_threads >= 0); - num_created_threads++; - - if (const auto count = ++num_threads; count > peak_num_threads) { - peak_num_threads = count; - } +void KProcess::IncrementRunningThreadCount() { + ASSERT(num_running_threads.load() >= 0); + ++num_running_threads; } -void KProcess::DecrementThreadCount() { - ASSERT(num_threads > 0); +void KProcess::DecrementRunningThreadCount() { + ASSERT(num_running_threads.load() > 0); - if (const auto count = --num_threads; count == 0) { - LOG_WARNING(Kernel, "Process termination is not fully implemented."); + if (const auto prev = num_running_threads--; prev == 1) { + // TODO(bunnei): Process termination to be implemented when multiprocess is supported. + UNIMPLEMENTED_MSG("KProcess termination is not implemennted!"); } } diff --git a/src/core/hle/kernel/k_process.h b/src/core/hle/kernel/k_process.h index c2a672021..38b446350 100644 --- a/src/core/hle/kernel/k_process.h +++ b/src/core/hle/kernel/k_process.h @@ -235,8 +235,8 @@ public: ++schedule_count; } - void IncrementThreadCount(); - void DecrementThreadCount(); + void IncrementRunningThreadCount(); + void DecrementRunningThreadCount(); void SetRunningThread(s32 core, KThread* thread, u64 idle_count) { running_threads[core] = thread; @@ -473,9 +473,7 @@ private: bool is_suspended{}; bool is_initialized{}; - std::atomic<s32> num_created_threads{}; - std::atomic<u16> num_threads{}; - u16 peak_num_threads{}; + std::atomic<u16> num_running_threads{}; std::array<KThread*, Core::Hardware::NUM_CPU_CORES> running_threads{}; std::array<u64, Core::Hardware::NUM_CPU_CORES> running_thread_idle_counts{}; diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index f42abb8a1..de3ffe0c7 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp @@ -215,7 +215,6 @@ ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_s parent = owner; parent->Open(); - parent->IncrementThreadCount(); } // Initialize thread context. @@ -327,11 +326,6 @@ void KThread::Finalize() { } } - // Decrement the parent process's thread count. - if (parent != nullptr) { - parent->DecrementThreadCount(); - } - // Perform inherited finalization. KSynchronizationObject::Finalize(); } @@ -1011,7 +1005,7 @@ ResultCode KThread::Run() { if (IsUserThread() && IsSuspended()) { this->UpdateState(); } - owner->IncrementThreadCount(); + owner->IncrementRunningThreadCount(); } // Set our state and finish. @@ -1026,10 +1020,11 @@ ResultCode KThread::Run() { void KThread::Exit() { ASSERT(this == GetCurrentThreadPointer(kernel)); - // Release the thread resource hint from parent. + // Release the thread resource hint, running thread count from parent. if (parent != nullptr) { parent->GetResourceLimit()->Release(Kernel::LimitableResource::Threads, 0, 1); resource_limit_release_hint = true; + parent->DecrementRunningThreadCount(); } // Perform termination. diff --git a/src/input_common/drivers/udp_client.cpp b/src/input_common/drivers/udp_client.cpp index 9aaeb91be..d1cdb1ab2 100644 --- a/src/input_common/drivers/udp_client.cpp +++ b/src/input_common/drivers/udp_client.cpp @@ -339,7 +339,7 @@ void UDPClient::StartCommunication(std::size_t client, const std::string& host, } } -const PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const { +PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const { const std::size_t client = pad_index / PADS_PER_CLIENT; return { .guid = clients[client].uuid, @@ -348,9 +348,9 @@ const PadIdentifier UDPClient::GetPadIdentifier(std::size_t pad_index) const { }; } -const Common::UUID UDPClient::GetHostUUID(const std::string host) const { - const auto ip = boost::asio::ip::address_v4::from_string(host); - const auto hex_host = fmt::format("{:06x}", ip.to_ulong()); +Common::UUID UDPClient::GetHostUUID(const std::string& host) const { + const auto ip = boost::asio::ip::make_address_v4(host); + const auto hex_host = fmt::format("{:06x}", ip.to_uint()); return Common::UUID{hex_host}; } diff --git a/src/input_common/drivers/udp_client.h b/src/input_common/drivers/udp_client.h index 61a1fff37..30d7c2682 100644 --- a/src/input_common/drivers/udp_client.h +++ b/src/input_common/drivers/udp_client.h @@ -145,8 +145,8 @@ private: void OnPortInfo(Response::PortInfo); void OnPadData(Response::PadData, std::size_t client); void StartCommunication(std::size_t client, const std::string& host, u16 port); - const PadIdentifier GetPadIdentifier(std::size_t pad_index) const; - const Common::UUID GetHostUUID(const std::string host) const; + PadIdentifier GetPadIdentifier(std::size_t pad_index) const; + Common::UUID GetHostUUID(const std::string& host) const; Common::Input::ButtonNames GetUIButtonName(const Common::ParamPackage& params) const; diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp index d2132b408..7029287a9 100644 --- a/src/yuzu/configuration/configure_input_player.cpp +++ b/src/yuzu/configuration/configure_input_player.cpp @@ -147,7 +147,7 @@ QString ConfigureInputPlayer::ButtonToText(const Common::ParamPackage& param) { // Retrieve the names from Qt if (param.Get("engine", "") == "keyboard") { const QString button_str = GetKeyName(param.Get("code", 0)); - return QObject::tr("%1%2").arg(toggle, button_str); + return QObject::tr("%1%2%3").arg(toggle, inverted, button_str); } if (common_button_name == Common::Input::ButtonNames::Invalid) { @@ -341,7 +341,7 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i emulated_controller->SetButtonParam(button_id, {}); button_map[button_id]->setText(tr("[not set]")); }); - if (param.Has("button") || param.Has("hat")) { + if (param.Has("code") || param.Has("button") || param.Has("hat")) { context_menu.addAction(tr("Toggle button"), [&] { const bool toggle_value = !param.Get("toggle", false); param.Set("toggle", toggle_value); @@ -349,8 +349,8 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i emulated_controller->SetButtonParam(button_id, param); }); context_menu.addAction(tr("Invert button"), [&] { - const bool toggle_value = !param.Get("inverted", false); - param.Set("inverted", toggle_value); + const bool invert_value = !param.Get("inverted", false); + param.Set("inverted", invert_value); button_map[button_id]->setText(ButtonToText(param)); emulated_controller->SetButtonParam(button_id, param); }); @@ -510,28 +510,37 @@ ConfigureInputPlayer::ConfigureInputPlayer(QWidget* parent, std::size_t player_i analog_map_modifier_button[analog_id]->setContextMenuPolicy(Qt::CustomContextMenu); - connect(analog_map_modifier_button[analog_id], &QPushButton::customContextMenuRequested, - [=, this](const QPoint& menu_location) { - QMenu context_menu; - Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); - context_menu.addAction(tr("Clear"), [&] { - param.Set("modifier", ""); - analog_map_modifier_button[analog_id]->setText(tr("[not set]")); - emulated_controller->SetStickParam(analog_id, param); - }); - context_menu.addAction(tr("Toggle button"), [&] { - Common::ParamPackage modifier_param = - Common::ParamPackage{param.Get("modifier", "")}; - const bool toggle_value = !modifier_param.Get("toggle", false); - modifier_param.Set("toggle", toggle_value); - param.Set("modifier", modifier_param.Serialize()); - analog_map_modifier_button[analog_id]->setText( - ButtonToText(modifier_param)); - emulated_controller->SetStickParam(analog_id, param); - }); - context_menu.exec( - analog_map_modifier_button[analog_id]->mapToGlobal(menu_location)); + connect( + analog_map_modifier_button[analog_id], &QPushButton::customContextMenuRequested, + [=, this](const QPoint& menu_location) { + QMenu context_menu; + Common::ParamPackage param = emulated_controller->GetStickParam(analog_id); + context_menu.addAction(tr("Clear"), [&] { + param.Set("modifier", ""); + analog_map_modifier_button[analog_id]->setText(tr("[not set]")); + emulated_controller->SetStickParam(analog_id, param); + }); + context_menu.addAction(tr("Toggle button"), [&] { + Common::ParamPackage modifier_param = + Common::ParamPackage{param.Get("modifier", "")}; + const bool toggle_value = !modifier_param.Get("toggle", false); + modifier_param.Set("toggle", toggle_value); + param.Set("modifier", modifier_param.Serialize()); + analog_map_modifier_button[analog_id]->setText(ButtonToText(modifier_param)); + emulated_controller->SetStickParam(analog_id, param); }); + context_menu.addAction(tr("Invert button"), [&] { + Common::ParamPackage modifier_param = + Common::ParamPackage{param.Get("modifier", "")}; + const bool invert_value = !modifier_param.Get("inverted", false); + modifier_param.Set("inverted", invert_value); + param.Set("modifier", modifier_param.Serialize()); + analog_map_modifier_button[analog_id]->setText(ButtonToText(modifier_param)); + emulated_controller->SetStickParam(analog_id, param); + }); + context_menu.exec( + analog_map_modifier_button[analog_id]->mapToGlobal(menu_location)); + }); connect(analog_map_range_spinbox[analog_id], qOverload<int>(&QSpinBox::valueChanged), [=, this] { |