Setting cursor style fights with Windows default

Hey guys,

I’ve got a game I’m integrating SDL2 into with the following setup:

  1. Windows 7. VC10 x64.
  2. I’m using CreateWindowFrom() on an existing non-fullscreen window.
  3. I’m starting the game with SetRelativeMouseMode() set to SDL_FALSE (for the main menu).

Okay, so, with that framework, here’s what’s happening. If I set the cursor using, for example,

Code:
SDL_SetCursor( SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_NO ) );

it will flash to the appropriate cursor as I enter the window then switch back to the default Windows pointer. If I call SetCursor() every frame, I end up with a flickering effect where I get the cursor I want most of the time, but occasionally I’ll get the default mouse or an offset version of the cursor I want.

Now, I don’t really care about changing the look of the cursor for my menus, but what I do care about is that when I turn on RelativeMouseMode, the cursor doesn’t hide, it’s the standard cursor in the middle of the screen.

Thoughts?

I’d say seeing it correctly at all points away from SDL as the culprit.
Seems you have some unwanted recursion…weird. recheck ur brackets and put
in some disc variables is what I’d do.On Feb 18, 2014 12:24 AM, “jessome” wrote:

Hey guys,

I’ve got a game I’m integrating SDL2 into with the following setup:

  1. Windows 7. VC10 x64.
  2. I’m using CreateWindowFrom() on an existing non-fullscreen window.
  3. I’m starting the game with SetRelativeMouseMode() set to SDL_FALSE (for
    the main menu).

Okay, so, with that framework, here’s what’s happening. If I set the
cursor using, for example,
Code: SDL_SetCursor( SDL_CreateSystemCursor( SDL_SYSTEM_CURSOR_NO ) ); it
will flash to the appropriate cursor as I enter the window then switch back
to the default Windows pointer. If I call SetCursor() every frame, I end up
with a flickering effect where I get the cursor I want most of the time,
but occasionally I’ll get the default mouse or an offset version of the
cursor I want.

Now, I don’t really care about changing the look of the cursor for my
menus, but what I do care about is that when I turn on RelativeMouseMode,
the cursor doesn’t hide, it’s the standard cursor in the middle of the
screen.

Thoughts?


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

I switched the responsibility for window creation to SDL and told OGRE ( formerly responsible for window creation ) about SDL’s window using “exernalWindowHandle”. And my issue is now resolved.

The fault here is either in OGRE’s window creation code or SDL’s CreateWindowFrom() code. I haven’t looked to closely at it, but I thought the community could benefit from at least this much.

According to MSDN docs for SetCursor [1]:

“If your application must set the cursor while it is in a window, make sure
the class cursor for the specified window’s class is set to NULL. If the
class cursor is not NULL, the system restores the class cursor each time
the mouse is moved.”

So whoever creates the window (ogre or sdl) needs to specify null for the
class cursor, otherwise SetCursor() will not function as expected.

[1]
http://msdn.microsoft.com/en-us/library/windows/desktop/ms648393(v=vs.85).aspx

2014-02-19 15:20 GMT+01:00 jessome :> I switched the responsibility for window creation to SDL and told OGRE (

formerly responsible for window creation ) about SDL’s window using
"exernalWindowHandle". And my issue is now resolved.

The fault here is either in OGRE’s window creation code or SDL’s
CreateWindowFrom() code. I haven’t looked to closely at it, but I thought
the community could benefit from at least this much.


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

That’s great information. Thank you