Example #1
0
// SEAN -new actual
int run_trials(void)
{
  int i=0;
  
  target_foreground_color = RGB(0,0,0);          // set background for calibration
  target_background_color = RGB(255,255,255);    // This should match the display
  set_calibration_colors(target_foreground_color, target_background_color);
  
  /*TRIAL_VAR_LABELS message is recorded for EyeLink Data Viewer analysis
  It specifies the list of trial variables for the trial
  This should be written once only and put before the recording of individual trials */
  eyemsg_printf("TRIAL_VAR_LABELS TRIAL_WORD");
  
  /* PERFORM CAMERA SETUP, CALIBRATION */
  do_tracker_setup();
  
  
  //SEAN -moved from win_main
  sean_window(sean_nCmdShow, &sean_lpCmdLine);
  
  if(eyelink_is_connected()==0 || break_pressed())    /* drop out if link closed */
  {
      return ABORT_EXPT;
  }
  
  return 0;
}
Example #2
0
//SEAN excluded
int run_trials_org(void)
{
  int i=0;
  int trial;
  
  target_foreground_color = RGB(0,0,0);          // set background for calibration
  target_background_color = RGB(255,255,255);    // This should match the display
  set_calibration_colors(target_foreground_color, target_background_color);
  
  /*TRIAL_VAR_LABELS message is recorded for EyeLink Data Viewer analysis
  It specifies the list of trial variables for the trial
  This should be written once only and put before the recording of individual trials */
  eyemsg_printf("TRIAL_VAR_LABELS TRIAL_WORD");
  
  /* PERFORM CAMERA SETUP, CALIBRATION */
  do_tracker_setup();
  
  
  
		/* loop through trials */
  for(trial=1;trial<=NTRIALS;trial++)
  {
    if(eyelink_is_connected()==0 || break_pressed())    /* drop out if link closed */
    {
      return ABORT_EXPT;
    }
				/* RUN THE TRIAL */
    i = do_simple_trial(trial);
    end_realtime_mode();          // safety: make sure realtime mode stopped
    
    
    
    
    switch(i)         	/* REPORT ANY ERRORS */
    {
    case ABORT_EXPT:        /* handle experiment abort or disconnect */
      eyemsg_printf("EXPERIMENT ABORTED");
      return ABORT_EXPT;
    case REPEAT_TRIAL:	  /* trial restart requested */
      eyemsg_printf("TRIAL REPEATED");
      trial--;
      break;
    case SKIP_TRIAL:	  /* skip trial */
      eyemsg_printf("TRIAL ABORTED");
      break;
    case TRIAL_OK:          // successful trial
      eyemsg_printf("TRIAL OK");
      break;
    default:                // other error code
      eyemsg_printf("TRIAL ERROR");
      break;
    }
  }  // END OF TRIAL LOOP
  return 0;
}
// ######################################################################
void EyeTrackerEyeLink::setBackgroundColor(nub::soft_ref<PsychoDisplay> d)
{
#ifndef HAVE_EYELINK
  LFATAL("Proprietary EyeLink developer API not installed");
#else
	SDL_Color bgcolor = { d->getGrey().red(), d->getGrey().green(), d->getGrey().blue()};
	SDL_Color fgcolor = { 192, 192, 192};
	
	set_calibration_colors(&fgcolor, &bgcolor);
	LINFO("RGB: %i %i %i", d->getGrey().red(), d->getGrey().green(), d->getGrey().blue());
#endif
}
	/* from the tracker ABORT menu. */
