openvr actions are not active

89 views Asked by At

im trying to get the action binding working.

steamvr doesn't seam to recognise the "new input method" in the steamvr console, but all the bindings get loaded correctly but dont get bound, and binding the with the ui still doesn't produce outputs no errors are thrown, and the actions aren't active and just return empty data (all 0)

{
  "default_bindings": [
    {
      "controller_type": "knuckles",
      "binding_url": "binding_knuckles.json"
    }
  ],
  "actions": [
    {
      "name": "/actions/Dragger/in/hand_pos",
      "requirement": "optional",
      "type": "pose"
    },
    {
      "name": "/actions/Dragger/in/a_butt",
      "requirement": "optional",
      "type": "boolean"
    }
  ],
  "localization": [
    {
      "language_tag": "en_us",
      "/actions/Dragger/in/hand_pos": "poseable",
      "/actions/Dragger/in/a_butt": "abutt"
    }
  ]
}
{
 "bindings": {
  "/actions/Dragger": {
   "poses": [
    {
     "output": "/actions/Dragger/in/hand_pos",
     "path": "/user/hand/left/pose/raw"
    }
   ],
   "haptics": [],
   "sources": [
    {
     "inputs": {
      "click": {
       "output": "/actions/Dragger/in/a_butt"
      }
     },
     "mode": "button",
     "path": "/user/hand/left/input/b"
    }
   ]
  }
 },
 "cords": {},
 "controller_type": "knuckles"
}

import os, time, openvr

openvr.init(openvr.VRApplication_Scene)
openvr.VRInput().setActionManifestPath(os.path.abspath("manifests/manifest.json"))
actionset = openvr.VRInput().getActionSetHandle("/actions/Dragger")
action_hide_cubes = openvr.VRInput().getActionHandle("/actions/Dragger/in/a_butt")
action_hand = openvr.VRInput().getActionHandle("/actions/Dragger/in/hand_pos")

print("running")
for i in range(100000):

    action_sets = (openvr.VRActiveActionSet_t * 1)()
    action_set = action_sets[0]
    action_set.ulActionSet = actionset
    openvr.VRInput().updateActionState(action_sets)

    action_data = openvr.VRInput().getDigitalActionData(action_hide_cubes, openvr.k_ulInvalidInputValueHandle)
    if action_data.bActive:
        print("can be clicked")
        if action_data.bState:
            print("has been click")

    action_data = openvr.VRInput().getPoseActionDataForNextFrame(action_hand, openvr.TrackingUniverseRawAndUncalibrated
                                                                 ,   openvr.k_ulInvalidInputValueHandle)
    if action_data.bActive:
        print("hand pos:", action_data.pose.mDeviceToAbsoluteTracking)
    time.sleep(0.1)
    print()
    print("-----------")
openvr.shutdown()
print("shutdown")

1

There are 1 answers

8
VonC On
    if action_data.bActive:
        print("clicked")

From ValveSoftware/openvr/headers/openvr.h, bActive means "Whether or not this action is currently available to be bound in the active action set"

It does not mean "clicked".

For that, you would need to use bState:

The current state of this action; will be true if currently pressed

That is, in your case:

    if action_data.bActive and action_data.bState:
        print("Button pressed")

all data bActive, bState always being 0, action_data.pose.mDeviceToAbsoluteTracking is all 0 to. all data is 0

Make sure that your JSON files are valid. You can use online JSON validators to check for syntax errors.

Use the SteamVR binding UI to make sure your actions are correctly set up and bound to the controller inputs. Sometimes, manually setting up bindings through this interface can resolve recognition issues.

Double-check the content of the SteamVR Input guide.


looks like there was two issues.

  • using action_set instead of action_sets.
  • and the workshop replacing "/actions/Dragger" with "/actions/dragger" in some place.

True: action_sets is an array of VRActiveActionSet_t, which allows you to update and manage multiple action sets simultaneously. The proper handling of this array is essential for OpenVR to correctly process which actions are active and should be listened for.
usage:

action_sets = (openvr.VRActiveActionSet_t * 1)()
action_set = action_sets[0]
action_set.ulActionSet = actionset
openvr.VRInput().updateActionState(action_sets)

Regarding the case sensitivity in action paths, if the action paths do not match exactly between your code, manifest, and binding files, OpenVR will not recognize them as the same action. That can lead to actions not being triggered or recognized.
Make sure the action paths are consistently named across all your files. The case (uppercase vs. lowercase) must match exactly. Consistency in naming conventions should help prevent such issues.