feat(gamepad): Switch Pro backend — Linux UHID via hid-nintendo (N2)
A virtual Pro Controller (057E:2009, BUS_USB, verbatim 203-byte USB
descriptor triple-cross-checked from real-device captures) bound by
hid-nintendo (>= 5.16): Nintendo-family client pads get correct glyphs +
POSITIONAL layout (wire south/east/west/north -> Switch B/A/Y/X, so the
physical-position <-> glyph relationship survives), live gyro/accel, and
HD-rumble feedback — instead of folding to Xbox360 (mirrored A/B + X/Y,
no motion).
- switch_proto: report-0x30/0x21/0x81 codec + the entire canned probe
conversation, pinned line-by-line against hid-nintendo.c: 0x80-family
USB acks, device info (type 0x03 + per-pad MAC), SPI-flash calibration
blobs (user magics ABSENT -> factory path; sticks 2048 +/- 1400 with
the left/right byte-order difference; IMU offsets 0 + the driver's own
default scales so raw units pass 1:1), rumble amplitude decode through
the driver's inverted joycon_rumble_amplitudes table, player lights ->
0xCD PlayerLeds. 11 new pin tests.
- switch_pro: UHID backend answering the probe from the manager's
service pass; SwitchProManager = UhidManager<SwitchProProto> (the 8 ms
heartbeat doubles as the steady 0x30 stream the driver's post-probe
rate limiter wants). switchpro-test CLI smoke.
- Router/fold: SwitchPro arms; pick_gamepad SwitchPro -> itself on Linux;
degrade_if_no_uhid covers it. SDL picker: NintendoSwitchPro + JoyconPair
declare SwitchPro.
Headless-validated on .21 (hid-nintendo 7.1): probe completes ('using
factory cal' for sticks + IMU, player-1 LED round-trips to the 0xCD
plane), gamepad + IMU input devices created, and an evdev capture pins
the positional swap (wire A/B -> BTN_SOUTH/BTN_EAST) + full-range stick
scaling. .21 clippy -D warnings + 303/0 tests; .133 clippy -D warnings.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -268,6 +268,7 @@ impl PadInfo {
|
||||
GamepadPref::DualShock4 => "DualShock 4",
|
||||
GamepadPref::XboxOne => "Xbox One",
|
||||
GamepadPref::SteamDeck => "Steam Deck",
|
||||
GamepadPref::SwitchPro => "Switch Pro",
|
||||
_ => "",
|
||||
}
|
||||
}
|
||||
@@ -298,6 +299,9 @@ fn pref_for_type(t: sdl3::gamepad::GamepadType) -> GamepadPref {
|
||||
T::PS5 => GamepadPref::DualSense,
|
||||
T::PS4 => GamepadPref::DualShock4,
|
||||
T::XboxOne => GamepadPref::XboxOne,
|
||||
// A paired Joy-Con set exposes the full Pro button surface through SDL, so it rides
|
||||
// the same virtual pad; single Joy-Cons stay on the Xbox 360 fallback (half a pad).
|
||||
T::NintendoSwitchPro | T::NintendoSwitchJoyconPair => GamepadPref::SwitchPro,
|
||||
_ => GamepadPref::Xbox360,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user