diff options
| author | 2023-11-27 19:26:06 +0100 | |
|---|---|---|
| committer | 2023-11-27 20:01:30 +0100 | |
| commit | e21f96ffde30d66337bd119c04a13f1025be159c (patch) | |
| tree | 7a50d39041cde8bb3d74e8130a905c8f75d89702 /src/core/hle/service/hid | |
| parent | Merge pull request #12183 from german77/justmii (diff) | |
| download | yuzu-e21f96ffde30d66337bd119c04a13f1025be159c.tar.gz yuzu-e21f96ffde30d66337bd119c04a13f1025be159c.tar.xz yuzu-e21f96ffde30d66337bd119c04a13f1025be159c.zip | |
Fixed controller applet crashing when on FW17+
Diffstat (limited to 'src/core/hle/service/hid')
| -rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.cpp | 12 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.h | 4 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid_server.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid_server.h | 1 |
4 files changed, 30 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 { | |||
| 16 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400; | 16 | constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400; |
| 17 | 17 | ||
| 18 | TouchScreen::TouchScreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) | 18 | TouchScreen::TouchScreen(Core::HID::HIDCore& hid_core_, u8* raw_shared_memory_) |
| 19 | : ControllerBase{hid_core_} { | 19 | : ControllerBase{hid_core_}, touchscreen_width(Layout::ScreenUndocked::Width), |
| 20 | touchscreen_height(Layout::ScreenUndocked::Height) { | ||
| 20 | static_assert(SHARED_MEMORY_OFFSET + sizeof(TouchSharedMemory) < shared_memory_size, | 21 | static_assert(SHARED_MEMORY_OFFSET + sizeof(TouchSharedMemory) < shared_memory_size, |
| 21 | "TouchSharedMemory is bigger than the shared memory"); | 22 | "TouchSharedMemory is bigger than the shared memory"); |
| 22 | shared_memory = std::construct_at( | 23 | shared_memory = std::construct_at( |
| @@ -95,8 +96,8 @@ void TouchScreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 95 | if (id < active_fingers_count) { | 96 | if (id < active_fingers_count) { |
| 96 | const auto& [active_x, active_y] = active_fingers[id].position; | 97 | const auto& [active_x, active_y] = active_fingers[id].position; |
| 97 | touch_entry.position = { | 98 | touch_entry.position = { |
| 98 | .x = static_cast<u16>(active_x * Layout::ScreenUndocked::Width), | 99 | .x = static_cast<u16>(active_x * static_cast<float>(touchscreen_width)), |
| 99 | .y = static_cast<u16>(active_y * Layout::ScreenUndocked::Height), | 100 | .y = static_cast<u16>(active_y * static_cast<float>(touchscreen_height)), |
| 100 | }; | 101 | }; |
| 101 | touch_entry.diameter_x = Settings::values.touchscreen.diameter_x; | 102 | touch_entry.diameter_x = Settings::values.touchscreen.diameter_x; |
| 102 | touch_entry.diameter_y = Settings::values.touchscreen.diameter_y; | 103 | touch_entry.diameter_y = Settings::values.touchscreen.diameter_y; |
| @@ -120,4 +121,9 @@ void TouchScreen::OnUpdate(const Core::Timing::CoreTiming& core_timing) { | |||
| 120 | shared_memory->touch_screen_lifo.WriteNextEntry(next_state); | 121 | shared_memory->touch_screen_lifo.WriteNextEntry(next_state); |
| 121 | } | 122 | } |
| 122 | 123 | ||
| 124 | void TouchScreen::SetTouchscreenDimensions(u32 width, u32 height) { | ||
| 125 | touchscreen_width = width; | ||
| 126 | touchscreen_height = height; | ||
| 127 | } | ||
| 128 | |||
| 123 | } // namespace Service::HID | 129 | } // 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: | |||
| 28 | // When the controller is requesting an update for the shared memory | 28 | // When the controller is requesting an update for the shared memory |
| 29 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; | 29 | void OnUpdate(const Core::Timing::CoreTiming& core_timing) override; |
| 30 | 30 | ||
| 31 | void SetTouchscreenDimensions(u32 width, u32 height); | ||
| 32 | |||
| 31 | private: | 33 | private: |
| 32 | static constexpr std::size_t MAX_FINGERS = 16; | 34 | static constexpr std::size_t MAX_FINGERS = 16; |
| 33 | 35 | ||
| @@ -53,5 +55,7 @@ private: | |||
| 53 | Core::HID::EmulatedConsole* console = nullptr; | 55 | Core::HID::EmulatedConsole* console = nullptr; |
| 54 | 56 | ||
| 55 | std::array<Core::HID::TouchFinger, MAX_FINGERS> fingers{}; | 57 | std::array<Core::HID::TouchFinger, MAX_FINGERS> fingers{}; |
| 58 | u32 touchscreen_width; | ||
| 59 | u32 touchscreen_height; | ||
| 56 | }; | 60 | }; |
| 57 | } // namespace Service::HID | 61 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/hid_server.cpp b/src/core/hle/service/hid/hid_server.cpp index 583142e35..a7d1578d9 100644 --- a/src/core/hle/service/hid/hid_server.cpp +++ b/src/core/hle/service/hid/hid_server.cpp | |||
| @@ -208,6 +208,7 @@ IHidServer::IHidServer(Core::System& system_, std::shared_ptr<ResourceManager> r | |||
| 208 | {1001, &IHidServer::GetNpadCommunicationMode, "GetNpadCommunicationMode"}, | 208 | {1001, &IHidServer::GetNpadCommunicationMode, "GetNpadCommunicationMode"}, |
| 209 | {1002, &IHidServer::SetTouchScreenConfiguration, "SetTouchScreenConfiguration"}, | 209 | {1002, &IHidServer::SetTouchScreenConfiguration, "SetTouchScreenConfiguration"}, |
| 210 | {1003, &IHidServer::IsFirmwareUpdateNeededForNotification, "IsFirmwareUpdateNeededForNotification"}, | 210 | {1003, &IHidServer::IsFirmwareUpdateNeededForNotification, "IsFirmwareUpdateNeededForNotification"}, |
| 211 | {1004, &IHidServer::SetTouchScreenResolution, "SetTouchScreenResolution"}, | ||
| 211 | {2000, nullptr, "ActivateDigitizer"}, | 212 | {2000, nullptr, "ActivateDigitizer"}, |
| 212 | }; | 213 | }; |
| 213 | // clang-format on | 214 | // clang-format on |
| @@ -2363,6 +2364,21 @@ void IHidServer::IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx) { | |||
| 2363 | rb.Push(false); | 2364 | rb.Push(false); |
| 2364 | } | 2365 | } |
| 2365 | 2366 | ||
| 2367 | void IHidServer::SetTouchScreenResolution(HLERequestContext& ctx) { | ||
| 2368 | IPC::RequestParser rp{ctx}; | ||
| 2369 | const auto width{rp.Pop<u32>()}; | ||
| 2370 | const auto height{rp.Pop<u32>()}; | ||
| 2371 | const auto applet_resource_user_id{rp.Pop<u64>()}; | ||
| 2372 | |||
| 2373 | GetResourceManager()->GetTouchScreen()->SetTouchscreenDimensions(width, height); | ||
| 2374 | |||
| 2375 | LOG_INFO(Service_HID, "called, width={}, height={}, applet_resource_user_id={}", width, height, | ||
| 2376 | applet_resource_user_id); | ||
| 2377 | |||
| 2378 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 2379 | rb.Push(ResultSuccess); | ||
| 2380 | } | ||
| 2381 | |||
| 2366 | std::shared_ptr<ResourceManager> IHidServer::GetResourceManager() { | 2382 | std::shared_ptr<ResourceManager> IHidServer::GetResourceManager() { |
| 2367 | resource_manager->Initialize(); | 2383 | resource_manager->Initialize(); |
| 2368 | return resource_manager; | 2384 | return resource_manager; |
diff --git a/src/core/hle/service/hid/hid_server.h b/src/core/hle/service/hid/hid_server.h index eb2e8e7f4..cc7c4ebdd 100644 --- a/src/core/hle/service/hid/hid_server.h +++ b/src/core/hle/service/hid/hid_server.h | |||
| @@ -141,6 +141,7 @@ private: | |||
| 141 | void GetNpadCommunicationMode(HLERequestContext& ctx); | 141 | void GetNpadCommunicationMode(HLERequestContext& ctx); |
| 142 | void SetTouchScreenConfiguration(HLERequestContext& ctx); | 142 | void SetTouchScreenConfiguration(HLERequestContext& ctx); |
| 143 | void IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx); | 143 | void IsFirmwareUpdateNeededForNotification(HLERequestContext& ctx); |
| 144 | void SetTouchScreenResolution(HLERequestContext& ctx); | ||
| 144 | 145 | ||
| 145 | std::shared_ptr<ResourceManager> resource_manager; | 146 | std::shared_ptr<ResourceManager> resource_manager; |
| 146 | std::shared_ptr<HidFirmwareSettings> firmware_settings; | 147 | std::shared_ptr<HidFirmwareSettings> firmware_settings; |