summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/hid/controllers
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-06-28 23:41:24 +0200
committerbunnei <bunneidev@gmail.com>2021-07-21 03:54:55 +0200
commit015058fadf8dbc72c186e833512e7189c625474b (patch)
treebc8839ef4b46c86283fda20cf95e4b0c6ab18e54 /src/core/hle/service/hid/controllers
parenthle: kernel: Provide methods for tracking dangling kernel objects. (diff)
downloadyuzu-015058fadf8dbc72c186e833512e7189c625474b.tar
yuzu-015058fadf8dbc72c186e833512e7189c625474b.tar.gz
yuzu-015058fadf8dbc72c186e833512e7189c625474b.tar.bz2
yuzu-015058fadf8dbc72c186e833512e7189c625474b.tar.lz
yuzu-015058fadf8dbc72c186e833512e7189c625474b.tar.xz
yuzu-015058fadf8dbc72c186e833512e7189c625474b.tar.zst
yuzu-015058fadf8dbc72c186e833512e7189c625474b.zip
Diffstat (limited to 'src/core/hle/service/hid/controllers')
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp12
-rw-r--r--src/core/hle/service/hid/controllers/npad.h8
2 files changed, 14 insertions, 6 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index 6ce1360e3..95d4f9588 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -18,6 +18,7 @@
#include "core/hle/kernel/k_writable_event.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/service/hid/controllers/npad.h"
+#include "core/hle/service/kernel_helpers.h"
namespace Service::HID {
constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
@@ -147,7 +148,9 @@ 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_,
+ KernelHelpers::ServiceContext& service_context_)
+ : ControllerBase{system_}, service_context{service_context_} {
latest_vibration_values.fill({DEFAULT_VIBRATION_VALUE, DEFAULT_VIBRATION_VALUE});
}
@@ -253,8 +256,8 @@ void Controller_NPad::InitNewlyAddedController(std::size_t controller_idx) {
void Controller_NPad::OnInit() {
auto& kernel = system.Kernel();
for (std::size_t i = 0; i < styleset_changed_events.size(); ++i) {
- styleset_changed_events[i] = Kernel::KEvent::Create(kernel);
- styleset_changed_events[i]->Initialize(fmt::format("npad:NpadStyleSetChanged_{}", i));
+ styleset_changed_events[i] =
+ service_context.CreateEvent(fmt::format("npad:NpadStyleSetChanged_{}", i));
}
if (!IsControllerActivated()) {
@@ -344,8 +347,7 @@ void Controller_NPad::OnRelease() {
}
for (std::size_t i = 0; i < styleset_changed_events.size(); ++i) {
- styleset_changed_events[i]->Close();
- styleset_changed_events[i] = nullptr;
+ service_context.CloseEvent(styleset_changed_events[i]);
}
}
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index 1409d82a2..4fcc6f93a 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -20,6 +20,10 @@ class KEvent;
class KReadableEvent;
} // namespace Kernel
+namespace Service::KernelHelpers {
+class ServiceContext;
+}
+
namespace Service::HID {
constexpr u32 NPAD_HANDHELD = 32;
@@ -27,7 +31,8 @@ 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_,
+ KernelHelpers::ServiceContext& service_context_);
~Controller_NPad() override;
// Called when the controller is initialized
@@ -566,6 +571,7 @@ private:
std::array<std::unique_ptr<Input::MotionDevice>, Settings::NativeMotion::NUM_MOTIONS_HID>,
10>;
+ KernelHelpers::ServiceContext& service_context;
std::mutex mutex;
ButtonArray buttons;
StickArray sticks;