All pastes #623490 Raw Edit

Untitled

public text v1 · immutable
·published 2007-07-17 17:08 UTC
rendered paste body
"Thumb to keys" lets you use the Joypad of your PDA for fast writing.    

The idea is from http://thumbscript.com. Maybe it is patented. I wrote them a 
lot of emails asking about the conditions but they did not respond :(.

You will have to press 2 directions to get one keycode.

This is your PDA Joypad:

    _                _ = up
 /     \             / = upper left  \ = upper right
|   m   |            | = left        m = middle button  | = right
 \     /             \ = lower left  / = lower right
    -                - = down

If you don't have a middle button or if your middle button is not mapped to 
key enter you can redefine the button (see examples for more details about
that). Siemens SIMpads have no middle button but it is possible to press
the hole joypad down. You can use this as middle button.

Because a joypad is generally a quite cool thing to play games or to surf etc. 
thumb2keys has 2 different modes. The thumbscript mode with which you are able 
to write letters or the normal mode. To switch beetween those modes you need to
press the "SWI" combination (see table) in tumbscript mode or 5 times the middle
button or the button which you set with the -k option. On SIMpads you
have to map one button with the -k option to be able to switch the table.

Here is the table:

s = start                 A          B         C (        D ?        E /
e = end                   _          s          _          s          _
press s than e         /     \    /     \    /     s    /     \    /     s
to write the first    |   m   |  |   m   |  |   m   |  |   m   |  |   m   |
letter and e than s    s     e    \     e    \     e    e     /    e     / 
to write the second       -          -          -          -          - 


  F  {       G  <      H  SWI       I |       J =         K '        L +
    _          _          _          s          s          s          s
 /     s    /     s    /     \    /     \    /     \    /     e    /     \
|   m   |  |   m   e  s   m   |  |   m   |  |   m   |  |   m   |  |   m   e
 \     /    \     /    \     e    \     /    e     /    \     /    \     /
    e          -          -          e          -          -          -
    
    
  M  ~       N  ]       O  0        P >       Q esc       R -        s :
    _          _          _          _          _          _          _
 /     \    /     \    /     \    s     \    s     \    /     \    /     \
|   m   |  s   m   |  s   m   e  e   m   |  |   m   e  |   m   |  |   m   s
 s     /    \     /    \     /    \     /    \     /    \     e    \     e
    e          e          -          -          -          s          -
    
    
  T  [       U  \         V         W "        X )        Y }        Z ;     
    _          _          e          _          _          _          _
 /     \    s     \    s     \    s     e    s     \    s     \    /     \
|   m   s  |   m   |  |   m   |  |   m   |  |   m   |  |   m   |  s   m   |
 \     /    \     e    \     /    \     /    e     /    \     /    e     /
    e          -          -          -          -          e          -

For numbers please press first the number than the middle button
To get "5" press the middle button two times.

    2
 1     3
4   5   6
 7     9
    8

To get the following keys you need to press the middle button first and than the
key you want.
    
    @
 !     #
$       ^
 &     %
    *
    
By pressing the same direction twice you will get:
    
    SHIFT
 CTRL    Backspace
TAB       Retrun
   ,     .
    SPACE

Requierments and examples:

You will need to have at least Linux Kernel version 2.6 with uinput and evdev
modules build in or loaded. To find out if they are loaded you can type as root

# lsmod | grep evdev
# lsmod | grep uinput

If there are no modules you can load them with
# modprobe evdev
and 
# modprobe uinput

If you don't have the modules look at the documentation of you distribution how
to install them.

It is also possible that the modules are build into the kernel. 

A good way to check it is to grep the kernel config.

# zcat /proc/config.gz | grep UINPUT
CONFIG_INPUT_UINPUT=y

# zcat /proc/config.gz | grep EVDEV       
CONFIG_INPUT_EVDEV=y

y means that it is build into the kernel m means that it is build in as module.

The foolstep about it is that on PDAs the file is normally disabled to save 
memory


But than you can check evdev with 
# cat /proc/bus/input/devices

If there is no such file evdev isn't build into your kernel.

To check if uinput is build into your kernel you can do a 
# ls /dev/input/uinput

If the file exists it is a good sign.

Next you have to figure out your Joypad evdev number.

To do this you have to do
# cat /proc/bus/input/devices

On my SIMpad I get this output:

root@simpad:~$ cat /proc/bus/input/devices                                      
I: Bus=0000 Vendor=0000 Product=1005 Version=0000                               
N: Name="Touchscreen panel"                                                     
P: Phys=                                                                        
S: Sysfs=/class/input/input0                                                    
H: Handlers=event0 ts0 evbug                                                    
B: EV=9                                                                         
B: ABS=1000003                                                                                                                               
                                                                                
I: Bus=0000 Vendor=0000 Product=1005 Version=0000                               
N: Name="SIMpad Switches"                                                       
P: Phys=                                                                        
S: Sysfs=/class/input/input1                                                    
H: Handlers=kbd event1 evbug                                                    
B: EV=100003                                                                    
B: KEY=300000 1680 0 0 0                                                        
                                                                                
I: Bus=0019 Vendor=0001 Product=0001 Version=0100                               
N: Name="gpio-keys"                                                             
P: Phys=gpio-keys/input0                                                        
S: Sysfs=/class/input/input2      
H: Handlers=kbd event2 evbug                                                    
B: EV=3                                                                         
B: KEY=100000 0 0 0               

The SIMpad Switches device is my joypad it has H: event1

This is the information I need.

As default thumb2keys uses event handler 0 which in this example is the 
touchscreen device. So I need to give the right event Handler to thumb2keys.

# thumb2keys -e /dev/input/event1

Is the right command line for my SIMpad.

The next thing you have to figure out is the keyevent number of your middle
key. This step is only needed if your middle key is not mapped to key enter.

If you are lucky evbug is enabled and you can do
dmesg after pressing the button you wish to get mapped.

On my SIMpad this looks like that:

# dmesg
<---snipp--->
<7>evbug.c: Event. Dev: <NULL>, Type: 1, Code: 148, Value: 1                    
<7>evbug.c: Event. Dev: <NULL>, Type: 0, Code: 0, Value: 0                      
<7>evbug.c: Event. Dev: <NULL>, Type: 1, Code: 148, Value: 0                    
<7>evbug.c: Event. Dev: <NULL>, Type: 0, Code: 0, Value: 0  

The code on my pad is 148

So my complete command line is
# thumb2keys -e /dev/input/event1 -k 148 &

the & sign is for getting the process in background. You may not need it.

If you want to boot it at start up you need to put it into your init scripts.
Please consider your distribution documentation about that.

If you have any questions or ideas please write me an email.

Have fun!

Some parts of this program are based on esekeyd, uinput_mouse.c and kbdd
which are all licenced under GPL.

This code is licenced under GPL v2.

Written by Bernhard 'mr_nice' Guillon <Bernhard.Guillon@opensimpad.org>