summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Morph2021-11-29 18:23:52 -0500
committerGravatar Morph2021-11-29 19:21:51 -0500
commit322339a5fd4ed78826ecea42e71bc179afb7b5a7 (patch)
treef6b38e702674c524cc53a11f5c8705f6db0d415d /src
parentcore: hid: hid_types: Add "All" to NpadButton (diff)
downloadyuzu-322339a5fd4ed78826ecea42e71bc179afb7b5a7.tar.gz
yuzu-322339a5fd4ed78826ecea42e71bc179afb7b5a7.tar.xz
yuzu-322339a5fd4ed78826ecea42e71bc179afb7b5a7.zip
npad: Return NpadButton in GetAndResetPressState
We were previously truncating this to a u32 as there were no known buttons that used the full 64 bits of this type. Fix this now that we know they are used.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/hid/controllers/npad.cpp6
-rw-r--r--src/core/hle/service/hid/controllers/npad.h4
-rw-r--r--src/core/memory/cheat_engine.cpp3
3 files changed, 6 insertions, 7 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp
index 35dbf12df..6916930f7 100644
--- a/src/core/hle/service/hid/controllers/npad.cpp
+++ b/src/core/hle/service/hid/controllers/npad.cpp
@@ -510,7 +510,7 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
510 libnx_state.r_stick = pad_state.r_stick; 510 libnx_state.r_stick = pad_state.r_stick;
511 npad.system_ext_lifo.WriteNextEntry(pad_state); 511 npad.system_ext_lifo.WriteNextEntry(pad_state);
512 512
513 press_state |= static_cast<u32>(pad_state.npad_buttons.raw); 513 press_state |= static_cast<u64>(pad_state.npad_buttons.raw);
514 514
515 std::memcpy(data + NPAD_OFFSET + (i * sizeof(NpadInternalState)), 515 std::memcpy(data + NPAD_OFFSET + (i * sizeof(NpadInternalState)),
516 &controller.shared_memory_entry, sizeof(NpadInternalState)); 516 &controller.shared_memory_entry, sizeof(NpadInternalState));
@@ -1149,8 +1149,8 @@ void Controller_NPad::ClearAllControllers() {
1149 } 1149 }
1150} 1150}
1151 1151
1152u32 Controller_NPad::GetAndResetPressState() { 1152Core::HID::NpadButton Controller_NPad::GetAndResetPressState() {
1153 return press_state.exchange(0); 1153 return static_cast<Core::HID::NpadButton>(press_state.exchange(0));
1154} 1154}
1155 1155
1156bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller) const { 1156bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller) const {
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h
index 9fa113bb6..de5fa5a64 100644
--- a/src/core/hle/service/hid/controllers/npad.h
+++ b/src/core/hle/service/hid/controllers/npad.h
@@ -179,7 +179,7 @@ public:
179 179
180 // Logical OR for all buttons presses on all controllers 180 // Logical OR for all buttons presses on all controllers
181 // Specifically for cheat engine and other features. 181 // Specifically for cheat engine and other features.
182 u32 GetAndResetPressState(); 182 Core::HID::NpadButton GetAndResetPressState();
183 183
184 static bool IsNpadIdValid(Core::HID::NpadIdType npad_id); 184 static bool IsNpadIdValid(Core::HID::NpadIdType npad_id);
185 static bool IsDeviceHandleValid(const Core::HID::SixAxisSensorHandle& device_handle); 185 static bool IsDeviceHandleValid(const Core::HID::SixAxisSensorHandle& device_handle);
@@ -503,7 +503,7 @@ private:
503 NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id); 503 NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id);
504 const NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) const; 504 const NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) const;
505 505
506 std::atomic<u32> press_state{}; 506 std::atomic<u64> press_state{};
507 507
508 std::array<NpadControllerData, 10> controller_data{}; 508 std::array<NpadControllerData, 10> controller_data{};
509 KernelHelpers::ServiceContext& service_context; 509 KernelHelpers::ServiceContext& service_context;
diff --git a/src/core/memory/cheat_engine.cpp b/src/core/memory/cheat_engine.cpp
index 20f0e90f5..12446c9ac 100644
--- a/src/core/memory/cheat_engine.cpp
+++ b/src/core/memory/cheat_engine.cpp
@@ -19,7 +19,6 @@
19namespace Core::Memory { 19namespace Core::Memory {
20namespace { 20namespace {
21constexpr auto CHEAT_ENGINE_NS = std::chrono::nanoseconds{1000000000 / 12}; 21constexpr auto CHEAT_ENGINE_NS = std::chrono::nanoseconds{1000000000 / 12};
22constexpr u32 KEYPAD_BITMASK = 0x3FFFFFF;
23 22
24std::string_view ExtractName(std::string_view data, std::size_t start_index, char match) { 23std::string_view ExtractName(std::string_view data, std::size_t start_index, char match) {
25 auto end_index = start_index; 24 auto end_index = start_index;
@@ -61,7 +60,7 @@ u64 StandardVmCallbacks::HidKeysDown() {
61 applet_resource 60 applet_resource
62 ->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad) 61 ->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad)
63 .GetAndResetPressState(); 62 .GetAndResetPressState();
64 return press_state & KEYPAD_BITMASK; 63 return static_cast<u64>(press_state & HID::NpadButton::All);
65} 64}
66 65
67void StandardVmCallbacks::DebugLog(u8 id, u64 value) { 66void StandardVmCallbacks::DebugLog(u8 id, u64 value) {