input_common: Remove duplicated DriverResult enum
This commit is contained in:
parent
0fe44071f8
commit
df9685a21c
21 changed files with 523 additions and 479 deletions
|
@ -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<JoyconHandle> 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<u8, 37> 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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue