Skip to content

Improve controller detection before autoboot and reduce module loading overhead - #42

Open
tganet-oliveira wants to merge 1 commit into
wiiu-env:mainfrom
tganet-oliveira:fix/pro-controller-startup
Open

tganet-oliveira wants to merge 1 commit into
wiiu-env:mainfrom
tganet-oliveira:fix/pro-controller-startup

Conversation

@tganet-oliveira

Copy link
Copy Markdown

Summary

Improve external controller detection during startup and remove redundant work during module loading.

Controller detection

Previously, EnvironmentLoader initialized KPAD and immediately checked controller input once before starting the default environment. External controllers may not have samples available at that point, causing a held X button to be missed.

This change:

  • Polls controller input for up to one second before starting the default environment.
  • Opens the selection menu immediately when X is detected.
  • Polls all supported controller channels without waiting for GamePad samples first.
  • Explicitly reads the Pro Controller fields from KPADStatus.
  • Reuses the Classic Controller button mapping for the Pro Controller, as the menu buttons share the same bit values.
  • Documents X on the GamePad, Pro Controller, and Classic Controller, and 1 on the Wii Remote.

The polling window is skipped when the selection menu must open because no valid default environment is configured.

An environment path supplied by IOSU continues to bypass the SD configuration and startup button check.

Startup tradeoff

When a default environment is configured and X is not detected, the polling window adds approximately one second before autoboot. This gives external controllers time to provide input samples after initialization.

The controller initialization timing is a suspected cause of the reported issue; hardware testing is still needed to confirm the fix.

Module loading optimizations

  • Construct the ELF symbol table accessor once per relocation section rather than once per relocation entry. Its constructor performs an internal hash-section search.
  • Reuse map lookup results when resolving loaded RPL libraries and import information.
  • Remove the explicit setup module sort because the DirList constructor already sorts the entries.

These changes reduce repeated work while preserving module execution order.

No performance measurements have been collected, so the actual startup improvement remains unverified.

Validation

  • git diff --check passed.
  • Compilation has not been performed because Docker and the Wii U toolchain were unavailable in the development environment.
  • Wii U hardware testing is pending.

Hardware validation checklist

  • Holding X on the GamePad opens the selection menu.
  • Holding X on a paired Pro Controller opens the menu without a connected GamePad.
  • Holding X on a Classic Controller opens the menu.
  • Holding 1 on a Wii Remote opens the menu.
  • Autoboot completes when no startup button is held.
  • Autoboot completes when no controller is connected.
  • The menu opens immediately when no valid default environment is configured.
  • Menu navigation and environment selection continue to work.
  • Setup modules execute successfully in the same order.

Related issue

Refs #ISSUE_NUMBER

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