Page 1 of 1

USBComposite: Nintendo Switch Controller

Posted: Fri Jan 21, 2022 3:07 am
by arpruss
I've just added a Nintendo Switch Controller to the library. It's pretty straightforward to use. It's based on the HORIPAD USB descriptor because the Switch Pro Controller is too complicated. As a result, it doesn't support gyros, and the joystick resolution is 8-bit instead of 16-bit (which is fine for my intended project which is to use it in my GameCube controller to USB adapter).

E.g:

Code: Select all

#include <USBComposite.h>

USBHID HID;
HIDSwitchController controller(HID);

void setup() {
  controller.begin();  
  while (!USBComposite);
  delay(1000);
}

void loop() {
  controller.X(16);
  controller.send();
  delay(300);
  controller.X(255-16);
  controller.send();
  delay(300);
  controller.X(128);
  controller.send();
  delay(300);
}

Re: USBComposite: Nintendo Switch Controller

Posted: Fri Jan 21, 2022 2:00 pm
by fpiSTM
Wow. Nice!
Great job!

Re: USBComposite: Nintendo Switch Controller

Posted: Mon Jan 24, 2022 3:12 pm
by arpruss
BTW, does anybody here own a GameCube USB adapter, either a Nintendo or a Mayflash one? If so, would they be able to send me a dump of its USB HID data (either with https://github.com/todbot/win-hid-dump or with https://www.systutorials.com/docs/linux ... bhid-dump/)?