~fginther/frame/precise-transitional-1

« back to all changes in this revision

Viewing changes to include/oif/frame.h

  • Committer: Francis Ginther
  • Date: 2012-08-08 14:45:26 UTC
  • mfrom: (1.1.13)
  • Revision ID: francis.ginther@canonical.com-20120808144526-5x9p295ps2k6oy87
* Update debian/watch file for project rename
* New upstream release.
  - Compile fixes
  - Removal of v1 API
  - Accept/reject owned touches that have already ended (lp: #1025297)
  - Rename project to "Frame"
  - Remove ChangeLog

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 *
3
 
 * utouch-frame - Touch Frame Library
 
3
 * frame - Touch Frame Library
4
4
 *
5
5
 * Copyright (C) 2010-2012 Canonical Ltd.
6
6
 *
19
19
 ****************************************************************************/
20
20
 
21
21
/**
22
 
 * @file utouch/frame.h
 
22
 * @file oif/frame.h
23
23
 * Definitions of the main and platform-generic API
24
24
 */
25
25
 
26
 
#ifndef UTOUCH_FRAME_UTOUCH_FRAME_H_
27
 
#define UTOUCH_FRAME_UTOUCH_FRAME_H_
 
26
#ifndef FRAME_OIF_FRAME_H_
 
27
#define FRAME_OIF_FRAME_H_
28
28
 
29
29
/* Macros that set symbol visibilities in shared libraries properly.
30
30
 * Adapted from http://gcc.gnu.org/wiki/Visibility
45
45
  #endif
46
46
#endif
47
47
 
48
 
/* Clang provides __has_extension, but GCC does not */
49
 
#ifdef __has_extension
50
 
#if __has_extension(c_generic_selections)
 
48
/* Clang provides __has_feature, but GCC does not */
 
49
#ifdef __has_feature
 
50
#if __has_feature(c_generic_selections)
51
51
#define HAS_C_GENERIC_SELECTIONS
52
 
#endif // __has_extension
53
 
#endif // __has_extension(c_generic_selections)
 
52
#endif // __has_feature
 
53
#endif // __has_feature(c_generic_selections)
54
54
 
55
55
#ifdef __cplusplus
56
56
extern "C" {
58
58
 
59
59
#include <stdint.h>
60
60
 
61
 
/**
62
 
 * @defgroup v1 uTouch-Frame 1.x
63
 
 * @{
64
 
 * @internal
65
 
 */
66
 
 
67
 
#define UTOUCH_FRAME_VERSION    0x00001010
68
 
 
69
 
/**
70
 
 * struct utouch_surface - device surface details
71
 
 * @needs_pointer: device needs a screen pointer to function
72
 
 * @is_direct: surface is a direct device (e.g. touchscreen)
73
 
 * @is_buttonpad: surface has button(s) under it
74
 
 * @is_semi_mt: surface detects bounding rectangle only
75
 
 * @use_touch_major: device uses major axis for contact modulation
76
 
 * @use_touch_minor: device uses minor axis for contact modulation
77
 
 * @use_width_major: device uses approaching major axis for contact modulation
78
 
 * @use_width_minor: device uses approaching minor axis for contact modulation
79
 
 * @use_orientation: device uses ellipse orientation for contact modulation
80
 
 * @use_pressure: device uses pressure for contact modulation
81
 
 * @use_distance: device uses hover distance
82
 
 * @phys_width: physical width in millimeters (mm)
83
 
 * @phys_height: physical height in millimeters (mm)
84
 
 * @phys_pressure: maximal physical pressure (N/cm^2)
85
 
 * @min_x: minimum horizontal device coordinate
86
 
 * @min_y: minimum vertical device coordinate
87
 
 * @max_x: maximum horizontal device coordinate
88
 
 * @max_y: maximum vertical device coordinate
89
 
 * @max_pressure: maximum pressure device coordinate
90
 
 * @max_orient: maximum orientation device coordinate
91
 
 * @mapped_min_x: minimum horizontal mapped coordinate
92
 
 * @mapped_min_y: minimum vertical mapped coordinate
93
 
 * @mapped_max_x: maximum horizontal mapped coordinate
94
 
 * @mapped_max_y: maximum vertical mapped coordinate
95
 
 * @mapped_max_pressure: maximum pressure mapped coordinate
96
 
 *
97
 
 * The mutable contact given by utouch_frame_get_current_slot() should
98
 
 * be set in device coordinates. The contact data is subsequently
99
 
 * transformed to mapped (e.g., screen) coordinates in
100
 
 * utouch_frame_sync(). To a frame user, all data will appear in
101
 
 * mapped coordinates.
102
 
 *
103
 
 * Device properties and touch surface details. Later versions of this
104
 
 * struct may grow in size, but will remain binary compatible with
105
 
 * older versions.
106
 
 */
107
 
struct utouch_surface {
108
 
        int needs_pointer;
109
 
        int is_direct;
110
 
        int is_buttonpad;
111
 
        int is_semi_mt;
112
 
        int use_touch_major;
113
 
        int use_touch_minor;
114
 
        int use_width_major;
115
 
        int use_width_minor;
116
 
        int use_orientation;
117
 
        int use_pressure;
118
 
        int use_distance;
119
 
        float phys_width;
120
 
        float phys_height;
121
 
        float phys_pressure;
122
 
        float min_x;
123
 
        float min_y;
124
 
        float max_x;
125
 
        float max_y;
126
 
        float max_pressure;
127
 
        float max_orient;
128
 
        float mapped_min_x;
129
 
        float mapped_min_y;
130
 
        float mapped_max_x;
131
 
        float mapped_max_y;
132
 
        float mapped_max_pressure;
133
 
        unsigned int min_id;
134
 
        unsigned int max_id;
135
 
};
136
 
 
137
 
#define UTOUCH_TOOL_FINGER      0
138
 
#define UTOUCH_TOOL_PEN         1
139
 
 
140
 
/**
141
 
 * struct utouch_contact - surface contact details
142
 
 * @prev: pointer to same slot of previous frame
143
 
 * @active: currently in use
144
 
 * @slot: slot occupied by this contact
145
 
 * @id: unique id of this contact
146
 
 * @tool_type: the tool type of this contact
147
 
 * @x: horizontal center position coordinate (surface units)
148
 
 * @y: vertical center position coordinate (surface units)
149
 
 * @touch_major: major axis of contact (surface units)
150
 
 * @touch_minor: minor axis of contact (surface units)
151
 
 * @width_major: major axis of approaching contact (surface units)
152
 
 * @width_minor: minor axis of approaching contact (surface units)
153
 
 * @orientation: direction of ellipse (left: -Pi/2, up: 0, right: Pi/2)
154
 
 * @pressure: pressure of contact (pressure units)
155
 
 * @distance: distance of contact (surface units)
156
 
 * @vx: horizontal velocity coordinate (units / millisecond)
157
 
 * @vy: vertical velocity coordinate (units / millisecond)
158
 
 *
159
 
 * Surface contact details. Later versions of this struct may grow in
160
 
 * size, but will remain binary compatible with older versions.
161
 
 *
162
 
 * Contact structures are connected into one ring per slot. The
163
 
 * previous contact pointers are ABI agnostic, owned by the engine,
164
 
 * and have engine scope.
165
 
 */
166
 
struct utouch_contact {
167
 
        const struct utouch_contact *prev;
168
 
        int active;
169
 
        int slot;
170
 
        unsigned int id;
171
 
        int tool_type;
172
 
        float x;
173
 
        float y;
174
 
        float touch_major;
175
 
        float touch_minor;
176
 
        float width_major;
177
 
        float width_minor;
178
 
        float orientation;
179
 
        float pressure;
180
 
        float distance;
181
 
        float vx;
182
 
        float vy;
183
 
};
184
 
 
185
 
/* time in milliseconds */
186
 
typedef uint64_t utouch_frame_time_t;
187
 
 
188
 
/* the frame engine handle */
189
 
typedef struct utouch_frame_engine *utouch_frame_handle;
190
 
 
191
 
/**
192
 
 * struct utouch_frame - emitted frame details
193
 
 * @prev: pointer to previous frame
194
 
 * @sequence_id: frame sequence number
195
 
 * @revision: changes whenever the contact count changes
196
 
 * @slot_revision: changes whenever the slot id array change
197
 
 * @num_active: the number of contacts in the active array
198
 
 * @time: time of frame completion (ms)
199
 
 * @mod_time: time of last contact count change (ms)
200
 
 * @slot_mod_time: time of last slot id array change (ms)
201
 
 * @active: the array of active contacts
202
 
 *
203
 
 * Contact frame details. Later versions of this struct may grow in
204
 
 * size, but will remain binary compatible with older versions.
205
 
 *
206
 
 * Frames are connected into a ring. The previous frame pointer is ABI
207
 
 * agnostic, owned by the engine, and has engine scope.
208
 
 */
209
 
struct utouch_frame {
210
 
        const struct utouch_frame *prev;
211
 
        unsigned int sequence_id;
212
 
        unsigned int revision;
213
 
        unsigned int slot_revision;
214
 
        unsigned int num_active;
215
 
        utouch_frame_time_t time;
216
 
        utouch_frame_time_t mod_time;
217
 
        utouch_frame_time_t slot_mod_time;
218
 
        struct utouch_contact **active;
219
 
        struct utouch_contact **slots;
220
 
};
221
 
 
222
 
/**
223
 
 * utouch_frame_get_version - get library abi version
224
 
 *
225
 
 * Returns the version of the library, which may be different
226
 
 * from the api version of the compiled user program.
227
 
 */
228
 
FRAME_PUBLIC
229
 
unsigned int utouch_frame_get_version(void);
230
 
 
231
 
/**
232
 
 * utouch_frame_get_num_frames - get number of supported frames
233
 
 *
234
 
 * Returns the number of frames supported by this engine.
235
 
 */
236
 
FRAME_PUBLIC
237
 
unsigned int utouch_frame_get_num_frames(utouch_frame_handle fh);
238
 
 
239
 
/**
240
 
 * utouch_frame_get_num_slots - get number of supported slots
241
 
 *
242
 
 * Returns the number of simultaneous contacts supported by this engine.
243
 
 */
244
 
FRAME_PUBLIC
245
 
unsigned int utouch_frame_get_num_slots(utouch_frame_handle fh);
246
 
 
247
 
FRAME_PUBLIC
248
 
utouch_frame_handle utouch_frame_new_engine_raw(unsigned int num_frames,
249
 
                                                unsigned int num_slots,
250
 
                                                unsigned int frame_rate,
251
 
                                                unsigned int version,
252
 
                                                unsigned int surface_size,
253
 
                                                unsigned int frame_size,
254
 
                                                unsigned int slot_size);
255
 
 
256
 
/**
257
 
 * utouch_frame_new_engine - allocate a new frame engine
258
 
 * @num_frames: number of frames in cyclic buffer
259
 
 * @num_slots: maximum number of slots per frame
260
 
 * @frame_rate: maximum frame rate (frames/s)
261
 
 *
262
 
 * Allocates memory, initializes the internal engine and returns a
263
 
 * handle to it. A rate of 100 frames per second is normal.
264
 
 */
265
 
#define utouch_frame_new_engine(num_frames, num_slots, frame_rate)      \
266
 
        utouch_frame_new_engine_raw(num_frames,                         \
267
 
                                    num_slots,                          \
268
 
                                    frame_rate,                         \
269
 
                                    UTOUCH_FRAME_VERSION,               \
270
 
                                    sizeof(struct utouch_surface),      \
271
 
                                    sizeof(struct utouch_frame),        \
272
 
                                    sizeof(struct utouch_contact))
273
 
 
274
 
/**
275
 
 * utouch_frame_delete_engine - deallocate a frame engine
276
 
 * @fh: frame engine in use
277
 
 *
278
 
 * Deallocates all memory associated with the engine.
279
 
 */
280
 
FRAME_PUBLIC
281
 
void utouch_frame_delete_engine(utouch_frame_handle fh);
282
 
 
283
 
/**
284
 
 * utouch_frame_get_surface - get the mutable device surface information
285
 
 * @fh: the frame engine in use
286
 
 *
287
 
 * Returns a pointer to the mutable device surface information. It is
288
 
 * preferrably set up by one of the input handlers. The pointer is ABI
289
 
 * agnostic, has frame engine scope, and is owned by the engine.
290
 
 */
291
 
FRAME_PUBLIC
292
 
struct utouch_surface *utouch_frame_get_surface(utouch_frame_handle fh);
293
 
 
294
 
/**
295
 
 * utouch_frame_get_current_slot - get the current mutable slot contact
296
 
 * @fh: the frame engine in use
297
 
 *
298
 
 * Returns a pointer to the contact current being modified. The
299
 
 * pointer is ABI agnostic, has frame engine scope, and is owned by
300
 
 * the engine.
301
 
 */
302
 
FRAME_PUBLIC
303
 
struct utouch_contact *utouch_frame_get_current_slot(utouch_frame_handle fh);
304
 
 
305
 
/**
306
 
 * utouch_frame_set_current_slot - set the current slot number
307
 
 * @fh: the frame engine in use
308
 
 * @slot: the slot number
309
 
 *
310
 
 * Sets the slot currently being modified. Returns zero if successful,
311
 
 * negative error otherwise.
312
 
 */
313
 
FRAME_PUBLIC
314
 
int utouch_frame_set_current_slot(utouch_frame_handle fh, int slot);
315
 
 
316
 
/**
317
 
 * utouch_frame_set_current_id - set the current slot by touch id
318
 
 * @fh: the frame engine in use
319
 
 * @id: the touch id
320
 
 *
321
 
 * Sets the slot currently being modified, by touch id. If the id is
322
 
 * not currently in use (does not have an active slot), a new slot is
323
 
 * assigned. Returns zero if successful, negative error otherwise.
324
 
 */
325
 
FRAME_PUBLIC
326
 
int utouch_frame_set_current_id(utouch_frame_handle fh, int id);
327
 
 
328
 
/**
329
 
 * utouch_frame_sync - synchronize and return new frame
330
 
 * @fh: the frame engine in use
331
 
 * @time: the frame synchronization time (ms)
332
 
 *
333
 
 * Scans through the updates, and in case the changes make up a new
334
 
 * frame, returns the updated frame.
335
 
 *
336
 
 * If time is zero, a time-of-receipt will be used instead.
337
 
 *
338
 
 * The frame returned is always the next in the cyclic list, and
339
 
 * always points back at the previous frame returned by this function.
340
 
 *
341
 
 * The returned pointer is ABI agnostic and owned by the frame
342
 
 * engine. It may very well be zero if there is nothing to report or
343
 
 * if the frame rate is limited.
344
 
 */
345
 
FRAME_PUBLIC
346
 
const struct utouch_frame *utouch_frame_sync(utouch_frame_handle fh,
347
 
                                             utouch_frame_time_t time);
348
 
 
349
 
/**
350
 
 * utouch_coordinate_transform_cb - user-definable callback that transforms a touch point
351
 
 * @x: pointer to an x coordinate (in, out)
352
 
 * @y: pointer to a y coordinate (in, out)
353
 
 * @user_data: opaque pointer, passed by the user when setting the callback
354
 
 */
355
 
typedef void (*utouch_coordinate_transform_cb)(float *x, float *y, void *user_data);
356
 
 
357
 
/**
358
 
 * utouch_frame_set_coordinate_transform_callback - set a callback to obtain a transformation
359
 
 *   to apply to every touch point
360
 
 * @fh: the frame engine in use
361
 
 * @callback: the callback that transforms x and y
362
 
 * @user_data: opaque pointer to user data for the callback
363
 
 */
364
 
FRAME_PUBLIC
365
 
void utouch_frame_set_coordinate_transform_callback(utouch_frame_handle fh,
366
 
                                                    utouch_coordinate_transform_cb callback,
367
 
                                                    void *user_data);
368
 
/** @} */
369
 
 
370
 
/**
371
 
 * @defgroup v2 uTouch-Frame 2.x
372
 
 * @{
373
 
 */
374
 
 
375
 
/** An object for the context of the uTouch Frame instance */
 
61
/** An object for the context of the frame instance */
376
62
typedef struct UFHandle_* UFHandle;
377
63
/** An object for an event */
378
64
typedef struct UFEvent_* UFEvent;
412
98
   *
413
99
   * Value type: const char *
414
100
   *
415
 
   * The uTouch frame library owns the string. The string is valid until an
416
 
   * event notifying removal of the device is released.
 
101
   * The frame library owns the string. The string is valid until an event
 
102
   * notifying removal of the device is released.
417
103
   */
418
104
  UFDevicePropertyName = 0,
419
105
  /**
530
216
   *
531
217
   * This property holds the time the event occurred in display server
532
218
   * timespace. The time is provided in milliseconds (ms). If the event, such as
533
 
   * device addition, occurred before the uTouch Frame context was created, the
534
 
   * value will be 0.
 
219
   * device addition, occurred before the frame context was created, the value
 
220
   * will be 0.
535
221
   */
536
222
  UFEventPropertyTime,
537
223
} UFEventProperty;
657
343
} UFTouchProperty;
658
344
 
659
345
/**
660
 
 * Get the event file descriptor for the uTouch Frame context
 
346
 * Get the event file descriptor for the frame context
661
347
 *
662
 
 * @param [in] handle The uTouch Frame context object
 
348
 * @param [in] handle The frame context object
663
349
 * @return A file descriptor for the context
664
350
 *
665
351
 * When events are available for processing, the file descriptor will be
670
356
int frame_get_fd(UFHandle handle);
671
357
 
672
358
/**
673
 
 * Get an event from the uTouch Frame context
 
359
 * Get an event from the frame context
674
360
 *
675
361
 * @param [in] handle The context object
676
362
 * @param [out] event The retrieved event
1052
738
 
1053
739
/** @} */
1054
740
 
1055
 
/** @} */
1056
 
 
1057
 
#include <utouch/frame_internal.h>
 
741
#include "frame_internal.h"
1058
742
 
1059
743
#ifdef __cplusplus
1060
744
}
1062
746
 
1063
747
#undef HAS_C_GENERIC_SELECTIONS
1064
748
 
1065
 
#endif // UTOUCH_FRAME_UTOUCH_FRAME_H_
 
749
#endif // FRAME_OIF_FRAME_H_