mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-18 11:30:59 +01:00
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.
This commit is contained in:
parent
bfac21fca1
commit
322339a5fd
3 changed files with 6 additions and 7 deletions
|
@ -510,7 +510,7 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
|
||||||
libnx_state.r_stick = pad_state.r_stick;
|
libnx_state.r_stick = pad_state.r_stick;
|
||||||
npad.system_ext_lifo.WriteNextEntry(pad_state);
|
npad.system_ext_lifo.WriteNextEntry(pad_state);
|
||||||
|
|
||||||
press_state |= static_cast<u32>(pad_state.npad_buttons.raw);
|
press_state |= static_cast<u64>(pad_state.npad_buttons.raw);
|
||||||
|
|
||||||
std::memcpy(data + NPAD_OFFSET + (i * sizeof(NpadInternalState)),
|
std::memcpy(data + NPAD_OFFSET + (i * sizeof(NpadInternalState)),
|
||||||
&controller.shared_memory_entry, sizeof(NpadInternalState));
|
&controller.shared_memory_entry, sizeof(NpadInternalState));
|
||||||
|
@ -1149,8 +1149,8 @@ void Controller_NPad::ClearAllControllers() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Controller_NPad::GetAndResetPressState() {
|
Core::HID::NpadButton Controller_NPad::GetAndResetPressState() {
|
||||||
return press_state.exchange(0);
|
return static_cast<Core::HID::NpadButton>(press_state.exchange(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller) const {
|
bool Controller_NPad::IsControllerSupported(Core::HID::NpadStyleIndex controller) const {
|
||||||
|
|
|
@ -179,7 +179,7 @@ public:
|
||||||
|
|
||||||
// Logical OR for all buttons presses on all controllers
|
// Logical OR for all buttons presses on all controllers
|
||||||
// Specifically for cheat engine and other features.
|
// Specifically for cheat engine and other features.
|
||||||
u32 GetAndResetPressState();
|
Core::HID::NpadButton GetAndResetPressState();
|
||||||
|
|
||||||
static bool IsNpadIdValid(Core::HID::NpadIdType npad_id);
|
static bool IsNpadIdValid(Core::HID::NpadIdType npad_id);
|
||||||
static bool IsDeviceHandleValid(const Core::HID::SixAxisSensorHandle& device_handle);
|
static bool IsDeviceHandleValid(const Core::HID::SixAxisSensorHandle& device_handle);
|
||||||
|
@ -503,7 +503,7 @@ private:
|
||||||
NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id);
|
NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id);
|
||||||
const NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) const;
|
const NpadControllerData& GetControllerFromNpadIdType(Core::HID::NpadIdType npad_id) const;
|
||||||
|
|
||||||
std::atomic<u32> press_state{};
|
std::atomic<u64> press_state{};
|
||||||
|
|
||||||
std::array<NpadControllerData, 10> controller_data{};
|
std::array<NpadControllerData, 10> controller_data{};
|
||||||
KernelHelpers::ServiceContext& service_context;
|
KernelHelpers::ServiceContext& service_context;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
namespace Core::Memory {
|
namespace Core::Memory {
|
||||||
namespace {
|
namespace {
|
||||||
constexpr auto CHEAT_ENGINE_NS = std::chrono::nanoseconds{1000000000 / 12};
|
constexpr auto CHEAT_ENGINE_NS = std::chrono::nanoseconds{1000000000 / 12};
|
||||||
constexpr u32 KEYPAD_BITMASK = 0x3FFFFFF;
|
|
||||||
|
|
||||||
std::string_view ExtractName(std::string_view data, std::size_t start_index, char match) {
|
std::string_view ExtractName(std::string_view data, std::size_t start_index, char match) {
|
||||||
auto end_index = start_index;
|
auto end_index = start_index;
|
||||||
|
@ -61,7 +60,7 @@ u64 StandardVmCallbacks::HidKeysDown() {
|
||||||
applet_resource
|
applet_resource
|
||||||
->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad)
|
->GetController<Service::HID::Controller_NPad>(Service::HID::HidController::NPad)
|
||||||
.GetAndResetPressState();
|
.GetAndResetPressState();
|
||||||
return press_state & KEYPAD_BITMASK;
|
return static_cast<u64>(press_state & HID::NpadButton::All);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StandardVmCallbacks::DebugLog(u8 id, u64 value) {
|
void StandardVmCallbacks::DebugLog(u8 id, u64 value) {
|
||||||
|
|
Loading…
Reference in a new issue