[SOLVED] VR Launch title and icon in SteamVR

OK, here is the working registration code:

private void registerVr() {
        File manifest = new File(VR_MANIFEST); //Path to manifest
        if (manifest.exists()) {
            String path = manifest.getAbsolutePath(); //Must be absolute path
            int error;
            if (!VRApplications.VRApplications_IsApplicationInstalled(VR_APP_KEY)) {
                error = VRApplications.VRApplications_AddApplicationManifest(path, false);
                LOGGER.info("Register VR Manifest: " + VRApplications.VRApplications_GetApplicationsErrorNameFromEnum(error));
            } else {
                LOGGER.info("VR App already installed");

            //Now that we are registered, we set that the manifest goes to the current app
            long pid = ProcessHandle.current().pid();
            LOGGER.finest("VR PID = " + pid);
            error = VRApplications.VRApplications_IdentifyApplication((int) pid, VR_APP_KEY);
            LOGGER.info("Set VR Manifest: " + VRApplications.VRApplications_GetApplicationsErrorNameFromEnum(error));
        } else {
            LOGGER.severe("VR Manifest not found, but VR is enabled");

Take note, I have a two constants here, VR_MANIFEST is a path (absolute or relative, does not matter) to the .vrmanifest file. VR_APP_KEY is the app_key in the manifest, these must match.

Here is a sample manifest:

	"source" : "builtin",
	"applications": [{
		"app_key": "io.tlf.example.vr",
		"launch_type": "binary",
		"binary_path_windows": "OutsideClient.exe",
		"arguments": "",
        "image_path": "assets/Textures/VR/vr_banner.png",
		"action_manifest_path" : "none",
		"strings": {
			"en_us": {
				"name": "Outside",
				"description": "The Outside Engine"

Take note in my manifest, I am using the exe wrapper for my application. You do not need to do this, but if not, you will need to use an absolute path to java.exe and the arguments for launching your jar. The image path is relative to the manifest, not your application. Again, the app key must match what is in the constant in your program. This app key must be unique to your application.

Why do I run VRApplications.VRApplications_IdentifyApplication?
Answer: because otherwise it will take a program restart for the manifest to go into effect.

The documentation says that you can pass in 0 for the PID, why did you get the PID and pass it in?
Answer: Because the documentation is wrong, Unity discovered this, you need the PID.

What is the best size for the banner image?
Answer: According to Unity 460x215 px.

When do I run this in my code?
Answer: AFTER the VREnvironment has been initialized!!! (It will throw a native error otherwise)

If you have any other questions, please feel free to ask.

@grizeldi I also found a bug in the jme implementation for VRInput.

Should be:
controllerName = VRSystem.VRSystem_GetStringTrackedDeviceProperty(i, VR.ETrackedDeviceProperty_Prop_ModelNumber_String, error);

As the code stands right now, it just always returns lighthouse for me. I do not know if this is always the case, but for the Vive Pro and Vive Controllers and Vive Trackers it is true. I tested my trackers just to make sure.
By changing it, I get the actual model name:

INFO:   Tracked controller 3/64 VIVE Tracker Pro MV (HTC) attached.
INFO:   Tracked controller 6/64 VIVE Controller Pro MV (HTC) attached.
INFO:   Tracked controller 7/64 VIVE Controller Pro MV (HTC) attached.

I am marking this solved, and I hope it can be of use to someone in the future.

1 Like