Re: [hatari-devel] Recent SDL GUI key up event patch |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: Hatari devel list <hatari-devel@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [hatari-devel] Recent SDL GUI key up event patch
- From: Andreas Grabher <andreas_g86@xxxxxxxxxx>
- Date: Sun, 7 Jul 2024 11:16:09 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1720343774; bh=Xx344Tripq86uHCDE3QS7TrPQ3ODAf9g5Spe6jAvhxA=; h=From:Content-Type:Mime-Version:Subject:Date:To:Message-Id; b=QMhjTv+uBcZk1aN0rxQV8eaYh86kEEyI/hi4sVN4ZPhgsqLF+213TcsU4atEOBKfg fjnOxxRucejelEF+CDEwIFTR2YpU4cHBLjfRJdJcO+mx6HYd1sxg4AxfFXfjWKYwwD kbfuMgLxIpJVjuMl9dC7OFH2SSM9EJIjrAKE+7vU5YLYBH5MsbAYaa86vT4qK26Gc+ z6NBzUsjAdCNLzoKdbaVqpA9EhUgY6BzUxcIk/u2SXrSgjyBwvVnWg7roHspsAQhxG cVvmn+qd7xhOOjw5XCAGCubgSEYHtXOo+ZsB5oiDRYR3GFk+/2GkilJ8+ZU4vCSa0j LjEiabBlzCBLA==
> Am 07.07.2024 um 11:06 schrieb Thomas Huth <th.huth@xxxxxxxxx>:
>
> 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
>
In this case I’d also use scancodes in the key up switch to be consistent:
switch (sdlEvent.key.keysym.scancode)
{
case SDL_SCANCODE_SPACE:
…
Andreas