summaryrefslogtreecommitdiffstats
path: root/src/hid_core/resources/abstracted_pad/abstract_vibration_handler.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/hid_core/resources/abstracted_pad/abstract_vibration_handler.h')
-rw-r--r--src/hid_core/resources/abstracted_pad/abstract_vibration_handler.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/hid_core/resources/abstracted_pad/abstract_vibration_handler.h b/src/hid_core/resources/abstracted_pad/abstract_vibration_handler.h
new file mode 100644
index 000000000..aeb07ce86
--- /dev/null
+++ b/src/hid_core/resources/abstracted_pad/abstract_vibration_handler.h
@@ -0,0 +1,51 @@
+// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#pragma once
+
+#include <span>
+
+#include "common/common_types.h"
+#include "core/hle/result.h"
+#include "hid_core/hid_types.h"
+
+namespace Service::HID {
+struct AppletResourceHolder;
+class NpadAbstractedPadHolder;
+class NpadAbstractPropertiesHandler;
+class NpadGcVibrationDevice;
+class NpadVibrationDevice;
+class NpadN64VibrationDevice;
+class NpadVibration;
+
+/// Keeps track of battery levels and updates npad battery shared memory values
+class NpadAbstractVibrationHandler final {
+public:
+ explicit NpadAbstractVibrationHandler();
+ ~NpadAbstractVibrationHandler();
+
+ void SetAbstractPadHolder(NpadAbstractedPadHolder* holder);
+ void SetAppletResource(AppletResourceHolder* applet_resource);
+ void SetPropertiesHandler(NpadAbstractPropertiesHandler* handler);
+
+ void SetN64Vibration(NpadN64VibrationDevice* n64_device);
+ void SetVibration(std::span<NpadVibrationDevice*> device);
+ void SetGcVibration(NpadGcVibrationDevice* gc_device);
+
+ Result IncrementRefCounter();
+ Result DecrementRefCounter();
+
+ void UpdateVibrationState();
+
+private:
+ AppletResourceHolder* applet_resource_holder{nullptr};
+ NpadAbstractedPadHolder* abstract_pad_holder{nullptr};
+ NpadAbstractPropertiesHandler* properties_handler{nullptr};
+
+ NpadN64VibrationDevice* n64_vibration_device{nullptr};
+ std::array<NpadVibrationDevice*, 2> vibration_device{};
+ NpadGcVibrationDevice* gc_vibration_device{nullptr};
+ NpadVibration* vibration_handler{nullptr};
+ s32 ref_counter{};
+};
+} // namespace Service::HID