diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-08-19 20:16:17 +0200 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-08-19 20:16:17 +0200 |
| commit | 5348eb281e599942d903f023b2aecd87a77792af (patch) | |
| tree | 5e8e80872effdec0922122cfb5ed03883cf2907e | |
| parent | a704984e03d28b4be40e12c43be1b163bc9e09e2 (diff) | |
Add documentation to structs and functions in grail.h
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
| -rw-r--r-- | include/grail.h | 143 |
1 files changed, 138 insertions, 5 deletions
diff --git a/include/grail.h b/include/grail.h index c77a6e3..ae3a73f 100644 --- a/include/grail.h +++ b/include/grail.h | |||
| @@ -37,23 +37,59 @@ | |||
| 37 | #define GRAIL_STATUS_UPDATE 1 | 37 | #define GRAIL_STATUS_UPDATE 1 |
| 38 | #define GRAIL_STATUS_END 2 | 38 | #define GRAIL_STATUS_END 2 |
| 39 | 39 | ||
| 40 | typedef float grail_prop_t; | 40 | typedef float grail_prop_t; /* gesture properties */ |
| 41 | typedef __u64 grail_time_t; | 41 | typedef __u64 grail_time_t; /* time in milliseconds */ |
| 42 | 42 | ||
| 43 | /** | ||
| 44 | * struct grail_coord - coordinate in bounding box units | ||
| 45 | * @x: the horizontal position (bbox units) | ||
| 46 | * @y: the vertical position (bbox units) | ||
| 47 | */ | ||
| 43 | struct grail_coord { | 48 | struct grail_coord { |
| 44 | float x, y; | 49 | float x, y; |
| 45 | }; | 50 | }; |
| 46 | 51 | ||
| 52 | |||
| 53 | /** | ||
| 54 | * struct grail_client_id - Gesture client information | ||
| 55 | * @client: Client id | ||
| 56 | * @root: Root window | ||
| 57 | * @event: Window to route events to | ||
| 58 | * @child: Window the event occured in | ||
| 59 | * | ||
| 60 | * This struct is treated opaquely, and only has meaning to the gesture | ||
| 61 | * client. Details are subject to change. | ||
| 62 | */ | ||
| 47 | struct grail_client_id { | 63 | struct grail_client_id { |
| 48 | int client; | 64 | int client; |
| 49 | int root, event, child; | 65 | int root, event, child; |
| 50 | }; | 66 | }; |
| 51 | 67 | ||
| 68 | /** | ||
| 69 | * struct grail_client_info - Gesture request information | ||
| 70 | * @id: Gesture client id | ||
| 71 | * @mask: Gestures the client is listening to | ||
| 72 | */ | ||
| 52 | struct grail_client_info { | 73 | struct grail_client_info { |
| 53 | struct grail_client_id id; | 74 | struct grail_client_id id; |
| 54 | grail_mask_t mask[DIM_GRAIL_TYPE_BYTES]; | 75 | grail_mask_t mask[DIM_GRAIL_TYPE_BYTES]; |
| 55 | }; | 76 | }; |
| 56 | 77 | ||
| 78 | /** | ||
| 79 | * struct grail_event - Gesture event | ||
| 80 | * @type: The gesture type | ||
| 81 | * @id: Unique identifier foof the gesture instance | ||
| 82 | * @status: Gesture status (begin, update, end) | ||
| 83 | * @ntouch: Number of current touches | ||
| 84 | * @nprop: Number of properties in the gesture | ||
| 85 | * @pos: Focus point of the gesture (bbox coordinates) | ||
| 86 | * @touch: Array of individual touch information | ||
| 87 | * @client_id: The gesture client to route the gesture to | ||
| 88 | * @time: Time of event (milliseconds) | ||
| 89 | * @prop: Array of properties of the event | ||
| 90 | * | ||
| 91 | * Gesture events are passed to the client via the gesture() callback. | ||
| 92 | */ | ||
| 57 | struct grail_event { | 93 | struct grail_event { |
| 58 | int type; | 94 | int type; |
| 59 | int id; | 95 | int id; |
| @@ -66,6 +102,25 @@ struct grail_event { | |||
| 66 | grail_prop_t prop[DIM_GRAIL_PROP]; | 102 | grail_prop_t prop[DIM_GRAIL_PROP]; |
| 67 | }; | 103 | }; |
| 68 | 104 | ||
| 105 | /** | ||
| 106 | * struct grail - Main grail device | ||
| 107 | * @get_clients: Called at the onset of new gestures to retrieve the list | ||
| 108 | * of listening clients. | ||
| 109 | * @event: Callback for kernel events passing through grail. | ||
| 110 | * @gesture: Main gesture callback. | ||
| 111 | * @impl: Grail implementation details. | ||
| 112 | * @gin: Gesture instatiation details. | ||
| 113 | * @gru: Gesture recognition details. | ||
| 114 | * @priv: Generic pointer to user-defined content. | ||
| 115 | * | ||
| 116 | * The grail device pulls events from the underlying device, detects | ||
| 117 | * gestures, and passes them on to the client via the gesture() | ||
| 118 | * callback. Events that are not gesture or for other reasons held back are | ||
| 119 | * passed on via the event() callback. The user provides information about | ||
| 120 | * windows and listening clients via the get_clients callback, which is | ||
| 121 | * called during gesture instantiation. | ||
| 122 | * | ||
| 123 | */ | ||
| 69 | struct grail { | 124 | struct grail { |
| 70 | int (*get_clients)(struct grail *ge, | 125 | int (*get_clients)(struct grail *ge, |
| 71 | struct grail_client_info *client, int max_clients, | 126 | struct grail_client_info *client, int max_clients, |
| @@ -81,18 +136,96 @@ struct grail { | |||
| 81 | void *priv; | 136 | void *priv; |
| 82 | }; | 137 | }; |
| 83 | 138 | ||
| 139 | /** | ||
| 140 | * grail_open - open a grail device | ||
| 141 | * @ge: the grail device to open | ||
| 142 | * @fd: file descriptor of the kernel device | ||
| 143 | * | ||
| 144 | * Initialize the internal grail structures and configure it by reading the | ||
| 145 | * protocol capabilities through the file descriptor. | ||
| 146 | * | ||
| 147 | * The callbacks, parameters and priv pointer should be set prior to this | ||
| 148 | * call. | ||
| 149 | * | ||
| 150 | * Returns zero on success, negative error number otherwise. | ||
| 151 | */ | ||
| 84 | int grail_open(struct grail *ge, int fd); | 152 | int grail_open(struct grail *ge, int fd); |
| 153 | |||
| 154 | /** | ||
| 155 | * grail_idle - check state of kernel device | ||
| 156 | * @ge: the grail device in use | ||
| 157 | * @fd: file descriptor of the kernel device | ||
| 158 | * @ms: number of milliseconds to wait for activity | ||
| 159 | * | ||
| 160 | * Returns true if the device is idle, i.e., there are no fetched | ||
| 161 | * events in the pipe and there is nothing to fetch from the device. | ||
| 162 | */ | ||
| 85 | int grail_idle(struct grail *ge, int fd, int ms); | 163 | int grail_idle(struct grail *ge, int fd, int ms); |
| 164 | |||
| 165 | /** | ||
| 166 | * grail_pull - pull and process available events from the kernel device | ||
| 167 | * @ge: the grail device in use | ||
| 168 | * @fd: file descriptor of the kernel device | ||
| 169 | * | ||
| 170 | * Pull all available events and process them. The grail callbacks are | ||
| 171 | * invoked during this call. | ||
| 172 | * | ||
| 173 | * The underlying file descriptor must have O_NONBLOCK set, or this method | ||
| 174 | * will not return until the file is closed. | ||
| 175 | * | ||
| 176 | * On success, returns the number of events read. Otherwise, | ||
| 177 | * a standard negative error number is returned. | ||
| 178 | */ | ||
| 86 | int grail_pull(struct grail *ge, int fd); | 179 | int grail_pull(struct grail *ge, int fd); |
| 180 | |||
| 181 | /** | ||
| 182 | * grail_close - close the grail device | ||
| 183 | * @ge: the grail device to close | ||
| 184 | * @fd: file descriptor of the kernel device | ||
| 185 | * | ||
| 186 | * Deallocates all memory associated with grail, and clears the grail | ||
| 187 | * structure. | ||
| 188 | */ | ||
| 87 | void grail_close(struct grail *ge, int fd); | 189 | void grail_close(struct grail *ge, int fd); |
| 88 | 190 | ||
| 191 | /** | ||
| 192 | * grail_set_bbox - set the grail unit bounding box | ||
| 193 | * @ge: the grail device in use | ||
| 194 | * @min: the minimum (lower-left) corner of the bounding box | ||
| 195 | * @max: the maximum (upper-right) corner of the bounding box | ||
| 196 | * | ||
| 197 | * Sets the box within which the device coordinates should be presented. | ||
| 198 | */ | ||
| 89 | void grail_set_bbox(struct grail *ge, | 199 | void grail_set_bbox(struct grail *ge, |
| 90 | const struct grail_coord *min, | 200 | const struct grail_coord *min, |
| 91 | const struct grail_coord *max); | 201 | const struct grail_coord *max); |
| 92 | 202 | ||
| 203 | /** | ||
| 204 | * grail_filter_abs_events - filter kernel motion events | ||
| 205 | * @ge: the grail device in use | ||
| 206 | * @usage: When true, filter kernel motion events. | ||
| 207 | * | ||
| 208 | * Single-finger pointer events are treated as pointer gestures in | ||
| 209 | * grail. When filter_motion_events is non-zero, the kernel events | ||
| 210 | * corresponding to pointer movement are removed from the event | ||
| 211 | * stream. | ||
| 212 | * | ||
| 213 | */ | ||
| 214 | void grail_filter_abs_events(struct grail *ge, int usage); | ||
| 215 | |||
| 216 | /** | ||
| 217 | * grail_get_units - get device coordinate ranges | ||
| 218 | * @ge: the grail device in use | ||
| 219 | * @min: minimum x and y coordinates | ||
| 220 | * @max: maximum x and y coordinates | ||
| 221 | * | ||
| 222 | * The grail event attributes pos, touch_major, touch_minor, | ||
| 223 | * width_major, and width_minor are all given in device coordinate | ||
| 224 | * units, unless specified otherwise using the grail_set_bbox() | ||
| 225 | * function. This function reports the device coordinate ranges. | ||
| 226 | * | ||
| 227 | */ | ||
| 93 | void grail_get_units(const struct grail *ge, | 228 | void grail_get_units(const struct grail *ge, |
| 94 | struct grail_coord *min, struct grail_coord *max); | 229 | struct grail_coord *min, struct grail_coord *max); |
| 95 | 230 | ||
| 96 | void grail_filter_abs_events(struct grail *ge, int usage); | ||
| 97 | |||
| 98 | #endif | 231 | #endif |
