Tobii Pro SDK C API
external_signal.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 external_signal_callback(TobiiResearchExternalSignalData* external_signal_data, void* user_data) {
(void)(user_data); // Is NULL, see subscription call
printf("External signal: device time stamp %" PRId64 ", value %i \n",
external_signal_data->device_time_stamp, external_signal_data->value);
}
void external_signal_example(TobiiResearchEyeTracker* eyetracker) {
char* serial_number;
tobii_research_get_serial_number(eyetracker, &serial_number);
printf("Subscribing to external signal for eye tracker with serial number %s.\n", serial_number);
tobii_research_subscribe_to_external_signal_data(eyetracker, external_signal_callback, NULL);
/* Wait for external signal. */
sleep_ms(2000);
tobii_research_unsubscribe_from_external_signal_data(eyetracker, external_signal_callback);
printf("Unsubscribed from external signal.");
}