Grrr. My attempt to commit got aborted, and the commit message was lost.

Now I've lost track of what I said I'd done.  Something like:

 * Fixed some issues with multiple wheels.
 * Noted in comments some issues about other-than-3-real-buttons.
 * Fixed formatting to fit 80 columns.
 * Removed some BCPL/C++ style comments (//) that are not legal, and
   which, if memory servers, are not even strictly legal when disabled
   by preprocessor directives.  E.g.,

   #if 0
     not-syntactically-valid-C
   #endif

   ...is not legal.  Though most cpp's will discard the bracketed material
   completely before the main C compiler pass has a chance to analyze the
   syntax.  (MSVC++ and GCC both don't seem to mind the BCPL style comments
   in plain C, but let's keep the sources clean, eh?)
 * Fixed a problem that would have caused freeglut to report doubled
   wheel events under XFree86.

Not tested other than compiling.  Personally, I think that the interface
is inherently broken at this point unless you are willing to get user-
configuration.  (Which would then solve the complaint that Steve had
about computing the tick-size on behalf of applications.)  I.e., there
is NO WAY to know if we have the right buttons to start wheels at, or
if there are any buttons after the first wheel(s), etc.  We just have to
guess---and if we are wrong, we can get varying degrees of brokeness.


git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@267 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
rkrolib 2003-10-30 03:08:16 +00:00
parent 2682a53352
commit c2f23f0bb2

View File

@ -811,19 +811,15 @@ void FGAPIENTRY glutMainLoopEvent( void )
}
/*
* Check if there is a mouse or mouse wheel callback hooked to the window
* Check if there is a mouse or mouse wheel callback hooked to the
* window
*/
if ( ( window->Callbacks.Mouse == NULL ) && ( window->Callbacks.MouseWheel == NULL ) )
if ( ( window->Callbacks.Mouse == NULL ) &&
( window->Callbacks.MouseWheel == NULL ) )
break;
/*
* Set the current window
*/
fgSetWindow ( window );
/*
* Remember the current modifiers state
*/
modifiers = 0;
if (event.xbutton.state & (ShiftMask|LockMask))
modifiers |= GLUT_ACTIVE_SHIFT;
@ -835,6 +831,8 @@ void FGAPIENTRY glutMainLoopEvent( void )
/*
* Finally execute the mouse or mouse wheel callback
*
* XXX Use a symbolic constant, *not* "4"!
*/
if ( button < 4 )
{
@ -847,17 +845,27 @@ void FGAPIENTRY glutMainLoopEvent( void )
}
else
{
if ( window->Callbacks.MouseWheel != NULL )
if ( window->Callbacks.MouseWheel )
{
int wheel_number = button / 2 - 2 ; /* Map 4 and 5 to wheel zero */
int direction = 9 - button * 2 ; /* Map 4 to +1 and 5 to -1 */
/*
* Map 4 and 5 to wheel zero; EVEN to +1, ODD to -1
* " 6 and 7 " " one; ...
*
* XXX This *should* be behind some variables/macros,
* XXX since the order and numbering isn't certain
* XXX See XFree86 configuration docs (even back in the
* XXX 3.x days, and especially with 4.x).
*/
int wheel_number = (button - 4) / 2;
int direction = (button & 1)*2 - 1;
fgStructure.Window->Callbacks.MouseWheel(
wheel_number,
direction,
event.xbutton.x,
event.xbutton.y
);
if( ButtonPress )
fgStructure.Window->Callbacks.MouseWheel(
wheel_number,
direction,
event.xbutton.x,
event.xbutton.y
);
}
else
{
@ -1446,25 +1454,34 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
}
break;
case 0x020a : /* Should be WM_MOUSEWHEEL but my compiler doesn't recognize it */
case 0x020a:
/* Should be WM_MOUSEWHEEL but my compiler doesn't recognize it */
{
int wheel_number = LOWORD ( lParam ) ; /* THIS IS SPECULATIVE -- John Fay, 10/2/03 */
int direction = HIWORD ( lParam ) / 120 ; /* Should be WHEEL_DELTA instead of 120 */
int wheel_number = LOWORD ( lParam ) ;
/* THIS IS SPECULATIVE -- John Fay, 10/2/03 */
int direction = HIWORD ( lParam ) / 120 ;
/* Should be WHEEL_DELTA instead of 120 */
/*
* The mouse cursor has moved. Remember the new mouse cursor's position
*/
// window->State.MouseX = LOWORD( lParam ); // Need to adjust by window position,
// window->State.MouseY = HIWORD( lParam ); // change "lParam" to other parameter
/* window->State.MouseX = LOWORD( lParam ); */
/* Need to adjust by window position, */
/* window->State.MouseY = HIWORD( lParam ); */
/* change "lParam" to other parameter */
if ( ( window->Callbacks.MouseWheel == NULL ) && ( window->Callbacks.Mouse == NULL ) )
if ( ( window->Callbacks.MouseWheel == NULL ) &&
( window->Callbacks.Mouse == NULL ) )
break;
fgSetWindow ( window );
fgStructure.Window->State.Modifiers =
( ( (GetKeyState( VK_LSHIFT ) < 0 ) || ( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
( ( (GetKeyState( VK_LCONTROL ) < 0 ) || ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
( ( (GetKeyState( VK_LSHIFT ) < 0 ) ||
( GetKeyState( VK_RSHIFT ) < 0 )) ? GLUT_ACTIVE_SHIFT : 0 ) |
( ( (GetKeyState( VK_LCONTROL ) < 0 ) ||
( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
( ( (GetKeyState( VK_LMENU ) < 0 ) ||
( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
if ( window->Callbacks.MouseWheel )
window->Callbacks.MouseWheel(
@ -1473,10 +1490,20 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
window->State.MouseX,
window->State.MouseY
) ;
else // No mouse wheel, call the mouse button callback twice
else /* No mouse wheel, call the mouse button callback twice */
{
window->Callbacks.Mouse ( ( direction > 0 ) ? 4 : 5, GLUT_DOWN, window->State.MouseX, window->State.MouseY ) ;
window->Callbacks.Mouse ( ( direction > 0 ) ? 4 : 5, GLUT_UP, window->State.MouseX, window->State.MouseY ) ;
int button = wheel_number * 2 + 4;
/*
* XXX The above assumes that you have no more than 3 mouse
* XXX buttons. Sorry.
*/
button += (1 + direction)/2;
window->Callbacks.Mouse ( button, GLUT_DOWN,
window->State.MouseX,
window->State.MouseY ) ;
window->Callbacks.Mouse ( button, GLUT_UP,
window->State.MouseX,
window->State.MouseY ) ;
}
fgStructure.Window->State.Modifiers = 0xffffffff;