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 4163 - Missing X11 to keycode mappings
Summary: Missing X11 to keycode mappings
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.8
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-11 18:42 UTC by Michael Roe
Modified: 2018-05-11 18:42 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Roe 2018-05-11 18:42:07 UTC
The mapping from X11 keysyms to SDL keycodes in src/video/x11/SDL_x11keyboard.c is missing entries for the multimedia keys found on some keyboards, such as the Microsoft Natural 4000.

The consequence is that these keys don't work in SDL2 applications that needs
a keycode to keysym mapping.

The following patch will fix the issue:

*** SDL_x11keyboard.c.old       2018-05-11 19:33:24.165362000 +0100
--- SDL_x11keyboard.c   2018-05-11 19:36:07.443282000 +0100
***************
*** 29,34 ****
--- 29,35 ----
  #include "../../events/scancodes_xfree86.h"

  #include <X11/keysym.h>
+ #include <X11/XF86keysym.h>
  #include <X11/XKBlib.h>

  #include "imKStoUCS.h"
***************
*** 148,153 ****
--- 149,174 ----
      { XK_apostrophe, SDL_SCANCODE_APOSTROPHE },
      { XK_bracketleft, SDL_SCANCODE_LEFTBRACKET },
      { XK_bracketright, SDL_SCANCODE_RIGHTBRACKET },
+     { XF86XK_Cut, SDL_SCANCODE_CUT },
+     { XF86XK_Copy, SDL_SCANCODE_COPY },
+     { XF86XK_Paste, SDL_SCANCODE_PASTE },
+     { XF86XK_AudioMute, SDL_SCANCODE_MUTE },
+     { XF86XK_AudioRaiseVolume, SDL_SCANCODE_VOLUMEUP },
+     { XF86XK_AudioLowerVolume, SDL_SCANCODE_VOLUMEDOWN },
+     { XF86XK_AudioNext, SDL_SCANCODE_AUDIONEXT },
+     { XF86XK_AudioPrev, SDL_SCANCODE_AUDIOPREV },
+     { XF86XK_AudioStop, SDL_SCANCODE_AUDIOSTOP },
+     { XF86XK_AudioPlay, SDL_SCANCODE_AUDIOPLAY },
+     { XF86XK_Mail, SDL_SCANCODE_MAIL },
+     { XF86XK_Calculator, SDL_SCANCODE_CALCULATOR },
+     { XF86XK_Search, SDL_SCANCODE_AC_SEARCH },
+     { XF86XK_HomePage, SDL_SCANCODE_AC_HOME },
+     { XF86XK_Back, SDL_SCANCODE_AC_BACK },
+     { XF86XK_Forward, SDL_SCANCODE_AC_FORWARD },
+     { XF86XK_Refresh, SDL_SCANCODE_AC_REFRESH },
+     { XF86XK_Favorites, SDL_SCANCODE_AC_BOOKMARKS },
+     { XF86XK_AudioRewind, SDL_SCANCODE_AUDIOREWIND },
+     { XF86XK_AudioForward, SDL_SCANCODE_AUDIOFASTFORWARD },
  };

  static const struct


(This is also available on github at https://github.com/michael-roe/SDL-mirror/commit/5d13872bbfcf61c85735207731f09c5248a11052  (in branch x11-keyboard)