Re: [hatari-devel] Recent SDL GUI key up event patch |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] Recent SDL GUI key up event patch
- From: Thomas Huth <th.huth@xxxxxxxxx>
- Date: Sun, 7 Jul 2024 09:06:40 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1720343203; bh=NLRa8EtBwcmjfqD05jf6llg42YwfWj/+a7NrDj0k2z8=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=T4y5ODbRAn1Tz73JhHSo18uhSscldKWF5CwIRalyilTlJkseImjd4fqjVoZxWbVbA ve9xHW59QUwWYudybLhZh0ryP7+wsU/wrM2tjv4W3NWaqjHMCO06lMW3b6hXZ+SIPr 6V3iG18qW5BJsMK7o++mTMK3Q8+X+W9zmidKcrCPQ9BBsXGYgk7A2MBvEXurPCrU9M 0a8elgHivg3MkQYU7IKqUjjaqt3r+G9+Jqh/KutyS+5SeMXudCKi+ItQfZCKkeLRx6 AAyw+UOaglDsZZO1d0aPOG3X+0MpEX5fx4Fq76Yh+jmsjfGp1RLtFjB1lqXL6SlOra dErckulyRYUig==
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