Skip to content

Commit f17a611

Browse files
committed
Version 1.3b07 Per project app ids, one pose / haptic action, dashboard
* Fixed issue with upgrading from the legacy system * Fixed some line endings * Fixed generation bug where it wouldn't reopen to the scene you started on * Auto replacing app key in binding files * Updating actions and bindings to have one pose and one haptic action * Gave each app its own app id via a vrmanifest that is generated on import. Can be modified in SteamVR_Settings for release. * Fixed haptic actions not displaying in play mode * Temporary fix for skeletons erroring while the dashboard is up
1 parent bf60145 commit f17a611

27 files changed

+568
-122
lines changed

Assets/SteamVR/Editor/SteamVR_Settings.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/SteamVR/Input/Editor/SteamVR_Input_Generator.cs

Lines changed: 13 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ private static void OnScriptsReloaded()
146146
#else
147147
CheckForNextStep();
148148
#endif
149+
SteamVR_Settings.VerifyScriptableObject();
149150
}
150151

151152
private static void CheckForNextStep()
@@ -322,6 +323,8 @@ private static void AssignDefaultsInBuiltScenes()
322323
EditorSceneManager.SaveOpenScenes();
323324

324325
var activeScene = EditorSceneManager.GetActiveScene();
326+
string activeScenePath = activeScene.path;
327+
325328
List<string> processedScenes = new List<string>();
326329

327330
AssignDefaultsInScene();
@@ -360,8 +363,11 @@ private static void AssignDefaultsInBuiltScenes()
360363
}
361364
}
362365

363-
if (string.IsNullOrEmpty(activeScene.path) == false)
364-
EditorSceneManager.OpenScene(activeScene.path, OpenSceneMode.Single);
366+
if (string.IsNullOrEmpty(activeScenePath) == false)
367+
{
368+
EditorSceneManager.OpenScene(activeScenePath, OpenSceneMode.Single);
369+
Debug.Log("Opened previous scene: " + activeScenePath);
370+
}
365371
}
366372

367373
private static void AssignDefaultsInScene()
@@ -936,6 +942,8 @@ private static void GenerateActionHelpers(string actionsClassFileName)
936942

937943
CodeArrayCreateExpression actionsOutArray = new CodeArrayCreateExpression(new CodeTypeReference(typeof(SteamVR_Input_Action_Out)));
938944

945+
CodeArrayCreateExpression actionsVibrationArray = new CodeArrayCreateExpression(new CodeTypeReference(typeof(SteamVR_Input_Action_Vibration)));
946+
939947
CodeArrayCreateExpression actionsPoseArray = new CodeArrayCreateExpression(new CodeTypeReference(typeof(SteamVR_Input_Action_Pose)));
940948

941949
CodeArrayCreateExpression actionsSkeletonArray = new CodeArrayCreateExpression(new CodeTypeReference(typeof(SteamVR_Input_Action_Skeleton)));
@@ -1009,6 +1017,8 @@ private static void GenerateActionHelpers(string actionsClassFileName)
10091017
}
10101018
else
10111019
{
1020+
actionsVibrationArray.Initializers.Add(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), codeFriendlyInstanceName));
1021+
10121022
actionsOutArray.Initializers.Add(new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), codeFriendlyInstanceName));
10131023
}
10141024

