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 09:06:08 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1720335973; bh=5M/YPxpPqgTJgag2QmcZxaLIgMnEzrBiqwE+tXfSvkE=; h=From:Content-Type:Mime-Version:Subject:Date:To:Message-Id; b=mo7rY436dinG5MHZos1EbSCdpO+JX2PzuWhmK0coPqoZWcBvA162HygkMQLppTw7k Q6dM4rktfj3nkPMcY7I14gdvqUuEvVKND99o7QiWPHQaVHExJDUV+LTFqWuVpzRsRY 7sribX+0VwF7Dxs2yjMZw5SYlPe/XENgWAydc/n/0v9FiqAdf5dzb8BRLZxKkjiAlE moE4+Hcv35wPI+4x1sJXyD4u2bIzKj4ZOHXGsRQEh+AVKuSuVdHmzMgYhASbWucvDp ZP6bOh3MUOv8j/LBpJX7jFrQfcSjDZtVgrXAnkTdEEjw/OPEKBxHMpt465JfQvWkfq eL0B1nlxD2t5A==
> 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)];