Package: libsdl1.2
Severity: normal
Tags: patch

Hello,

the SDL-library does not properly lookup keysyms under X11.  Each key
has a list of four keysyms assigned to it, which are interpreted as
"group 1 without shift", "group 1 with shift", "group 2 without
shift", and "group 2 with shift".  The SDL library only uses the first
element of this array.  This makes it impossible to use keysyms from
group 2 (i.e. keysyms accessed using the altgr modifier).

The problem is in the file src/video/x11/SDL_x11events.c, line 621:

    xsym = XKeycodeToKeysym(display, kc, 0);

The "0" is the index into the above mentioned list and thus we get
always the first keysym.

An easy fix (which avoids messing around with the modifiers ourselves)
is to use the XLookupString function instead.  In translates a
keyboard event into a string (which we may ignore) and the *correct*
keysym.  This approach is implemented in the appended patch.

I hope this helps,
Jochen

-- System Information:
Debian Release: 3.1
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: powerpc (ppc)
Kernel: Linux 2.6.11
Locale: LANG=en_GB.iso885915, LC_CTYPE=en_GB.iso885915 (charmap=ISO-8859-15)
--- SDL-1.2.7+1.2.8cvs20041007.orig/src/video/x11/SDL_x11events.c	2005-03-16 23:39:50.000000000 +0000
+++ SDL-1.2.7+1.2.8cvs20041007/src/video/x11/SDL_x11events.c	2005-03-16 23:43:49.000000000 +0000
@@ -614,11 +614,12 @@
 SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey, KeyCode kc,
 			     SDL_keysym *keysym)
 {
+        char buffer[8];
 	KeySym xsym;
 
 	/* Get the raw keyboard scancode */
 	keysym->scancode = kc;
-	xsym = XKeycodeToKeysym(display, kc, 0);
+	XLookupString (xkey, buffer, 8, &xsym, NULL);
 #ifdef DEBUG_KEYS
 	fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, kc);
 #endif

Reply via email to