From: Ingo A. <iar...@ya...> - 2012-10-09 21:08:07
|
I attach a patch to read mouse wheel with non-freeglut under linux. Note that in theory, one can read any mapped button on X using glut, including special mouse buttons (I know... the trend is to use just one button ;)... but one could...) However, my proposed solution will not work out of the box with windows glut, and will fail if you, for whatever reasons, have remapped the wheel under X to different button codes. There is a patch for win32 glut available here: http://www.realmtech.net/opengl/glut.php I noticed that my freeglut (2.6.0-1ubuntu3) does not report mousewheel callbacks on linux, so the patch might be considered as standard and have the explicit freeglut dependency removed from the glut mouse driver. Ingo. p.s.: @Daniel: it would be really nice to know which glut version you are using. @Dominik: as X also maps other buttons, the current code could lead to corruption, as we do not check the button index (l.105, #29742) when we write the button value; IMO there should at least be a check/switch-case whatever. On 10/04/2012 10:11 PM, Ingo Assenmacher wrote: > Hi! > > There are some shortcomings on the current implementation as it is in > Vista with regards to the wheel handling. > > a) if you are using freeglut (which is most often default on Linux), you > are fine off, but make sure that you compile the library using the > USE_NATIVE_GLUT=0 preprocessor flag. Check your cmake cache file to see > the value, os normally the cmake scripts make sure to detect whether you > have freeglut or the 'only' the normal glut. > > b) depending on your version of glut (here is where the 'luck' part > starts), it reports mouse wheels as mouse button events. Check if you > can find GLUT_WHEEL_<UP|DOWN> flags in your glut(.h). If that is the > case, the Vista implementation is plainly not working good, as it does > dispatch only the first three buttons and waits for magics to happen to > the scroll wheel state. (In a nutshell: current glut implementations > show the wheel as additional button). > > Here is why you see 0 as a value: > > in case the mouse button callback gets called (which happens if you use > glut and not freeglut and you use the wheel), the mouse driver records > the current state of the mouse. The right file to look at for your case > would be > VistaDeviceDrivers/VistaGlutMouseDriver/VistaGlutMouseDriver.cpp, l. > 92f). This includes the current state of the variables for the wheel and > the wheel state. As they are only changed in the case of freeglut > installed, the state variables do not get updated. Are you sure you see > "(0,0)" only? And not "(-1,0)"? > > > The code, as it is right now can crash, so its good you pointed that > out. It needs to be fixed. It would be very good to know what version of > glut you are using and where we can peek at the source. > |