diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2022-12-20 20:27:34 -0600 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2023-01-19 18:05:21 -0600 |
commit | f09a023292e659af46d551b9b134d94d000a57c7 (patch) | |
tree | f34ef390cac9f32f7d807614505601635ac62e28 /src/input_common/helpers/joycon_protocol/rumble.h | |
parent | 5676c2e17fe895e450e185029991fc20bdf56ec5 (diff) |
input_common: Add support for joycon input reports
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/rumble.h')
-rw-r--r-- | src/input_common/helpers/joycon_protocol/rumble.h | 33 |
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 |