summaryrefslogtreecommitdiff
path: root/src/input_common/helpers/joycon_protocol
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common/helpers/joycon_protocol')
-rw-r--r--src/input_common/helpers/joycon_protocol/irs.cpp4
-rw-r--r--src/input_common/helpers/joycon_protocol/joycon_types.h6
-rw-r--r--src/input_common/helpers/joycon_protocol/nfc.cpp8
-rw-r--r--src/input_common/helpers/joycon_protocol/rumble.cpp12
4 files changed, 15 insertions, 15 deletions
diff --git a/src/input_common/helpers/joycon_protocol/irs.cpp b/src/input_common/helpers/joycon_protocol/irs.cpp
index 68b0589e3..5bf72114d 100644
--- a/src/input_common/helpers/joycon_protocol/irs.cpp
+++ b/src/input_common/helpers/joycon_protocol/irs.cpp
@@ -236,9 +236,9 @@ Common::Input::DriverResult IrsProtocol::WriteRegistersStep2() {
236 .number_of_registers = 0x8, 236 .number_of_registers = 0x8,
237 .registers = 237 .registers =
238 { 238 {
239 IrsRegister{IrRegistersAddress::LedIntensitiyMSB, 239 IrsRegister{IrRegistersAddress::LedIntensityMSB,
240 static_cast<u8>(led_intensity >> 8)}, 240 static_cast<u8>(led_intensity >> 8)},
241 {IrRegistersAddress::LedIntensitiyLSB, static_cast<u8>(led_intensity & 0xff)}, 241 {IrRegistersAddress::LedIntensityLSB, static_cast<u8>(led_intensity & 0xff)},
242 {IrRegistersAddress::ImageFlip, static_cast<u8>(image_flip)}, 242 {IrRegistersAddress::ImageFlip, static_cast<u8>(image_flip)},
243 {IrRegistersAddress::DenoiseSmoothing, static_cast<u8>((denoise >> 16) & 0xff)}, 243 {IrRegistersAddress::DenoiseSmoothing, static_cast<u8>((denoise >> 16) & 0xff)},
244 {IrRegistersAddress::DenoiseEdge, static_cast<u8>((denoise >> 8) & 0xff)}, 244 {IrRegistersAddress::DenoiseEdge, static_cast<u8>((denoise >> 8) & 0xff)},
diff --git a/src/input_common/helpers/joycon_protocol/joycon_types.h b/src/input_common/helpers/joycon_protocol/joycon_types.h
index 77a43c67a..792f124e1 100644
--- a/src/input_common/helpers/joycon_protocol/joycon_types.h
+++ b/src/input_common/helpers/joycon_protocol/joycon_types.h
@@ -282,7 +282,7 @@ enum class NFCCommand : u8 {
282 CancelAll = 0x00, 282 CancelAll = 0x00,
283 StartPolling = 0x01, 283 StartPolling = 0x01,
284 StopPolling = 0x02, 284 StopPolling = 0x02,
285 StartWaitingRecieve = 0x04, 285 StartWaitingReceive = 0x04,
286 ReadNtag = 0x06, 286 ReadNtag = 0x06,
287 WriteNtag = 0x08, 287 WriteNtag = 0x08,
288 Mifare = 0x0F, 288 Mifare = 0x0F,
@@ -382,8 +382,8 @@ enum class IrRegistersAddress : u16 {
382 FinalizeConfig = 0x0700, 382 FinalizeConfig = 0x0700,
383 LedFilter = 0x0e00, 383 LedFilter = 0x0e00,
384 Leds = 0x1000, 384 Leds = 0x1000,
385 LedIntensitiyMSB = 0x1100, 385 LedIntensityMSB = 0x1100,
386 LedIntensitiyLSB = 0x1200, 386 LedIntensityLSB = 0x1200,
387 ImageFlip = 0x2d00, 387 ImageFlip = 0x2d00,
388 Resolution = 0x2e00, 388 Resolution = 0x2e00,
389 DigitalGainLSB = 0x2e01, 389 DigitalGainLSB = 0x2e01,
diff --git a/src/input_common/helpers/joycon_protocol/nfc.cpp b/src/input_common/helpers/joycon_protocol/nfc.cpp
index 09953394b..db83f9ef4 100644
--- a/src/input_common/helpers/joycon_protocol/nfc.cpp
+++ b/src/input_common/helpers/joycon_protocol/nfc.cpp
@@ -519,13 +519,13 @@ Common::Input::DriverResult NfcProtocol::GetMifareData(
519 } 519 }
520 520
521 if (output.mcu_report == MCUReport::NFCState && output.mcu_data[1] == 0x10) { 521 if (output.mcu_report == MCUReport::NFCState && output.mcu_data[1] == 0x10) {
522 constexpr std::size_t DATA_LENGHT = 0x10 + 1; 522 constexpr std::size_t DATA_LENGTH = 0x10 + 1;
523 constexpr std::size_t DATA_START = 11; 523 constexpr std::size_t DATA_START = 11;
524 const u8 number_of_elements = output.mcu_data[10]; 524 const u8 number_of_elements = output.mcu_data[10];
525 for (std::size_t i = 0; i < number_of_elements; i++) { 525 for (std::size_t i = 0; i < number_of_elements; i++) {
526 out_data[i].sector = output.mcu_data[DATA_START + (i * DATA_LENGHT)]; 526 out_data[i].sector = output.mcu_data[DATA_START + (i * DATA_LENGTH)];
527 memcpy(out_data[i].data.data(), 527 memcpy(out_data[i].data.data(),
528 output.mcu_data.data() + DATA_START + 1 + (i * DATA_LENGHT), 528 output.mcu_data.data() + DATA_START + 1 + (i * DATA_LENGTH),
529 sizeof(MifareReadData::data)); 529 sizeof(MifareReadData::data));
530 } 530 }
531 package_index++; 531 package_index++;
@@ -659,7 +659,7 @@ Common::Input::DriverResult NfcProtocol::SendStopPollingRequest(MCUCommandRespon
659Common::Input::DriverResult NfcProtocol::SendNextPackageRequest(MCUCommandResponse& output, 659Common::Input::DriverResult NfcProtocol::SendNextPackageRequest(MCUCommandResponse& output,
660 u8 packet_id) { 660 u8 packet_id) {
661 NFCRequestState request{ 661 NFCRequestState request{
662 .command_argument = NFCCommand::StartWaitingRecieve, 662 .command_argument = NFCCommand::StartWaitingReceive,
663 .block_id = {}, 663 .block_id = {},
664 .packet_id = packet_id, 664 .packet_id = packet_id,
665 .packet_flag = MCUPacketFlag::LastCommandPacket, 665 .packet_flag = MCUPacketFlag::LastCommandPacket,
diff --git a/src/input_common/helpers/joycon_protocol/rumble.cpp b/src/input_common/helpers/joycon_protocol/rumble.cpp
index 7647f505e..9fd0b8470 100644
--- a/src/input_common/helpers/joycon_protocol/rumble.cpp
+++ b/src/input_common/helpers/joycon_protocol/rumble.cpp
@@ -67,7 +67,7 @@ u8 RumbleProtocol::EncodeHighAmplitude(f32 amplitude) const {
67 // More information about these values can be found here: 67 // More information about these values can be found here:
68 // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md 68 // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md
69 69
70 static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{ 70 static constexpr std::array<std::pair<f32, int>, 101> high_frequency_amplitude{
71 std::pair<f32, int>{0.0f, 0x0}, 71 std::pair<f32, int>{0.0f, 0x0},
72 {0.01f, 0x2}, 72 {0.01f, 0x2},
73 {0.012f, 0x4}, 73 {0.012f, 0x4},
@@ -171,20 +171,20 @@ u8 RumbleProtocol::EncodeHighAmplitude(f32 amplitude) const {
171 {1.003f, 0xc8}, 171 {1.003f, 0xc8},
172 }; 172 };
173 173
174 for (const auto& [amplitude_value, code] : high_fequency_amplitude) { 174 for (const auto& [amplitude_value, code] : high_frequency_amplitude) {
175 if (amplitude <= amplitude_value) { 175 if (amplitude <= amplitude_value) {
176 return static_cast<u8>(code); 176 return static_cast<u8>(code);
177 } 177 }
178 } 178 }
179 179
180 return static_cast<u8>(high_fequency_amplitude[high_fequency_amplitude.size() - 1].second); 180 return static_cast<u8>(high_frequency_amplitude[high_frequency_amplitude.size() - 1].second);
181} 181}
182 182
183u16 RumbleProtocol::EncodeLowAmplitude(f32 amplitude) const { 183u16 RumbleProtocol::EncodeLowAmplitude(f32 amplitude) const {
184 // More information about these values can be found here: 184 // More information about these values can be found here:
185 // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md 185 // https://github.com/dekuNukem/Nintendo_Switch_Reverse_Engineering/blob/master/rumble_data_table.md
186 186
187 static constexpr std::array<std::pair<f32, int>, 101> high_fequency_amplitude{ 187 static constexpr std::array<std::pair<f32, int>, 101> high_frequency_amplitude{
188 std::pair<f32, int>{0.0f, 0x0040}, 188 std::pair<f32, int>{0.0f, 0x0040},
189 {0.01f, 0x8040}, 189 {0.01f, 0x8040},
190 {0.012f, 0x0041}, 190 {0.012f, 0x0041},
@@ -288,13 +288,13 @@ u16 RumbleProtocol::EncodeLowAmplitude(f32 amplitude) const {
288 {1.003f, 0x0072}, 288 {1.003f, 0x0072},
289 }; 289 };
290 290
291 for (const auto& [amplitude_value, code] : high_fequency_amplitude) { 291 for (const auto& [amplitude_value, code] : high_frequency_amplitude) {
292 if (amplitude <= amplitude_value) { 292 if (amplitude <= amplitude_value) {
293 return static_cast<u16>(code); 293 return static_cast<u16>(code);
294 } 294 }
295 } 295 }
296 296
297 return static_cast<u16>(high_fequency_amplitude[high_fequency_amplitude.size() - 1].second); 297 return static_cast<u16>(high_frequency_amplitude[high_frequency_amplitude.size() - 1].second);
298} 298}
299 299
300} // namespace InputCommon::Joycon 300} // namespace InputCommon::Joycon