Lines Matching +full:- +full:r

29 #define LV_GESTURE_PINCH_DOWN_THRESHOLD 0.75f /* Default value - start sending events when reached …
30 #define LV_GESTURE_PINCH_UP_THRESHOLD 1.5f /* Default value - start sending events when reached */
68 if(recognizer->config == NULL) { in lv_indev_set_pinch_up_threshold()
70 recognizer->config = lv_malloc(sizeof(lv_indev_gesture_configuration_t)); in lv_indev_set_pinch_up_threshold()
71 LV_ASSERT(recognizer->config != NULL); in lv_indev_set_pinch_up_threshold()
72 recognizer->config->pinch_down_threshold = LV_GESTURE_PINCH_DOWN_THRESHOLD; in lv_indev_set_pinch_up_threshold()
75 recognizer->config->pinch_up_threshold = threshold; in lv_indev_set_pinch_up_threshold()
83 if(recognizer->config == NULL) { in lv_indev_set_pinch_down_threshold()
85 recognizer->config = lv_malloc(sizeof(lv_indev_gesture_configuration_t)); in lv_indev_set_pinch_down_threshold()
86 LV_ASSERT(recognizer->config != NULL); in lv_indev_set_pinch_down_threshold()
87 recognizer->config->pinch_up_threshold = LV_GESTURE_PINCH_UP_THRESHOLD; in lv_indev_set_pinch_down_threshold()
90 recognizer->config->pinch_down_threshold = threshold; in lv_indev_set_pinch_down_threshold()
95 if(recognizer->info->motions[0].finger != -1) { in lv_indev_get_gesture_primary_point()
96 point->x = recognizer->info->motions[0].point.x; in lv_indev_get_gesture_primary_point()
97 point->y = recognizer->info->motions[0].point.y; in lv_indev_get_gesture_primary_point()
102 point->x = 0; in lv_indev_get_gesture_primary_point()
103 point->y = 0; in lv_indev_get_gesture_primary_point()
108 if(recognizer->state == LV_INDEV_GESTURE_STATE_ENDED || in lv_indev_recognizer_is_active()
109 recognizer->info->finger_cnt == 0) { in lv_indev_recognizer_is_active()
124 return recognizer->scale; in lv_event_get_pinch_scale()
130 point->x = 0; in lv_indev_get_gesture_center_point()
131 point->y = 0; in lv_indev_get_gesture_center_point()
135 point->x = recognizer->info->center.x; in lv_indev_get_gesture_center_point()
136 point->y = recognizer->info->center.y; in lv_indev_get_gesture_center_point()
148 return recognizer->state; in lv_event_get_gesture_state()
166 data->point.x = cur_pnt.x; in lv_indev_set_gesture_data()
167 data->point.y = cur_pnt.y; in lv_indev_set_gesture_data()
169 data->gesture_type = LV_INDEV_GESTURE_NONE; in lv_indev_set_gesture_data()
170 data->gesture_data = NULL; in lv_indev_set_gesture_data()
173 /* - OR when the gesture has ended, false is considered as a RELEASED state */ in lv_indev_set_gesture_data()
177 data->state = LV_INDEV_STATE_RELEASED; in lv_indev_set_gesture_data()
181 data->state = LV_INDEV_STATE_PRESSED; in lv_indev_set_gesture_data()
184 switch(recognizer->state) { in lv_indev_set_gesture_data()
187 data->point.x = cur_pnt.x; in lv_indev_set_gesture_data()
188 data->point.y = cur_pnt.y; in lv_indev_set_gesture_data()
189 data->gesture_type = LV_INDEV_GESTURE_PINCH; in lv_indev_set_gesture_data()
190 data->gesture_data = (void *) recognizer; in lv_indev_set_gesture_data()
194 data->gesture_type = LV_INDEV_GESTURE_PINCH; in lv_indev_set_gesture_data()
195 data->gesture_data = (void *) recognizer; in lv_indev_set_gesture_data()
208 lv_indev_gesture_recognizer_t * r = recognizer; in lv_indev_gesture_detect_pinch() local
211 if(r->info == NULL) { in lv_indev_gesture_detect_pinch()
213 r->info = init_gesture_info(); in lv_indev_gesture_detect_pinch()
216 if(r->config == NULL) { in lv_indev_gesture_detect_pinch()
217 LV_LOG_TRACE("init gesture configuration - set defaults"); in lv_indev_gesture_detect_pinch()
218 r->config = lv_malloc(sizeof(lv_indev_gesture_configuration_t)); in lv_indev_gesture_detect_pinch()
220 LV_ASSERT(r->config != NULL); in lv_indev_gesture_detect_pinch()
222 r->config->pinch_up_threshold = LV_GESTURE_PINCH_UP_THRESHOLD; in lv_indev_gesture_detect_pinch()
223 r->config->pinch_down_threshold = LV_GESTURE_PINCH_DOWN_THRESHOLD; in lv_indev_gesture_detect_pinch()
230 process_touch_event(touch, r->info); in lv_indev_gesture_detect_pinch()
234 … i, touch->id, touch->state, touch->point.x, touch->point.y, r->info->finger_cnt); in lv_indev_gesture_detect_pinch()
237 LV_LOG_TRACE("Current finger count: %d state: %d", r->info->finger_cnt, r->state); in lv_indev_gesture_detect_pinch()
240 if(r->info->finger_cnt == 2) { in lv_indev_gesture_detect_pinch()
242 switch(r->state) { in lv_indev_gesture_detect_pinch()
247 /* 2 fingers down - potential pinch or swipe */ in lv_indev_gesture_detect_pinch()
249 gesture_update_center_point(r->info, 2); in lv_indev_gesture_detect_pinch()
250 r->state = LV_INDEV_GESTURE_STATE_ONGOING; in lv_indev_gesture_detect_pinch()
256 /* It's an ongoing pinch gesture - update the factors */ in lv_indev_gesture_detect_pinch()
257 gesture_calculate_factors(r->info, 2); in lv_indev_gesture_detect_pinch()
259 if(r->info->scale > LV_GESTURE_PINCH_MAX_INITIAL_SCALE && in lv_indev_gesture_detect_pinch()
260 r->state == LV_INDEV_GESTURE_STATE_ONGOING) { in lv_indev_gesture_detect_pinch()
261 r->state = LV_INDEV_GESTURE_STATE_CANCELED; in lv_indev_gesture_detect_pinch()
265 LV_ASSERT(r->config != NULL); in lv_indev_gesture_detect_pinch()
267 if(r->info->scale > r->config->pinch_up_threshold || in lv_indev_gesture_detect_pinch()
268 r->info->scale < r->config->pinch_down_threshold) { in lv_indev_gesture_detect_pinch()
270 if(r->info->scale > 1.0f) { in lv_indev_gesture_detect_pinch()
271 r->scale = r->info->scale - (r->config->pinch_up_threshold - 1.0f); in lv_indev_gesture_detect_pinch()
274 else if(r->info->scale < 1.0f) { in lv_indev_gesture_detect_pinch()
276 r->scale = r->info->scale + (1.0f - r->config->pinch_down_threshold); in lv_indev_gesture_detect_pinch()
279 r->type = LV_INDEV_GESTURE_PINCH; in lv_indev_gesture_detect_pinch()
280 r->state = LV_INDEV_GESTURE_STATE_RECOGNIZED; in lv_indev_gesture_detect_pinch()
291 switch(r->state) { in lv_indev_gesture_detect_pinch()
294 r->state = LV_INDEV_GESTURE_STATE_ENDED; in lv_indev_gesture_detect_pinch()
295 r->type = LV_INDEV_GESTURE_PINCH; in lv_indev_gesture_detect_pinch()
300 r->state = LV_INDEV_GESTURE_STATE_CANCELED; in lv_indev_gesture_detect_pinch()
301 reset_recognizer(r); in lv_indev_gesture_detect_pinch()
306 reset_recognizer(r); in lv_indev_gesture_detect_pinch()
328 if(gesture_event == NULL || gesture_event->param == NULL) return NULL; in lv_indev_get_gesture_recognizer()
330 indev = (lv_indev_t *) gesture_event->param; in lv_indev_get_gesture_recognizer()
332 if(indev == NULL || indev->gesture_data == NULL) return NULL; in lv_indev_get_gesture_recognizer()
334 return (lv_indev_gesture_recognizer_t *) indev->gesture_data; in lv_indev_get_gesture_recognizer()
349 info = recognizer->info; in reset_recognizer()
350 conf = recognizer->config; in reset_recognizer()
355 lv_memset(info + motion_arr_sz, 0, sizeof(lv_indev_gesture_t) - motion_arr_sz); in reset_recognizer()
358 recognizer->scale = info->scale = 1; in reset_recognizer()
359 recognizer->info = info; in reset_recognizer()
360 recognizer->config = conf; in reset_recognizer()
376 info->scale = 1; in init_gesture_info()
379 info->motions[i].finger = -1; in init_gesture_info()
396 if(info->motions[i].finger == id) { in get_motion()
397 return &info->motions[i]; in get_motion()
409 * @return the index of the motion descriptor or -1 if not found
416 if(info->motions[i].finger == id) { in get_motion_idx()
421 return -1; in get_motion_idx()
437 motion_idx = get_motion_idx(touch->id, g); in process_touch_event()
439 if(motion_idx == -1 && touch->state == LV_INDEV_STATE_PRESSED) { in process_touch_event()
441 if(g->finger_cnt == LV_GESTURE_MAX_POINTS) { in process_touch_event()
447 motion = &g->motions[g->finger_cnt]; in process_touch_event()
448 motion->start_point.x = touch->point.x; in process_touch_event()
449 motion->start_point.y = touch->point.y; in process_touch_event()
450 motion->point.x = touch->point.x; in process_touch_event()
451 motion->point.y = touch->point.y; in process_touch_event()
452 motion->finger = touch->id; in process_touch_event()
453 motion->state = touch->state; in process_touch_event()
455 g->finger_cnt++; in process_touch_event()
458 else if(motion_idx >= 0 && touch->state == LV_INDEV_STATE_RELEASED) { in process_touch_event()
460 if(motion_idx == g->finger_cnt - 1) { in process_touch_event()
462 /* Mark last item as un-used */ in process_touch_event()
463 motion = get_motion(touch->id, g); in process_touch_event()
464 motion->finger = -1; in process_touch_event()
465 motion->state = touch->state; in process_touch_event()
471 len = (g->finger_cnt - 1) - motion_idx; in process_touch_event()
472 lv_memmove(g->motions + motion_idx, in process_touch_event()
473 g->motions + motion_idx + 1, in process_touch_event()
476 g->motions[g->finger_cnt - 1].finger = -1; in process_touch_event()
478 LV_ASSERT(g->motions[motion_idx + 1].finger == -1); in process_touch_event()
481 g->finger_cnt--; in process_touch_event()
486 motion = get_motion(touch->id, g); in process_touch_event()
487 motion->point.x = touch->point.x; in process_touch_event()
488 motion->point.y = touch->point.y; in process_touch_event()
489 motion->state = touch->state; in process_touch_event()
493 LV_LOG_TRACE("Ignore extra touch id: %d", touch->id); in process_touch_event()
516 g->p_scale = g->scale; in gesture_update_center_point()
517 g->p_delta_x = g->delta_x; in gesture_update_center_point()
518 g->p_delta_y = g->delta_y; in gesture_update_center_point()
519 g->p_rotation = g->rotation; in gesture_update_center_point()
522 motion = &g->motions[i]; in gesture_update_center_point()
524 if(motion->finger >= 0) { in gesture_update_center_point()
525 x += motion->point.x; in gesture_update_center_point()
526 y += motion->point.y; in gesture_update_center_point()
535 g->center.x = x / touch_cnt; in gesture_update_center_point()
536 g->center.y = y / touch_cnt; in gesture_update_center_point()
540 motion = &g->motions[i]; in gesture_update_center_point()
541 if(motion->finger >= 0) { in gesture_update_center_point()
542 delta_x[i] = motion->point.x - g->center.x; in gesture_update_center_point()
543 delta_y[i] = motion->point.y - g->center.y; in gesture_update_center_point()
549 motion = &g->motions[i]; in gesture_update_center_point()
550 if(motion->finger >= 0) { in gesture_update_center_point()
551 g->scale_factors_x[i] = delta_x[i] / scale_factor; in gesture_update_center_point()
552 g->scale_factors_y[i] = delta_y[i] / scale_factor; in gesture_update_center_point()
577 motion = &g->motions[i]; in gesture_calculate_factors()
579 if(motion->finger >= 0) { in gesture_calculate_factors()
580 center_x += motion->point.x; in gesture_calculate_factors()
581 center_y += motion->point.y; in gesture_calculate_factors()
594 g->delta_x = g->p_delta_x + (center_x - g->center.x); in gesture_calculate_factors()
595 g->delta_y = g->p_delta_x + (center_y - g->center.y); in gesture_calculate_factors()
599 motion = &g->motions[i]; in gesture_calculate_factors()
601 if(motion->finger >= 0) { in gesture_calculate_factors()
602 d_x = (motion->point.x - center_x); in gesture_calculate_factors()
603 d_y = (motion->point.y - center_y); in gesture_calculate_factors()
604 a += g->scale_factors_x[i] * d_x + g->scale_factors_y[i] * d_y; in gesture_calculate_factors()
605 b += g->scale_factors_x[i] * d_y + g->scale_factors_y[i] * d_x; in gesture_calculate_factors()
609 g->rotation = g->p_rotation + atan2f(b, a); in gesture_calculate_factors()
610 g->scale = g->p_scale * sqrtf((a * a) + (b * b)); in gesture_calculate_factors()
612 g->center.x = (int32_t)center_x; in gesture_calculate_factors()
613 g->center.y = (int32_t)center_y; in gesture_calculate_factors()