glfw/glfw

Did a scroll event come from a wheel or from a trackpad?

cblc opened this issue · 1 comments

cblc commented

I'm applying #2419 internally for supporting Trackpad gestures in my apps, but, in that very same topic, I found that most 3D apps really need to know if a scroll gesture comes from a true scroll wheel, or from a trackpad (or a mouse that behaves like a trackpad, like the Magic Mouse and the Mighty Mouse). And I say that they really need to know this, because the usual behaviour in 3D apps (at least in all apps I know) is that the mouse wheel is used for zooming, while the Trackpad, the scrolling-pad in the Magic Mouse, and the ball in the Mighty Mouse are used for panning.

It would be absurd that a mouse wheel is used for panning vertically a 3D view (in a 3D camera, you want to pan in both X and Y, so if you have a mouse wheel, you want it for zooming rather than just Y panning), and it would also be absurd that a scrolling event from a Trackpad is used for zooming (because the Trackpad has the zoom gesture for that).

So, I'm doing some modifications to GLFW (after applying #2419), so that there's a new callback for panning, while the existing callback for scrolling is used when the event comes from a real mouse wheel.

BTW, it's not very clear how to check if a scrolling event comes from a wheel or from a trackpad/magic_mouse/mighty_mouse. If you google for it, you'll find that the way of checking looks a bit hacky.

I prefer not to maintain my own fork, so I'm opening this issue in order to see if you find this interesting and if you agree with me that 3D apps need to know this.

cblc commented

Rather than having separate callbacks for trackpad-like and for scrollwheel events, I believe it's better to put everything in the same callback, but with a more detailed interface. An interface that would work perfectly for me is as follows:

detailedscroll_callback(GLFWwindow *window, double xoffset, double yoffset, int iswheel, int isinverted)

where iswheel would be true if the event came from a scrollwheel, or false if it came from a trackpad or trackpad-like device, and isinverted is true if the user enabled the "natural scroll direction" Mac user preference, or false otherwise.

This callback provides everything that both my 2D and 3D apps would need for properly responding to scroll/panning events.

The existing scroll callback could be kept for backwards compatibility, and provide this one with its more detailed interface for applications that need it.