Re: [AD] XIM patch for Allegro 4.1.x |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: Re: [AD] XIM patch for Allegro 4.1.x
- From: Elias Pschernig <allefant@xxxxxxxxxx>
- Date: Wed, 10 Nov 2004 19:39:57 +0100
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:references; b=bIPcK+jIEoCnQUP1m1roWNzr8A5LhNZ/8fYuqRdfOYwk104Xamkggr9QlP2PjemXvVaKvWDWoxkjYLMsUuOkXDmfbRkvm/N3XcOcSYXqOCnmT2lwlxSvLurdfJMdzGh+LVZ0f/OeA/9YSMryfGO4/rCBoqsdEy1p4elSV9WPoUI=
Attached is a patch which should fix the detection of the number keys,
and I commented out the locale modification, since it actually doesn't
seem to change anything.
> Of course, for KEY_3, it would always return ". It would actually be
> easy to report all the codes generated for the key, since X11 reports
> that information (as can be seen in the logfile).
>
Hm, I was primising too much. The logfile already writes the X11
KeySyms, e.g. it writes "eacute".. but there is no way to translate
"eacute" into é, except a really big list, like GTK or Qt contain. I'd
say, there's no point for such a list in Allegro. And it wouldn't help
much, since what ASCII would you return for example for F1?
I think we should provide a function:
char const *get_key_name (scancode)
Which would return the name of the key. In case a driver doesn't
implement it, it would just work like exkeys, i.e.
get_key_name(KEY_F1) returns "F1". A driver like X11 could override it
and display the result of KeysymToString instead.
> > I can help if you need. Also, can't you use OpenGL unaccelerated ? That might
> > be enough to test. Or maybe this is a problem for Bob to fix ;-) Should I
> > report on [AGL] ?
> >
> > Anyway, here's what I could gather after a bit of investigation :
> >
> > The AllegroGL examples that fail are dumbtest, exgui and exalleg. They have in
> > common that they use rect() and rectfill() directly, or indirectly through
> > gui objects. After commenting these use, they work fine. Does that help ?
> >
>
> I think, you should report on the AGL list.. I just tried it here, and
> it crashes with a 0 pointer reference in rect() it seems - can't see
> how that is connected to XIM though.
>
I tried with 4.1.16, and the example programs still crash. Can you
confirm that AGL worked for you with 4.1.16? I'll try to investigate
this further, but I couldn't find a connection to the XIM patch so
far.
Index: src/x/xkeyboard.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/x/xkeyboard.c,v
retrieving revision 1.6
diff -u -p -r1.6 xkeyboard.c
--- src/x/xkeyboard.c 2 Nov 2004 13:38:24 -0000 1.6
+++ src/x/xkeyboard.c 10 Nov 2004 18:20:17 -0000
@@ -482,33 +482,44 @@ void _xwin_get_keyboard_mapping(void)
TRACE ("xkeyboard: %i keys, %i symbols per key.\n", count, sym_per_key);
missing = 0;
+
for (i = min_keycode; i <= max_keycode; i++) {
KeySym sym = keysyms[sym_per_key * (i - min_keycode)];
+ KeySym sym2 = keysyms[sym_per_key * (i - min_keycode) + 1];
+ int allegro_key = 0;
+
+ TRACE ("key [%i: %s %s]", i, XKeysymToString(sym), XKeysymToString(sym2));
- TRACE ("key %i: %s", i, XKeysymToString(sym));
+ /* Hack for French keyboards, to correctly map KEY_0 to KEY_9. */
+ if (sym2 >= XK_0 && sym2 <= XK_9)
+ {
+ allegro_key = find_allegro_key(sym2);
+ }
- if (sym != NoSymbol) {
- int allegro_key = find_allegro_key(sym);
+ if (!allegro_key)
+ {
+ if (sym != NoSymbol) {
+ allegro_key = find_allegro_key(sym);
- if (allegro_key == 0) {
- missing++;
- TRACE (" defering.");
+ if (allegro_key == 0) {
+ missing++;
+ TRACE (" defering.\n");
+ }
}
- else {
- if (used[allegro_key])
- TRACE (" *double*");
- x_to_allegro_keycode[i] = allegro_key;
- used[allegro_key] = 1;
- TRACE (" assigned to %i.", allegro_key);
+ else
+ {
+ /* No KeySym for this key - ignore it. */
+ x_to_allegro_keycode[i] = -1;
+ TRACE (" not assigned.\n");
}
-
- TRACE ("\n");
}
- else
- {
- /* No KeySym for this key - ignore it. */
- x_to_allegro_keycode[i] = -1;
- TRACE (" not assigned.\n");
+
+ if (allegro_key) {
+ if (used[allegro_key])
+ TRACE (" *double*");
+ x_to_allegro_keycode[i] = allegro_key;
+ used[allegro_key] = 1;
+ TRACE (" assigned to %i.\n", allegro_key);
}
}
@@ -614,6 +625,7 @@ static int x_keyboard_init(void)
XLOCK ();
#ifdef ALLEGRO_USE_XIM
+/* TODO: is this needed?
if (setlocale(LC_ALL,"") == NULL) {
TRACE("x keyboard warning: Could not set default locale.\n");
}
@@ -622,7 +634,7 @@ static int x_keyboard_init(void)
if (modifiers == NULL) {
TRACE ("x keyboard warning: XSetLocaleModifiers failed.\n");
}
-
+*/
xim = XOpenIM (_xwin.display, NULL, NULL, NULL);
if (xim == NULL) {
TRACE("x keyboard warning: XOpenIM failed.\n");