[SDL] mouse coordinates with a render logical size

albert albzey at gmail.com
Wed Sep 10 08:05:45 PDT 2014


Hi,

I setup a render logical size (SDL_RenderSetLogicalSize).

SDL_GetMouseState() does not return the translated mouse coordinates, as I figured out. That is a bit confusing because it doesn't mention it in the docs. Maybe the docs should be updated.

Is there any way to do the translation by myself? As a workaround, I'm just taking the coordinates out of SDL_MOUSEMOTION. 

Then, because my logical size has a different size ratio (4x3) instead of the full screen (SDL_WINDOW_FULLSCREEN_DESKTOP), I get some black letterboxing area. I don't want that the mouse can move into that area. Is there any way to do that? Right now, to my confusion, it can go there.

I tried to manually calculate the mouse coordinates by just relying on the relative mouse motion data. I called SDL_SetRelativeMouseMode() but I think I misunderstood what it was doing. I thought it would enable some relative mode, where I can indefinitely move into any direction and always get relative movements. However, it seems as if the absolute mouse coordinates are still locked in some area and I cannot make free relative movements once I am at some corner of the area. Is that expected? What exactly does SDL_SetRelativeMouseMode() mean then?

Another workaround would be to always call SDL_WarpMouseInWindow() so that the relative mouse movements will work in all cases.

I only want those things in fullscreen, where I have black letterboxing areas, that the mouse just stays inside of the logical screen. In window mode, I don't want any of that - the mouse can also leave the window.

Thanks,
Albert




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20140910/b1332267/attachment.htm>


More information about the SDL mailing list