PsychEyelinkDispatchCallback implementes the EyeLink Core Graphics part
of the EyeLink API. This “Core Graphics” part of our API is responsible
for handling the times when the API and Host PC takes control of the eye
tracking procedures. This includes the functionality to stream camera
images during camera/participant setup, displaying targets at locations
on the participant screen during calibration, validation, and drift/check
and correction routines. Complimentary to handling the visual aspect of
these operations contingent on display routines, the functionality
implemented herewith also handles the playback of feedback sounds to
the experimenter and participant for guiding these interactive
procedures. During these modes of operation, this function also
implements the forwarding of kepresses to the Host PC that are registered
on the computer’s keyboard which is running this implementation. The
purpose of this is to make sure that bost Host and Display PCs are
operating as identically in these modes of operation.

This function is normally called from within the Eyelink() mex file.
Normal user code only calls it once to supply the eyelink defaults struct.
This is handled within the EyelinkInitDefaults.m file, so you generally
should not have to worry about this. However, if you change settings in
the el structure, you may need to call it yourself.

To define which onscreen window the eye image should be
drawn to, call it with the return value from EyelinkInitDefaults, e.g.,
w=Screen(‘OpenWindow’, …);

To actually receive and display the images, register this function as
eyelink’s callback:

if Eyelink(‘Initialize’, ‘myEyelinkDispatchCallback’) ~=0
error(‘eyelink failed init’)
result = Eyelink(‘StartSetup’,1) %put the tracker into a mode capable of sending images

then you must hit ‘return’ on the PTB computer, this key command will be
sent to the tracker host to initiate sending of images.


  1. 3.2009 Derived from MemoryBuffer2TextureDemo.m (MK).
  2. 4.2009 Updated to use EyelinkGetKey + fixed eyelinktex persistence
    crash (edf).
  3. 4.2009 Cleaned up. Should be ready for 1st release, although still
    pretty alpha quality. (MK).
  4. 6.2010 Added some drawing routines to get standard behaviour back.
    Enabled use of the callback by default. Clarified in
    helptext that user normally should not have to worry
    about calling this file. (fwc)
  5. 7.2010 Drawing of instructions, eye-image+title, playing sounds in
    seperate functions

  6. 2.2010 Modified to allow for cross hair and fix bugs. (nj)=
    29.10.2018 Drop ‘DrawDots’ for calibration target. Some white-space fixes.
  7. 3.2020 Cleaned up the documentation of this function, and added
    additiontal handling for two types of stereoscopic
    calibrations, ability to reference video files for
    animated calibration targets, bug fixes for audio
    feedback playback. Apologies to NJ for removing
    previous comments where code was previously added, this
    was done for easier reading of the code.
Path   Retrieve current version from GitHub | View changelog