USBComposite: Nintendo Switch Controller

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
arpruss
Posts: 83
Joined: Sat Dec 21, 2019 10:06 pm

USBComposite: Nintendo Switch Controller

Post 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);
}
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: USBComposite: Nintendo Switch Controller

Post by fpiSTM »

Wow. Nice!
Great job!
arpruss
Posts: 83
Joined: Sat Dec 21, 2019 10:06 pm

Re: USBComposite: Nintendo Switch Controller

Post 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/)?
Post Reply

Return to “General discussion”