Re: [hatari-devel] Recent SDL GUI key up event patch

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


Am Sun, 7 Jul 2024 09:06:08 +0200
schrieb Andreas Grabher <andreas_g86@xxxxxxxxxx>:

> > Am 07.07.2024 um 08:24 schrieb Andreas Grabher <andreas_g86@xxxxxxxxxx>:
> > 
> > 
> >   
> >> Am 07.07.2024 um 08:17 schrieb Thomas Huth <th.huth@xxxxxxxxx>:
> >> 
> >> Am Sun, 7 Jul 2024 07:15:02 +0200
> >> schrieb Andreas Grabher <andreas_g86@xxxxxxxxxx>:
> >>   
> >>> Hello all,
> >>> 
> >>> I noticed the recent fix for orphaned key up events in SDL GUI. I think this is too complicated and probably unsafe. I suggest calling
> >>> 
> >>> 	SDL_ResetKeyboard();
> >>> 	SDL_FlushEvent(SDL_KEYUP);
> >>> 
> >>> instead.  
> >> 
> >> I remembered your mail from many months ago and tried that first, indeed,
> >> but for some reasons it does not work for me: If I add that sequence e..g.
> >> to Main_PauseEmulation() or the beginning of SDLGui_DoDialogExt(), the
> >> button of the exit dialog still gets activated if I e.g. hold down the
> >> return key and then click the "X" to close the Hatari window. Seems like
> >> the logic in Hatari works a little bit different than in Previous here?
> >> 
> >> Thomas
> >> 
> >>   
> > 
> > Does it still fail if you put SDL_PumpEvents() in between?
> > 
> > 	SDL_ResetKeyboard();
> > 	SDL_PumpEvents();
> > 	SDL_FlushEvent(SDL_KEYUP);
> >   
> 
> OK, for some reason I can’t make this work on my system anymore. So probably your solution is the only solution to this problem. Anyway I suggest using SDL_GetScancodeFromKey() to make it more secure:
> 
> ignore_first_keyup = keystates[SDL_GetScancodeFromKey(SDLK_RETURN)] ||
>                      keystates[SDL_GetScancodeFromKey(SDLK_KP_ENTER)] ||
>                      keystates[SDL_GetScancodeFromKey(SDLK_SPACE)] ||
>                      keystates[SDL_GetScancodeFromKey(SDLK_ESCAPE)];

I don't think that we really need SDL_GetScancodeFromKey() - these keys
should always be in the same location. SDL_GetScancodeFromKey() is rather
required for keys that have different locations in differnt country layouts.

 Thomas



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