From: Szymon Janc <szymon.janc@codecoup.pl>
To: Bastien Nocera <hadess@hadess.net>
Cc: linux-bluetooth@vger.kernel.org, Juha Kuikka <juha.kuikka@gmail.com>
Subject: Re: [PATCH 8/9] plugins/sixaxis: Add support for DualShock 4/PS4 cable pairing
Date: Wed, 27 Sep 2017 11:12:01 +0200 [thread overview]
Message-ID: <8659915.mKjsMy947m@ix> (raw)
In-Reply-To: <20170904181212.5639-8-hadess@hadess.net>
Hi Bastien,
On Monday, 4 September 2017 20:12:11 CEST Bastien Nocera wrote:
> From: Juha Kuikka <juha.kuikka@gmail.com>
>
> This patch adds support for "pairing" a Dualshock4 controller over USB
> into the sixaxis plugin, similarly to what the Sixaxis/PS3 controller
> supported.
>
> Actual bonding happens on first connection, but the device will be
> marked as trusted when the agent replies.
>
> This patch is based on DS4 supprt for sixpair tool by t0xicCode:
> https://github.com/t0xicCode/sixpair/commit/975c38cb6cd61a2f0be350714f0f64ce
> f5f0432c ---
> plugins/sixaxis.c | 73
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 72
> insertions(+), 1 deletion(-)
>
> diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c
> index b62834d72..eb15acb92 100644
> --- a/plugins/sixaxis.c
> +++ b/plugins/sixaxis.c
> @@ -83,10 +83,34 @@ static int sixaxis_get_device_bdaddr(int fd, bdaddr_t
> *bdaddr) return 0;
> }
>
> +static int ds4_get_device_bdaddr(int fd, bdaddr_t *bdaddr)
> +{
> + uint8_t buf[7];
> + int ret;
> +
> + memset(buf, 0, sizeof(buf));
> +
> + buf[0] = 0x81;
> +
> + ret = ioctl(fd, HIDIOCGFEATURE(sizeof(buf)), buf);
> + if (ret < 0) {
> + error("ds4: failed to read device address (%s)",
> + strerror(errno));
Lets prefix all sixaxis error/info logs with "sixaxis:"
> + return ret;
> + }
> +
> + /* address is little-endian on DS4 */
> + bacpy(bdaddr, (bdaddr_t*) (buf + 1));
> +
> + return 0;
> +}
> +
> static int get_device_bdaddr(int fd, bdaddr_t *bdaddr, CablePairingType
> type) {
> if (type == CABLE_PAIRING_SIXAXIS)
> return sixaxis_get_device_bdaddr(fd, bdaddr);
> + else if (type == CABLE_PAIRING_DS4)
> + return ds4_get_device_bdaddr(fd, bdaddr);
> return -1;
> }
>
> @@ -111,10 +135,34 @@ static int sixaxis_get_master_bdaddr(int fd, bdaddr_t
> *bdaddr) return 0;
> }
>
> +static int ds4_get_master_bdaddr(int fd, bdaddr_t *bdaddr)
> +{
> + uint8_t buf[16];
> + int ret;
> +
> + memset(buf, 0, sizeof(buf));
> +
> + buf[0] = 0x12;
> +
> + ret = ioctl(fd, HIDIOCGFEATURE(sizeof(buf)), buf);
> + if (ret < 0) {
> + error("ds4: failed to read master address (%s)",
> + strerror(errno));
> + return ret;
> + }
> +
> + /* address is little-endian on DS4 */
> + bacpy(bdaddr, (bdaddr_t*) (buf + 10));
> +
> + return 0;
> +}
> +
> static int get_master_bdaddr(int fd, bdaddr_t *bdaddr, CablePairingType
> type) {
> if (type == CABLE_PAIRING_SIXAXIS)
> return sixaxis_get_master_bdaddr(fd, bdaddr);
> + else if (type == CABLE_PAIRING_DS4)
> + return ds4_get_master_bdaddr(fd, bdaddr);
> return -1;
> }
>
> @@ -136,11 +184,33 @@ static int sixaxis_set_master_bdaddr(int fd, const
> bdaddr_t *bdaddr) return ret;
> }
>
> +static int ds4_set_master_bdaddr(int fd, const bdaddr_t *bdaddr)
> +{
> + uint8_t buf[23];
> + int ret;
> +
> + buf[0] = 0x13;
> + bacpy((bdaddr_t*) (buf + 1), bdaddr);
> + /* TODO: we could put the key here but
> + there is no way to force a re-loading
> + of link keys to the kernel from here. */
> + memset(buf + 7, 0, 16);
> +
> + ret = ioctl(fd, HIDIOCSFEATURE(sizeof(buf)), buf);
> + if (ret < 0)
> + error("ds4: failed to write master address (%s)",
> + strerror(errno));
> +
> + return ret;
> +}
> +
> static int set_master_bdaddr(int fd, const bdaddr_t *bdaddr,
> CablePairingType type)
> {
> if (type == CABLE_PAIRING_SIXAXIS)
> return sixaxis_set_master_bdaddr(fd, bdaddr);
> + else if (type == CABLE_PAIRING_DS4)
> + return ds4_set_master_bdaddr(fd, bdaddr);
> return -1;
> }
>
> @@ -279,7 +349,8 @@ static void device_added(struct udev_device *udevice)
> &name,
> &source,
> &version);
> - if (type != CABLE_PAIRING_SIXAXIS)
> + if (type != CABLE_PAIRING_SIXAXIS &&
> + type != CABLE_PAIRING_DS4)
> return;
> if (bus != BUS_USB)
> return;
--
pozdrawiam
Szymon Janc
next prev parent reply other threads:[~2017-09-27 9:12 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-04 18:12 [PATCH 1/9] plugins/sixaxis: Remove LEDs handling Bastien Nocera
2017-09-04 18:12 ` [PATCH 2/9] adapter: Add btd_request_authorization_cable_configured() Bastien Nocera
2017-09-04 18:12 ` [PATCH 3/9] sixaxis: Ask user whether cable configuration should be allowed Bastien Nocera
2017-09-27 9:12 ` Szymon Janc
2017-10-18 1:51 ` Bastien Nocera
2017-09-27 9:14 ` Szymon Janc
2017-10-04 12:38 ` Bastien Nocera
2017-09-04 18:12 ` [PATCH 4/9] plugins/sixaxis: Move device discovery to shared header Bastien Nocera
2017-09-05 9:03 ` Bastien Nocera
2017-09-05 9:13 ` Szymon Janc
2017-09-05 10:37 ` Bastien Nocera
2017-09-04 18:12 ` [PATCH 5/9] profiles/input: Use sixaxis header to simplify device detection Bastien Nocera
2017-09-04 18:12 ` [PATCH 6/9] profiles/input: Add DS4 devices to the shared header Bastien Nocera
2017-09-04 18:12 ` [PATCH 7/9] plugins/sixaxis: Rename sixaxis specific functions Bastien Nocera
2017-09-04 18:12 ` [PATCH 8/9] plugins/sixaxis: Add support for DualShock 4/PS4 cable pairing Bastien Nocera
2017-09-27 9:12 ` Szymon Janc [this message]
2017-10-04 12:40 ` Bastien Nocera
2017-10-18 1:51 ` Bastien Nocera
2017-09-04 18:12 ` [PATCH 9/9] plugins/sixaxis: Cancel cable pairing if unplugged Bastien Nocera
2017-09-27 9:07 ` [PATCH 1/9] plugins/sixaxis: Remove LEDs handling Szymon Janc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8659915.mKjsMy947m@ix \
--to=szymon.janc@codecoup.pl \
--cc=hadess@hadess.net \
--cc=juha.kuikka@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.