summaryrefslogtreecommitdiff
path: root/src/input_common/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/helpers')
-rw-r--r--src/input_common/helpers/joycon_driver.cpp2
-rw-r--r--src/input_common/helpers/joycon_protocol/calibration.cpp10
-rw-r--r--src/input_common/helpers/joycon_protocol/calibration.h2
-rw-r--r--src/input_common/helpers/joycon_protocol/common_protocol.cpp6
-rw-r--r--src/input_common/helpers/joycon_protocol/generic_functions.cpp12
-rw-r--r--src/input_common/helpers/joycon_protocol/generic_functions.h2
-rw-r--r--src/input_common/helpers/joycon_protocol/nfc.cpp9
-rw-r--r--src/input_common/helpers/joycon_protocol/nfc.h4
-rw-r--r--src/input_common/helpers/joycon_protocol/ringcon.cpp16
-rw-r--r--src/input_common/helpers/joycon_protocol/ringcon.h4
-rw-r--r--src/input_common/helpers/joycon_protocol/rumble.cpp13
-rw-r--r--src/input_common/helpers/joycon_protocol/rumble.h2
12 files changed, 41 insertions, 41 deletions
diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp
index db9ff4875..8982a2397 100644
--- a/src/input_common/helpers/joycon_driver.cpp
+++ b/src/input_common/helpers/joycon_driver.cpp
@@ -465,7 +465,7 @@ void JoyconDriver::SetCallbacks(const Joycon::JoyconCallbacks& callbacks) {
465 465
466Joycon::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info, 466Joycon::DriverResult JoyconDriver::GetDeviceType(SDL_hid_device_info* device_info,
467 ControllerType& controller_type) { 467 ControllerType& controller_type) {
468 std::array<std::pair<u32, Joycon::ControllerType>, 4> supported_devices{ 468 static constexpr std::array<std::pair<u32, Joycon::ControllerType>, 4> supported_devices{
469 std::pair<u32, Joycon::ControllerType>{0x2006, Joycon::ControllerType::Left}, 469 std::pair<u32, Joycon::ControllerType>{0x2006, Joycon::ControllerType::Left},
470 {0x2007, Joycon::ControllerType::Right}, 470 {0x2007, Joycon::ControllerType::Right},
471 {0x2009, Joycon::ControllerType::Pro}, 471 {0x2009, Joycon::ControllerType::Pro},
diff --git a/src/input_common/helpers/joycon_protocol/calibration.cpp b/src/input_common/helpers/joycon_protocol/calibration.cpp
index ce1ff7061..cd30ab869 100644
--- a/src/input_common/helpers/joycon_protocol/calibration.cpp
+++ b/src/input_common/helpers/joycon_protocol/calibration.cpp
@@ -9,7 +9,7 @@
9namespace InputCommon::Joycon { 9namespace InputCommon::Joycon {
10 10
11CalibrationProtocol::CalibrationProtocol(std::shared_ptr<JoyconHandle> handle) 11CalibrationProtocol::CalibrationProtocol(std::shared_ptr<JoyconHandle> handle)
12 : JoyconCommonProtocol(handle) {} 12 : JoyconCommonProtocol(std::move(handle)) {}
13 13
14DriverResult CalibrationProtocol::GetLeftJoyStickCalibration(JoyStickCalibration& calibration) { 14DriverResult CalibrationProtocol::GetLeftJoyStickCalibration(JoyStickCalibration& calibration) {
15 std::vector<u8> buffer; 15 std::vector<u8> buffer;
@@ -136,12 +136,8 @@ DriverResult CalibrationProtocol::GetRingCalibration(RingCalibration& calibratio
136 ring_data_min = current_value - 800; 136 ring_data_min = current_value - 800;
137 ring_data_default = current_value; 137 ring_data_default = current_value;
138 } 138 }
139 if (ring_data_max < current_value) { 139 ring_data_max = std::max(ring_data_max, current_value);
140 ring_data_max = current_value; 140 ring_data_min = std::min(ring_data_min, current_value);
141 }
142 if (ring_data_min > current_value) {
143 ring_data_min = current_value;
144 }
145 calibration = { 141 calibration = {
146 .default_value = ring_data_default, 142 .default_value = ring_data_default,
147 .max_value = ring_data_max, 143 .max_value = ring_data_max,
diff --git a/src/input_common/helpers/joycon_protocol/calibration.h b/src/input_common/helpers/joycon_protocol/calibration.h
index 32ddef4b8..afb52a36a 100644
--- a/src/input_common/helpers/joycon_protocol/calibration.h
+++ b/src/input_common/helpers/joycon_protocol/calibration.h
@@ -24,7 +24,7 @@ namespace InputCommon::Joycon {
24/// Driver functions related to retrieving calibration data from the device 24/// Driver functions related to retrieving calibration data from the device
25class CalibrationProtocol final : private JoyconCommonProtocol { 25class CalibrationProtocol final : private JoyconCommonProtocol {
26public: 26public:
27 CalibrationProtocol(std::shared_ptr<JoyconHandle> handle); 27 explicit CalibrationProtocol(std::shared_ptr<JoyconHandle> handle);
28 28
29 /** 29 /**
30 * Sends a request to obtain the left stick calibration from memory 30 * Sends a request to obtain the left stick calibration from memory
diff --git a/src/input_common/helpers/joycon_protocol/common_protocol.cpp b/src/input_common/helpers/joycon_protocol/common_protocol.cpp
index 43a036e02..a4d08fdaf 100644
--- a/src/input_common/helpers/joycon_protocol/common_protocol.cpp
+++ b/src/input_common/helpers/joycon_protocol/common_protocol.cpp
@@ -6,7 +6,7 @@
6 6
7namespace InputCommon::Joycon { 7namespace InputCommon::Joycon {
8JoyconCommonProtocol::JoyconCommonProtocol(std::shared_ptr<JoyconHandle> hidapi_handle_) 8JoyconCommonProtocol::JoyconCommonProtocol(std::shared_ptr<JoyconHandle> hidapi_handle_)
9 : hidapi_handle{hidapi_handle_} {} 9 : hidapi_handle{std::move(hidapi_handle_)} {}
10 10
11u8 JoyconCommonProtocol::GetCounter() { 11u8 JoyconCommonProtocol::GetCounter() {
12 hidapi_handle->packet_counter = (hidapi_handle->packet_counter + 1) & 0x0F; 12 hidapi_handle->packet_counter = (hidapi_handle->packet_counter + 1) & 0x0F;
@@ -256,7 +256,7 @@ DriverResult JoyconCommonProtocol::WaitSetMCUMode(ReportMode report_mode, MCUMod
256} 256}
257 257
258// crc-8-ccitt / polynomial 0x07 look up table 258// crc-8-ccitt / polynomial 0x07 look up table
259static constexpr uint8_t mcu_crc8_table[256] = { 259constexpr std::array<u8, 256> mcu_crc8_table = {
260 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D, 260 0x00, 0x07, 0x0E, 0x09, 0x1C, 0x1B, 0x12, 0x15, 0x38, 0x3F, 0x36, 0x31, 0x24, 0x23, 0x2A, 0x2D,
261 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D, 261 0x70, 0x77, 0x7E, 0x79, 0x6C, 0x6B, 0x62, 0x65, 0x48, 0x4F, 0x46, 0x41, 0x54, 0x53, 0x5A, 0x5D,
262 0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD, 262 0xE0, 0xE7, 0xEE, 0xE9, 0xFC, 0xFB, 0xF2, 0xF5, 0xD8, 0xDF, 0xD6, 0xD1, 0xC4, 0xC3, 0xCA, 0xCD,
@@ -278,7 +278,7 @@ u8 JoyconCommonProtocol::CalculateMCU_CRC8(u8* buffer, u8 size) const {
278 u8 crc8 = 0x0; 278 u8 crc8 = 0x0;
279 279
280 for (int i = 0; i < size; ++i) { 280 for (int i = 0; i < size; ++i) {
281 crc8 = mcu_crc8_table[(u8)(crc8 ^ buffer[i])]; 281 crc8 = mcu_crc8_table[static_cast<u8>(crc8 ^ buffer[i])];
282 } 282 }
283 return crc8; 283 return crc8;
284} 284}
diff --git a/src/input_common/helpers/joycon_protocol/generic_functions.cpp b/src/input_common/helpers/joycon_protocol/generic_functions.cpp
index 829f7625d..cbd9ff4f8 100644
--- a/src/input_common/helpers/joycon_protocol/generic_functions.cpp
+++ b/src/input_common/helpers/joycon_protocol/generic_functions.cpp
@@ -7,7 +7,7 @@
7namespace InputCommon::Joycon { 7namespace InputCommon::Joycon {
8 8
9GenericProtocol::GenericProtocol(std::shared_ptr<JoyconHandle> handle) 9GenericProtocol::GenericProtocol(std::shared_ptr<JoyconHandle> handle)
10 : JoyconCommonProtocol(handle) {} 10 : JoyconCommonProtocol(std::move(handle)) {}
11 11
12DriverResult GenericProtocol::EnablePassiveMode() { 12DriverResult GenericProtocol::EnablePassiveMode() {
13 SetBlocking(); 13 SetBlocking();
@@ -43,7 +43,7 @@ DriverResult GenericProtocol::GetControllerType(ControllerType& controller_type)
43} 43}
44 44
45DriverResult GenericProtocol::EnableImu(bool enable) { 45DriverResult GenericProtocol::EnableImu(bool enable) {
46 const std::vector<u8> buffer{static_cast<u8>(enable ? 1 : 0)}; 46 const std::array<u8, 1> buffer{static_cast<u8>(enable ? 1 : 0)};
47 std::vector<u8> output; 47 std::vector<u8> output;
48 SetBlocking(); 48 SetBlocking();
49 const auto result = SendSubCommand(SubCommand::ENABLE_IMU, buffer, output); 49 const auto result = SendSubCommand(SubCommand::ENABLE_IMU, buffer, output);
@@ -54,8 +54,8 @@ DriverResult GenericProtocol::EnableImu(bool enable) {
54DriverResult GenericProtocol::SetImuConfig(GyroSensitivity gsen, GyroPerformance gfrec, 54DriverResult GenericProtocol::SetImuConfig(GyroSensitivity gsen, GyroPerformance gfrec,
55 AccelerometerSensitivity asen, 55 AccelerometerSensitivity asen,
56 AccelerometerPerformance afrec) { 56 AccelerometerPerformance afrec) {
57 const std::vector<u8> buffer{static_cast<u8>(gsen), static_cast<u8>(asen), 57 const std::array<u8, 4> buffer{static_cast<u8>(gsen), static_cast<u8>(asen),
58 static_cast<u8>(gfrec), static_cast<u8>(afrec)}; 58 static_cast<u8>(gfrec), static_cast<u8>(afrec)};
59 std::vector<u8> output; 59 std::vector<u8> output;
60 SetBlocking(); 60 SetBlocking();
61 const auto result = SendSubCommand(SubCommand::SET_IMU_SENSITIVITY, buffer, output); 61 const auto result = SendSubCommand(SubCommand::SET_IMU_SENSITIVITY, buffer, output);
@@ -115,7 +115,7 @@ DriverResult GenericProtocol::GetVersionNumber(FirmwareVersion& version) {
115} 115}
116 116
117DriverResult GenericProtocol::SetHomeLight() { 117DriverResult GenericProtocol::SetHomeLight() {
118 const std::vector<u8> buffer{0x0f, 0xf0, 0x00}; 118 static constexpr std::array<u8, 3> buffer{0x0f, 0xf0, 0x00};
119 std::vector<u8> output; 119 std::vector<u8> output;
120 SetBlocking(); 120 SetBlocking();
121 121
@@ -130,7 +130,7 @@ DriverResult GenericProtocol::SetLedBusy() {
130} 130}
131 131
132DriverResult GenericProtocol::SetLedPattern(u8 leds) { 132DriverResult GenericProtocol::SetLedPattern(u8 leds) {
133 const std::vector<u8> buffer{leds}; 133 const std::array<u8, 1> buffer{leds};
134 std::vector<u8> output; 134 std::vector<u8> output;
135 SetBlocking(); 135 SetBlocking();
136 136
diff --git a/src/input_common/helpers/joycon_protocol/generic_functions.h b/src/input_common/helpers/joycon_protocol/generic_functions.h
index c3e2ccadc..239bb7dbf 100644
--- a/src/input_common/helpers/joycon_protocol/generic_functions.h
+++ b/src/input_common/helpers/joycon_protocol/generic_functions.h
@@ -16,7 +16,7 @@ namespace InputCommon::Joycon {
16/// Joycon driver functions that easily implemented 16/// Joycon driver functions that easily implemented
17class GenericProtocol final : private JoyconCommonProtocol { 17class GenericProtocol final : private JoyconCommonProtocol {
18public: 18public:
19 GenericProtocol(std::shared_ptr<JoyconHandle> handle); 19 explicit GenericProtocol(std::shared_ptr<JoyconHandle> handle);
20 20
21 /// Enables passive mode. This mode only sends button data on change. Sticks will return digital 21 /// Enables passive mode. This mode only sends button data on change. Sticks will return digital
22 /// data instead of analog. Motion will be disabled 22 /// data instead of analog. Motion will be disabled
diff --git a/src/input_common/helpers/joycon_protocol/nfc.cpp b/src/input_common/helpers/joycon_protocol/nfc.cpp
index 69b2bfe05..8755e310b 100644
--- a/src/input_common/helpers/joycon_protocol/nfc.cpp
+++ b/src/input_common/helpers/joycon_protocol/nfc.cpp
@@ -7,7 +7,8 @@
7 7
8namespace InputCommon::Joycon { 8namespace InputCommon::Joycon {
9 9
10NfcProtocol::NfcProtocol(std::shared_ptr<JoyconHandle> handle) : JoyconCommonProtocol(handle) {} 10NfcProtocol::NfcProtocol(std::shared_ptr<JoyconHandle> handle)
11 : JoyconCommonProtocol(std::move(handle)) {}
11 12
12DriverResult NfcProtocol::EnableNfc() { 13DriverResult NfcProtocol::EnableNfc() {
13 LOG_INFO(Input, "Enable NFC"); 14 LOG_INFO(Input, "Enable NFC");
@@ -160,9 +161,9 @@ DriverResult NfcProtocol::ReadTag(const TagFoundData& data) {
160 std::vector<u8> output; 161 std::vector<u8> output;
161 std::size_t tries = 0; 162 std::size_t tries = 0;
162 163
163 std::string uuid_string = ""; 164 std::string uuid_string;
164 for (auto& content : data.uuid) { 165 for (auto& content : data.uuid) {
165 uuid_string += " " + fmt::format("{:02x}", content); 166 uuid_string += fmt::format(" {:02x}", content);
166 } 167 }
167 168
168 LOG_INFO(Input, "Tag detected, type={}, uuid={}", data.type, uuid_string); 169 LOG_INFO(Input, "Tag detected, type={}, uuid={}", data.type, uuid_string);
@@ -407,7 +408,7 @@ NFCReadBlockCommand NfcProtocol::GetReadBlockCommand(std::size_t pages) const {
407 return {}; 408 return {};
408} 409}
409 410
410bool NfcProtocol::IsEnabled() { 411bool NfcProtocol::IsEnabled() const {
411 return is_enabled; 412 return is_enabled;
412} 413}
413 414
diff --git a/src/input_common/helpers/joycon_protocol/nfc.h b/src/input_common/helpers/joycon_protocol/nfc.h
index 0ede03d50..5cb0e5a65 100644
--- a/src/input_common/helpers/joycon_protocol/nfc.h
+++ b/src/input_common/helpers/joycon_protocol/nfc.h
@@ -17,7 +17,7 @@ namespace InputCommon::Joycon {
17 17
18class NfcProtocol final : private JoyconCommonProtocol { 18class NfcProtocol final : private JoyconCommonProtocol {
19public: 19public:
20 NfcProtocol(std::shared_ptr<JoyconHandle> handle); 20 explicit NfcProtocol(std::shared_ptr<JoyconHandle> handle);
21 21
22 DriverResult EnableNfc(); 22 DriverResult EnableNfc();
23 23
@@ -29,7 +29,7 @@ public:
29 29
30 bool HasAmiibo(); 30 bool HasAmiibo();
31 31
32 bool IsEnabled(); 32 bool IsEnabled() const;
33 33
34private: 34private:
35 struct TagFoundData { 35 struct TagFoundData {
diff --git a/src/input_common/helpers/joycon_protocol/ringcon.cpp b/src/input_common/helpers/joycon_protocol/ringcon.cpp
index 47769f344..8adad57dd 100644
--- a/src/input_common/helpers/joycon_protocol/ringcon.cpp
+++ b/src/input_common/helpers/joycon_protocol/ringcon.cpp
@@ -7,7 +7,7 @@
7namespace InputCommon::Joycon { 7namespace InputCommon::Joycon {
8 8
9RingConProtocol::RingConProtocol(std::shared_ptr<JoyconHandle> handle) 9RingConProtocol::RingConProtocol(std::shared_ptr<JoyconHandle> handle)
10 : JoyconCommonProtocol(handle) {} 10 : JoyconCommonProtocol(std::move(handle)) {}
11 11
12DriverResult RingConProtocol::EnableRingCon() { 12DriverResult RingConProtocol::EnableRingCon() {
13 LOG_DEBUG(Input, "Enable Ringcon"); 13 LOG_DEBUG(Input, "Enable Ringcon");
@@ -78,7 +78,7 @@ DriverResult RingConProtocol::IsRingConnected(bool& is_connected) {
78 is_connected = false; 78 is_connected = false;
79 79
80 do { 80 do {
81 std::vector<u8> empty_data(0); 81 std::array<u8, 1> empty_data{};
82 const auto result = SendSubCommand(SubCommand::UNKNOWN_RINGCON, empty_data, output); 82 const auto result = SendSubCommand(SubCommand::UNKNOWN_RINGCON, empty_data, output);
83 83
84 if (result != DriverResult::Success) { 84 if (result != DriverResult::Success) {
@@ -101,11 +101,11 @@ DriverResult RingConProtocol::ConfigureRing() {
101 std::vector<u8> output; 101 std::vector<u8> output;
102 std::size_t tries = 0; 102 std::size_t tries = 0;
103 103
104 static constexpr std::array<u8, 37> ring_config{
105 0x06, 0x03, 0x25, 0x06, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x16, 0xED, 0x34, 0x36,
106 0x00, 0x00, 0x00, 0x0A, 0x64, 0x0B, 0xE6, 0xA9, 0x22, 0x00, 0x00, 0x04, 0x00,
107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xA8, 0xE1, 0x34, 0x36};
104 do { 108 do {
105 std::vector<u8> ring_config{0x06, 0x03, 0x25, 0x06, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x16,
106 0xED, 0x34, 0x36, 0x00, 0x00, 0x00, 0x0A, 0x64, 0x0B, 0xE6,
107 0xA9, 0x22, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
108 0x00, 0x00, 0x90, 0xA8, 0xE1, 0x34, 0x36};
109 result = SendSubCommand(SubCommand::UNKNOWN_RINGCON3, ring_config, output); 109 result = SendSubCommand(SubCommand::UNKNOWN_RINGCON3, ring_config, output);
110 110
111 if (result != DriverResult::Success) { 111 if (result != DriverResult::Success) {
@@ -116,13 +116,13 @@ DriverResult RingConProtocol::ConfigureRing() {
116 } 116 }
117 } while (output[14] != 0x5C); 117 } while (output[14] != 0x5C);
118 118
119 std::vector<u8> ringcon_data{0x04, 0x01, 0x01, 0x02}; 119 static constexpr std::array<u8, 4> ringcon_data{0x04, 0x01, 0x01, 0x02};
120 result = SendSubCommand(SubCommand::UNKNOWN_RINGCON2, ringcon_data, output); 120 result = SendSubCommand(SubCommand::UNKNOWN_RINGCON2, ringcon_data, output);
121 121
122 return result; 122 return result;
123} 123}
124 124
125bool RingConProtocol::IsEnabled() { 125bool RingConProtocol::IsEnabled() const {
126 return is_enabled; 126 return is_enabled;
127} 127}
128 128
diff --git a/src/input_common/helpers/joycon_protocol/ringcon.h b/src/input_common/helpers/joycon_protocol/ringcon.h
index 0c25de23e..6e858f3fc 100644
--- a/src/input_common/helpers/joycon_protocol/ringcon.h
+++ b/src/input_common/helpers/joycon_protocol/ringcon.h
@@ -17,7 +17,7 @@ namespace InputCommon::Joycon {
17 17
18class RingConProtocol final : private JoyconCommonProtocol { 18class RingConProtocol final : private JoyconCommonProtocol {
19public: 19public:
20 RingConProtocol(std::shared_ptr<JoyconHandle> handle); 20 explicit RingConProtocol(std::shared_ptr<JoyconHandle> handle);
21 21
22 DriverResult EnableRingCon(); 22 DriverResult EnableRingCon();
23 23
@@ -25,7 +25,7 @@ public:
25 25
26 DriverResult StartRingconPolling(); 26 DriverResult StartRingconPolling();
27 27
28 bool IsEnabled(); 28 bool IsEnabled() const;
29 29
30private: 30private:
31 DriverResult IsRingConnected(bool& is_connected); 31 DriverResult IsRingConnected(bool& is_connected);
diff --git a/src/input_common/helpers/joycon_protocol/rumble.cpp b/src/input_common/helpers/joycon_protocol/rumble.cpp
index 17ee38863..fad67a94b 100644
--- a/src/input_common/helpers/joycon_protocol/rumble.cpp
+++ b/src/input_common/helpers/joycon_protocol/rumble.cpp
@@ -1,17 +1,20 @@
1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include <algorithm>
5#include <cmath>
6
4#include "common/logging/log.h" 7#include "common/logging/log.h"
5#include "input_common/helpers/joycon_protocol/rumble.h" 8#include "input_common/helpers/joycon_protocol/rumble.h"
6 9
7namespace InputCommon::Joycon { 10namespace InputCommon::Joycon {
8 11
9RumbleProtocol::RumbleProtocol(std::shared_ptr<JoyconHandle> handle) 12RumbleProtocol::RumbleProtocol(std::shared_ptr<JoyconHandle> handle)
10 : JoyconCommonProtocol(handle) {} 13 : JoyconCommonProtocol(std::move(handle)) {}
11 14
12DriverResult RumbleProtocol::EnableRumble(bool is_enabled) { 15DriverResult RumbleProtocol::EnableRumble(bool is_enabled) {
13 LOG_DEBUG(Input, "Enable Rumble"); 16 LOG_DEBUG(Input, "Enable Rumble");
14 const std::vector<u8> buffer{static_cast<u8>(is_enabled ? 1 : 0)}; 17 const std::array<u8, 1> buffer{static_cast<u8>(is_enabled ? 1 : 0)};
15 std::vector<u8> output; 18 std::vector<u8> output;
16 SetBlocking(); 19 SetBlocking();
17 const auto result = SendSubCommand(SubCommand::ENABLE_VIBRATION, buffer, output); 20 const auto result = SendSubCommand(SubCommand::ENABLE_VIBRATION, buffer, output);
@@ -20,7 +23,7 @@ DriverResult RumbleProtocol::EnableRumble(bool is_enabled) {
20} 23}
21 24
22DriverResult RumbleProtocol::SendVibration(const VibrationValue& vibration) { 25DriverResult RumbleProtocol::SendVibration(const VibrationValue& vibration) {
23 std::vector<u8> buffer(sizeof(DefaultVibrationBuffer)); 26 std::array<u8, sizeof(DefaultVibrationBuffer)> buffer{};
24 27
25 if (vibration.high_amplitude <= 0.0f && vibration.low_amplitude <= 0.0f) { 28 if (vibration.high_amplitude <= 0.0f && vibration.low_amplitude <= 0.0f) {
26 return SendVibrationReport(DefaultVibrationBuffer); 29 return SendVibrationReport(DefaultVibrationBuffer);
@@ -66,7 +69,7 @@ u8 RumbleProtocol::EncodeHighAmplitude(f32 amplitude) const {
66 /* More information about these values can be found here: 69 /* More information about these values can be found here:
67 * https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md 70 * https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md
68 */ 71 */
69 constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{ 72 static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{
70 std::pair<f32, int>{0.0f, 0x0}, 73 std::pair<f32, int>{0.0f, 0x0},
71 {0.01f, 0x2}, 74 {0.01f, 0x2},
72 {0.012f, 0x4}, 75 {0.012f, 0x4},
@@ -183,7 +186,7 @@ u16 RumbleProtocol::EncodeLowAmplitude(f32 amplitude) const {
183 /* More information about these values can be found here: 186 /* More information about these values can be found here:
184 * https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md 187 * https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md
185 */ 188 */
186 constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{ 189 static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{
187 std::pair<f32, int>{0.0f, 0x0040}, 190 std::pair<f32, int>{0.0f, 0x0040},
188 {0.01f, 0x8040}, 191 {0.01f, 0x8040},
189 {0.012f, 0x0041}, 192 {0.012f, 0x0041},
diff --git a/src/input_common/helpers/joycon_protocol/rumble.h b/src/input_common/helpers/joycon_protocol/rumble.h
index 7d0329f03..6c12b7925 100644
--- a/src/input_common/helpers/joycon_protocol/rumble.h
+++ b/src/input_common/helpers/joycon_protocol/rumble.h
@@ -17,7 +17,7 @@ namespace InputCommon::Joycon {
17 17
18class RumbleProtocol final : private JoyconCommonProtocol { 18class RumbleProtocol final : private JoyconCommonProtocol {
19public: 19public:
20 RumbleProtocol(std::shared_ptr<JoyconHandle> handle); 20 explicit RumbleProtocol(std::shared_ptr<JoyconHandle> handle);
21 21
22 DriverResult EnableRumble(bool is_enabled); 22 DriverResult EnableRumble(bool is_enabled);
23 23