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.gitgit clone git://gitorious.org/maliit/maliit-plugins.gitUpgrade 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 Versionlibglib2 2.32.3 2.34.0dbus-glib N/A 0.100dbus 1.6.2 1.6.4Now 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=/usrNow build and install Maliit-framework first by building it and then in a terminal entering the framework shadow build directory and typing:

sudo make installGo back to QtCreator and build the plugins project and again enter it’s shadow build directory and type:

sudo make installNow 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/binsudo cp -r /usr/include/maliit /home/myuser/exported-nfs/usr/includesudo cp -r /usr/share/maliit /home/myuser/exported-nfs/usr/sharesudo cp -r /usr/lib/libmaliit*.so* /home/myuser/exported-nfs/usr/libsudo cp -r /usr/lib/pkgconfig /home/myuser/exported-nfs/usr/libsudo cp -r /usr/lib/maliit /home/myuser/exported-nfs/usr/libsudo cp -r /usr/lib/maliit-framework-tests /home/myuser/exported-nfs/usr/libNow 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.soNow 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 DBUS_SESSION_BUS_ADDRESS="${ENVIRON}"$ 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.#!/bin/bash# Run this script using the command "./keyboard_demo.sh"# Kill existing serviceskillall maliit-serverkillall maliit-exampleapp-settings# Search processes for the dbus-daemon session bus PIDPID=$(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 pidif [[ "${PID}" == "" ]]; then echo "No existing dbus session bus… Starting one now." eval $(dbus-launch –sh-syntax) sleep 3 export DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS export DBUS_SESSION_BUS_PID=$DBUS_SESSION_BUS_PID #PID=$(ps | grep "dbus-daemon" | grep "session" | cut -d’ ‘ -f3) PID=$DBUS_SESSION_BUS_PID echo $PIDelse echo "Existing DBUS session bus found…"fi# Export the keyboard variablesexport QT_PLUGIN_PATH=/home/myuser/plugins # Provide plugin locationexport QT_IM_MODULE=Maliit # Turn on the keyboard dbus plugin# Echo the env variablesecho ""echo ""echo $QT_PLUGIN_PATHecho $QT_IM_MODULEecho $DBUS_SESSION_BUS_ADDRESSecho $DBUS_SESSION_BUS_PIDecho ""# Something nasty happenedif [[ "${DBUS_SESSION_BUS_ADDRESS}" == "" ]]; then echo "We don’t have a DBUS session address!" return 1fi# Turn on the maliit serverenv 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 appenv 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

值不值得,真是不足为外人道,自己心里有数就行。

Embedded Linux Maliit Virtual Keyboard

相关文章:

你感兴趣的文章:

标签云: