layer:11

an addiction to or an obsession with acquiring, manipulating, and sharing information

Latvian Keyboard Layout

Recently I got Nokia N900, but it doesn’t come with Latvian keyboard layout, not a big deal, since it’s running Linux and Xorg. This is a recollection of my journey into XKB configuration.

All of the fallowing code goes into /usr/share/X11/xkb/symbols/nokia_vndr/rx-51, after making changes, you run setxkbmap lv to activate the layout.

This was my first try:

 1 partial alphanumeric_keys modifier_keys
 2 xkb_symbols "lv" {
 3 
 4   include "nokia_vndr/rx-51(english_base)"
 5   include "nokia_vndr/rx-51(arrows_4btns)"
 6 
 7   name[Group1]= "Latvian";
 8 
 9   key <AD03> { [e, E, emacron, Emacron] };
10   key <AD07> { [u, U, umacron, Umacron] };
11   key <AD08> { [i, I, imacron, Imacron] };
12   key <AC01> { [a, A, amacron, Amacron] };
13   key <AC02> { [s, S, scaron, Scaron] };
14   key <AC05> { [g, G, gcedilla, Gcedilla] };
15   key <AC08> { [k, K, kcedilla, Kcedilla] };
16   key <AC09> { [l, L, lcedilla, Lcedilla] };
17   key <AB01> { [z, Z, zcaron, Zcaron] };
18   key <AB03> { [c, C, ccaron, Ccaron] };
19   key <AB06> { [n, N, ncedilla, Ncedilla] };
20 
21 };

This works as expected, you can type both Latin and Latvian letters, but the problem is that you lose some numbers and special characters, that are defined on the third level in english_base. Something like this would work perfectly, if you need to simply replace one letter with another. What’s interesting is that the fourth level isn’t actually necessary, it doesn’t get used. Looking at the modifiers symbols definition, you can see that there’s no way to switch to the fourth level, I don’t know why most keys have four levels defined, I did it just because that’s how Nokia does it. What’s interesting is that with three levels, you can get six different symbols:

 1 partial alphanumeric_keys modifier_keys
 2 xkb_symbols "lv" {
 3 
 4   include "nokia_vndr/rx-51(english_base)"
 5   include "nokia_vndr/rx-51(arrows_4btns)"
 6 
 7   name[Group1]= "Latvian";
 8 
 9   key <AD03> { [e, emacron, 3, 3] };
10   key <AD07> { [u, umacron, 7, 7] };
11   key <AD08> { [i, imacron, 8, 8] };
12   key <AC01> { [a, amacron, asterisk, asterisk] };
13   key <AC02> { [s, scaron, plus, plus] };
14   key <AC05> { [g, gcedilla, underscore, underscore] };
15   key <AC08> { [k, kcedilla, ampersand, ampersand] };
16   key <AC09> { [l, lcedilla, exclam, exclam] };
17   key <AB01> { [z, zcaron, sterling, sterling] };
18   key <AB03> { [c, ccaron, EuroSign, EuroSign] };
19   key <AB06> { [n, ncedilla, quotedbl, quotedbl] };
20 
21 };
That’s my second attempt, it works like this:
  • press e - level one - returns “e”
  • press Shift, then e - level one - returns “E”
  • hold Shift and press e - level two - returns “ē”
  • press Shift, then hold Shift and press e - level two - returns “Ē”
  • press or hold Fn, then e - level three - returns “3”
This is better than the first attempt, but very confusing to type, I don’t think you would want to use something like this, illustrates how the levels work though.

Another try:

 1 partial alphanumeric_keys modifier_keys
 2 xkb_symbols "lv" {
 3 
 4   include "nokia_vndr/rx-51(english_base)"
 5 
 6   name[Group1]= "Latvian";
 7 
 8   key <UP> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [Up] };
 9   key <LEFT> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [Left, dead_caron] };
10   key <DOWN> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [Down, dead_cedilla] };
11   key <RGHT> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [Right, dead_macron] };
12 
13 };

Here we set the second level of arrow keys to work as dead keys. I’m not sure why you needed to assign a special type, but this won’t work otherwise. If your language has one diacritic, this would be a good solution, more than that and this gets confusing.

Here’s the best and final configuration:

 1 partial alphanumeric_keys modifier_keys
 2 xkb_symbols "lv" {
 3 
 4   include "nokia_vndr/rx-51(english_base)"
 5   include "nokia_vndr/rx-51(arrows_4btns)"
 6 
 7   name[Group1] = "Latin";
 8   name[Group2] = "Latvian";
 9 
10   key <AD03> { symbols[Group2] = [emacron, Emacron, 3, 3] };
11   key <AD07> { symbols[Group2] = [umacron, Umacron, 7, 7] };
12   key <AD08> { symbols[Group2] = [imacron, Imacron, 8, 8] };
13   key <AC01> { symbols[Group2] = [amacron, Amacron, asterisk, asterisk] };
14   key <AC02> { symbols[Group2] = [scaron, Scaron, plus, plus] };
15   key <AC05> { symbols[Group2] = [gcedilla, Gcedilla, underscore, underscore] };
16   key <AC08> { symbols[Group2] = [kcedilla, Kcedilla, ampersand, ampersand] };
17   key <AC09> { symbols[Group2] = [lcedilla, Lcedilla, exclam, exclam] };
18   key <AB01> { symbols[Group2] = [zcaron, Zcaron, sterling, sterling] };
19   key <AB03> { symbols[Group2] = [ccaron, Ccaron, EuroSign, EuroSign] };
20   key <AB06> { symbols[Group2] = [ncedilla, Ncedilla, quotedbl, quotedbl] };
21 
22   key <AB08> { [ISO_Group_Latch, semicolon, equal, equal], [comma, semicolon, equal, equal] };
23   key <SPCE> { symbols[Group2] = [comma, space, at, at] };
24 
25 };

What this does is adds another group to keys and sets , key to “latch” onto it. Here’s how it works - every key works like normal, except ,, it sets key group to two, so that when you press the next key, that has a second group defined, a symbol from group two will be used, instead of the default first group. Works really well, I’m happy with this setup, only thing that could make it better, would be a dedicated Chr key, like some other Nokia phones have.

Another interesting possibility is to define keys with eight levels and set first group type to EIGHT_LEVEL_SEMIALPHABETIC, then you can switch between first four and last four levels with Ctrl + Space. Perfect for languages that don’t have Latin letters.

Resources: An Unreliable Guide to XKB Configuration, X Keyboard Extension - Иван Паскаль, example configurations.

2010-02-02 00:13

XKBMaemoN900

| Archive | RSS | E-mail | Twitter | Alvis Mikovs