summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/hid/controllers/touchscreen.cpp
diff options
context:
space:
mode:
authorNarr the Reg <juangerman-13@hotmail.com>2022-04-19 22:30:32 +0200
committerNarr the Reg <juangerman-13@hotmail.com>2022-04-23 22:41:42 +0200
commit61582efeb976b0852e73b734835d60c73b38f3cf (patch)
treeb5ac72746de0533cd292ad5cb962d0e663326b0e /src/core/hle/service/hid/controllers/touchscreen.cpp
parentMerge pull request #8249 from german77/queued (diff)
downloadyuzu-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 '')
-rw-r--r--src/core/hle/service/hid/controllers/touchscreen.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp
index 5b4b51a69..5f584586b 100644
--- a/src/core/hle/service/hid/controllers/touchscreen.cpp
+++ b/src/core/hle/service/hid/controllers/touchscreen.cpp
@@ -15,8 +15,12 @@
namespace Service::HID {
constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400;
-Controller_Touchscreen::Controller_Touchscreen(Core::HID::HIDCore& hid_core_)
+Controller_Touchscreen::Controller_Touchscreen(Core::HID::HIDCore& hid_core_,
+ u8* raw_shared_memory_)
: ControllerBase{hid_core_} {
+ static_assert(SHARED_MEMORY_OFFSET + sizeof(TouchSharedMemory) < shared_memory_size,
+ "TouchSharedMemory is bigger than the shared memory");
+ shared_memory = std::construct_at(reinterpret_cast<TouchSharedMemory*>(raw_shared_memory_ + SHARED_MEMORY_OFFSET));
console = hid_core.GetEmulatedConsole();
}
@@ -26,14 +30,12 @@ void Controller_Touchscreen::OnInit() {}
void Controller_Touchscreen::OnRelease() {}
-void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* data,
- std::size_t size) {
- touch_screen_lifo.timestamp = core_timing.GetCPUTicks();
+void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) {
+ shared_memory->touch_screen_lifo.timestamp = core_timing.GetCPUTicks();
if (!IsControllerActivated()) {
- touch_screen_lifo.buffer_count = 0;
- touch_screen_lifo.buffer_tail = 0;
- std::memcpy(data, &touch_screen_lifo, sizeof(touch_screen_lifo));
+ shared_memory->touch_screen_lifo.buffer_count = 0;
+ shared_memory->touch_screen_lifo.buffer_tail = 0;
return;
}
@@ -74,7 +76,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin
static_cast<std::size_t>(std::distance(active_fingers.begin(), end_iter));
const u64 tick = core_timing.GetCPUTicks();
- const auto& last_entry = touch_screen_lifo.ReadCurrentEntry().state;
+ const auto& last_entry = shared_memory->touch_screen_lifo.ReadCurrentEntry().state;
next_state.sampling_number = last_entry.sampling_number + 1;
next_state.entry_count = static_cast<s32>(active_fingers_count);
@@ -106,8 +108,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin
}
}
- touch_screen_lifo.WriteNextEntry(next_state);
- std::memcpy(data + SHARED_MEMORY_OFFSET, &touch_screen_lifo, sizeof(touch_screen_lifo));
+ shared_memory->touch_screen_lifo.WriteNextEntry(next_state);
}
} // namespace Service::HID