diff options
| author | 2023-01-30 09:02:12 -0500 | |
|---|---|---|
| committer | 2023-01-30 09:02:12 -0500 | |
| commit | e74660673b68e7226b7e934efe5eac620f7a98e6 (patch) | |
| tree | 355def233607668733581b2b5194d0e54e1b7995 /src/input_common/helpers/joycon_protocol/ringcon.cpp | |
| parent | Merge pull request #9631 from vonchenplus/vulkan_clear (diff) | |
| parent | input_common: joycon: Remove Magic numbers from common protocol (diff) | |
| download | yuzu-e74660673b68e7226b7e934efe5eac620f7a98e6.tar.gz yuzu-e74660673b68e7226b7e934efe5eac620f7a98e6.tar.xz yuzu-e74660673b68e7226b7e934efe5eac620f7a98e6.zip | |
Merge pull request #9701 from german77/common_protocol
input_common: joycon: Remove Magic numbers from common protocol
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/ringcon.cpp')
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/ringcon.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/input_common/helpers/joycon_protocol/ringcon.cpp b/src/input_common/helpers/joycon_protocol/ringcon.cpp index 12f81309e..190cef812 100644 --- a/src/input_common/helpers/joycon_protocol/ringcon.cpp +++ b/src/input_common/helpers/joycon_protocol/ringcon.cpp | |||
| @@ -70,14 +70,12 @@ DriverResult RingConProtocol::StartRingconPolling() { | |||
| 70 | DriverResult RingConProtocol::IsRingConnected(bool& is_connected) { | 70 | DriverResult RingConProtocol::IsRingConnected(bool& is_connected) { |
| 71 | LOG_DEBUG(Input, "IsRingConnected"); | 71 | LOG_DEBUG(Input, "IsRingConnected"); |
| 72 | constexpr std::size_t max_tries = 28; | 72 | constexpr std::size_t max_tries = 28; |
| 73 | constexpr u8 ring_controller_id = 0x20; | 73 | SubCommandResponse output{}; |
| 74 | std::vector<u8> output; | ||
| 75 | std::size_t tries = 0; | 74 | std::size_t tries = 0; |
| 76 | is_connected = false; | 75 | is_connected = false; |
| 77 | 76 | ||
| 78 | do { | 77 | do { |
| 79 | std::array<u8, 1> empty_data{}; | 78 | const auto result = SendSubCommand(SubCommand::GET_EXTERNAL_DEVICE_INFO, {}, output); |
| 80 | const auto result = SendSubCommand(SubCommand::UNKNOWN_RINGCON, empty_data, output); | ||
| 81 | 79 | ||
| 82 | if (result != DriverResult::Success) { | 80 | if (result != DriverResult::Success) { |
| 83 | return result; | 81 | return result; |
| @@ -86,7 +84,7 @@ DriverResult RingConProtocol::IsRingConnected(bool& is_connected) { | |||
| 86 | if (tries++ >= max_tries) { | 84 | if (tries++ >= max_tries) { |
| 87 | return DriverResult::NoDeviceDetected; | 85 | return DriverResult::NoDeviceDetected; |
| 88 | } | 86 | } |
| 89 | } while (output[16] != ring_controller_id); | 87 | } while (output.external_device_id != ExternalDeviceId::RingController); |
| 90 | 88 | ||
| 91 | is_connected = true; | 89 | is_connected = true; |
| 92 | return DriverResult::Success; | 90 | return DriverResult::Success; |
| @@ -100,14 +98,14 @@ DriverResult RingConProtocol::ConfigureRing() { | |||
| 100 | 0x00, 0x00, 0x00, 0x0A, 0x64, 0x0B, 0xE6, 0xA9, 0x22, 0x00, 0x00, 0x04, 0x00, | 98 | 0x00, 0x00, 0x00, 0x0A, 0x64, 0x0B, 0xE6, 0xA9, 0x22, 0x00, 0x00, 0x04, 0x00, |
| 101 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xA8, 0xE1, 0x34, 0x36}; | 99 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xA8, 0xE1, 0x34, 0x36}; |
| 102 | 100 | ||
| 103 | const DriverResult result = SendSubCommand(SubCommand::UNKNOWN_RINGCON3, ring_config); | 101 | const DriverResult result = SendSubCommand(SubCommand::SET_EXTERNAL_FORMAT_CONFIG, ring_config); |
| 104 | 102 | ||
| 105 | if (result != DriverResult::Success) { | 103 | if (result != DriverResult::Success) { |
| 106 | return result; | 104 | return result; |
| 107 | } | 105 | } |
| 108 | 106 | ||
| 109 | static constexpr std::array<u8, 4> ringcon_data{0x04, 0x01, 0x01, 0x02}; | 107 | static constexpr std::array<u8, 4> ringcon_data{0x04, 0x01, 0x01, 0x02}; |
| 110 | return SendSubCommand(SubCommand::UNKNOWN_RINGCON2, ringcon_data); | 108 | return SendSubCommand(SubCommand::ENABLE_EXTERNAL_POLLING, ringcon_data); |
| 111 | } | 109 | } |
| 112 | 110 | ||
| 113 | bool RingConProtocol::IsEnabled() const { | 111 | bool RingConProtocol::IsEnabled() const { |