Skip to content

feat: DualSense + Switch Pro types + thin-catalog default-to-first - #31

Merged
emir-hasanbegovic merged 2 commits into
mainfrom
feat/controller-types-dualsense-switchpro
Jul 23, 2026
Merged

feat: DualSense + Switch Pro types + thin-catalog default-to-first#31
emir-hasanbegovic merged 2 commits into
mainfrom
feat/controller-types-dualsense-switchpro

Conversation

@emir-hasanbegovic

@emir-hasanbegovic emir-hasanbegovic commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What

Adds two sender-side controller types that auto-detect from the physical SDL pad. Dish is a sender — it never materializes pads — so the type is purely cosmetic metadata that rides the REST descriptor to the receiver, which picks a matching virtual pad. No user picker; no protocolVersion bump (additive contract ids).

id name key caps
2 dualsense rumble, analogTriggers, motion, lightbar, touchpad
3 switchpro rumble, motion

(id 0 xbox, id 1 playstation/DS4 unchanged.)

Changes

  • Protocol.h — add kControllerTypeDualSense = 2, kControllerTypeSwitchPro = 3.
  • SDLGamepadBridge.cppsdlTypeToControllerType splits SDL_CONTROLLER_TYPE_PS5 out to DualSense and maps SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO to SwitchPro. PS3/PS4 stay PlayStation (DS4); everything else stays Xbox. (This TU keeps its own copy of the type constants, extended to match.) Refreshed the now-stale mapping comments.
  • WifiConnection.cppdesiredDescriptor()'s type→touchpadMode rule is widened via a small touchpadModeForType helper: DualSense has a trackpad so it also maps to ds4; Switch Pro has none so stays off.
  • test_models.cpp — mirrored assertions: a DualSense descriptor emits type==2 & touchpadMode=="ds4"; a Switch Pro descriptor emits type==3 & touchpadMode=="off".

Verification

scripts/ci_local.sh --no-tidy all green natively (macOS, Homebrew Qt6/SDL2/libsodium): clang-format, Debug configure+build, ctest 235/235 passed, Release build. clang-tidy and the container/GCC pass (GCC-only -Wshadow) are the follow-up; no shadowing introduced here (the new helper is a free function with a type param and no enclosing type).


Thin-catalog update (default-to-first; gains a catalog fetch)

This branch now also carries the thin-catalog client change.

  • dish-linux GAINS a catalog fetch it never had: HTTPClient::getCatalog (unauthenticated GET /api/catalog) + a small ServerCatalog DTO/parser, fetched once per connection before the session PUT.
  • Defaults the sent type to controllerTypes[0] and sources touchpadMode from that type's catalog features. Removed sdlTypeToControllerType and the pad-derived type plumbing.
  • Behaviour change (intended interim): linux no longer auto-selects the emulated type from the physical pad — it always sends the first offered type (the deferred-SDL-match design; the host's new emulates hint preserves the info for a later matcher). A user picker is a separate follow-up. Falls back to type 0 / touchpad off when no catalog.
  • Tolerates the new emulates field. Verified: ci_local.sh ctest (native macOS/clang) and g++ in the dish-linux-ci container (239/239).

Auto-detect two new sender-side controller types from the physical SDL pad,
riding only the REST descriptor (no user picker, no protocolVersion bump):

- id 2 dualsense: SDL PS5 pads. Touchpad → touchpadMode=ds4.
- id 3 switchpro: SDL Switch Pro pads. No trackpad → touchpadMode=off.

sdlTypeToControllerType now splits PS5 out to DualSense and maps
SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO to SwitchPro; PS3/PS4 stay
PlayStation (DS4), everything else Xbox. The type→touchpadMode rule in
desiredDescriptor() is widened via a small helper so DualSense also routes
its trackpad as ds4.
Fetch GET /api/catalog when a session opens and default the sent
controller type to the first offered type, replacing the SDL-derived
type decision. The chosen type's catalog entry also drives touchpadMode
(ds4 when advertised, else off). Physical-pad matching stays deferred; an
unreachable/older satellite falls back to type 0 / touchpad off.

- Models: CatalogType / ServerCatalog DTO + lenient parser (id + whether
  features.touchpad.modes contains "ds4"; tolerates an emulates block).
- HTTPClient::getCatalog -- unauthenticated GET, clones getSession.
- WifiConnection caches the catalog (fetched once per connection, before
  the PUT) and sources desiredDescriptor's type + touchpadMode from it.
- WifiConnectionManager gates openSession on the catalog fetch.
- Remove sdlTypeToControllerType, the ConnectionHub controller-type seam,
  AppModel's setControllerTypeFn, and the bridge's per-device type map.

A user-facing type picker is a separate follow-up.
@emir-hasanbegovic emir-hasanbegovic changed the title Add DualSense + Switch Pro controller types feat: DualSense + Switch Pro types + thin-catalog default-to-first Jul 23, 2026
@emir-hasanbegovic
emir-hasanbegovic merged commit 01598c2 into main Jul 23, 2026
7 checks passed
@emir-hasanbegovic
emir-hasanbegovic deleted the feat/controller-types-dualsense-switchpro branch July 23, 2026 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants