diff options
| author | 2023-06-28 00:20:38 -0600 | |
|---|---|---|
| committer | 2023-06-28 09:49:47 -0600 | |
| commit | df9685a21c105962e90dbd95133c5a1bcef7886f (patch) | |
| tree | acfd98ca20286dca669077b165943f6c4af711a6 /src/input_common/helpers/joycon_protocol/ringcon.cpp | |
| parent | Merge pull request #10933 from merryhime/dunno (diff) | |
| download | yuzu-df9685a21c105962e90dbd95133c5a1bcef7886f.tar.gz yuzu-df9685a21c105962e90dbd95133c5a1bcef7886f.tar.xz yuzu-df9685a21c105962e90dbd95133c5a1bcef7886f.zip | |
input_common: Remove duplicated DriverResult enum
Diffstat (limited to 'src/input_common/helpers/joycon_protocol/ringcon.cpp')
| -rw-r--r-- | src/input_common/helpers/joycon_protocol/ringcon.cpp | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/src/input_common/helpers/joycon_protocol/ringcon.cpp b/src/input_common/helpers/joycon_protocol/ringcon.cpp index 190cef812..f31ff6b34 100644 --- a/src/input_common/helpers/joycon_protocol/ringcon.cpp +++ b/src/input_common/helpers/joycon_protocol/ringcon.cpp | |||
| @@ -1,6 +1,7 @@ | |||
| 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 "common/input.h" | ||
| 4 | #include "common/logging/log.h" | 5 | #include "common/logging/log.h" |
| 5 | #include "input_common/helpers/joycon_protocol/ringcon.h" | 6 | #include "input_common/helpers/joycon_protocol/ringcon.h" |
| 6 | 7 | ||
| @@ -9,18 +10,18 @@ namespace InputCommon::Joycon { | |||
| 9 | RingConProtocol::RingConProtocol(std::shared_ptr<JoyconHandle> handle) | 10 | RingConProtocol::RingConProtocol(std::shared_ptr<JoyconHandle> handle) |
| 10 | : JoyconCommonProtocol(std::move(handle)) {} | 11 | : JoyconCommonProtocol(std::move(handle)) {} |
| 11 | 12 | ||
| 12 | DriverResult RingConProtocol::EnableRingCon() { | 13 | Common::Input::DriverResult RingConProtocol::EnableRingCon() { |
| 13 | LOG_DEBUG(Input, "Enable Ringcon"); | 14 | LOG_DEBUG(Input, "Enable Ringcon"); |
| 14 | ScopedSetBlocking sb(this); | 15 | ScopedSetBlocking sb(this); |
| 15 | DriverResult result{DriverResult::Success}; | 16 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 16 | 17 | ||
| 17 | if (result == DriverResult::Success) { | 18 | if (result == Common::Input::DriverResult::Success) { |
| 18 | result = SetReportMode(ReportMode::STANDARD_FULL_60HZ); | 19 | result = SetReportMode(ReportMode::STANDARD_FULL_60HZ); |
| 19 | } | 20 | } |
| 20 | if (result == DriverResult::Success) { | 21 | if (result == Common::Input::DriverResult::Success) { |
| 21 | result = EnableMCU(true); | 22 | result = EnableMCU(true); |
| 22 | } | 23 | } |
| 23 | if (result == DriverResult::Success) { | 24 | if (result == Common::Input::DriverResult::Success) { |
| 24 | const MCUConfig config{ | 25 | const MCUConfig config{ |
| 25 | .command = MCUCommand::ConfigureMCU, | 26 | .command = MCUCommand::ConfigureMCU, |
| 26 | .sub_command = MCUSubCommand::SetDeviceMode, | 27 | .sub_command = MCUSubCommand::SetDeviceMode, |
| @@ -33,12 +34,12 @@ DriverResult RingConProtocol::EnableRingCon() { | |||
| 33 | return result; | 34 | return result; |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | DriverResult RingConProtocol::DisableRingCon() { | 37 | Common::Input::DriverResult RingConProtocol::DisableRingCon() { |
| 37 | LOG_DEBUG(Input, "Disable RingCon"); | 38 | LOG_DEBUG(Input, "Disable RingCon"); |
| 38 | ScopedSetBlocking sb(this); | 39 | ScopedSetBlocking sb(this); |
| 39 | DriverResult result{DriverResult::Success}; | 40 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 40 | 41 | ||
| 41 | if (result == DriverResult::Success) { | 42 | if (result == Common::Input::DriverResult::Success) { |
| 42 | result = EnableMCU(false); | 43 | result = EnableMCU(false); |
| 43 | } | 44 | } |
| 44 | 45 | ||
| @@ -47,27 +48,27 @@ DriverResult RingConProtocol::DisableRingCon() { | |||
| 47 | return result; | 48 | return result; |
| 48 | } | 49 | } |
| 49 | 50 | ||
| 50 | DriverResult RingConProtocol::StartRingconPolling() { | 51 | Common::Input::DriverResult RingConProtocol::StartRingconPolling() { |
| 51 | LOG_DEBUG(Input, "Enable Ringcon"); | 52 | LOG_DEBUG(Input, "Enable Ringcon"); |
| 52 | ScopedSetBlocking sb(this); | 53 | ScopedSetBlocking sb(this); |
| 53 | DriverResult result{DriverResult::Success}; | 54 | Common::Input::DriverResult result{Common::Input::DriverResult::Success}; |
| 54 | bool is_connected = false; | 55 | bool is_connected = false; |
| 55 | 56 | ||
| 56 | if (result == DriverResult::Success) { | 57 | if (result == Common::Input::DriverResult::Success) { |
| 57 | result = IsRingConnected(is_connected); | 58 | result = IsRingConnected(is_connected); |
| 58 | } | 59 | } |
| 59 | if (result == DriverResult::Success && is_connected) { | 60 | if (result == Common::Input::DriverResult::Success && is_connected) { |
| 60 | LOG_INFO(Input, "Ringcon detected"); | 61 | LOG_INFO(Input, "Ringcon detected"); |
| 61 | result = ConfigureRing(); | 62 | result = ConfigureRing(); |
| 62 | } | 63 | } |
| 63 | if (result == DriverResult::Success) { | 64 | if (result == Common::Input::DriverResult::Success) { |
| 64 | is_enabled = true; | 65 | is_enabled = true; |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | return result; | 68 | return result; |
| 68 | } | 69 | } |
| 69 | 70 | ||
| 70 | DriverResult RingConProtocol::IsRingConnected(bool& is_connected) { | 71 | Common::Input::DriverResult RingConProtocol::IsRingConnected(bool& is_connected) { |
| 71 | LOG_DEBUG(Input, "IsRingConnected"); | 72 | LOG_DEBUG(Input, "IsRingConnected"); |
| 72 | constexpr std::size_t max_tries = 28; | 73 | constexpr std::size_t max_tries = 28; |
| 73 | SubCommandResponse output{}; | 74 | SubCommandResponse output{}; |
| @@ -77,20 +78,20 @@ DriverResult RingConProtocol::IsRingConnected(bool& is_connected) { | |||
| 77 | do { | 78 | do { |
| 78 | const auto result = SendSubCommand(SubCommand::GET_EXTERNAL_DEVICE_INFO, {}, output); | 79 | const auto result = SendSubCommand(SubCommand::GET_EXTERNAL_DEVICE_INFO, {}, output); |
| 79 | 80 | ||
| 80 | if (result != DriverResult::Success) { | 81 | if (result != Common::Input::DriverResult::Success) { |
| 81 | return result; | 82 | return result; |
| 82 | } | 83 | } |
| 83 | 84 | ||
| 84 | if (tries++ >= max_tries) { | 85 | if (tries++ >= max_tries) { |
| 85 | return DriverResult::NoDeviceDetected; | 86 | return Common::Input::DriverResult::NoDeviceDetected; |
| 86 | } | 87 | } |
| 87 | } while (output.external_device_id != ExternalDeviceId::RingController); | 88 | } while (output.external_device_id != ExternalDeviceId::RingController); |
| 88 | 89 | ||
| 89 | is_connected = true; | 90 | is_connected = true; |
| 90 | return DriverResult::Success; | 91 | return Common::Input::DriverResult::Success; |
| 91 | } | 92 | } |
| 92 | 93 | ||
| 93 | DriverResult RingConProtocol::ConfigureRing() { | 94 | Common::Input::DriverResult RingConProtocol::ConfigureRing() { |
| 94 | LOG_DEBUG(Input, "ConfigureRing"); | 95 | LOG_DEBUG(Input, "ConfigureRing"); |
| 95 | 96 | ||
| 96 | static constexpr std::array<u8, 37> ring_config{ | 97 | static constexpr std::array<u8, 37> ring_config{ |
| @@ -98,9 +99,10 @@ DriverResult RingConProtocol::ConfigureRing() { | |||
| 98 | 0x00, 0x00, 0x00, 0x0A, 0x64, 0x0B, 0xE6, 0xA9, 0x22, 0x00, 0x00, 0x04, 0x00, | 99 | 0x00, 0x00, 0x00, 0x0A, 0x64, 0x0B, 0xE6, 0xA9, 0x22, 0x00, 0x00, 0x04, 0x00, |
| 99 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xA8, 0xE1, 0x34, 0x36}; | 100 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xA8, 0xE1, 0x34, 0x36}; |
| 100 | 101 | ||
| 101 | const DriverResult result = SendSubCommand(SubCommand::SET_EXTERNAL_FORMAT_CONFIG, ring_config); | 102 | const Common::Input::DriverResult result = |
| 103 | SendSubCommand(SubCommand::SET_EXTERNAL_FORMAT_CONFIG, ring_config); | ||
| 102 | 104 | ||
| 103 | if (result != DriverResult::Success) { | 105 | if (result != Common::Input::DriverResult::Success) { |
| 104 | return result; | 106 | return result; |
| 105 | } | 107 | } |
| 106 | 108 | ||