With SDL 1.2 I was using SDL_WM_GrabInput to center the (hidden) mouse on screen. This gave me unlimited turning freedom for a first person shooter. SDL2 no longer provides this function but has SDL_SetWindowGrab. This does not seem to be repositioning the mouse to the center of the screen after each loop (event read). I can turn the player around only 1 and a half times before the mouse has hit the edge of the window and will no longer produce xrel values. Is this a bug or is there another function I should be using?
Give SDL_SetRelativeMouseMode()
and SDL_GetRelativeMouseState()
a try.
Alternatively recenter the mouse each frame yourself with SDL_WarpMouseInWindow()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With