@@ -926,6 +926,33 @@ namespace lvh::detail::test {
926926 return create_fake_libevdev_device (DeviceType::gamepad, keep_fake_libevdev_successful, kind);
927927 }
928928
929+ template <typename TouchDevice>
930+ LinuxInputSubmissionResult touch_contact_reuse_pipe () {
931+ std::array<int , 2 > descriptors {-1 , -1 };
932+ if (::pipe (descriptors.data ()) != 0 ) {
933+ return {system_error_status (ErrorCode::backend_failure, " failed to create pipe" , errno), {}};
934+ }
935+
936+ TouchDevice device {descriptors[1 ]};
937+ auto status = device.place_contact ({.id = 0 , .x = 0 .1F , .y = 0 .1F , .pressure = 0 .5F });
938+ if (status.ok ()) {
939+ status = device.place_contact ({.id = 1 , .x = 0 .2F , .y = 0 .2F , .pressure = 0 .5F });
940+ }
941+ if (status.ok ()) {
942+ status = device.release_contact (0 , PointerTransition::release);
943+ }
944+ if (status.ok ()) {
945+ status = device.place_contact ({.id = 0 , .x = 0 .3F , .y = 0 .3F , .pressure = 0 .5F });
946+ }
947+ if (status.ok ()) {
948+ status = device.place_contact ({.id = 1 , .x = 0 .25F , .y = 0 .25F , .pressure = 0 .5F });
949+ }
950+ static_cast <void >(device.close ());
951+ auto records = read_input_events_until_eof (descriptors[0 ]);
952+ static_cast <void >(::close (descriptors[0 ]));
953+ return {std::move (status), std::move (records)};
954+ }
955+
929956 } // namespace
930957
931958 std::string linux_copy_string_char_buffer (const std::string &source) {
@@ -1384,6 +1411,20 @@ namespace lvh::detail::test {
13841411 return {std::move (status), std::move (records)};
13851412 }
13861413
1414+ LinuxInputSubmissionResult linux_uinput_touch_contact_reuse_pipe (DeviceType device_type) {
1415+ switch (device_type) {
1416+ case DeviceType::touchscreen:
1417+ return touch_contact_reuse_pipe<UinputTouchscreen>();
1418+ case DeviceType::trackpad:
1419+ return touch_contact_reuse_pipe<UinputTrackpad>();
1420+ default :
1421+ return {
1422+ OperationStatus::failure (ErrorCode::invalid_argument, " device type must be touchscreen or trackpad" ),
1423+ {},
1424+ };
1425+ }
1426+ }
1427+
13871428 OperationStatus linux_uinput_touchscreen_invalid_contacts () {
13881429 std::array<int , 2 > descriptors {-1 , -1 };
13891430 if (::pipe (descriptors.data ()) != 0 ) {
0 commit comments