Embedded Linux Maliit Virtual Keyboard

Embedded Linux Maliit Virtual Keyboard

Maliit (https://wiki.maliit.org/Main_Page) is a great project that provides virtual on-screen keyboards primarily for embedded linux. These keyboards come in several styles and with support for a large number of languages.

This page is a quick tutorial on how to build and install Maliit on an embedded system like the BeagleBoard. I will assume you are using Buildroot to build your system.

Download both the Maliit Framework and Maliit Plugins like so:
git clone git://gitorious.org/maliit/maliit-framework.git
git clone git://gitorious.org/maliit/maliit-plugins.git

Upgrade the default versions of the following packages in Buildroot to the following verions. To do this just change the version strings in the make files in the package directories for these packages. Note that you will have to manually add the dbus-glib package to Buildroot as it is not currently included by default. Just copy and existing package that is close and modify it to add a new package.
Package -- Default Version -- Upgraded Version
libglib2 2.32.3 2.34.0
dbus-glib N/A 0.100
dbus 1.6.2 1.6.4

Now make sure your Buildroot RFS is completely built with the upgraded package versions.

For simplicity, use QtCreator to build the package and make sure that you added your embedded Qt Version ( qmake ) and embedded ARM compiler ( arm-uknown-linux-gcc ) in the QtCreator tools menu.

Open the Maliit-framework and Maliit-plugins *.pro files in QtCreator and for both projects make the build settings for qmake look like the following:

CONFIG+=qws CONFIG+=nodoc CONFIG+=notest PREFIX=/usr

Now build and install Maliit-framework first by building it and then in a terminal entering the framework shadow build directory and typing:

sudo make install

Go back to QtCreator and build the plugins project and again enter it's shadow build directory and type:

sudo make install

Now everything Maliit is installed in your /usr directories. Copy Maliit to the exported-nfs directory of your root file system like so:

sudo cp /usr/bin/maliit-* /home/myuser/exported-nfs/usr/bin
sudo cp -r /usr/include/maliit /home/myuser/exported-nfs/usr/include
sudo cp -r /usr/share/maliit /home/myuser/exported-nfs/usr/share
sudo cp -r /usr/lib/libmaliit*.so* /home/myuser/exported-nfs/usr/lib
sudo cp -r /usr/lib/pkgconfig /home/myuser/exported-nfs/usr/lib
sudo cp -r /usr/lib/maliit /home/myuser/exported-nfs/usr/lib
sudo cp -r /usr/lib/maliit-framework-tests /home/myuser/exported-nfs/usr/lib

Now make sure you have your Qt Plugins directory also installed on the target RFS. This is very important. Based on your Qmake when you build Maliit there will be the input context plugins installed here. You can view them like so:

ls -lrt $QT_PLUGIN_PATH/inputmethods/
-rwxr-xr-x 1 root root 889355 Oct 9 12:44 libmaliit-qt4.so
-rwxr-xr-x 1 root root 975345 Oct 9 12:44 libmaliit-direct-qt4.so

Now boot your board and Open 2 seperate SSH sessions to the board.

In the first session type the following:

$ export QT_IM_MODULE=Maliit
$ eval `dbus-launch --auto-syntax`
$ maliit-server -software -qws &

In the second session type the following:

$ PID=$(pidof -s maliit-server)
$ ENVIRON="$(tr '\0' '\n' < /proc/${PID}/environ | grep "DBUS_SESSION_BUS_ADDRESS" | cut -d "=" -f 2-)"
$ export QT_PLUGIN_PATH=/home/user/plugins
$ export QT_IM_MODULE=Maliit
$ maliit-exampleapp-settings -qws &

Notice that you had to find the DBUS_SESSION_BUS_ADDRESS environment variable from the seperate session's maliit-server process and export it in the secondary shell. The server and keyboard plugin communicate via the dbus session bus. You also must export the QT_IM_MODULE variable so Qt knows to use Maliit.

Now you have a built-in Maliit example app working and you should be able to show the keyboard by sending focus to the input widgets. You can also change the language with this settings file easily. That should be enough to get you started. The example apps are a great way to learn how Maliit works.

The following script is an easily adaptable sample script to demonstrate Maliit.


# Run this script using the command "./keyboard_demo.sh"

# Kill existing services
killall maliit-server
killall maliit-exampleapp-settings

# Search processes for the dbus-daemon session bus PID
PID=$(ps | grep "dbus-daemon" | grep "session" | grep "myuser" | cut -d' ' -f3)

# If there is no PID for a session bus then start a session bus
# and grab the resulting pid
if [[ "${PID}" == "" ]]; then
echo "No existing dbus session bus... Starting one now."
eval $(dbus-launch --sh-syntax)
sleep 3
#PID=$(ps | grep "dbus-daemon" | grep "session" | cut -d' ' -f3)
echo $PID
echo "Existing DBUS session bus found..."

# Export the keyboard variables
export QT_PLUGIN_PATH=/home/myuser/plugins # Provide plugin location
export QT_IM_MODULE=Maliit # Turn on the keyboard dbus plugin

# Echo the env variables
echo ""
echo ""
echo ""

# Something nasty happened
if [[ "${DBUS_SESSION_BUS_ADDRESS}" == "" ]]; then
echo "We don't have a DBUS session address!"
return 1

# Turn on the maliit server
env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS QT_PLUGIN_PATH=/home/myuser/plugins QT_IM_MODULE=Maliit maliit-server -software -qws &

# Turn on the example app
env DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS QT_PLUGIN_PATH=/home/myuser/plugins QT_IM_MODULE=Maliit maliit-exampleapp-settings -qws &

Feel free to leave feedback - happy coding

ClassyBits 2020