summaryrefslogtreecommitdiff
path: root/src/yuzu
diff options
context:
space:
mode:
Diffstat (limited to 'src/yuzu')
-rw-r--r--src/yuzu/configuration/configure_input.cpp6
-rw-r--r--src/yuzu/configuration/configure_input_player.cpp46
-rw-r--r--src/yuzu/debugger/wait_tree.cpp57
-rw-r--r--src/yuzu/debugger/wait_tree.h14
-rw-r--r--src/yuzu/main.cpp2
5 files changed, 66 insertions, 59 deletions
diff --git a/src/yuzu/configuration/configure_input.cpp b/src/yuzu/configuration/configure_input.cpp
index 567a36d9b..422022d02 100644
--- a/src/yuzu/configuration/configure_input.cpp
+++ b/src/yuzu/configuration/configure_input.cpp
@@ -190,12 +190,16 @@ void ConfigureInput::ApplyConfiguration() {
// This emulates a delay between disconnecting and reconnecting controllers as some games
// do not respond to a change in controller type if it was instantaneous.
using namespace std::chrono_literals;
- std::this_thread::sleep_for(60ms);
+ std::this_thread::sleep_for(150ms);
for (auto* controller : player_controllers) {
controller->TryConnectSelectedController();
}
+ // This emulates a delay between disconnecting and reconnecting controllers as some games
+ // do not respond to a change in controller type if it was instantaneous.
+ std::this_thread::sleep_for(150ms);
+
advanced->ApplyConfiguration();
const bool pre_docked_mode = Settings::values.use_docked_mode.GetValue();
diff --git a/src/yuzu/configuration/configure_input_player.cpp b/src/yuzu/configuration/configure_input_player.cpp
index 13f0351d4..fbe36046b 100644
--- a/src/yuzu/configuration/configure_input_player.cpp
+++ b/src/yuzu/configuration/configure_input_player.cpp
@@ -579,11 +579,11 @@ void ConfigureInputPlayer::ApplyConfiguration() {
// Apply configuration for handheld
if (player_index == 0) {
auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
+ const auto handheld_connected = handheld.connected;
if (player.controller_type == Settings::ControllerType::Handheld) {
handheld = player;
}
- handheld.connected = ui->groupConnectedController->isChecked() &&
- player.controller_type == Settings::ControllerType::Handheld;
+ handheld.connected = handheld_connected;
}
}
@@ -595,6 +595,18 @@ void ConfigureInputPlayer::TryConnectSelectedController() {
const auto player_connected = ui->groupConnectedController->isChecked() &&
controller_type != Settings::ControllerType::Handheld;
+ // Connect Handheld depending on Player 1's controller configuration.
+ if (player_index == 0 && controller_type == Settings::ControllerType::Handheld) {
+ auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
+ const auto handheld_connected = ui->groupConnectedController->isChecked() &&
+ controller_type == Settings::ControllerType::Handheld;
+ // Connect only if handheld is going from disconnected to connected
+ if (!handheld.connected && handheld_connected) {
+ UpdateController(controller_type, HANDHELD_INDEX, true);
+ }
+ handheld.connected = handheld_connected;
+ }
+
if (player.controller_type == controller_type && player.connected == player_connected) {
// Set vibration devices in the event that the input device has changed.
ConfigureVibration::SetVibrationDevices(player_index);
@@ -606,22 +618,11 @@ void ConfigureInputPlayer::TryConnectSelectedController() {
ConfigureVibration::SetVibrationDevices(player_index);
- // Connect/Disconnect Handheld depending on Player 1's controller configuration.
- if (player_index == 0) {
- auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
- if (controller_type == Settings::ControllerType::Handheld) {
- handheld = player;
- }
- handheld.connected = ui->groupConnectedController->isChecked() &&
- controller_type == Settings::ControllerType::Handheld;
- UpdateController(Settings::ControllerType::Handheld, HANDHELD_INDEX, handheld.connected);
- }
-
if (!player.connected) {
return;
}
- UpdateController(controller_type, player_index, player_connected);
+ UpdateController(controller_type, player_index, true);
}
void ConfigureInputPlayer::TryDisconnectSelectedController() {
@@ -632,11 +633,28 @@ void ConfigureInputPlayer::TryDisconnectSelectedController() {
const auto player_connected = ui->groupConnectedController->isChecked() &&
controller_type != Settings::ControllerType::Handheld;
+ // Disconnect Handheld depending on Player 1's controller configuration.
+ if (player_index == 0 && player.controller_type == Settings::ControllerType::Handheld) {
+ const auto& handheld = Settings::values.players.GetValue()[HANDHELD_INDEX];
+ const auto handheld_connected = ui->groupConnectedController->isChecked() &&
+ controller_type == Settings::ControllerType::Handheld;
+ // Disconnect only if handheld is going from connected to disconnected
+ if (handheld.connected && !handheld_connected) {
+ UpdateController(controller_type, HANDHELD_INDEX, false);
+ }
+ return;
+ }
+
// Do not do anything if the controller configuration has not changed.
if (player.controller_type == controller_type && player.connected == player_connected) {
return;
}
+ // Do not disconnect if the controller is already disconnected
+ if (!player.connected) {
+ return;
+ }
+
// Disconnect the controller first.
UpdateController(controller_type, player_index, false);
}
diff --git a/src/yuzu/debugger/wait_tree.cpp b/src/yuzu/debugger/wait_tree.cpp
index a93b5d3c2..0e5156dcc 100644
--- a/src/yuzu/debugger/wait_tree.cpp
+++ b/src/yuzu/debugger/wait_tree.cpp
@@ -15,10 +15,11 @@
#include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/k_scheduler.h"
#include "core/hle/kernel/k_synchronization_object.h"
+#include "core/hle/kernel/k_thread.h"
#include "core/hle/kernel/process.h"
#include "core/hle/kernel/readable_event.h"
#include "core/hle/kernel/svc_common.h"
-#include "core/hle/kernel/thread.h"
+#include "core/hle/kernel/svc_types.h"
#include "core/memory.h"
namespace {
@@ -90,9 +91,9 @@ std::size_t WaitTreeItem::Row() const {
std::vector<std::unique_ptr<WaitTreeThread>> WaitTreeItem::MakeThreadItemList() {
std::vector<std::unique_ptr<WaitTreeThread>> item_list;
std::size_t row = 0;
- auto add_threads = [&](const std::vector<std::shared_ptr<Kernel::Thread>>& threads) {
+ auto add_threads = [&](const std::vector<std::shared_ptr<Kernel::KThread>>& threads) {
for (std::size_t i = 0; i < threads.size(); ++i) {
- if (!threads[i]->IsHLEThread()) {
+ if (threads[i]->GetThreadTypeForDebugging() == Kernel::ThreadType::User) {
item_list.push_back(std::make_unique<WaitTreeThread>(*threads[i]));
item_list.back()->row = row;
}
@@ -117,7 +118,7 @@ WaitTreeMutexInfo::WaitTreeMutexInfo(VAddr mutex_address, const Kernel::HandleTa
: mutex_address(mutex_address) {
mutex_value = Core::System::GetInstance().Memory().Read32(mutex_address);
owner_handle = static_cast<Kernel::Handle>(mutex_value & Kernel::Svc::HandleWaitMask);
- owner = handle_table.Get<Kernel::Thread>(owner_handle);
+ owner = handle_table.Get<Kernel::KThread>(owner_handle);
}
WaitTreeMutexInfo::~WaitTreeMutexInfo() = default;
@@ -139,7 +140,7 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutexInfo::GetChildren() cons
return list;
}
-WaitTreeCallstack::WaitTreeCallstack(const Kernel::Thread& thread) : thread(thread) {}
+WaitTreeCallstack::WaitTreeCallstack(const Kernel::KThread& thread) : thread(thread) {}
WaitTreeCallstack::~WaitTreeCallstack() = default;
QString WaitTreeCallstack::GetText() const {
@@ -149,7 +150,7 @@ QString WaitTreeCallstack::GetText() const {
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeCallstack::GetChildren() const {
std::vector<std::unique_ptr<WaitTreeItem>> list;
- if (thread.IsHLEThread()) {
+ if (thread.GetThreadTypeForDebugging() != Kernel::ThreadType::User) {
return list;
}
@@ -194,7 +195,7 @@ std::unique_ptr<WaitTreeSynchronizationObject> WaitTreeSynchronizationObject::ma
case Kernel::HandleType::ReadableEvent:
return std::make_unique<WaitTreeEvent>(static_cast<const Kernel::ReadableEvent&>(object));
case Kernel::HandleType::Thread:
- return std::make_unique<WaitTreeThread>(static_cast<const Kernel::Thread&>(object));
+ return std::make_unique<WaitTreeThread>(static_cast<const Kernel::KThread&>(object));
default:
return std::make_unique<WaitTreeSynchronizationObject>(object);
}
@@ -231,21 +232,17 @@ std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeObjectList::GetChildren() con
return list;
}
-WaitTreeThread::WaitTreeThread(const Kernel::Thread& thread)
+WaitTreeThread::WaitTreeThread(const Kernel::KThread& thread)
: WaitTreeSynchronizationObject(thread) {}
WaitTreeThread::~WaitTreeThread() = default;
QString WaitTreeThread::GetText() const {
- const auto& thread = static_cast<const Kernel::Thread&>(object);
+ const auto& thread = static_cast<const Kernel::KThread&>(object);
QString status;
switch (thread.GetState()) {
case Kernel::ThreadState::Runnable:
- if (!thread.IsPaused()) {
- if (thread.WasRunning()) {
- status = tr("running");
- } else {
- status = tr("ready");
- }
+ if (!thread.IsSuspended()) {
+ status = tr("runnable");
} else {
status = tr("paused");
}
@@ -297,15 +294,11 @@ QString WaitTreeThread::GetText() const {
QColor WaitTreeThread::GetColor() const {
const std::size_t color_index = IsDarkTheme() ? 1 : 0;
- const auto& thread = static_cast<const Kernel::Thread&>(object);
+ const auto& thread = static_cast<const Kernel::KThread&>(object);
switch (thread.GetState()) {
case Kernel::ThreadState::Runnable:
- if (!thread.IsPaused()) {
- if (thread.WasRunning()) {
- return QColor(WaitTreeColors[0][color_index]);
- } else {
- return QColor(WaitTreeColors[1][color_index]);
- }
+ if (!thread.IsSuspended()) {
+ return QColor(WaitTreeColors[0][color_index]);
} else {
return QColor(WaitTreeColors[2][color_index]);
}
@@ -336,27 +329,21 @@ QColor WaitTreeThread::GetColor() const {
std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const {
std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeSynchronizationObject::GetChildren());
- const auto& thread = static_cast<const Kernel::Thread&>(object);
+ const auto& thread = static_cast<const Kernel::KThread&>(object);
QString processor;
- switch (thread.GetProcessorID()) {
- case Kernel::ThreadProcessorId::THREADPROCESSORID_IDEAL:
+ switch (thread.GetActiveCore()) {
+ case Kernel::Svc::IdealCoreUseProcessValue:
processor = tr("ideal");
break;
- case Kernel::ThreadProcessorId::THREADPROCESSORID_0:
- case Kernel::ThreadProcessorId::THREADPROCESSORID_1:
- case Kernel::ThreadProcessorId::THREADPROCESSORID_2:
- case Kernel::ThreadProcessorId::THREADPROCESSORID_3:
- processor = tr("core %1").arg(thread.GetProcessorID());
- break;
default:
- processor = tr("Unknown processor %1").arg(thread.GetProcessorID());
+ processor = tr("core %1").arg(thread.GetActiveCore());
break;
}
list.push_back(std::make_unique<WaitTreeText>(tr("processor = %1").arg(processor)));
- list.push_back(
- std::make_unique<WaitTreeText>(tr("ideal core = %1").arg(thread.GetIdealCore())));
+ list.push_back(std::make_unique<WaitTreeText>(
+ tr("ideal core = %1").arg(thread.GetIdealCoreForDebugging())));
list.push_back(std::make_unique<WaitTreeText>(
tr("affinity mask = %1").arg(thread.GetAffinityMask().GetAffinityMask())));
list.push_back(std::make_unique<WaitTreeText>(tr("thread id = %1").arg(thread.GetThreadID())));
@@ -390,7 +377,7 @@ WaitTreeEvent::WaitTreeEvent(const Kernel::ReadableEvent& object)
: WaitTreeSynchronizationObject(object) {}
WaitTreeEvent::~WaitTreeEvent() = default;
-WaitTreeThreadList::WaitTreeThreadList(const std::vector<Kernel::Thread*>& list)
+WaitTreeThreadList::WaitTreeThreadList(const std::vector<Kernel::KThread*>& list)
: thread_list(list) {}
WaitTreeThreadList::~WaitTreeThreadList() = default;
diff --git a/src/yuzu/debugger/wait_tree.h b/src/yuzu/debugger/wait_tree.h
index cf96911ea..b202c5567 100644
--- a/src/yuzu/debugger/wait_tree.h
+++ b/src/yuzu/debugger/wait_tree.h
@@ -19,8 +19,8 @@ class EmuThread;
namespace Kernel {
class HandleTable;
class KSynchronizationObject;
+class KThread;
class ReadableEvent;
-class Thread;
} // namespace Kernel
class WaitTreeThread;
@@ -83,20 +83,20 @@ private:
VAddr mutex_address;
u32 mutex_value;
Kernel::Handle owner_handle;
- std::shared_ptr<Kernel::Thread> owner;
+ std::shared_ptr<Kernel::KThread> owner;
};
class WaitTreeCallstack : public WaitTreeExpandableItem {
Q_OBJECT
public:
- explicit WaitTreeCallstack(const Kernel::Thread& thread);
+ explicit WaitTreeCallstack(const Kernel::KThread& thread);
~WaitTreeCallstack() override;
QString GetText() const override;
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
private:
- const Kernel::Thread& thread;
+ const Kernel::KThread& thread;
};
class WaitTreeSynchronizationObject : public WaitTreeExpandableItem {
@@ -131,7 +131,7 @@ private:
class WaitTreeThread : public WaitTreeSynchronizationObject {
Q_OBJECT
public:
- explicit WaitTreeThread(const Kernel::Thread& thread);
+ explicit WaitTreeThread(const Kernel::KThread& thread);
~WaitTreeThread() override;
QString GetText() const override;
@@ -149,14 +149,14 @@ public:
class WaitTreeThreadList : public WaitTreeExpandableItem {
Q_OBJECT
public:
- explicit WaitTreeThreadList(const std::vector<Kernel::Thread*>& list);
+ explicit WaitTreeThreadList(const std::vector<Kernel::KThread*>& list);
~WaitTreeThreadList() override;
QString GetText() const override;
std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
private:
- const std::vector<Kernel::Thread*>& thread_list;
+ const std::vector<Kernel::KThread*>& thread_list;
};
class WaitTreeModel : public QAbstractItemModel {
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index e76141125..886e6e9d2 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -1039,8 +1039,6 @@ bool GMainWindow::LoadROM(const QString& filename, std::size_t program_index) {
std::make_unique<QtWebBrowser>(*this), // Web Browser
});
- system.RegisterHostThread();
-
const Core::System::ResultStatus result{
system.Load(*render_window, filename.toStdString(), program_index)};