Android keyboard layout for TK-FBP018

Introduction

In my opinion, ELECOM TK-FBP018 is one of the best portable bluetooth keyboards available on the market today. As you can see, the keyboard layout is quite different from the default US English keyboard. This note presents the Android key layout for this keyboard written by me.

Layout description

The keyboard layout is represented on the image below.

TK-FBP018-original-layout

It offers two key maps: English and Russian . The English key map is colored in black. It’s almost identical to the key map printed on the keyboard. The Russian key map is colored in green. The Caps lock toggles between the two key maps.

If you want to adapt the key map for some other language, just replace the capslock and capslock+shift mappings with desired unicode codes in the kcm-file.

How to install

Just copy the key character file Vendor_056e_Product_1018.kl to /system/usr/keylayout/ and the key layout file Vendor_056e_Product_1018.kcm to /system/usr/keychars/.

You need to have root access to do this. Also make sure that permissions to these files are 0644 and the owner is root:root.

In case of any troubles with the layout (for example, when it doesn’t seem to be loaded when you connect the keyboard), see the system log using the logcat command.

Useful links

  1. Key Layout Files from official Android documentation.
  2. Key Character Map Files from official Android documentation.
  3. Tutorial: A custom android layout for logitech tablet keyboard – a very detailed instruction for creating custom key maps for Android.

Update from 17 Jan 2015

After few weeks of usage, I decided to modify the keyboard kayout in order to make it as close to the ordinary qwerty-layout as possible. This image repesents the result:

TK-FBP018-ordinary-layout

The corresponding keyboard layout files are here: kcm, kl.

Fixing size of android terminal

The issue

Since Android 4.3 the traditional way of gaining superuser access no longer works because the zygote process drops many capabilities, and the entire /system partition is mounted nosuid. SuperSU (popular superuser access provider) solves this issue by proxying requests to a special daemon which is not a descendant of the zygote process. Here is the explanation of the new SuperSU architecture from its authors.

This new architecture causes problems with handling terminal properly. When you start Android Terminal Emulator, it creates a terminal connected to some tty (/dev/pts/0, for example). When you type su, the superuser process you get is connected to another tty (/dev/pts/2), which the terminal emulator is not aware of. After that, when you invoke or hide virtual keyboard, rotate your device, the terminal emulator notifies the original tty to change its size, but not the one, which the superuser process is connected to. This issue makes terminal emulator almost unusable.

Possible solution

This issue has been discussed in this thread: Terminal emulator size after upgrade Android 4.3. There is a link to one possible solution of the issue: Android root shell. In my opinion, it’s quite overcomplicated: it
requires running another daemon (pts-daemon) and using a wrapper process (pts-shell). So I developed another solution, which is much simpler and is not dependent on the application providing superuser access.

My solution

The solution is based on maintaining a special file containing all superuser ttys and making Android Terminal Emulator notify each tty from that list.

The first part can be done via editing /system/etc/mkshrc. Add the following lines to the end of the file:

SUTTYS=/data/data/jackpal.androidterm/suttys

function on_exit {
    grep -v tty $SUTTYS > ${SUTTYS}.bak
    mv ${SUTTYS}.bak $SUTTYS
    chmod 644 $SUTTYS
}

if [ "$USER" = "root" ]; then
  tty >> $SUTTYS
  chmod 644 $SUTTYS
  chmod 666 tty
  trap on_exit EXIT
fi

This code is executed each time new mksh is emerged. It makes mksh do the following:

  1. Add newly created root tty to the suttys file;
  2. Remove root tty from the file before exiting the shell.

The second part requires patching Android Terminal Emulator. The patch is available here. And here is the packaged version of the application with this patch applied. Once you install it, you should no longer experience any issues with the size of the terminal.