OSDN Git Service

plugins/sixaxis: Add a set_leds_sysfs() function
authorAntonio Ospite <ao2@ao2.it>
Tue, 27 May 2014 11:25:15 +0000 (13:25 +0200)
committerSzymon Janc <szymon.janc@gmail.com>
Sun, 8 Jun 2014 12:54:41 +0000 (14:54 +0200)
commitfbe7d5226f5ff4287f065b7b3f45b6669f22f140
tree80e16e56a34d0515b62559ed57b23124eb0d72ca
parent1a124e4accb1a0d1a137bd422df3f334186b7acf
plugins/sixaxis: Add a set_leds_sysfs() function

On recent kernels the hid-sony driver exposes leds class entries in
sysfs for setting the Sixaxis LEDs, use this interface and fall back to
hidraw in case using sysfs fails (e.g. on older hid-sony versions).

Setting the LEDs via sysfs is the preferred way on newer kernels, the
rationale behind that is:

  1. the Sixaxis uses the same HID output report for setting both LEDs
     and rumble effects;
  2. hid-sony remembers the state of LEDs in order to preserve them when
     setting rumble effects;
  3. when the LEDs are set via hidraw hid-sony has no way to know the
     new LEDs state and thus can change the LEDs in an inconsistent way
     when setting rumble effects later.

Also require libudev >= 172, this is where
udev_enumerate_add_match_parent() has been first introduced.

NOTE: using udev_enumerate_add_match_parent() results in a memory leak
when enumerating child devices, this has been fixed in udev 207; the
commit which fixes the issue is this one:
http://cgit.freedesktop.org/systemd/systemd/commit/?id=51cc07576e119dea6e65478eeba9472979fd0936
configure.ac
plugins/sixaxis.c