Print EV_REP properties and values of those properties

Needs a bit of special treatment, EV_REP bits are not set by the kernel on
EVIOCGBIT as properties between 0 and REP_MAX are always set. Hack around
that so the output is preventing EV_REP to appear as an event.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Benjamin Tissoires 2013-03-13 17:00:53 +01:00 committed by Peter Hutterer
parent 65520efa7e
commit a79bb44230
1 changed files with 19 additions and 1 deletions

View File

@ -729,6 +729,20 @@ static void print_absdata(int fd, int axis)
printf(" %s %6d\n", absval[k], abs[k]);
}
static void print_repdata(int fd)
{
int i;
unsigned int rep[2];
ioctl(fd, EVIOCGREP, rep);
for (i = 0; i <= REP_MAX; i++) {
printf(" Property code %d (%s)\n", i, names[EV_REP] ? (names[EV_REP][i] ? names[EV_REP][i] : "?") : "?");
printf(" Value %6d\n", rep[i]);
}
}
/**
* Print static device information (no events). This information includes
* version numbers, device name and all bits supported by this device.
@ -767,7 +781,7 @@ static int print_device_info(int fd)
printf("Supported events:\n");
for (i = 0; i < EV_MAX; i++)
if (test_bit(i, bit[0])) {
if (test_bit(i, bit[0]) && i != EV_REP) {
printf(" Event type %d (%s)\n", i, events[i] ? events[i] : "?");
if (!i) continue;
ioctl(fd, EVIOCGBIT(i, KEY_MAX), bit[i]);
@ -783,6 +797,10 @@ static int print_device_info(int fd)
memset(propbits, 0, sizeof(propbits));
ioctl(fd, EVIOCGPROP(sizeof(propbits)), propbits);
printf("Properties:\n");
if (test_bit(EV_REP, bit[0])) {
printf(" Property type %d (%s)\n", EV_REP, events[EV_REP] ? events[EV_REP] : "?");
print_repdata(fd);
}
for (i = 0; i < INPUT_PROP_MAX; i++) {
if (test_bit(i, propbits))
printf(" Property type %d (%s)\n", i, props[i] ? props[i] : "?");