-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
refactor(Joystick): Modernize joystick subsystem with SDL3 and unified Android support #13885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 |
4cda8cd to
4b0bbc7
Compare
2262f0f to
29898ce
Compare
…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>
d4ae89a to
01d1a9d
Compare
01d1a9d to
4b656ac
Compare
Summary
Changes
SDL3 Migration:
Android Integration:
Testing:
UI Improvements:
Test plan
./build/QGroundControl --unittest:JoystickTest./build/QGroundControl --unittest:JoystickManagerTest