This is example 9. This example demonstrates the following:
-
Starting the drift-check procedure on proceed request
This example is basically the same as
example 8 except that it extends the
onModeChange()
event handler function to trigger a drift-check whenever the
experimenter has used the Esc
key or Proceed button in the
user-interface to signal he/she wants to proceed with the experiment.
Source code
Source file: example9.c
onModeChange()
In the onModeChange()
event handler function we’re conditionally starting a
drift-check.
static int onModeChange(EyeVec* eyevec, int64_t eventtime,
const EyeVecModeChangeEventData* modedata, void* cldata)
{
(void)eyevec;
ClientData* clientdata = (ClientData*)cldata;
if (clientdata == NULL) return 0;
clientdata->trackermode = modedata->newmode;
if (clientdata->showmodechanges) {
printf("onModeChange:\n");
printf(" eventtime: %" PRId64 "\n",
eventtime);
printf(" oldmode: %s\n",
eyevec_tracker_mode_string(modedata->oldmode));
printf(" newmode: %s\n",
eyevec_tracker_mode_string(modedata->newmode));
printf(" exitstatus: %s\n",
eyevec_exit_status_string(modedata->exitstatus));
}
// If we're entering data mode from setup mode and the exitstatus is OK
// then that signifies the experimenter clicked the Proceed button in the
// user-interface or has hit <Esc>. Let's interpret this as:
// "proceed with the experiment by presenting a drift-check target".
if (modedata->oldmode == EYEVEC_TRACKER_MODE_SETUP && (1)
modedata->newmode == EYEVEC_TRACKER_MODE_DATA &&
modedata->exitstatus == EYEVEC_EXIT_STATUS_OK) {
bool ignore;
EyeVecResult err = eyevec_start_drift_check(eyevec, 0.3, 0.3, &ignore); (2)
printError("eyevec_start_drift_check()", err);
}
return 0;
}
1 | Check oldmode , newmode and exitstatus of specified
EyeVecModeChangeEventData
struct to see if going from setup mode to data mode with an exitstatus
of EYEVEC_EXIT_STATUS_OK . For a regular switch to data mode exitstatus
will be EYEVEC_EXIT_STATUS_NONE . |
2 | Start drift-check procedure at logical screen position <0.3, 0.3>. |
Running
After a succesful build run the program:
-
Press
x
to calleyevec_set_show_gui_on_setup_mode()
. This sets the show-gui-on-setup-mode flag to make the user-interface show on setup mode enter. If however you prefer to keep the user-interface visible at all times while testing pressu
to calleyevec_show_control_window()
. If you don’t want to calleyevec_show_control_window()
explicity but do want the user-interface to show when in data mode, pressX
to calleyevec_set_show_gui_on_data_mode()
. This sets the show-gui-on-data-mode flag to make the user-interface show on data mode enter. -
Press
o
to calleyevec_open()
. Eye-tracker should go from off mode to idle mode. -
Press
s
to calleyevec_enter_setup_mode()
. Eye-tracker should go from idle mode to setup mode and the user-interface should appear. Now perform a baseline measurement and calibration in the user-interface. -
In the user-interface press
Esc
or click Proceed make the eye-tracker go from setup mode to data mode (callingeyevec_enter_data_mode()
would also work). The user-interface should disappear (unless you pressedu
orX
in step 1) to be immediately followed by the test window presenting a drift-check target. -
Press
q
to quit.
Output might look like this (empty lines added for clarity):
eyevec_create_thread(): OK
eyevec_initialize(): OK
Type q to quit, ? for help.
[x]
eyevec_set_show_gui_on_setup_mode(true): OK
[o]
onModeChange:
eventtime: 1750592604612227
oldmode: TRACKER_MODE_OFF
newmode: TRACKER_MODE_IDLE
eyevec_open(): OK
exitstatus: EXIT_STATUS_NONE
[s]
eyevec_enter_setup_mode(): OK
onModeChange:
eventtime: 1750592606886614
oldmode: TRACKER_MODE_IDLE
newmode: TRACKER_MODE_SETUP
exitstatus: EXIT_STATUS_NONE
onModeChange:
eventtime: 1750592611564357
oldmode: TRACKER_MODE_SETUP
newmode: TRACKER_MODE_SETUP_BASELINE
exitstatus: EXIT_STATUS_NONE
onModeChange:
eventtime: 1750592615330694
oldmode: TRACKER_MODE_SETUP_BASELINE
newmode: TRACKER_MODE_SETUP
exitstatus: EXIT_STATUS_OK
onModeChange:
eventtime: 1750592618832015
oldmode: TRACKER_MODE_SETUP
newmode: TRACKER_MODE_SETUP_CALIBRATION
exitstatus: EXIT_STATUS_NONE
onModeChange:
eventtime: 1750592629405306
oldmode: TRACKER_MODE_SETUP_CALIBRATION
newmode: TRACKER_MODE_SETUP
exitstatus: EXIT_STATUS_OK
onModeChange:
eventtime: 1750592634980006
oldmode: TRACKER_MODE_SETUP
newmode: TRACKER_MODE_DATA
exitstatus: EXIT_STATUS_OK
eyevec_start_drift_check(): OK
onModeChange:
eventtime: 1750592634982049
oldmode: TRACKER_MODE_DATA
newmode: TRACKER_MODE_DRIFT_CHECK
exitstatus: EXIT_STATUS_NONE
onModeChange:
eventtime: 1750592637055370
oldmode: TRACKER_MODE_DRIFT_CHECK
newmode: TRACKER_MODE_DATA
exitstatus: EXIT_STATUS_OK
[q]
eyevec_cleanup(): OK
eyevec_destroy_thread(): OK
If the
auto-apply-drift-correction
eye-tracker setting is set (the default), then a succesful drift-check will
result in
eyevec_apply_drift_check_gaze_offset()
being called. If this settings is false then you can choose to analyze the
drift-check results in onModeChange()
and call the function contingent on the
reported drift-check error.