Skip to content

Commit 0589d62

Browse files
DuFF14rpavlik
authored andcommitted
VRHead will now ping DisplayInterface in Update if DisplayInterface hasn't read from /display yet.
Removed filename from device descriptor.
1 parent 0b6fc7c commit 0589d62

5 files changed

Lines changed: 34 additions & 28 deletions

File tree

OSVR-Unity/Assets/OSVRUnity/src/DeviceDescriptor.cs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@
3030

3131
public class DeviceDescriptor
3232
{
33-
34-
//filename
35-
private string _fileName = "";
36-
public string FileName
37-
{
38-
get { return _fileName; }
39-
set { _fileName = value; }
40-
}
4133
//hmd
4234
private string _vendor = "";
4335
public string Vendor
@@ -173,11 +165,10 @@ public int Rotate180
173165

174166
//constructors
175167
public DeviceDescriptor() { }
176-
public DeviceDescriptor(string fileName, string vendor, string model, string version, int numDisplays, string note, float monocularHorizontal,
168+
public DeviceDescriptor(string vendor, string model, string version, int numDisplays, string note, float monocularHorizontal,
177169
float monocularVertical, float overlapPercent, float pitchTilt, int width, int height, int videoInputs, string displayMode, float k1Red,
178170
float k1Green, float k1Blue, float leftRoll, float rightRoll, float centerProjX, float centerProjY, int rotate180)
179171
{
180-
this._fileName = fileName;
181172
this._vendor = vendor;
182173
this._model = model;
183174
this._version = version;
@@ -203,15 +194,9 @@ public DeviceDescriptor(string fileName, string vendor, string model, string ver
203194

204195
public override string ToString()
205196
{
206-
207-
if (FileName.Equals(""))
208-
{
209-
return "No json file has been provided.";
210-
}
211197
//print
212198
StringBuilder jsonPrinter = new StringBuilder(64);
213199
jsonPrinter.AppendLine("Json File Device Description:")
214-
.Append("filename = ").AppendLine(FileName)
215200
.Append("HMD\n")
216201
.Append("vendor = ").AppendLine(Vendor)
217202
.Append("model = ").AppendLine(Model)

OSVR-Unity/Assets/OSVRUnity/src/DisplayInterface.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ public class DisplayInterface : MonoBehaviour
3838
{
3939
private string _deviceDescriptorJson; //a string that is the JSON file to be parsed
4040

41-
//TODO: remove this field. It was added when external JSON files were being loaded rather than
42-
//being read from /display. _initalized exists to make sure display config has been parsed before trying to read it
43-
//this probably isn't necessary anymore now that it comes from /display, but leaving this here for now just to be safe.
41+
//_initalized exists to make sure the display config has been parsed before trying to read it
4442
public bool Initialized
4543
{
4644
get { return _initialized; }
@@ -49,8 +47,21 @@ public bool Initialized
4947

5048
void Start()
5149
{
52-
_deviceDescriptorJson = ClientKit.instance.context.getStringParameter("/display");
53-
_initialized = true;
50+
ReadDisplayPath();
51+
}
52+
53+
//this function attemtps to retrieve display configuration from the /display path
54+
//this data is in JSON format. Once it has initialized, the data is used to configure Camera and other settings.
55+
public void ReadDisplayPath()
56+
{
57+
if (!_initialized)
58+
{
59+
_deviceDescriptorJson = ClientKit.instance.context.getStringParameter("/display");
60+
if (_deviceDescriptorJson != "")
61+
{
62+
_initialized = true;
63+
}
64+
}
5465
}
5566

5667
/// <summary>

OSVR-Unity/Assets/OSVRUnity/src/VRHead.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,24 @@ void Start()
8080
#region Loop
8181
void Update()
8282
{
83-
//make sure we have display config info from /display.
84-
if(!_initDisplayInterface && GetComponent<DisplayInterface>().Initialized)
83+
84+
if(!_initDisplayInterface && !GetComponent<DisplayInterface>().Initialized)
85+
{
86+
//if the display configuration hasn't initialized, ping the DisplayInterface to retrieve it from the ClientKit
87+
//this would mean DisplayInterface was unable to retrieve that data in its Start() function.
88+
GetComponent<DisplayInterface>().ReadDisplayPath();
89+
}
90+
else if (!_initDisplayInterface && GetComponent<DisplayInterface>().Initialized)
8591
{
92+
//once the DisplayInterface has initialized, meaning it has read data from the /display path which contains
93+
//display configuration, update the Camera and other settings with properties from the display configuration.
8694
UpdateDisplayInterface();
8795
}
88-
UpdateStereoAmount();
89-
UpdateViewMode();
96+
else if (_initDisplayInterface)
97+
{
98+
UpdateStereoAmount();
99+
UpdateViewMode();
100+
}
90101
}
91102
#endregion
92103

@@ -198,7 +209,6 @@ private void GetDeviceDescription()
198209
_deviceDescriptor = GetComponent<DisplayInterface>().GetDeviceDescription();
199210
if (_deviceDescriptor != null)
200211
{
201-
Debug.Log(_deviceDescriptor.ToString());
202212
switch (_deviceDescriptor.DisplayMode)
203213
{
204214
case "full_screen":
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.2-1-g0f15a69
1+
v0.2-5-g1d72171

OSVR-Unity/Assets/Plugins/osvr-ver.txt.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.

0 commit comments

Comments
 (0)