tools: add capture_usbmon.py

this is a tool which fetch the usbmon raw data, the evemu output and the
corresponding hid traces in one call.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-replay: silent one compiler complain

hid-replay.c:165:2: warning: pointer targets in passing argument 1 of ‘strlen’ differ in signedness [-Wpointer-sign]
  len = strlen(dev->name);
  ^
In file included from hid-replay.c:40:0:
/usr/include/string.h:395:15: note: expected ‘const char *’ but argument is of type ‘__u8 *’
 extern size_t strlen (const char *__s)
               ^

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-recorder: silent some -Wall warnings

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-recorder: silent one valgrind memleak error

filename was allocated in case of an autodetection. Storing it for later
and destroying it at the termination of the program silents valgrind.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-recorder: store device attributes in one struct

We want to record several devices at the same time in one call.
The first step is to group all of the state of a recording in a struct.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-recorder: cleanup the device when Ctrl-C is pressed

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-recorder: fetch_hidraw_information should also take a hid_recorder_device

allows to add fields in the struct and reuse them in
fetch_hidraw_information.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-replay: create a struct hid_replay_device

Will allow to have several devices in the same hid-replay file.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
add list implementation from ccan

licensed under BSD-MIT

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-replay: allow several devices to be described in one file

We are using a tag "D:" which switches from one device to an other.
This is a backward-compatible change which allows to have several
hidraw recording (one per usb interface for instance) in the same file.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
tools: usbmon2hid-replay: convert the script to multi-device handling

Remove the 'nomem' flag because now we can multiplex several devices
in one file. This also removes print_hid_replay() and
print_hid_replay_dev() because nobody uses them anymore.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
tools: capture_usbmon: use a bigger usbmon buffer

For some devices, 256 bytes is not enough. Use 512.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-recorder: store and use the device index

Actually use it so that when several devices are multiplexed, the device
index is produced.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-recorder: calloc the list of recorded devices

hid-replay can replay several multiplexed devices at a time, hid-recorder
should be able to record several at a time.

First step is to calloc the list of devices, so we can have a random
number of recorded devices.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-recorder: implement poll of multiplexed devices

hid-recorder can now record several hidraw device nodes at a time.

Add a note in the usage.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-recorder: handle device disconnect

With polling, device disconnects are a little bit more tricky to handle.
We need to close the device, and remove it from the list of polled device.

To be consistent with the index, we need to also stack the existing devices
to the left in fds and devices.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-replay: install signal handler

Alows to clean up gently the allocated memory when hitting Ctrl-C

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Release version 0.7

- Allow to multiplex several hidraw nodes with the tag "D:"
- lots of valgrind memleaks fixed
- add a GUI to edit the report descriptors in tools (requires Python and Qt)
- add several tools in the tools directory to automate capturing from usbmon
  and evemu

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
hid-recorder: start time should be global, not per device

When multiplexing devices, the origin of the time is global accross
devices. Using a per device start time does not give any benefit.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Release 0.7.1

- forgot about the starttime which was not global

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>