int run_trials(void)
{
  int i;
  int trial;
                 // INITIAL CALIBRATION: matches following trials
  target_foreground_color = RGB(0,0,0);         // color of calibration target
  target_background_color = RGB(200,200,200);   // background for drift correction
  set_calibration_colors(target_foreground_color, target_background_color); // tell EXPTSPPT the colors
   
  // TRIAL_VAR_LABELS message is recorded for EyeLink Data Viewer analysis
  // It specifies the list of trial variables for the trial 
  // This should be written once only and put before the recording of individual trials
  eyemsg_printf("TRIAL_VAR_LABELS TYPE CENTRAL PERIPHERAL");

  if(SCRWIDTH!=800 || SCRHEIGHT!=600)
    alert_printf("Display mode is not 800x600, resizing will slow loading.");

  		/* PERFORM CAMERA SETUP, CALIBRATION */
  do_tracker_setup();
				/* loop through trials */
  for(trial=1;trial<=NTRIALS;trial++)
    {
      if(eyelink_is_connected()==0 || break_pressed())    /* drop out if link closed */
	{
	  return ABORT_EXPT;
	}
				/* RUN THE TRIAL */
      i = do_gcwindow_trial(trial);
      end_realtime_mode();

      switch(i)         	/* REPORT ANY ERRORS */
	{
	  case ABORT_EXPT:        /* handle experiment abort or disconnect */
	    eyemsg_printf("EXPERIMENT ABORTED");
	    return ABORT_EXPT;
	  case REPEAT_TRIAL:	  /* trial restart requested */
	    eyemsg_printf("TRIAL REPEATED");
	    trial--;
	    break;
	  case SKIP_TRIAL:	  /* skip trial */
	    eyemsg_printf("TRIAL ABORTED");
	    break;
	  case TRIAL_OK:          // successful trial
	    eyemsg_printf("TRIAL OK");
	    break;
	  default:                // other error code
	    eyemsg_printf("TRIAL ERROR");
	    break;
	}
    }  // END OF TRIAL LOOP
  return 0;
}
/******************************** TRIAL LOOP ************************************

	This code sequences trials within a block  It calls run_trial() to 
	execute a trial, then interperts result code. It places a result message 
	in the EDF file. This example allows trials to be repeated from 
	the tracker ABORT menu. 
 ********************************************************************************/
int run_trials(void)
{
  int i;
  int trial;
  
  SETCOLOR(target_foreground_color,0,0,0);       /* set background for calibration */
  SETCOLOR(target_background_color,255,255,255); /* This should match the display */
  set_calibration_colors(&target_foreground_color, &target_background_color); 
        
  /* PERFORM CAMERA SETUP, CALIBRATION */
  do_tracker_setup();
				
  /* loop through trials */
  for(trial=1;trial<=NTRIALS;trial++)
    {
      if(eyelink_is_connected()==0 || break_pressed())    /* drop out if link closed */
		{
			return ABORT_EXPT;
		}
		/* RUN THE TRIAL */
		i = do_simple_trial(trial);
		end_realtime_mode();          /* safety: make sure realtime mode stopped */

		switch(i)         	/* REPORT ANY ERRORS */
		{
		case ABORT_EXPT:        /* handle experiment abort or disconnect */
			eyemsg_printf("EXPERIMENT ABORTED");
			return ABORT_EXPT;
		case REPEAT_TRIAL:	  /* trial restart requested */
			eyemsg_printf("TRIAL REPEATED");
			trial--;
			break;
		case SKIP_TRIAL:	  /* skip trial */
			eyemsg_printf("TRIAL ABORTED");
			break;
		case TRIAL_OK:          /* successful trial */
		    eyemsg_printf("TRIAL OK");
		    break;
		default:                /* other error code */
		    eyemsg_printf("TRIAL ERROR");
			break;
		}
    }  /* END OF TRIAL LOOP */
  return 0;
}
         // Create foreground and background bitmaps of picture
         // EyeLink graphics: blank display with box at center
         // type: 0 = blank background, 1= blank fovea (mask), 2 = blurred background
