Was wondering if there is a function in SDL which locks the mouse cursor to the center of a window, while still receiving mouse motion events? I’ve tried using SDL_SetRelativeMouseMode(SDL_TRUE), but that doesn’t seem to achieve it. There is a function in glfw which I’m trying to replace with an SDL equivalent, which does this, called glfwSetCursor. It hides the cursor (when GLFW_CURSOR_DISABLED flag is used), but locks it to the screen center, while still receiving events. Any ideas of a similar function to this in SDL?
[EDIT: seemed to be an issue in my code. Everything now works as intended]
I thought glfwSetCursor() simply set the appearance of the cursor, rather than its position. SDL2 has SDL_SetCursor() to change its appearance and SDL_WarpMouseInWindow() to move it, but they are quite separate. There’s also SDL_ShowCursor() to hide it.
It seems to me that it’s not being centered, because if I mouse the mouse outside the window, I don’t seem to get any motion events when the mouse is moved
Yeah, it sets the appearance, but it also “locks” is to the center, while still receiving motion events when the cursor is moved. I’m basically trying to force the cursor to stay centrally, but still allow mouse events to be registered, even when the cursor leave the window. This way, the mouse will always generate callbacks regardless of window or display extents (as it’s not being constrained inside a window, it’s essentially infinite)