@@ -93,7 +93,11 @@ public virtual void UpdateController(InputDevice inputDevice)
93
93
94
94
protected virtual void UpdateSixDofData ( InputDevice inputDevice )
95
95
{
96
- UpdateSourceData ( inputDevice ) ;
96
+ if ( ! UpdateSourceData ( inputDevice ) )
97
+ {
98
+ return ;
99
+ }
100
+
97
101
UpdateVelocity ( inputDevice ) ;
98
102
99
103
if ( TrackingState == TrackingState . Tracked && LastControllerPose != CurrentControllerPose )
@@ -129,33 +133,43 @@ protected virtual void UpdateSixDofData(InputDevice inputDevice)
129
133
/// Update the source input from the device.
130
134
/// </summary>
131
135
/// <param name="inputDevice">The InputDevice retrieved from the platform.</param>
132
- public void UpdateSourceData ( InputDevice inputDevice )
136
+ /// <returns>Whether position or rotation was successfully updated.</returns>
137
+ public bool UpdateSourceData ( InputDevice inputDevice )
133
138
{
134
139
using ( UpdateSourceDataPerfMarker . Auto ( ) )
135
140
{
136
- var lastState = TrackingState ;
141
+ TrackingState lastState = TrackingState ;
137
142
LastControllerPose = CurrentControllerPose ;
138
143
139
144
// Check for position and rotation.
140
- IsPositionAvailable = inputDevice . TryGetFeatureValue ( CommonUsages . devicePosition , out CurrentControllerPosition ) ;
141
- IsPositionApproximate = false ;
145
+ bool isPositionAvailable = inputDevice . TryGetFeatureValue ( CommonUsages . devicePosition , out Vector3 position ) ;
146
+ bool isRotationAvailable = inputDevice . TryGetFeatureValue ( CommonUsages . deviceRotation , out Quaternion rotation ) ;
142
147
143
- IsRotationAvailable = inputDevice . TryGetFeatureValue ( CommonUsages . deviceRotation , out CurrentControllerRotation ) ;
148
+ if ( isPositionAvailable || isRotationAvailable )
149
+ {
150
+ IsPositionAvailable = isPositionAvailable ;
151
+ IsPositionApproximate = false ;
152
+ IsRotationAvailable = isRotationAvailable ;
144
153
145
- // Devices are considered tracked if we receive position OR rotation data from the sensors.
146
- TrackingState = ( IsPositionAvailable || IsRotationAvailable ) ? TrackingState . Tracked : TrackingState . NotTracked ;
154
+ // Devices are considered tracked if we receive position OR rotation data from the sensors.
155
+ TrackingState = ( IsPositionAvailable || IsRotationAvailable ) ? TrackingState . Tracked : TrackingState . NotTracked ;
147
156
148
- CurrentControllerPosition = MixedRealityPlayspace . TransformPoint ( CurrentControllerPosition ) ;
149
- CurrentControllerRotation = MixedRealityPlayspace . Rotation * CurrentControllerRotation ;
157
+ CurrentControllerPosition = MixedRealityPlayspace . TransformPoint ( position ) ;
158
+ CurrentControllerRotation = MixedRealityPlayspace . Rotation * rotation ;
150
159
151
- CurrentControllerPose . Position = CurrentControllerPosition ;
152
- CurrentControllerPose . Rotation = CurrentControllerRotation ;
160
+ CurrentControllerPose . Position = CurrentControllerPosition ;
161
+ CurrentControllerPose . Rotation = CurrentControllerRotation ;
153
162
154
- // Raise input system events if it is enabled.
155
- if ( lastState != TrackingState )
156
- {
157
- CoreServices . InputSystem ? . RaiseSourceTrackingStateChanged ( InputSource , this , TrackingState ) ;
163
+ // Raise input system events if it is enabled.
164
+ if ( lastState != TrackingState )
165
+ {
166
+ CoreServices . InputSystem ? . RaiseSourceTrackingStateChanged ( InputSource , this , TrackingState ) ;
167
+ }
168
+
169
+ return true ;
158
170
}
171
+
172
+ return false ;
159
173
}
160
174
}
161
175
@@ -165,13 +179,12 @@ public void UpdateVelocity(InputDevice inputDevice)
165
179
{
166
180
using ( UpdateVelocityPerfMarker . Auto ( ) )
167
181
{
168
- Vector3 newVelocity ;
169
- if ( inputDevice . TryGetFeatureValue ( CommonUsages . deviceVelocity , out newVelocity ) )
182
+ if ( inputDevice . TryGetFeatureValue ( CommonUsages . deviceVelocity , out Vector3 newVelocity ) )
170
183
{
171
184
Velocity = newVelocity ;
172
185
}
173
- Vector3 newAngularVelocity ;
174
- if ( inputDevice . TryGetFeatureValue ( CommonUsages . deviceAngularVelocity , out newAngularVelocity ) )
186
+
187
+ if ( inputDevice . TryGetFeatureValue ( CommonUsages . deviceAngularVelocity , out Vector3 newAngularVelocity ) )
175
188
{
176
189
AngularVelocity = newAngularVelocity ;
177
190
}
0 commit comments