Dee,
The patch is very small -- three lines added to fghCheckJoystickPolls.
Clive.

/*
 * Check all windows for joystick polling
 */
static void fghCheckJoystickPolls( void )
{
    SFG_Enumerator enumerator;

+ if(fgState.NumActiveJoysticks > 0)
+ {
enumerator.found = GL_FALSE;
enumerator.data  =  NULL;

fgEnumWindows( fghcbCheckJoystickPolls, &enumerator );
+ }
}

> Date: Tue, 28 Feb 2012 12:03:46 +0800
> From: dcnieho@gmail.com
> To: freeglut-developer@lists.sourceforge.net
> Subject: Re: [Freeglut-developer] profiling 2.8.0
>
> Hi Clive,
>
> Thanks for having a look! Yes indeed, I see that the number of active
> joysticks is counted, but nothing is ever done with that variable (in
> the windows code at least...). So thats a bug. Could you send a patch?
> I'll adapt it for the current trunk and send it to John.
>
> Thanks!
> Dee
>
> On Tue, Feb 28, 2012 at 10:13, Clive McCarthy <clivemccarthy@msn.com> wrote:
> > Dee,
> > I worked on the issue this afternoon. Your counting of active joysticks
> > works fine. It is not even necessary to setup a NULL callback. What makes
> > all the difference is to check if(fgState.NumActiveJoysticks > 0) within
> > fghCheckJoystickPolls -- if it is zero or negative then then the call can
> > just return immediately to glutMainLoopEvent.
> >
> >   %   cumulative   self              self     total
> >  time   seconds   seconds    calls   s/call   s/call  name
> >  16.77      8.38     8.38 334193326     0.00     0.00  glutMainLoopEvent
> >  15.17     15.96     7.58        1      7.58    42.28  glutMainLoop
> >  10.53     21.23     5.26 334193325     0.00     0.00  glut_OpenGL_idle
> >   8.44     25.45     4.22  6305849      0.00     0.00  convolve_kernel
> >   5.76     28.32     2.88 334267887     0.00     0.00  fgElapsedTime
> >   5.46     31.05     2.73 334193335     0.00     0.00  fgEnumWindows
> >   5.08     33.59     2.54 334193325     0.00     0.00  fgEnumSubWindows
> >   4.90     36.05     2.45  4879103      0.00     0.00  convolve_kernel_safe
> >   4.64     38.37     2.32 334267888     0.00     0.00  fgSystemTime
> >   4.38     40.55     2.19 334193325     0.00     0.00  fghcbDisplayWindow
> >   3.60     42.35     1.80       16      0.11     0.11  image_vanishing_point
> >   3.29     44.00     1.65 13975589      0.00     0.00  idle_checks
> >   2.66     45.33     1.33 103991850     0.00     0.00  RGB_painting_value
> >   2.26     46.46     1.13 334193326     0.00     0.00  fgCloseWindows
> >
> > All mention of joystick polling is gone!
> > Clive.
> >
> >> Date: Tue, 28 Feb 2012 07:18:25 +0800
> >> From: dcnieho@gmail.com
> >> To: freeglut-developer@lists.sourceforge.net
> >> Subject: Re: [Freeglut-developer] profiling 2.8.0
> >>
> >> I remember an old discussion touching on this:
> >> http://old.nabble.com/Re%3A-overjoyed-p26766239.html, its commit 863
> >> that is talked about i believe. So this solution is not adequate
> >> Clive?
> >>
> >> Best,
> >> Dee
> >>
> >> On Tue, Feb 28, 2012 at 01:52, Clive McCarthy <clivemccarthy@msn.com>
> >> wrote:
> >> > 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
> >> >
> >> >
> >> >
> >> > ------------------------------------------------------------------------------
> >> > Try before you buy = See our experts in action!
> >> > The most comprehensive online learning library for Microsoft developers
> >> > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> >> > Metro Style Apps, more. Free future releases when you subscribe now!
> >> > http://p.sf.net/sfu/learndevnow-dev2
> >> > _______________________________________________
> >> > Freeglut-developer mailing list
> >> > Freeglut-developer@lists.sourceforge.net
> >> > https://lists.sourceforge.net/lists/listinfo/freeglut-developer
> >> >
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Try before you buy = See our experts in action!
> >> The most comprehensive online learning library for Microsoft developers
> >> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> >> Metro Style Apps, more. Free future releases when you subscribe now!
> >> http://p.sf.net/sfu/learndevnow-dev2
> >> _______________________________________________
> >> Freeglut-developer mailing list
> >> Freeglut-developer@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/freeglut-developer
> >
> >
> > ------------------------------------------------------------------------------
> > Keep Your Developer Skills Current with LearnDevNow!
> > The most comprehensive online learning library for Microsoft developers
> > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> > Metro Style Apps, more. Free future releases when you subscribe now!
> > http://p.sf.net/sfu/learndevnow-d2d
> > _______________________________________________
> > Freeglut-developer mailing list
> > Freeglut-developer@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/freeglut-developer
> >
>
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Freeglut-developer mailing list
> Freeglut-developer@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freeglut-developer