Remapping keyboard

In the English variant of the N900 keyboard arrow keys have no extra symbols attached to them.

You can remap those keys to add things such as accents, umlauts or other useful symbols (e.g. `|', `<' or `>' for the X terminal).

You need to edit this file on your N900 (you should make a copy first in case something goes wrong, do not place the copy in the nokia_vndr folder or it will stop your phone from booting):

/usr/share/X11/xkb/symbols/nokia_vndr/rx-51

The arrow keys are located at the end of the file. This example shows how to add dead acute, grave, tilde and circumflex accents (useful for writing in Portuguese) Press Fn+Up/Down/Left/Right to use these accents.

xkb_symbols "arrows_4btns" {
    key <UP>   { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Up, dead_circumflex ] };
    key <LEFT> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Left, dead_acute ] };
    key <DOWN> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Down, dead_tilde ] };
    key <RGHT> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Right, dead_grave ] };
};

This example adds German umlauts:

xkb_symbols "arrows_4btns" {
    key <UP>   { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Up, udiaeresis ] };
    key <LEFT> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Left, odiaeresis ] };
    key <DOWN> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Down, adiaeresis ] };
    key <RGHT> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Right, ssharp ] };
};

This one adds Page Up, Page Down, Home and End:

xkb_symbols "arrows_4btns" {
    key <UP>   { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Up, Page_Up ] };
    key <LEFT> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Left, Home ] };
    key <DOWN> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Down, Page_Down ] };
    key <RGHT> { type[Group1] = "PC_FN_LEVEL2", symbols[Group1] = [ Right, End ] };
};

Type `setxkbmap' to apply the changes. If you see an error you should replace the rx-51 file with your backup, if you don't the device will fail to boot and you'll have to reflash it.

Of couse all these are just examples. You can add any other symbol you like, or you can remap any other key, not just the arrows.

If you want to know the name of a symbol, just take a look at this list of standard PC keyboard layouts as an example:

http://cgit.freedesktop.org/xkeyboard-config/tree/symbols/

An alternative approach for getting custom special characters is to edit the Special characters view.

Note: the pipe symbol is called "bar".

Temporary remap

Keys can be also remapped temporarily by loading keymap to a file, edit that file and then reload changed file to N900 X server; like this (on an X terminal):

xkbcomp :0
vi server-0.xkb
xkbcomp server-0.xkb :0

This has the advantage that if keymap get screwed out, running just setxkbmap will fix it back to original. If this cannot be done, rebooting will fix things for sure.

For arrow key remapping the following script can be handy:

Just noticed that this makes N900 drain battery !!! (N900 was shutdown in the morning). After executing this maemo-xinput-sounds takes >90% of cpu time. Killing the process will be a temporary fix; I'll look for better solution...

#!/bin/sh

set -eux

# busybox mktemp is sooo strict: 6 X:s at the end is the only option...
tf=`mktemp xkb-XXXXXX`
trap "rm $tf.0 $tf" 0

xkbcomp :0 $tf.0

perl -pe '
 sub out ($$$) {
        print qq(    key <$_[0]> { type[Group1] = "PC_FN_LEVEL2",);
        print qq( symbols[Group1] = [ $_[1], $_[2] ] };);
        return if s/.*};//; while (<>) { last if s/.*};//; };
 }
 s/controls=\)/controls=SlowKeys\)/; # hmm...
 out "UP", "Up", "Odiaeresis" if (/key\s+<UP>/);
 out "DOWN", "Down", "adiaeresis" if (/key\s+<DOWN>/);
 out "LEFT", "Left", "odiaeresis" if (/key\s+<LEFT>/);
 out "RGHT", "Right", "Adiaeresis" if (/key\s+<RGHT>/);
' $tf.0 > $tf

xkbcomp $tf :0

This one maps Up, Down, Left and Right to Ö, ä, ö, Ä, respectively (for finnish/scandinavian users), and is easy to tune for other purposes. Copy this as xk to home directory on N900 and execute it as sh xk whenever (seldom) you reboot N900.