Commit Graph

661 Commits

Author SHA1 Message Date
Antonio Ospite
fbe7d5226f 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
2014-06-08 14:54:41 +02:00
Antonio Ospite
1a124e4acc plugins/sixaxis: Add a get_leds_data() function
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.
2014-06-08 14:54:41 +02:00
Antonio Ospite
fdbe933252 plugins/sixaxis: Fix get_js_number() for devices connected via BT
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.
2014-06-08 14:54:41 +02:00
Antonio Ospite
1783548cf7 plugins/sixaxis: Factor out a calc_leds_bitmap() function
This is also in preparation of set_leds_sysfs().
2014-05-16 14:34:47 +02:00
Antonio Ospite
f6e6850c1e plugins/sixaxis: Factor out a set_leds_hidraw() function
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.
2014-05-16 14:34:47 +02:00
Johan Hedberg
986c3d2b1a plugins/policy: Both !uuids and !uuids[0] mean an empty list 2014-05-15 11:46:00 +03:00
Johan Hedberg
de663bfc39 plugins/policy: Remove reconnect timer in reconnect_reset()
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.
2014-05-15 11:46:00 +03:00
Johan Hedberg
f8a0c50bc6 plugins/policy: Add support to retreive ReconnectUUIDs from main.conf 2014-05-15 11:19:32 +03:00
Johan Hedberg
40e77e7b71 plugins/policy: Rename UUIDs list variable to avoid name collisions 2014-05-15 11:16:34 +03:00
Johan Hedberg
42fd4ce72c plugins/policy: Add exponential backoff for reconnection attempts 2014-05-15 11:16:34 +03:00
Johan Hedberg
c3a21d3393 plugins/policy: Continue reconnections after connect attempt failure
This patch adds support for continuing reconnecting for several more
times (up to 3 minutes) even when a connection attempt fails.
2014-05-15 11:16:34 +03:00
Johan Hedberg
e0929a6e88 plugins/policy: Add basic reconnection handling 2014-05-15 11:16:33 +03:00
Claudio Takahasi
6b09f55b09 Remove unneeded headers include 2014-04-04 21:21:42 +03:00
Claudio Takahasi
f1956438cc gatt: Move Characteristic properties to attrib/gatt.h
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
2014-03-25 17:24:01 +02:00
Claudio Takahasi
454a30731b Replace att_put_u16() by put_le16() 2014-03-24 22:11:28 +02:00
Johan Hedberg
c19756d372 core: Update btd_adapter_find_device to also match the address type
This is necessary to do accurate matching for LE devices.
2014-03-22 19:34:32 +02:00
Anderson Lizardo
ef80103f95 autopair: Remove time(NULL) fallback when seeding rand()
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.
2014-03-05 22:31:16 +02:00
Johan Hedberg
a9f523e0c3 core: Split LE and BR/EDR states for devices
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.
2014-02-21 16:15:56 +02:00
Petri Gynther
0b4da9426f core: Fix device_get_name() to always null-terminate what it returns
Fix device_get_name() to null-terminate the name string it returns.
Modify all callers as needed.
2014-02-19 06:14:17 +02:00
Marcel Holtmann
0b7482398e plugins: Use full include path for header files 2014-01-25 20:09:45 -08:00
Johan Hedberg
57a9c82aca plugins/neard: Use correct service UUID free function 2014-01-21 15:06:16 +02:00
Szymon Janc
6ed9f1552f neard: Refactor request_oob function
This makes function flow easier to follow.
2014-01-18 15:19:37 +02:00
Szymon Janc
d471ce2d77 neard: Set device UUIDs from EIR
Handle UUIDs received in EIR from neard in same way as UUIDs received
on device discovery.
2014-01-18 15:19:33 +02:00
Szymon Janc
231ac1cab9 sixaxis: Don't mark USB plugged device as trusted
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.
2014-01-09 17:54:57 +02:00
Bastien Nocera
7dfdf3f5a0 sixaxis: Fix device detection
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.
2013-12-13 11:53:52 +02:00
Szymon Janc
1787252671 sixaxis: Add support for setting LEDs when connected over USB
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.
2013-12-03 09:47:07 +02:00
Szymon Janc
67c269d171 sixaxis: Skip controller setup if already connected over Bluetooth
If controller is already connected over Bluetooth but was then
plugged-in via USB (eg. to charge battery) there is no need to do
any setup.
2013-12-03 09:46:56 +02:00
Szymon Janc
752b6b1cb6 sixaxis: Add support for setting PS3 controller LEDs
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.
2013-12-03 09:44:07 +02:00
Johan Hedberg
ffb0da64dc plugins/sixaxis: Use explicit include paths 2013-11-27 11:32:36 +02:00
Szymon Janc
8b9bd382ec plugins/sixaxis: Add support for configuring new controllers
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.
2013-11-27 11:29:30 +02:00
Szymon Janc
663e0b2f0c plugins/sixaxis: Add initial code for udev handling
When new device is added plugin will be notified about it.
2013-11-27 11:29:28 +02:00
Szymon Janc
f52aa87499 plugins: Add initial code for sixaxis plugin
This plugin will be used to associate PS3 controllers.
2013-11-27 11:29:26 +02:00
Szymon Janc
bc05407e07 Rename adapter_get_address to btd_adapter_get_address
Allow this symbol to be exported and usable from external plugins.
2013-11-27 11:21:42 +02:00
Szymon Janc
e48206fe9b Rename device_device_set_name to btd_device_device_set_name
Allow this symbol to be exported and usable from external plugins.
2013-11-27 11:20:23 +02:00
Szymon Janc
70510e5f11 Rename adapter_get_device to btd_adapter_get_device
Allow this symbol to be exported and usable from external plugins.
2013-11-27 11:19:30 +02:00
Bastien Nocera
ffd321f1e1 autopair: Add special handling for printers
As was done in gnome-bluetooth since 2009:
https://git.gnome.org/browse/gnome-bluetooth/commit/?id=7a472c151d44a3378ecbd3c2a75c763f5c577fe9
2013-11-19 15:35:19 +02:00
David Herrmann
1bbc54e1f3 wiimote: add new documented device IDs
Add some new device IDs for the LEGO wiimote and Wii U Pro Controllers.
Also add comments for each ID so we can track them better.
2013-10-18 17:25:44 +03:00
Szymon Janc
f538355c3f adapter: Handle removing of SDP records
Make adapter in charge of updating SDP database. This allow to decouple
SDP of code used for notifying adapters about SDP database change.
2013-09-23 10:43:01 +03:00
Luiz Augusto von Dentz
92d1321602 neard: Make use of g_dbus_send_message_with_reply
This replaces dbus_connection_send_with_reply with
g_dbus_send_message_with_reply which does not alter message order.
2013-09-09 17:35:30 +03:00
Dirk-Jan C. Binnema
1208266dcc attrib: Rename GATT_OPT_CHR_UUID into GATT_OPT_CHR_UUID16
Rename the option for all in-tree users. This frees up GATT_OPT_CHR_UUID to be used
for UUIDs of type bt_uuid_t* (in a next patch).
2013-07-30 12:59:12 +03:00
Luiz Augusto von Dentz
57ce0cb4c2 plugins/policy: Limit the number of retries to sink profile
The policy should only retry a limit number of times.
2013-07-12 15:05:50 +03:00
Luiz Augusto von Dentz
48e3137565 plugins/policy: Limit the number of retries to source profile
The policy should only retry a limit number of times.
2013-07-12 15:05:50 +03:00
Luiz Augusto von Dentz
f5fc3fffe5 audio/sink: Move stream retry logic to policy plugin
policy plugin is a better place to have such a logic as it is already
handling other connection policies related to such profiles.
2013-07-12 15:05:50 +03:00
Luiz Augusto von Dentz
3c29a14f84 audio/source: Move stream retry logic to policy plugin
policy plugin is a better place to have such a logic as it is already
handling other connection policies related to such profiles.
2013-07-12 15:05:49 +03:00
Luiz Augusto von Dentz
fe4cbedb1e plugins/policy: Reword audio policy code in a simple plugin
This moves audio device policy to a plugin and removes any dependency of
audio plugin to it.
2013-07-12 15:05:49 +03:00
Anderson Lizardo
83ecd743a9 core: Avoid unnecessary gboolean on pincode callback API
Use standard "bool" type instead. Callers in plugins/* are fixed on the
same commit to avoid compilation errors.
2013-06-13 17:24:20 +03:00
Anderson Lizardo
0743aa5a6f plugins: Use open()/read() instead of fopen()/fread() on autopair
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]
2013-06-13 17:24:20 +03:00
Johan Hedberg
a7171953ac autopair: Clean up coding style 2013-05-10 10:35:54 +03:00
Alex Deymo
dc3a586501 autopair: Try a fixed pincode for keyboards rejecting random codes
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.
2013-05-10 10:26:19 +03:00
Alex Deymo
4cf14a98e5 autopair: Add the autopair plugin
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.
2013-05-10 10:21:39 +03:00