Xbox controller and visionOS 2

I am having problems getting button input from an Xbox game controller.

I have the visionOS 2 beta on my Apple Vision Pro, and I am trying to use an Xbox game controller with a RealityView following the instructions from the WWDC session Explore game input in visionOS.

The notification about a game controller is picking up the game controller, finds GCInputButtonA, and I am setting closures for touchedChangedHandler, pressedChangedHandler, and valueChangedHandler that just print an os_log statement.

buttonA.valueChangedHandler = { button, value, pressed in
    os_log("Got valueChangedHandler")
}

At the end of RealityView, I have the modifier

RealityView { content in
    // stuff
}
.handlesGameControllerEvents(matching: .gamepad)

But I am never seeing the log message appear in the console when I press the 'A' button (or any other button).

Any ideas what I might be doing wrong?

The Xbox controller is pretty old. Settings is reporting it as version 9.0.3

I've largely solved it following the information from this discussion:

https://forums.developer.apple.com/forums/thread/746728

Side note: When I look at my virtual Mac screen while in immersive mode (a new feature) to look for the console messages and press the 'A' button, I lose the ability to detect the button presses in my app. Does the input focus switch?

Xbox controller and visionOS 2
 
 
Q