2
* @file oif/frame_backend.h
3
* API for creating objects.
6
#ifndef FRAME_OIF_FRAME_BACKEND_H_
7
#define FRAME_OIF_FRAME_BACKEND_H_
9
/* front end definitions */
10
#include <oif/frame.h>
16
/** Handle for a device to be used on the backend API */
17
typedef struct UFBackendDevice_* UFBackendDevice;
19
/** Handle for a frame to be used on the backend API */
20
typedef struct UFBackendFrame_* UFBackendFrame;
22
/** Handle for a touch to be used on the backend API */
23
typedef struct UFBackendTouch_* UFBackendTouch;
25
/********************************************************************
27
********************************************************************/
30
* Creates a new event with a reference count of one.
33
UFEvent frame_event_new();
36
* Sets the type of the given event
39
void frame_event_set_type(UFEvent event, UFEventType type);
42
* Sets the device property of the given event
44
* It increases the reference count of the corresponding UFDevice by one.
47
void frame_event_set_device(UFEvent event, UFBackendDevice device);
50
* Sets the frame property of the given event
52
* It increases the reference count of the corresponding UFFrame by one.
55
void frame_event_set_frame(UFEvent event, UFBackendFrame frame);
58
* Sets the time of the given event
61
void frame_event_set_time(UFEvent event, uint64_t time);
63
/********************************************************************
65
********************************************************************/
68
* Creates a new UFDevice and returns its backend handle.
71
UFBackendDevice frame_backend_device_new();
74
* Returns a UFDevice instance given its backend handle.
77
UFDevice frame_backend_device_get_device(UFBackendDevice device);
80
* Sets the "Name" property of the given device
83
void frame_backend_device_set_name(UFBackendDevice device, const char *name);
86
* Sets the "Direct" property of the given device
89
void frame_backend_device_set_direct(UFBackendDevice device, int direct);
92
* Sets the "Independent" property of the given device
95
void frame_backend_device_set_independent(UFBackendDevice device, int independent);
98
* Sets the "SemiMT" property of the given device
101
void frame_backend_device_set_semi_mt(UFBackendDevice device, int semi_mt);
104
* Sets the "MaxTouches" property of the given device
107
void frame_backend_device_set_max_touches(UFBackendDevice device, unsigned int max_touches);
110
* Sets the "WindowResolutionX" and "WindowResolutionY" properties of the
114
void frame_backend_device_set_window_resolution(UFBackendDevice device, float x, float y);
117
* Adds an axis to the device
120
void frame_backend_device_add_axis(UFBackendDevice device,
122
float min, float max, float resolution);
125
* Deletes the backend handle of a UFDevice, decreasing its reference count by one.
128
void frame_backend_device_delete(UFBackendDevice device);
130
/********************************************************************
132
********************************************************************/
135
* Creates a new, empty, UFFrame and returns its backend handle.
137
* Usually you will use this method only for the very first frame. For all
138
* subsequent ones it will be safer and more convinent to use
139
* frame_backend_frame_create_next().
142
UFBackendFrame frame_backend_frame_new();
145
* Creates a new UFFrame that is a continuation of the given one.
147
* Touches that had a "begin" state on the given frame will be hard-copied and
148
* have an "update" state on the new frame.
150
* Touches that had an "update" state will be lazily copied to the new frame.
152
* Touches that had a "end" state on the given frame won't be present
156
UFBackendFrame frame_backend_frame_create_next(UFBackendFrame frame);
159
* Returns a UFFrame instance given its backend handle.
162
UFFrame frame_backend_frame_get_frame(UFBackendFrame frame);
165
* Gets a UFBackendTouch for the UFTouch that has the given id.
167
* The underlying UFTouch is moved from the given frame to the returned UFBackendTouch.
168
* Once done modifying the touch you're expected to return it to the frame via
169
* frame_backend_frame_give_touch().
171
* If the underlying UFTouch is a lazy copy (likely from a touch in the previous frame), a hard copy
172
* will be made upon the first change made to it.
174
* Possible errors: UFStatusErrorInvalidTouch
177
UFStatus frame_backend_frame_borrow_touch_by_id(UFBackendFrame frame,
179
UFBackendTouch *touch);
182
* Sets the "Device" property of the given frame
185
void frame_backend_frame_set_device(UFBackendFrame frame, UFBackendDevice device);
188
* Sets the "WindowId" property of the given frame
191
void frame_backend_frame_set_window_id(UFBackendFrame frame, UFWindowId window_id);
194
* Sets the "ActiveTouches" property of the given frame
196
* If unset this property returns the number of touches.
199
void frame_backend_frame_set_active_touches(UFBackendFrame frame, unsigned int active_touches);
202
* Gives a UFTouch to the specified frame.
204
* Gives the underlying UFTouch to the specified frame. The UFBackendTouch
205
* is deleted and no longer valid after this call.
207
* Possible errors: UFStatusErrorTouchIdExists
210
UFStatus frame_backend_frame_give_touch(UFBackendFrame frame, UFBackendTouch *touch);
213
* Deletes the backend handle of a UFFrame,
214
* decreasing its reference count by one.
217
void frame_backend_frame_delete(UFBackendFrame frame);
219
/********************************************************************
221
********************************************************************/
224
* Creates a new UFTouch and returns its backend handle.
226
* Its state will be set to "Begin".
228
* After filled out, it should be given to a frame via frame_backend_frame_give_touch()
231
UFBackendTouch frame_backend_touch_new();
234
* Returns a UFTouch instance given its backend handle.
237
UFTouch frame_backend_touch_get_touch(UFBackendTouch touch);
240
* Sets the "Id" property of the given touch
243
void frame_backend_touch_set_id(UFBackendTouch touch, UFTouchId id);
246
* Sets the "State" property of the given touch to "End"
249
void frame_backend_touch_set_ended(UFBackendTouch touch);
252
* Sets the "WindowX" and "WindowY" properties of the given touch
255
void frame_backend_touch_set_window_pos(UFBackendTouch touch, float x, float y);
258
* Sets the "Time" property of the given touch
261
void frame_backend_touch_set_time(UFBackendTouch touch, uint64_t time);
264
* Sets the "StartTime" property of the given touch
267
void frame_backend_touch_set_start_time(UFBackendTouch touch, uint64_t start_time);
270
* Sets the "Owned" property of the given touch
273
void frame_backend_touch_set_owned(UFBackendTouch touch, int owned);
276
* Sets the "PendingEnd" property of the given touch
279
void frame_backend_touch_set_pending_end(UFBackendTouch touch, int pending_end);
282
* Sets the value of an axis of the given touch
285
void frame_backend_touch_set_value(UFBackendTouch touch, UFAxisType type, float value);
291
#endif /* FRAME_OIF_FRAME_BACKEND_H_ */