/// <inheritdoc/> void IMixedRealityPointerHandler.OnPointerUp(MixedRealityPointerEventData eventData) { if (!this.SimulateTouchWithPointers || eventData.EventHandled || eventData.CurrentTarget != this.Owner || this.simulatedPointerEventData?.Cursor != eventData.Cursor) { return; } this.simulatedPointerEventData = eventData; this.simulatePressState = PressSimulationState.Releasing; }
/// <inheritdoc/> protected override void Update(TimeSpan gameTime) { if (this.forceRunTouchCompletedEventData != null) { if (this.delayedFrames++ == 2) { this.DoTouchCompleted(this.forceRunTouchCompletedEventData); this.forceRunTouchCompletedEventData = null; this.delayedFrames = 0; } } switch (this.simulatePressState) { default: return; case PressSimulationState.Pressing: this.simulatedPressAmount += (float)(gameTime.TotalSeconds / this.SimulatedPressDuration.TotalSeconds); break; case PressSimulationState.Releasing: this.simulatedPressAmount -= (float)(gameTime.TotalSeconds / this.SimulatedPressDuration.TotalSeconds); break; } this.simulatedPressAmount = MathHelper.Clamp(this.simulatedPressAmount, 0, 1); var cursor = this.simulatedPointerEventData.Cursor; if (this.simulatedPressAmount > 0) { var localPressPosition = this.GetSimulatedPressStepPosition(this.simulatedPointerEventData.Position, this.simulatedPressAmount); this.TouchUpdate(cursor, localPressPosition); } else { this.simulatedPointerEventData = null; this.simulatePressState = PressSimulationState.None; this.TouchComplete(cursor); } }
/// <inheritdoc/> void IMixedRealityPointerHandler.OnPointerDown(MixedRealityPointerEventData eventData) { if (!this.SimulateTouchWithPointers || eventData.EventHandled || eventData.CurrentTarget != this.Owner) { return; } if (eventData.Cursor is CursorTouch || (this.simulatePressState != PressSimulationState.None && this.simulatedPointerEventData?.Cursor != eventData.Cursor)) { return; } this.simulatePressState = PressSimulationState.Pressing; this.simulatedPointerEventData = eventData; var localPressPosition = this.GetSimulatedPressStepPosition(eventData.Position, 0); this.TouchStart(eventData.Cursor, localPressPosition); }