1

I'm trying to use GLUT (freeglut) in my OpenGL application, and I need to register some callbacks for mouse wheel events. I managed to dig out a fairly undocumented function:

api documentation

But the man page and the API entry for this function both state the same thing:

Note: Due to lack of information about the mouse, it is impossible to implement this correctly on X at this time. Use of this function limits the portability of your application. (This feature does work on X, just not reliably.) You are encouraged to use the standard, reliable mouse-button reporting, rather than wheel events.

Fair enough, but how do I use this standard, reliable mouse-reporting? And how do I know which is the standard? Do I just use glutMouseFunc() and use button values like 4 and 5 for the scroll up and down values respectively, say if 1, 2 and 3 are the left, middle and right buttons? Is this the reliable method?

Bonus question: it seems the `xev' tool is reporting different values for my buttons. My mouse buttons are numbered from 1 to 5 with xev, but glut is reporting buttons from 0 to 4, i.e. an off-by-one. Is this common?

1 Answer 1

0

I thought I might revisit my own question since it has been a long time since I asked it without any replies.

Reading yet more thoroughly at aforementioned documentation, from what I understand it seems that my guess was indeed true.

My guess:

Do I just use glutMouseFunc() and use button values like 4 and 5 for the scroll up and down values respectively [...]?

I haven't tested it yet, but from the following quote from the documentation, I gather that this is indeed what they meant.

If you do not register a wheel callback, wheel events will be reported as mouse buttons.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.