@@ -518,13 +518,31 @@ private void UpdateSourceState(InteractionSourceState interactionSource, SourceD
518518
519519 InteractionSourceLocation locationData = interactionSource . properties . location ;
520520
521- sourceData . Position . IsAvailable = locationData . TryGetPosition ( out sourceData . Position . CurrentReading ) ;
521+ Vector3 newPosition ;
522+ sourceData . Position . IsAvailable = locationData . TryGetPosition ( out newPosition ) ;
522523 // Using a heuristic for IsSupported, since the APIs don't yet support querying this capability directly.
523524 sourceData . Position . IsSupported |= sourceData . Position . IsAvailable ;
525+ if ( sourceData . Position . IsAvailable )
526+ {
527+ if ( ! ( sourceData . Position . CurrentReading . Equals ( newPosition ) ) )
528+ {
529+ InputManager . Instance . RaiseSourcePositionChanged ( this , sourceData . SourceId , newPosition ) ;
530+ }
531+ }
532+ sourceData . Position . CurrentReading = newPosition ;
524533
525- sourceData . Orientation . IsAvailable = locationData . TryGetOrientation ( out sourceData . Orientation . CurrentReading ) ;
534+ Quaternion newOrientation ;
535+ sourceData . Orientation . IsAvailable = locationData . TryGetOrientation ( out newOrientation ) ;
526536 // Using a heuristic for IsSupported, since the APIs don't yet support querying this capability directly.
527537 sourceData . Orientation . IsSupported |= sourceData . Orientation . IsAvailable ;
538+ if ( sourceData . Orientation . IsAvailable )
539+ {
540+ if ( ! ( sourceData . Orientation . CurrentReading . Equals ( newOrientation ) ) )
541+ {
542+ InputManager . Instance . RaiseSourceOrientationChanged ( this , sourceData . SourceId , newOrientation ) ;
543+ }
544+ }
545+ sourceData . Orientation . CurrentReading = newOrientation ;
528546
529547 sourceData . PointingRay . IsSupported = interactionSource . source . supportsPointing ;
530548 sourceData . PointingRay . IsAvailable = interactionSource . sourceRay . IsValid ( ) ;
@@ -535,15 +553,55 @@ private void UpdateSourceState(InteractionSourceState interactionSource, SourceD
535553
536554 sourceData . Thumbstick . IsSupported = ( gotController && controller . hasThumbstick ) ;
537555 sourceData . Thumbstick . IsAvailable = sourceData . Thumbstick . IsSupported ;
538- sourceData . Thumbstick . CurrentReading = ( sourceData . Thumbstick . IsAvailable ? AxisButton2D . GetThumbstick ( interactionSource ) : default ( AxisButton2D ) ) ;
556+ if ( sourceData . Thumbstick . IsAvailable )
557+ {
558+ AxisButton2D newThumbstick = AxisButton2D . GetThumbstick ( interactionSource ) ;
559+ if ( ( sourceData . Thumbstick . CurrentReading . X != newThumbstick . X ) || ( sourceData . Thumbstick . CurrentReading . Y != newThumbstick . Y ) )
560+ {
561+ InputManager . Instance . RaiseInputXYChanged ( this , sourceData . SourceId , InteractionPressKind . Thumbstick , newThumbstick . X , newThumbstick . Y ) ;
562+ }
563+ sourceData . Thumbstick . CurrentReading = newThumbstick ;
564+ }
565+ else
566+ {
567+ sourceData . Thumbstick . CurrentReading = default ( AxisButton2D ) ;
568+ }
539569
540570 sourceData . Touchpad . IsSupported = ( gotController && controller . hasTouchpad ) ;
541571 sourceData . Touchpad . IsAvailable = sourceData . Touchpad . IsSupported ;
542- sourceData . Touchpad . CurrentReading = ( sourceData . Touchpad . IsAvailable ? TouchpadData . GetTouchpad ( interactionSource ) : default ( TouchpadData ) ) ;
572+ if ( sourceData . Touchpad . IsAvailable )
573+ {
574+ TouchpadData newTouchpad = TouchpadData . GetTouchpad ( interactionSource ) ;
575+ if ( ( sourceData . Touchpad . CurrentReading . AxisButton . X != newTouchpad . AxisButton . X ) || ( sourceData . Touchpad . CurrentReading . AxisButton . Y != newTouchpad . AxisButton . Y ) )
576+ {
577+ InputManager . Instance . RaiseInputXYChanged ( this , sourceData . SourceId , InteractionPressKind . Touchpad , newTouchpad . AxisButton . X , newTouchpad . AxisButton . Y ) ;
578+ }
579+ if ( sourceData . Touchpad . CurrentReading . Touched != newTouchpad . Touched )
580+ {
581+ if ( newTouchpad . Touched )
582+ {
583+ InputManager . Instance . RaiseTouchpadTouched ( this , sourceData . SourceId ) ;
584+ }
585+ else
586+ {
587+ InputManager . Instance . RaiseTouchpadReleased ( this , sourceData . SourceId ) ;
588+ }
589+ }
590+ sourceData . Touchpad . CurrentReading = newTouchpad ;
591+ }
592+ else
593+ {
594+ sourceData . Touchpad . CurrentReading = default ( TouchpadData ) ;
595+ }
543596
544597 sourceData . Trigger . IsSupported = true ; // All input mechanisms support "select" which is considered the same as "trigger".
545598 sourceData . Trigger . IsAvailable = sourceData . Trigger . IsSupported ;
546- sourceData . Trigger . CurrentReading = AxisButton1D . GetTrigger ( interactionSource ) ;
599+ AxisButton1D newTrigger = AxisButton1D . GetTrigger ( interactionSource ) ;
600+ if ( sourceData . Trigger . CurrentReading . PressedValue != newTrigger . PressedValue )
601+ {
602+ InputManager . Instance . RaiseTriggerPressedValueChanged ( this , sourceData . SourceId , newTrigger . PressedValue ) ;
603+ }
604+ sourceData . Trigger . CurrentReading = newTrigger ;
547605
548606 sourceData . Grasp . IsSupported = interactionSource . source . supportsGrasp ;
549607 sourceData . Grasp . IsAvailable = sourceData . Grasp . IsSupported ;
0 commit comments