#!html <h1 style="text-align: left; color: red"> This program is not part of the current lcd4linux. This wiki entry was created for discussion about a program prototype. <br><br> </h1>
ctrl_usbmouse
\
1. Description
This external program is a Controller to interact with the Control plugin. It identifies a USB mouse (may be a second one) by its id, detaches it from the kernel (⇒ mouse won't effect other processes) and write its button and mouse wheel events to stdout.
It may be used for a first testing of the Control plugin (since a USB mouse will often be available) or mods by soldering own buttons on the board of a disassembled mouse.
\
2. Preparation
===== 2.1. Download and make
Download and extract the sources.
glibc and libusb-1.0-0-dev will be needed.
Create executable with:
gcc -o ctrl_usbmouse ctrl_usbmouse.c util.c -lusb-1.0
===== 2.2. Get the mouse id
Use the program lsusb to get the mouse id. In this example it's “046d:c050” where “046d” is the vendor id and “c050” is the product id.
Since most usb mouses have no serial number this id is used to identify the mouse. Therefore multiple mouses of the same model shouldn't be used with this program.
===== 2.3. Set privileges
Add a new rule file to /etc/udev/rules.d
Example 93.usbmouse.rules (username in example: test):
SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c050", OWNER="test"
3 Test
Run the program in test mode (option -t) to check if it works correctly and which byte value will be sent by the controller on button or wheel events. On any event the a new line with the raw bytes will be shown. If the event would result in a byte written to stdout this byte will be shown in different representations.
Use option -h to get more infos.
4. Configuration
The structure in the config-file looks like this example which configures a usb mouse controller to navigate within a menu:
Plugin Control { active 1 Controller1 { name 'C_usbmouse' prog '/home/test/lcd/ctrl/ctrl_usbmouse' arg1 '-i' arg2 '046d:c050' Key1.action menu::confirm() #left button Key2.action menu::cancel() #right button Key64.action menu::next() #wheel down Key128.action menu::prev() #wheel up } ... }
' Edit prog path and arg2 (id)! '
5. Default behavior
This controller does not read its stdin. So it's useless to call control::send(…) for this controller. The controller will return a byte on the change of button states or wheel movement. (It will send byte 0 if all buttons are released. By contrast the stop of wheel movement won't result in byte 0.)
Bits 0-5 are the states of the first 6 buttons (1 = pressed), bits 7-8 movement of the mouse wheel (bit7: 1 = wheel down, bit8: 1 = wheel up).
6. Options
Option | Description |
-h | Help |
-i <device id> | set Device ID |
-t | Testmode, see chapter 3 |
-b <index> | index of the byte which will be interpreted as button state - default: 0. Set to -1 if no button should be used |
-w <index> | index of the byte which will be interpreted as wheel action - default: 3. Set to -1 will will make all 8 bits to be used as buttton flags. |
-z | Wheel bits have to be changed for new output byte. Set this option if -w is set to a rawbyte that indicates horizontal wheel movement. |