diff options
| author | 2021-01-01 10:40:02 -0600 | |
|---|---|---|
| committer | 2021-01-15 09:05:17 -0600 | |
| commit | 390ee10eefea4249aff94eb5351a908e3cafe228 (patch) | |
| tree | 075185209ebab612070fed9066269272557e41c4 /src/core | |
| parent | Add multitouch support (diff) | |
| download | yuzu-390ee10eefea4249aff94eb5351a908e3cafe228.tar.gz yuzu-390ee10eefea4249aff94eb5351a908e3cafe228.tar.xz yuzu-390ee10eefea4249aff94eb5351a908e3cafe228.zip | |
Allow all touch inputs at the same time and remove config options that are not longer necesary
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/touchscreen.h | 15 |
2 files changed, 20 insertions, 11 deletions
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 | |||
| 40 | cur_entry.sampling_number = last_entry.sampling_number + 1; | 40 | cur_entry.sampling_number = last_entry.sampling_number + 1; |
| 41 | cur_entry.sampling_number2 = cur_entry.sampling_number; | 41 | cur_entry.sampling_number2 = cur_entry.sampling_number; |
| 42 | 42 | ||
| 43 | updateTouchInputEvent(touch_device->GetStatus(), mouse_finger_id); | 43 | updateTouchInputEvent(touch_mouse_device->GetStatus(), mouse_finger_id); |
| 44 | updateTouchInputEvent(touch_btn_device->GetStatus(), keyboar_finger_id); | 44 | updateTouchInputEvent(touch_btn_device->GetStatus(), keyboard_finger_id); |
| 45 | updateTouchInputEvent(touch_udp_device->GetStatus(), udp_finger_id); | ||
| 45 | 46 | ||
| 46 | std::array<Finger, 16> sorted_fingers; | 47 | std::array<Finger, 16> sorted_fingers; |
| 47 | s32_le active_fingers = 0; | 48 | size_t active_fingers = 0; |
| 48 | for (Finger finger : fingers) { | 49 | for (Finger finger : fingers) { |
| 49 | if (finger.pressed) { | 50 | if (finger.pressed) { |
| 50 | sorted_fingers[active_fingers++] = finger; | 51 | sorted_fingers[active_fingers++] = finger; |
| @@ -52,7 +53,7 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin | |||
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | const u64 tick = core_timing.GetCPUTicks(); | 55 | const u64 tick = core_timing.GetCPUTicks(); |
| 55 | cur_entry.entry_count = active_fingers; | 56 | cur_entry.entry_count = static_cast<s32_le>(active_fingers); |
| 56 | for (size_t id = 0; id < MAX_FINGERS; id++) { | 57 | for (size_t id = 0; id < MAX_FINGERS; id++) { |
| 57 | auto& touch_entry = cur_entry.states[id]; | 58 | auto& touch_entry = cur_entry.states[id]; |
| 58 | if (id < active_fingers) { | 59 | if (id < active_fingers) { |
| @@ -81,7 +82,8 @@ void Controller_Touchscreen::OnUpdate(const Core::Timing::CoreTiming& core_timin | |||
| 81 | } | 82 | } |
| 82 | 83 | ||
| 83 | void Controller_Touchscreen::OnLoadInputDevices() { | 84 | void Controller_Touchscreen::OnLoadInputDevices() { |
| 84 | touch_device = Input::CreateDevice<Input::TouchDevice>(Settings::values.touchscreen.device); | 85 | touch_mouse_device = Input::CreateDevice<Input::TouchDevice>("engine:emu_window"); |
| 86 | touch_udp_device = Input::CreateDevice<Input::TouchDevice>("engine:cemuhookudp"); | ||
| 85 | if (Settings::values.use_touch_from_button) { | 87 | if (Settings::values.use_touch_from_button) { |
| 86 | touch_btn_device = Input::CreateDevice<Input::TouchDevice>("engine:touch_from_button"); | 88 | touch_btn_device = Input::CreateDevice<Input::TouchDevice>("engine:touch_from_button"); |
| 87 | } else { | 89 | } else { |
| @@ -90,7 +92,7 @@ void Controller_Touchscreen::OnLoadInputDevices() { | |||
| 90 | } | 92 | } |
| 91 | 93 | ||
| 92 | void Controller_Touchscreen::updateTouchInputEvent( | 94 | void Controller_Touchscreen::updateTouchInputEvent( |
| 93 | const std::tuple<float, float, bool>& touch_input, int& finger_id) { | 95 | const std::tuple<float, float, bool>& touch_input, size_t& finger_id) { |
| 94 | bool pressed = false; | 96 | bool pressed = false; |
| 95 | float x, y; | 97 | float x, y; |
| 96 | std::tie(x, y, pressed) = touch_input; | 98 | std::tie(x, y, pressed) = touch_input; |
| @@ -110,7 +112,7 @@ void Controller_Touchscreen::updateTouchInputEvent( | |||
| 110 | fingers[finger_id].x = x; | 112 | fingers[finger_id].x = x; |
| 111 | fingers[finger_id].y = y; | 113 | fingers[finger_id].y = y; |
| 112 | fingers[finger_id].pressed = true; | 114 | fingers[finger_id].pressed = true; |
| 113 | fingers[finger_id].id = finger_id; | 115 | fingers[finger_id].id = static_cast<u32_le>(finger_id); |
| 114 | fingers[finger_id].attribute.start_touch.Assign(1); | 116 | fingers[finger_id].attribute.start_touch.Assign(1); |
| 115 | } | 117 | } |
| 116 | } else { | 118 | } 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: | |||
| 30 | void OnLoadInputDevices() override; | 30 | void OnLoadInputDevices() override; |
| 31 | 31 | ||
| 32 | private: | 32 | private: |
| 33 | void updateTouchInputEvent(const std::tuple<float, float, bool>& touch_input, int& finger_id); | 33 | // If the touch is new it tries to assing a new finger id, if there is no fingers avaliable no |
| 34 | // changes will be made. Updates the coordinates if the finger id it's already set. If the touch | ||
| 35 | // ends delays the output by one frame to set the end_touch flag before finally freeing the | ||
| 36 | // finger id | ||
| 37 | void updateTouchInputEvent(const std::tuple<float, float, bool>& touch_input, | ||
| 38 | size_t& finger_id); | ||
| 34 | static const size_t MAX_FINGERS = 16; | 39 | static const size_t MAX_FINGERS = 16; |
| 35 | 40 | ||
| 36 | struct Attributes { | 41 | struct Attributes { |
| @@ -80,10 +85,12 @@ private: | |||
| 80 | }; | 85 | }; |
| 81 | 86 | ||
| 82 | TouchScreenSharedMemory shared_memory{}; | 87 | TouchScreenSharedMemory shared_memory{}; |
| 83 | std::unique_ptr<Input::TouchDevice> touch_device; | 88 | std::unique_ptr<Input::TouchDevice> touch_mouse_device; |
| 89 | std::unique_ptr<Input::TouchDevice> touch_udp_device; | ||
| 84 | std::unique_ptr<Input::TouchDevice> touch_btn_device; | 90 | std::unique_ptr<Input::TouchDevice> touch_btn_device; |
| 85 | int mouse_finger_id{-1}; | 91 | size_t mouse_finger_id{-1}; |
| 86 | int keyboar_finger_id{-1}; | 92 | size_t keyboard_finger_id{-1}; |
| 93 | size_t udp_finger_id{-1}; | ||
| 87 | std::array<Finger, MAX_FINGERS> fingers; | 94 | std::array<Finger, MAX_FINGERS> fingers; |
| 88 | }; | 95 | }; |
| 89 | } // namespace Service::HID | 96 | } // namespace Service::HID |