summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2024-01-02 04:33:07 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2024-01-04 03:21:16 +0100
commit55623222908d2fd979de9ab101b1deff33a622f8 (patch)
treeaba09a6d8801b28dbfb6c7f5f35b4a666db6d931 /src/core/hle
parentservice: hid: Implement NpadResource and NpadData (diff)
downloadyuzu-55623222908d2fd979de9ab101b1deff33a622f8.tar
yuzu-55623222908d2fd979de9ab101b1deff33a622f8.tar.gz
yuzu-55623222908d2fd979de9ab101b1deff33a622f8.tar.bz2
yuzu-55623222908d2fd979de9ab101b1deff33a622f8.tar.lz
yuzu-55623222908d2fd979de9ab101b1deff33a622f8.tar.xz
yuzu-55623222908d2fd979de9ab101b1deff33a622f8.tar.zst
yuzu-55623222908d2fd979de9ab101b1deff33a622f8.zip
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/hid/controllers/capture_button.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/console_six_axis.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/controller_base.cpp4
-rw-r--r--src/core/hle/service/hid/controllers/controller_base.h4
-rw-r--r--src/core/hle/service/hid/controllers/debug_mouse.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/debug_pad.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/digitizer.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/gesture.cpp6
-rw-r--r--src/core/hle/service/hid/controllers/home_button.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/keyboard.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/mouse.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp2
-rw-r--r--src/core/hle/service/hid/controllers/six_axis.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/sleep_button.cpp3
-rw-r--r--src/core/hle/service/hid/controllers/touchscreen.cpp2
-rw-r--r--src/core/hle/service/hid/controllers/unique_pad.cpp2
-rw-r--r--src/core/hle/service/hid/resource_manager.cpp24
17 files changed, 45 insertions, 29 deletions
diff --git a/src/core/hle/service/hid/controllers/capture_button.cpp b/src/core/hle/service/hid/controllers/capture_button.cpp
index 8b486fcb5..7847c080e 100644
--- a/src/core/hle/service/hid/controllers/capture_button.cpp
+++ b/src/core/hle/service/hid/controllers/capture_button.cpp
@@ -21,10 +21,11 @@ void CaptureButton::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
return;
}
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/console_six_axis.cpp b/src/core/hle/service/hid/controllers/console_six_axis.cpp
index 8eba2c292..4b574c2e5 100644
--- a/src/core/hle/service/hid/controllers/console_six_axis.cpp
+++ b/src/core/hle/service/hid/controllers/console_six_axis.cpp
@@ -20,10 +20,11 @@ void ConsoleSixAxis::OnInit() {}
void ConsoleSixAxis::OnRelease() {}
void ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/controller_base.cpp b/src/core/hle/service/hid/controllers/controller_base.cpp
index 2083ccfad..afca7154c 100644
--- a/src/core/hle/service/hid/controllers/controller_base.cpp
+++ b/src/core/hle/service/hid/controllers/controller_base.cpp
@@ -32,8 +32,10 @@ bool ControllerBase::IsControllerActivated() const {
return is_activated;
}
-void ControllerBase::SetAppletResource(std::shared_ptr<AppletResource> resource) {
+void ControllerBase::SetAppletResource(std::shared_ptr<AppletResource> resource,
+ std::recursive_mutex* resource_mutex) {
applet_resource = resource;
+ shared_mutex = resource_mutex;
}
} // namespace Service::HID
diff --git a/src/core/hle/service/hid/controllers/controller_base.h b/src/core/hle/service/hid/controllers/controller_base.h
index 759ae0053..b34b85ece 100644
--- a/src/core/hle/service/hid/controllers/controller_base.h
+++ b/src/core/hle/service/hid/controllers/controller_base.h
@@ -42,11 +42,13 @@ public:
bool IsControllerActivated() const;
- void SetAppletResource(std::shared_ptr<AppletResource> resource);
+ void SetAppletResource(std::shared_ptr<AppletResource> resource,
+ std::recursive_mutex* resource_mutex);
protected:
bool is_activated{false};
std::shared_ptr<AppletResource> applet_resource{nullptr};
+ std::recursive_mutex* shared_mutex{nullptr};
Core::HID::HIDCore& hid_core;
};
diff --git a/src/core/hle/service/hid/controllers/debug_mouse.cpp b/src/core/hle/service/hid/controllers/debug_mouse.cpp
index f2f1a27f8..ceeb78d36 100644
--- a/src/core/hle/service/hid/controllers/debug_mouse.cpp
+++ b/src/core/hle/service/hid/controllers/debug_mouse.cpp
@@ -21,10 +21,11 @@ void DebugMouse::OnInit() {}
void DebugMouse::OnRelease() {}
void DebugMouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/debug_pad.cpp b/src/core/hle/service/hid/controllers/debug_pad.cpp
index 1811cf620..dc83f90f3 100644
--- a/src/core/hle/service/hid/controllers/debug_pad.cpp
+++ b/src/core/hle/service/hid/controllers/debug_pad.cpp
@@ -23,10 +23,11 @@ void DebugPad::OnInit() {}
void DebugPad::OnRelease() {}
void DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/digitizer.cpp b/src/core/hle/service/hid/controllers/digitizer.cpp
index c01580fd6..d5514c965 100644
--- a/src/core/hle/service/hid/controllers/digitizer.cpp
+++ b/src/core/hle/service/hid/controllers/digitizer.cpp
@@ -21,10 +21,11 @@ void Digitizer::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
return;
}
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/gesture.cpp b/src/core/hle/service/hid/controllers/gesture.cpp
index 6e686fe65..c73da13ee 100644
--- a/src/core/hle/service/hid/controllers/gesture.cpp
+++ b/src/core/hle/service/hid/controllers/gesture.cpp
@@ -28,10 +28,11 @@ Gesture::Gesture(Core::HID::HIDCore& hid_core_) : ControllerBase(hid_core_) {
Gesture::~Gesture() = default;
void Gesture::OnInit() {
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
@@ -44,10 +45,11 @@ void Gesture::OnInit() {
void Gesture::OnRelease() {}
void Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/home_button.cpp b/src/core/hle/service/hid/controllers/home_button.cpp
index 71dd9bc08..1397379f3 100644
--- a/src/core/hle/service/hid/controllers/home_button.cpp
+++ b/src/core/hle/service/hid/controllers/home_button.cpp
@@ -21,10 +21,11 @@ void HomeButton::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
return;
}
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/keyboard.cpp b/src/core/hle/service/hid/controllers/keyboard.cpp
index c72b3e5ce..c069bcbb2 100644
--- a/src/core/hle/service/hid/controllers/keyboard.cpp
+++ b/src/core/hle/service/hid/controllers/keyboard.cpp
@@ -22,10 +22,11 @@ void Keyboard::OnInit() {}
void Keyboard::OnRelease() {}
void Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/mouse.cpp b/src/core/hle/service/hid/controllers/mouse.cpp
index 58deafbc5..3a8d1751b 100644
--- a/src/core/hle/service/hid/controllers/mouse.cpp
+++ b/src/core/hle/service/hid/controllers/mouse.cpp
@@ -21,10 +21,11 @@ void Mouse::OnInit() {}
void Mouse::OnRelease() {}
void Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index bf387e22d..17cd0d7a0 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -128,7 +128,7 @@ void NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, std::size_t c
auto* data = applet_resource_holder.applet_resource->GetAruidDataByIndex(aruid_index);
- if (data->flag.is_assigned) {
+ if (!data->flag.is_assigned) {
continue;
}
diff --git a/src/core/hle/service/hid/controllers/six_axis.cpp b/src/core/hle/service/hid/controllers/six_axis.cpp
index a5a67dea6..adab60911 100644
--- a/src/core/hle/service/hid/controllers/six_axis.cpp
+++ b/src/core/hle/service/hid/controllers/six_axis.cpp
@@ -27,10 +27,11 @@ void SixAxis::OnInit() {}
void SixAxis::OnRelease() {}
void SixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/sleep_button.cpp b/src/core/hle/service/hid/controllers/sleep_button.cpp
index 978dc4c1f..d44b1f4cc 100644
--- a/src/core/hle/service/hid/controllers/sleep_button.cpp
+++ b/src/core/hle/service/hid/controllers/sleep_button.cpp
@@ -21,10 +21,11 @@ void SleepButton::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
return;
}
+ std::scoped_lock shared_lock{*shared_mutex};
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp
index 291dc707e..b585a5829 100644
--- a/src/core/hle/service/hid/controllers/touchscreen.cpp
+++ b/src/core/hle/service/hid/controllers/touchscreen.cpp
@@ -30,7 +30,7 @@ void TouchScreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/controllers/unique_pad.cpp b/src/core/hle/service/hid/controllers/unique_pad.cpp
index 8230501a5..6c543031d 100644
--- a/src/core/hle/service/hid/controllers/unique_pad.cpp
+++ b/src/core/hle/service/hid/controllers/unique_pad.cpp
@@ -24,7 +24,7 @@ void UniquePad::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
const u64 aruid = applet_resource->GetActiveAruid();
auto* data = applet_resource->GetAruidData(aruid);
- if (data == nullptr) {
+ if (data == nullptr || !data->flag.is_assigned) {
return;
}
diff --git a/src/core/hle/service/hid/resource_manager.cpp b/src/core/hle/service/hid/resource_manager.cpp
index ab49259ac..1f41e645d 100644
--- a/src/core/hle/service/hid/resource_manager.cpp
+++ b/src/core/hle/service/hid/resource_manager.cpp
@@ -171,31 +171,31 @@ void ResourceManager::InitializeHidCommonSampler() {
palma = std::make_shared<Palma>(system.HIDCore(), service_context);
six_axis = std::make_shared<SixAxis>(system.HIDCore(), npad);
- debug_pad->SetAppletResource(applet_resource);
- digitizer->SetAppletResource(applet_resource);
- keyboard->SetAppletResource(applet_resource);
+ debug_pad->SetAppletResource(applet_resource, &shared_mutex);
+ digitizer->SetAppletResource(applet_resource, &shared_mutex);
+ keyboard->SetAppletResource(applet_resource, &shared_mutex);
npad->SetNpadExternals(applet_resource, &shared_mutex);
- six_axis->SetAppletResource(applet_resource);
- mouse->SetAppletResource(applet_resource);
- debug_mouse->SetAppletResource(applet_resource);
- home_button->SetAppletResource(applet_resource);
- sleep_button->SetAppletResource(applet_resource);
- capture_button->SetAppletResource(applet_resource);
+ six_axis->SetAppletResource(applet_resource, &shared_mutex);
+ mouse->SetAppletResource(applet_resource, &shared_mutex);
+ debug_mouse->SetAppletResource(applet_resource, &shared_mutex);
+ home_button->SetAppletResource(applet_resource, &shared_mutex);
+ sleep_button->SetAppletResource(applet_resource, &shared_mutex);
+ capture_button->SetAppletResource(applet_resource, &shared_mutex);
}
void ResourceManager::InitializeTouchScreenSampler() {
gesture = std::make_shared<Gesture>(system.HIDCore());
touch_screen = std::make_shared<TouchScreen>(system.HIDCore());
- touch_screen->SetAppletResource(applet_resource);
- gesture->SetAppletResource(applet_resource);
+ touch_screen->SetAppletResource(applet_resource, &shared_mutex);
+ gesture->SetAppletResource(applet_resource, &shared_mutex);
}
void ResourceManager::InitializeConsoleSixAxisSampler() {
console_six_axis = std::make_shared<ConsoleSixAxis>(system.HIDCore());
seven_six_axis = std::make_shared<SevenSixAxis>(system);
- console_six_axis->SetAppletResource(applet_resource);
+ console_six_axis->SetAppletResource(applet_resource, &shared_mutex);
}
void ResourceManager::InitializeAHidSampler() {