linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Robert Swiecki <robert@swiecki.net>
To: "Daniel J. Ogorchock" <djogorchock@gmail.com>
Cc: linux-input@vger.kernel.org
Subject: 8bitdo usb adapter 2 in the NintendoMode (hid-nintendo.ko)
Date: Wed, 26 Apr 2023 01:51:05 +0200	[thread overview]
Message-ID: <CAP145pi2dYbe_6NCe9RKpaa3643-h9iOZi8evXPFmd+8-mZgKQ@mail.gmail.com> (raw)

Hi Daniel and linux-input@vger.kernel.org,

I've recently bought a 8bitdo usb adapter 2 -
https://www.8bitdo.com/usb-wireless-adapter-2/ - and it didn't work
with Linux in its Nintendo Switch Pro mode (emulating the Nintendo Pro
Controller over the USB).

It turned out that the following func sends 2 bytes in the
JC_OUTPUT_USB_CMD, while the adapter expects 64 bytes. Maybe it
expects fewer, but that's what the yuzu emulator sends to it over
hidraw (bypassing the hid-nintendo), and it works.

static int joycon_send_usb(struct joycon_ctlr *ctlr, u8 cmd, u32 timeout)
{
  int ret;
  u8 buf[2] = {JC_OUTPUT_USB_CMD};

  buf[1] = cmd;
   ctlr->usb_ack_match = cmd;
  ctlr->msg_type = JOYCON_MSG_TYPE_USB;
  ret = joycon_hid_send_sync(ctlr, buf, sizeof(buf), timeout);
  if (ret)
   hid_dbg(ctlr->hdev, "send usb command failed; ret=%d\n", ret);
  return ret;
}

If only 2 bytes are sent, then it causes the adapter to disconnect,
probably due to some desync on the protocol level on the adapter side
of things.

[135278.921421] nintendo 0003:057E:2009.00DD: hidraw16: USB HID v81.11
Joystick [Nintendo Co., Ltd. Pro Controller] on
usb-0000:07:00.3-3.1/input0
[135280.000469] nintendo 0003:057E:2009.00DD: failed reading SPI flash; ret=-71
[135280.000473] nintendo 0003:057E:2009.00DD: using factory cal for left stick
[135280.008470] nintendo 0003:057E:2009.00DD: failed reading SPI flash; ret=-71
[135280.008473] nintendo 0003:057E:2009.00DD: using factory cal for right stick
[135280.016469] nintendo 0003:057E:2009.00DD: failed reading SPI flash; ret=-71
[135280.016472] nintendo 0003:057E:2009.00DD: Failed to read left
stick cal, using defaults; e=-71
[135280.024468] nintendo 0003:057E:2009.00DD: failed reading SPI flash; ret=-71
[135280.024471] nintendo 0003:057E:2009.00DD: Failed to read right
stick cal, using defaults; e=-71
[135280.032470] nintendo 0003:057E:2009.00DD: failed reading SPI flash; ret=-71
[135280.032473] nintendo 0003:057E:2009.00DD: using factory cal for IMU
[135280.040468] nintendo 0003:057E:2009.00DD: failed reading SPI flash; ret=-71
[135280.040471] nintendo 0003:057E:2009.00DD: Failed to read IMU cal,
using defaults; ret=-71
[135280.040472] nintendo 0003:057E:2009.00DD: Unable to read IMU
calibration data
[135280.048470] nintendo 0003:057E:2009.00DD: Failed to set report mode; ret=-71
[135280.048743] nintendo 0003:057E:2009.00DD: probe - fail = -71
[135280.048749] nintendo: probe of 0003:057E:2009.00DD failed with error -71
[135280.050014] usb 3-3.1: USB disconnect, device number 53

In case it didn't create any problems with the actual Nintendo Pro
Controller, nor with the JoyCons, could we change this code from

u8 buf[2] = {JC_OUTPUT_USB_CMD};

to

u8 buf[64] = {JC_OUTPUT_USB_CMD};

?

I know this change is a bit "out of the blue", but given that the
protocol seems to be generally undocumented and reverse-engineered,
maybe that's fine here.

Thanks in advance.

-- 
Robert Święcki

                 reply	other threads:[~2023-04-25 23:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CAP145pi2dYbe_6NCe9RKpaa3643-h9iOZi8evXPFmd+8-mZgKQ@mail.gmail.com \
    --to=robert@swiecki.net \
    --cc=djogorchock@gmail.com \
    --cc=linux-input@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 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).