We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3153

Summary: SDL not recognizing 'space' on some keyboards
Product: SDL Reporter: Drew Bliss <drewb>
Component: eventsAssignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: icculus, magist3r, me, ori, sezeroz
Version: 2.0.3Keywords: target-2.0.6
Hardware: x86_64   
OS: Linux   
Attachments: xev on us layout
xev on ru layout

Description Drew Bliss 2015-10-15 20:03:32 UTC
This report
 
https://github.com/ValveSoftware/Dota-2/issues/453
 
has a user where when pressing space SDL doesn’t recognize the key as space.
 
SDL:  got SDL_KEYDOWN
KEYDOWN (keyc): sdlkeycode=1073741824 sdlscancode=44 SDL_GetKeyName='' buttoncode=0 buttonname='' ButtonCode_GetLocalKeyNameUTF8=''
SDL:  got SDL_TEXTINPUT
TEXTINPUT ' '
SDL:  got SDL_KEYUP
KEYUP (keyc) 0 ()
 
The scancode of 44 is normal (SDL_SCANCODE_SPACE) but then the keycode is SDLK_SCANCODE_MASK | SDL_SCANCODE_UNKNOWN.  It seems like something may be not working when building the keymap?  I think it’s a Latvian keyboard layout.

His system info:
Linux (64 bit)
    Kernel Name:  Linux
    Kernel Version:  4.2.2-1-ARCH
    X Server Vendor:  The X.Org Foundation
    X Server Release:  11702000
    X Window Manager:  GNOME Shell
Comment 1 Ryan C. Gordon 2016-02-08 06:19:49 UTC
I can't reproduce this here, but I can't help but think either this broke it...

    https://hg.libsdl.org/SDL/rev/8a89b58895c1

...or this is an Arch-specific bug?

Specifically, it looks like the failure is here...

https://hg.libsdl.org/SDL/file/c31b24c7babc/src/video/x11/SDL_x11keyboard.c#l329

...which lands here...

https://hg.libsdl.org/SDL/file/c31b24c7babc/src/video/x11/SDL_x11keyboard.c#l182

...which presumably returns NoSymbol. The fallback once this happens...

https://hg.libsdl.org/SDL/file/c31b24c7babc/src/video/x11/SDL_x11keyboard.c#l333

...only works on US QWERTY keyboards, so we end up with that SDLK_SCANCODE_MASK | SDL_SCANCODE_UNKNOWN in that switch statement's default case.


I've updated the table in X11_KeySymToUcs4(), but presumably we never got this far, and it looks like it was right except for a small unrelated thing. We'd have to deep-dive on this person's computer (including the keyboard he's using) to get further now, I think. I'll ask him to run xev.

--ryan.
Comment 2 magist3r 2016-03-11 09:25:05 UTC
Created attachment 2394 [details]
xev on us layout
Comment 3 magist3r 2016-03-11 09:25:38 UTC
Created attachment 2395 [details]
xev on ru layout
Comment 4 magist3r 2016-03-11 09:26:52 UTC
I've added logs from xev. I pressed button '1' after starting command with en and ru locales. In Dota2 it recognizes sometimes as RETURN.
Comment 5 K900 2016-05-15 15:26:25 UTC
I've got the same issue on one of my laptops. Do you guys need any more info?
Comment 6 Ori Avtalion 2017-10-23 19:23:32 UTC
I *think* I'm affected by this, but not sure.
Willing to perform any tests you wish.

I have a keyboard that's usually set to US English, but I also use a Hebrew layout.

The first game where I 'space' didn't work is Thimbleweed Park. 'space' is supposed to pause the game, but instead did nothing. It was magically fixed after a while, likely tied to an update, but I'm not sure. They never updated their SDL version (2.0.5), and made no discernible changes to the UI code.

The game Opus Magnum was just released, using SDL 2.*. It makes two uses of the  space key: as a hotkey to activate an action, which doesn't work for me, and for inputting arbitrary text, which does work.
Comment 7 Ori Avtalion 2017-12-09 13:10:33 UTC
Follow-up to my previous comment:

Opus Magnum ships with SDL 2.0.4, and if I link it against 2.0.5 onwards, the space key is recognized correctly.

I tried bisecting the code to find the fix, and I think it's this one:

changeset:   10439:0426a82e291d
user:        Sam Lantinga <slouken@libsdl.org>
date:        Sat Oct 01 14:22:10 2016 -0700
summary:     Fixed bug 3130 - Spacebar not responding
Comment 8 Sam Lantinga 2017-12-09 18:38:56 UTC
Great, thanks!
Comment 9 Ozkan Sezer 2017-12-09 19:00:05 UTC
Is this really fixed now?  If so, by which commit?
Comment 10 Ori Avtalion 2017-12-09 19:12:44 UTC
(In reply to Ozkan Sezer from comment #9)
> Is this really fixed now?  If so, by which commit?
As mentioned above, my testing implies it's this one:
  https://hg.libsdl.org/SDL/rev/0426a82e291d

Some of the commits around it failed to compile, but this is the first one where the space key worked on my test program.
Comment 11 Ozkan Sezer 2017-12-09 19:20:28 UTC
OK, I see; I misinterpreted your comment in a way that that commit
started your issue.  Sorry for the noise.