Skip to content

fix(Joystick): fix 0-to-MAX trigger axis calibration and UI preview - #15032

Open
M4rkoHR wants to merge 1 commit into
mavlink:masterfrom
M4rkoHR:fix/gamepad-trigger-calibration
Open

fix(Joystick): fix 0-to-MAX trigger axis calibration and UI preview#15032
M4rkoHR wants to merge 1 commit into
mavlink:masterfrom
M4rkoHR:fix/gamepad-trigger-calibration

Conversation

@M4rkoHR

@M4rkoHR M4rkoHR commented Sep 3, 2026

Copy link
Copy Markdown
  • Lower movement delta thresholds during Joystick mode so half-axis (0-to-MAX) triggers auto-detect.
  • Update _validateAndAdjustCalibrationValues to prevent resetting valid trigger spans that do not cross 0.
  • Stretch half-axis values in _adjustChannelRawValue to display full -MAX to +MAX travel in the QML Attitude Controls preview.

Description

When calibrating a gamepad trigger or other half-axis control (which physically outputs 0 to 32767 rather than -32768 to 32767) mapped to a primary attitude control like Throttle, the calibration workflow previously suffered from three key issues:

  1. Auto-Detect Failure: Triggers resting at 0 or 16383 failed to trigger automatic stick movement detection during _inputStickDetect and _inputStickMin because the logic required crossing a hardcoded negative center threshold (0). Users were forced to manually click the "Next" button to proceed.
  2. Validation Reset: At the end of calibration, _validateAndAdjustCalibrationValues() reset any non-extension channel whose channelMin did not cross a negative lower bound (_calValidMinValue). This wiped valid trigger calibrations back to default -32768 bounds.
  3. UI Preview Clipping: Because the QML Attitude Controls preview expects a normalized -32768 to 32767 range, applying non-negative trigger inputs against default bounds caused the preview dot to sit at the middle (0) at rest and only move through the upper half of the display.

Changes Made:

  • _inputStickDetect & _inputStickMin: Lowered the movement delta requirement in Joystick mode to 8000 and updated the _inputStickMin check to compare movement relative to the captured center value rather than hardcoded 0.
  • _validateAndAdjustCalibrationValues: Added a validSpan check (channelMax - channelMin > 10000) so valid half-axis calibrations are retained rather than reset to defaults, and automatically sets channelTrim to the true midpoint when a trigger edge-resting trim is detected.
  • _adjustChannelRawValue: Added linear range normalization in Joystick mode to scale physical 0 -> 32767 inputs across the full -32768 -> 32767 range for proper QML Attitude Controls preview rendering.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/Build changes
  • Other

Testing

  • Tested locally
  • Added/updated unit tests
  • Tested with simulator (SITL)
  • Tested with hardware

Platforms Tested

  • Linux
  • Windows
  • macOS
  • Android
  • iOS

Flight Stacks Tested

  • PX4
  • ArduPilot

Screenshots

Throttle at minimum (channel 5):
image

Throttle at maximum:
image

Checklist

  • I have read the Contribution Guidelines
  • I have read the Code of Conduct
  • My code follows the project's coding standards
  • I have added tests that prove my fix/feature works
  • New and existing unit tests pass locally

Related Issues

#11017

By submitting this pull request, I confirm that my contribution is made under the terms of the project's dual license (Apache 2.0 and GPL v3).

- Lower movement delta thresholds during Joystick mode so half-axis (0-to-MAX) triggers auto-detect.
- Update _validateAndAdjustCalibrationValues to prevent resetting valid trigger spans that do not cross 0.
- Stretch half-axis values in _adjustChannelRawValue to display full -MAX to +MAX travel in the QML Attitude Controls preview.
Copilot AI balanced review requested due to automatic review settings September 3, 2026 07:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for your first pull request! 🎉

A maintainer will review this soon. Please ensure:

  • CI checks pass
  • Code follows coding standards
  • Changes tested on relevant platforms

We appreciate your contribution to QGroundControl!

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 3.33333% with 58 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.52%. Comparing base (f29efd3) to head (f31d2da).
⚠️ Report is 354 commits behind head on master.

Files with missing lines Patch % Lines
...VehicleSetup/RemoteControlCalibrationController.cc 3.33% 56 Missing and 2 partials ⚠️

❌ Your patch check has failed because the patch coverage (3.33%) is below the target coverage (30.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15032      +/-   ##
==========================================
+ Coverage   25.47%   34.52%   +9.05%     
==========================================
  Files         769      945     +176     
  Lines       65912    85676   +19764     
  Branches    30495    39492    +8997     
==========================================
+ Hits        16788    29583   +12795     
+ Misses      37285    36440     -845     
- Partials    11839    19653    +7814     
Flag Coverage Δ
unittests 34.52% <3.33%> (+9.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...VehicleSetup/RemoteControlCalibrationController.cc 31.80% <3.33%> (+31.80%) ⬆️

... and 662 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8150b0...f31d2da. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Build Results

Platform Status

Platform Status Details
Linux Passed View
Windows Passed View
MacOS Passed View
Android Passed View

All builds passed.

Pre-commit

Check Status Details
pre-commit Failed (non-blocking) View

Pre-commit hooks: 2 passed, 76 failed, 7 skipped.

Test Results

linux-coverage-integration: 52 passed, 0 skipped
linux-coverage-unit: 185 passed, 0 skipped
linux-sanitizers-integration: 31 passed, 0 skipped
linux-sanitizers-unit: 185 passed, 0 skipped
Total: 453 passed, 0 skipped

Code Coverage

Coverage: 70.6%

No baseline available for comparison

Artifact Sizes

Artifact Size
QGroundControl 253.11 MB
QGroundControl-aarch64 177.29 MB
QGroundControl-installer-AMD64 128.44 MB
QGroundControl-installer-AMD64-ARM64 70.81 MB
QGroundControl-installer-ARM64 99.55 MB
QGroundControl-linux 84.76 MB
QGroundControl-mac 84.76 MB
QGroundControl-x86_64 189.57 MB
No baseline available for comparison

Updated: 2026-09-03 09:18:52 UTC • Commit: f31d2da • Triggered by: Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants