Sunday, April 26, 2009

On screen keyboard

On screen keyboard is necessary for a tablet PC. Have tried several on screen keyboard implementation under X window, no one is perfect. Currently using one is cellwriter. Hope the one developed for Moblin will be better.

Requirement for on screen keyboard:
  • Focus: the on screen keyboard should not be focused, and the faked key should be sent to the focused window.
  • Window placement: the on screen keyboard window should not be covered by other windows (for example to be the top-most window), and it should not cover other windows completely (semi-transparent or docked at the desktop side, but it seems docking is not supported well in my metacity 2.24.0).
  • Compatible with XIM. I am Chinese, I need use XIM to input Chinese.
  • Configurable layout (to keep only the needed keys).
  • Show/Hide can be controlled easily (via a panel button is preferable).
  • Support screen rotation. On screen keyboard should not outside the screen or bigger than screen after rotation.
Tried on screen keyboard software:
  • xvkbd: does not handle focus perfectly, the xvkbd itself seem be focused too (titlebar highlighted), so need two click for one key; need to specify which widget faked keys go, not very conveniently.
  • matchbox-keyboard: good support for rotation, configurable laout, XIM, focus. Docking support for matchbox-wm is good. Original version does not support docking for metacity. I have a hack to support docking for metacity, but the hack doesn't support metacity 2.24.0. Show/Hide control can be done with daemon mode (-d) + matchbox-keyboard-toggler utility.
  • gok (gnome on screen keyboard): recommended by many guys, but not good for me. Appears not works with XIM, and not works well without pointer in/out event.
  • onboard: not used too much, I think it is good and simple.
  • cellwriter: hand writing recoganizing program, but it is a good and simple on screen keyboard too. To use it as on screen keyboard add "--keyboard-only" to command line. Do no support configurable layout. Seems not support docking good.

Lenovo Thinkpad X61 Tablet

Bought a Lenovo Thinkpad X61 Tablet recently. Will post some usage tips. Most useful links:

http://www.thinkwiki.org/wiki/ThinkWiki

Evtouch configuration

This article is mainly for Tablet Classmate PC.

Evtouch is a Xorg (X window system) input driver for touchscreen device with Linux kernel input/event driver. For example some USB touchscreen device with USBHID class.

To use evtouch Xorg driver, xorg should be setup as follow:


--------------------------------------------------------------------------------
Section "InputDevice"
Identifier "TOUCH"
Driver "evtouch"
Option "Device" "/dev/input/by-path/pci-0000:00:1d.3-usb-0:1:1.0-event-"

Option "DeviceName" "touchscreen"
Option "ReportingMode" "Raw"
Option "MoveLimit" "10"
Option "SendCoreEvents" "On"
# Option "Calibrate" "1"
Option "MinX" "1"
Option "MinY" "1"
Option "MaxX" "4090"
Option "MaxY" "4090"
Option "x0" "-6"
Option "y0" "8"
Option "x1" "1"
Option "y1" "2"
Option "x2" "12"
Option "y2" "2"
Option "x3" "5"
Option "y3" "3"
Option "x4" "-6"
Option "y4" "3"
Option "x5" "-4"
Option "y5" "3"
Option "x6" "0"
Option "y6" "5"
Option "x7" "1"
Option "y7" "5"
Option "x8" "1"
Option "y8" "5"
EndSection

Section "ServerLayout"
......
InputDevice "TOUCH"
EndSection
--------------------------------------------------------------------------------


Calibrate by hand


Evtouch comes with a calibration utility. It works, but I find the result is not very accurate. In fact it can be calibrated further by editing xorg.conf directly.

  • If you find when you touch the margin of the screen, the cursor is not at margin, you can change the "MinX", "MinY", "MaxX", "MaxY" in xorg.conf to calibrate.
  • The x0-y0 to x9-y9 corresponds to 9 regions on screen, with the x0-y0 at the left-bottom corner, x2-y0 at the right-bottom corner, x9-y9 at the right-top corner. To calibrate the touch screen in the region, just the values of corresponding options.