static int create_image_bitmaps(int type)
{ 
  target_foreground_color = RGB(0,0,0);         // color of calibration target
  target_background_color = RGB(128,128,128);   // background for drift correction
  set_calibration_colors(target_foreground_color, target_background_color); // tell EXPTSPPT the colors

  clear_full_screen_window(target_background_color);
// NOTE:  *** THE FOLLOWING TEXT SHOULD NOT APPEAR IN A REAL EXPERIMENT!!!! ****
  get_new_font("Arial", 24, 1);
  graphic_printf(target_foreground_color, -1, 1, SCRWIDTH/2, SCRHEIGHT/2, "Loading image...");

  switch(type)
    {  
      case 0:     // blank background
        fgbm = image_file_bitmap("images/sacrmeto.jpg", 0, SCRWIDTH,SCRHEIGHT,target_background_color);
        bgbm = blank_bitmap(target_background_color);
        break;
      case 1:     // blank fovea
        fgbm = blank_bitmap(target_background_color);
        bgbm = image_file_bitmap("images/sacrmeto.jpg", 0, SCRWIDTH,SCRHEIGHT,target_background_color);
        break;
      case 2:     // normal and blurred bitmaps, stretched to fit display
        fgbm = image_file_bitmap("images/sacrmeto.jpg", 0, SCRWIDTH,SCRHEIGHT,target_background_color);
        bgbm = image_file_bitmap("images/sac_blur.jpg", 0, SCRWIDTH,SCRHEIGHT,target_background_color);
        break;
    }

  eyecmd_printf("clear_screen 0");                   // clear EyeLink display
  eyecmd_printf("draw_box %d %d %d %d 15",          // Box around fixation point
           SCRWIDTH/2-16, SCRHEIGHT/2-16, SCRWIDTH/2+16, SCRHEIGHT/2+16);

  if(!fgbm || !bgbm)  // Check that both bitmaps exist.
    {
      eyemsg_printf("ERROR: could not load image");
      alert_printf("ERROR: could not load an image file");
      if(fgbm) DeleteObject(fgbm);
      if(bgbm) DeleteObject(bgbm);
      return SKIP_TRIAL;
    }
  return 0;
}
         // Create foreground and background bitmaps of text
