From ed53ab9cd9c7f91e21d0bfae321bd8df3253dbd2 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Wed, 19 Dec 2018 13:48:15 +1100 Subject: [PATCH] Limit setting hold types to either vertical and horizontal Apparently some games throw bad values for this, does not look like any error codes are in place from what I can see, will need to investigate further to see why games try this. --- src/core/hle/service/hid/controllers/npad.cpp | 14 ++++++++++++-- src/core/hle/service/hid/controllers/npad.h | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index d6829d0b8e..6fd4aad3b6 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -512,11 +512,21 @@ std::size_t Controller_NPad::GetSupportedNPadIdTypesSize() const { void Controller_NPad::SetHoldType(NpadHoldType joy_hold_type) { styleset_changed_event.writable->Signal(); - hold_type = joy_hold_type; + if (joy_hold_type < NpadHoldType::HoldType_Max) { + hold_type = joy_hold_type; + } else { + LOG_WARNING(Service_HID, "got bad hold type={}", static_cast(joy_hold_type)); + } } Controller_NPad::NpadHoldType Controller_NPad::GetHoldType() const { - return hold_type; + if (hold_type < NpadHoldType::HoldType_Max) { + return hold_type; + } else { + LOG_WARNING(Service_HID, "has bad stored hold_type={}, defaulting to vertical", + static_cast(hold_type)); + return NpadHoldType::Vertical; + } } void Controller_NPad::SetNpadMode(u32 npad_id, NPadAssignments assignment_mode) { diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 29851f16ab..095c17fa4a 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -61,6 +61,7 @@ public: enum class NpadHoldType : u64 { Vertical = 0, Horizontal = 1, + HoldType_Max = 2, }; enum class NPadAssignments : u32_le {