Skip to content

Conversation

@HTRamsey
Copy link
Collaborator

@HTRamsey HTRamsey commented Jan 22, 2026

Summary

  • Modernizes the joystick subsystem to use SDL3 API with helper functions and improved error handling
  • Unifies Android joystick support through SDL instead of custom JNI implementation
  • Adds comprehensive unit tests for Joystick and JoystickManager classes
  • Improves joystick indicator UI with battery status and connection state

Changes

SDL3 Migration:

  • Updated to SDL3 API (SDL_OpenJoystick, SDL_GetJoystickName, etc.)
  • Added helper functions for cleaner axis/button/hat handling
  • Improved gamepad mapping with SDL_GameControllerDB integration
  • Added battery monitoring support

Android Integration:

  • Replaced custom JoystickAndroid with SDL-based implementation
  • Added SDL Java layer (SDLControllerManager, HIDDeviceManager, etc.)
  • Input events forwarded from QGCActivity to SDL
  • Removed deprecated QGCJoystickManager.java

Testing:

  • Added JoystickTest with MockJoystick for unit testing
  • Added JoystickManagerTest for manager lifecycle testing
  • Covers axis mapping, button handling, calibration, and threading

UI Improvements:

  • Enhanced JoystickIndicator with battery level display
  • Added connected/disconnected state visualization
  • Removed unused virtualJoystickAutoCenterThrottle setting

Test plan

  • Verify joystick detection on Windows/Linux/macOS
  • Test gamepad button and axis mapping
  • Verify rumble/haptic feedback works
  • Test Android joystick with Bluetooth gamepad
  • Run unit tests: ./build/QGroundControl --unittest:JoystickTest
  • Run unit tests: ./build/QGroundControl --unittest:JoystickManagerTest

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR modernizes QGroundControl's joystick subsystem by migrating from SDL2 to SDL3 and unifying Android support through SDL instead of custom JNI. The changes include comprehensive unit tests, improved UI with battery status, and enhanced error handling.

Changes:

  • Migrated to SDL3 API with improved gamepad mapping and battery monitoring
  • Replaced custom Android JNI implementation with SDL-based joystick support
  • Added comprehensive unit tests for Joystick and JoystickManager classes
  • Enhanced UI with battery level display and connection state visualization

Reviewed changes

Copilot reviewed 46 out of 47 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/Joystick/* New unit tests using SDL virtual joysticks for testing
src/Joystick/JoystickSDL.h/cc Expanded SDL3 implementation with new capabilities
src/Joystick/JoystickManager.h/cc Simplified manager using SDL event watcher
src/Joystick/Joystick.h/cc Extended base class with new virtual methods
src/Joystick/JoystickAndroid.* Removed - replaced by SDL implementation
src/UI/toolbar/JoystickIndicator.qml Enhanced UI with battery and connection info
src/Settings/FlyViewSettings.* Removed unused joystick toolbar setting
android/src/org/libsdl/app/* SDL Java layer for Android joystick support
android/src/org/mavlink/qgroundcontrol/QGCActivity.java Input event forwarding to SDL
src/Android/AndroidEvents.* New Android event handling infrastructure
src/Joystick/CMakeLists.txt Updated to build SDL3 as shared lib on Android

@HTRamsey HTRamsey force-pushed the feature/joystick-refactor-sdl3 branch from 4cda8cd to 4b0bbc7 Compare January 22, 2026 16:10
@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2026

Build Results

Platform Status

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

Some builds failed.


Updated: 2026-01-23 11:42:33 UTC • Triggered by: Android

@HTRamsey HTRamsey force-pushed the feature/joystick-refactor-sdl3 branch 2 times, most recently from 2262f0f to 29898ce Compare January 22, 2026 17:34
…mprehensive enhancements

SDL Backend (JoystickSDL):
- Full SDL3 API migration with gamepad/joystick abstraction
- Added sensor support (gyroscope, accelerometer) with enable/disable
- Added touchpad and trackball support for modern controllers
- Added LED control (mono, RGB, player LEDs)
- Added rumble and trigger rumble support
- Added haptic/force feedback via SDL_Haptic
- Added virtual joystick support for testing
- Added comprehensive device info (GUID, serial, firmware, connection type)
- Added gamepad type detection and type-specific button labels
- Added mapping management (get/set/reload mappings)
- Added axis initial state for drift detection
- Added discovery cache for proper lifecycle management
- Extracted helper methods (_checkVirtualJoystick, _hasGamepadCapability, findBinding)

Android Backend (JoystickAndroid):
- Added sensor support (gyroscope, accelerometer) via SensorManager API 31+
- Added LED support via LightsManager API 31+
- Added battery status via BatteryState API 31+
- Added vibration support with VibrationEffect API 26+
- Added device info (vendor/product ID, serial, connection type)
- Added player index and gamepad type detection
- Added axis calibration info via MotionRange
- Added comprehensive named constants for Android APIs
- Added null safety checks and JNI memory management
- Created QGCJoystickManager.java for sensor data callbacks
- Created AndroidEvents for lifecycle management

Base Joystick Class:
- Extended virtual interface for all new capabilities
- Added Q_PROPERTY declarations for QML bindings
- Added signals for sensor data updates

JoystickManager:
- Simplified architecture with settings-based vehicle enable
- Added event handlers for SDL events (battery, touchpad, sensor, remap)
- Removed complex multi-vehicle joystick mode

Testing:
- Added comprehensive unit tests (JoystickTest, JoystickManagerTest)
- Added MockJoystick for isolated testing
- Tests cover lifecycle, discovery, calibration, button actions

UI Updates:
- Updated JoystickIndicator with battery and connection status
- Simplified JoystickComponent settings
- Removed deprecated virtualJoystick settings

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@HTRamsey HTRamsey force-pushed the feature/joystick-refactor-sdl3 branch 3 times, most recently from d4ae89a to 01d1a9d Compare January 23, 2026 11:02
@HTRamsey HTRamsey force-pushed the feature/joystick-refactor-sdl3 branch from 01d1a9d to 4b656ac Compare January 23, 2026 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant