-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathgesture.h
70 lines (58 loc) · 1.87 KB
/
gesture.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* File : gesture.h
* COPYRIGHT (C) 2012-2017, Shanghai Real-Thread Technology Co., Ltd
*
* Change Logs:
* Date Author Notes
* 2017-11-05 realthread the first version
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <rtgui/event.h>
struct rtgui_gesture
{
struct rtgui_object *owner;
rt_uint32_t touch_id;
enum rtgui_gesture_type interest;
/* Public info. Read only for application and recognizer. */
struct
{
/* Pixel per second. */
int x, y;
} speed;
/* FIXME: Need acceleration? */
/* @last will behold while recognizing the gesture. It should never be
* updated by the recognizer. The @current is the most recent point and
* timestamp is read-only to the recognizer too. These members will be
* updated by the gesture framwork. */
struct
{
rt_uint16_t x, y;
rt_tick_t ts;
} start, last, current;
/* Private info. Read/write for recognizer. */
struct rtgui_timer *timer;
rt_uint32_t start_stat;
rt_uint32_t finish_stat;
};
int rtgui_gesture_init(struct rtgui_gesture *gest,
struct rtgui_object *owner,
enum rtgui_gesture_type inter);
void rtgui_gesture_cleanup(struct rtgui_gesture *gest);
/** Try to recognize gestures from the @eve.
*
* @eve should be a mouse event(either RTGUI_EVENT_MOUSE_BUTTON or
* RTGUI_EVENT_MOUSE_MOTION) and every mouse event should be feed into this
* function to get a possible gesture.
*
* When a gesture is recognized, it will return RT_TRUE. Otherwise, it will
* return RT_FALSE. The event handler of the @owner will be called once a
* gesture is recognized, with a rtgui_event_gesture event.
*/
rt_bool_t rtgui_gesture_recognize(struct rtgui_gesture *gest,
const struct rtgui_event *eve);
#ifdef __cplusplus
}
#endif