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_drag(int fd, uint32_t device_flags, int start_x, int start_y, int end_x, int end_y, int num_steps, int duration_msec) { int delta[] = {(end_x-start_x)/num_steps, (end_y-start_y)/num_steps}; int sleeptime = duration_msec / num_steps; int i; print_action(ACTION_START, "drag", "\"start_x\": %d, \"start_y\": %d, " "\"end_x\": %d, \"end_y\": %d, \"num_steps\": %d, " "\"duration_msec\": %d", start_x, start_y, end_x, end_y, num_steps, duration_msec); // press execute_press(fd, device_flags, start_x, start_y); // drag for (i=0; i<num_steps; i++) { execute_sleep(sleeptime); execute_move(fd, device_flags, start_x+delta[0]*i, start_y+delta[1]*i); } // release execute_release(fd, device_flags); // wait execute_sleep(100); print_action(ACTION_END, "drag", 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); }
void execute_drag(int fd, uint32_t device_flags, int start_x, int start_y, int end_x, int end_y, int num_steps, int duration_msec) { int delta[] = {(end_x-start_x)/num_steps, (end_y-start_y)/num_steps}; double desired_interval_msec, avg_event_dispatch_time_msec; struct timespec start_time, current_time, time_before_last_move; int i; clock_gettime(CLOCK_MONOTONIC, &start_time); double start_nsecs = (double) (start_time.tv_sec * (1000*1000)) + start_time.tv_nsec; print_action(ACTION_START, "drag", "\"start_x\": %d, \"start_y\": %d, " "\"end_x\": %d, \"end_y\": %d, \"num_steps\": %d, " "\"duration_msec\": %d", start_x, start_y, end_x, end_y, num_steps, duration_msec); // press clock_gettime(CLOCK_MONOTONIC, &time_before_last_move); execute_press(fd, device_flags, start_x, start_y); // drag desired_interval_msec = duration_msec / num_steps; for (i=0; i<num_steps; i++) { clock_gettime(CLOCK_MONOTONIC, ¤t_time); avg_event_dispatch_time_msec = ((avg_event_dispatch_time_msec * i) + timediff_msec(&time_before_last_move, ¤t_time)) / i; if (desired_interval_msec > 0 && avg_event_dispatch_time_msec < desired_interval_msec) { execute_sleep(desired_interval_msec - avg_event_dispatch_time_msec); } memcpy(&time_before_last_move, ¤t_time, sizeof(struct timespec)); execute_move(fd, device_flags, start_x+delta[0]*i, start_y+delta[1]*i); } // release execute_release(fd, device_flags); // wait execute_sleep(100); print_action(ACTION_END, "drag", NULL); }
void execute_tap(int fd, int version, unsigned int device_flags, int x, int y, int num_times) { int i; for (i=0;i<num_times;i++) { // press execute_press(fd, version, device_flags, x, y); execute_sleep(100); // release execute_release(fd, version, device_flags); execute_sleep(100); // wait execute_sleep(50); } }
void execute_tap(int fd, uint32_t device_flags, int x, int y, int num_times, int duration_msec) { int i; for (i=0; i<num_times; i++) { // press execute_press(fd, device_flags, x, y); execute_sleep(duration_msec); // release execute_release(fd, device_flags); execute_sleep(100); // wait execute_sleep(50); } }
void execute_drag(int fd, int version, unsigned int device_flags, int start_x, int start_y, int end_x, int end_y, int num_steps, int duration_msec) { int delta[] = {(end_x-start_x)/num_steps, (end_y-start_y)/num_steps}; int sleeptime = duration_msec / num_steps; int i; // press execute_press(fd, version, device_flags, start_x, start_y); // drag for (i=0; i<num_steps; i++) { execute_sleep(sleeptime); execute_move(fd, version, device_flags, start_x+delta[0]*i, start_y+delta[1]*i); } // release execute_release(fd, version, device_flags); // wait execute_sleep(100); }
void execute_tap(int fd, uint32_t device_flags, int x, int y, int num_times, int duration_msec) { int i; print_action(ACTION_START, "tap", "\"x\": %d, \"y\": %d, " "\"num_times\": %d, \"duration_msec\": %d", x, y, num_times, duration_msec); for (i=0; i<num_times; i++) { // press execute_press(fd, device_flags, x, y); execute_sleep(duration_msec); // release execute_release(fd, device_flags); execute_sleep(100); // wait execute_sleep(50); } print_action(ACTION_END, "tap", NULL); }