ValveSoftware / steamvr_unity_plugin

SteamVR Unity Plugin - Documentation at: https://valvesoftware.github.io/steamvr_unity_plugin/
BSD 3-Clause "New" or "Revised" License
1.04k stars 259 forks source link

How do I create bindings for devices I don't own? #927

Open Saticmotion opened 3 years ago

Saticmotion commented 3 years ago

I currently own a Vive Cosmos, but would like my software to support all SteamVR devices. For the Vive Cosmos I've been able to make and publish bindings (by clicking on the "Replace default bindings button". Since I don't own other devices, I can't access the replace button. So I've edited the json bindings files that the SteamVR plugin creates.

When I try to use these bindings on a user's PC (users have tested with Rift S and Quest 2 through Oculus Link), SteamVR tells me it hasn't found any bindings. Although the json files are in the StreamingAssets folder, as they're supposed to be. I have attached my actions file and a couple of bindings files.

I'm using SteamVR plugin 2.7.3 and Unity 2019.4.21f. Image shows how the bindings show up in the UI.

If you need more information from me, please do ask. Or check the GitHub repo.

image

actions.json

``` { "actions": [ { "name": "/actions/default/in/Pose", "type": "pose" }, { "name": "/actions/default/in/SkeletonLeftHand", "type": "skeleton", "skeleton": "/skeleton/hand/left" }, { "name": "/actions/default/in/SkeletonRightHand", "type": "skeleton", "skeleton": "/skeleton/hand/right" }, { "name": "/actions/default/in/HeadsetOnHead", "type": "boolean", "requirement": "optional" }, { "name": "/actions/default/in/Grip", "type": "boolean", "requirement": "mandatory" }, { "name": "/actions/default/in/Trigger", "type": "boolean", "requirement": "mandatory" }, { "name": "/actions/default/in/RotateRight", "type": "boolean" }, { "name": "/actions/default/in/RotateLeft", "type": "boolean" }, { "name": "/actions/default/out/Haptic", "type": "vibration" } ], "action_sets": [ { "name": "/actions/default", "usage": "single" } ], "default_bindings": [ { "controller_type": "vive_controller", "binding_url": "bindings_vive_controller.json" }, { "controller_type": "vive_cosmos_controller", "binding_url": "bindings_vive_cosmos_controller.json" }, { "controller_type": "oculus_touch", "binding_url": "bindings_oculus_touch.json" }, { "controller_type": "knuckles", "binding_url": "bindings_knuckles.json" }, { "controller_type": "holographic_controller", "binding_url": "bindings_holographic_controller.json" }, { "controller_type": "vive", "binding_url": "binding_vive.json" }, { "controller_type": "vive_pro", "binding_url": "binding_vive_pro.json" }, { "controller_type": "rift", "binding_url": "binding_rift.json" }, { "controller_type": "holographic_hmd", "binding_url": "binding_holographic_hmd.json" }, { "controller_type": "vive_tracker_camera", "binding_url": "binding_vive_tracker_camera.json" } ], "localization": [ { "language_tag": "en_US", "/actions/default/in/HeadsetOnHead": "Headset on head (proximity sensor)", "/actions/default/in/Pose": "Pose", "/actions/default/in/SkeletonLeftHand": "Skeleton (Left)", "/actions/default/in/SkeletonRightHand": "Skeleton (Right)", "/actions/default/out/Haptic": "Haptic", "/actions/default/in/Grip": "Grip", "/actions/default/in/Trigger": "Trigger", "/actions/default/in/RotateRight": "Rotate Right", "/actions/default/in/RotateLeft": "Rotate Left" } ] } ```

binding_vive_cosmos_controller.json This is a known good bindings file

``` { "/actions/buggy": { "chords": [], "poses": [], "haptics": [], "sources": [], "skeleton": [] }, "/actions/default": { "chords": [], "poses": [ { "output": "/actions/default/in/pose", "path": "/user/hand/left/pose/raw" }, { "output": "/actions/default/in/pose", "path": "/user/hand/right/pose/raw" } ], "haptics": [ { "output": "/actions/default/out/haptic", "path": "/user/hand/left/output/haptic" }, { "output": "/actions/default/out/haptic", "path": "/user/hand/right/output/haptic" } ], "sources": [ { "path": "/user/hand/left/input/trigger", "mode": "button", "inputs": { "click": { "output": "/actions/default/in/trigger" } } }, { "path": "/user/hand/left/input/grip", "mode": "button", "parameters": { "click_activate_threshold": "0.8", "click_deactivate_threshold": "0.7", "force_input": "force" }, "inputs": { "click": { "output": "/actions/default/in/grip" } } }, { "path": "/user/hand/right/input/trigger", "mode": "button", "inputs": { "click": { "output": "/actions/default/in/trigger" } } }, { "path": "/user/hand/right/input/grip", "mode": "button", "parameters": { "click_activate_threshold": "0.8", "click_deactivate_threshold": "0.7", "force_input": "force" }, "inputs": { "click": { "output": "/actions/default/in/grip" } } }, { "path": "/user/hand/left/input/joystick", "mode": "dpad", "parameters": { "sub_mode": "click" }, "inputs": { "east": { "output": "/actions/default/in/rotateright" }, "west": { "output": "/actions/default/in/rotateleft" } } }, { "path": "/user/hand/right/input/joystick", "mode": "dpad", "parameters": { "sub_mode": "click" }, "inputs": { "east": { "output": "/actions/default/in/rotateright" }, "west": { "output": "/actions/default/in/rotateleft" } } } ], "skeleton": [ { "output": "/actions/default/in/skeletonlefthand", "path": "/user/hand/left/input/skeleton/left" }, { "output": "/actions/default/in/skeletonrighthand", "path": "/user/hand/right/input/skeleton/right" } ] }, "/actions/platformer": { "chords": [], "poses": [], "haptics": [], "sources": [], "skeleton": [] }, "controller_type" : "vive_cosmos_controller", "description" : "", "name" : "vive_cosmos_controller" } ```

