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 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 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
    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 $PID
else 
    echo "Existing DBUS session bus found..."
fi

# 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 $QT_PLUGIN_PATH
echo $QT_IM_MODULE
echo $DBUS_SESSION_BUS_ADDRESS
echo $DBUS_SESSION_BUS_PID
echo ""

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

# 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
xxv Introduction The text is divided into ten chapters and two appendices. Chapter 1, “Introduction,” gives a brief history of embedded Linux and what the benefits of embedded Linux are over other RTOSs. It discusses in detail the features of various open source and commercial embedded Linux distributions available. The chapter concludes by presenting a transition roadmap from a traditional RTOS to embedded Linux. Chapter 2, “Getting Started,” explains the architecture of embedded Linux and compares it with traditional RTOS and microkernel architectures. In brief various Linux kernel subsystems such as the hardware abstraction layer, memory management, scheduler, file system, and so on are given. A small description of the user-space Linux programming model is also given. The second half of the chapter explains the Linux start-up sequence, from bootloaders to kernel start-up and user-space start-up scripts. The last section explains the steps involved in building a GNU cross-platform toolchain. Chapter 3, “Board Support Package,” explains bootloader architecture followed by a discussion on the system memory map, both hardware and software memory maps. The second half of the chapter explains interrupt management, the PCI subsystem, timers, UART, and power management in detail. Chapter 4, “Embedded Storage,” explains the MTD subsystem architecture for accessing flash devices. The second half of the chapter discusses various embedded file systems such as RAMFS, CRAMFS, JFFS2, NFS, and so on. The chapter also discusses various methods for optimizing storage space in an embedded system, both kernel and user-space optimizations. A discussion of various applications designed for embedded Linux such as Busybox is given. Finally some steps for tuning the kernel memory are given. Chapter 5, “Embedded Drivers,” discusses in detail various embedded drivers such as the Serial driver, Ethernet driver, I2C subsystem, and USB gadgets.
Key Features, Create efficient and secure embedded devices using LinuxMinimize project costs by using open source tools and programsExplore each component technology in depth, using sample implementations as a guide, Book Description, Mastering Embedded Linux Programming takes you through the product cycle and gives you an in-depth description of the components and options that are available at each stage. You will begin by learning about toolchains, bootloaders, the Linux kernel, and how to configure a root filesystem to create a basic working device. You will then learn how to use the two most commonly used build systems, Buildroot and Yocto, to speed up and simplify the development process. Building on this solid base, the next section considers how to make best use of raw NAND/NOR flash memory and managed flash eMMC chips, including mechanisms for increasing the lifetime of the devices and to perform reliable in-field updates. Next, you need to consider what techniques are best suited to writing applications for your device. We will then see how functions are split between processes and the usage of POSIX threads, which have a big impact on the responsiveness and performance of the final device The closing sections look at the techniques available to developers for profiling and tracing applications and kernel code using perf and ftrace., What you will learn, Understand the role of the Linux kernel and select an appropriate role for your applicationUse Buildroot and Yocto to create embedded Linux systems quickly and efficientlyCreate customized bootloaders using U-BootEmploy perf and ftrace to identify performance bottlenecksUnderstand device trees and make changes to accommodate new hardware on your deviceWrite applications that interact with Linux device driversDesign and write multi-threaded applications using POSIX threadsMeasure real-time latencies and tune the Linux kernel to minimize them, About the Author, Chris Simmonds is a software consultant and trainer who lives in southern England. He has been using Linux in embedded systems since the late 1990s, during which he has worked on many interesting projects, including a stereoscopic camera, intelligent weighing scales, various set-top boxes and home routers, and even a large walking robot., He is a frequent presenter at open source and embedded conferences, including the Embedded Linux Conference, Embedded World, and the Android Builders' Summit. He has been conducting training courses and workshops in embedded Linux since 2002 and in embedded Android since 2010. He has delivered hundreds of sessions to many well-known companies. You can see some of his work on the 'Inner Penguin' blog at www.2net.co.uk., Table of Contents, Starting OutLearning About ToolchainsAll About BootloadersPorting and Configuring the KernelBuilding a Root FilesystemSelecting a Build SystemCreating a Storage StrategyIntroducing Device DriversStarting up - the init ProgramLearning About Processes and ThreadsManaging MemoryDebugging with GDBProfiling and TracingReal-time Programming
There's a great deal of excitement surrounding the use of Linux in embedded systems -- for everything from cell phones to car ABS systems and water-filtration plants -- but not a lot of practical information. Building Embedded Linux Systems offers an in-depth, hard-core guide to putting together embedded systems based on Linux. Updated for the latest version of the Linux kernel, this new edition gives you the basics of building embedded Linux systems, along with the configuration, setup, and use of more than 40 different open source and free software packages in common use. The book also looks at the strengths and weaknesses of using Linux in an embedded system, plus a discussion of licensing issues, and an introduction to real-time, with a discussion of real-time options for Linux. This indispensable book features arcane and previously undocumented procedures for: * Building your own GNU development toolchain * Using an efficient embedded development framework * Selecting, configuring, building, and installing a target-specific kernel * Creating a complete target root filesystem * Setting up, manipulating, and using solid-state storage devices * Installing and configuring a bootloader for the target * Cross-compiling a slew of utilities and packages * Debugging your embedded system using a plethora of tools and techniques * Using the uClibc, BusyBox, U-Boot, OpenSSH, thttpd, tftp, strace, and gdb packages By presenting how to build the operating system components from pristine sources and how to find more documentation or help, Building Embedded Linux Systems greatly simplifies the task of keeping complete control over your embedded operating system.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值