torsdag 23 maj 2013

Swedish letters and dvorak-layout on usb-keyboard on the Nexus 7

I've finaly got some routine on changing the keyboard layout on my Nexus 7 (and what i know the procedure is the same for all android devices) This is a notice for future use, and if somebody has the same issues.

1. Get files from the device


adb pull /system/usr/keychars/Generic.kcm Generic.kcm
adb pull /system/usr/keylayout/Generic.kl Generic.kl

the kcm-file to set the swedish signs, and the kl-file to change layout. If you only want the swedish letters then you only need to change the kcm file and only the kl-file if you only want to change the layout (location of the keys). Notice that the device sometimes automaticaly changes to swedish letters, so the kcm-change is not always nessesary.

Rembemer to save backups!

2. Change the files

I found a reference to a file that got the swedish (and finish) letters of the alphabet. Especialy the parts in the kcm-file saying

key APOSTROPHE {
    label, number:                      '\''
    base:                               '\u00e4'
    shift:                              '\u00c4'
    ctrl, alt, meta:                    none
}


key SEMICOLON {
    label, number:                      ';'
    base:                               '\u00f6'
    shift:                              '\u00d6'
    ctrl, alt, meta:                    none
}

and

key LEFT_BRACKET {
    label, number:                      '['
    base:                               '\u00e5'
    shift:                              '\u00c5'
    ctrl, alt, meta:                    none
}



And of course bocause i use dvorak, i also has the appropiate dvorak Generik.kl-file


key 1     ESCAPE
key 2     1
key 3     2
key 4     3
key 5     4
key 6     5
key 7     6
key 8     7
key 9     8
key 10    9
key 11    0
key 12    GRAVE
key 13    EQUALS
key 14    DEL
key 15    TAB
key 16    LEFT_BRACKET
key 17    APOSTROPHE
key 18    SEMICOLON
key 19    P
key 20    Y
key 21    F
key 22    G
key 23    C
key 24    R
key 25    L
key 26    COMMA
key 27    RIGHT_BRACKET
key 28    ENTER
key 29    CTRL_LEFT
key 30    A
key 31    O
key 32    E
key 33    U
key 34    I
key 35    D
key 36    H
key 37    T
key 38    N
key 39    S
key 40    MINUS
key 41    APOSTROPHE
key 42    SHIFT_LEFT
key 43    BACKSLASH
key 44    PERIOD
key 45    COMMA
key 46    J
key 47    K
key 48    X
key 49    B
key 50    M
key 51    W
key 52    V
key 53    Z



Push files to the device


And when you are ready, use some useful tool to push the files back again (remount to make the system writable)

adb remount /system/usr/keychars 
adb remount /system/usr/keylayout
adb push Generic.kcm /system/usr/keychars
adb push Generic.kl /system/usr/keylayout



4. Debug

Something can easily go wrong. If so make sure to change the logcat print. Write in terminal

su
logcat

In worst case.. Push the backup-files back again.

Prroblems that i had:

  • I wrote the kcm-file wrong. You cannot make up new letters, that will cause a error.
  • I got the wrong user access set on the files. I sudoed in the files so the system could not use the files. Fixed with chmod.
  • I cannot write z... Not fixed. Don not know any workaroud...




Hope it helps! Post a comment if it doesnt.
Cheers!