No input working at all with SDL_SetRelativeMouseMode

Hey,

we are using SDL2 in our project for input only. Now, when I do not use SDL_SetRelativeMouseMode, the input works fine, but does not capture the mouse, which is very annoying for debugging in windowed mode.

So I tried setting SDL_SetRelativeMouseMode to true.
But that only leads to no input being captured at all, not even keyboard events any more! SDL_PollEvent simply never triggers in that case.

Here is how SDL is initialized:

Code:
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER);
Ogre::String error = SDL_GetError();
if (error != “”)
{
std::cout << "SDL_Init: " << error << std::endl;
error = “”;
}
SDL_SysWMinfo sysInfo;
SDL_VERSION(&sysInfo.version);
unsigned long hWnd=0;
window->getCustomAttribute(“WINDOW”, &hWnd);
SDL_Window* sdlWin = SDL_CreateWindowFrom((void*) hWnd); // The window is created by our graphics engine (Ogre)
error = SDL_GetError();
if (error != “”)
{
std::cout << "SDL_CreateWindowFrom: " << error << std::endl;
error = “”;
}
if(SDL_GetWindowWMInfo(sdlWin, &sysInfo) <= 0)
{
error = SDL_GetError();
if (error != “”)
{
std::cout << "SDL_GetWindowWMInfo: " << error << std::endl;
error = “”;
}
return false;
}
int result = SDL_SetRelativeMouseMode(SDL_TRUE);
error = SDL_GetError();
if (error != “”)
{
std::cout << "SDL_SetRelativeMouseMode: " << error << " " << result << std::endl;
error = “”;
}

I do get two errors here, one after SDL_CreateWindowFrom: "This operation is not supprted."
Not exactly a super helpful hint, if you ask me. “This doesn’t work”. Okaaay :wink:
Though I do not know if this is an actual problem, as input works just fine when not using relative mouse mode. And when I do not use SDL_CreateWindowFrom, no input works at all, so I think it is correct to use it like this.

Another error is reported after SDL_SetRelativeMouseMode. It is actually the same, “This operation is not supprted.”. I suspect it is just the last error repeated, and not really a new one, as the function returns 0 (would return -1 on error). Though I thought SDL_GetError() would flush the error.

I know I could reset the mouse position to the center of the screen each frame, thus simulating a captured mouse, but I would prefer not to.

So, what am I doing wrong here?

Btw. I am currently working on Windows and using MinGW, if that matters.

I forgot to mention (and can’t edit my post???) that SDL_CreateWindowFrom returns a window, so it definitely does work. No idea what operation SDL thinks is not supported here.

Try SDL init everything for testingOn Feb 18, 2014 12:24 AM, “TheSHEEEP” wrote:

I forgot to mention (and can’t edit my post???) that
SDL_CreateWindowFrom returns a window, so it definitely does work. No idea
what operation SDL thinks is not supported here.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

That will probably not work as I have compiled SDL with only video, loadso, events, haptic and joystick. I wanted to have it as small as possible as we really only use it for input.
Do I probably need something else built?

I said try and testingOn Feb 18, 2014 3:33 AM, “TheSHEEEP” wrote:

That will probably not work as I have compiled SDL with only video,
loadso, events, haptic and joystick. I wanted to have it as small as
possible as we really only use it for input.
Do I probably need something else built?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Ohh. Try the entire SDL for testing with init everything then. Its no
biggie if that corrects. Right? I’m thinking yes something missing and
testing should always be with known good where you can. If your lib
propagation is flawed this should help show also.On Feb 18, 2014 3:33 AM, “TheSHEEEP” wrote:

That will probably not work as I have compiled SDL with only video,
loadso, events, haptic and joystick. I wanted to have it as small as
possible as we really only use it for input.
Do I probably need something else built?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Allright, I will rebuild SDL with everything enabled (or at least the default ones) and see if that changes something.