summaryrefslogtreecommitdiffstats
path: root/src/input_common
diff options
context:
space:
mode:
Diffstat (limited to 'src/input_common')
-rw-r--r--src/input_common/drivers/virtual_amiibo.cpp9
-rw-r--r--src/input_common/helpers/joycon_driver.cpp38
-rw-r--r--src/input_common/helpers/joycon_driver.h2
3 files changed, 32 insertions, 17 deletions
diff --git a/src/input_common/drivers/virtual_amiibo.cpp b/src/input_common/drivers/virtual_amiibo.cpp
index 29e129d3c..4a0268a4d 100644
--- a/src/input_common/drivers/virtual_amiibo.cpp
+++ b/src/input_common/drivers/virtual_amiibo.cpp
@@ -27,17 +27,18 @@ Common::Input::DriverResult VirtualAmiibo::SetPollingMode(
const Common::Input::PollingMode polling_mode_) {
polling_mode = polling_mode_;
- if (polling_mode == Common::Input::PollingMode::NFC) {
+ switch (polling_mode) {
+ case Common::Input::PollingMode::NFC:
if (state == State::Initialized) {
state = State::WaitingForAmiibo;
}
- } else {
+ return Common::Input::DriverResult::Success;
+ default:
if (state == State::AmiiboIsOpen) {
CloseAmiibo();
}
+ return Common::Input::DriverResult::NotSupported;
}
-
- return Common::Input::DriverResult::Success;
}
Common::Input::NfcState VirtualAmiibo::SupportsNfc(
diff --git a/src/input_common/helpers/joycon_driver.cpp b/src/input_common/helpers/joycon_driver.cpp
index b00b6110b..8217ba7f6 100644
--- a/src/input_common/helpers/joycon_driver.cpp
+++ b/src/input_common/helpers/joycon_driver.cpp
@@ -238,7 +238,7 @@ void JoyconDriver::OnNewData(std::span<u8> buffer) {
}
}
-void JoyconDriver::SetPollingMode() {
+DriverResult JoyconDriver::SetPollingMode() {
disable_input_thread = true;
rumble_protocol->EnableRumble(vibration_enabled && supported_features.vibration);
@@ -263,7 +263,7 @@ void JoyconDriver::SetPollingMode() {
}
if (result == DriverResult::Success) {
disable_input_thread = false;
- return;
+ return result;
}
nfc_protocol->DisableNfc();
LOG_ERROR(Input, "Error enabling NFC");
@@ -282,7 +282,7 @@ void JoyconDriver::SetPollingMode() {
if (result == DriverResult::Success) {
ring_connected = true;
disable_input_thread = false;
- return;
+ return result;
}
ring_connected = false;
ring_protocol->DisableRingCon();
@@ -293,7 +293,7 @@ void JoyconDriver::SetPollingMode() {
const auto result = generic_protocol->EnablePassiveMode();
if (result == DriverResult::Success) {
disable_input_thread = false;
- return;
+ return result;
}
LOG_ERROR(Input, "Error enabling passive mode");
}
@@ -305,6 +305,7 @@ void JoyconDriver::SetPollingMode() {
}
disable_input_thread = false;
+ return result;
}
JoyconDriver::SupportedFeatures JoyconDriver::GetSupportedFeatures() {
@@ -380,8 +381,7 @@ DriverResult JoyconDriver::SetPasiveMode() {
hidbus_enabled = false;
nfc_enabled = false;
passive_enabled = true;
- SetPollingMode();
- return DriverResult::Success;
+ return SetPollingMode();
}
DriverResult JoyconDriver::SetActiveMode() {
@@ -390,28 +390,42 @@ DriverResult JoyconDriver::SetActiveMode() {
hidbus_enabled = false;
nfc_enabled = false;
passive_enabled = false;
- SetPollingMode();
- return DriverResult::Success;
+ return SetPollingMode();
}
DriverResult JoyconDriver::SetNfcMode() {
std::scoped_lock lock{mutex};
+
+ if (!supported_features.nfc) {
+ return DriverResult::NotSupported;
+ }
+
motion_enabled = true;
hidbus_enabled = false;
nfc_enabled = true;
passive_enabled = false;
- SetPollingMode();
- return DriverResult::Success;
+ return SetPollingMode();
}
DriverResult JoyconDriver::SetRingConMode() {
std::scoped_lock lock{mutex};
+
+ if (!supported_features.hidbus) {
+ return DriverResult::NotSupported;
+ }
+
motion_enabled = true;
hidbus_enabled = true;
nfc_enabled = false;
passive_enabled = false;
- SetPollingMode();
- return DriverResult::Success;
+
+ const auto result = SetPollingMode();
+
+ if (!ring_connected) {
+ return DriverResult::NoDeviceDetected;
+ }
+
+ return result;
}
bool JoyconDriver::IsConnected() const {
diff --git a/src/input_common/helpers/joycon_driver.h b/src/input_common/helpers/joycon_driver.h
index bf38a3009..5ff15c784 100644
--- a/src/input_common/helpers/joycon_driver.h
+++ b/src/input_common/helpers/joycon_driver.h
@@ -73,7 +73,7 @@ private:
void OnNewData(std::span<u8> buffer);
/// Updates device configuration to enable or disable features
- void SetPollingMode();
+ DriverResult SetPollingMode();
/// Returns true if input thread is valid and doesn't need to be stopped
bool IsInputThreadValid() const;