From: Bastien Nocera <hadess@hadess.net>
To: Juha Kuikka <juha.kuikka@gmail.com>
Cc: linux-bluetooth@vger.kernel.org,
Juha Kuikka <juha.kuikka@synapse.com>,
Frank Praznik <frank.praznik@gmail.com>,
roderick.colenbrander@sony.com
Subject: Re: [PATCH v2 4/4] Add new DS4 controller PID into special case handler
Date: Thu, 05 Jan 2017 12:17:03 +0100 [thread overview]
Message-ID: <1483615023.2420.23.camel@hadess.net> (raw)
In-Reply-To: <CAKvrXUpQ8b76Sc+MLLPkmmQ=ZLSP1YQSYKzep8VgJZr-sx1T0w@mail.gmail.com>
On Wed, 2017-01-04 at 11:18 -0800, Juha Kuikka wrote:
> Hi Bastien,
>
> On Thu, Dec 29, 2016 at 3:48 AM, Bastien Nocera <hadess@hadess.net>
> wrote:
> > On Wed, 2016-12-28 at 16:32 -0800, Juha Kuikka wrote:
> > > There is a special path for various game controllers where they
> > > connect
> > > to the hid service before bluetoothd knows what they are.
> > >
> > > This patch adds another PID for the Dualshock4 controller. This
> > > new
> > > PID
> > > matches with the model number CUH-ZCT2U.
> > > ---
> > > profiles/input/server.c | 6 ++++--
> > > 1 file changed, 4 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/profiles/input/server.c b/profiles/input/server.c
> > > index eb3fcf8..3576f2b 100644
> > > --- a/profiles/input/server.c
> > > +++ b/profiles/input/server.c
> > > @@ -135,8 +135,10 @@ static bool dev_is_sixaxis(const bdaddr_t
> > > *src,
> > > const bdaddr_t *dst)
> > > if (vid == 0x054c && pid == 0x0268)
> > > return true;
> > >
> > > - /* DualShock 4 */
> > > - if (vid == 0x054c && pid == 0x05c4)
> > > + /* DualShock 4 CUH-ZCT1U (PID 0x05c4)
> > > + * DualShock 4 CUH-ZCT2U (PID 0x09cc) (slim/pro)
> > > + */
> > > + if (vid == 0x054c && (pid == 0x05c4 || pid == 0x09cc))
> > > return true;
> > >
> > > /* Navigation Controller */
> >
> > Might be nice to have the struct you currently have in the sixaxis
> > plugin in a shared header, so we don't need to open code this
> > function.
> > For example:
> >
> > typedef enum {
> > CABLE_PAIRING_SIXAXIS,
> > CABLE_PAIRING_DS4
> > } CablePairingType;
> >
> > static struct {
> > int vid;
> > int pid;
> > CablePairingType type;
> > } cable_pairing_devices[] = {
> > ...
> > };
> >
>
> I agree, having the pertinent VID/PID in one place only would be a
> good idea. One small issue I see here is that it would unnecessarily
> expose internal information from sixaxis plugin.
Which internal information? I don't think you need to export any
information from the sixaxis plugin to make this work.
> > The sixaxis plugin would know which functions to use from the type,
> > the
> > input/server.c code would loop over the array to see whether it's a
> > cable pairing.
>
> Having a type field instead of the function pointers would make for a
> less clear implementation in sixaxis.c. My previous patch had an
> analogous mechanism for detecting controller type and changing
> behavior accordingly and I got some comments about a function pointer
> approach being preferred.
No, I'm not asking you to replace that. Inside the sixaxis plugin you
used to do:
set_master_bdaddr()
{
if (is_ds4()) {
...
} else if (is_sixaxis()) {
...
}
}
Here, I'm saying that when you're doing your search you should have:
setup_device()
{
if (is_ds4())
device->funcs = ds4_device_funcs;
else if (is_sixaxis()
device->funcs = sixaxis_device_funcs;
}
Or you could also use another array for that:
static struct {
DeviceType type;
SetupFunc setup_func;
PostSetupFunc post_setup_func;
} functions[] = {
CABLE_PAIRING_TYPE_DS4, ds4_setup_func, ...
And set that up in setup_device().
> I saw some patches floating around concerning a generalized cable
> pairing mechanism. Perhaps this change should be part of that?
I don't think we need something more generic at this point.
next prev parent reply other threads:[~2017-01-05 11:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-29 0:32 [PATCH v2 0/4] BlueZ: Add support for pairing the DS4 controller over USB Juha Kuikka
2016-12-29 0:32 ` [PATCH v2 1/4] sixaxis: Re-organize functions for refactoring Juha Kuikka
2016-12-29 0:32 ` [PATCH v2 2/4] sixaxis: Refactor to add device-specific functions Juha Kuikka
2016-12-29 0:32 ` [PATCH v2 3/4] sixaxis: Add support for pairing DS4 over USB Juha Kuikka
2016-12-29 0:32 ` [PATCH v2 4/4] Add new DS4 controller PID into special case handler Juha Kuikka
2016-12-29 11:48 ` Bastien Nocera
2017-01-04 19:18 ` Juha Kuikka
2017-01-05 11:17 ` Bastien Nocera [this message]
2017-01-05 19:17 ` Juha Kuikka
2017-01-06 12:17 ` Bastien Nocera
2017-08-25 18:17 ` [PATCH v2 0/4] BlueZ: Add support for pairing the DS4 controller over USB Bastien Nocera
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=1483615023.2420.23.camel@hadess.net \
--to=hadess@hadess.net \
--cc=frank.praznik@gmail.com \
--cc=juha.kuikka@gmail.com \
--cc=juha.kuikka@synapse.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=roderick.colenbrander@sony.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).