Re: [AD] keyboard recalcitrant under X

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Mon, 2003-03-10 at 20:01, Julien Cugniere wrote:
> Elias Pschernig wrote:
> > A mapping from the X-codes to something else is always needed, else
> > programs would be quite non-portable. Allegro just does a bad job at
> > mapping X-keycodes to Allegro-keycodes.
> 
> Sorry to bother you further with this issue, but I'd really like to find a 
> good solution :-o
> 
> I've looked further into the problem, and here's what I found. In xwin.c, 
> there is a harcoded table _xwin_keysym_to_scancode[] that maps X keysyms to 
> (I think) raw pc codes. It is used to generate the final mapping 
> keycode_to_scancode[]. It contains an entry for each key of a *QWERTY* 
> keyboard, identified by the keysym that this key would produce with no 
> modifier active.
> 
> For keys like XK_a, this works fine, because it can be found on every 
> keyboard. But other keys like XK_1 are troublesome because for example, on an 
> AZERTY keyboard, there is no key that with no modifier would produce a "1". 
> The corresponding key would produce XK_ampersand. So the autodection of the 
> mapping fails on an AZERTY keyboard for this key (and similar ones).
> 
> Now, if I replace the entry { XK_1, 0x02 } by { XK_ampersand, 0x02 } in 
> _xwin_keysym_to_scancode[], the mapping is correctly autodected on my 
> keyboard (but would fail on a QWERTY).

Yes, that's what I tried explaining when I said the mapping has to look
for the right "unicode characters". In this case, the 0x02 code maps to
KEY_1 in Allegro, which produces the ampersand unicode character with
the AZERTY layout. Therefore it has to be mapped to the XK code which
also produces the ampersand unicode character.

> So, unless I'm missing something, if we create an _xwin_keysym_to_scancode[] 
> table for every keyboard layout, and use the one that correspond to the 
> keyboard language selected in allegro.cfg, it might be possible to get much 
> better mappings, and maybe even get completely rid of the xkeymap utility!

Hm, good idea. I always thought different X-setups are too different to
allow an assumption about a key-mapping working on one system working on
another as well. Especially when I found out how XF86Config selects a
combination of the tables in subdirs of /usr/X11R6/lib/X11/xkb/ on my
system, giving endless possibilities of different keyboard layouts. (I
could create my own circle-shaped keyboard, with Chinese characters on
it, and X would have zero problems with it, given there are proper
layout and mapping descriptions. It would of course be impossible to map
to Allegro's keyboard in that case.)

But when I think about it, chances are the AZERTY mapping you created in
xkeyconf also works for other users with AZERTY keyboards. Even if it
doesn't always work, it would be better than now. And if 1 or 2 keys are
wrong, xkeymap still could be used additionally by someone who knows
about it (e.g. there are several possible german keyboard layouts in X,
only differing in what certain keys like the right Alt or the one with ^
and ° on it do, so just knowing it's the de.cfg layout in Allegro won't
help, because in X they still differ even though it is the same physical
keyboard).

> Or maybe not, and it only works for me because of the way my system is 
> (mis)configured :-). Anyway, I hope my explanations were clear (the problem 
> is a bit complex!).
> 

Well, it's the same with my configuration at least :)
The problem is simply that X refuses to tell us which PC key a pressed
key corresponds to, and there seems to be no reliable way to get this
information.

-- 
Elias Pschernig <elias@xxxxxxxxxx>





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/