Hello!
In my engine I am trying to make a nice way to get the polled mouse data.
Currently:
// handle mouse for game engine
GameMouse mouse = GameEngine.mouse_get();
mouse.clear(); // This resets all values modified below to 0. Not exactly needed in this case.
Mouse.poll();
while( Mouse.next() ) {
mouse.mouse_dx = Mouse.getDX();
mouse.mouse_dy = Mouse.getDY();
mouse.mouse_x = Mouse.getX();
mouse.mouse_y = Mouse.getY();
mouse.mouse_wheel = Mouse.getDWheel();
}
Then to access/use the values:
EditorCamera cam = camera_get();
cam.rotate( mouse_get_delta_x() * 0.003f, -mouse_get_delta_y() * 0.003f);
And this works, but I’ve noticed that if I run the game at say 30 fps I can rotate my camera 20-25 times fully. If I set the fps to 300 I can only rotate the camera 2 times.
My first thought was that multiple values were changing when Mouse.poll() was called. So I then tried:
// handle mouse for game engine
GameMouse mouse = GameEngine.mouse_get();
mouse.clear(); // This resets all values modified below to 0.
Mouse.poll();
while( Mouse.next() ) {
mouse.mouse_dx += Mouse.getDX();
mouse.mouse_dy += Mouse.getDY();
mouse.mouse_x += Mouse.getX();
mouse.mouse_y += Mouse.getY();
mouse.mouse_wheel += Mouse.getDWheel();
}
This however doesn’t work either.
Thirdly, I tried multiplying the deltax/y by the games delta time, and this did not solve the issue either.
What do you guys recommend?
Here’s a fun picture: