Skip to content

Add per-profile SOCD cleaning settings to address #1187 - #1692

Open
j-zhao wants to merge 1 commit into
OpenStickCommunity:mainfrom
j-zhao:worktree-1187-profile-extension
Open

Add per-profile SOCD cleaning settings to address #1187#1692
j-zhao wants to merge 1 commit into
OpenStickCommunity:mainfrom
j-zhao:worktree-1187-profile-extension

Conversation

@j-zhao

@j-zhao j-zhao commented Aug 12, 2026

Copy link
Copy Markdown

Addresses the SOCD portion of #1187.

Full disclosure, this was specced out with Claude Fable, with first initial review by myself.

Summary

Each profile can now override the global SOCD cleaning mode. A profile without an override uses the global setting, exactly as before. The Pin Mapping page gets a per-profile SOCD dropdown.

  • New proto message ProfileSettings { socdEnabled, socdMode } as GpioMappings.settings (field 5; field 4 stays reserved for feat: Add per-profile keyboard mapping and per-pin GPIO polarity support #1566). socdEnabled == false means "use the global setting".
  • Resolution order: SOCD slider add-on (hardware) > profile override > global. The bypass-to-neutral guard for PS3/Switch/NeoGeo/PS4 is unchanged.
  • SOCD hotkeys and the on-device display menu write to the effective source: the profile when its override is active, the global otherwise. Neither ever creates an override, and neither touches overrides while the slider add-on owns the mode.
  • Web API: the pin-mapping and profile endpoints carry socdEnabled/socdMode. Setters apply the keys only when present and in range, so older payloads leave stored overrides unchanged. getProfileOptions JSON capacity grows 500 -> 700 slots (the old budget overflowed at 4+ profiles with the new keys).

Web server fix

On-device testing exposed a latent webconfig bug: API responses are heap strings freed on connection close, but lwIP's httpd queues data by reference (assuming ROM), so a freed buffer can hit the wire as garbage. Fixed by setting HTTP_IS_DATA_VOLATILE to TCP_WRITE_FLAG_COPY in lib/lwip-port/lwipopts.h. This may also fix rare corrupted webconfig responses on current firmware.

Design notes

  • Allow SOCD settings to be stored alongside a Profile #1187 suggested ProfileOptions, but profile 1 lives outside it (config.gpioMappings), so the settings nest under GpioMappings to give every profile the same shape.
  • New/copied profiles inherit the source profile's SOCD override, matching how pins and labels copy.
  • Compatibility: old configs behave identically (override defaults off); downgrade is safe (unknown field is skipped); Config_size 21267 -> 21303 (+36 bytes, budget 32756); no migration.

Testing

CI: all boards compile (fork run). Local: nanopb regen, npm run build-proto, npx vite build.

On-device checklist:

  • Profile switch changes effective SOCD (display widget confirms).
  • Hotkey writes the profile when overridden, else the global.
  • Slider wins over an overridden profile.
  • Settings survive reboot and backup/restore; restoring a pre-feature backup preserves overrides.
  • Web UI round-trips "Use Global" and each mode for all profiles; Pin Mapping loads with zero alternative profiles.
  • OLED menu shows the effective mode under an override; a menu edit changes the override, not the global.
  • A menu session changing both profile and SOCD mode writes the mode to the newly selected profile.
image

@j-zhao
j-zhao marked this pull request as ready for review August 12, 2026 22:24
@j-zhao
j-zhao force-pushed the worktree-1187-profile-extension branch from 74d308e to 3c17884 Compare August 13, 2026 16:42
@j-zhao j-zhao changed the title #1187 profile extension Add per-profile SOCD cleaning settings to address #1187 Aug 13, 2026
Each profile can override the global SOCD mode. Addresses the SOCD
portion of OpenStickCommunity#1187.

- Add ProfileSettings message (socdEnabled, socdMode) as
  GpioMappings.settings field 5; field 4 stays reserved for OpenStickCommunity#1566.
- Resolve SOCD mode as: slider addon > profile override > global.
- SOCD hotkeys write to the effective source and never create an
  override; skipped while the slider addon owns the mode.
- The on-device display menu reads and writes the SOCD mode through
  the same profile-aware routing as the hotkeys.
- Web API: socdEnabled/socdMode on get/setPinMappings and
  get/setProfileOptions, presence-guarded and range-checked; raise
  getProfileOptions JSON capacity for the added fields.
- Web UI: per-profile SOCD dropdown on the Pin Mapping page with a
  "Use global setting" option and a slider-addon note.
- Copy webconfig response data in tcp_write; the zero-copy default
  can transmit freed heap memory (exposed by this change on device).
@j-zhao
j-zhao force-pushed the worktree-1187-profile-extension branch from 3c17884 to 2e7d094 Compare August 13, 2026 17:01
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.

1 participant