The hover effects feature introduced in visionOS 26 represents a significant enhancement for creating immersive experiences, allowing users to interact with virtual objects using spatial gestures. However, the behavior of these gestures, particularly with the PSVR 2 controllers, can indeed vary based on how they are integrated into different types of views and applications.
Clarification on Hover Effects and PSVR 2 Controllers
Hover Effects in VisionOS:
Hover effects are designed to provide feedback when a user's gaze is directed towards a virtual object. This is akin to a mouse hover on a desktop and can trigger spatial events or visual highlights.
Controller Gestures:
On the PSVR 2, traditional button presses (like pulling the trigger) are well-supported across various interfaces, including SwiftUI. However, gaze-based interactions like hover effects require additional handling to map spatial gestures to these events.
Discrepancies in Behavior
Sample Application Behavior:
The sample you referenced likely relies on Compositor Services and Metal for rendering, which might not directly map the trigger press to hover events as SwiftUI does for button clicks. Instead, it may expect pinch gestures or explicit gaze-based input to trigger spatial events.
SwiftUI Views:
SwiftUI abstracts much of the complexity involved in handling different input methods, providing a more consistent interface for gestures like trigger presses. This is why you observe trigger presses being recognized as button clicks in SwiftUI views.
Possible Explanations and Solutions
Gesture Mapping:
Ensure that your sample application correctly maps hover events to the appropriate PSVR 2 controller gestures. This might involve customizing gesture recognizers to handle gaze-based input and trigger presses separately.
Compositor Services API:
Dive deeper into the Compositor Services API documentation to understand how hover events are triggered and how they can be customized for different input devices. You may need to handle spatial events manually and map them to the desired actions.
Event Handling Updates:
Check for any updates or patches to visionOS or the Compositor Services framework that might address discrepancies in gesture handling. Apple frequently updates its APIs to improve compatibility and functionality.
Community and Support:
Engage with the Apple Developer forums or reach out to Apple Support for specific guidance on implementing hover effects with PSVR 2 controllers. They may provide insights or workarounds tailored to your application's needs.
Custom Implementations:
Consider implementing custom gesture recognizers that combine gaze tracking with controller input to achieve the desired hover effect behavior. This might offer more flexibility and control over how interactions are handled.
In summary, while hover effects and PSVR 2 controller gestures are designed to work together, discrepancies can arise due to differences in how input is processed in various frameworks. By carefully mapping gestures and leveraging the latest API features, you can create a more seamless and intuitive user experience in your visionOS application.