Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp1280471pxy; Thu, 6 May 2021 04:50:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzI7Qnpdv9L/OL6G5S+ufY1tn9TWTg9rGo3zXvLb9UWI8OBefgDVAyc1GRiSOKiQcqLxwm4 X-Received: by 2002:a17:906:739c:: with SMTP id f28mr3814802ejl.259.1620301856268; Thu, 06 May 2021 04:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620301856; cv=none; d=google.com; s=arc-20160816; b=weP9fMtFDyBMLNbyH1hJnUmW+ipCVWK8FiZ1gZ4qiYnmCx9uc0R2KWFATzhryYU2Ok jsV8B1Mo+GVdU5Fddp55rtOl40sQbNMgmXLgRb5wbAqu8ldFAOy12AsMd1HIMEsmycls kFFac25nknSlIIf1sy8zeZ43UiA1Fj/jrWf4xH1yYVVBIDuoNBt9goVkWSj+TqfcHKWy /6PHlclB4UkTTh+nUIZZmCfSmdPiMxwlgo7UVlIdKyoceGe8MSBbcRLk8SozfDK5SCIh ULEG0Y4ozcdkN8E49kPb2teyefyBTpR8PiuZMoFOz5xcFkAfwrSNxVil3BqwA5Wuas+q ncNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:jabber-id:message-id:subject:cc:to:from:date; bh=LX3Ax71ogo1OTvfVz6m0msV2NedDVZ9Uw3wBDgToTSw=; b=lJCeZkQwfVioaiMzlrkDr7IHEtjRbrE3DaLehB85IBhaYW7Rx8v5OdltVnp39nFu7j 7N9CyqMpo/OOoNm4pQCbbmBGYhg50zc7wQga3GvFzw1pFdFDME3ymy6WynfXI8Hdc3AX FCcyZu7wp+vdCdm/u1PYAPypGvK851z9JEvnpSJBm/w4Dy2rapnCj7Y38SkrBhrLI9k+ bcemYj5kpoXdl9G3XJgyMi0KAJ5Tvw0t+oXRz2iM7vRo8SocYSN8tCSlYifYX2FqinUl TKBRg10LxhFDIjRu0vWkVrqvWbT+LxCxC1Z0Kg2AnErclrQVsPYINy+2MosxlsEaArak iveg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x26si2204173edv.23.2021.05.06.04.50.32; Thu, 06 May 2021 04:50:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233707AbhEFKIN (ORCPT + 99 others); Thu, 6 May 2021 06:08:13 -0400 Received: from 82-65-109-163.subs.proxad.net ([82.65.109.163]:49506 "EHLO luna.linkmauve.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233573AbhEFKIL (ORCPT ); Thu, 6 May 2021 06:08:11 -0400 Received: by luna.linkmauve.fr (Postfix, from userid 1000) id C2EB0F4059A; Thu, 6 May 2021 12:07:05 +0200 (CEST) Date: Thu, 6 May 2021 12:07:05 +0200 From: Emmanuel Gil Peyrot To: Jonathan =?utf-8?Q?Neusch=C3=A4fer?= Cc: linux-input@vger.kernel.org, Ash Logan , Jiri Kosina , Benjamin Tissoires , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/4] HID: wiiu-drc: Add a driver for this gamepad Message-ID: <20210506100705.5bcpywy25kfqwgkn@luna> Jabber-ID: linkmauve@linkmauve.fr References: <20210502232836.26134-1-linkmauve@linkmauve.fr> <20210502232836.26134-2-linkmauve@linkmauve.fr> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jtw7k5qsxufz3nus" Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --jtw7k5qsxufz3nus Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 05, 2021 at 10:33:15PM +0000, Jonathan Neusch=C3=A4fer wrote: > Hi, Hi, >=20 > some mostly trivial remarks and questions of curiosity below, because > I'm not very qualified to review the input subsystem side of things. Thanks for the questions anyway, I can probably make things clearer in the patch thanks to them. :) [=E2=80=A6] > Out of curiosity: >=20 > Do the HID reports travel over the wireless link from DRC to DRH, or are > they formed in DRH firmware? This HID report is a 1:1 copy of what the DRC sends, with no modification that I could find. >=20 > Is there a reference of the device-specific HID format? I briefly looked > at https://libdrc.org/docs/index.html but couldn't find it there. You were very close, the input report is described here: https://libdrc.org/docs/re/sc-input.html This project wrote a userland driver for using the DRC without the DRH, but it requires a very specific wifi chip which makes it quite cumbersome to use. >=20 >=20 > > drivers/hid/Kconfig | 7 + > > drivers/hid/Makefile | 1 + > > drivers/hid/hid-ids.h | 1 + > > drivers/hid/hid-quirks.c | 3 + > > drivers/hid/hid-wiiu-drc.c | 270 +++++++++++++++++++++++++++++++++++++ > > 5 files changed, 282 insertions(+) > > create mode 100644 drivers/hid/hid-wiiu-drc.c > >=20 > > diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig > > index 4bf263c2d61a..01116c315459 100644 > > --- a/drivers/hid/Kconfig > > +++ b/drivers/hid/Kconfig > > @@ -1105,6 +1105,13 @@ config HID_WACOM > > To compile this driver as a module, choose M here: the > > module will be called wacom. > > =20 > > +config HID_WIIU_DRC > > + tristate "Nintendo Wii U gamepad over internal DRH" >=20 > gamepad (DRC) >=20 > ... so it's clearer where the "DRC" name comes from. Will do in v2. >=20 > > +#if IS_ENABLED(CONFIG_HID_WIIU_DRC) > > + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO= _WIIU_DRH) }, > > +#endif >=20 > Is the DRC connection the only USB function that the DRH provides? As far as I know, yes. But the DRC also sends microphone and camera data, which gets exposed by the DRH, but juuuuuust not quite standard enough to work as is using snd_usb_audio or uvcvideo. There is also a NFC reader which no one has reversed yet to my knowledge. There are two DRCs exposed by the DRH, despite only one of them being bundled with each Wii=C2=A0U, and no game ever making use of more. >=20 >=20 > > +++ b/drivers/hid/hid-wiiu-drc.c > > @@ -0,0 +1,270 @@ > > +// SPDX-License-Identifier: GPL-2.0-or-later > > +/* > > + * HID driver for Nintendo Wii U gamepad, connected via console-intern= al DRH >=20 > gamepad (DRC) Ack, will be fixed in v2. >=20 >=20 > > +static int drc_raw_event(struct hid_device *hdev, struct hid_report *r= eport, > > + u8 *data, int len) > > +{ > > + struct drc *drc =3D hid_get_drvdata(hdev); > > + int i; > > + u32 buttons; > > + > > + if (len !=3D 128) > > + return 0; >=20 > From include/linux/hid.h: >=20 > * raw_event and event should return negative on error, any other value w= ill > * pass the event on to .event() typically return 0 for success. >=20 > Not sure if returning 0 as you do above is appropriate. Oops, thanks for noticing, this will be fixed in v2. >=20 >=20 > > +static bool drc_setup_joypad(struct drc *drc, > > + struct hid_device *hdev) > > +{ > > + struct input_dev *input_dev; > > + > > + input_dev =3D allocate_and_setup(hdev, DEVICE_NAME " Joypad"); >=20 > "Nintendo Wii U gamepad Joypad" looks a bit sub-optimal, but I'm not > sure about the conventions here. "Nintendo Wii U gamepad buttons and sticks" would be better I think. >=20 >=20 > > + > > + /* These two buttons are actually TV control and Power. */ > > + set_bit(BTN_Z, input_dev->keybit); > > + set_bit(BTN_DEAD, input_dev->keybit); >=20 > Hmm... from what I've deen the TV control button opens a menu on the > gamepad itself. Does it send the input event in addition to that? > Or is there a mode where it opens the TV menu, and a mode where it > forwards the button press to the Wii U? It does draw a line of text near the bottom of the screen, saying =E2=80=9C= TV Remote can be configured in System Settings.=E2=80=9D, but also sends the b= utton as a normal button in the report. It could be possible to change its behaviour (in System Settings perhaps?) but so far I=E2=80=99ve been avoidi= ng interacting with the proprietary OS. The power button also has a special behaviour: when it is held for four seconds, it will power off the DRC. >=20 >=20 > > +MODULE_AUTHOR("Ash Logan "); >=20 > Since you're submitting the driver, rather than Ash, maybe adjust the > author field here? (totally your choice.) I=E2=80=99ll ask them, I=E2=80=99m perfectly fine with becoming the author,= but they wrote most of that code, I only fixed the last few missing pieces and did some cleanup. >=20 >=20 >=20 > Thanks, > Jonathan Thanks! --=20 Emmanuel Gil Peyrot --jtw7k5qsxufz3nus Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEjrVT1SzTln43kCLJOWgfYkb2LpAFAmCTv8AACgkQOWgfYkb2 LpCeaAf/X3dtreCXE5NVSLSA0zloCS5Y7WAPlshsE2Zc8NCVKcRPNamkHSFWtENf +OkJ6mZyQ8dGBEwqlrxPMyn1mL8FnIgvZOeNfIzCbNcodpdfLoL+noM+7hrOQRUj 0vACbVkhCVYT3Gu9cDE9/2wQLHnvm/W1u4RWeWO2YLb+hjFzyWx4DmE2AdL2KeWw gy9BDiH6eao3StD3p1mhuMtg9YQD5Dj6C+c0hvzNRx9933fS+CvBsEQqVNpCdczi giGJ9vbngW83Y+OcRcfJIMwL4yKsI/ABngFwy6t4IWIN1lP73o5T56Kei6y0idlO kBHFMKSy3SAq/MVOyBsUIhv871tnXw== =F43R -----END PGP SIGNATURE----- --jtw7k5qsxufz3nus--