I have some preliminary profiling results for freeglut 2.8.0 which shows that joystick polling takes place even when there is no joystick callback defined. It seems that there is a recursive examination of all windows that is executed from glutMainLoopEvent. It chews up a reasonable number of cycles before it figures out, in my case, that there is no joystick.

It seems that there should be a check, within fghCheckJoystickPolls, to see if the glutJoystickFunc is defined and immediately return if it is not. 


  %   cumulative   self              self     total           
 time   seconds   seconds    calls   s/call   s/call  name    
 13.38      3.86     3.86 142284132    0.00     0.00  glutMainLoopEvent
 12.10      7.35     3.49        1     3.49    25.10  glutMainLoop
  8.04      9.67     2.32 284602456    0.00     0.00  fgSystemTime
  7.66     11.88     2.21 284568272    0.00     0.00  fgEnumWindows
  6.93     13.88     2.00  2788395     0.00     0.00  convolve_kernel
  6.90     15.87     1.99 284568262    0.00     0.00  fgEnumSubWindows
  6.55     17.76     1.89 142284131    0.00     0.00  glut_OpenGL_idle
  6.07     19.51     1.75 284602455    0.00     0.00  fgElapsedTime
  5.13     20.99     1.48 142284131    0.00     0.00  fgJoystickPollWindow
  4.02     22.15     1.16  2468169     0.00     0.00  convolve_kernel_safe
  3.81     23.25     1.10 142284131    0.00     0.00  fghcbDisplayWindow
  3.64     24.30     1.05 142284131    0.00     0.00  fghcbCheckJoystickPolls
  3.22     25.23     0.93        8     0.12     0.12  image_vanishing_point
  2.51     25.95     0.72  6669255     0.00     0.00  idle_checks
  2.08     26.55     0.60 48529530     0.00     0.00  RGB_painting_value
  2.01     27.14     0.58 142284132    0.00     0.00  fgCloseWindows
  1.56     27.59     0.45       21     0.02     0.05  compute_image_mean_square_tone_data
  1.01     27.88     0.29   926999     0.00     0.00  RGB2HSV


This is a similar (not identical conditions) profile with line 1489 crudely commented out in glutMainLoopEvent.

  %   cumulative   self              self     total           
 time   seconds   seconds    calls   s/call   s/call  name    
 16.64     12.50    12.50 502633966    0.00     0.00  glutMainLoopEvent
 14.50     23.39    10.89        1    10.89    63.08  glutMainLoop
  9.85     30.79     7.40 502633965    0.00     0.00  glut_OpenGL_idle
  8.58     37.23     6.45  8931480     0.00     0.00  convolve_kernel
  5.49     41.35     4.12 502741543    0.00     0.00  fgSystemTime
  5.30     45.34     3.98 502633965    0.00     0.00  fgEnumSubWindows
  5.29     49.30     3.97 502633975    0.00     0.00  fgEnumWindows
  4.97     53.03     3.73 502633965    0.00     0.00  fghcbDisplayWindow
  4.53     56.44     3.40  8675613     0.00     0.00  convolve_kernel_safe
  3.83     59.31     2.88 20811184     0.00     0.00  idle_checks
  3.79     62.16     2.85 502741542    0.00     0.00  fgElapsedTime
  3.78     65.00     2.84       25     0.11     0.11  image_vanishing_point
  2.69     67.02     2.02 166386960    0.00     0.00  RGB_painting_value
  2.60     68.97     1.95 502633966    0.00     0.00  fgCloseWindows
  2.53     70.87     1.90       72     0.03     0.05  compute_image_mean_square_tone_data
  1.11     71.70     0.83       48     0.02     0.02  compute_image_mean_square_error_data
  1.01     72.46     0.76  2462651     0.00     0.00  RGB2HSV