Skip to main content

SteamVRDeviceLifecycle

A class in Root.Township, the global namespace.

Device lifecycle for SteamVR: listens to SteamVR events for new poses and controllers connecting or changing role. Client only.

Constructors​

MemberWhat it is
SteamVRDeviceLifecycle(IPlatformPlayer player, IPlatformDevice platformDevice)Creates a SteamVRDeviceLifecycle from player and platformDevice.

Fields​

4 private and internal fields
MemberWhat it is
private SteamVR_Events.Action deviceRoleChangedSteamVR system event action for device role changes.
private List<SteamVRPose> foundControllersConnected controller poses.
private static Logger loggerNLog logger for assignment warnings.
private List<SteamVRPose> posesOne SteamVRPose per tracked device index, created on demand.

Methods​

MemberWhat it is
override void DisableSDK()Removes all SteamVR event listeners.
override void EnableSDK()Registers already connected devices and subscribes to SteamVR pose, focus, connection and role-change events.
protected override void OnPlatformPlayerSet(IPlatformPlayer oldPlayer, IPlatformPlayer newPlayer)Reassigns controllers when the platform player changes.
7 private and internal methods
MemberWhat it is
private void AssignControllers()Looks up the left and right hand device indices and tries to assign them to the player's hands.
private bool AttemptAssignDevice(PosedObject posedObject, SteamVR_TrackedObject.EIndex device)Returns true if the device's pose exists and isn't reserved, otherwise logs a warning. It doesn't assign anything itself.
private SteamVRPose GetPose(SteamVR_TrackedObject.EIndex index)Returns the SteamVRPose for a device index, creating poses up to it and enabling it. Null for None.
private void OnDeviceConnected(int deviceIndex, bool isConnected)Tracks controllers connecting or disconnecting and reassigns hands.
private void OnInputFocus(bool isShowingDashboard)Does nothing.
private void OnNewPoses(TrackedDevicePose_t[] devicePoses)Passes new SteamVR poses to each enabled SteamVRPose.
private void OnTrackedDeviceRoleChanged(VREvent_t args)Reassigns controllers when SteamVR changes a device's hand role.