I use a mix of java's mouse logic and glfw. Hopefully you can see what's going on.
class
{
int WIDTH = 1200;
int HEIGHT = 800;
int mouseCenterX = WIDTH / 2;
int mouseCenterY = HEIGHT / 2;
gameLoop()
{
DoubleBuffer mouseX = BufferUtils.createDoubleBuffer(1);
DoubleBuffer mouseY = BufferUtils.createDoubleBuffer(1);
int newMouseX = -1;
int newMouseY = -1;
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
glfwGetCursorPos(window, mouseX, mouseY);
mouseX.rewind();
mouseY.rewind();
newMouseX = (int) mouseX.get(0);
newMouseY = (int) mouseY.get(0);
if (newMouseX < mouseCenterX - 10) {
p.faceLeft(); // tell the player to turn left
newMouseX = mouseCenterX;
}
if (newMouseX > mouseCenterX + 10) {
p.faceRight(); // tell the player to turn right
newMouseX = mouseCenterX;
}
if (newMouseY < mouseCenterY - 10) {
newMouseY = mouseCenterY; // up and down but I don't use these yet
}
if (newMouseY > mouseCenterY + 10) {
newMouseY = mouseCenterY;
}
glfwSetCursorPos(window, mouseCenterX, mouseCenterY);
}
}
// to put the mouse back on the screen glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
// my MVP matrix uses the player's left/right rotation to determine the view, so move the player and you move the camera