Skip to content

Joystick: add named profile presets#3707

Open
HubMan17 wants to merge 1 commit intoArduPilot:masterfrom
HubMan17:joystick-profiles
Open

Joystick: add named profile presets#3707
HubMan17 wants to merge 1 commit intoArduPilot:masterfrom
HubMan17:joystick-profiles

Conversation

@HubMan17
Copy link
Copy Markdown

What

Adds a named profile manager on top of the ExportConfig/ImportConfig methods that landed in #3656. Users can save the current joystick configuration under a name, switch between profiles, and import/export profiles as .joycfg files for sharing.

UI

A new row appears in JoystickSetup, below the device combo:

Profile: [dropdown]  [Create]  [Delete]

The existing Export and Import buttons are kept and now operate on the active profile (Export saves the active profile to a chosen path; Import asks for a name and registers the file as a new profile). Switching profiles from the dropdown reloads the form in place, no window close/reopen.

Storage

Profiles are stored as .joycfg files in:

Documents/Mission Planner/joystick_profiles/

The .joycfg format from #3656 is reused as-is. The active profile name is persisted in Settings under the key JoystickActiveProfile.

Migration

On first run with existing joystickbutton*.xml / joystickaxis*.xml in the user data directory, those files are packaged into a profile named Default and set as active. The Default profile cannot be deleted from the UI.

Hardening of existing Export/Import

While in the area, two safety fixes:

  • ExportConfig now writes to <name>.tmp and then atomically replaces the target file. A killed process can no longer leave a half-written .joycfg.
  • loadconfig now logs XML deserialization failures via log4net instead of swallowing them in an empty catch.

Files

  • ExtLibs/ArduPilot/Joystick/JoystickProfileManager.cs (new)
  • ExtLibs/ArduPilot/Joystick/JoystickBase.cs
  • Joystick/JoystickSetup.cs
  • Joystick/JoystickSetup.Designer.cs

Out of scope

Testing

  • Solution builds clean in Release with no new warnings or errors from the new code.
  • Live tested on Windows 10 with a Radiomaster Zorro joystick:
    • First-run migration of existing XMLs into a Default profile
    • Create / Save / Switch / Delete cycles
    • Switch dialog with OK/Cancel, dropdown reverts on Cancel
    • Deleting the active profile asks for confirmation and auto-switches to the first remaining profile; the dropdown updates immediately
    • Default profile is protected from deletion
    • Import / Export round trip via .joycfg files
    • Stale JoystickActiveProfile in Settings (e.g. profile deleted between sessions) falls back to the first available profile via EnsureDefault

Adds a profile manager on top of ExportConfig/ImportConfig from ArduPilot#3656.
JoystickSetup gets a profile row (dropdown, Create, Delete). Profiles
are stored as .joycfg files in Documents/Mission Planner/joystick_profiles/.
Existing joystick XMLs are migrated to a Default profile on first run.
The Default profile cannot be deleted from the UI. Switching reloads
the form in place; deleting the active profile auto-switches to the
first remaining one.

Hardens the existing Export/Import:
- ExportConfig writes to .tmp and then atomically replaces the target,
  so a killed process cannot leave a corrupt .joycfg.
- loadconfig logs XML deserialization errors via log4net instead of
  silently swallowing them.
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