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 257 forks source link

Unity.XR.OpenVR easily get hmd_interaction and user_input_focus #737

Open AVOlight opened 4 years ago

AVOlight commented 4 years ago

if the events have already happened....

i'm unable to get this working...


static uint controller_state_size = (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(Unity.XR.OpenVR.API.VRControllerState_t));
static uint open_vr_any_device_index = (uint)Unity.XR.OpenVR.API.ETrackedDeviceClass.Invalid; // unrestricted // Any

Unity.XR.OpenVR.API.VRControllerState_t controllerState = new Unity.XR.OpenVR.API.VRControllerState_t();

bool stateOK = Unity.XR.OpenVR.API.OpenVR.System.GetControllerState(open_vr_any_device_index, ref controllerState, controller_state_size);

if (stateOK)
{
  //"/actions/legacy/in/head_proximity"
  open_vr_user_present = (((Unity.XR.OpenVR.API.EVRButtonId)controllerState.ulButtonPressed) & Unity.XR.OpenVR.API.EVRButtonId.k_EButton_ProximitySensor) != 0;
}

please i just want a simple way to get input focus and user presence

AVOlight commented 4 years ago

this works with user presence


var hmd_activity = system.GetTrackedDeviceActivityLevel((uint)ETrackedControllerRole.Invalid);
open_vr_hmd_interaction = hmd_activity == EDeviceActivityLevel.k_EDeviceActivityLevel_UserInteraction;

doesn't work through Unity head_device.TryGetFeatureValue(CommonUsages.userPresence, out hmd_interaction);

don't know what i can do about getting user input focus events work (except with Oculus Dash) but i have to assume input focus at launch and rather than assume it would be nice to get the actual state

cameronfeng commented 4 years ago

Any updates on this?