summaryrefslogtreecommitdiffstats
path: root/src/input_common/helpers/joycon_protocol/rumble.h
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2022-12-21 03:27:34 +0100
committerNarr the Reg <juangerman-13@hotmail.com>2023-01-20 01:05:21 +0100
commitf09a023292e659af46d551b9b134d94d000a57c7 (patch)
treef34ef390cac9f32f7d807614505601635ac62e28 /src/input_common/helpers/joycon_protocol/rumble.h
parentinput_common: Use calibration from joycon (diff)
downloadyuzu-f09a023292e659af46d551b9b134d94d000a57c7.tar
yuzu-f09a023292e659af46d551b9b134d94d000a57c7.tar.gz
yuzu-f09a023292e659af46d551b9b134d94d000a57c7.tar.bz2
yuzu-f09a023292e659af46d551b9b134d94d000a57c7.tar.lz
yuzu-f09a023292e659af46d551b9b134d94d000a57c7.tar.xz
yuzu-f09a023292e659af46d551b9b134d94d000a57c7.tar.zst
yuzu-f09a023292e659af46d551b9b134d94d000a57c7.zip
Diffstat (limited to '')
-rw-r--r--src/input_common/helpers/joycon_protocol/rumble.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/input_common/helpers/joycon_protocol/rumble.h b/src/input_common/helpers/joycon_protocol/rumble.h
new file mode 100644
index 000000000..7d0329f03
--- /dev/null
+++ b/src/input_common/helpers/joycon_protocol/rumble.h
@@ -0,0 +1,33 @@
+// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+// Based on dkms-hid-nintendo implementation, CTCaer joycon toolkit and dekuNukem reverse
+// engineering https://github.com/nicman23/dkms-hid-nintendo/blob/master/src/hid-nintendo.c
+// https://github.com/CTCaer/jc_toolkit
+// https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering
+
+#pragma once
+
+#include <vector>
+
+#include "input_common/helpers/joycon_protocol/common_protocol.h"
+#include "input_common/helpers/joycon_protocol/joycon_types.h"
+
+namespace InputCommon::Joycon {
+
+class RumbleProtocol final : private JoyconCommonProtocol {
+public:
+ RumbleProtocol(std::shared_ptr<JoyconHandle> handle);
+
+ DriverResult EnableRumble(bool is_enabled);
+
+ DriverResult SendVibration(const VibrationValue& vibration);
+
+private:
+ u16 EncodeHighFrequency(f32 frequency) const;
+ u8 EncodeLowFrequency(f32 frequency) const;
+ u8 EncodeHighAmplitude(f32 amplitude) const;
+ u16 EncodeLowAmplitude(f32 amplitude) const;
+};
+
+} // namespace InputCommon::Joycon