diff options
author | Narr the Reg <juangerman-13@hotmail.com> | 2022-04-19 22:30:32 +0200 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2022-04-23 22:41:42 +0200 |
commit | 61582efeb976b0852e73b734835d60c73b38f3cf (patch) | |
tree | b5ac72746de0533cd292ad5cb962d0e663326b0e /src/core/hle/service/hid/controllers/console_sixaxis.cpp | |
parent | Merge pull request #8249 from german77/queued (diff) | |
download | yuzu-61582efeb976b0852e73b734835d60c73b38f3cf.tar yuzu-61582efeb976b0852e73b734835d60c73b38f3cf.tar.gz yuzu-61582efeb976b0852e73b734835d60c73b38f3cf.tar.bz2 yuzu-61582efeb976b0852e73b734835d60c73b38f3cf.tar.lz yuzu-61582efeb976b0852e73b734835d60c73b38f3cf.tar.xz yuzu-61582efeb976b0852e73b734835d60c73b38f3cf.tar.zst yuzu-61582efeb976b0852e73b734835d60c73b38f3cf.zip |
Diffstat (limited to 'src/core/hle/service/hid/controllers/console_sixaxis.cpp')
-rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.cpp b/src/core/hle/service/hid/controllers/console_sixaxis.cpp index f5a0b94dd..c93bcd678 100644 --- a/src/core/hle/service/hid/controllers/console_sixaxis.cpp +++ b/src/core/hle/service/hid/controllers/console_sixaxis.cpp @@ -9,9 +9,14 @@ namespace Service::HID { constexpr std::size_t SHARED_MEMORY_OFFSET = 0x3C200; -Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::HID::HIDCore& hid_core_) +Controller_ConsoleSixAxis::Controller_ConsoleSixAxis(Core::HID::HIDCore& hid_core_, + u8* raw_shared_memory_) : ControllerBase{hid_core_} { console = hid_core.GetEmulatedConsole(); + static_assert(SHARED_MEMORY_OFFSET + sizeof(ConsoleSharedMemory) < shared_memory_size, + "ConsoleSharedMemory is bigger than the shared memory"); + shared_memory = + std::construct_at(reinterpret_cast<ConsoleSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET)); } Controller_ConsoleSixAxis::~Controller_ConsoleSixAxis() = default; @@ -20,8 +25,7 @@ void Controller_ConsoleSixAxis::OnInit() {} void Controller_ConsoleSixAxis::OnRelease() {} -void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data, - std::size_t size) { +void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_timing) { if (!IsControllerActivated() || !is_transfer_memory_set) { seven_sixaxis_lifo.buffer_count = 0; seven_sixaxis_lifo.buffer_tail = 0; @@ -48,13 +52,11 @@ void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_ti -motion_status.quaternion.xyz.z, }; - console_six_axis.sampling_number++; - console_six_axis.is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest; - console_six_axis.verticalization_error = motion_status.verticalization_error; - console_six_axis.gyro_bias = motion_status.gyro_bias; + shared_memory->sampling_number++; + shared_memory->is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest; + shared_memory->verticalization_error = motion_status.verticalization_error; + shared_memory->gyro_bias = motion_status.gyro_bias; - // Update console six axis shared memory - std::memcpy(data + SHARED_MEMORY_OFFSET, &console_six_axis, sizeof(console_six_axis)); // Update seven six axis transfer memory seven_sixaxis_lifo.WriteNextEntry(next_seven_sixaxis_state); std::memcpy(transfer_memory, &seven_sixaxis_lifo, sizeof(seven_sixaxis_lifo)); |