summaryrefslogtreecommitdiff
path: root/src/core/hid
diff options
context:
space:
mode:
authorGravatar bunnei2021-12-30 16:54:35 -0800
committerGravatar GitHub2021-12-30 16:54:35 -0800
commit667a8ae163681f68d90010bc7dd05eb7398524d6 (patch)
treedea803db312fc0e36c5ed2c9000cacf3bd4df7c3 /src/core/hid
parentMerge pull request #7635 from bunnei/set-heap-size (diff)
parentcore/hid: Fix controller type validation (diff)
downloadyuzu-667a8ae163681f68d90010bc7dd05eb7398524d6.tar.gz
yuzu-667a8ae163681f68d90010bc7dd05eb7398524d6.tar.xz
yuzu-667a8ae163681f68d90010bc7dd05eb7398524d6.zip
Merge pull request #7647 from german77/toad
core/hid: Fix controller type validation
Diffstat (limited to 'src/core/hid')
-rw-r--r--src/core/hid/emulated_controller.cpp12
-rw-r--r--src/core/hid/emulated_controller.h10
2 files changed, 14 insertions, 8 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp
index ff9d7a7e3..2d3fce276 100644
--- a/src/core/hid/emulated_controller.cpp
+++ b/src/core/hid/emulated_controller.cpp
@@ -886,8 +886,9 @@ void EmulatedController::SetSupportedNpadStyleTag(NpadStyleTag supported_styles)
886 } 886 }
887} 887}
888 888
889bool EmulatedController::IsControllerSupported() const { 889bool EmulatedController::IsControllerSupported(bool use_temporary_value) const {
890 switch (npad_type) { 890 const auto type = is_configuring && use_temporary_value ? tmp_npad_type : npad_type;
891 switch (type) {
891 case NpadStyleIndex::ProController: 892 case NpadStyleIndex::ProController:
892 return supported_style_tag.fullkey; 893 return supported_style_tag.fullkey;
893 case NpadStyleIndex::Handheld: 894 case NpadStyleIndex::Handheld:
@@ -915,9 +916,10 @@ bool EmulatedController::IsControllerSupported() const {
915 } 916 }
916} 917}
917 918
918void EmulatedController::Connect() { 919void EmulatedController::Connect(bool use_temporary_value) {
919 if (!IsControllerSupported()) { 920 if (!IsControllerSupported(use_temporary_value)) {
920 LOG_ERROR(Service_HID, "Controller type {} is not supported", npad_type); 921 const auto type = is_configuring && use_temporary_value ? tmp_npad_type : npad_type;
922 LOG_ERROR(Service_HID, "Controller type {} is not supported", type);
921 return; 923 return;
922 } 924 }
923 { 925 {
diff --git a/src/core/hid/emulated_controller.h b/src/core/hid/emulated_controller.h
index e42aafebc..d887eca87 100644
--- a/src/core/hid/emulated_controller.h
+++ b/src/core/hid/emulated_controller.h
@@ -167,8 +167,11 @@ public:
167 */ 167 */
168 void SetSupportedNpadStyleTag(NpadStyleTag supported_styles); 168 void SetSupportedNpadStyleTag(NpadStyleTag supported_styles);
169 169
170 /// Sets the connected status to true 170 /**
171 void Connect(); 171 * Sets the connected status to true
172 * @param use_temporary_value If true tmp_npad_type will be used
173 */
174 void Connect(bool use_temporary_value = false);
172 175
173 /// Sets the connected status to false 176 /// Sets the connected status to false
174 void Disconnect(); 177 void Disconnect();
@@ -319,9 +322,10 @@ private:
319 322
320 /** 323 /**
321 * Checks the current controller type against the supported_style_tag 324 * Checks the current controller type against the supported_style_tag
325 * @param use_temporary_value If true tmp_npad_type will be used
322 * @return true if the controller is supported 326 * @return true if the controller is supported
323 */ 327 */
324 bool IsControllerSupported() const; 328 bool IsControllerSupported(bool use_temporary_value = false) const;
325 329
326 /** 330 /**
327 * Updates the button status of the controller 331 * Updates the button status of the controller