Skip to content
nopper edited this page Aug 20, 2011 · 2 revisions

What is keymouse?

Keymouse is just a simple mouse emulator (for Linux only) that can be controlled with keyboard. Useful on laptop with broken touch pad or in absence of external mouse device.

Configuration file

The configuration file has a very simple structure in the form of:

# This is a comment
option=value

Of course there are several parameters that should be properly set to have a working configuration. We have:

Device

The option device represents your keyboard. You have to put a link to a device file which represents your keyboard. In fact, keymouse will listen on events coming from this device and then it will transform them to specific mouse movements, according to your configuration. To found the proper device just use:

$ ls -lh /dev/input/by-id/
lrwxrwxrwx 1 root root 10 8 mar 11:12 usb-062a_USB-compliant_keyboard-event-kbd -> ../event10
lrwxrwxrwx 1 root root 10 8 mar 11:12 usb-062a_USB-compliant_keyboard-event-mouse -> ../event11
lrwxrwxrwx 1 root root 9 8 mar 11:12 usb-062a_USB-compliant_keyboard-mouse -> ../mouse2
lrwxrwxrwx 1 root root 9 8 mar 11:12 usb-Acrox_USB___PS.2_Mouse-event-mouse -> ../event9
lrwxrwxrwx 1 root root 9 8 mar 11:12 usb-Acrox_USB___PS.2_Mouse-mouse -> ../mouse1

and then choose the appropriate value. In our case the keyboard is the device file /dev/input/event10.

Udevice

On the other hand, udevice represents the path to udevice device file. Usually udevice device file is named /dev/uinput or /dev/input/uinput. If you do not have such a file in your /dev directory probably it is because you have not loaded the uinput kernel module. To load the it just type in a console sudo modprobe uinput.

Dump

dump is a flag that can be set to 0 or 1. Usually it is used in the pre-configuration phase. When it is enabled the program will just act as xev by listening at events coming from the keyboard and printing to the screen the corresponding keyvalues. As an example if you don't know at which value the spacebar is associated with, you can run keymouse in dump mode and then press the spacebar. On the screen you will see appearing the keyvalue corresponding to the spacebar button.

Max accel

max accel is the maximum acceleration or acceleration limit for the mouse pointer while moving. The default value should be ok.

Max modes

max modes is the mode keys limit. Keymouse limit is 8. This value should be equal to the number of modes you have in the configuration file. Therefore a maximum number of 8 modes is supported by the program.

Notify

notify option specifies how keymouse notifies you while in locking mode:

  • set it to 0 for no notification
  • set it to 1 to have a led notification (block num blinks 2 times)
  • set it to 2 to exec a command (see also notify exec)

Notify exec

notify exec is a path to a program you wish to execute whenever keymouse wants to notify you about entering/leaving locking mode.

Modes

modes is a sequence of integers in the form of int,int...,int. It represents the mod keys or better the starting keys of a keystroke sequence. Please be aware that the order is important to form correct keystrokes and that the value of this option will influence the action section of your configuration. Therefore pay attention while changing this string sequence because a simple change may require the change of the entire configuration file.

Bkeys

bkeys is a sequence of integers in the form of int,int...,int. It represents extra buttons that can not fit in modes but are the final part of the a keysequence.

Actions

Actions are the essential part of keymouse configuration. Valid actions are:

  • up: triggering mouse movement towards the upper part of the screen
  • down: triggering mouse movement towards the lower part of the screen
  • right: triggering mouse movement towards the right part of the screen
  • left: triggering mouse movement towards the left part of the screen
  • rup: triggering mouse movement towards upper-right part of the screen
  • rdown: triggering mouse movement towards lower-right part of the screen
  • lup: triggering mouse movement towards upper-left part of the screen
  • ldown: triggering mouse movement towards lower-left part of the screen
  • click: triggering a mouse click event
  • rclick: triggering a mouse right click event
  • 3click: triggering a mouse 3click (aka middle click or wheel click)
  • lock: enter/leave locking mode. It is like keeping the left mouse button clicked. Useful for moving windows or to execute drag and drop actions.

An action is a string in the form of:

action_name=discriminant code:index1:index2:index3: .. :

where discriminant code is the last keycode of the sequence while index1:index2:index3: says to keymouse to check if mods are pressed and held during the keystroke execution. Please note that they are index and not values. Here it comes the importance of the ordering in the modes option. Please also keep in mind of the trailing : at the end of the line.

Just for the sake of clarity we present here a small example. Assume that I want to bind the <CTRL> + <SHIFT> keystroke in order to move up the mouse cursor and the reverse keystroke <SHIFT> + <CTRL> for the opposite direction. What I have to do is:

  1. Enable the dump option in the configuration file in order to see the corresponding keyvalues. In our case CTRL = 29, SHIFT = 42.
  2. Then we have to set the modes option. In our case the first keystrokes has as starting key <CTRL> while the latter the <SHIFT>. Therefore modes should be set to modes=29,42.
  3. Now we have to configure the actions by setting up=42:0 and down=29:1.

To simplify the concept you can think at an action in these terms. By keeping in mind the modes and by reading from right-to-left we have for the up action: Provided that modes[1] -> 42 , ... is/are pressed and held if the key button corresponding to the keyval 29 is also pressed please move my mouse up

Touchscreen support

touchscreen is the boolen to enable touchscreen emulation (value = 1 enables touchscreen/touchpad emulation. Default value 0.) In touchscreen mode, coordinate changes are given in absolute coordinates (limited between 0 and touchscreen_max_x and touchscreen_max_y values)(relative changes in traditional mouse emulation), and while key is pressed down also the pressure/force indication is also sent (ie so sw can detect that emulated finger touches the screen by listening ABS_PRESSURE or BTN_TOUCH events).

Touchscreen autorepeat

touchscreen_autorepeat is the boolen to enable touchscreen repeat events (value = 1 enables repeat features. Default value 0.) This option is usefull on keyboards that don't send repeat events while key is pressed down (hardwares like N810 only sends keydown and keyup events and no repeats). With keyboard that sends autorepeats this can be disabled, but if you enable this your mouse will just move quite much faster than normally, since repeats are effectively doubled since driver will get repeats from duplicate places. Ofcourse if you want you mouse to move very fast then this is a good thing. Speed of the events can be tuned with touchscreen_autorepeat_rate value.

Touchscreen autorepeat rate

touchscreen_autorepeat_rate is the integer to tune the delay between autorepeat events (time.usec) (value = 600 use as N810 example rate. Default value 0.) By increasing the microseconds value, driver will send repeat events in slower rate. (this will tune ::select()-function timeout).

Touchscreen max x

touchscreen_max_x is the integer for max value for x-coordinate (value = 800 use as N810 example. Default value 10.)

Touchscreen max y

touchscreen_max_y is the integer for max value for y-coordinate (value = 480 use as N810 example. Default value 10.)