Rotate screen


To rotate screen:
xrandr --output LVDS --rotate left

evtouch should have supported rotation automatically. But the evtouch-0.8.7 in my debian does not work. I write a small patch 08__fix_rotate.patch to fix this issue.

Suspend and Resume


My touchscreen device is a usb device. This means it will be removed by Linux kernel before suspend and re-plugged after resume. Evtouch xorg driver has suspend and resume support mechansim, but it does not work sometimes. From the error message in /var/log/Xorg.0.log, it seems that the underlaying usb kernel device is not ready when evtouch xorg driver is being initialized. Fortunatally, it works sometimes. So if it your touchscreen does not work after resume, just go suspend again and hope it works after next resume.

Right Button


I am not successful in configuring right button. Maybe a kernel input driver issue, usbhid can not report BTN_TOUCHED for my device. But it seems that the following configuration should work for correct kernel input drivers.


--------------------------------------------------------------------------------
Section "InputDevice"
Identifier "TOUCH"
Driver "evtouch"
......
Option "longtouched_action" "down"
Option "longtouched_button" "3"
EndSection
--------------------------------------------------------------------------------

Thursday, April 2, 2009

IBSuite

To read book on my PRS505 e-book reader, I write some tools. Now I collect these tools into IBSuite (Image Book Suite), and put that on sourceforge. You can download the source code from the git of sourceforge project. Hope that can be useful for somebody.

http://sourceforge.net/projects/ibsuite/

IBSUITE

ibsuite stands for image book suite. It contains a set of tools to convert ebook in various format (pdf, chm, html) into a set of images, reformat the images (crop, embold, divide, etc), and assemble the result images into a new ebook.


COMPONENTS

  • ibhtml2img: convert html to image with xulrunner
  • ibhtml2pdf: convert html to pdf with xulrunner
  • iblineparser: parser input image, extract line information
  • ibpdfinfo: get some meta-information from pdf file, such as title, author, table of contents etc.
  • ibpy: python module, which is the driver of the whole system, it uses above programs to convert input file to image, extract line information from image, dilate image, and re-assemble lines into a new image, generate output e-book.
  • ibtools: A set of utilities and tools, some of them are used internal by ibsuite, others are user command provided by ibsuite.


USAGE

The most important command of ibsuite is ibreformat, the basic usage is as follow:

ibreformat [options] <input file>

In most cases, something like following:

ibreformat -o <output file> --iprof=<iprof> --oprof=<oprof>
--pprof=<pprof> <input file>

Where <input file> is input file name, <output file> is output file name, <iprof> is input profile, <pprof> is output profile, is <pprof> processing profile.

Available input/output/processing profiles are as follow:


input profiles:
img: for scanned book

output profiles:
prs505p: for Sony PRS505 in portrait mode
prs505l: for Sony PRS505 in landscape mode

processing profiles:

divide2: divide one line into two line (a kind of simple reflow)
resize: Resize and dilate pages
repage: Re-page input book, without much other processing such as dilate.

For other command line options, please refer to "ibreformat -h".


Some useful command line option combinations:

For scanned book on PRS505:

ibsuite -o -iprof=img -pprof=resize -oprof=prs505l
<input file>

For chm file on PRS505:

ibchm2imb .chm

When it finishs, .imb will be generated, then

ibsuite -o -pprof=repage --oprof=prs505l .imb


INSTALL

Currently, only Linux is supported, but I think it may work on some unix enviroment (including cygwin on Windows) after some work. Currently only install from source code is supported.

Pre-requirement:

  • gcc, g++, bash, make
  • libfontconfig-dev, libnetpbm-dev, libgtk-dev
  • python, python-imaging
  • imagemagick
  • for HTML/CHM support: python-chm, xulrunner
  • for scanned book: unpaper

Build:

./configure [--prefix=]
make [PREFIX=] [NO_XUL=1]

Install:

# become root
make install [PREFIX=]