@@ -1018,6 +1028,7 @@ private static void GenerateActionHelpers(string actionsClassFileName)
10181028
AddAssignStatement(actionsInitMethod, GetCodeFriendlyInstanceName(SteamVR_Input_Generator_Names.actionsFieldName), actionsArray);
10191029
AddAssignStatement(actionsInitMethod, GetCodeFriendlyInstanceName(SteamVR_Input_Generator_Names.actionsInFieldName), actionsInArray);
10201030
AddAssignStatement(actionsInitMethod, GetCodeFriendlyInstanceName(SteamVR_Input_Generator_Names.actionsOutFieldName), actionsOutArray);
1031+
AddAssignStatement(actionsInitMethod, GetCodeFriendlyInstanceName(SteamVR_Input_Generator_Names.actionsVibrationFieldName), actionsVibrationArray);
10211032
AddAssignStatement(actionsInitMethod, GetCodeFriendlyInstanceName(SteamVR_Input_Generator_Names.actionsPoseFieldName), actionsPoseArray);
10221033
AddAssignStatement(actionsInitMethod, GetCodeFriendlyInstanceName(SteamVR_Input_Generator_Names.actionsBooleanFieldName), actionsBooleanArray);
10231034
AddAssignStatement(actionsInitMethod, GetCodeFriendlyInstanceName(SteamVR_Input_Generator_Names.actionsSingleFieldName), actionsSingleArray);
@@ -1323,65 +1334,4 @@ private static CodeConditionStatement CreateStringCompareStatement(CodeMemberMet
13231334

13241335
return condition;
13251336
}
1326-
1327-
private static void CreateManifestFile()
1328-
{
1329-
SteamVR_Input_ManifestFile file = new SteamVR_Input_ManifestFile();
1330-
file.source = "builtin";
1331-
1332-
SteamVR_Input_ManifestFile_Application application = new SteamVR_Input_ManifestFile_Application();
1333-
file.applications.Add(application);
1334-
1335-
string appKey = GetValidIdentifier("com." + PlayerSettings.companyName + "." + PlayerSettings.productName);
1336-
1337-
application.app_key = appKey;
1338-
application.launch_type = "binary";
1339-
application.binary_path_windows = ConvertToForwardSlashes(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
1340-
application.action_manifest_path = ConvertToForwardSlashes(SteamVR_Input.actionsFilePath);
1341-
1342-
SteamVR_Input_ManifestFile_Application_Binding touchBinding = CreateApplicationBindingItem(SteamVR_Input_ManifestFile_Application_Binding_ControllerTypes.oculus_touch);
1343-
SteamVR_Input_ManifestFile_Application_Binding viveBinding = CreateApplicationBindingItem(SteamVR_Input_ManifestFile_Application_Binding_ControllerTypes.vive_controller);
1344-
SteamVR_Input_ManifestFile_Application_Binding knucklesBinding = CreateApplicationBindingItem(SteamVR_Input_ManifestFile_Application_Binding_ControllerTypes.knuckles);
1345-
1346-
application.bindings.Add(touchBinding);
1347-
application.bindings.Add(viveBinding);
1348-
application.bindings.Add(knucklesBinding);
1349-
1350-
application.strings = new Dictionary<string, SteamVR_Input_ManifestFile_ApplicationString>();
1351-
application.strings["en_us"] = new SteamVR_Input_ManifestFile_ApplicationString() { name = PlayerSettings.productName + "[Testing]" };
1352-
1353-
string json = Valve.Newtonsoft.Json.JsonConvert.SerializeObject(file, Valve.Newtonsoft.Json.Formatting.Indented, new Valve.Newtonsoft.Json.JsonSerializerSettings
1354-
{ NullValueHandling = Valve.Newtonsoft.Json.NullValueHandling.Ignore });
1355-
1356-
1357-
string currentPath = Application.dataPath;
1358-
int lastIndex = currentPath.LastIndexOf('/');
1359-
currentPath = currentPath.Remove(lastIndex, currentPath.Length - lastIndex);
1360-
1361-
string fullPath = Path.Combine(currentPath, "example.vrmanifest");
1362-
File.WriteAllText(fullPath, json);
1363-
1364-
Debug.Log("[SteamVR] Wrote example json: " + fullPath);
1365-
}
1366-
1367-
private static SteamVR_Input_ManifestFile_Application_Binding CreateApplicationBindingItem(string controller_type)
1368-
{
1369-
string actionsPath = ConvertToForwardSlashes(SteamVR_Input.actionsFilePath);
1370-
int lastSlash = actionsPath.LastIndexOf('/');
1371-
string path = actionsPath.Substring(0, lastSlash);
1372-
1373-
SteamVR_Input_ManifestFile_Application_Binding binding = new SteamVR_Input_ManifestFile_Application_Binding();
1374-
binding.controller_type = controller_type;
1375-
binding.binding_url = ConvertToForwardSlashes(Path.Combine(path, string.Format("bindings_{0}.json", binding.controller_type)));
1376-
1377-
return binding;
1378-
}
1379-
1380-
private static string ConvertToForwardSlashes(string fromString)
1381-
{
1382-
string newString = fromString.Replace("\\\\", "\\");
1383-
newString = newString.Replace("\\", "/");
1384-
1385-
return newString;
1386-
}
13871337
}

Assets/SteamVR/Input/Editor/SteamVR_Input_PostProcessBuild.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProj
3737

3838
File.Copy(file, newFilePath);
3939

