SDL2 Mouse Capture

Using SDL2 and Vulkan on Ubuntu 20.04 LTS, I'm trying to hide and capture mouse movement in order to implement mouse movement found commonly in FPS games.

Currently, I initialize SDL using the following functions:

SDL_Init(SDL_INIT_EVERYTHING);

if (SDL_SetRelativeMouseMode(SDL_TRUE) != 0)
{
    // Deal with error...
}

Using SDL_PollEvent() and SDL_MouseMotionEvent, I am able to mimic the desired camera movement. Although I haven't tested anything on fullscreen mode, in windowed mode, the mouse is hidden and continues to give input even when it passes the borders of the window just like how I want it to be.

However, when I left click with the mouse once and move the mouse afterwards, the mouse appears when it passes the window's borders (yet still gives input).

How can I prevent this from happening? Is there another function other than SDL_SetRelativeMouseMode() I could use? Were there any functions I forgot to call during initialization?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum