jdmouse - SONY VAIO event handler

Kunihiko IMAI <bak@d2.dion.ne.jp>

2005/03/19

1. Components

2. Quick Start

3. jdmouse

4. blctl

5. xzoom

6. acpi3


1. Components

At a long time, people have said on jdmouse like, "Hard coding is not refined" or "Less configurable"..

At last, I found an ultimate solution.

Throw to others.

That's it!

Jdmouse only does event receiving and interpretation, invoke external programs to command execution. Then, backlight and sound volume control, which previous version of jdmouse has, was purged to externals.

But with jogdial events, because of event frequency and identity of its name, jdmouse still handles.

Here is a chart for relation of programs.


sonypi.ko -> jdmouse* -> ~/.jdmouse_event* +-> xzoom*
                |                          +-> blctl*
                V                          +-> acpi3*
             uinput.ko                     +-> amixer
                |                          + ....
                V
             /dev/input/mice
                |
                V
             mouse events on X

Programs with `*' are included in this archive.

2. Quick Start

Following procedure is for kernel 2.6.11 + debian sarge environment. On another kernels or another distributions, slightly differ :)

2.1 Sonypi Driver

  1. Make sure that your kernel has sonypi.ko. If not found it... Recompile kernel.
    $ find /lib/modules/`uname -r` -name sonypi.ko
    
  2. Edit /etc/modprobe.conf, and add following line.
    options sonypi minor=250
    
  3. Make a device file.
    # mknod /dev/sonypi c 10 250
    # chmod 666 /dev/sonypi
    

2.2 Uinput Driver

  1. Make sure that your kernel has uinput.ko. If not found it, recompile kernel, too.
    find /lib/modules/`uname -r` -name uinput.ko
    
  2. Make the device file.
    # mknod /dev/input/uinput c 10 223
    # chmod 666 /dev/input/uinput
    

2.3 X Window System

Make sure that following configuration is available in /etc/X11/XFree86-4.

Section "InputDevice"
        Identifier      "Generic Mouse"
        Driver          "mouse"
        Option          "SendCoreEvents"        "true"
        Option          "Device"                "/dev/input/mice"
        Option          "Protocol"              "ImPS/2"
        Option          "Emulate3Buttons"       "true"
        Option          "ZAxisMapping"          "4 5"
EndSection
...
Section "ServerLayout"
        ...
        InputDevice     "Generic Mouse"
        ...
EndSection

2.4 Compile and Install Jdmouse

On top directory of extracted archives, do following. Programs are installed to /usr/local/bin.

$ make
$ su
# make install

2.5 Copy and Edit Configuration File

Copy configs/dot_jdmouse_event to  /.jdmouse_event, and edit to work your favorite action.

2.6 Loading Drivers

Load the needed drivers.

# modprobe sonypi
# modprobe uinput

2.7 Running the Program

Then, run the program.

$ jdmouse &

3. jdmouse

An event interpreter for sonypi devices.

3.1 Command Line

jdmouse [-d] [-s sonypi_device_file] \
             [-e event_handler] \
             [-u uinput_device_file] [-b 1|2|3]]

3.2 Options

-d

With this option, jdmouse dumps each event to stderr.

-s sonypi_device_file

Specify sonypi defvice file. Default value is /dev/sonypi.

-e event_handler

Specify event handler. Default value is  /.jdmouse_event.

-u uinput_device_file

Specify uinput device file. Without this option, jdmouse does not convert from jogdial events to wheel mouse event, throws away them.

If you want to use jogdial events conversion of jdmouse, you must load sonypi driver with `useinput=0' option. Or your X will receive events twice, from sonypi and jdmouse, for an jogdial event.

-b 1|2|3

Specify mouse button number for jogdial click. Number is same for X mouse button. 1 =left, 2 = center ( or wheel ), 3 = right. Default value is 2 (center).

3.3 Event Handler API

Description

The event hander is called by jdmouse with following system(2) command line.

program_name event_name sequence_number
program_name

An event handling program. This is specified by jdmouse command line with -e option, or default value  /.jdmouse_event.

You can use any executable program, bash script or perl script, C executable and so on.

event_name

An event name from sonypi device driver. The name list is in /usr/include/linux/sonypi.h, which begins SONYPI_EVENT_ . On this command line API, `SONYPI_EVENT_' is omitterd. For example, when pressed Fn + F1 key, here is specified `FNKEY_F1'.

sequence_number

The sequence number for each event kind. They begin from 0.

For example, when pressed Fn + F1 key at first of running jdmouse, here is 0. Next, pressed Fn + F1 key, here is 1. Then, pressed Fn + F2 key, here is 0 not 2. Because each event kind has each counter.

You can use this number for cyclic command execution. For example, changing backlight brightness to max -> min -> max ...

An Example

There is an example script at configs/dot_jdmouse_event. Refer it.

3.4 Note

A CAPTURE button on VAIO C1 (aka picturebook) generates events with each press / release. And it has deep / half press operation. It is too complicated for external handlers to interpret the sequence. So jdmouse converts the sequence as follows:

3.5 Bugs

The sequence number on event handler API is unsigned 32 bit. So it has same problem with UNIX time. Overflow the counter, it will return to 0. But I think that it is hard for you to meet this bug, until you offer whole of your life to debugging jdmouse.

4. blctl

Backlight control.

4.1 Command Line

blctl [value]

4.2 Option

value

Numeric value of backlight brightness. You can specify from 0 to 255. 0 is most dark, 255 is most bright.

If no value is specified, print current value to stdout.

4.3 Note

I was reported that on some VAIO series the brightest value was 100, not 255.

5. xzoom

Zoom in / zoom out on X terminal

5.1 Command Line

xzoom [+|-]

5.2 Options

+|-

Specified `+' for zoom in. Or `-' for zoom out. If no option is specified, do zoom in.

5.3 Bugs

This program implements Zoom in / zoom out functions with generating key events of `right ctrl'`right alt'`keypad + or -' via uinput driver. If you remapped these keys to another function with xmodmap command, this program will not work. Or at X configration, if you configured `not zoom in / out with these keys', also will not work.

6. acpi3

Go to ACPI S3 (suspend) state.

6.1 Command Line

acpi3

6.2 Option

None.

6.3 Caution

This program works equivalent actiton with

# echo -n 3 >/proc/acpi/sleep

With installing setuid bit, normal user can execute this action. But in some case, this may be a security hole.

If so, consider using sudo management.