src/SDL12_compat.c
changeset 88 60cb434b52b8
parent 87 9dc1cdfa0fa9
child 89 5db689f27ecd
     1.1 --- a/src/SDL12_compat.c	Thu Feb 28 09:43:17 2019 -0500
     1.2 +++ b/src/SDL12_compat.c	Fri Mar 01 01:08:43 2019 -0500
     1.3 @@ -2951,11 +2951,34 @@
     1.4      SDL12_GRAB_ON = 1
     1.5  } SDL12_GrabMode;
     1.6  
     1.7 +static void
     1.8 +UpdateRelativeMouseMode(void)
     1.9 +{
    1.10 +    // in SDL 1.2, hiding+grabbing the cursor was like SDL2's relative mouse mode.
    1.11 +    if (VideoWindow20) {
    1.12 +        const int visible = SDL20_ShowCursor(-1);
    1.13 +        const SDL_bool grabbed = SDL20_GetWindowGrab(VideoWindow20);
    1.14 +        SDL20_SetRelativeMouseMode((!visible && grabbed) ? SDL_TRUE : SDL_FALSE);
    1.15 +    }
    1.16 +}
    1.17 +
    1.18 +DECLSPEC int SDLCALL
    1.19 +SDL_ShowCursor(int toggle)
    1.20 +{
    1.21 +    const int retval = SDL20_ShowCursor(toggle);
    1.22 +    if (toggle >= 0) {
    1.23 +        UpdateRelativeMouseMode();
    1.24 +    }
    1.25 +    return retval;
    1.26 +}
    1.27 +
    1.28 +
    1.29  DECLSPEC SDL12_GrabMode SDLCALL
    1.30  SDL_WM_GrabInput(SDL12_GrabMode mode)
    1.31  {
    1.32      if (mode != SDL12_GRAB_QUERY) {
    1.33          SDL20_SetWindowGrab(VideoWindow20, (mode == SDL12_GRAB_ON));
    1.34 +        UpdateRelativeMouseMode();
    1.35      }
    1.36      return SDL20_GetWindowGrab(VideoWindow20) ? SDL12_GRAB_ON : SDL12_GRAB_OFF;
    1.37  }