Skip to content

Add runtime_profile#131

Open
herzmx wants to merge 7 commits into
joypad-ai:mainfrom
herzmx:runtime-profile
Open

Add runtime_profile#131
herzmx wants to merge 7 commits into
joypad-ai:mainfrom
herzmx:runtime-profile

Conversation

@herzmx
Copy link
Copy Markdown
Contributor

@herzmx herzmx commented Apr 24, 2026

This PR adds a runtime profile service (runtime_profile) that lets users remap
buttons and configure auto-fire on the fly without reflashing the firmware.

Changes

New runtime_profile service (src/core/services/profiles/)

Runtime button-mapping service with three trigger modes, all operating with profile-switch combo:

Trigger Activation Behavior
A — Sequential mode Hold SELECT alone for 2s Press buttons one by one to map them in order to fixed outputs, START cancel/clear runtime profile
B — Tap mode Hold START + 2 eligible buttons for 2s Tap a button N times to map it to output slot N, START save current map, SELECT cancel/clear runtime profile
C — Auto-fire mode Hold START + 1 eligible button for 2s Tap the target button 1–6 times to select frequency, START save, SELECT cancel/clear auto-fire

Available auto-fire frequencies: 30 Hz, 20 Hz, 15 Hz, 12 Hz, 10 Hz, 7.5 Hz
(tap sequence timeout: 800 ms).

Auto-fire support in the profile system (src/core/services/profiles/profile.h/c)

  • New autofire_period_ms field in button_map_entry_t
  • New autofire_start_ms[22] array in profile_output_t — preserved across calls
    (excluded from the memset reset)
  • New MAP_AUTOFIRE(in, out, period_ms) macro and AUTOFIRE_*HZ constants
  • profile_apply() drives auto-fire via time-based oscillation: button ON during
    the first half of each period, OFF during the second half
    • (elapsed % period) < (period / 2)

usb2neogeo integration (src/apps/usb2neogeo/)

  • Runtime profile config for 6 NeoGeo outputs (B1–B6) with a face + shoulder as input
    mask
  • app.c calls runtime_profile_init() at startup

gpio_device.c refactor

  • Extracted gpio_apply_output() helper that transparently selects the runtime profile
    or falls back to the active normal profile
  • Tap callback now stores all analog axes (lx, ly, rx, ry, l2, r2, rz) for full
    re-application
  • Periodic re-apply loop in gpio_device_task() so auto-fire oscillates even when the
    controller stops sending USB reports while a button is held
  • Profile-switch combo is suppressed during mapping mode; switching profiles normally
    clears the runtime map

@herzmx herzmx marked this pull request as draft April 24, 2026 00:36
@herzmx herzmx force-pushed the runtime-profile branch 3 times, most recently from 7781ba2 to b7e05f1 Compare April 26, 2026 20:09
@herzmx herzmx marked this pull request as ready for review April 27, 2026 01:36
@herzmx herzmx force-pushed the runtime-profile branch from bec22d2 to 5aa7d11 Compare May 7, 2026 18:21
To works with wireless controller using hold START to ON/OFF
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