LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Andrew_3ds on December 18, 2014, 01:54:14

Title: How to get mouse DWheel in GLFW
Post by: Andrew_3ds on December 18, 2014, 01:54:14
I'm still trying to get used to the new input system in GLFW. I know how to get key input by using glfwGetKey(), but there ins't a "glfwGetScroll()" or something, and I don't like using window callback adapters because they are slow. How can I get the mouse wheel movement without the adapter?
Title: Re: How to get mouse DWheel in GLFW
Post by: Zeroni on December 18, 2014, 02:16:41
I do not know where you got the notion that the window callback adapters are slow, because it is not true (I only get a few microseconds delay). I use a window class with all the all callback adapters, and I haven't noticed any notable input lagg, it may be just your machine. I do not know a way of get the scroll without the callback adapters in LWJGL 3.0.

I would message user: spasi
He may know a way to get the scroll outside of the Graphics Library Framework.
Title: Re: How to get mouse DWheel in GLFW
Post by: SHC on December 18, 2014, 05:40:05
See the glfwSetScrollCallback() (http://www.glfw.org/docs/latest/group__input.html#ga6228cdf94d28fbd3a9a1fbb0e5922a8a) function. In Java, you can do the following.


GLFW.glfwSetScrollCallback(window, scrollCallback = GLFWScrollCallback((win, dx, dy) ->
{
    // Store dx and dy here (both are double values)
    Mouse.dx = dx;
    Mouse.dy = dy;
});

Just make sure that you call scrollCallback.release() before destroying the window. Hope this helps.
Title: Re: How to get mouse DWheel in GLFW
Post by: quew8 on December 18, 2014, 10:41:37
GLFW isn't built around the concept of a game loop. It can be used for any application, so it really makes no sense to have a getScroll() function - what would it return? But as @SHC says, it is trivial code to replicate the LWJGL2 functionality, and as @Zeroni says, it is not at all slow. Even if it was I don't know what you would be comparing it to.