summaryrefslogtreecommitdiffstats
path: root/src/core/hid
diff options
context:
space:
mode:
authorgerman77 <juangerman-13@hotmail.com>2021-12-05 23:17:52 +0100
committergerman77 <juangerman-13@hotmail.com>2021-12-05 23:18:23 +0100
commitd6ae9c68f80792cf11f13ca2c81ac34ddf01dafa (patch)
treec09f3cbe3806d91999a1d36fad5842e7ae89669e /src/core/hid
parentMerge pull request #7518 from german77/is_npad_valid (diff)
downloadyuzu-d6ae9c68f80792cf11f13ca2c81ac34ddf01dafa.tar
yuzu-d6ae9c68f80792cf11f13ca2c81ac34ddf01dafa.tar.gz
yuzu-d6ae9c68f80792cf11f13ca2c81ac34ddf01dafa.tar.bz2
yuzu-d6ae9c68f80792cf11f13ca2c81ac34ddf01dafa.tar.lz
yuzu-d6ae9c68f80792cf11f13ca2c81ac34ddf01dafa.tar.xz
yuzu-d6ae9c68f80792cf11f13ca2c81ac34ddf01dafa.tar.zst
yuzu-d6ae9c68f80792cf11f13ca2c81ac34ddf01dafa.zip
Diffstat (limited to 'src/core/hid')
-rw-r--r--src/core/hid/hid_core.cpp10
-rw-r--r--src/core/hid/hid_core.h3
2 files changed, 13 insertions, 0 deletions
diff --git a/src/core/hid/hid_core.cpp b/src/core/hid/hid_core.cpp
index 0c3eb5a62..a1c3bbb57 100644
--- a/src/core/hid/hid_core.cpp
+++ b/src/core/hid/hid_core.cpp
@@ -145,6 +145,16 @@ NpadIdType HIDCore::GetFirstNpadId() const {
return NpadIdType::Player1;
}
+NpadIdType HIDCore::GetFirstDisconnectedNpadId() const {
+ for (std::size_t player_index = 0; player_index < available_controllers; ++player_index) {
+ const auto* const controller = GetEmulatedControllerByIndex(player_index);
+ if (!controller->IsConnected()) {
+ return controller->GetNpadIdType();
+ }
+ }
+ return NpadIdType::Player1;
+}
+
void HIDCore::EnableAllControllerConfiguration() {
player_1->EnableConfiguration();
player_2->EnableConfiguration();
diff --git a/src/core/hid/hid_core.h b/src/core/hid/hid_core.h
index 2fb0f7e19..837f7de49 100644
--- a/src/core/hid/hid_core.h
+++ b/src/core/hid/hid_core.h
@@ -45,6 +45,9 @@ public:
/// Returns the first connected npad id
NpadIdType GetFirstNpadId() const;
+ /// Returns the first disconnected npad id
+ NpadIdType GetFirstDisconnectedNpadId() const;
+
/// Sets all emulated controllers into configuring mode.
void EnableAllControllerConfiguration();