2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

service/hid: Fix memory allocated incorrectly

This commit is contained in:
german77 2021-10-24 20:27:00 -05:00 committed by Narr the Reg
parent 464c4d26ac
commit f01dac3bf9
5 changed files with 7 additions and 7 deletions

View file

@ -12,7 +12,7 @@
#include "core/hle/service/hid/controllers/debug_pad.h" #include "core/hle/service/hid/controllers/debug_pad.h"
namespace Service::HID { namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x00000;
constexpr s32 HID_JOYSTICK_MAX = 0x7fff; constexpr s32 HID_JOYSTICK_MAX = 0x7fff;
[[maybe_unused]] constexpr s32 HID_JOYSTICK_MIN = -0x7fff; [[maybe_unused]] constexpr s32 HID_JOYSTICK_MIN = -0x7fff;
enum class JoystickId : std::size_t { Joystick_Left, Joystick_Right }; enum class JoystickId : std::size_t { Joystick_Left, Joystick_Right };
@ -32,7 +32,7 @@ void Controller_DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing,
if (!IsControllerActivated()) { if (!IsControllerActivated()) {
debug_pad_lifo.entry_count = 0; debug_pad_lifo.entry_count = 0;
debug_pad_lifo.last_entry_index = 0; debug_pad_lifo.last_entry_index = 0;
std::memcpy(data, &debug_pad_lifo, sizeof(debug_pad_lifo)); std::memcpy(data + SHARED_MEMORY_OFFSET, &debug_pad_lifo, sizeof(debug_pad_lifo));
return; return;
} }
@ -51,7 +51,7 @@ void Controller_DebugPad::OnUpdate(const Core::Timing::CoreTiming& core_timing,
} }
debug_pad_lifo.WriteNextEntry(next_state); debug_pad_lifo.WriteNextEntry(next_state);
std::memcpy(data, &debug_pad_lifo, sizeof(debug_pad_lifo)); std::memcpy(data + SHARED_MEMORY_OFFSET, &debug_pad_lifo, sizeof(debug_pad_lifo));
} }
} // namespace Service::HID } // namespace Service::HID

View file

@ -43,7 +43,7 @@ void Controller_Gesture::OnUpdate(const Core::Timing::CoreTiming& core_timing, u
if (!IsControllerActivated()) { if (!IsControllerActivated()) {
gesture_lifo.entry_count = 0; gesture_lifo.entry_count = 0;
gesture_lifo.last_entry_index = 0; gesture_lifo.last_entry_index = 0;
std::memcpy(data, &gesture_lifo, sizeof(gesture_lifo)); std::memcpy(data + SHARED_MEMORY_OFFSET, &gesture_lifo, sizeof(gesture_lifo));
return; return;
} }

View file

@ -29,7 +29,7 @@ void Controller_Keyboard::OnUpdate(const Core::Timing::CoreTiming& core_timing,
if (!IsControllerActivated()) { if (!IsControllerActivated()) {
keyboard_lifo.entry_count = 0; keyboard_lifo.entry_count = 0;
keyboard_lifo.last_entry_index = 0; keyboard_lifo.last_entry_index = 0;
std::memcpy(data, &keyboard_lifo, sizeof(keyboard_lifo)); std::memcpy(data + SHARED_MEMORY_OFFSET, &keyboard_lifo, sizeof(keyboard_lifo));
return; return;
} }

View file

@ -29,7 +29,7 @@ void Controller_Mouse::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
if (!IsControllerActivated()) { if (!IsControllerActivated()) {
mouse_lifo.entry_count = 0; mouse_lifo.entry_count = 0;
mouse_lifo.last_entry_index = 0; mouse_lifo.last_entry_index = 0;
std::memcpy(data, &mouse_lifo, sizeof(mouse_lifo)); std::memcpy(data + SHARED_MEMORY_OFFSET, &mouse_lifo, sizeof(mouse_lifo));
return; return;
} }

View file

@ -22,7 +22,7 @@ void Controller_XPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8*
if (!IsControllerActivated()) { if (!IsControllerActivated()) {
basic_xpad_lifo.entry_count = 0; basic_xpad_lifo.entry_count = 0;
basic_xpad_lifo.last_entry_index = 0; basic_xpad_lifo.last_entry_index = 0;
std::memcpy(data, &basic_xpad_lifo, sizeof(basic_xpad_lifo)); std::memcpy(data + SHARED_MEMORY_OFFSET, &basic_xpad_lifo, sizeof(basic_xpad_lifo));
return; return;
} }