Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Is it possible to unlock the mouse in fullscreen mode so that you can use it on a another monitor? I read trough the SDL documentation, but I couldn't find anything related to my problem.

share|improve this question
2  
It's likely you don't want to use "real" fullscreen, but "fake" fullscreen (full size borderless window). See this question on SO and maybe it'll help you: stackoverflow.com/questions/7927974/… –  Tetrad Feb 27 '13 at 22:05
    
I didn't need to do anything special to support this when I did exactly this, yesterday, testing on OSX using SDL version 2.0.2. Had a fullscreen window on one monitor, not set to capture the mouse, and I was able to freely move the mouse back to the other monitor and interact with windows there. What you're seeing might be platform-specific behaviour? (In which case, you should specify what platform you're working on) –  Trevor Powell Apr 10 at 4:36

3 Answers 3

This is for SDL 2, but have you showing the cursor cursor and seeing if it can escape?

function for creating a cursor:

int SDL_ShowCursor(int toggle)    

so it would be like this

SDL_ShowCursor(1);

look more into it here:

http://wiki.libsdl.org/SDL_ShowCursor?highlight=%28%5CbCategoryMouse%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

personally I do not have a second monitor so I cannot help you

share|improve this answer

In SDL 2 there is also SDL_Get/SetWindowGrab which returns/sets whether or not the window is grabbing the mouse. I think this is what you want.
https://wiki.libsdl.org/SDL_SetWindowGrab?highlight=%28%5CbCategoryVideo%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

share|improve this answer

For SDL2 (don't use SDL1 anymore):

// to configure the window
SDL_SetWindowFullscreen(my_window, SDL_WINDOW_FULLSCREEN_DESKTOP);

// to unlock the mouse
SDL_SetWindowGrab(my_window, false);
SDL_SetRelativeMouseMode(false);

// to lock the mouse
SDL_SetWindowGrab(my_window, true);
SDL_SetRelativeMouseMode(true);

That first sets the window to the "fake" fullscreen that is just a resolution-sized borderless window. This is necessary on Windows and some Linux setups to have a mouse cursor that can freely enter and leave the window on a multi-monitor setup.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.