tobii_sys/
lib.rs

1//! Based on the stream engine headers from v1.2.1.305
2
3/* automatically generated by rust-bindgen and then heavily cleaned up by @trishume */
4
5pub mod helpers;
6
7pub const TOBII_DEVICE_GENERATION_G5: ::std::os::raw::c_uint = 2;
8pub const TOBII_DEVICE_GENERATION_IS3: ::std::os::raw::c_uint = 4;
9pub const TOBII_DEVICE_GENERATION_IS4: ::std::os::raw::c_uint = 8;
10
11pub const TOBII_ERROR_NO_ERROR: Status = 0;
12pub const TOBII_ERROR_INTERNAL: Status = 1;
13pub const TOBII_ERROR_INSUFFICIENT_LICENSE: Status = 2;
14pub const TOBII_ERROR_NOT_SUPPORTED: Status = 3;
15pub const TOBII_ERROR_NOT_AVAILABLE: Status = 4;
16pub const TOBII_ERROR_CONNECTION_FAILED: Status = 5;
17pub const TOBII_ERROR_TIMED_OUT: Status = 6;
18pub const TOBII_ERROR_ALLOCATION_FAILED: Status = 7;
19pub const TOBII_ERROR_INVALID_PARAMETER: Status = 8;
20pub const TOBII_ERROR_CALIBRATION_ALREADY_STARTED: Status = 9;
21pub const TOBII_ERROR_CALIBRATION_NOT_STARTED: Status = 10;
22pub const TOBII_ERROR_ALREADY_SUBSCRIBED: Status = 11;
23pub const TOBII_ERROR_NOT_SUBSCRIBED: Status = 12;
24pub const TOBII_ERROR_OPERATION_FAILED: Status = 13;
25pub const TOBII_ERROR_CONFLICTING_API_INSTANCES: Status = 14;
26pub const TOBII_ERROR_CALIBRATION_BUSY: Status = 15;
27pub const TOBII_ERROR_CALLBACK_IN_PROGRESS: Status = 16;
28
29/// tobii_error_t
30pub type Status = ::std::os::raw::c_uint;
31
32/// tobii_device_t
33#[repr(C)]
34#[derive(Debug, Copy, Clone )]
35pub struct Device {
36    _unused: [u8; 0],
37}
38
39/// tobii_device_info_t
40#[repr(C)]
41#[derive(Copy, Clone )]
42pub struct DeviceInfo {
43    pub serial_number: [::std::os::raw::c_char; 128usize],
44    pub model: [::std::os::raw::c_char; 64usize],
45    pub generation: [::std::os::raw::c_char; 64usize],
46    pub firmware_version: [::std::os::raw::c_char; 128usize],
47}
48
49/// tobii_version_t
50#[repr(C)]
51#[derive(Debug, Copy, Clone )]
52pub struct Version {
53    pub major: ::std::os::raw::c_int,
54    pub minor: ::std::os::raw::c_int,
55    pub revision: ::std::os::raw::c_int,
56    pub build: ::std::os::raw::c_int,
57}
58
59pub const TOBII_LOG_LEVEL_ERROR: LogLevel = 0;
60pub const TOBII_LOG_LEVEL_WARN: LogLevel = 1;
61pub const TOBII_LOG_LEVEL_INFO: LogLevel = 2;
62pub const TOBII_LOG_LEVEL_DEBUG: LogLevel = 3;
63pub const TOBII_LOG_LEVEL_TRACE: LogLevel = 4;
64pub type LogLevel = ::std::os::raw::c_uint;
65pub type LogFn =
66    ::std::option::Option<unsafe extern "C" fn(log_context: *mut ::std::os::raw::c_void,
67                                               level: LogLevel,
68                                               text: *const ::std::os::raw::c_char)>;
69
70/// tobii_custom_log_t
71#[repr(C)]
72#[derive(Debug, Copy, Clone )]
73pub struct CustomLog {
74    pub log_context: *mut ::std::os::raw::c_void,
75    pub log_func: LogFn,
76}
77pub type MallocFn =
78    ::std::option::Option<unsafe extern "C" fn(mem_context: *mut ::std::os::raw::c_void,
79                                               size: usize)
80                                               -> *mut ::std::os::raw::c_void>;
81pub type FreeFn =
82    ::std::option::Option<unsafe extern "C" fn(mem_context: *mut ::std::os::raw::c_void,
83                                               ptr: *mut ::std::os::raw::c_void)>;
84
85#[repr(C)]
86#[derive(Debug, Copy, Clone )]
87pub struct CustomAlloc {
88    pub mem_context: *mut ::std::os::raw::c_void,
89    pub malloc_func: MallocFn,
90    pub free_func: FreeFn,
91}
92
93/// tobii_api_t
94#[repr(C)]
95#[derive(Debug, Copy, Clone )]
96pub struct Api {
97    _unused: [u8; 0],
98}
99pub type DeviceUrlReceiver =
100    ::std::option::Option<unsafe extern "C" fn(url: *const ::std::os::raw::c_char,
101                                               user_data: *mut ::std::os::raw::c_void)>;
102
103#[repr(C)]
104#[derive(Debug, Copy, Clone )]
105pub struct TrackBox {
106    pub front_upper_right_xyz: [f32; 3],
107    pub front_upper_left_xyz: [f32; 3],
108    pub front_lower_left_xyz: [f32; 3],
109    pub front_lower_right_xyz: [f32; 3],
110    pub back_upper_right_xyz: [f32; 3],
111    pub back_upper_left_xyz: [f32; 3],
112    pub back_lower_left_xyz: [f32; 3],
113    pub back_lower_right_xyz: [f32; 3],
114}
115
116pub const TOBII_STATE_POWER_SAVE_ACTIVE: State = 0;
117pub const TOBII_STATE_REMOTE_WAKE_ACTIVE: State = 1;
118pub const TOBII_STATE_DEVICE_PAUSED: State = 2;
119pub const TOBII_STATE_EXCLUSIVE_MODE: State = 3;
120pub type State = ::std::os::raw::c_uint;
121
122pub const TOBII_STATE_BOOL_FALSE: StateBool = 0;
123pub const TOBII_STATE_BOOL_TRUE: StateBool = 1;
124pub type StateBool = ::std::os::raw::c_uint;
125
126pub const TOBII_NOT_SUPPORTED: Supported = 0;
127pub const TOBII_SUPPORTED: Supported = 1;
128pub type Supported = ::std::os::raw::c_uint;
129
130pub const TOBII_CAPABILITY_DISPLAY_AREA_WRITABLE: Capability = 0;
131pub const TOBII_CAPABILITY_CALIBRATION_2D: Capability = 1;
132pub const TOBII_CAPABILITY_CALIBRATION_3D: Capability = 2;
133pub const TOBII_CAPABILITY_PERSISTENT_STORAGE: Capability = 3;
134pub type Capability = ::std::os::raw::c_uint;
135
136pub const TOBII_STREAM_GAZE_POINT: Stream = 0;
137pub const TOBII_STREAM_GAZE_ORIGIN: Stream = 1;
138pub const TOBII_STREAM_EYE_POSITION_NORMALIZED: Stream = 2;
139pub const TOBII_STREAM_USER_PRESENCE: Stream = 3;
140pub const TOBII_STREAM_HEAD_POSE: Stream = 4;
141pub const TOBII_STREAM_WEARABLE: Stream = 5;
142pub const TOBII_STREAM_GAZE_DATA: Stream = 6;
143pub const TOBII_STREAM_DIGITAL_SYNCPORT: Stream = 7;
144pub const TOBII_STREAM_DIAGNOSTICS_IMAGE: Stream = 8;
145pub type Stream = ::std::os::raw::c_uint;
146
147pub type DataReceiver =
148    ::std::option::Option<unsafe extern "C" fn(data: *const ::std::os::raw::c_void,
149                                               size: usize,
150                                               user_data: *mut ::std::os::raw::c_void)>;
151
152pub const TOBII_VALIDITY_INVALID: Validity = 0;
153pub const TOBII_VALIDITY_VALID: Validity = 1;
154pub type Validity = ::std::os::raw::c_uint;
155
156#[repr(C)]
157#[derive(Debug, Copy, Clone )]
158pub struct DisplayArea {
159    pub top_left_mm_xyz: [f32; 3],
160    pub top_right_mm_xyz: [f32; 3],
161    pub bottom_left_mm_xyz: [f32; 3],
162}
163
164// tobii_stream.h =========================
165
166pub const TOBII_NOTIFICATION_TYPE_CALIBRATION_STATE_CHANGED : NotificationType = 0 ;
167pub const TOBII_NOTIFICATION_TYPE_EXCLUSIVE_MODE_STATE_CHANGED : NotificationType = 1 ;
168pub const TOBII_NOTIFICATION_TYPE_TRACK_BOX_CHANGED : NotificationType = 2 ;
169pub const TOBII_NOTIFICATION_TYPE_DISPLAY_AREA_CHANGED : NotificationType = 3 ;
170pub const TOBII_NOTIFICATION_TYPE_FRAMERATE_CHANGED : NotificationType = 4 ;
171pub const TOBII_NOTIFICATION_TYPE_POWER_SAVE_STATE_CHANGED : NotificationType = 5 ;
172pub const TOBII_NOTIFICATION_TYPE_DEVICE_PAUSED_STATE_CHANGED : NotificationType = 6 ;
173pub type NotificationType = ::std::os::raw::c_uint;
174pub const TOBII_NOTIFICATION_VALUE_TYPE_NONE : NotificationValueType = 0 ;
175pub const TOBII_NOTIFICATION_VALUE_TYPE_FLOAT : NotificationValueType = 1 ;
176pub const TOBII_NOTIFICATION_VALUE_TYPE_STATE : NotificationValueType = 2 ;
177pub const TOBII_NOTIFICATION_VALUE_TYPE_DISPLAY_AREA : NotificationValueType = 3 ;
178pub type NotificationValueType = ::std::os::raw::c_uint;
179
180#[repr(C)]
181#[derive(Copy, Clone)]
182pub union NotificationUnion {
183    float: f32,
184    state: StateBool,
185    display_area: DisplayArea,
186}
187
188#[repr(C)]
189#[derive(Copy, Clone)]
190pub struct Notification {
191    pub type_: NotificationType,
192    pub value_type: NotificationValueType,
193    pub value: NotificationUnion,
194}
195
196pub type NotificationsCallbackFn =
197    ::std::option::Option<unsafe extern "C" fn(notification: *const Notification,
198                                               user_data: *mut ::std::os::raw::c_void)>;
199
200#[repr(C)]
201#[derive(Debug, Copy, Clone)]
202pub struct GazePoint {
203    pub timestamp_us: i64,
204    pub validity: Validity,
205    pub position_xy: [f32; 2usize],
206}
207pub type GazePointFn =
208    ::std::option::Option<unsafe extern "C" fn(gaze_point: *const GazePoint,
209                                               user_data: *mut ::std::os::raw::c_void)>;
210#[repr(C)]
211#[derive(Debug, Copy, Clone)]
212pub struct GazeOrigin {
213    pub timestamp_us: i64,
214    pub left_validity: Validity,
215    pub left_xyz: [f32; 3usize],
216    pub right_validity: Validity,
217    pub right_xyz: [f32; 3usize],
218}
219
220#[repr(C)]
221#[derive(Debug, Copy, Clone)]
222pub struct EyePositionNormalized {
223    pub timestamp_us: i64,
224    pub left_validity: Validity,
225    pub left_xyz: [f32; 3usize],
226    pub right_validity: Validity,
227    pub right_xyz: [f32; 3usize],
228}
229
230pub const TOBII_USER_PRESENCE_STATUS_UNKNOWN : UserPresenceStatus = 0 ;
231pub const TOBII_USER_PRESENCE_STATUS_AWAY : UserPresenceStatus = 1 ;
232pub const TOBII_USER_PRESENCE_STATUS_PRESENT : UserPresenceStatus = 2 ;
233pub type UserPresenceStatus = ::std::os::raw::c_uint;
234pub type UserPresenceFn =
235    ::std::option::Option<unsafe extern "C" fn(status: UserPresenceStatus,
236                                               timestamp_us: i64,
237                                               user_data: *mut ::std::os::raw::c_void)>;
238#[repr(C)]
239#[derive(Debug, Copy, Clone)]
240pub struct HeadPose {
241    pub timestamp_us: i64,
242    pub position_validity: Validity,
243    pub position_xyz: [f32; 3usize],
244    pub rotation_validity_xyz: [Validity; 3usize],
245    pub rotation_xyz: [f32; 3usize],
246}
247pub type HeadPoseFn =
248    ::std::option::Option<unsafe extern "C" fn(head_pose: *const HeadPose,
249                                               user_data: *mut ::std::os::raw::c_void)>;
250pub type GazeOriginFn =
251    ::std::option::Option<unsafe extern "C" fn(gaze_origin: *const GazeOrigin,
252                                               user_data: *mut ::std::os::raw::c_void)>;
253pub type EyePositionNormalizedFn = :: std :: option :: Option < unsafe extern "C" fn ( eye_position : * const EyePositionNormalized , user_data : * mut :: std :: os :: raw :: c_void ) > ;
254
255
256
257#[link(name = "StreamEngineClientKit", kind = "framework")]
258extern "C" {
259    pub fn tobii_error_message(error: Status) -> *const ::std::os::raw::c_char;
260    pub fn tobii_get_api_version(version: *mut Version) -> Status;
261    pub fn tobii_api_create(api: *mut *mut Api,
262                            custom_alloc: *const CustomAlloc,
263                            custom_log: *const CustomLog)
264                            -> Status;
265    pub fn tobii_api_destroy(api: *mut Api) -> Status;
266    pub fn tobii_system_clock(api: *mut Api, timestamp_us: *mut i64) -> Status;
267    pub fn tobii_enumerate_local_device_urls(api: *mut Api,
268                                             receiver: DeviceUrlReceiver,
269                                             user_data: *mut ::std::os::raw::c_void)
270                                             -> Status;
271    pub fn tobii_enumerate_local_device_urls_ex(api: *mut Api,
272                                                receiver: DeviceUrlReceiver,
273                                                user_data: *mut ::std::os::raw::c_void,
274                                                device_generations: u32)
275                                                -> Status;
276    pub fn tobii_device_create(api: *mut Api,
277                               url: *const ::std::os::raw::c_char,
278                               device: *mut *mut Device)
279                               -> Status;
280    pub fn tobii_device_destroy(device: *mut Device) -> Status;
281    // TODO add support for engine type
282    pub fn tobii_wait_for_callbacks(engine: *mut ::std::os::raw::c_void,
283                                    device_count: ::std::os::raw::c_int,
284                                    devices: *const *mut Device)
285                                    -> Status;
286    pub fn tobii_device_process_callbacks(device: *mut Device) -> Status;
287    pub fn tobii_clear_callback_buffers(device: *mut Device) -> Status;
288    pub fn tobii_device_reconnect(device: *mut Device) -> Status;
289    pub fn tobii_update_timesync(device: *mut Device) -> Status;
290    pub fn tobii_get_device_info(device: *mut Device,
291                                 device_info: *mut DeviceInfo)
292                                 -> Status;
293    pub fn tobii_get_track_box(device: *mut Device,
294                               track_box: *mut TrackBox)
295                               -> Status;
296    pub fn tobii_get_state_bool(device: *mut Device,
297                                state: State,
298                                value: *mut StateBool)
299                                -> Status;
300    pub fn tobii_capability_supported(device: *mut Device,
301                                      capability: Capability,
302                                      supported: *mut Supported)
303                                      -> Status;
304    pub fn tobii_stream_supported(device: *mut Device,
305                                  stream: Stream,
306                                  supported: *mut Supported)
307                                  -> Status;
308
309
310    // tobii_stream.h =================================================================
311
312    pub fn tobii_gaze_point_subscribe(device: *mut Device,
313                                      callback: GazePointFn,
314                                      user_data: *mut ::std::os::raw::c_void)
315                                      -> Status;
316    pub fn tobii_gaze_point_unsubscribe(device: *mut Device) -> Status;
317    pub fn tobii_gaze_origin_subscribe(device: *mut Device,
318                                       callback: GazeOriginFn,
319                                       user_data: *mut ::std::os::raw::c_void)
320                                       -> Status;
321    pub fn tobii_gaze_origin_unsubscribe(device: *mut Device) -> Status;
322    pub fn tobii_eye_position_normalized_subscribe(device: *mut Device,
323                                       callback: EyePositionNormalizedFn,
324                                       user_data: *mut ::std::os::raw::c_void)
325                                       -> Status;
326    pub fn tobii_eye_position_normalized_unsubscribe(device: *mut Device) -> Status;
327    pub fn tobii_user_presence_subscribe(device: *mut Device,
328                                         callback: UserPresenceFn,
329                                         user_data: *mut ::std::os::raw::c_void)
330                                         -> Status;
331    pub fn tobii_user_presence_unsubscribe(device: *mut Device) -> Status;
332    pub fn tobii_head_pose_subscribe(device: *mut Device,
333                                     callback: HeadPoseFn,
334                                     user_data: *mut ::std::os::raw::c_void)
335                                     -> Status;
336    pub fn tobii_head_pose_unsubscribe(device: *mut Device) -> Status;
337    pub fn tobii_notifications_subscribe(device: *mut Device,
338                                         callback: NotificationsCallbackFn,
339                                         user_data: *mut ::std::os::raw::c_void)
340                                         -> Status;
341    pub fn tobii_notifications_unsubscribe(device: *mut Device) -> Status;
342}