40+
UpdateAppKey(newFilePath, fileInfo.Name);
41+
4042
Debug.Log("[SteamVR] Copied (overwrote) SteamVR Input file at build path: " + newFilePath);
4143
}
4244
else
@@ -47,9 +49,45 @@ public static void OnPostprocessBuild(BuildTarget target, string pathToBuiltProj
4749
else
4850
{
4951
File.Copy(file, newFilePath);
52+
UpdateAppKey(newFilePath, fileInfo.Name);
5053

5154
Debug.Log("[SteamVR] Copied SteamVR Input file to build folder: " + newFilePath);
5255
}
56+
57+
}
58+
}
59+
60+
private static void UpdateAppKey(string newFilePath, string executableName)
61+
{
62+
if (File.Exists(newFilePath))
63+
{
64+
string jsonText = System.IO.File.ReadAllText(newFilePath);
65+
66+
string findString = "\"app_key\" : \"";
67+
int stringStart = jsonText.IndexOf(findString);
68+
69+
if (stringStart == -1)
70+
{
71+
findString = findString.Replace(" ", "");
72+
stringStart = jsonText.IndexOf(findString);
73+
74+
if (stringStart == -1)
75+
return; //no app key
76+
}
77+
78+
stringStart += findString.Length;
79+
int stringEnd = jsonText.IndexOf("\"", stringStart);
80+
81+
int stringLength = stringEnd - stringStart;
82+
83+
string appKey = jsonText.Substring(stringStart, stringLength);
84+
85+
if (string.Equals(appKey, SteamVR_Settings.instance.appKey, System.StringComparison.CurrentCultureIgnoreCase) == false)
86+
{
87+
jsonText = jsonText.Replace(appKey, SteamVR_Settings.instance.appKey);
88+
89+
File.WriteAllText(newFilePath, jsonText);
90+
}
5391
}
5492
}
5593
}

Assets/SteamVR/Input/ExampleJSON/actions.json

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@
2525
"type": "boolean"
2626
},
2727
{
28-
"name": "/actions/default/in/PoseLeftHand",
29-
"type": "pose"
30-
},
31-
{
32-
"name": "/actions/default/in/PoseRightHand",
28+
"name": "/actions/default/in/Pose",
3329
"type": "pose"
3430
},
3531
{
@@ -43,11 +39,7 @@
4339
"skeleton": "/skeleton/hand/right"
4440
},
4541
{
46-
"name": "/actions/default/out/HapticLeftHand",
47-
"type": "vibration"
48-
},
49-
{
50-
"name": "/actions/default/out/HapticRightHand",
42+
"name": "/actions/default/out/Haptic",
5143
"type": "vibration"
5244
}
5345
],
@@ -84,9 +76,11 @@
8476
"/actions/default/in/PoseRightHand": "Pose (Right)",
8577
"/actions/default/in/SkeletonLeftHand": "Skeleton (Left)",
8678
"/actions/default/in/SkeletonRightHand": "Skeleton (Right)",
87-
"/actions/default/out/HapticLeftHand": "Haptic (Left)",
79+
"/actions/default/out/HapticLeftHand": "Haptic",
8880
"/actions/default/out/HapticRightHand": "Haptic (Right)",
89-
"/actions/default/in/Plant": "Plant"
81+
"/actions/default/in/Plant": "Plant",
82+
"/actions/default/in/Pose": "Pose",
83+
"/actions/default/out/Haptic": "Haptic"
9084
}
9185
]
9286
}

Assets/SteamVR/Input/ExampleJSON/bindings_knuckles.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
"chords" : [],
55
"haptics" : [
66
{
7-
"output" : "/actions/default/out/hapticlefthand",
7+
"output" : "/actions/default/out/haptic",
88
"path" : "/user/hand/left/output/haptic"
99
},
1010
{
11-
"output" : "/actions/default/out/hapticrighthand",
11+
"output" : "/actions/default/out/haptic",
1212
"path" : "/user/hand/right/output/haptic"
1313
}
1414
],
1515
"poses" : [
1616
{
17-
"output" : "/actions/default/in/poselefthand",
17+
"output" : "/actions/default/in/pose",
1818
"path" : "/user/hand/left/pose/raw"
1919
},
2020
{
21-
"output" : "/actions/default/in/poserighthand",
21+
"output" : "/actions/default/in/pose",
2222
"path" : "/user/hand/right/pose/raw"
2323
}
2424
],

Assets/SteamVR/Input/ExampleJSON/bindings_oculus_touch.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
"chords" : [],
55
"haptics" : [
66
{
7-
"output" : "/actions/default/out/hapticlefthand",
7+
"output" : "/actions/default/out/haptic",
88
"path" : "/user/hand/left/output/haptic"
99
},
1010
{
11-
"output" : "/actions/default/out/hapticrighthand",
11+
"output" : "/actions/default/out/haptic",
1212
"path" : "/user/hand/right/output/haptic"
1313
}
1414
],
1515
"poses" : [
1616
{
17-
"output" : "/actions/default/in/poselefthand",
17+
"output" : "/actions/default/in/pose",
1818
"path" : "/user/hand/left/pose/raw"
1919
},
2020
{
21-
"output" : "/actions/default/in/poserighthand",
21+
"output" : "/actions/default/in/pose",
2222
"path" : "/user/hand/right/pose/raw"
2323
}
2424
],

