Overview
TheNintendoSwitchBackend class provides Nintendo Switch Pro Controller emulation over USB. The controller identifies as a Hori Pokken Tournament Pro Pad, which is officially licensed and doesn’t require pairing.
This backend uses the Hori Pokken controller USB descriptor for immediate plug-and-play compatibility without Bluetooth pairing.
Platform Support
- Raspberry Pi Pico: ✅ Supported
- Arduino (AVR): ❌ Not supported
Constructor
Reference to the global input state structure that tracks all button and analog input values.
Array of pointers to input source objects (GPIO buttons, analog sticks, etc.) that provide input data.
Number of elements in the
input_sources array.USB Device Identity
The backend configures the USB device to appear as:- Manufacturer: “HORI CO.,LTD.”
- Product: “POKKEN CONTROLLER”
- Version: “1.0”
- Vendor ID:
0x0F0D(Hori) - Product ID:
0x0092(Pokken Tournament Pro Pad)
Using the Hori Pokken controller identity allows the device to work immediately without the complex pairing process required for standard Pro Controllers.
RegisterDescriptor Method
Button Mapping
The Switch backend supports all standard Pro Controller buttons:Face Buttons
- A, B, X, Y
Shoulder Buttons
- L, R (shoulder)
- ZL, ZR (trigger)
System Buttons
- Plus (Start)
- Minus (Select)
- Home
- Capture
Stick Buttons
- L3 (left stick click)
- R3 (right stick click)
D-pad
Implemented as an 8-direction hat switch:- Up, Down, Left, Right
- Diagonal directions (Up-Right, Down-Right, Down-Left, Up-Left)
- Centered (no direction)
Analog Inputs
Stick Axes
- Left Stick: X/Y (8-bit, 0-255)
- Right Stick: X/Y (8-bit, 0-255)
Deadzone and Radius Filtering
The backend applies sophisticated filtering to analog inputs:- Deadzone: 11-unit deadzone prevents drift
- Radius limiting: Ensures circular gate behavior
- Y-axis inversion: Matches Switch coordinate system
The deadzone and radius filters ensure smooth analog behavior and prevent unintended inputs from stick drift or calibration issues.
Configuration
To use the Switch backend as your primary backend:Backend ID
SendReport Method
SendReport() method handles the complete input processing pipeline:
- Scans inputs at three different speeds (slow, medium, fast)
- Waits for USB HID device to be ready
- Updates output state based on game mode logic
- Applies deadzone and radius filtering to analog inputs
- Maps outputs to Switch report format
- Sends the report via USB
Report Structure
Theswitch_gamepad_report_t structure contains:
Hat Switch Positions
The D-pad is reported as a hat switch with the following enum values:GetHatPosition() helper method calculates the correct hat value:
Usage Example
HID Descriptor Details
The backend uses a custom HID descriptor that matches the Hori Pokken controller:- Report ID: 0 (no report ID)
- Button Map: 16-bit bitfield
- Hat Switch: 4-bit value (8 directions + center)
- Analog Axes: 4 × 8-bit values (LX, LY, RX, RY)
- Vendor Input: 1 byte (reserved)
- Output Report: 8 bytes (for rumble/LEDs, handled by host)
Advantages
- No pairing required: Works immediately when plugged in
- Official protocol: Uses licensed controller identity
- Full feature support: All buttons and analog inputs
- Plug and play: No driver installation needed
Limitations
- No wireless: USB connection only (Hori controller is wired)
- No advanced features: No gyro, accelerometer, or NFC
- No rumble: Hori controller doesn’t support HD rumble
- No amiibo: No NFC reader functionality
Troubleshooting
Switch doesn’t recognize the controller
- Ensure USB cable supports data (not charge-only)
- Try a different USB port on the dock
- Verify firmware was built with Switch backend enabled
- Check that
RegisterDescriptor()was called before backend creation
Analog sticks drifting
- Adjust the deadzone value if needed
- Calibrate input sources
- Check for proper pull-up/pull-down resistors on analog pins
Buttons not responding
- Verify button mapping in your input mode
- Check that input sources are properly configured
- Test with a simpler input mode to isolate the issue
See Also
- XInputBackend - For PC gaming
- DInputBackend - For universal PC compatibility
- Input Sources - Configuring input devices