static int create_text_bitmaps(void)
{
  RECT margins;                // margins for text
          
  margins.top = SCRHEIGHT/20;  // set margin in about 1°
  margins.left = SCRWIDTH/20;
  margins.right = SCRWIDTH - SCRWIDTH/20;
  margins.bottom = SCRHEIGHT - SCRHEIGHT/20;
    
  target_foreground_color = RGB(0,0,0);         // color of calibration target
  target_background_color = RGB(255,255,255);   // background for drift correction
  set_calibration_colors(target_foreground_color, target_background_color); // tell EXPTSPPT the colors

  get_new_font("Courier New", SCRHEIGHT/32, 1);   // create a monospaced font
                                 

  // Draw text and EyeLink graphics
  fgbm = text_bitmap_segment(fg_text, RGB(0,0,0), RGB(255,255,255), margins, SCRHEIGHT/15, 0, 
		"text.ias", "segments", SV_NOREPLACE); // Create bitmap and its segmentation (if it does not exist)
 

  // IAREA command is recorded for EyeLink Data Viewer analysis
  // It creates a set of interest areas by reading the segment files
  // Writes segmentation filename + path info 	
  eyemsg_printf("!V IAREA FILE segments/text.ias"); 

  // Draw text and EyeLink graphics for the background bitmap
  bgbm = text_bitmap(bg_text, RGB(0,0,0), RGB(255,255,255), margins, SCRHEIGHT/15, 0);

  
  if(!fgbm || !bgbm)  // Check that both bitmaps exist.
    {
      eyemsg_printf("ERROR: could not load image");
      alert_printf("ERROR: could not load an image file");
      if(fgbm) DeleteObject(fgbm);
      if(bgbm) DeleteObject(bgbm);
      return SKIP_TRIAL;
    }
  return 0;
}
// ######################################################################
void EyeTrackerEyeLink::openSDL()
{
#ifdef HAVE_EYELINK
  // set the display characteristics:
	DISPLAYINFO di;
  di.width = itsDims.getVal().w(); di.height = itsDims.getVal().h();
  di.left = 0; di.top = 0; di.right = di.width-1; di.bottom = di.height-1;
  di.bits = 24; di.palsize = 0; di.pages = 0; di.refresh = 60.0F;
  di.winnt = 0;

  // open the display with our wishes:
  if (init_expt_graphics(NULL, &di))
    LFATAL("Cannot open display");

  // see what we actually got:
  get_display_information(&di);
  LINFO("DISPLAYINFO: [%dx%d}: (%d,%d)-(%d,%d) %dbpp %.1fHz",
        int(di.width), int(di.height), int(di.left), int(di.top),
        int(di.right), int(di.bottom), int(di.bits), di.refresh);
  if (di.palsize) LFATAL("Paletized color modes not supported");

  // Prepare for calibration and other settings:
  set_target_size(10, 2);
  set_calibration_colors(&target_foreground_color, &target_background_color);
  set_cal_sounds(const_cast<char*>(""), const_cast<char*>(""), const_cast<char*>(""));
  set_dcorr_sounds(const_cast<char*>(""), const_cast<char*>("off"), const_cast<char*>("off"));

  // Setup calibration type:
  eyecmd_printf(const_cast<char*>("calibration_type = HV9"));

  // Configure tracker for display:
  eyecmd_printf(const_cast<char*>("screen_pixel_coords = %ld %ld %ld %ld"),
                di.left, di.top, di.right, di.bottom);

        if (di.refresh > 40.0F)
    eyemsg_printf(const_cast<char*>("FRAMERATE %1.2f Hz."), di.refresh);
#endif
}
Example #9
0
int app_main(char * trackerip, DISPLAYINFO * disp)
{
  UINT16 i, j;
  char our_file_name[260] = "TEST";
  char verstr[50];
  int eyelink_ver = 0;
  int tracker_software_ver = 0;
  
  if(trackerip)
		set_eyelink_address(trackerip);
  if(open_eyelink_connection(0)) return -1;    /* abort if we can't open link */
  set_offline_mode();
  flush_getkey_queue();                        /* initialize getkey() system */

  eyelink_ver = eyelink_get_tracker_version(verstr);
  if (eyelink_ver == 3)
	  tracker_software_ver = get_tracker_sw_version(verstr);



  if(init_expt_graphics(NULL, disp))
	  goto shutdown;   /* register window with EXPTSPPT */


  window = SDL_GetVideoSurface();
  get_display_information(&dispinfo);          /* get window size, characteristics */

    /*
		NOTE: Camera display does not support 16-color modes
		NOTE: Picture display examples don't work well with 256-color modes
		However, all other sample programs should work well.
	*/

  if(dispinfo.palsize)     /* 256-color modes: palettes not supported by this example */
      alert_printf("This program is not optimized for 256-color displays");


 

  
  i = SCRWIDTH/60;		  /* select best size for calibration target */
  j = SCRWIDTH/300;       /* and focal spot in target */
  if(j < 2) j = 2;
  set_target_size(i, j);  /* tell DLL the size of target features */


  /* color of calibration target */
  SETCOLOR(target_foreground_color, 0,0,0);
  /* background for calibration and drift correction */
  SETCOLOR(target_background_color, 128,128,128);
  /* tell EXPTSPPT the colors */
  set_calibration_colors(&target_foreground_color, &target_background_color);

  set_cal_sounds("", "", "");
  set_dcorr_sounds("", "off", "off");

  /* draw a title screen */
  clear_full_screen_window(target_background_color);    /* clear screen */
  get_new_font("Times Roman", SCRHEIGHT/32, 1);         /* select a font */
                                                        /* Draw text */
  graphic_printf(window, target_foreground_color,  CENTER, SCRWIDTH/2, 1*SCRHEIGHT/30,
                 "EyeLink Demonstration Experiment: Communicate with Listener");
  graphic_printf(window, target_foreground_color,  CENTER, SCRWIDTH/2, 2*SCRHEIGHT/30,
                 "Included with the Experiment Programming Kit for Windows");
  graphic_printf(window, target_foreground_color,  CENTER, SCRWIDTH/2, 3*SCRHEIGHT/30,
                 "All code is Copyright (c) 1997-2002 SR Research Ltd.");
  graphic_printf(window, target_foreground_color,  CENTER, SCRWIDTH/5, 4*SCRHEIGHT/30,
                 "Source code may be used as template for your experiments.");
  SDL_Flip(window);

  eyelink_set_name("comm_simple");  /* NEW: set our network name */

  if(check_for_listener())   /* check for COMM_LISTENER application */
    {
      alert_printf("Could not communicate with COMM_LISTENER application.");
      goto shutdown;
    }

  if(i==1)  our_file_name[0] = 0;   /* Cancelled: No file name */
  if(our_file_name[0])    /* If file name set, open it */
    {
      if(!strstr(our_file_name, ".")) strcat(our_file_name, ".EDF");  /* add extension   */
      i = open_data_file(our_file_name);                              /* open file       */
      if(i!=0)                                                        /* check for error */
        {
          alert_printf("Cannot create EDF file '%s'", our_file_name);
          goto shutdown;
        }
	  /* add title to preamble */
      eyecmd_printf("add_file_preamble_text 'RECORDED BY %s' ", program_name);
    }
  /*
		SET UP TRACKER CONFIGURATION
		NOTE: set contents before sending messages!
		set EDF file contents
  */
   if(eyelink_ver>=2)
    {
      eyecmd_printf("select_parser_configuration 0");  // 0 = standard sensitivity
	  if(eyelink_ver == 2) //turn off scenelink camera stuff
	  {
		eyecmd_printf("scene_camera_gazemap = NO");
	  }
    }
  else
    {
      eyecmd_printf("saccade_velocity_threshold = 35");
      eyecmd_printf("saccade_acceleration_threshold = 9500");
    }
  // NOTE: set contents before sending messages!
		     // set EDF file contents 
  eyecmd_printf("file_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON");
  eyecmd_printf("file_sample_data  = LEFT,RIGHT,GAZE,AREA,GAZERES,STATUS%s",(tracker_software_ver>=4)?",HTARGET":"");
		      // set link data (used for gaze cursor) 
  eyecmd_printf("link_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,BUTTON");
  eyecmd_printf("link_sample_data  = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS%s",(tracker_software_ver>=4)?",HTARGET":"");

  /* NEW: Allow EyeLink I (v2.1+) to echo messages back to listener */
  eyecmd_printf("link_nonrecord_events = BUTTONS, MESSAGES");

  /* Program button #5 for use in drift correction */
  eyecmd_printf("button_function 5 'accept_target_fixation'");

  /* Now configure tracker for display resolution */
  eyecmd_printf("screen_pixel_coords = %ld %ld %ld %ld",    /* Set display resolution */
                 dispinfo.left, dispinfo.top, dispinfo.right, dispinfo.bottom);
  eyecmd_printf("calibration_type = HV9");       /* Setup calibration type */
  eyemsg_printf("DISPLAY_COORDS %ld %ld %ld %ld",/* Add resolution to EDF file */
                 dispinfo.left, dispinfo.top, dispinfo.right, dispinfo.bottom);
  if(dispinfo.refresh>40)
    eyemsg_printf("FRAMERATE %1.2f Hz.", dispinfo.refresh);

  

  /* make sure we're still alive */
  if(!eyelink_is_connected() || break_pressed()) goto end_expt;

  /*
	 RUN THE EXPERIMENTAL TRIALS (code depends on type of experiment)
     Calling run_trials() performs a calibration followed by trials
     This is equivalent to one block of an experiment
     It will return ABORT_EXPT if the program should exit
   */
  i = run_trials();

end_expt:                /* END: close, transfer EDF file */
  set_offline_mode();    /* set offline mode so we can transfer file */
  pump_delay(500);       /* delay so tracker is ready */
  eyecmd_printf("close_data_file"); /* close data file */

  if(break_pressed()) goto shutdown;/* don't get file if we aborted experiment */
  if(our_file_name[0])              /* make sure we created a file */
    receive_data_file(our_file_name, "", 0);  /* transfer the file, ask for a local name */

shutdown:                /* CLEANUP */
  close_expt_graphics();           /* tell EXPTSPPT to release window */
  close_eyelink_connection();      /* disconnect from tracker */
  return 0;
}
Example #10
0
app_main()
{
  int i, j;
  char our_file_name[260] = "TEST";

  if(open_eyelink_connection(0)) return -1;    // abort if we can't open link
  set_offline_mode();                          
  flush_getkey_queue();                        // initialize getkey() system
  is_eyelink2 = (2 == eyelink_get_tracker_version(NULL) );

  get_display_information(&dispinfo);          // get window size, characteristics
      
     // NOTE: Camera display does not support 16-color modes
     // NOTE: Picture display examples don't work well with 256-color modes
     //       However, all other sample programs should work well.
  if(dispinfo.palsize==16)      // 16-color modes not functional
    {
      alert_printf("This program cannot use 16-color displays");
      goto shutdown;
    }
  if(dispinfo.refresh < 40)  // wait_for_refresh doesn't work!
    {
      alert_printf("No refresh synchroniztion available!");
    }
  if(dispinfo.palsize)     // 256-color modes: palettes not supported by this example
    {
      alert_printf("This program is not optimized for 256-color displays");
    }



  //SEAN  -display window
  if(make_full_screen_window(application_instance)) goto shutdown;  // create the window
  if(init_expt_graphics(full_screen_window, NULL)) goto shutdown;   // register window with EXPTSPPT

  i = SCRWIDTH/60;        // select best size for calibration target
  j = SCRWIDTH/300;       // and focal spot in target
  if(j < 2) j = 2;
  set_target_size(i, j);  // tell DLL the size of target features

  target_foreground_color = RGB(0,0,0);    // color of calibration target
  target_background_color = RGB(128,128,128);       // background for calibration and drift correction
  set_calibration_colors(target_foreground_color, target_background_color); // tell EXPTSPPT the colors

  set_cal_sounds("", "", "");
  set_dcorr_sounds("", "off", "off");
                                     // draw a title screen
  
  // SEAN
  clear_full_screen_window(target_background_color);    // clear screen

  get_new_font("Times Roman", SCRHEIGHT/32, 1);         // select a font
                                                        // Draw text
  graphic_printf(target_foreground_color, target_background_color, 1, SCRWIDTH/2, 1*SCRHEIGHT/30, 
                 "EyeLink Demonstration Experiment: Sample Code");
  graphic_printf(target_foreground_color, target_background_color, 1, SCRWIDTH/2, 2*SCRHEIGHT/30,
                 "Included with the Experiment Programming Kit for Windows");
  graphic_printf(target_foreground_color, target_background_color, 1, SCRWIDTH/2, 3*SCRHEIGHT/30, 
                 "All code is Copyright (c) 1997-2002 SR Research Ltd.");
  graphic_printf(target_foreground_color, target_background_color, 0, SCRWIDTH/5, 4*SCRHEIGHT/30, 
                 "Source code may be used as template for your experiments.");




//SEAN - file i/o
  i = edit_dialog(full_screen_window, "Create EDF File",            // Get the EDF file name
                 "Enter Tracker EDF file name:", our_file_name, 8);

  if(i==-1) goto shutdown;          // ALT-F4: terminate
  if(i==1)  our_file_name[0] = 0;   // Cancelled: No file name
  
  if(our_file_name[0])    // If file name set, open it
    {           
      if(!strstr(our_file_name, ".")) strcat(our_file_name, ".EDF");  // add extension
      i = open_data_file(our_file_name);                              // open file
      if(i!=0)                                                        // check for error
        {
          alert_printf("Cannot create EDF file '%s'", our_file_name);
          goto shutdown;
        }                                                              // add title to preamble
      eyecmd_printf("add_file_preamble_text 'RECORDED BY %s' ", program_name);
    }
                                      // Now configure tracker for display resolution
  eyecmd_printf("screen_pixel_coords = %ld %ld %ld %ld",    // Set display resolution   
                 dispinfo.left, dispinfo.top, dispinfo.right, dispinfo.bottom);
  eyecmd_printf("calibration_type = HV9");                  // Setup calibration type
  eyemsg_printf("DISPLAY_COORDS %ld %ld %ld %ld",           // Add resolution to EDF file
                 dispinfo.left, dispinfo.top, dispinfo.right, dispinfo.bottom);
  if(dispinfo.refresh>40)
    eyemsg_printf("FRAMERATE %1.2f Hz.", dispinfo.refresh);




		// SET UP TRACKER CONFIGURATION 
		      // set parser saccade thresholds (conservative settings)
  if(is_eyelink2)
    {
      eyecmd_printf("select_parser_configuration 0");  // 0 = standard sensitivity
    }
  else
    {
      eyecmd_printf("saccade_velocity_threshold = 35");
      eyecmd_printf("saccade_acceleration_threshold = 9500");
    }
		      // set EDF file contents 
  eyecmd_printf("file_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,MESSAGE,BUTTON");
  eyecmd_printf("file_sample_data  = LEFT,RIGHT,GAZE,AREA,GAZERES,STATUS");
		      // set link data (used for gaze cursor) 
  eyecmd_printf("link_event_filter = LEFT,RIGHT,FIXATION,SACCADE,BLINK,BUTTON");
  eyecmd_printf("link_sample_data  = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS");
                      // Program button #5 for use in drift correction
  eyecmd_printf("button_function 5 'accept_target_fixation'");

  if(!eyelink_is_connected() || break_pressed()) goto end_expt;  // make sure we're still alive


	
       // RUN THE EXPERIMENTAL TRIALS (code depends on type of experiment)
                // Calling run_trials() performs a calibration followed by trials
                // This is equivalent to one block of an experiment 
                // It will return ABORT_EXPT if the program should exit

  i = run_trials();
  

end_expt:                // END: close, transfer EDF file
  set_offline_mode();               // set offline mode so we can transfer file
  pump_delay(500);                  // delay so tracker is ready
  eyecmd_printf("close_data_file"); // close data file

  if(break_pressed()) goto shutdown;          // don't get file if we aborted experiment
  if(our_file_name[0])                        // make sure we created a file
    receive_data_file(our_file_name, "", 0);  // transfer the file, ask for a local name

shutdown:                // CLEANUP
  close_expt_graphics();           // tell EXPTSPPT to release window
  close_eyelink_connection();      // disconnect from tracker
  close_full_screen_window();
  return 0;
}
Example #11
0
// ######################################################################
void EyeTrackerEyeLink::start1()
{
#ifndef HAVE_EYELINK
  LFATAL("Proprietary EyeLink developer API not installed");
#else
  // get the link to the eye-tracker going:
  if (open_eyelink_connection(0))
    LFATAL("Cannot open link to EyeLink tracker - make sure your "
           "hostname resolves to 100.1.1.2 (check /etc/hosts)");

  // Basic initializations:
  set_offline_mode();
  flush_getkey_queue();/* initialize getkey() system */

  // Open EyeLink version of SDL
  openSDL();

  // set the display characteristics: 
  DISPLAYINFO di; // defined in eyelink/core_expt.h
  di.width = itsDims.getVal().w(); di.height = itsDims.getVal().h();
  di.left = 0; di.top = 0; di.right = di.width-1; di.bottom = di.height-1;
  di.bits = 24; di.palsize = 0; di.pages = 0; di.refresh = 60.0F;
  di.winnt = 0;

  set_calibration_colors(&target_foreground_color, &target_background_color);

	// open EDF file if set:
  if (itsEDFfname.getVal().empty() == false)
    {
      if (open_data_file((char *)(itsEDFfname.getVal().c_str())) != 0)
        LFATAL("Cannot open EDF file '%s'", itsEDFfname.getVal().c_str());

      eyecmd_printf(const_cast<char*>("add_file_preamble_text 'RECORDED BY iLab code' "));
    }

  // Add resolution to EDF file:
  eyemsg_printf(const_cast<char*>("DISPLAY_COORDS %ld %ld %ld %ld"),
                di.left, di.top, di.right, di.bottom);

  /* SET UP TRACKER CONFIGURATION */
  /* set parser saccade thresholds (conservative settings) */
  /* 0 = standard sensitivity */
  eyecmd_printf(const_cast<char*>("select_parser_configuration 0"));

  // set EDF file contents:
  eyecmd_printf(const_cast<char*>("file_event_filter = LEFT,RIGHT,FIXATION,SACCADE,"
                                  "BLINK,MESSAGE,BUTTON"));
  eyecmd_printf(const_cast<char*>("file_sample_data = LEFT,RIGHT,GAZE,AREA,GAZERES,STATUS"));

  // set link data (used for gaze cursor):
  eyecmd_printf(const_cast<char*>("link_event_filter = LEFT,RIGHT,FIXATION,FIXUPDATE,SACCADE,BLINK,BUTTON"));
  eyecmd_printf(const_cast<char*>("link_sample_data = LEFT,RIGHT,GAZE,GAZERES,AREA,STATUS"));

  // Program button #5 for use in drift correction:
  eyecmd_printf(const_cast<char*>("button_function 5 'accept_target_fixation'"));
  
	// setup eyelink filtering: default is "1 2"
	eyecmd_printf(const_cast<char*>("heuristic_filter = 1 2"));
	eyelink_wait_for_mode_ready(500);

  // make sure we're still alive:
  if (!eyelink_is_connected() || break_pressed())
    LFATAL("Connection to EyeLink broken or aborted");

  /* TRIAL_VAR_LABELS message is recorded for EyeLink Data Viewer analysis
     It specifies the list of trial variables for the trial
     This should be written once only and put before the recording of
     individual trials */
  eyemsg_printf(const_cast<char*>("TRIAL_VAR_LABELS CONDITION"));

  // Configure EyeLink to send fixation updates every 50 msec:
  //eyecmd_printf("link_event_filter = LEFT,RIGHT,FIXUPDATE");
  //eyecmd_printf("fixation_update_interval = 50");
  //eyecmd_printf("fixation_update_accumulate = 50");

  EyeTracker::start1();
#endif
}