From d583e01f54a7f53d1955f8bc76169c02b807df2e Mon Sep 17 00:00:00 2001 From: german Date: Thu, 31 Dec 2020 20:40:55 -0600 Subject: Add multitouch support --- .../hle/service/hid/controllers/touchscreen.cpp | 97 +++++++++++++++++----- src/core/hle/service/hid/controllers/touchscreen.h | 19 ++++- 2 files changed, 93 insertions(+), 23 deletions(-) (limited to 'src/core/hle/service/hid/controllers') diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index 0df395e85..de8315ce4 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -40,29 +40,43 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin cur_entry.sampling_number = last_entry.sampling_number + 1; cur_entry.sampling_number2 = cur_entry.sampling_number; - bool pressed = false; - float x, y; - std::tie(x, y, pressed) = touch_device->GetStatus(); - auto& touch_entry = cur_entry.states[0]; - touch_entry.attribute.raw = 0; - if (!pressed && touch_btn_device) { - std::tie(x, y, pressed) = touch_btn_device->GetStatus(); - } - if (pressed && Settings::values.touchscreen.enabled) { - touch_entry.x = static_cast(x * Layout::ScreenUndocked::Width); - touch_entry.y = static_cast(y * Layout::ScreenUndocked::Height); - touch_entry.diameter_x = Settings::values.touchscreen.diameter_x; - touch_entry.diameter_y = Settings::values.touchscreen.diameter_y; - touch_entry.rotation_angle = Settings::values.touchscreen.rotation_angle; - const u64 tick = core_timing.GetCPUTicks(); - touch_entry.delta_time = tick - last_touch; - last_touch = tick; - touch_entry.finger = Settings::values.touchscreen.finger; - cur_entry.entry_count = 1; - } else { - cur_entry.entry_count = 0; + updateTouchInputEvent(touch_device->GetStatus(), mouse_finger_id); + updateTouchInputEvent(touch_btn_device->GetStatus(), keyboar_finger_id); + + std::array sorted_fingers; + s32_le active_fingers = 0; + for (Finger finger : fingers) { + if (finger.pressed) { + sorted_fingers[active_fingers++] = finger; + } } + const u64 tick = core_timing.GetCPUTicks(); + cur_entry.entry_count = active_fingers; + for (size_t id = 0; id < MAX_FINGERS; id++) { + auto& touch_entry = cur_entry.states[id]; + if (id < active_fingers) { + touch_entry.x = static_cast(sorted_fingers[id].x * Layout::ScreenUndocked::Width); + touch_entry.y = static_cast(sorted_fingers[id].y * Layout::ScreenUndocked::Height); + touch_entry.diameter_x = Settings::values.touchscreen.diameter_x; + touch_entry.diameter_y = Settings::values.touchscreen.diameter_y; + touch_entry.rotation_angle = Settings::values.touchscreen.rotation_angle; + touch_entry.delta_time = tick - sorted_fingers[id].last_touch; + sorted_fingers[id].last_touch = tick; + touch_entry.finger = sorted_fingers[id].id; + touch_entry.attribute.raw = sorted_fingers[id].attribute.raw; + } else { + // Clear touch entry + touch_entry.attribute.raw = 0; + touch_entry.x = 0; + touch_entry.y = 0; + touch_entry.diameter_x = 0; + touch_entry.diameter_y = 0; + touch_entry.rotation_angle = 0; + touch_entry.delta_time = 0; + touch_entry.finger = 0; + } + } std::memcpy(data + SHARED_MEMORY_OFFSET, &shared_memory, sizeof(TouchScreenSharedMemory)); } @@ -74,4 +88,45 @@ void Controller_Touchscreen::OnLoadInputDevices() { touch_btn_device.reset(); } } + +void Controller_Touchscreen::updateTouchInputEvent( + const std::tuple& touch_input, int& finger_id) { + bool pressed = false; + float x, y; + std::tie(x, y, pressed) = touch_input; + if (pressed) { + if (finger_id == -1) { + int first_free_id = 0; + int found = false; + while (!found && first_free_id < MAX_FINGERS) { + if (!fingers[first_free_id].pressed) { + found = true; + } else { + first_free_id++; + } + } + if (found) { + finger_id = first_free_id; + fingers[finger_id].x = x; + fingers[finger_id].y = y; + fingers[finger_id].pressed = true; + fingers[finger_id].id = finger_id; + fingers[finger_id].attribute.start_touch.Assign(1); + } + } else { + fingers[finger_id].x = x; + fingers[finger_id].y = y; + fingers[finger_id].attribute.raw = 0; + } + } else if (finger_id != -1) { + if (!fingers[finger_id].attribute.end_touch) { + fingers[finger_id].attribute.end_touch.Assign(1); + fingers[finger_id].attribute.start_touch.Assign(0); + } else { + fingers[finger_id].pressed = false; + finger_id = -1; + } + } +} + } // namespace Service::HID diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index 4d9042adc..6c7620420 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h @@ -30,6 +30,9 @@ public: void OnLoadInputDevices() override; private: + void updateTouchInputEvent(const std::tuple& touch_input, int& finger_id); + static const size_t MAX_FINGERS = 16; + struct Attributes { union { u32 raw{}; @@ -55,7 +58,7 @@ private: s64_le sampling_number; s64_le sampling_number2; s32_le entry_count; - std::array states; + std::array states; }; static_assert(sizeof(TouchScreenEntry) == 0x298, "TouchScreenEntry is an invalid size"); @@ -66,9 +69,21 @@ private: }; static_assert(sizeof(TouchScreenSharedMemory) == 0x3000, "TouchScreenSharedMemory is an invalid size"); + + struct Finger { + u64_le last_touch{}; + float x{}; + float y{}; + u32_le id{}; + bool pressed{}; + Attributes attribute; + }; + TouchScreenSharedMemory shared_memory{}; std::unique_ptr touch_device; std::unique_ptr touch_btn_device; - s64_le last_touch{}; + int mouse_finger_id{-1}; + int keyboar_finger_id{-1}; + std::array fingers; }; } // namespace Service::HID -- cgit v1.2.3 From 390ee10eefea4249aff94eb5351a908e3cafe228 Mon Sep 17 00:00:00 2001 From: german Date: Fri, 1 Jan 2021 10:40:02 -0600 Subject: Allow all touch inputs at the same time and remove config options that are not longer necesary --- src/core/hle/service/hid/controllers/touchscreen.cpp | 16 +++++++++------- src/core/hle/service/hid/controllers/touchscreen.h | 15 +++++++++++---- 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'src/core/hle/service/hid/controllers') diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index de8315ce4..13f75b48a 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -40,11 +40,12 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin cur_entry.sampling_number = last_entry.sampling_number + 1; cur_entry.sampling_number2 = cur_entry.sampling_number; - updateTouchInputEvent(touch_device->GetStatus(), mouse_finger_id); - updateTouchInputEvent(touch_btn_device->GetStatus(), keyboar_finger_id); + updateTouchInputEvent(touch_mouse_device->GetStatus(), mouse_finger_id); + updateTouchInputEvent(touch_btn_device->GetStatus(), keyboard_finger_id); + updateTouchInputEvent(touch_udp_device->GetStatus(), udp_finger_id); std::array sorted_fingers; - s32_le active_fingers = 0; + size_t active_fingers = 0; for (Finger finger : fingers) { if (finger.pressed) { sorted_fingers[active_fingers++] = finger; @@ -52,7 +53,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin } const u64 tick = core_timing.GetCPUTicks(); - cur_entry.entry_count = active_fingers; + cur_entry.entry_count = static_cast(active_fingers); for (size_t id = 0; id < MAX_FINGERS; id++) { auto& touch_entry = cur_entry.states[id]; if (id < active_fingers) { @@ -81,7 +82,8 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin } void Controller_Touchscreen::OnLoadInputDevices() { - touch_device = Input::CreateDevice(Settings::values.touchscreen.device); + touch_mouse_device = Input::CreateDevice("engine:emu_window"); + touch_udp_device = Input::CreateDevice("engine:cemuhookudp"); if (Settings::values.use_touch_from_button) { touch_btn_device = Input::CreateDevice("engine:touch_from_button"); } else { @@ -90,7 +92,7 @@ void Controller_Touchscreen::OnLoadInputDevices() { } void Controller_Touchscreen::updateTouchInputEvent( - const std::tuple& touch_input, int& finger_id) { + const std::tuple& touch_input, size_t& finger_id) { bool pressed = false; float x, y; std::tie(x, y, pressed) = touch_input; @@ -110,7 +112,7 @@ void Controller_Touchscreen::updateTouchInputEvent( fingers[finger_id].x = x; fingers[finger_id].y = y; fingers[finger_id].pressed = true; - fingers[finger_id].id = finger_id; + fingers[finger_id].id = static_cast(finger_id); fingers[finger_id].attribute.start_touch.Assign(1); } } else { diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index 6c7620420..03f399344 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h @@ -30,7 +30,12 @@ public: void OnLoadInputDevices() override; private: - void updateTouchInputEvent(const std::tuple& touch_input, int& finger_id); + // If the touch is new it tries to assing a new finger id, if there is no fingers avaliable no + // changes will be made. Updates the coordinates if the finger id it's already set. If the touch + // ends delays the output by one frame to set the end_touch flag before finally freeing the + // finger id + void updateTouchInputEvent(const std::tuple& touch_input, + size_t& finger_id); static const size_t MAX_FINGERS = 16; struct Attributes { @@ -80,10 +85,12 @@ private: }; TouchScreenSharedMemory shared_memory{}; - std::unique_ptr touch_device; + std::unique_ptr touch_mouse_device; + std::unique_ptr touch_udp_device; std::unique_ptr touch_btn_device; - int mouse_finger_id{-1}; - int keyboar_finger_id{-1}; + size_t mouse_finger_id{-1}; + size_t keyboard_finger_id{-1}; + size_t udp_finger_id{-1}; std::array fingers; }; } // namespace Service::HID -- cgit v1.2.3 From d8df9a16bd4f4517b024c17446a94915493d7f3d Mon Sep 17 00:00:00 2001 From: german Date: Fri, 1 Jan 2021 12:32:29 -0600 Subject: Allow to return up to 16 touch inputs per engine --- .../hle/service/hid/controllers/touchscreen.cpp | 114 ++++++++++++--------- src/core/hle/service/hid/controllers/touchscreen.h | 16 +-- 2 files changed, 75 insertions(+), 55 deletions(-) (limited to 'src/core/hle/service/hid/controllers') diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index 13f75b48a..dc0d2c712 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include #include #include "common/common_types.h" #include "core/core_timing.h" @@ -16,7 +17,13 @@ constexpr std::size_t SHARED_MEMORY_OFFSET = 0x400; Controller_Touchscreen::Controller_Touchscreen(Core::System& system) : ControllerBase(system) {} Controller_Touchscreen::~Controller_Touchscreen() = default; -void Controller_Touchscreen::OnInit() {} +void Controller_Touchscreen::OnInit() { + for (size_t id = 0; id < MAX_FINGERS; id++) { + mouse_finger_id[id] = MAX_FINGERS; + keyboard_finger_id[id] = MAX_FINGERS; + udp_finger_id[id] = MAX_FINGERS; + } +} void Controller_Touchscreen::OnRelease() {} @@ -40,32 +47,35 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin cur_entry.sampling_number = last_entry.sampling_number + 1; cur_entry.sampling_number2 = cur_entry.sampling_number; - updateTouchInputEvent(touch_mouse_device->GetStatus(), mouse_finger_id); - updateTouchInputEvent(touch_btn_device->GetStatus(), keyboard_finger_id); - updateTouchInputEvent(touch_udp_device->GetStatus(), udp_finger_id); - - std::array sorted_fingers; - size_t active_fingers = 0; - for (Finger finger : fingers) { - if (finger.pressed) { - sorted_fingers[active_fingers++] = finger; - } + const Input::TouchStatus& mouse_status = touch_mouse_device->GetStatus(); + const Input::TouchStatus& keyboard_status = touch_btn_device->GetStatus(); + const Input::TouchStatus& udp_status = touch_udp_device->GetStatus(); + for (size_t id = 0; id < mouse_status.size(); id++) { + mouse_finger_id[id] = UpdateTouchInputEvent(mouse_status[id], mouse_finger_id[id]); + keyboard_finger_id[id] = UpdateTouchInputEvent(keyboard_status[id], keyboard_finger_id[id]); + udp_finger_id[id] = UpdateTouchInputEvent(udp_status[id], udp_finger_id[id]); } + std::array active_fingers; + const auto end_iter = std::copy_if(fingers.begin(), fingers.end(), active_fingers.begin(), + [](const auto& finger) { return finger.pressed; }); + const auto active_fingers_count = + static_cast(std::distance(active_fingers.begin(), end_iter)); + const u64 tick = core_timing.GetCPUTicks(); - cur_entry.entry_count = static_cast(active_fingers); + cur_entry.entry_count = static_cast(active_fingers_count); for (size_t id = 0; id < MAX_FINGERS; id++) { auto& touch_entry = cur_entry.states[id]; - if (id < active_fingers) { - touch_entry.x = static_cast(sorted_fingers[id].x * Layout::ScreenUndocked::Width); - touch_entry.y = static_cast(sorted_fingers[id].y * Layout::ScreenUndocked::Height); + if (id < active_fingers_count) { + touch_entry.x = static_cast(active_fingers[id].x * Layout::ScreenUndocked::Width); + touch_entry.y = static_cast(active_fingers[id].y * Layout::ScreenUndocked::Height); touch_entry.diameter_x = Settings::values.touchscreen.diameter_x; touch_entry.diameter_y = Settings::values.touchscreen.diameter_y; touch_entry.rotation_angle = Settings::values.touchscreen.rotation_angle; - touch_entry.delta_time = tick - sorted_fingers[id].last_touch; - sorted_fingers[id].last_touch = tick; - touch_entry.finger = sorted_fingers[id].id; - touch_entry.attribute.raw = sorted_fingers[id].attribute.raw; + touch_entry.delta_time = tick - active_fingers[id].last_touch; + active_fingers[id].last_touch = tick; + touch_entry.finger = active_fingers[id].id; + touch_entry.attribute.raw = active_fingers[id].attribute.raw; } else { // Clear touch entry touch_entry.attribute.raw = 0; @@ -91,44 +101,50 @@ void Controller_Touchscreen::OnLoadInputDevices() { } } -void Controller_Touchscreen::updateTouchInputEvent( - const std::tuple& touch_input, size_t& finger_id) { - bool pressed = false; - float x, y; - std::tie(x, y, pressed) = touch_input; +std::optional Controller_Touchscreen::GetUnusedFingerID() const { + size_t first_free_id = 0; + while (first_free_id < MAX_FINGERS) { + if (!fingers[first_free_id].pressed) { + return first_free_id; + } else { + first_free_id++; + } + } + return std::nullopt; +} + +size_t Controller_Touchscreen::UpdateTouchInputEvent( + const std::tuple& touch_input, size_t finger_id) { + const auto& [x, y, pressed] = touch_input; if (pressed) { - if (finger_id == -1) { - int first_free_id = 0; - int found = false; - while (!found && first_free_id < MAX_FINGERS) { - if (!fingers[first_free_id].pressed) { - found = true; - } else { - first_free_id++; - } + Attributes attribute = {}; + if (finger_id == MAX_FINGERS) { + const auto first_free_id = GetUnusedFingerID(); + if (!first_free_id) { + // Invalid finger id do nothing + return MAX_FINGERS; } - if (found) { - finger_id = first_free_id; - fingers[finger_id].x = x; - fingers[finger_id].y = y; - fingers[finger_id].pressed = true; - fingers[finger_id].id = static_cast(finger_id); - fingers[finger_id].attribute.start_touch.Assign(1); - } - } else { - fingers[finger_id].x = x; - fingers[finger_id].y = y; - fingers[finger_id].attribute.raw = 0; + finger_id = first_free_id.value(); + fingers[finger_id].pressed = true; + fingers[finger_id].id = static_cast(finger_id); + attribute.start_touch.Assign(1); } - } else if (finger_id != -1) { + fingers[finger_id].x = x; + fingers[finger_id].y = y; + fingers[finger_id].attribute = attribute; + return finger_id; + } + + if (finger_id != MAX_FINGERS) { if (!fingers[finger_id].attribute.end_touch) { fingers[finger_id].attribute.end_touch.Assign(1); fingers[finger_id].attribute.start_touch.Assign(0); - } else { - fingers[finger_id].pressed = false; - finger_id = -1; + return finger_id; } + fingers[finger_id].pressed = false; } + + return MAX_FINGERS; } } // namespace Service::HID diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index 03f399344..e39ab89ee 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h @@ -30,13 +30,17 @@ public: void OnLoadInputDevices() override; private: + static constexpr size_t MAX_FINGERS = 16; + + // Returns an unused finger id, if there is no fingers available std::nullopt will be returned + std::optional GetUnusedFingerID() const; + // If the touch is new it tries to assing a new finger id, if there is no fingers avaliable no // changes will be made. Updates the coordinates if the finger id it's already set. If the touch // ends delays the output by one frame to set the end_touch flag before finally freeing the // finger id - void updateTouchInputEvent(const std::tuple& touch_input, - size_t& finger_id); - static const size_t MAX_FINGERS = 16; + size_t UpdateTouchInputEvent(const std::tuple& touch_input, + size_t finger_id); struct Attributes { union { @@ -88,9 +92,9 @@ private: std::unique_ptr touch_mouse_device; std::unique_ptr touch_udp_device; std::unique_ptr touch_btn_device; - size_t mouse_finger_id{-1}; - size_t keyboard_finger_id{-1}; - size_t udp_finger_id{-1}; + std::array mouse_finger_id; + std::array keyboard_finger_id; + std::array udp_finger_id; std::array fingers; }; } // namespace Service::HID -- cgit v1.2.3 From 8495e1bd8373fed993975e40c360c87409455e9e Mon Sep 17 00:00:00 2001 From: german Date: Sat, 2 Jan 2021 22:04:50 -0600 Subject: Add mutitouch support for touch screens --- .../hle/service/hid/controllers/touchscreen.cpp | 30 +++++++++++++--------- src/core/hle/service/hid/controllers/touchscreen.h | 14 +++++----- 2 files changed, 25 insertions(+), 19 deletions(-) (limited to 'src/core/hle/service/hid/controllers') diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index dc0d2c712..cd318f25b 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -18,7 +18,7 @@ Controller_Touchscreen::Controller_Touchscreen(Core::System& system) : Controlle Controller_Touchscreen::~Controller_Touchscreen() = default; void Controller_Touchscreen::OnInit() { - for (size_t id = 0; id < MAX_FINGERS; id++) { + for (std::size_t id = 0; id < MAX_FINGERS; ++id) { mouse_finger_id[id] = MAX_FINGERS; keyboard_finger_id[id] = MAX_FINGERS; udp_finger_id[id] = MAX_FINGERS; @@ -48,23 +48,29 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin cur_entry.sampling_number2 = cur_entry.sampling_number; const Input::TouchStatus& mouse_status = touch_mouse_device->GetStatus(); - const Input::TouchStatus& keyboard_status = touch_btn_device->GetStatus(); const Input::TouchStatus& udp_status = touch_udp_device->GetStatus(); - for (size_t id = 0; id < mouse_status.size(); id++) { + for (std::size_t id = 0; id < mouse_status.size(); ++id) { mouse_finger_id[id] = UpdateTouchInputEvent(mouse_status[id], mouse_finger_id[id]); - keyboard_finger_id[id] = UpdateTouchInputEvent(keyboard_status[id], keyboard_finger_id[id]); udp_finger_id[id] = UpdateTouchInputEvent(udp_status[id], udp_finger_id[id]); } + if (Settings::values.use_touch_from_button) { + const Input::TouchStatus& keyboard_status = touch_btn_device->GetStatus(); + for (std::size_t id = 0; id < mouse_status.size(); ++id) { + keyboard_finger_id[id] = + UpdateTouchInputEvent(keyboard_status[id], keyboard_finger_id[id]); + } + } + std::array active_fingers; const auto end_iter = std::copy_if(fingers.begin(), fingers.end(), active_fingers.begin(), [](const auto& finger) { return finger.pressed; }); const auto active_fingers_count = - static_cast(std::distance(active_fingers.begin(), end_iter)); + static_cast(std::distance(active_fingers.begin(), end_iter)); const u64 tick = core_timing.GetCPUTicks(); cur_entry.entry_count = static_cast(active_fingers_count); - for (size_t id = 0; id < MAX_FINGERS; id++) { + for (std::size_t id = 0; id < MAX_FINGERS; ++id) { auto& touch_entry = cur_entry.states[id]; if (id < active_fingers_count) { touch_entry.x = static_cast(active_fingers[id].x * Layout::ScreenUndocked::Width); @@ -73,7 +79,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin touch_entry.diameter_y = Settings::values.touchscreen.diameter_y; touch_entry.rotation_angle = Settings::values.touchscreen.rotation_angle; touch_entry.delta_time = tick - active_fingers[id].last_touch; - active_fingers[id].last_touch = tick; + fingers[active_fingers[id].id].last_touch = tick; touch_entry.finger = active_fingers[id].id; touch_entry.attribute.raw = active_fingers[id].attribute.raw; } else { @@ -101,8 +107,8 @@ void Controller_Touchscreen::OnLoadInputDevices() { } } -std::optional Controller_Touchscreen::GetUnusedFingerID() const { - size_t first_free_id = 0; +std::optional Controller_Touchscreen::GetUnusedFingerID() const { + std::size_t first_free_id = 0; while (first_free_id < MAX_FINGERS) { if (!fingers[first_free_id].pressed) { return first_free_id; @@ -113,11 +119,11 @@ std::optional Controller_Touchscreen::GetUnusedFingerID() const { return std::nullopt; } -size_t Controller_Touchscreen::UpdateTouchInputEvent( - const std::tuple& touch_input, size_t finger_id) { +std::size_t Controller_Touchscreen::UpdateTouchInputEvent( + const std::tuple& touch_input, std::size_t finger_id) { const auto& [x, y, pressed] = touch_input; if (pressed) { - Attributes attribute = {}; + Attributes attribute{}; if (finger_id == MAX_FINGERS) { const auto first_free_id = GetUnusedFingerID(); if (!first_free_id) { diff --git a/src/core/hle/service/hid/controllers/touchscreen.h b/src/core/hle/service/hid/controllers/touchscreen.h index e39ab89ee..784124e25 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.h +++ b/src/core/hle/service/hid/controllers/touchscreen.h @@ -30,17 +30,17 @@ public: void OnLoadInputDevices() override; private: - static constexpr size_t MAX_FINGERS = 16; + static constexpr std::size_t MAX_FINGERS = 16; // Returns an unused finger id, if there is no fingers available std::nullopt will be returned - std::optional GetUnusedFingerID() const; + std::optional GetUnusedFingerID() const; // If the touch is new it tries to assing a new finger id, if there is no fingers avaliable no // changes will be made. Updates the coordinates if the finger id it's already set. If the touch // ends delays the output by one frame to set the end_touch flag before finally freeing the // finger id - size_t UpdateTouchInputEvent(const std::tuple& touch_input, - size_t finger_id); + std::size_t UpdateTouchInputEvent(const std::tuple& touch_input, + std::size_t finger_id); struct Attributes { union { @@ -92,9 +92,9 @@ private: std::unique_ptr touch_mouse_device; std::unique_ptr touch_udp_device; std::unique_ptr touch_btn_device; - std::array mouse_finger_id; - std::array keyboard_finger_id; - std::array udp_finger_id; + std::array mouse_finger_id; + std::array keyboard_finger_id; + std::array udp_finger_id; std::array fingers; }; } // namespace Service::HID -- cgit v1.2.3 From b483f2d010bf745ab873e8f8bfaca5515e56d39f Mon Sep 17 00:00:00 2001 From: german Date: Sun, 10 Jan 2021 08:36:31 -0600 Subject: Always initialize keyboard input --- src/core/hle/service/hid/controllers/touchscreen.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/core/hle/service/hid/controllers') diff --git a/src/core/hle/service/hid/controllers/touchscreen.cpp b/src/core/hle/service/hid/controllers/touchscreen.cpp index cd318f25b..5219f2dad 100644 --- a/src/core/hle/service/hid/controllers/touchscreen.cpp +++ b/src/core/hle/service/hid/controllers/touchscreen.cpp @@ -100,11 +100,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin void Controller_Touchscreen::OnLoadInputDevices() { touch_mouse_device = Input::CreateDevice("engine:emu_window"); touch_udp_device = Input::CreateDevice("engine:cemuhookudp"); - if (Settings::values.use_touch_from_button) { - touch_btn_device = Input::CreateDevice("engine:touch_from_button"); - } else { - touch_btn_device.reset(); - } + touch_btn_device = Input::CreateDevice("engine:touch_from_button"); } std::optional Controller_Touchscreen::GetUnusedFingerID() const { -- cgit v1.2.3