Reputation: 150
I would like to know how do I get the following actions using LWJGL's Mouse class:
Thanks for the help!
Upvotes: 3
Views: 4017
Reputation: 962
For LWJGL 3 you may do this
import org.lwjgl.glfw.GLFW;
import org.lwjgl.glfw.GLFWScrollCallback;
// ...
float mouseWheelVelocity = 0;
GLFW.glfwSetScrollCallback(windowId, new GLFWScrollCallback() {
@Override public void invoke (long win, double dx, double dy) {
System.out.println(dy);
mouseWheelVelocity = (float) dy;
}
});
Replace windowId
variable with yours. Make sure it's initialized by that time. Then you can save dy
argument which shows change of the mouse wheel rotation (+1 and -1).
Upvotes: 5
Reputation: 837
As specified on the lwjgl javadoc, try calling
Mouse.getDWheel(); // Scroll amount
Mouse.isButtonDown(2); // Scroll wheel pressed?
Upvotes: 3