Hardware Reference
In-Depth Information
Utility input-events
When developing uinput -related code, the input-events utility is a great help. Here we run
it for event3 (the argument 3 on the command line), where the Nunchuk mouse device is:
$ input−events 3
/dev/input/event3
bustype : BUS_USB
vendor : 0x1
product : 0x1
version : 1
name : "nunchuk"
bits ev : EV_SYN EV_KEY EV_REL
waiting for events
23:35:15.345105: EV_KEY BTN_LEFT (0x110) pressed
23:35:15.345190: EV_SYN code=0 value=0
23:35:15.517611: EV_KEY BTN_LEFT (0x110) released
23:35:15.517713: EV_SYN code=0 value=0
23:35:15.833640: EV_KEY BTN_RIGHT (0x111) pressed
23:35:15.833727: EV_SYN code=0 value=0
23:35:16.019363: EV_KEY BTN_RIGHT (0x111) released
23:35:16.019383: EV_SYN code=0 value=0
23:35:16.564129: EV_REL REL_X −1
23:35:16.564213: EV_REL REL_Y 1
23:35:16.564261: EV_SYN code=0 value=0
...
The Program
The code for nunchuk.c is presented on the following pages. The source code for timed_
wait.c is shown in Chapter 1. We've covered the I2C I/O in other chapters. The only thing
left to note is the difficulty of providing a smooth interface for events produced by the
Nunchuk. Here are a few hints for the person who wants to experiment:
1.
If the mouse moves too quickly, one major factor is the timed
delay used. The timed_wait() call in line 107 spaces out read
events for the Nunchuk (currently 15 ms). This also lightens
the load on the CPU. Reducing this time-out increases the
number of Nunchuk reads and causes more uinput events to
be injected. This speeds up the mouse pointer.
The function curve() in line 349 attempts to provide a
somewhat exponential movement response. Small joystick
excursions should be slow and incremental. More-extreme
movements will result in faster mouse movements.
2.
 
Search WWH ::




Custom Search