Skip to content

Commit

Permalink
Merge pull request #1104 from ValveSoftware/beta
Browse files Browse the repository at this point in the history
Merging beta to main for v2.8.0
  • Loading branch information
zite authored Jan 15, 2024
2 parents 9442d7d + acac54f commit c9d9539
Show file tree
Hide file tree
Showing 33 changed files with 648 additions and 106 deletions.
8 changes: 4 additions & 4 deletions Assets/SteamVR/Editor/SteamVR_Update.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ namespace Valve.VR
[InitializeOnLoad]
public class SteamVR_Update : EditorWindow
{
const string currentVersion = "2.1";
const string versionUrl = "http://media.steampowered.com/apps/steamvr/unitypluginversion.txt";
const string notesUrl = "http://media.steampowered.com/apps/steamvr/unityplugin-v{0}.txt";
const string pluginUrl = "http://u3d.as/content/valve-corporation/steam-vr-plugin";
const string currentVersion = "2.8";
const string versionUrl = "https://media.steampowered.com/apps/steamvr/unitypluginversion.txt";
const string notesUrl = "https://media.steampowered.com/apps/steamvr/unityplugin-v{0}.txt";
const string pluginUrl = "https://u3d.as/content/valve-corporation/steam-vr-plugin";
const string doNotShowKey = "SteamVR.DoNotShow.v{0}";

static bool gotVersion = false;
Expand Down
6 changes: 6 additions & 0 deletions Assets/SteamVR/Input/Editor/SteamVR_CopyExampleInputFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ public class SteamVR_CopyExampleInputFiles : Editor

[UnityEditor.Callbacks.DidReloadScripts]
private static void OnReloadScripts()
{
EditorApplication.update += Update;
}

private static void Update()
{
EditorApplication.update -= Update;
SteamVR_Input.CheckOldLocation();
CopyFiles();
}
Expand Down
68 changes: 52 additions & 16 deletions Assets/SteamVR/Input/SteamVR_ActionSet_Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,32 @@ namespace Valve.VR
/// </summary>
public static class SteamVR_ActionSet_Manager
{
public static VRActiveActionSet_t[] rawActiveActionSetArray;
public static VRActiveActionSet_t[] rawActiveActionSetArray
{
get
{
if (currentArraySize <= 0)
return null;
else
return poolActiveActionSetArrays[currentArraySize];
}
}

[NonSerialized]
private static uint activeActionSetSize;

[NonSerialized]
private static bool changed = false;

[NonSerialized]
private static int currentArraySize;
[NonSerialized]
private static Dictionary<int, VRActiveActionSet_t[]> poolActiveActionSetArrays;

public static void Initialize()
{
activeActionSetSize = (uint)(Marshal.SizeOf(typeof(VRActiveActionSet_t)));
poolActiveActionSetArrays = new Dictionary<int, VRActiveActionSet_t[]>();
}

/// <summary>
Expand Down Expand Up @@ -74,10 +90,38 @@ public static void SetChanged()
changed = true;
}

private static int GetNewArraySize()
{
int size = 0;

SteamVR_Input_Sources[] sources = SteamVR_Input_Source.GetAllSources();
for (int actionSetIndex = 0; actionSetIndex < SteamVR_Input.actionSets.Length; actionSetIndex++)
{
SteamVR_ActionSet set = SteamVR_Input.actionSets[actionSetIndex];

for (int sourceIndex = 0; sourceIndex < sources.Length; sourceIndex++)
{
SteamVR_Input_Sources source = sources[sourceIndex];

if (set.ReadRawSetActive(source))
{
size++;
}
}
}

return size;
}

private static void UpdateActionSetsArray()
{
List<VRActiveActionSet_t> activeActionSetsList = new List<VRActiveActionSet_t>();
int newArraySize = GetNewArraySize();
if (poolActiveActionSetArrays.ContainsKey(newArraySize) == false)
{
poolActiveActionSetArrays[newArraySize] = new VRActiveActionSet_t[newArraySize];
}

int arrayIndex = 0;
SteamVR_Input_Sources[] sources = SteamVR_Input_Source.GetAllSources();

for (int actionSetIndex = 0; actionSetIndex < SteamVR_Input.actionSets.Length; actionSetIndex++)
Expand All @@ -90,25 +134,17 @@ private static void UpdateActionSetsArray()

if (set.ReadRawSetActive(source))
{
VRActiveActionSet_t activeSet = new VRActiveActionSet_t();
activeSet.ulActionSet = set.handle;
activeSet.nPriority = set.ReadRawSetPriority(source);
activeSet.ulRestrictedToDevice = SteamVR_Input_Source.GetHandle(source);

int insertionIndex = 0;
for (insertionIndex = 0; insertionIndex < activeActionSetsList.Count; insertionIndex++)
{
if (activeActionSetsList[insertionIndex].nPriority > activeSet.nPriority)
break;
}
activeActionSetsList.Insert(insertionIndex, activeSet);
poolActiveActionSetArrays[newArraySize][arrayIndex].ulActionSet = set.handle;
poolActiveActionSetArrays[newArraySize][arrayIndex].nPriority = set.ReadRawSetPriority(source);
poolActiveActionSetArrays[newArraySize][arrayIndex].ulRestrictedToDevice = SteamVR_Input_Source.GetHandle(source);

arrayIndex++;
}
}
}

changed = false;

rawActiveActionSetArray = activeActionSetsList.ToArray();
currentArraySize = newArraySize;

if (Application.isEditor || updateDebugTextInBuilds)
UpdateDebugText();
Expand Down
24 changes: 24 additions & 0 deletions Assets/SteamVR/Input/SteamVR_Action_Boolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,30 @@ public void RemoveAllListeners()
foreach (Delegate existingDelegate in delegates)
onState -= (SteamVR_Action_Boolean.StateHandler)existingDelegate;
}

if (onChange != null)
{
delegates = onChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onChange -= (SteamVR_Action_Boolean.ChangeHandler)existingDelegate;
}

if (onUpdate != null)
{
delegates = onUpdate.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onUpdate -= (SteamVR_Action_Boolean.UpdateHandler)existingDelegate;
}

if (onActiveChange != null)
{
delegates = onActiveChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onActiveChange -= (SteamVR_Action_Boolean.ActiveChangeHandler)existingDelegate;
}
}

/// <summary><strong>[Should not be called by user code]</strong>
Expand Down
14 changes: 11 additions & 3 deletions Assets/SteamVR/Input/SteamVR_Action_Pose.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,14 @@ public virtual void RemoveAllListeners()
onActiveChange -= (SteamVR_Action_Pose.ActiveChangeHandler)existingDelegate;
}

if (onActiveBindingChange != null)
{
delegates = onActiveBindingChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onActiveBindingChange -= (SteamVR_Action_Pose.ActiveChangeHandler)existingDelegate;
}

if (onChange != null)
{
delegates = onChange.GetInvocationList();
Expand Down Expand Up @@ -618,7 +626,7 @@ public override void UpdateValue()
UpdateValue(false);
}

public static float framesAhead = 2;
public static float framesAhead = -1;

/// <summary><strong>[Should not be called by user code]</strong>
/// Updates the data for this action and this input source. Sends related events.
Expand All @@ -634,10 +642,10 @@ public virtual void UpdateValue(bool skipStateAndEventUpdates)

EVRInputError err;

if (framesAhead == 0)
if (framesAhead == -1)
err = OpenVR.Input.GetPoseActionDataForNextFrame(handle, universeOrigin, ref poseActionData, poseActionData_size, inputSourceHandle);
else
err = OpenVR.Input.GetPoseActionDataRelativeToNow(handle, universeOrigin, framesAhead * (Time.timeScale / SteamVR.instance.hmd_DisplayFrequency), ref poseActionData, poseActionData_size, inputSourceHandle);
err = OpenVR.Input.GetPoseActionDataRelativeToNow(handle, universeOrigin, framesAhead * (1 / SteamVR.instance.hmd_DisplayFrequency), ref poseActionData, poseActionData_size, inputSourceHandle);

if (err != EVRInputError.None)
{
Expand Down
16 changes: 16 additions & 0 deletions Assets/SteamVR/Input/SteamVR_Action_Single.cs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,22 @@ public void RemoveAllListeners()
foreach (Delegate existingDelegate in delegates)
onChange -= (SteamVR_Action_Single.ChangeHandler)existingDelegate;
}

if (onActiveChange != null)
{
delegates = onActiveChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onActiveChange -= (SteamVR_Action_Single.ActiveChangeHandler)existingDelegate;
}

if (onActiveBindingChange != null)
{
delegates = onActiveBindingChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onActiveBindingChange -= (SteamVR_Action_Single.ActiveChangeHandler)existingDelegate;
}
}

/// <summary><strong>[Should not be called by user code]</strong>
Expand Down
8 changes: 8 additions & 0 deletions Assets/SteamVR/Input/SteamVR_Action_Skeleton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,14 @@ public override void RemoveAllListeners()
onActiveChange -= (SteamVR_Action_Skeleton.ActiveChangeHandler)existingDelegate;
}

