Re: [hatari-devel] Question about mouse grab in DebugUI

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]



Am 06.08.2024 um 20:25 schrieb Eero Tamminen <oak@xxxxxxxxxxxxxx>:

Hi,

On 6.8.2024 18.16, Andreas Grabher wrote:
I have a short question: in debugui.c, DebugUI() we call SDL_SetRelativeMouseMode(false) to ungrab the mouse. Shouldn’t this be Main_SetMouseGrab(false)?

There's no Main_SetMouseGrab() function, and only functions in main.c calling SDL_SetRelativeMouseMode() are for pausing & unpausing emulation...

Or did you mean adding such a function?

SDL_SetRelativeMouseMode() is called also from several other files:
--------------------------------------
$ git grep SDL_SetRelativeMouseMode | cut -d: -f1 | uniq -c
     1 src/debug/debugui.c
     2 src/dialog.c
     2 src/gui-sdl/dlgAlert.c
     2 src/gui-sdl/dlgHalt.c
     2 src/main.c
     3 src/screen.c
     4 src/shortcut.c
--------------------------------------


   - Eero

Sorry, my fault! Obviously that function is exclusive to Previous. I thought that was adopted from Hatari. 

This is the function, in case you are interested:

/* ----------------------------------------------------------------------- */
/**
* Set mouse grab.
*/
void Main_SetMouseGrab(bool grab) {
/* If emulation is active, set the mouse cursor mode now: */
if (grab) {
if (bEmulationActive) {
Main_WarpMouse(sdlscrn->w/2, sdlscrn->h/2); /* Cursor must be inside window */
SDL_SetRelativeMouseMode(SDL_TRUE);
SDL_SetWindowGrab(sdlWindow, SDL_TRUE);
Main_SetTitle("Mouse is locked. Ctrl-click to release.");
}
} else {
SDL_SetRelativeMouseMode(SDL_FALSE);
SDL_SetWindowGrab(sdlWindow, SDL_FALSE);
Main_SetTitle(NULL);
}
}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/