Re: keyboard capabilities



On Wed, Jun 20, 2007 at 12:57:34PM +0200, David Gasa Castell wrote:
> I need some help from you !. I need anyone who points out the function
> that permits me to change -for a little moment- the layout of the
> keyboard, like this:
> ...

I don't think anything like that, i.e. platform-independent,
exists.  You can of course use platform-specific means to
change the keyboard layout (running setxkbmap or whatever),
but people with customized keyboards may and probably will
hate you, because the hard problem is to restore the
keyboard, which could be modified by xmodmap, etc.

> I don't know if this function really exists in the developed libraries
> but I think is not an stupid function.

Let me state that as someone with a heavily customized
keyboard, I think it is.

> I know that Gnome Desktop
> Environment can do something like this: It's possible to predefine
> layouts (Desktop > Preferences > Keyboard > Layouts) and select a
> combination keys to change the current layout (Desktop > Keyboard >
> Layout Options > Group Shift/Lock behaviour). I also know that all of
> this is controlled by a kind of register based in XML but, indeed it's
> not enought.

This configures the keyboard on the X level (see e.g.
http://ftp.x.org/pub/X11R7.0/doc/html/XKB-Config.html
and http://pascal.tsu.ru/en/xkb/).  Applications --
including at the Gdk level -- obtain key symbols according
to the current keyboard map.  They also obtain the raw
keycodes, however using these portably may be a problem.

> Obviously, there are a lots of keyboard models... But that must be a
> constant value !.

The raw key code is generally a constant value on
a particular hardware.  It's different on different hardware.
The translation of the raw keycode to a key symbol is the
task of X (or other windowing environment).

> The idea is make the keyboard a bit more "multi"
> language.

Why?  If I, as a user, want an English-Czech-Russian keyboard,
I configure it easily and it will work system-wide.  I can
also define a keyboard that contains an arbitrary mixture of
characters if I feel such a need.  Why should applications
change the keyboard layout I am used to?

> Furthermore, I know that Gnome can draw Unicode characters using UTF-8
> characters encoding.

Essentially anything from this millenium can.

However, this is not much UTF-8 or glyph-rendering related.
In fact, X11 symbol codes (see X11/keysymdef.h) differ from
Unicode character codepoints, although there are relations
between some blocks of X11 keycodes and some Unicode
character blocks.

> Note that I'm speaking a different question that
> is,
> 
> if I type an "a" touch in an english keyboard and in an environment
> configured as english, it's normal to hope obtain the letter "a". But
> with the same keyboard but with different language, for example greek,
> according to http://www.galaxie.com/assets/biblescript/greek.gif, it's
> normal to obtain -when typing the same touch (ie. our "a")- the greek
> letter alfa ("?").

Yes, this is exactly what happens.

There is no intermediate translation step between the raw
keycode and the Greek letter alpha that would involve the
English letter `a'.  The Greek keyboard map simply states
that raw key code AC01 (that is the first key of the second
row) types alpha, and that's it.

More precisely, on X11 there are three codes involved:

1. Raw keyboard code.  A hardware-dependent number, for
instance 38 on a common i386 hardware.  You can obtain this
one, but generally you should not use it.

2. X11 key code.  This is an abstraction of 1 representing
a position an function of the key on the keyboard, for
instance AC01 for the key that types `a' on the English
keyboard.  The translation from 1 is defined in the
corresponding xkb/kecodes/ map.  I'm not sure one can obtain
this.

3. Symbol.  This is the character the key already types
(well, keys can do other things, like be modifiers, which is
also defined in the maps, but let put aside this), this is
a concretization of 2 for a partcular keyboard map, for
instance it's alpha or a.  The translation from 2 is defined
in the corresponding xkb/symbols/ map.  This is essentially
what all applications use.

Now, forget all this.  What Gtk+ actually uses in most
cases is not even the symbol, but the output of the input
method.  Input methods are things that can translate whole
sequences of keystrokes to symbols and they enable us to
type complex scripts (Japanesse, Chinesse, ...) on our
simple keyboards.  However, even things like typing acute + a
to get á in Latin languages involve a (simple) input method.
And applications that do not support this are definitely broken
from internationalization point of view.

> It's very important for me to clarify all these concepts and to
> understand how the system (GNU/Linux, GTK+,...) operates. You can
> point me documentation, ideas, suggestions,...

Hopefully the XKB links above will explain at least some
bits.

Yeti

--
http://gwyddion.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]