Skip to content

libretro compliance improvements#87

Merged
nchapman merged 4 commits into
developfrom
feature/libretro-good-citizen
Dec 17, 2025
Merged

libretro compliance improvements#87
nchapman merged 4 commits into
developfrom
feature/libretro-good-citizen

Conversation

@nchapman
Copy link
Copy Markdown
Collaborator

@nchapman nchapman commented Dec 17, 2025

This PR significantly improves LessUI's libretro API compliance by implementing several missing environment callbacks and fixing fast-forward behavior. It brings the player closer to RetroArch's reference implementation while maintaining the minimal, focused design philosophy for handheld devices.

  • Implements new libretro environment callbacks (performance interface, extended messages, language, hardware render rejection, audio latency control, option visibility)
  • Fixes fast-forward speed calculations to properly report FPS-based rates instead of multipliers
  • Adds dynamic option visibility support for cores that hide/show options based on other settings
  • Includes comprehensive 536-line compliance documentation

Performance interface (GET_PERF_INTERFACE 28):
- Add CPU feature detection for ARM (NEON, VFP, ASIMD, CMOV)
- Use compile-time detection via predefined macros
- Implement timing and profiling callbacks

Core options visibility:
- Add visible field to PlayerOption struct
- Implement SET_CORE_OPTIONS_DISPLAY (55) handler
- Implement SET_CORE_OPTIONS_UPDATE_DISPLAY_CALLBACK (69)
- Invoke visibility callback on menu open and option changes
- Add OptionsMenu_invalidateList() for menu rebuild

Additional environment callbacks:
- GET_LANGUAGE (39) - returns RETRO_LANGUAGE_ENGLISH
- SET_MESSAGE_EXT (60) - extended message logging
- GET_PREFERRED_HW_RENDER (56) - returns RETRO_HW_CONTEXT_NONE

Bug fixes:
- Fix SET_VARIABLE (70) incorrect NULL pointer handling

Add libretro compliance documentation with implementation status and
recommendations for future work.
Add two new environment callbacks matching RetroArch implementation:
- GET_MESSAGE_INTERFACE_VERSION (59): Returns version 1
- SET_MINIMUM_AUDIO_LATENCY (63): Dynamic audio buffer sizing with 512ms
  cap and default floor behavior

Fix fast-forward broken by vsync/audio rewrite:
- Vsync loop: Run core multiple times per vsync (2x-5x speeds)
- Audioclock loop: Throttle vsync to 30ms during FF
- Frame time callback: Prevent timing discontinuity when FF ends
- Audio buffer status: Report inactive during FF
- GET_THROTTLE_STATE: Report FPS (e.g., 300fps) instead of multiplier

Update libretro-compliance.md with comprehensive RetroArch comparison
covering video, audio, input callbacks, environment commands, and
architectural differences.
Copilot AI review requested due to automatic review settings December 17, 2025 19:48
Copy link
Copy Markdown

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 significantly improves LessUI's libretro API compliance by implementing several missing environment callbacks and fixing fast-forward behavior. It brings the player closer to RetroArch's reference implementation while maintaining the minimal, focused design philosophy for handheld devices.

Key Changes:

  • Implements new libretro environment callbacks (performance interface, extended messages, language, hardware render rejection, audio latency control, option visibility)
  • Fixes fast-forward speed calculations to properly report FPS-based rates instead of multipliers
  • Adds dynamic option visibility support for cores that hide/show options based on other settings
  • Includes comprehensive 536-line compliance documentation

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
workspace/all/player/player_options.h Adds visible field to PlayerOption struct for dynamic option hiding
workspace/all/player/player_internal.h Adds update_visibility_callback field to Core struct
workspace/all/player/player_env.h Adds core_fps field to PlayerThrottleInfo for accurate rate reporting
workspace/all/player/player_env.c Fixes throttle state rate calculation to use FPS-based values
workspace/all/player/player.c Implements 8+ new environment callbacks, performance interface, option visibility handling, and menu invalidation
workspace/all/player/player_loop_vsync.inc Refactors fast-forward to run core multiple times per vsync with proper audio/timing handling
workspace/all/player/player_loop_audioclock.inc Adds fast-forward flip throttling and consistent audio buffer status reporting
workspace/all/common/api.h Declares SND_setMinLatency function for audio buffer adjustment
workspace/all/common/api.c Implements dynamic audio latency adjustment with proper locking and bounds checking
tests/unit/all/player/test_player_env.c Updates throttle state tests to expect FPS-based rates instead of multipliers
docs/libretro-compliance.md Comprehensive 536-line compliance analysis comparing with libretro spec and RetroArch

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread workspace/all/common/api.c Outdated
Comment thread workspace/all/player/player_loop_audioclock.inc Outdated
Comment thread workspace/all/player/player.c Outdated
Comment thread workspace/all/player/player.c Outdated
Copy link
Copy Markdown

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@nchapman nchapman merged commit 58e1138 into develop Dec 17, 2025
4 checks passed
@nchapman nchapman deleted the feature/libretro-good-citizen branch December 17, 2025 20:10
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.

2 participants