summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/hid
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/service/hid')
-rw-r--r--src/core/hle/service/hid/controllers/touchscreen.cpp16
-rw-r--r--src/core/hle/service/hid/controllers/touchscreen.h15
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
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<Finger, 16> 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<s32_le>(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<Input::TouchDevice>(Settings::values.touchscreen.device);
+ touch_mouse_device = Input::CreateDevice<Input::TouchDevice>("engine:emu_window");
+ touch_udp_device = Input::CreateDevice<Input::TouchDevice>("engine:cemuhookudp");
if (Settings::values.use_touch_from_button) {
touch_btn_device = Input::CreateDevice<Input::TouchDevice>("engine:touch_from_button");
} else {
@@ -90,7 +92,7 @@ void Controller_Touchscreen::OnLoadInputDevices() {
}
void Controller_Touchscreen::updateTouchInputEvent(
- const std::tuple<float, float, bool>& touch_input, int& finger_id) {
+ const std::tuple<float, float, bool>& 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<u32_le>(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<float, float, bool>& 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<float, float, bool>& 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<Input::TouchDevice> touch_device;
+ std::unique_ptr<Input::TouchDevice> touch_mouse_device;
+ std::unique_ptr<Input::TouchDevice> touch_udp_device;
std::unique_ptr<Input::TouchDevice> 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<Finger, MAX_FINGERS> fingers;
};
} // namespace Service::HID