Skip to content

Commit 4097e6d

Browse files
committed
Tidy/Comment PoseInterface.
1 parent ee0e3bd commit 4097e6d

1 file changed

Lines changed: 45 additions & 4 deletions

File tree

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

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ namespace Unity
1515
{
1616
/// <summary>
1717
/// OSVR Interface, supporting generic callbacks that provide the source path and a Unity-native datatype.
18-
///
19-
/// Note that right now, this doesn't work right.
2018
/// </summary>
2119
public class InterfaceCallbacks : MonoBehaviour
2220
{
@@ -25,12 +23,14 @@ public class InterfaceCallbacks : MonoBehaviour
2523
/// </summary>
2624
public string path;
2725

26+
#region Callback (delegate) types
2827
public delegate void PoseMatrixCallback(string source, Matrix4x4 pose);
2928
public delegate void PoseCallback(string source, Vector3 position, Quaternion rotation);
3029
public delegate void PositionCallback(string source, Vector3 position);
3130
public delegate void OrientationCallback(string source, Quaternion rotation);
3231
public delegate void ButtonCallback(string source, bool pressed);
3332
public delegate void AnalogCallback(string source, float value);
33+
#endregion
3434

3535
void Start()
3636
{
@@ -44,6 +44,8 @@ void OnDestroy()
4444
{
4545
iface = null;
4646
}
47+
48+
#region Generated RegisterCallback overloads and associated data
4749
/* BEGIN GENERATED CODE - unity-generate.lua */
4850
public void RegisterCallback(PoseMatrixCallback callback)
4951
{
@@ -154,34 +156,64 @@ public void RegisterCallback(AnalogCallback callback)
154156
private AnalogCallback analogCallbacks;
155157

156158
/* END GENERATED CODE - unity-generate.lua */
159+
#endregion
157160

158-
159-
161+
#region Private wrapper callbacks/trampolines
162+
/// <summary>
163+
/// Pose (as position and orientation) wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes, including coordinate system conversion.
164+
/// </summary>
165+
/// <param name="userdata">Unused</param>
166+
/// <param name="timestamp">Unused</param>
167+
/// <param name="report">Tracker pose report</param>
160168
private void PoseCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.PoseReport report)
161169
{
162170
Vector3 position = Math.ConvertPosition(report.pose.translation);
163171
Quaternion rotation = Math.ConvertOrientation(report.pose.rotation);
164172
poseCallbacks(path, position, rotation);
165173
}
166174

175+
/// <summary>
176+
/// Pose (as a 4x4 matrix) wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes, including coordinate system conversion.
177+
/// </summary>
178+
/// <param name="userdata">Unused</param>
179+
/// <param name="timestamp">Unused</param>
180+
/// <param name="report">Tracker pose report</param>
167181
private void PoseMatrixCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.PoseReport report)
168182
{
169183
Matrix4x4 matPose = Math.ConvertPose(report.pose);
170184
poseMatrixCallbacks(path, matPose);
171185
}
172186

187+
/// <summary>
188+
/// Position wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes, including coordinate system conversion.
189+
/// </summary>
190+
/// <param name="userdata">Unused</param>
191+
/// <param name="timestamp">Unused</param>
192+
/// <param name="report">Tracker position report</param>
173193
private void PositionCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.PositionReport report)
174194
{
175195
Vector3 position = Math.ConvertPosition(report.xyz);
176196
positionCallbacks(path, position);
177197
}
178198

199+
/// <summary>
200+
/// Orientation wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes, including coordinate system conversion.
201+
/// </summary>
202+
/// <param name="userdata">Unused</param>
203+
/// <param name="timestamp">Unused</param>
204+
/// <param name="report">Tracker orientation report</param>
179205
private void OrientationCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.OrientationReport report)
180206
{
181207
Quaternion rotation = Math.ConvertOrientation(report.rotation);
182208
orientationCallbacks(path, rotation);
183209
}
184210

211+
/// <summary>
212+
/// Button wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes.
213+
/// </summary>
214+
/// <param name="userdata">Unused</param>
215+
/// <param name="timestamp">Unused</param>
216+
/// <param name="report">Button report</param>
185217
private void ButtonCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.ButtonReport report)
186218
{
187219
bool pressed = (report.state == 1);
@@ -191,13 +223,22 @@ private void ButtonCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue times
191223
}
192224
}
193225

226+
/// <summary>
227+
/// Analog wrapper callback, interfacing Managed-OSVR's signatures and more Unity-native datatypes.
228+
/// </summary>
229+
/// <param name="userdata">Unused</param>
230+
/// <param name="timestamp">Unused</param>
231+
/// <param name="report">Analog report</param>
194232
private void AnalogCb(System.IntPtr userdata, ref OSVR.ClientKit.TimeValue timestamp, ref OSVR.ClientKit.AnalogReport report)
195233
{
196234
float val = (float)report.state;
197235
analogCallbacks(path, val);
198236
}
237+
#endregion
199238

239+
#region Private variables
200240
private OSVR.ClientKit.Interface iface;
241+
#endregion
201242
}
202243
}
203244
}

0 commit comments

Comments
 (0)