From 869780207da03240a3b72fd4fff85efd563fa131 Mon Sep 17 00:00:00 2001 From: rkrolib Date: Fri, 7 Nov 2003 05:43:34 +0000 Subject: [PATCH] Minor corrections to the UNIX_X11 mouse-wheel support. In part this reflects that {button} is already shifted to the GLUT numbering, and hence should be counted as 3&4, 5&6, etc. The other change was simply to clarify the computation of {direction}. The original code did some clever arithmetic. The new code is more straightforward, even if it requires more lines to express. git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@306 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/src/freeglut_main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/freeglut/freeglut/src/freeglut_main.c b/freeglut/freeglut/src/freeglut_main.c index 6c569d3..fd0abbc 100644 --- a/freeglut/freeglut/src/freeglut_main.c +++ b/freeglut/freeglut/src/freeglut_main.c @@ -801,7 +801,7 @@ void FGAPIENTRY glutMainLoopEvent( void ) * * XXX Use a symbolic constant, *not* "4"! */ - if( ( button < 4 ) || ( ! FETCH_WCB( *window, MouseWheel ) ) ) + if( ( button < 3 ) || ( ! FETCH_WCB( *window, MouseWheel ) ) ) { INVOKE_WCB( *window, Mouse, ( button, pressed ? GLUT_DOWN : GLUT_UP, @@ -819,9 +819,14 @@ void FGAPIENTRY glutMainLoopEvent( void ) * 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). + * + * XXX Note that {button} has already been decremeted + * XXX in mapping from X button numbering to GLUT. */ - int wheel_number = (button - 4) / 2; - int direction = (button & 1)*2 - 1; + int wheel_number = (button - 3) / 2; + int direction = -1; + if( button % 2 ) + direction = 1; if( pressed ) INVOKE_WCB( *window, MouseWheel, ( wheel_number,