AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
HapticsTest.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using UnityEngine;
6 
7 namespace HoloToolkit.Unity.Tests
8 {
9  [RequireComponent(typeof(SetGlobalListener))]
10  public class HapticsTest : MonoBehaviour, IInputHandler
11  {
13  {
15  if (inputSource != null)
16  {
17  switch (eventData.PressType)
18  {
19  case InteractionSourcePressInfo.Grasp:
20  inputSource.StartHaptics(eventData.SourceId, 1.0f);
21  return;
23  inputSource.StartHaptics(eventData.SourceId, 1.0f, 1.0f);
24  return;
25  }
26  }
27  }
28 
29  void IInputHandler.OnInputUp(InputEventData eventData)
30  {
32  if (inputSource != null)
33  {
34  if (eventData.PressType == InteractionSourcePressInfo.Grasp)
35  {
36  inputSource.StopHaptics(eventData.SourceId);
37  }
38  }
39  }
40  }
41 }
Input source for gestures and interaction source information from the WSA APIs, which gives access to...
uint SourceId
The id of the source the event is from, for instance the hand id.
IInputSource InputSource
The source the input event originates from.
void OnInputUp(InputEventData eventData)
Register this game object on the InputManager as a global listener.
InteractionSourcePressInfo PressType
Button type that initiated the event.
Interface to implement to react to simple pointer-like input.
Describes an input event that has a source id and a press kind.
void OnInputDown(InputEventData eventData)