From df9685a21c105962e90dbd95133c5a1bcef7886f Mon Sep 17 00:00:00 2001 From: german77 Date: Wed, 28 Jun 2023 00:20:38 -0600 Subject: input_common: Remove duplicated DriverResult enum --- .../helpers/joycon_protocol/ringcon.cpp | 42 +++++++++++----------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'src/input_common/helpers/joycon_protocol/ringcon.cpp') 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 @@ // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "common/input.h" #include "common/logging/log.h" #include "input_common/helpers/joycon_protocol/ringcon.h" @@ -9,18 +10,18 @@ namespace InputCommon::Joycon { RingConProtocol::RingConProtocol(std::shared_ptr handle) : JoyconCommonProtocol(std::move(handle)) {} -DriverResult RingConProtocol::EnableRingCon() { +Common::Input::DriverResult RingConProtocol::EnableRingCon() { LOG_DEBUG(Input, "Enable Ringcon"); ScopedSetBlocking sb(this); - DriverResult result{DriverResult::Success}; + Common::Input::DriverResult result{Common::Input::DriverResult::Success}; - if (result == DriverResult::Success) { + if (result == Common::Input::DriverResult::Success) { result = SetReportMode(ReportMode::STANDARD_FULL_60HZ); } - if (result == DriverResult::Success) { + if (result == Common::Input::DriverResult::Success) { result = EnableMCU(true); } - if (result == DriverResult::Success) { + if (result == Common::Input::DriverResult::Success) { const MCUConfig config{ .command = MCUCommand::ConfigureMCU, .sub_command = MCUSubCommand::SetDeviceMode, @@ -33,12 +34,12 @@ DriverResult RingConProtocol::EnableRingCon() { return result; } -DriverResult RingConProtocol::DisableRingCon() { +Common::Input::DriverResult RingConProtocol::DisableRingCon() { LOG_DEBUG(Input, "Disable RingCon"); ScopedSetBlocking sb(this); - DriverResult result{DriverResult::Success}; + Common::Input::DriverResult result{Common::Input::DriverResult::Success}; - if (result == DriverResult::Success) { + if (result == Common::Input::DriverResult::Success) { result = EnableMCU(false); } @@ -47,27 +48,27 @@ DriverResult RingConProtocol::DisableRingCon() { return result; } -DriverResult RingConProtocol::StartRingconPolling() { +Common::Input::DriverResult RingConProtocol::StartRingconPolling() { LOG_DEBUG(Input, "Enable Ringcon"); ScopedSetBlocking sb(this); - DriverResult result{DriverResult::Success}; + Common::Input::DriverResult result{Common::Input::DriverResult::Success}; bool is_connected = false; - if (result == DriverResult::Success) { + if (result == Common::Input::DriverResult::Success) { result = IsRingConnected(is_connected); } - if (result == DriverResult::Success && is_connected) { + if (result == Common::Input::DriverResult::Success && is_connected) { LOG_INFO(Input, "Ringcon detected"); result = ConfigureRing(); } - if (result == DriverResult::Success) { + if (result == Common::Input::DriverResult::Success) { is_enabled = true; } return result; } -DriverResult RingConProtocol::IsRingConnected(bool& is_connected) { +Common::Input::DriverResult RingConProtocol::IsRingConnected(bool& is_connected) { LOG_DEBUG(Input, "IsRingConnected"); constexpr std::size_t max_tries = 28; SubCommandResponse output{}; @@ -77,20 +78,20 @@ DriverResult RingConProtocol::IsRingConnected(bool& is_connected) { do { const auto result = SendSubCommand(SubCommand::GET_EXTERNAL_DEVICE_INFO, {}, output); - if (result != DriverResult::Success) { + if (result != Common::Input::DriverResult::Success) { return result; } if (tries++ >= max_tries) { - return DriverResult::NoDeviceDetected; + return Common::Input::DriverResult::NoDeviceDetected; } } while (output.external_device_id != ExternalDeviceId::RingController); is_connected = true; - return DriverResult::Success; + return Common::Input::DriverResult::Success; } -DriverResult RingConProtocol::ConfigureRing() { +Common::Input::DriverResult RingConProtocol::ConfigureRing() { LOG_DEBUG(Input, "ConfigureRing"); static constexpr std::array ring_config{ @@ -98,9 +99,10 @@ DriverResult RingConProtocol::ConfigureRing() { 0x00, 0x00, 0x00, 0x0A, 0x64, 0x0B, 0xE6, 0xA9, 0x22, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xA8, 0xE1, 0x34, 0x36}; - const DriverResult result = SendSubCommand(SubCommand::SET_EXTERNAL_FORMAT_CONFIG, ring_config); + const Common::Input::DriverResult result = + SendSubCommand(SubCommand::SET_EXTERNAL_FORMAT_CONFIG, ring_config); - if (result != DriverResult::Success) { + if (result != Common::Input::DriverResult::Success) { return result; } -- cgit v1.2.3