Assets/SteamVR/Input/ExampleJSON/bindings_vive_controller.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
"chords" : [],
55
"haptics" : [
66
{
7-
"output" : "/actions/default/out/hapticlefthand",
7+
"output" : "/actions/default/out/haptic",
88
"path" : "/user/hand/left/output/haptic"
99
},
1010
{
11-
"output" : "/actions/default/out/hapticrighthand",
11+
"output" : "/actions/default/out/haptic",
1212
"path" : "/user/hand/right/output/haptic"
1313
}
1414
],
1515
"poses" : [
1616
{
17-
"output" : "/actions/default/in/poselefthand",
17+
"output" : "/actions/default/in/pose",
1818
"path" : "/user/hand/left/pose/raw"
1919
},
2020
{
21-
"output" : "/actions/default/in/poserighthand",
21+
"output" : "/actions/default/in/pose",
2222
"path" : "/user/hand/right/pose/raw"
2323
}
2424
],

Assets/SteamVR/Input/SteamVR_Input.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public static SteamVR_Input_ActionSet[] actionSets
6666

6767
public SteamVR_Input_Action_Skeleton[] instance_actionsSkeleton;
6868

69+
public SteamVR_Input_Action_Vibration[] instance_actionsVibration;
70+
6971
public SteamVR_Input_Action_In[] instance_actionsNonPoseNonSkeletonIn;
7072

7173
public static SteamVR_Input_Action[] actions
@@ -140,6 +142,14 @@ public static SteamVR_Input_Action_Skeleton[] actionsSkeleton
140142
}
141143
}
142144

145+
public static SteamVR_Input_Action_Vibration[] actionsVibration
146+
{
147+
get
148+
{
149+
return SteamVR_Input.instance.instance_actionsVibration;
150+
}
151+
}
152+
143153
public static SteamVR_Input_Action_In[] actionsNonPoseNonSkeletonIn
144154
{
145155
get
@@ -619,7 +629,7 @@ public static T[] GetActions<T>() where T : SteamVR_Input_Action
619629
}
620630
else if (type == typeof(SteamVR_Input_Action_Vibration))
621631
{
622-
return actionsOut.Cast<SteamVR_Input_Action_Vibration>() as T[];
632+
return actionsVibration as T[];
623633
}
624634
else
625635
{
@@ -801,6 +811,7 @@ public class SteamVR_Input_Generator_Names
801811
public const string actionsFieldName = "actions";
802812
public const string actionsInFieldName = "actionsIn";
803813
public const string actionsOutFieldName = "actionsOut";
814+
public const string actionsVibrationFieldName = "actionsVibration";
804815
public const string actionsPoseFieldName = "actionsPose";
805816
public const string actionsBooleanFieldName = "actionsBoolean";
806817
public const string actionsSingleFieldName = "actionsSingle";

Assets/SteamVR/Input/SteamVR_Input_ActionFile.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,10 @@ public class SteamVR_Input_ManifestFile_Application
322322
{
323323
public string app_key;
324324
public string launch_type;
325+
public string url;
325326
public string binary_path_windows;
327+
public string binary_path_linux;
328+
public string binary_path_osx;
326329
public string action_manifest_path;
327330
public List<SteamVR_Input_ManifestFile_Application_Binding> bindings = new List<SteamVR_Input_ManifestFile_Application_Binding>();
328331
public string image_path;

Assets/SteamVR/Input/SteamVR_Input_Action_Pose.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,18 @@ public virtual void UpdateValue(SteamVR_Input_Input_Sources inputSource, bool sk
6666

6767
EVRInputError err = OpenVR.Input.GetPoseActionData(handle, universeOrigin, predictedSecondsFromNow, ref tempPoseActionData, poseActionData_size, SteamVR_Input_Input_Source.GetHandle(inputSource));
6868
if (err != EVRInputError.None)
69-
Debug.LogError("GetPoseActionData error (" + fullPath + "): " + err.ToString() + " handle: " + handle.ToString());
69+
{
70+
if (err == EVRInputError.InvalidHandle)
71+
{
72+
//todo: ignoring this error for now since it throws while the dashboard is up
73+
}
74+
else
75+
{
76+
Debug.LogError("GetPoseActionData error (" + fullPath + "): " + err.ToString() + " handle: " + handle.ToString()); //todo: this should be an error
77+
}
78+
active[inputSource] = false;
79+
return;
80+
}
7081

7182
poseActionData[inputSource] = tempPoseActionData;
7283
active[inputSource] = tempPoseActionData.bActive;

0 commit comments

Comments
 (0)