ValveSoftware / openvr

OpenVR SDK
http://steamvr.com
BSD 3-Clause "New" or "Revised" License
6.12k stars 1.28k forks source link

IVRInput integration issues #895

Closed salians closed 6 years ago

salians commented 6 years ago

I am having trouble integrating with the new IVRInput interface. Wondering if anyone out there with a successful IVRInput integration can comment on why GetDigitalActionData returns invalid handle?

One cause for Invalid handle can be if the action referenced is not in the action manifest file, but that doesn't seem to be the case here.

The manifest file looks like this:

{
  "default_bindings": [
     {
        "controller_type" : "vive_controller",
        "binding_url" : "legacy_bindings_vive_controller.json"
     }
  ], 
  "actions": [
    {
      "name": "/actions/legacy/in/left_axis1_press",
      "type": "boolean"
    },
    {
      "name": "/actions/legacy/in/right_axis1_press",
      "type": "boolean"
    }
  ],
    "action_sets": [
    {
      "name": "/actions/legacy",
      "usage": "leftright"
    },
  ],
    "localization" : [
        {
            "language_tag": "en_US",
        }
    ]
}

The IVRInput APIs below, GetActionHandle and GetInputSourceHandle are successful but GetDigitalActionData always returns invalidHandle. Any ideas?

    VRActionHandle_t m_controllerState = 0;
    vr::InputDigitalActionData_t actionData = { 0 };
    VRInputValueHandle_t Inputhandle = 0;
    EVRInputError retErr = VRInputError_None;

    retErr = vr::VRInput()->GetActionHandle("/actions/legacy/in/right_axis1_press", &m_controllerState); //returned handle value 60
    retErr = vr::VRInput()->GetInputSourceHandle("/user/hand/right/input/trigger", &Inputhandle); //returned handle value 229
    //retErr = vr::VRInput()->GetDigitalActionData(m_controllerState, &actionData, sizeof(actionData), vr::k_ulInvalidInputValueHandle);
    retErr = vr::VRInput()->GetDigitalActionData(m_controllerState, &actionData, sizeof(actionData), Inputhandle); //API returns VRInputError_InvalidHandle

    if (actionData.bActive || actionData.bChanged || actionData.bState)
        vlog("*****actionState active:%d, changed state:%d, actual state:%d", actionData.bActive, actionData.bChanged, actionData.bState);
BOLL7708 commented 6 years ago

I have tried integrating the input system with C#, I have a test project here. So far I cannot seem to get the bindings working properly, currently I've moved on to other parts of my rewrite but will eventually get back to the input.

My problem, I think, is that I am making background applications and I cannot get them (or others overlay applications) to show up in the bindings interface. This makes me wonder if they work with the new input system at all... 🤔 What application type are you working on?

salians commented 6 years ago

The wiki https://github.com/ValveSoftware/openvr/wiki/SteamVR-Input from Joe is useful. On Step9 controller binding settings, there was a json file parsing error only visible in the HMD. The issue I guess was some typo, I re-did the manifest json file for all the controls. After that I am good I can detect button states now.

salians commented 6 years ago

BTW the IVRInput wiki link came from https://github.com/ValveSoftware/openvr/issues/869#issuecomment-425018285 since all my IVRInput searches were ending up on manifest file details https://github.com/ValveSoftware/openvr/wiki/Action-manifest

BOLL7708 commented 6 years ago

I actually followed that wiki when trying to do my integration 😗 but on step 9 I did fix my manifest problems, but my application will never show up in the bindings interface to generate a bindings file. That's where my problems started 😅 Might open a new issue about it the next time I try to battle this, I guess.

salians commented 6 years ago

Please note that I could not create a working controller binding from step#9 in the wiki since when I tried I got steam into a very bad state. I am instead using a legacy_bindings_vive_controller.json which works very well for the legacy controls I need.

chang47 commented 5 years ago

@salians Sorry to bring up an old thread, but I was wondering if you have an idea on whether this method would work with the new valve knuckles as opposed to the legacy controls? Thanks!

satishsalian-nv commented 5 years ago

Sorry, no I haven't used the new knuckle controllers... hopefully, there are other users who can confirm.

chang47 commented 5 years ago

@NVIDIA-Nsight Thanks for replying back!

I started to try and implement your solution and am experiencing problems with invalid handlers, while I'm trying to figure this out, I was wondering if you were able to get any actionData from the new Input system for more than 2 controllers (either the legacy ones or the new knuckles).

A couple of friends and I are trying to create an experience that requires 4 controllers so it's very important to figure out if this is even possible. Thanks again!

salians commented 5 years ago

I am suspecting you guys are targeting multiplayer support :-) Anyways best is to check with Valve team if 4 instance of the controller works.

cnlohr commented 5 years ago

Just so anyone else who trips along this thread isn't confused. Two things:

(1) I was forgetting UpdateActionState however, that does not seem to be the case of any of the folks here. The other note is: (2) GetInputSourceHandle will almost always return valid handles, even if the actions are not mapped, or the mapped actions are incompatible, and you won't find the errors until later, when calling GetDigitalActionData.