summaryrefslogtreecommitdiff
path: root/src/input_common/helpers/joycon_protocol/rumble.cpp
diff options
context:
space:
mode:
authorGravatar german772023-01-13 23:29:05 -0600
committerGravatar Narr the Reg2023-01-20 00:51:45 -0600
commit340f15d1fa79594dbe12a6e19140ba012751b533 (patch)
tree7a9ef54a17f927e4b8cf98dd32dd6d41c0d75201 /src/input_common/helpers/joycon_protocol/rumble.cpp
parentcore: hid: Only set the polling mode to the correct side (diff)
downloadyuzu-340f15d1fa79594dbe12a6e19140ba012751b533.tar.gz
yuzu-340f15d1fa79594dbe12a6e19140ba012751b533.tar.xz
yuzu-340f15d1fa79594dbe12a6e19140ba012751b533.zip
input_common: Address byte review
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/rumble.cpp')
-rw-r--r--src/input_common/helpers/joycon_protocol/rumble.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/input_common/helpers/joycon_protocol/rumble.cpp b/src/input_common/helpers/joycon_protocol/rumble.cpp
index fad67a94b..63b60c946 100644
--- a/src/input_common/helpers/joycon_protocol/rumble.cpp
+++ b/src/input_common/helpers/joycon_protocol/rumble.cpp
@@ -14,12 +14,9 @@ RumbleProtocol::RumbleProtocol(std::shared_ptr<JoyconHandle> handle)
14 14
15DriverResult RumbleProtocol::EnableRumble(bool is_enabled) { 15DriverResult RumbleProtocol::EnableRumble(bool is_enabled) {
16 LOG_DEBUG(Input, "Enable Rumble"); 16 LOG_DEBUG(Input, "Enable Rumble");
17 ScopedSetBlocking sb(this);
17 const std::array<u8, 1> buffer{static_cast<u8>(is_enabled ? 1 : 0)}; 18 const std::array<u8, 1> buffer{static_cast<u8>(is_enabled ? 1 : 0)};
18 std::vector<u8> output; 19 return SendSubCommand(SubCommand::ENABLE_VIBRATION, buffer);
19 SetBlocking();
20 const auto result = SendSubCommand(SubCommand::ENABLE_VIBRATION, buffer, output);
21 SetNonBlocking();
22 return result;
23} 20}
24 21
25DriverResult RumbleProtocol::SendVibration(const VibrationValue& vibration) { 22DriverResult RumbleProtocol::SendVibration(const VibrationValue& vibration) {
@@ -66,9 +63,9 @@ u8 RumbleProtocol::EncodeLowFrequency(f32 frequency) const {
66} 63}
67 64
68u8 RumbleProtocol::EncodeHighAmplitude(f32 amplitude) const { 65u8 RumbleProtocol::EncodeHighAmplitude(f32 amplitude) const {
69 /* More information about these values can be found here: 66 // More information about these values can be found here:
70 * https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md 67 // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md
71 */ 68
72 static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{ 69 static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{
73 std::pair<f32, int>{0.0f, 0x0}, 70 std::pair<f32, int>{0.0f, 0x0},
74 {0.01f, 0x2}, 71 {0.01f, 0x2},
@@ -183,9 +180,9 @@ u8 RumbleProtocol::EncodeHighAmplitude(f32 amplitude) const {
183} 180}
184 181
185u16 RumbleProtocol::EncodeLowAmplitude(f32 amplitude) const { 182u16 RumbleProtocol::EncodeLowAmplitude(f32 amplitude) const {
186 /* More information about these values can be found here: 183 // More information about these values can be found here:
187 * https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md 184 // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md
188 */ 185
189 static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{ 186 static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{
190 std::pair<f32, int>{0.0f, 0x0040}, 187 std::pair<f32, int>{0.0f, 0x0040},
191 {0.01f, 0x8040}, 188 {0.01f, 0x8040},