Skip to content

Fix vWii autoboot hanging when no GamePad is connected - #69

Open
patapovich wants to merge 1 commit into
wiiu-env:mainfrom
patapovich:fix-vwii-autoboot-without-gamepad
Open

patapovich wants to merge 1 commit into
wiiu-env:mainfrom
patapovich:fix-vwii-autoboot-without-gamepad

Conversation

@patapovich

Copy link
Copy Markdown

Fixes #67.

Problem

Autobooting into the vWii System Menu (or vWii HBC) hangs on a permanent black screen when the GamePad is powered off. The same launch works fine when selected manually from the boot selector, and connecting the GamePad makes autoboot work — matching the report in #67.

Root cause (two parts)

  1. Timing: on autoboot, launchvWiiTitle() runs much earlier in the boot process than a manual boot-selector launch. Launching before the compat subsystem is ready results in a black screen. This is why the identical call works from the menu: the extra seconds of menu interaction hide the race. Adding a readiness wait on CMPTCheckScreenState() (up to 5 s, then launch anyway) fixed this on the test console — screen-type changes alone did not.
  2. DRC wait: the Wii U Menu calls CMPTAcctSetDrcCtrlEnabled() (exported by nn_cmpt.rpl, not declared in wut) before launching vWii titles. Without it the vWii transition can wait on a GamePad connection. This PR calls it with 0 and sets the TV screen type.

Testing

Tested on a PAL Wii U, GamePad powered off, autobooting to vWii System Menu (through Priiloader): black screen before the patch, boots reliably with it. Also verified the boot selector still works and that manual selection of vWii from the selector behaves as before.

Known tradeoff

This forces TV-only vWii output for autoboot also for users who do use the GamePad. A conditional version (probe as before, only disable DRC when no GamePad is attached) would be nicer, but the original BOTH/DRC probing succeeded even with no GamePad connected on the test console, so a reliable attach check would be needed — happy to rework if you have a preferred way to detect that here.

https://claude.ai/code/session_01PE4DJqPCXQzkGorJSUDrGv

Autobooting into the vWii System Menu or vWii Homebrew Channel hung on
a permanent black screen when the GamePad is powered off, while the
same launch worked from the boot selector menu. Two changes:

- Wait (up to 5s) for CMPTCheckScreenState to report readiness before
  launching: on autoboot this code runs much earlier in the boot than a
  manual selection, and launching before the compat subsystem is ready
  black-screens.
- Call CMPTAcctSetDrcCtrlEnabled(0) and use the TV screen type, like
  the Wii U Menu does before launching vWii titles, so the launch does
  not wait on a GamePad connection.

Tested on a PAL Wii U with the GamePad powered off (autoboot to vWii
System Menu through Priiloader). Note the tradeoff: this forces
TV-only vWii output also for users who do use the GamePad; making the
DRC handling conditional needs testing on a GamePad-connected console.

Fixes wiiu-env#67

Claude-Session: https://claude.ai/code/session_01PE4DJqPCXQzkGorJSUDrGv
@grantendo

Copy link
Copy Markdown

Thanks for this, it got me most of the way on my console. On your "known tradeoff": I think I have the reliable attach check you mention, plus one more piece that was needed on my side. Both are built on your three commits.

1. A GamePad attach check that holds up. CCRCDCDevicePing(CCR_CDC_DESTINATION_DRC0) pings the GamePad over its radio link. It returns 0 when one answers and an error when none does, in 2 to 4 ms either way on my US Wii U. I ask up to 10 times, 50 ms apart, since a GamePad that wakes with the console may still be connecting at autoboot. With that:

  • GamePad connected: exactly the old code (BOTH, then DRC, then TV), so the vWii keeps mirroring to the GamePad;
  • none: your path (DRC control off, TV only, the CMPTCheckScreenState wait), plus point 2.

I first used VPADRead's VPAD_READ_INVALID_CONTROLLER for this, but a plugin that replaces VPADRead (the DRC Read Result Spoofer, which people use to play GamePad-only games on a Pro Controller) makes it report a GamePad that isn't there, and the launch went black again. The ping goes past VPADRead.

2. With no GamePad connected, the launch could also be refused outright. On my console (Aroma, GamePad battery flat), with your screen-type and DRC changes in, every vWii launch from the boot menu still failed: CMPTLaunchTitle / CMPTLaunchMenu returned -512. The cause was AVMSetDCWiiCompat (the TV's switch to Wii mode): it also reprograms the GamePad's display pipe from avm's GamePad settings, and with no GamePad those say "off" (what GX2SetDRCBuffer stores for GX2_DRC_RENDER_MODE_DISABLE), which dc rejects. Giving the GamePad pipe a normal mode first fixes it, with the call GX2SetDRCBuffer makes for GX2_DRC_RENDER_MODE_SINGLE: AVMSetDRCBufferAttr(2, 1, 896) (found with OSDynLoad). It only runs when no GamePad is connected.

Wii VC injects are Wii U titles, so they don't go through launchvWiiTitle and aren't affected.

All of it is on grantendo/AutobootModule, branch pr-gamepad-off: your three commits as they are (your authorship), then 6a5cb85 (the pipe mode), db5afe0 (TV only just without a GamePad) and 15513a1 (the ping).

Tested on a US Wii U, from the boot menu and on autoboot:

  • No GamePad connected (battery flat, or out of range): the vWii System Menu, the Homebrew Channel and a vWii channel all boot on the TV.
  • GamePad connected: the launch is as before, and the vWii mirrors to the GamePad.
  • The DRC Read Result Spoofer loaded and no GamePad in range: boots on the TV.

Would you like to pull these into this PR? Or, if you'd rather, I can open a PR that carries your commits and these on top. Whichever is easier for you and for review.

@grantendo

Copy link
Copy Markdown

Opened #70 with your three commits as they are, plus the GamePad check and the pipe fix. If you'd rather carry them here, say so and I'll close mine.

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.

vWii autoboot hangs if GamePad is disconnected

2 participants