bindings_oculus_touch.json This is a known bad bindings file

``` { "/actions/buggy": { "chords": [], "poses": [], "haptics": [], "sources": [], "skeleton": [] }, "/actions/default": { "chords": [], "poses": [ { "output": "/actions/default/in/pose", "path": "/user/hand/left/pose/raw" }, { "output": "/actions/default/in/pose", "path": "/user/hand/right/pose/raw" } ], "haptics": [ { "output": "/actions/default/out/haptic", "path": "/user/hand/left/output/haptic" }, { "output": "/actions/default/out/haptic", "path": "/user/hand/right/output/haptic" } ], "sources": [ { "path": "/user/hand/left/input/trigger", "mode": "button", "inputs": { "click": { "output": "/actions/default/in/trigger" } } }, { "path": "/user/hand/left/input/grip", "mode": "button", "parameters": { "click_activate_threshold": "0.8", "click_deactivate_threshold": "0.7", "force_input": "force" }, "inputs": { "click": { "output": "/actions/default/in/grip" } } }, { "path": "/user/hand/right/input/trigger", "mode": "button", "inputs": { "click": { "output": "/actions/default/in/trigger" } } }, { "path": "/user/hand/right/input/grip", "mode": "button", "parameters": { "click_activate_threshold": "0.8", "click_deactivate_threshold": "0.7", "force_input": "force" }, "inputs": { "click": { "output": "/actions/default/in/grip" } } }, { "path": "/user/hand/left/input/joystick", "mode": "dpad", "parameters": { "sub_mode": "click" }, "inputs": { "east": { "output": "/actions/default/in/rotateright" }, "west": { "output": "/actions/default/in/rotateleft" } } }, { "path": "/user/hand/right/input/joystick", "mode": "dpad", "parameters": { "sub_mode": "click" }, "inputs": { "east": { "output": "/actions/default/in/rotateright" }, "west": { "output": "/actions/default/in/rotateleft" } } } ], "skeleton": [ { "output": "/actions/default/in/skeletonlefthand", "path": "/user/hand/left/input/skeleton/left" }, { "output": "/actions/default/in/skeletonrighthand", "path": "/user/hand/right/input/skeleton/right" } ] }, "/actions/platformer": { "chords": [], "poses": [], "haptics": [], "sources": [], "skeleton": [] }, "controller_type" : "oculus_touch", "description" : "", "name" : "oculus_touch_default", } ```

AlkalineDevelopment commented 3 years ago

I ran into this exact issue myself while developing my SteamVR game. I only own a Rift S so the only controllers it let me customize were the HTC Vive, Valve Index, and Rift S. Because of this I was unable to create an Input Binding for the Vive Cosmos and Windows Mixed Reality.

In one of the SteamVR Hub Patch Notes it specifically mentions "Allowed bindings for Windows Mixed Reality Controller to be edited even if a controller isn't present." Despite all my searching, I was unable to find a way to show it or the Vive Cosmos controllers.

My solution was to manually edit the input binding files for those two. The Rift S Controller and the Vive Cosmos controllers share the same button mappings so I copied the relevant parts from the Rift S binding into the cosmos controller bindings and it worked like a charm.

My issue was creating a binding for the Windows Mixed Reality Gen 1 controllers. It's similar to the HTC Vive controllers but I still don't have a proper binding for it. However, the HP Reverb G2 also has a similar layout to the Rift S so I basically did the same thing as I did for the Cosmos to the holographic controller binding.

I've had no issues with players using those bindings after I manually created them. Still seems like there should be an easier method to do this for controllers you don't own.

Saticmotion commented 3 years ago

Thanks for your input @AlkalineDevelopment! As far as I can tell, I did the exact same thing as you did. But it didn't work for me. So I suspect there is some other issue on my end.

GabrielHare commented 2 years ago

Have both Steam and SteamVR open. SteamVR status window > Menu (top left corner) > Settings > Controllers > Show Old Bindings UI > Select Your App > In the "Current Controller" box click on the controller name > In the "Current Bindings" box click edit. (You can also reach this from within Unity via: Window > SteamVR Input > Open binding UI.)

Once the bindings are configured click "Export Binding File. You will still need to copy the files (or sections of the files) back in to the project in Asserts > StreamingAssets > SteamVR.

NOTE: This only works for the controllers. Bindings for headset inputs (e.g. user presence on binding_index_hmd.json) still need to be manually edited as far as I can tell.

NOTE: The SteamVR package ships with only Index and Holographic (a.k.a WIndows Mixed Reality) headset presence bindings. When I figure out what (if anything) to do about Oculus headsets I'll post again.