diff options
author | FrozenAra <macjordan02@googlemail.com> | 2023-11-27 19:26:06 +0100 |
---|---|---|
committer | FrozenAra <macjordan02@googlemail.com> | 2023-11-27 20:01:30 +0100 |
commit | e21f96ffde30d66337bd119c04a13f1025be159c (patch) | |
tree | 7a50d39041cde8bb3d74e8130a905c8f75d89702 /src/core/hle/service/hid/controllers | |
parent | Merge pull request #12183 from german77/justmii (diff) | |
download | yuzu-e21f96ffde30d66337bd119c04a13f1025be159c.tar yuzu-e21f96ffde30d66337bd119c04a13f1025be159c.tar.gz yuzu-e21f96ffde30d66337bd119c04a13f1025be159c.tar.bz2 yuzu-e21f96ffde30d66337bd119c04a13f1025be159c.tar.lz yuzu-e21f96ffde30d66337bd119c04a13f1025be159c.tar.xz yuzu-e21f96ffde30d66337bd119c04a13f1025be159c.tar.zst yuzu-e21f96ffde30d66337bd119c04a13f1025be159c.zip |
Diffstat (limited to 'src/core/hle/service/hid/controllers')
-rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.cpp | 12 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.h | 4 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index 3bcf0ee9f..fcd973414 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -16,7 +16,8 @@ namespace Service::HID { constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400; TouchScreen::TouchScreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) - : ControllerBase{hid_core_} { + : ControllerBase{hid_core_}, touchscreen_width(Layout::ScreenUndocked::Width), + touchscreen_height(Layout::ScreenUndocked::Height) { static_assert(SHARED_MEMORY_OFFSET + sizeof(TouchSharedMemory) < shared_memory_size, "TouchSharedMemory is bigger than the shared memory"); shared_memory = std::construct_at( @@ -95,8 +96,8 @@ void TouchScreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) { if (id < active_fingers_count) { const auto& [active_x, active_y] = active_fingers[id].position; touch_entry.position = { - .x = static_cast<u16>(active_x * Layout::ScreenUndocked::Width), - .y = static_cast<u16>(active_y * Layout::ScreenUndocked::Height), + .x = static_cast<u16>(active_x * static_cast<float>(touchscreen_width)), + .y = static_cast<u16>(active_y * static_cast<float>(touchscreen_height)), }; touch_entry.diameter_x = Settings::values.touchscreen.diameter_x; touch_entry.diameter_y = Settings::values.touchscreen.diameter_y; @@ -120,4 +121,9 @@ void TouchScreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) { shared_memory->touch_screen_lifo.WriteNextEntry(next_state); } +void TouchScreen::SetTouchscreenDimensions(u32 width, u32 height) { + touchscreen_width = width; + touchscreen_height = height; +} + } // namespace Service::HID diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index cd342ce91..79f026a81 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h @@ -28,6 +28,8 @@ public: // When the controller is requesting an update for the shared memory void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; + void SetTouchscreenDimensions(u32 width, u32 height); + private: static constexpr std::size_t MAX_FINGERS = 16; @@ -53,5 +55,7 @@ private: Core::HID::EmulatedConsole* console = nullptr; std::array<Core::HID::TouchFinger, MAX_FINGERS> fingers{}; + u32 touchscreen_width; + u32 touchscreen_height; }; } // namespace Service::HID |