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
Get all the data necessary to set the LEDs in a single function,
returning a leds_data structure to be passed as argument to the
setup_leds() callback.
For now only a 'bitmap' field is used, which is the only thing that
set_leds_hidraw() needs.
Match hid devices and input devices using HID_UNIQ and UNIQ when these
are available, this is the correct way to get matching devices when the
controllers are connected via BT (UNIQ refers to the device bdaddr, PHYS
is the adapter bdaddr, so matching against PHYS will result in all
devices with the same LED number).
Fall back to HID_PHYS and PHYS when needed, hid devices do not define
HID_UNIQ when connected via USB.
This is in preparation for a set_leds_sysfs() function.
Make set_leds_hidraw() return void, as its return value is never used
by the caller: the setup_leds() callback has to always return FALSE.
In the case that the remote starts connecting to us while we're waiting
for the timeout to discover we shouldn't just reset the basic time
keeping variables but also remove the timer.
Properties are defined by GATT specification. This patch moves and
renames the defines related to Characteristic properties bits from
attrib/att.h to attrib/gatt.h
If /dev/urandom cannot be opened or read, just fail the plugin
initialization, as it is very unlikely that a fully working Linux system
does not have a working /dev/urandom. This also simplifies the code
logic.
For dual mode devices there are several state variables that are
independent for each bearer. This patch splits these states up into two
separate variable groups in btd_device and tracks the values based on
what kind of connection is in question.
The information is also used to select which bearer to use with
Device1.Connect and Device1.Pair. The basic rule is that the bearer
that's not connected/paired is selected, or then the bearer over which
the device was last seen is selected.
There were some valid conserns raised against marking plugged device
as trusted. Mainly due to posibility of crafted USB device. With this
patch user will be asked to confirm service connection and device can
be marked as trusted like any other devices.
After searching past the end of the structure, the loop sometimes
found matches in the daemon's address space...
This fixes the loop to end after the elements have been exhausted.
This allows to setup LEDs when device is connected over USB, not
Bluetooth. This coverts two scenarios:
- user plugged PS3 controller and pressed PS3 button before unplugging,
in that case LEDs are set
- user plugged already BT connected PS3 controller to USB, this results
in new /dev/input/jsX device being create but controller is still
transmitting over BT and old jsX device exists. In that case don't
set LEDs as they are already set.
This is not directly related to Bluetooth itself but change is really
small and provides much better and consistent user experience.
This will set controller LEDs according to joystick device number
when controller is connected over Bluetooth. If joystick number is too
big (> 7) or falied to be read, set it to 0 to switch off all LEDs.
This will allow to disable LEDs blinking after connection.
Waiting for events is not really needed when connected over Bluetooth
but this is in preparation for supporting LEDs setup over USB.
When new PS3 controller is detected provide it with default adapter
address. Also create new btd_device with proper PNP info if it wasn't
existing yet.
open()/read() is more common on BlueZ code. Incidentally, get rid of
this compilation error (using gcc 4.6.3):
plugins/autopair.c: In function ‘autopair_init’:
plugins/autopair.c:154:8: error: ignoring return value of ‘fread’,
declared with attribute warn_unused_result [-Werror=unused-result]
This patch makes the autopair plugin try a fixed "0000" pincode for
keyboards that reject the pincode too fast (less than 500ms). This too
short delay rejecting the pincode means that the user didn't have time
to type the random pincode in the bluetooth keyboard and was the
keyboard who actually rejected it.
The autopair plugin tries standard pincodes for different devices with
dumb pincodes. It also generates a random 6 digit pincode for keyboards
that support any pincode but fallbacks to the agent call in case the
random generated pincode didn't work.