2012-01-05 13:07:25

by Thomas Perl

[permalink] [raw]
Subject: Device-initiated HID connections: How to pair? (PS Move)

Hi,

I'm working on getting the PS Move Controller to work with Linux[1].
Right now, I'm disabling bluetoothd's "input" plugin and listen to the
two l2cap sockets directly, which is ugly and prevents using "normal"
Bluetooth HID devices together with a PS Move controller. Ideally, I
want bluetoothd to accept the connection and use Linux' hidraw
interface to communicate with the controller. The GUI pairing in GNOME
3 doesn't work, no matter what PIN mode (automatic, 0000, do not pair)
I select. On Windows, it works after pairing it without PIN, and OS X
apparently allows the connection without any question or pairing.

Is there any way to tell bluetoothd "here's a Bluetooth address, and
if you get a HID connection from it, accept the connection"? I added
an entry "XX:XX:XX:XX:XX:XX [all]" to
/var/lib/bluetooth/YY:YY:YY:YY:YY:YY/trusts, but this entry gets
removed at first connection (the X-address being the controller's
address and the Y-address being my host adapter's address) and I'm
pretty sure that I'm not supposed to hand-edit files in
/var/lib/bluetooth/ ;) When pressing the PS button on the controller
(which tries to establish a Bluetooth connection with the host), I
get:

bluetoothd[5487]: Refusing input device connect: No such file or directory (2)

The pairing works about the same way as with the Sixaxis controller
(use USB HID feature reports to "upload" the Bluetooth host address to
the controller, and then the controller will connect to this address
as HID device).

I'd be also be grateful for any hints on where to start writing a
patch if device-initiated HID connections are not supported - I dug
around a bit in bluetoothd's input module code, but got stuck.

I'm using Bluez in Debian, with the following package versions installed:

ii bluetooth 4.96-3
ii bluez 4.96-3
ii bluez-alsa 4.96-3
ii bluez-cups 4.96-3
ii bluez-gstreamer 4.96-3
ii bluez-hcidump 2.1-1
ii gir1.2-gnomebluetooth-1.0 3.2.1-1
ii gnome-bluetooth 3.2.1-1
ii libbluetooth-dev 4.96-3
ii libbluetooth3 4.96-3
ii libgnome-bluetooth8 3.2.1-1

Thanks for any help or pointers :)
Thomas

[1] http://thp.io/2010/psmove/


2012-01-05 16:57:34

by Antonio Ospite

[permalink] [raw]
Subject: Re: Device-initiated HID connections: How to pair? (PS Move)

On Thu, 5 Jan 2012 14:07:25 +0100
Thomas Perl <[email protected]> wrote:

> Hi,
>
> I'm working on getting the PS Move Controller to work with Linux[1].
> Right now, I'm disabling bluetoothd's "input" plugin and listen to the
> two l2cap sockets directly, which is ugly and prevents using "normal"
> Bluetooth HID devices together with a PS Move controller. Ideally, I
> want bluetoothd to accept the connection and use Linux' hidraw
> interface to communicate with the controller. The GUI pairing in GNOME
> 3 doesn't work, no matter what PIN mode (automatic, 0000, do not pair)
> I select. On Windows, it works after pairing it without PIN, and OS X
> apparently allows the connection without any question or pairing.
>

I worked on the Sixaxis pairing and the mechanism should be similar
read below.

> Is there any way to tell bluetoothd "here's a Bluetooth address, and
> if you get a HID connection from it, accept the connection"? I added
> an entry "XX:XX:XX:XX:XX:XX [all]" to
> /var/lib/bluetooth/YY:YY:YY:YY:YY:YY/trusts, but this entry gets
> removed at first connection (the X-address being the controller's
> address and the Y-address being my host adapter's address) and I'm
> pretty sure that I'm not supposed to hand-edit files in
> /var/lib/bluetooth/ ;) When pressing the PS button on the controller
> (which tries to establish a Bluetooth connection with the host), I
> get:
>
> bluetoothd[5487]: Refusing input device connect: No such file or directory (2)
>

Just setting the "trust" file is not enough TTBOMK, you have to set also
a "did" (device ID? ) file with the SDP record relative to the device.

> The pairing works about the same way as with the Sixaxis controller
> (use USB HID feature reports to "upload" the Bluetooth host address to
> the controller, and then the controller will connect to this address
> as HID device).
>

Are the Feature reports the same as the Sixaxis? (0xF2 to read the
device bdaddr and 0xF5 to read and write the master bdaddr?).

> I'd be also be grateful for any hints on where to start writing a
> patch if device-initiated HID connections are not supported - I dug
> around a bit in bluetoothd's input module code, but got stuck.
>

Check out these patches for the BlueZ playstation-peripheral plugin:

http://ao2.it/tmp/__tmp_bluez_playstation-peripheral_plugin.patch

(apply with "git am" on top of 474c85f), in particular the
btd_device_set_trusted() bits (use a clean /var/lib/bluetooth for a
sane run).

The plugin supports only the sixaxis for now, but it is written
with other devices in mind. Tell me if you want me to add you to the CC
list when I submit them again for inclusion in BlueZ.

Regards,
Antonio

P.S. Thomas you can contact me on IRC or via XMPP/Gtalk as well, look at
http://ao2.it/en/contact

--
Antonio Ospite
http://ao2.it

A: Because it messes up the order in which people normally read text.
See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?


Attachments:
(No filename) (2.91 kB)
(No filename) (198.00 B)
Download all attachments

2012-01-05 14:14:39

by Daniele Forsi

[permalink] [raw]
Subject: Re: Device-initiated HID connections: How to pair? (PS Move)

2012/1/5 Thomas Perl:

> I'm working on getting the PS Move Controller to work with Linux[1].

> The GUI pairing in GNOME
> 3 doesn't work, no matter what PIN mode (automatic, 0000, do not pair)
> I select.

if the other PS3 controllers work, it should work if there is an entry
for your it in the PIN database in
/usr/share/gnome-bluetooth/pin-code-database.xml
if it is missing then adapt one of the other PS3 entries and please
inform the GNOME Bluetooth developers so it can be added to the next
release (or tell it to me and I will take care of this)

> ii ?gnome-bluetooth ? ? ? ? ? 3.2.1-1

in version 3.2 the PIN dialog was slightly broken and in some cases
you wouldn't be able to choose the option to not pair; this is fixed
in version 3.3.3, which is the current git HEAD

--
Daniele Forsi