Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keys send two keydown events at once #2293

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

Keys send two keydown events at once #2293

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: 2.0.5
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2016-10-31 18:11:06 +0000, Marisa wrote:

I have noticed this after updating from 2.0.4 on my system (Arch Linux). In many games, or even in simple programs I could write by myself, pressing any key results in two keydown events being sent at the same time.

On 2016-11-01 05:24:50 +0000, Ozkan Sezer wrote:

Duplicate of https://bugzilla.libsdl.org/show_bug.cgi?id=3472 ?

On 2016-11-01 11:53:41 +0000, Marisa wrote:

I have investigated that bug and it's unrelated to my case.

I do not use ibus, but rather uim, which seems to be responsible for this happening.

Instead of one keydown and one keyup event being sent at the same time like in that bug, I get two keydowns, one of them with the repeat flag.

I wrote a program to show this:

#include <SDL.h>

int main( void )
{
SDL_Init(SDL_INIT_VIDEO);
SDL_Window *w = SDL_CreateWindow("keydown",SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED,256,256,SDL_WINDOW_SHOWN);
SDL_Event e;
int quit = 0;
while ( !quit )
{
while ( SDL_PollEvent(&e) )
{
if ( e.type == SDL_QUIT ) quit = 1;
else if ( e.type == SDL_KEYDOWN )
{
printf("keydown:\n scancode %u\n repeat %u\n",
e.key.keysym.scancode,e.key.repeat);
if ( e.key.keysym.scancode == 41 ) quit = 1;
}
else if ( e.type == SDL_KEYUP )
{
printf("keyup:\n scancode %u\n repeat %u\n",
e.key.keysym.scancode,e.key.repeat);
}
}
}
SDL_DestroyWindow(w);
SDL_Quit();
}

The output when I do a single press of enter is:

keydown:
scancode 40
repeat 0
keydown:
scancode 40
repeat 1
keyup:
scancode 40
repeat 0

If I unset XMODIFIERS (which is set to @im=uim), the repeated keydown does not happen.

On 2016-11-01 17:15:39 +0000, Sam Lantinga wrote:

Alex, can you look into this?

Thanks!

On 2016-11-01 17:41:16 +0000, Alex Baines wrote:

Created attachment 2597
skip resent filtered keys

I believe this fixes it.

On 2016-11-01 17:51:25 +0000, Sam Lantinga wrote:

Fixed, thanks!
https://hg.libsdl.org/SDL/rev/251691cfeaa0

On 2016-11-02 04:23:57 +0000, Alex Baines wrote:

Created attachment 2598
don't skip sending text for resent events

I realized overnight that my patch probably broke text input events with UIM, and I confirmed that it does. Can't believe I overlooked that... I've been making stupid mistakes in these patches recently, sorry.

Anyway, this one seems to fix it properly. Knowing my luck it probably breaks something else.

On 2016-11-02 17:52:46 +0000, Sam Lantinga wrote:

Got it, thanks!
https://hg.libsdl.org/SDL/rev/8b8a45c000f9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant