From 621b25b6be99d357c9996fcb2df77f42c7dc2001 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Mon, 24 Dec 2018 16:19:16 -0500 Subject: hid: Make Hid service accessible and add GetPressState --- src/core/hle/service/hid/controllers/npad.cpp | 8 ++++++++ src/core/hle/service/hid/controllers/npad.h | 6 ++++++ 2 files changed, 14 insertions(+) (limited to 'src/core/hle/service/hid/controllers') diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 75fdb861a..2829f64e9 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -410,6 +410,8 @@ void Controller_NPad::OnUpdate(u8* data, std::size_t data_len) { libnx_entry.pad.pad_states.raw = pad_state.pad_states.raw; libnx_entry.pad.l_stick = pad_state.l_stick; libnx_entry.pad.r_stick = pad_state.r_stick; + + press_state |= static_cast(pad_state.pad_states.raw); } std::memcpy(data + NPAD_OFFSET, shared_memory_entries.data(), shared_memory_entries.size() * sizeof(NPadEntry)); @@ -636,6 +638,12 @@ void Controller_NPad::ClearAllControllers() { }); } +u32 Controller_NPad::GetPressState() { + const auto res = press_state; + press_state = 0; + return res; +} + bool Controller_NPad::IsControllerSupported(NPadControllerType controller) const { const bool support_handheld = std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(), NPAD_HANDHELD) != diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 29851f16a..6906d9ffb 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -124,6 +124,10 @@ public: void ConnectAllDisconnectedControllers(); void ClearAllControllers(); + // Logical OR for all buttons presses on all controllers + // Specifically for cheat engine and other features. + u32 GetPressState(); + static std::size_t NPadIdToIndex(u32 npad_id); static u32 IndexToNPad(std::size_t index); @@ -292,6 +296,8 @@ private: bool is_connected; }; + u32 press_state{}; + NPadType style{}; std::array shared_memory_entries{}; std::array< -- cgit v1.2.3