diff options
| author | Henrik Rydberg <rydberg@euromail.se> | 2010-12-30 17:58:01 +0100 |
|---|---|---|
| committer | Henrik Rydberg <rydberg@euromail.se> | 2010-12-30 17:58:01 +0100 |
| commit | f0aba58c91933a4702a7cc74f7daf4192868f570 (patch) | |
| tree | 648c41fe09adb72344769dd6242638cbad835482 /include/utouch/frame.h | |
Initial load of utouch-framev1.0.0
Compiles and runs on mtdev. ABI proof.
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'include/utouch/frame.h')
| -rw-r--r-- | include/utouch/frame.h | 250 |
1 files changed, 250 insertions, 0 deletions
diff --git a/include/utouch/frame.h b/include/utouch/frame.h new file mode 100644 index 0000000..08e4e26 --- /dev/null +++ b/include/utouch/frame.h | |||
| @@ -0,0 +1,250 @@ | |||
| 1 | /***************************************************************************** | ||
| 2 | * | ||
| 3 | * utouch-frame - Touch Frame Library | ||
| 4 | * | ||
| 5 | * Copyright (C) 2010-2011 Canonical Ltd. | ||
| 6 | * | ||
| 7 | * This program is free software: you can redistribute it and/or modify it | ||
| 8 | * under the terms of the GNU General Public License as published by the | ||
| 9 | * Free Software Foundation, either version 3 of the License, or (at your | ||
| 10 | * option) any later version. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but | ||
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU General Public License along | ||
| 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | ****************************************************************************/ | ||
| 21 | |||
| 22 | #ifndef _UTOUCH_FRAME_H | ||
| 23 | #define _UTOUCH_FRAME_H | ||
| 24 | |||
| 25 | #include <stdint.h> | ||
| 26 | |||
| 27 | #define UTOUCH_FRAME_VERSION 0x00001000 | ||
| 28 | |||
| 29 | /** | ||
| 30 | * struct utouch_surface - device surface details | ||
| 31 | * @needs_pointer: device needs a screen pointer to function | ||
| 32 | * @is_direct: surface is a direct device (e.g. touchscreen) | ||
| 33 | * @is_buttonpad: surface has button(s) under it | ||
| 34 | * @is_semi_mt: surface detects bounding rectangle only | ||
| 35 | * @use_touch_major: device uses major axis for contact modulation | ||
| 36 | * @use_touch_minor: device uses minor axis for contact modulation | ||
| 37 | * @use_width_major: device uses approaching major axis for contact modulation | ||
| 38 | * @use_width_minor: device uses approaching minor axis for contact modulation | ||
| 39 | * @use_orientation: device uses ellipse orientation for contact modulation | ||
| 40 | * @use_pressure: device uses pressure for contact modulation | ||
| 41 | * @use_distance: device uses hover distance | ||
| 42 | * @phys_width: physical width in millimeters (mm) | ||
| 43 | * @phys_height: physical height in millimeters (mm) | ||
| 44 | * @phys_pressure: maximal physical pressure (N/cm^2) | ||
| 45 | * @min_x: minimum horizontal coordinate value | ||
| 46 | * @min_y: minimum vertical coordinate value | ||
| 47 | * @max_x: maximum horizontal coordinate value | ||
| 48 | * @max_y: maximum vertical coordinate value | ||
| 49 | * @max_pressure: maximum pressure coordinate value | ||
| 50 | * | ||
| 51 | * Device properties and touch surface details. Later versions of this | ||
| 52 | * struct may grow in size, but will remain binary compatible with | ||
| 53 | * older versions. | ||
| 54 | */ | ||
| 55 | struct utouch_surface { | ||
| 56 | int needs_pointer; | ||
| 57 | int is_direct; | ||
| 58 | int is_buttonpad; | ||
| 59 | int is_semi_mt; | ||
| 60 | int use_touch_major; | ||
| 61 | int use_touch_minor; | ||
| 62 | int use_width_major; | ||
| 63 | int use_width_minor; | ||
| 64 | int use_orientation; | ||
| 65 | int use_pressure; | ||
| 66 | int use_distance; | ||
| 67 | float phys_width; | ||
| 68 | float phys_height; | ||
| 69 | float phys_pressure; | ||
| 70 | float min_x; | ||
| 71 | float min_y; | ||
| 72 | float max_x; | ||
| 73 | float max_y; | ||
| 74 | float max_pressure; | ||
| 75 | }; | ||
| 76 | |||
| 77 | #define UTOUCH_TOOL_FINGER 0 | ||
| 78 | #define UTOUCH_TOOL_PEN 1 | ||
| 79 | |||
| 80 | /** | ||
| 81 | * struct utouch_contact - surface contact details | ||
| 82 | * @prev: pointer to same slot of previous frame | ||
| 83 | * @active: currently in use | ||
| 84 | * @slot: slot occupied by this contact | ||
| 85 | * @id: unique id of this contact | ||
| 86 | * @tool_type: the tool type of this contact | ||
| 87 | * @x: horizontal center position coordinate (surface units) | ||
| 88 | * @y: vertical center position coordinate (surface units) | ||
| 89 | * @touch_major: major axis of contact (surface units) | ||
| 90 | * @touch_minor: minor axis of contact (surface units) | ||
| 91 | * @width_major: major axis of approaching contact (surface units) | ||
| 92 | * @width_minor: minor axis of approaching contact (surface units) | ||
| 93 | * @orientation: direction of ellipse (left: -Pi/2, up: 0, right: Pi/2) | ||
| 94 | * @pressure: pressure of contact (pressure units) | ||
| 95 | * @distance: distance of contact (surface units) | ||
| 96 | * | ||
| 97 | * Surface contact details. Later versions of this struct may grow in | ||
| 98 | * size, but will remain binary compatible with older versions. | ||
| 99 | * | ||
| 100 | * Contact structures are connected into one ring per slot. The | ||
| 101 | * previous contact pointers are ABI agnostic, owned by the engine, | ||
| 102 | * and have engine scope. | ||
| 103 | */ | ||
| 104 | struct utouch_contact { | ||
| 105 | const struct utouch_contact *prev; | ||
| 106 | int active; | ||
| 107 | int slot; | ||
| 108 | int id; | ||
| 109 | int tool_type; | ||
| 110 | float x; | ||
| 111 | float y; | ||
| 112 | float touch_major; | ||
| 113 | float touch_minor; | ||
| 114 | float width_major; | ||
| 115 | float width_minor; | ||
| 116 | float orientation; | ||
| 117 | float pressure; | ||
| 118 | float distance; | ||
| 119 | }; | ||
| 120 | |||
| 121 | /* time in milliseconds */ | ||
| 122 | typedef uint64_t utouch_frame_time_t; | ||
| 123 | |||
| 124 | /* the frame engine handle */ | ||
| 125 | typedef struct utouch_frame_engine *utouch_frame_handle; | ||
| 126 | |||
| 127 | /** | ||
| 128 | * struct utouch_frame - emitted frame details | ||
| 129 | * @prev: pointer to previous frame | ||
| 130 | * @sequence_id: frame sequence number | ||
| 131 | * @revision: changes whenever the contact count changes | ||
| 132 | * @slot_revision: changes whenever the slot id array change | ||
| 133 | * @num_active: the number of contacts in the active array | ||
| 134 | * @time: time of frame completion (ms) | ||
| 135 | * @mod_time: time of last contact count change (ms) | ||
| 136 | * @slot_mod_time: time of last slot id array change (ms) | ||
| 137 | * @active: the array of active contacts | ||
| 138 | * | ||
| 139 | * Contact frame details. Later versions of this struct may grow in | ||
| 140 | * size, but will remain binary compatible with older versions. | ||
| 141 | * | ||
| 142 | * Frames are connected into a ring. The previous frame pointer is ABI | ||
| 143 | * agnostic, owned by the engine, and has engine scope. | ||
| 144 | */ | ||
| 145 | struct utouch_frame { | ||
| 146 | const struct utouch_frame *prev; | ||
| 147 | unsigned int sequence_id; | ||
| 148 | unsigned int revision; | ||
| 149 | unsigned int slot_revision; | ||
| 150 | unsigned int num_active; | ||
| 151 | utouch_frame_time_t time; | ||
| 152 | utouch_frame_time_t mod_time; | ||
| 153 | utouch_frame_time_t slot_mod_time; | ||
| 154 | struct utouch_contact **active; | ||
| 155 | struct utouch_contact **slots; | ||
| 156 | }; | ||
| 157 | |||
| 158 | /** | ||
| 159 | * utouch_frame_get_version - get library abi version | ||
| 160 | * | ||
| 161 | * Returns the version of the library, which may be different | ||
| 162 | * from the api version of the compiled user program. | ||
| 163 | */ | ||
| 164 | unsigned int utouch_frame_get_version(void); | ||
| 165 | |||
| 166 | utouch_frame_handle utouch_frame_new_engine_raw(unsigned int num_frames, | ||
| 167 | unsigned int num_slots, | ||
| 168 | unsigned int frame_rate, | ||
| 169 | unsigned int version, | ||
| 170 | unsigned int surface_size, | ||
| 171 | unsigned int frame_size, | ||
| 172 | unsigned int slot_size); | ||
| 173 | |||
| 174 | /** | ||
| 175 | * utouch_frame_new_engine - allocate a new frame engine | ||
| 176 | * @num_frames: number of frames in cyclic buffer | ||
| 177 | * @num_slots: maximum number of slots per frame | ||
| 178 | * @frame_rate: maximum frame rate (frames/s) | ||
| 179 | * | ||
| 180 | * Allocates memory, initializes the internal engine and returns a | ||
| 181 | * handle to it. A rate of 100 frames per second is normal. | ||
| 182 | */ | ||
| 183 | #define utouch_frame_new_engine(num_frames, num_slots, frame_rate) \ | ||
| 184 | utouch_frame_new_engine_raw(num_frames, \ | ||
| 185 | num_slots, \ | ||
| 186 | frame_rate, \ | ||
| 187 | UTOUCH_FRAME_VERSION, \ | ||
| 188 | sizeof(struct utouch_surface), \ | ||
| 189 | sizeof(struct utouch_frame), \ | ||
| 190 | sizeof(struct utouch_contact)) | ||
| 191 | |||
| 192 | /** | ||
| 193 | * utouch_frame_delete_engine - deallocate a frame engine | ||
| 194 | * @fh: frame engine in use | ||
| 195 | * | ||
| 196 | * Deallocates all memory associated with the engine. | ||
| 197 | */ | ||
| 198 | void utouch_frame_delete_engine(utouch_frame_handle fh); | ||
| 199 | |||
| 200 | /** | ||
| 201 | * utouch_frame_get_surface - get the mutable device surface information | ||
| 202 | * @fh: the frame engine in use | ||
| 203 | * | ||
| 204 | * Returns a pointer to the mutable device surface information. It is | ||
| 205 | * preferrably set up by one of the input handlers. The pointer is ABI | ||
| 206 | * agnostic, has frame engine scope, and is owned by the engine. | ||
| 207 | */ | ||
| 208 | struct utouch_surface *utouch_frame_get_surface(utouch_frame_handle fh); | ||
| 209 | |||
| 210 | /** | ||
| 211 | * utouch_frame_get_current_slot - get the current mutable slot contact | ||
| 212 | * @fh: the frame engine in use | ||
| 213 | * | ||
| 214 | * Returns a pointer to the contact current being modified. The | ||
| 215 | * pointer is ABI agnostic, has frame engine scope, and is owned by | ||
| 216 | * the engine. | ||
| 217 | */ | ||
| 218 | struct utouch_contact *utouch_frame_get_current_slot(utouch_frame_handle fh); | ||
| 219 | |||
| 220 | /** | ||
| 221 | * utouch_frame_set_current_slot - set the current slot number | ||
| 222 | * @fh: the frame engine in use | ||
| 223 | * @slot: the slot number | ||
| 224 | * | ||
| 225 | * Sets the slot currently being modified. Returns zero if successful, | ||
| 226 | * negative error otherwise. | ||
| 227 | */ | ||
| 228 | int utouch_frame_set_current_slot(utouch_frame_handle fh, int slot); | ||
| 229 | |||
| 230 | /** | ||
| 231 | * utouch_frame_sync - synchronize and return new frame | ||
| 232 | * @fh: the frame engine in use | ||
| 233 | * @time: the frame synchronization time (ms) | ||
| 234 | * | ||
| 235 | * Scans through the updates, and in case the changes make up a new | ||
| 236 | * frame, returns the updated frame. | ||
| 237 | * | ||
| 238 | * If time is zero, a time-of-receipt will be used instead. | ||
| 239 | * | ||
| 240 | * The frame returned is always the next in the cyclic list, and | ||
| 241 | * always points back at the previous frame returned by this function. | ||
| 242 | * | ||
| 243 | * The returned pointer is ABI agnostic and owned by the frame | ||
| 244 | * engine. It may very well be zero if there is nothing to report or | ||
| 245 | * if the frame rate is limited. | ||
| 246 | */ | ||
| 247 | const struct utouch_frame *utouch_frame_sync(utouch_frame_handle fh, | ||
| 248 | utouch_frame_time_t time); | ||
| 249 | |||
| 250 | #endif | ||
