void execute_pinch(int fd, uint32_t device_flags, int touch1_x1, int touch1_y1, int touch1_x2, int touch1_y2, int touch2_x1, int touch2_y1, int touch2_x2, int touch2_y2, int num_steps, int duration_msec) { int delta1[] = {(touch1_x2-touch1_x1)/num_steps, (touch1_y2-touch1_y1)/num_steps}; int delta2[] = {(touch2_x2-touch2_x1)/num_steps, (touch2_y2-touch2_y1)/num_steps}; int sleeptime = duration_msec / num_steps; int i; print_action(ACTION_START, "pinch", "\"touch1_x1\": %d, \"touch1_y1\": %d, \"touch1_x2\": %d, " "\"touch1_y2\": %d, \"touch2_x1\": %d, \"touch2_y1\": %d, " "\"touch2_x2\": %d, \"touch2_y2\": %d, \"num_steps\": %d, " "\"duration_msec\": %d", touch1_x1, touch1_y1, touch1_x2, touch1_y2, touch2_x1, touch2_y1, touch2_x2, touch2_y2, num_steps, duration_msec); // press change_mt_slot(fd, device_flags, 0); add_mt_tracking_id(fd, device_flags, global_tracking_id++); execute_press(fd, device_flags, touch1_x1, touch1_y1); change_mt_slot(fd, device_flags, 1); add_mt_tracking_id(fd, device_flags, global_tracking_id++); execute_press(fd, device_flags, touch2_x1, touch2_y1); // drag for (i=0; i<num_steps; i++) { execute_sleep(sleeptime); change_mt_slot(fd, device_flags, 0); execute_move(fd, device_flags, touch1_x1+delta1[0]*i, touch1_y1+delta1[1]*i); change_mt_slot(fd, device_flags, 1); execute_move(fd, device_flags, touch2_x1+delta2[0]*i, touch2_y1+delta2[1]*i); //write_event(fd, EV_SYN, SYN_REPORT, 0); } // release change_mt_slot(fd, device_flags, 0); execute_release(fd, device_flags); change_mt_slot(fd, device_flags, 1); execute_release(fd, device_flags); remove_mt_tracking_id(fd, device_flags, 0); remove_mt_tracking_id(fd, device_flags, 1); // wait execute_sleep(100); print_action(ACTION_END, "pinch", NULL); }
void execute_pinch(int fd, int version, unsigned int device_flags, int touch1_x1, int touch1_y1, int touch1_x2, int touch1_y2, int touch2_x1, int touch2_y1, int touch2_x2, int touch2_y2, int num_steps, int duration_msec) { int delta1[] = {(touch1_x2-touch1_x1)/num_steps, (touch1_y2-touch1_y1)/num_steps}; int delta2[] = {(touch2_x2-touch2_x1)/num_steps, (touch2_y2-touch2_y1)/num_steps}; int sleeptime = duration_msec / num_steps; int i; // press change_mt_slot(fd, version, device_flags, 0); add_mt_tracking_id(fd, version, device_flags, global_tracking_id++); execute_press(fd, version, device_flags, touch1_x1, touch1_y1); change_mt_slot(fd, version, device_flags, 1); add_mt_tracking_id(fd, version, device_flags, global_tracking_id++); execute_press(fd, version, device_flags, touch2_x1, touch2_y1); // drag for (i=0; i<num_steps; i++) { execute_sleep(sleeptime); change_mt_slot(fd, version, device_flags, 0); execute_move(fd, version, device_flags, touch1_x1+delta1[0]*i, touch1_y1+delta1[1]*i); change_mt_slot(fd, version, device_flags, 1); execute_move(fd, version, device_flags, touch2_x1+delta2[0]*i, touch2_y1+delta2[1]*i); //write_event(fd, EV_SYN, SYN_REPORT, 0); } // release change_mt_slot(fd, version, device_flags, 0); execute_release(fd, version, device_flags); change_mt_slot(fd, version, device_flags, 1); execute_release(fd, version, device_flags); remove_mt_tracking_id(fd, version, device_flags, 0); remove_mt_tracking_id(fd, version, device_flags, 1); // wait execute_sleep(100); }