Tobii Pro SDK C API
time_synchronization_data.c
#include <stdio.h>
#include <inttypes.h>
#if _WIN32 || _WIN64
#include <windows.h>
static void sleep_ms(int time) {
Sleep(time);
}
#else
#include <unistd.h>
static void sleep_ms(int time) {
usleep(time * 1000);
}
#endif
void time_synchronization_data_callback(TobiiResearchTimeSynchronizationData* time_synchronization_data,
void* user_data){
(void)(user_data); // Is NULL, see subscribing call
printf("Device time stamp: %" PRId64 "\n", time_synchronization_data->device_time_stamp);
printf("System request time stamp: %" PRId64 "\n", time_synchronization_data->system_request_time_stamp);
printf("System response time stamp: %" PRId64 "\n", time_synchronization_data->system_response_time_stamp);
}
void time_synchronization_data_example(TobiiResearchEyeTracker* eyetracker) {
char* serial_number;
tobii_research_get_serial_number(eyetracker, &serial_number);
printf("Subscribing to time synchronization data for eye tracker with serial number %s.\n", serial_number);
tobii_research_subscribe_to_time_synchronization_data(eyetracker, time_synchronization_data_callback, NULL);
/* Wait while some time synchronization data is collected. */
sleep_ms(2000);
tobii_research_unsubscribe_from_time_synchronization_data(eyetracker, time_synchronization_data_callback);
printf("Unsubscribed from time synchronization data.\n");
}