if (onActiveBindingChange != null)
{
delegates = onActiveBindingChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onActiveBindingChange -= (SteamVR_Action_Skeleton.ActiveChangeHandler)existingDelegate;
}

if (onChange != null)
{
delegates = onChange.GetInvocationList();
Expand Down
16 changes: 16 additions & 0 deletions Assets/SteamVR/Input/SteamVR_Action_Vector2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,22 @@ public void RemoveAllListeners()
foreach (Delegate existingDelegate in delegates)
onChange -= (SteamVR_Action_Vector2.ChangeHandler)existingDelegate;
}

if (onActiveChange != null)
{
delegates = onActiveChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onActiveChange -= (SteamVR_Action_Vector2.ActiveChangeHandler)existingDelegate;
}

if (onActiveBindingChange != null)
{
delegates = onActiveBindingChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onActiveBindingChange -= (SteamVR_Action_Vector2.ActiveChangeHandler)existingDelegate;
}
}

/// <summary><strong>[Should not be called by user code]</strong>
Expand Down
16 changes: 16 additions & 0 deletions Assets/SteamVR/Input/SteamVR_Action_Vector3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,22 @@ public void RemoveAllListeners()
foreach (Delegate existingDelegate in delegates)
onChange -= (SteamVR_Action_Vector3.ChangeHandler)existingDelegate;
}

if (onActiveChange != null)
{
delegates = onActiveChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onActiveChange -= (SteamVR_Action_Vector3.ActiveChangeHandler)existingDelegate;
}

if (onActiveBindingChange != null)
{
delegates = onActiveBindingChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onActiveBindingChange -= (SteamVR_Action_Vector3.ActiveChangeHandler)existingDelegate;
}
}

/// <summary><strong>[Should not be called by user code]</strong>
Expand Down
40 changes: 40 additions & 0 deletions Assets/SteamVR/Input/SteamVR_Action_Vibration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ public void RemoveOnExecuteListener(ExecuteHandler functionToStopCalling, SteamV
sourceMap[inputSource].onExecute -= functionToStopCalling;
}

/// <summary>
/// Removes all listeners, useful for dispose pattern
/// </summary>
public void RemoveAllListeners(SteamVR_Input_Sources input_Sources)
{
sourceMap[input_Sources].RemoveAllListeners();
}

/// <summary>
/// Returns the last time this action was executed
/// </summary>
Expand Down Expand Up @@ -183,6 +191,38 @@ public override void Preinitialize(SteamVR_Action wrappingAction, SteamVR_Input_
vibrationAction = (SteamVR_Action_Vibration)wrappingAction;
}

/// <summary>
/// Removes all listeners, useful for dispose pattern
/// </summary>
public void RemoveAllListeners()
{
Delegate[] delegates;

if (onActiveBindingChange != null)
{
delegates = onActiveBindingChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onActiveBindingChange -= (SteamVR_Action_Vibration.ActiveChangeHandler)existingDelegate;
}

if (onActiveChange != null)
{
delegates = onActiveChange.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onActiveChange -= (SteamVR_Action_Vibration.ActiveChangeHandler)existingDelegate;
}

if (onExecute != null)
{
delegates = onExecute.GetInvocationList();
if (delegates != null)
foreach (Delegate existingDelegate in delegates)
onExecute -= (SteamVR_Action_Vibration.ExecuteHandler)existingDelegate;
}
}


/// <summary>
/// Trigger the haptics at a certain time for a certain length
Expand Down
26 changes: 25 additions & 1 deletion Assets/SteamVR/Input/SteamVR_Input_Sources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Valve.VR
{
public enum SteamVR_Input_Sources
{
[Description("/unrestricted")] //todo: check to see if this gets exported: k_ulInvalidInputHandle
[Description("/unrestricted")]
Any,

[Description("/user/hand/left")]
Expand Down Expand Up @@ -51,6 +51,30 @@ public enum SteamVR_Input_Sources

[Description("/user/treadmill")]
Treadmill,

[Description("/user/knee/left")]
LeftKnee,

[Description("/user/knee/right")]
RightKnee,

[Description("/user/elbow/left")]
LeftElbow,

[Description("/user/elbow/right")]
RightElbow,

[Description("/user/wrist/left")]
LeftWrist,

[Description("/user/wrist/right")]
RightWrist,

[Description("/user/ankle/left")]
LeftAnkle,

[Description("/user/ankle/right")]
RightAnkle,
}
}

Expand Down
1 change: 0 additions & 1 deletion Assets/SteamVR/InteractionSystem/Core/Scripts/DebugUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
//=============================================================================

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

namespace Valve.VR.InteractionSystem
Expand Down
Loading

0 comments on commit c9d9539

Please sign in to comment.