Jump to content
  • Advertisement
cozzie

Recentering the mouse, fixed timestep

This topic is 424 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

I'm struggling with an issue in the way I handle mouse input.
This is my current setup/ approach:

- I have a fixed timestep for updating game logics/ physics (i.e. 1/60th of a second
- rendering happens as fast as the conditions allow it
- I have an input system that takes RAW axis's on the input side, and provides logical ranges on the output side
(i.e. mouse axis X/Y in, and camera X/Y output)
- for the camera 'look'/ rotation, I use relative coordinates. Meaning that when the mouse moved 3 by 3 pixels the last frame, the camera is rotated using that as input
- after the game logics read/ retrieved the current logical range, it sets the raw axis input to 0, 0 (because it's relative) (*** A ***)

Now, the problem:
- depending on debug/ release or framerate, the number of times WM_MOUSEMOVE is called, differs
- in the handling of WM_MOUSEMOVE I update the RAW AXIS's values to the inputsystem
-- and I reset the mouse cursor

The symptom is that the mouselook/ rotation is slower when framerates are higher.
I also found out why, this is because the offsets/ relative movement of the mouse is very small, because after each WM_MOUSEMOVE, the cursor is reset (to center of the screen)

I thought of different solutions, for example resetting the mouse cursor at the point marked as ***A*** above. But then the game logics would know and act on something called a mouse. This is exactly what I want to prevent with the input handler. Because it could also be joypad or keyboard or whatsoever. Another solution could be that I add a GetRAWAxisValue function to the inputhandler, and check if this is 0, and if it isn't, then reset the mouse cursor (in WM_MOUSEMOVE handling).

I'm wondering if someone could point me in the right direction or suggest another solution.
Where possible I want to stay with relative, so no absolute mouse positions (because of going out of screen/window bounds etc., + the camera input system currently also expects 'changes', no absolute ranges).

Any input is appreciated.

Share this post


Link to post
Share on other sites
Advertisement

You need to adjust your delta mouse range by the delta time between the new input and the reset position.

Share this post


Link to post
Share on other sites
1 hour ago, cozzie said:

I thought of different solutions, for example resetting the mouse cursor at the point marked as ***A*** above. But then the game logics would know and act on something called a mouse.

You don't have to reset it inside your game logic do you? You know which frames will update game logic, reset in those frames after the game logic update.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!